@verisoft/ui-primeng 20.0.0 → 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 +43 -0
- package/assets/.gitkeep +0 -0
- package/jest.config.ts +22 -0
- package/ng-package.json +14 -0
- package/package.json +6 -18
- package/project.json +36 -0
- package/src/index.ts +34 -0
- package/src/lib/components/breadcrumb/breadcrumb.component.html +11 -0
- package/src/lib/components/breadcrumb/breadcrumb.component.scss +18 -0
- package/src/lib/components/breadcrumb/breadcrumb.component.spec.ts +21 -0
- package/src/lib/components/breadcrumb/breadcrumb.component.stories.ts +36 -0
- package/src/lib/components/breadcrumb/breadcrumb.component.ts +27 -0
- package/src/lib/components/breadcrumb/breadcrumb.pipe.ts +13 -0
- package/src/lib/components/breadcrumb/index.ts +1 -0
- package/src/lib/components/button/button-severity.pipe.ts +20 -0
- package/src/lib/components/button/button.component.html +20 -0
- package/src/lib/components/button/button.component.scss +0 -0
- package/src/lib/components/button/button.component.spec.ts +21 -0
- package/src/lib/components/button/button.component.ts +49 -0
- package/src/lib/components/button/index.ts +1 -0
- package/src/lib/components/calendar/calendar.component.html +53 -0
- package/src/lib/components/calendar/calendar.component.scss +0 -0
- package/src/lib/components/calendar/calendar.component.spec.ts +21 -0
- package/src/lib/components/calendar/calendar.component.ts +70 -0
- package/src/lib/components/calendar/index.ts +1 -0
- package/src/lib/components/checkbox/checkbox.component.html +20 -0
- package/src/lib/components/checkbox/checkbox.component.scss +15 -0
- package/src/lib/components/checkbox/checkbox.component.spec.ts +21 -0
- package/src/lib/components/checkbox/checkbox.component.stories.ts +72 -0
- package/src/lib/components/checkbox/checkbox.component.ts +46 -0
- package/src/lib/components/checkbox/index.ts +1 -0
- package/src/lib/components/confirm-dialog/confirm-dialog.component.html +51 -0
- package/src/lib/components/confirm-dialog/confirm-dialog.component.scss +3 -0
- package/src/lib/components/confirm-dialog/confirm-dialog.component.spec.ts +21 -0
- package/src/lib/components/confirm-dialog/confirm-dialog.component.stories.ts +74 -0
- package/src/lib/components/confirm-dialog/confirm-dialog.component.ts +73 -0
- package/src/lib/components/confirm-dialog/index.ts +1 -0
- package/src/lib/components/dropdown/dropdown.component.html +93 -0
- package/src/lib/components/dropdown/dropdown.component.scss +16 -0
- package/src/lib/components/dropdown/dropdown.component.spec.ts +21 -0
- package/src/lib/components/dropdown/dropdown.component.ts +139 -0
- package/src/lib/components/dropdown/index.ts +1 -0
- package/src/lib/components/dropdown-button/dropdown-button.component.html +1 -0
- package/src/lib/components/dropdown-button/dropdown-button.component.ts +20 -0
- package/src/lib/components/dropdown-button/index.ts +1 -0
- package/src/lib/components/errors/error.component.html +7 -0
- package/src/lib/components/errors/error.component.scss +3 -0
- package/src/lib/components/errors/error.component.ts +34 -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 +21 -0
- package/src/lib/components/feature-list/feature-list-page.component.ts +32 -0
- package/src/lib/components/feature-list/feature-list-page.model.ts +42 -0
- package/src/lib/components/feature-list/feature-list.component.html +59 -0
- package/src/lib/components/feature-list/feature-list.component.scss +10 -0
- package/src/lib/components/feature-list/feature-list.component.ts +341 -0
- package/src/lib/components/feature-list/index.ts +5 -0
- package/src/lib/components/filter/directives/filter-field.directive.ts +34 -0
- package/src/lib/components/filter/filter.component.html +68 -0
- package/src/lib/components/filter/filter.component.scss +0 -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 +281 -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 +42 -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.stories.ts +69 -0
- package/src/lib/components/form-field/form-field.component.ts +37 -0
- package/src/lib/components/form-field/index.ts +1 -0
- package/src/lib/components/header/header.component.html +84 -0
- package/src/lib/components/header/header.component.scss +0 -0
- package/src/lib/components/header/header.component.spec.ts +21 -0
- package/src/lib/components/header/header.component.stories.ts +24 -0
- package/src/lib/components/header/header.component.ts +65 -0
- package/src/lib/components/header/index.ts +2 -0
- package/src/lib/components/header/services/header-provider.service.ts +15 -0
- package/src/lib/components/icon/icon.component.html +2 -0
- package/src/lib/components/icon/icon.component.scss +51 -0
- package/src/lib/components/icon/icon.component.ts +86 -0
- package/src/lib/components/icon/index.ts +2 -0
- package/src/lib/components/input-group/index.ts +1 -0
- package/src/lib/components/input-group/input-group.component.html +34 -0
- package/src/lib/components/input-group/input-group.component.spec.ts +21 -0
- package/src/lib/components/input-group/input-group.component.ts +58 -0
- package/src/lib/components/loader/index.ts +1 -0
- package/src/lib/components/loader/loader.component.html +5 -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 +16 -0
- package/src/lib/components/multiselect/index.ts +1 -0
- package/src/lib/components/multiselect/multiselect.component.html +67 -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 +120 -0
- package/src/lib/components/number-input/index.ts +1 -0
- package/src/lib/components/number-input/number-input.component.html +22 -0
- package/src/lib/components/number-input/number-input.component.spec.ts +21 -0
- package/src/lib/components/number-input/number-input.component.ts +55 -0
- package/src/lib/components/page-header/index.ts +1 -0
- package/src/lib/components/page-header/page-header.component.html +35 -0
- package/src/lib/components/page-header/page-header.component.scss +0 -0
- package/src/lib/components/page-header/page-header.component.spec.ts +21 -0
- package/src/lib/components/page-header/page-header.component.ts +31 -0
- package/src/lib/components/password/index.ts +1 -0
- package/src/lib/components/password/password.component.html +24 -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 +56 -0
- package/src/lib/components/radiobutton/index.ts +1 -0
- package/src/lib/components/radiobutton/radiobutton.component.html +34 -0
- package/src/lib/components/radiobutton/radiobutton.component.scss +6 -0
- package/src/lib/components/radiobutton/radiobutton.component.spec.ts +21 -0
- package/src/lib/components/radiobutton/radiobutton.component.stories.ts +71 -0
- package/src/lib/components/radiobutton/radiobutton.component.ts +61 -0
- package/src/lib/components/section/index.ts +1 -0
- package/src/lib/components/section/section.component.html +25 -0
- package/src/lib/components/section/section.component.scss +0 -0
- package/src/lib/components/section/section.component.spec.ts +21 -0
- package/src/lib/components/section/section.component.ts +31 -0
- package/src/lib/components/shared-components/.eslintrc.json +42 -0
- package/src/lib/components/shared-components/action-button-group/action-button-group.component.html +25 -0
- package/src/lib/components/shared-components/action-button-group/action-button-group.component.scss +0 -0
- package/src/lib/components/shared-components/action-button-group/action-button-group.component.spec.ts +21 -0
- package/src/lib/components/shared-components/action-button-group/action-button-group.component.ts +111 -0
- package/src/lib/components/shared-components/action-button-group/components/action-button/action-button.component.html +10 -0
- package/src/lib/components/shared-components/action-button-group/components/action-button/action-button.component.scss +0 -0
- package/src/lib/components/shared-components/action-button-group/components/action-button/action-button.component.spec.ts +21 -0
- package/src/lib/components/shared-components/action-button-group/components/action-button/action-button.component.ts +69 -0
- package/src/lib/components/shared-components/action-button-group/index.ts +2 -0
- package/src/lib/components/shared-components/dynamic-component/dynamic-component-factory.service.ts +142 -0
- package/src/lib/components/shared-components/dynamic-component/dynamic-component.component.ts +56 -0
- package/src/lib/components/shared-components/dynamic-component/index.ts +2 -0
- package/src/lib/components/shared-components/generic-field/generic-field.component.html +98 -0
- package/src/lib/components/shared-components/generic-field/generic-field.component.spec.ts +21 -0
- package/src/lib/components/shared-components/generic-field/generic-field.component.ts +90 -0
- package/src/lib/components/shared-components/generic-field/index.ts +1 -0
- package/src/lib/components/shared-components/generic-form/generic-form.component.html +46 -0
- package/src/lib/components/shared-components/generic-form/generic-form.component.spec.ts +21 -0
- package/src/lib/components/shared-components/generic-form/generic-form.component.ts +56 -0
- package/src/lib/components/shared-components/generic-form/generic-form.model.spec.ts +82 -0
- package/src/lib/components/shared-components/generic-form/generic-form.model.ts +68 -0
- package/src/lib/components/shared-components/generic-form/index.ts +2 -0
- package/src/lib/components/shared-components/index.ts +4 -0
- package/src/lib/components/side-menu/index.ts +2 -0
- package/src/lib/components/side-menu/side-menu.component.html +53 -0
- package/src/lib/components/side-menu/side-menu.component.scss +0 -0
- package/src/lib/components/side-menu/side-menu.component.spec.ts +21 -0
- package/src/lib/components/side-menu/side-menu.component.ts +96 -0
- package/src/lib/components/side-menu/side-menu.module.ts +66 -0
- package/src/lib/components/slider/index.ts +1 -0
- package/src/lib/components/slider/slider.component.html +19 -0
- package/src/lib/components/slider/slider.component.spec.ts +21 -0
- package/src/lib/components/slider/slider.component.ts +56 -0
- package/src/lib/components/snackbar/index.ts +2 -0
- package/src/lib/components/snackbar/services/snackbar.service.ts +45 -0
- package/src/lib/components/snackbar/snackbar.component.html +3 -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.stories.ts +70 -0
- package/src/lib/components/snackbar/snackbar.component.ts +25 -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.spec.ts +21 -0
- package/src/lib/components/stepper/stepper.component.ts +39 -0
- package/src/lib/components/switch/index.ts +1 -0
- package/src/lib/components/switch/switch.component.html +18 -0
- package/src/lib/components/switch/switch.component.scss +0 -0
- package/src/lib/components/switch/switch.component.spec.ts +21 -0
- package/src/lib/components/switch/switch.component.stories.ts +65 -0
- package/src/lib/components/switch/switch.component.ts +52 -0
- package/src/lib/components/tab-view/index.ts +2 -0
- package/src/lib/components/tab-view/tab-view-item.component.ts +22 -0
- package/src/lib/components/tab-view/tab-view.component.html +41 -0
- package/src/lib/components/tab-view/tab-view.component.ts +55 -0
- package/src/lib/components/table/index.ts +1 -0
- package/src/lib/components/table/table-filter.pipe.ts +59 -0
- package/src/lib/components/table/table.component.html +127 -0
- package/src/lib/components/table/table.component.scss +11 -0
- package/src/lib/components/table/table.component.spec.ts +21 -0
- package/src/lib/components/table/table.component.stories.ts +55 -0
- package/src/lib/components/table/table.component.ts +288 -0
- package/src/lib/components/table/table.models.ts +26 -0
- package/src/lib/components/tag/index.ts +2 -0
- package/src/lib/components/tag/tag.component.html +12 -0
- package/src/lib/components/tag/tag.component.scss +33 -0
- package/src/lib/components/tag/tag.component.ts +83 -0
- package/src/lib/components/textarea/index.ts +1 -0
- package/src/lib/components/textarea/textarea.component.html +40 -0
- package/src/lib/components/textarea/textarea.component.scss +5 -0
- package/src/lib/components/textarea/textarea.component.spec.ts +21 -0
- package/src/lib/components/textarea/textarea.component.stories.ts +98 -0
- package/src/lib/components/textarea/textarea.component.ts +62 -0
- package/src/lib/components/textfield/index.ts +1 -0
- package/src/lib/components/textfield/textfield.component.html +82 -0
- package/src/lib/components/textfield/textfield.component.scss +23 -0
- package/src/lib/components/textfield/textfield.component.spec.ts +21 -0
- package/src/lib/components/textfield/textfield.component.stories.ts +85 -0
- package/src/lib/components/textfield/textfield.component.ts +68 -0
- package/src/lib/components/tooltip/index.ts +1 -0
- package/src/lib/components/tooltip/tooltip.component.html +3 -0
- package/src/lib/components/tooltip/tooltip.component.ts +17 -0
- package/src/lib/icons.ts +36 -0
- package/src/lib/interceptors/http-error-message.interceptor.ts +35 -0
- package/src/lib/pages/not-found-page/not-found-page.component.html +26 -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.spec.ts +21 -0
- package/src/lib/pages/not-found-page/not-found-page.component.ts +16 -0
- package/src/tab-view.ts +1 -0
- package/src/test-setup.ts +8 -0
- package/tsconfig.json +29 -0
- package/tsconfig.lib.json +18 -0
- package/tsconfig.lib.prod.json +9 -0
- package/tsconfig.spec.json +16 -0
- package/fesm2022/verisoft-ui-primeng.mjs +0 -2866
- package/fesm2022/verisoft-ui-primeng.mjs.map +0 -1
- package/index.d.ts +0 -729
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
import { TableComponent } from './table.component';
|
|
3
|
+
|
|
4
|
+
describe('TableComponent', () => {
|
|
5
|
+
let component: TableComponent<any>;
|
|
6
|
+
let fixture: ComponentFixture<TableComponent<any>>;
|
|
7
|
+
|
|
8
|
+
beforeEach(async () => {
|
|
9
|
+
await TestBed.configureTestingModule({
|
|
10
|
+
imports: [TableComponent],
|
|
11
|
+
}).compileComponents();
|
|
12
|
+
|
|
13
|
+
fixture = TestBed.createComponent(TableComponent);
|
|
14
|
+
component = fixture.componentInstance;
|
|
15
|
+
fixture.detectChanges();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('should create', () => {
|
|
19
|
+
expect(component).toBeTruthy();
|
|
20
|
+
});
|
|
21
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/angular';
|
|
2
|
+
import { within, expect } from '@storybook/test';
|
|
3
|
+
import { DEFAULT_SEARCH_LIMIT } from '@verisoft/core';
|
|
4
|
+
import { TableComponent } from './table.component';
|
|
5
|
+
|
|
6
|
+
const meta: Meta<TableComponent<any>> = {
|
|
7
|
+
component: TableComponent,
|
|
8
|
+
title: 'TableComponent',
|
|
9
|
+
};
|
|
10
|
+
export default meta;
|
|
11
|
+
type Story = StoryObj<TableComponent<any>>;
|
|
12
|
+
|
|
13
|
+
export const Primary: Story = {
|
|
14
|
+
args: {
|
|
15
|
+
tableRepository: '',
|
|
16
|
+
total: 0,
|
|
17
|
+
loading: false,
|
|
18
|
+
scrollHeight: '100%',
|
|
19
|
+
scrollable: true,
|
|
20
|
+
pageSize: DEFAULT_SEARCH_LIMIT,
|
|
21
|
+
currentPage: 0,
|
|
22
|
+
showPaginator: true,
|
|
23
|
+
sortMultiple: false,
|
|
24
|
+
lazy: true,
|
|
25
|
+
multipleSelect: false,
|
|
26
|
+
autoIndex: false,
|
|
27
|
+
showPageSizePicker: true,
|
|
28
|
+
entityId: '',
|
|
29
|
+
columnDefinitions: [],
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const Heading: Story = {
|
|
34
|
+
args: {
|
|
35
|
+
tableRepository: '',
|
|
36
|
+
total: 0,
|
|
37
|
+
loading: false,
|
|
38
|
+
scrollHeight: '100%',
|
|
39
|
+
scrollable: true,
|
|
40
|
+
pageSize: DEFAULT_SEARCH_LIMIT,
|
|
41
|
+
currentPage: 0,
|
|
42
|
+
showPaginator: true,
|
|
43
|
+
sortMultiple: false,
|
|
44
|
+
lazy: true,
|
|
45
|
+
multipleSelect: false,
|
|
46
|
+
autoIndex: false,
|
|
47
|
+
showPageSizePicker: true,
|
|
48
|
+
entityId: '',
|
|
49
|
+
columnDefinitions: [],
|
|
50
|
+
},
|
|
51
|
+
play: async ({ canvasElement }: any) => {
|
|
52
|
+
const canvas = within(canvasElement);
|
|
53
|
+
expect(canvas.getByText(/verisoft-table works!/gi)).toBeTruthy();
|
|
54
|
+
},
|
|
55
|
+
};
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
import { CommonModule } from '@angular/common';
|
|
2
|
+
import {
|
|
3
|
+
AfterViewInit,
|
|
4
|
+
ChangeDetectionStrategy,
|
|
5
|
+
ChangeDetectorRef,
|
|
6
|
+
Component,
|
|
7
|
+
ContentChild,
|
|
8
|
+
ContentChildren,
|
|
9
|
+
EventEmitter,
|
|
10
|
+
inject,
|
|
11
|
+
Input,
|
|
12
|
+
OnChanges,
|
|
13
|
+
Output,
|
|
14
|
+
QueryList,
|
|
15
|
+
SimpleChanges,
|
|
16
|
+
TemplateRef,
|
|
17
|
+
ViewChild,
|
|
18
|
+
ViewEncapsulation,
|
|
19
|
+
} from '@angular/core';
|
|
20
|
+
import { ActivatedRoute, Router, RouterModule } from '@angular/router';
|
|
21
|
+
import {
|
|
22
|
+
DEFAULT_SEARCH_LIMIT,
|
|
23
|
+
LazyLoadEvent,
|
|
24
|
+
Sort,
|
|
25
|
+
SortDirection,
|
|
26
|
+
SortDirectionType,
|
|
27
|
+
} from '@verisoft/core';
|
|
28
|
+
import {
|
|
29
|
+
ColumnDefinition,
|
|
30
|
+
ColumnModel,
|
|
31
|
+
ColumnProvider,
|
|
32
|
+
RowModel,
|
|
33
|
+
TABLE_COLUMN_PROVIDER,
|
|
34
|
+
TABLE_COMPONENT_TOKEN,
|
|
35
|
+
TableCore,
|
|
36
|
+
TableSelectionModeType,
|
|
37
|
+
} from '@verisoft/ui-core';
|
|
38
|
+
import { SortMeta } from 'primeng/api';
|
|
39
|
+
import { ButtonModule } from 'primeng/button';
|
|
40
|
+
import { RippleModule } from 'primeng/ripple';
|
|
41
|
+
import { Table, TableLazyLoadEvent, TableModule, TablePageEvent } from 'primeng/table';
|
|
42
|
+
import { Icons } from '../../icons';
|
|
43
|
+
import { TableFilterPipe } from './table-filter.pipe';
|
|
44
|
+
import { convertToFilter } from './table.models';
|
|
45
|
+
|
|
46
|
+
@Component({
|
|
47
|
+
selector: 'v-table',
|
|
48
|
+
imports: [
|
|
49
|
+
CommonModule,
|
|
50
|
+
TableModule,
|
|
51
|
+
RouterModule,
|
|
52
|
+
ButtonModule,
|
|
53
|
+
RippleModule,
|
|
54
|
+
TableFilterPipe,
|
|
55
|
+
],
|
|
56
|
+
providers: [
|
|
57
|
+
{
|
|
58
|
+
provide: TABLE_COMPONENT_TOKEN,
|
|
59
|
+
useExisting: TableComponent,
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
templateUrl: './table.component.html',
|
|
63
|
+
styleUrl: './table.component.scss',
|
|
64
|
+
encapsulation: ViewEncapsulation.None,
|
|
65
|
+
changeDetection: ChangeDetectionStrategy.OnPush
|
|
66
|
+
})
|
|
67
|
+
export class TableComponent<T>
|
|
68
|
+
implements AfterViewInit, OnChanges, TableCore<T>
|
|
69
|
+
{
|
|
70
|
+
@ContentChildren(TABLE_COLUMN_PROVIDER) viewColumns!: QueryList<
|
|
71
|
+
ColumnProvider<T>
|
|
72
|
+
>;
|
|
73
|
+
|
|
74
|
+
@ViewChild('table') table: Table | undefined;
|
|
75
|
+
|
|
76
|
+
@ContentChild('rowDetail', { static: false })
|
|
77
|
+
rowDetailTemplate!: TemplateRef<any>;
|
|
78
|
+
|
|
79
|
+
sorters!: Sort[];
|
|
80
|
+
|
|
81
|
+
@Input()
|
|
82
|
+
data!: T[];
|
|
83
|
+
|
|
84
|
+
@Input()
|
|
85
|
+
total = 0;
|
|
86
|
+
|
|
87
|
+
@Input() filter: Partial<T> | undefined;
|
|
88
|
+
|
|
89
|
+
@Input()
|
|
90
|
+
loading!: boolean;
|
|
91
|
+
|
|
92
|
+
@Input()
|
|
93
|
+
scrollable = true;
|
|
94
|
+
|
|
95
|
+
@Input()
|
|
96
|
+
pageSize = DEFAULT_SEARCH_LIMIT;
|
|
97
|
+
|
|
98
|
+
@Input()
|
|
99
|
+
currentPage!: number;
|
|
100
|
+
|
|
101
|
+
@Input()
|
|
102
|
+
showPaginator = true;
|
|
103
|
+
|
|
104
|
+
@Input()
|
|
105
|
+
sortMultiple = false;
|
|
106
|
+
|
|
107
|
+
@Input()
|
|
108
|
+
lazy = false;
|
|
109
|
+
|
|
110
|
+
@Input()
|
|
111
|
+
selectionMode: TableSelectionModeType | undefined;
|
|
112
|
+
|
|
113
|
+
@Input()
|
|
114
|
+
showPageSizePicker = true;
|
|
115
|
+
|
|
116
|
+
@Input()
|
|
117
|
+
entityKey: string | undefined;
|
|
118
|
+
|
|
119
|
+
@Input()
|
|
120
|
+
maximumColumnLength = 0;
|
|
121
|
+
|
|
122
|
+
@Input()
|
|
123
|
+
disableCustomClicks = false;
|
|
124
|
+
|
|
125
|
+
@Input()
|
|
126
|
+
set columns(value: ColumnDefinition<T>[]) {
|
|
127
|
+
this._columns = value;
|
|
128
|
+
this.tableColumns = (value ?? []).map((x) => new ColumnModel(x));
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
get columns(): ColumnDefinition<T>[] {
|
|
132
|
+
return this._columns;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
@Input() selection: T[] = [];
|
|
136
|
+
|
|
137
|
+
@Output()
|
|
138
|
+
pageSizeChange = new EventEmitter<number>();
|
|
139
|
+
|
|
140
|
+
@Output()
|
|
141
|
+
selectionChange = new EventEmitter<T[]>();
|
|
142
|
+
|
|
143
|
+
@Output()
|
|
144
|
+
pageChange = new EventEmitter<TablePageEvent>();
|
|
145
|
+
|
|
146
|
+
@Output()
|
|
147
|
+
sortChange = new EventEmitter<Sort[]>();
|
|
148
|
+
|
|
149
|
+
@Output()
|
|
150
|
+
lazyLoad = new EventEmitter<LazyLoadEvent>();
|
|
151
|
+
|
|
152
|
+
sorted!: boolean;
|
|
153
|
+
|
|
154
|
+
cdRef = inject(ChangeDetectorRef);
|
|
155
|
+
|
|
156
|
+
tableColumns: ColumnModel<T>[] = [];
|
|
157
|
+
|
|
158
|
+
tableRows: RowModel<T>[] = [];
|
|
159
|
+
|
|
160
|
+
tableSelection: RowModel<T>[] | RowModel<T> | undefined;
|
|
161
|
+
|
|
162
|
+
expandedRows = {};
|
|
163
|
+
|
|
164
|
+
expansionTemplate!: { template: TemplateRef<any> };
|
|
165
|
+
|
|
166
|
+
sortMeta: SortMeta[] | undefined;
|
|
167
|
+
|
|
168
|
+
sortSignleColumn: SortMeta | undefined;
|
|
169
|
+
|
|
170
|
+
globalFilterFields: string[] | undefined;
|
|
171
|
+
|
|
172
|
+
router = inject(Router);
|
|
173
|
+
|
|
174
|
+
route = inject(ActivatedRoute);
|
|
175
|
+
|
|
176
|
+
icons = Icons;
|
|
177
|
+
|
|
178
|
+
private _columns!: ColumnDefinition<T>[];
|
|
179
|
+
|
|
180
|
+
ngOnChanges(changes: SimpleChanges): void {
|
|
181
|
+
if (changes['data']) {
|
|
182
|
+
this.updateRowModels();
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
if (changes['selection'] || changes['data']) {
|
|
186
|
+
this.tableSelection = this.selection
|
|
187
|
+
? this.tableRows.filter((x) => this.selection.includes(x.row))
|
|
188
|
+
: undefined;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (changes['filter'] && !changes['filter'].isFirstChange()) {
|
|
192
|
+
this.globalFilterFields = this.columns.filter(x => x.id).map(x => 'row.' + x.id);
|
|
193
|
+
setTimeout(() => {
|
|
194
|
+
this.table?._filter();
|
|
195
|
+
}, 0);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
ngAfterViewInit(): void {
|
|
200
|
+
if (this.viewColumns?.length) {
|
|
201
|
+
const templateColumnModel = this.viewColumns
|
|
202
|
+
.toArray()
|
|
203
|
+
.map((provider) => new ColumnModel(provider.getDefinition()));
|
|
204
|
+
this.tableColumns = [...this.tableColumns, ...templateColumnModel];
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
this.expansionTemplate = {
|
|
208
|
+
template: this.rowDetailTemplate,
|
|
209
|
+
};
|
|
210
|
+
this.cdRef.detectChanges();
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
updateRowModels(): void {
|
|
214
|
+
this.tableRows = (this.data ?? []).map(
|
|
215
|
+
(x) => new RowModel(x, false, false)
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
pageChanged(page: TablePageEvent) {
|
|
220
|
+
this.pageChange.emit(page);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
pageSizeChanged(pageSize: number) {
|
|
224
|
+
this.pageSizeChange.emit(pageSize);
|
|
225
|
+
this.pageSize = pageSize;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
sortChanged(event: SortMeta | { multisortmeta: SortMeta[] }) {
|
|
229
|
+
let eventEmiterArg: Sort[];
|
|
230
|
+
if ((<SortMeta>event).field) {
|
|
231
|
+
const singleEvent = <SortMeta>event;
|
|
232
|
+
eventEmiterArg = this.getSorts([singleEvent]) as Sort[];
|
|
233
|
+
this.sortMeta = undefined;
|
|
234
|
+
this.sortSignleColumn = singleEvent;
|
|
235
|
+
} else {
|
|
236
|
+
const multiEvent = <{ multisortmeta: SortMeta[] }>event;
|
|
237
|
+
eventEmiterArg = this.getSorts(multiEvent.multisortmeta) as Sort[];
|
|
238
|
+
this.sortMeta = multiEvent.multisortmeta;
|
|
239
|
+
this.sortSignleColumn = undefined;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
this.sortChange.emit(eventEmiterArg);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
selectionChanged(event: RowModel<T>[] | RowModel<T>) {
|
|
246
|
+
this.tableSelection = event;
|
|
247
|
+
if (this.selectionMode) {
|
|
248
|
+
const eventArgArray = Array.isArray(event) ? event : [event];
|
|
249
|
+
const selection = event ? eventArgArray.map((x) => x.row) : [];
|
|
250
|
+
this.selectionChange.emit(selection);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
fireLazyLoad(event: TableLazyLoadEvent) {
|
|
255
|
+
if (this.lazy) {
|
|
256
|
+
const sort = this.sortSignleColumn
|
|
257
|
+
? this.getSorts([this.sortSignleColumn])
|
|
258
|
+
: this.sortMeta
|
|
259
|
+
? this.getSorts(this.sortMeta)
|
|
260
|
+
: undefined;
|
|
261
|
+
const lazyLoadEvent: LazyLoadEvent = {
|
|
262
|
+
sort,
|
|
263
|
+
offset: event.first ?? 0,
|
|
264
|
+
limit: event.rows ?? this.pageSize,
|
|
265
|
+
filter: convertToFilter(event.filters),
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
this.lazyLoad.emit(lazyLoadEvent);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
private removePrefix(input: string, prefix: string): string {
|
|
273
|
+
return input.startsWith(prefix) ? input.slice(prefix.length) : input;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
private convertToSortDirection(value: number): SortDirectionType {
|
|
277
|
+
return value === 1 ? SortDirection.asc : SortDirection.desc;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
private getSorts(value: SortMeta[] | undefined) {
|
|
281
|
+
return value
|
|
282
|
+
? value.map((x: SortMeta) => ({
|
|
283
|
+
field: this.removePrefix(x.field, 'row.'),
|
|
284
|
+
direction: this.convertToSortDirection(x.order),
|
|
285
|
+
}))
|
|
286
|
+
: undefined;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { FilterMetadata } from 'primeng/api';
|
|
2
|
+
|
|
3
|
+
export function convertToFilter<T>(
|
|
4
|
+
value:
|
|
5
|
+
| {
|
|
6
|
+
[s: string]: FilterMetadata | FilterMetadata[] | undefined;
|
|
7
|
+
}
|
|
8
|
+
| Partial<T>
|
|
9
|
+
| undefined
|
|
10
|
+
): Partial<T> | undefined {
|
|
11
|
+
if (value == undefined) {
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const filter: { [key: string]: unknown } = {};
|
|
16
|
+
Object.keys(value).map((key) => {
|
|
17
|
+
const filterValue = (value as { [s: string]: unknown })[key];
|
|
18
|
+
if (filterValue != undefined && typeof filterValue === 'object') {
|
|
19
|
+
filter[key] = (filterValue as FilterMetadata).value;
|
|
20
|
+
} else {
|
|
21
|
+
filter[key] = filterValue;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
return filter as Partial<T>;
|
|
26
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
display: inline-block;
|
|
3
|
+
|
|
4
|
+
.p-tag {
|
|
5
|
+
display: inline-flex;
|
|
6
|
+
align-items: center;
|
|
7
|
+
line-height: 1;
|
|
8
|
+
|
|
9
|
+
&.v-primeng-tag--small {
|
|
10
|
+
font-size: 0.75rem;
|
|
11
|
+
padding: 0.1rem 0.4rem;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
&.v-primeng-tag--medium {
|
|
15
|
+
font-size: 0.875rem;
|
|
16
|
+
padding: 0.15rem 0.5rem;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
&.v-primeng-tag--large {
|
|
20
|
+
font-size: 1rem;
|
|
21
|
+
padding: 0.25rem 0.6rem;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
&.v-primeng-tag--xl {
|
|
25
|
+
font-size: 1.125rem;
|
|
26
|
+
padding: 0.3rem 0.75rem;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
&.v-primeng-tag--subtle {
|
|
30
|
+
filter: brightness(1.1) saturate(0.5);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { CommonModule } from '@angular/common';
|
|
2
|
+
import { ChangeDetectionStrategy, Component, computed, input } from '@angular/core';
|
|
3
|
+
import { TranslateModule } from '@ngx-translate/core';
|
|
4
|
+
import {
|
|
5
|
+
ControlSeverity,
|
|
6
|
+
ControlSeverityType,
|
|
7
|
+
FieldSize,
|
|
8
|
+
FieldSizeType,
|
|
9
|
+
TagCore,
|
|
10
|
+
TAG_COMPONENT_TOKEN,
|
|
11
|
+
TagVariant,
|
|
12
|
+
} from '@verisoft/ui-core';
|
|
13
|
+
import { TagModule } from 'primeng/tag';
|
|
14
|
+
|
|
15
|
+
type PrimeSeverity = 'success' | 'info' | 'warning' | 'danger' | null;
|
|
16
|
+
|
|
17
|
+
@Component({
|
|
18
|
+
selector: 'v-tag',
|
|
19
|
+
imports: [CommonModule, TagModule, TranslateModule],
|
|
20
|
+
templateUrl: './tag.component.html',
|
|
21
|
+
styleUrl: './tag.component.scss',
|
|
22
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
23
|
+
providers: [
|
|
24
|
+
{
|
|
25
|
+
provide: TAG_COMPONENT_TOKEN,
|
|
26
|
+
useExisting: TagComponent,
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
})
|
|
30
|
+
export class TagComponent implements TagCore {
|
|
31
|
+
label = input<string | undefined>();
|
|
32
|
+
severity = input<ControlSeverityType | undefined>(ControlSeverity.primary);
|
|
33
|
+
variant = input<TagVariant>('bold');
|
|
34
|
+
size = input<FieldSizeType>(FieldSize.medium);
|
|
35
|
+
|
|
36
|
+
protected readonly primeSeverity = computed<PrimeSeverity>(() => {
|
|
37
|
+
const severity = this.severity();
|
|
38
|
+
if (!severity) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
switch (severity) {
|
|
43
|
+
case ControlSeverity.success:
|
|
44
|
+
return 'success';
|
|
45
|
+
case ControlSeverity.info:
|
|
46
|
+
case ControlSeverity.help:
|
|
47
|
+
case ControlSeverity.primary:
|
|
48
|
+
case ControlSeverity.secondary:
|
|
49
|
+
case ControlSeverity.contrast:
|
|
50
|
+
return 'info';
|
|
51
|
+
case ControlSeverity.warning:
|
|
52
|
+
return 'warning';
|
|
53
|
+
case ControlSeverity.danger:
|
|
54
|
+
return 'danger';
|
|
55
|
+
default:
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
protected readonly tagClasses = computed(() => {
|
|
61
|
+
const classes: string[] = ['v-primeng-tag'];
|
|
62
|
+
const severity = this.severity();
|
|
63
|
+
const variant = this.variant();
|
|
64
|
+
const size = this.size();
|
|
65
|
+
|
|
66
|
+
if (severity) {
|
|
67
|
+
classes.push(`v-primeng-tag--${severity}`);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (variant === 'subtle') {
|
|
71
|
+
classes.push('v-primeng-tag--subtle');
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (size) {
|
|
75
|
+
classes.push(`v-primeng-tag--${size}`);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return classes.join(' ');
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
protected readonly rounded = computed(() => this.variant() === 'subtle');
|
|
82
|
+
}
|
|
83
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './textarea.component';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<div class="v-textarea">
|
|
2
|
+
@if (!floatLabel) {
|
|
3
|
+
<v-form-field
|
|
4
|
+
[label]="label"
|
|
5
|
+
[tooltip]="tooltip"
|
|
6
|
+
[required]="isRequired()"
|
|
7
|
+
[display]="formDisplay"
|
|
8
|
+
>
|
|
9
|
+
<textarea
|
|
10
|
+
class="flex-grow-1"
|
|
11
|
+
pTextarea
|
|
12
|
+
[rows]="rows"
|
|
13
|
+
[cols]="cols"
|
|
14
|
+
[formControl]="formControl"
|
|
15
|
+
[placeholder]="placeholder"
|
|
16
|
+
[required]="isRequired()"
|
|
17
|
+
[readOnly]="readonly"
|
|
18
|
+
[autoResize]="autoResize"
|
|
19
|
+
></textarea>
|
|
20
|
+
</v-form-field>
|
|
21
|
+
<v-validation-message [ngControl]="ngControl"></v-validation-message>
|
|
22
|
+
}
|
|
23
|
+
@if (floatLabel) {
|
|
24
|
+
<p-floatLabel>
|
|
25
|
+
<textarea
|
|
26
|
+
class="flex-grow-1"
|
|
27
|
+
pTextarea
|
|
28
|
+
[rows]="rows"
|
|
29
|
+
[cols]="cols"
|
|
30
|
+
[id]="inputId"
|
|
31
|
+
[formControl]="formControl"
|
|
32
|
+
[placeholder]="placeholder"
|
|
33
|
+
[required]="isRequired()"
|
|
34
|
+
[readOnly]="readonly"
|
|
35
|
+
[autoResize]="autoResize"
|
|
36
|
+
></textarea>
|
|
37
|
+
<label [for]="inputId">{{ floatLabel }}</label>
|
|
38
|
+
</p-floatLabel>
|
|
39
|
+
}
|
|
40
|
+
</div>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
import { TextareaComponent } from './textarea.component';
|
|
3
|
+
|
|
4
|
+
describe('TextareaComponent', () => {
|
|
5
|
+
let component: TextareaComponent;
|
|
6
|
+
let fixture: ComponentFixture<TextareaComponent>;
|
|
7
|
+
|
|
8
|
+
beforeEach(async () => {
|
|
9
|
+
await TestBed.configureTestingModule({
|
|
10
|
+
imports: [TextareaComponent],
|
|
11
|
+
}).compileComponents();
|
|
12
|
+
|
|
13
|
+
fixture = TestBed.createComponent(TextareaComponent);
|
|
14
|
+
component = fixture.componentInstance;
|
|
15
|
+
fixture.detectChanges();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('should create', () => {
|
|
19
|
+
expect(component).toBeTruthy();
|
|
20
|
+
});
|
|
21
|
+
});
|