@verisoft/ui-core 0.0.1
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 +48 -0
- package/README.md +7 -0
- package/jest.config.ts +21 -0
- package/ng-package.json +7 -0
- package/package.json +16 -0
- package/project.json +36 -0
- package/src/index.ts +4 -0
- package/src/lib/common/angular-helper.ts +44 -0
- package/src/lib/common/constants.ts +1 -0
- package/src/lib/common/control.models.ts +57 -0
- package/src/lib/common/datasource-component.model.spec.ts +42 -0
- package/src/lib/common/datasource-component.model.ts +41 -0
- package/src/lib/common/index.ts +4 -0
- package/src/lib/components/action-button-group/action-button-group.model.ts +16 -0
- package/src/lib/components/action-button-group/action-button.model.ts +16 -0
- package/src/lib/components/action-button-group/index.ts +2 -0
- package/src/lib/components/base-form/base-form-input.component.ts +115 -0
- package/src/lib/components/base-form/base-form.component.ts +209 -0
- package/src/lib/components/base-form/directives/detail-store.directive.ts +146 -0
- package/src/lib/components/base-form/index.ts +4 -0
- package/src/lib/components/base-form/models/base-form-input.models.ts +11 -0
- package/src/lib/components/base-form/models/base-form.models.ts +31 -0
- package/src/lib/components/base-form/models/index.ts +2 -0
- package/src/lib/components/breadcrumb/breadcrumb.model.ts +21 -0
- package/src/lib/components/breadcrumb/breadcrumb.service.ts +9 -0
- package/src/lib/components/breadcrumb/breadcrumbcore.component.ts +94 -0
- package/src/lib/components/breadcrumb/index.ts +3 -0
- package/src/lib/components/button/button.model.ts +22 -0
- package/src/lib/components/button/index.ts +1 -0
- package/src/lib/components/calendar/calendar.model.ts +16 -0
- package/src/lib/components/calendar/index.ts +1 -0
- package/src/lib/components/checkbox/checkbox.model.ts +9 -0
- package/src/lib/components/checkbox/index.ts +1 -0
- package/src/lib/components/confirm-dialog/confirm-dialog.model.ts +26 -0
- package/src/lib/components/confirm-dialog/index.ts +1 -0
- package/src/lib/components/dropdown/dropdown.model.ts +13 -0
- package/src/lib/components/dropdown/index.ts +1 -0
- package/src/lib/components/form-field/form-field.model.ts +15 -0
- package/src/lib/components/form-field/index.ts +1 -0
- package/src/lib/components/generic-field/generic-field.model.ts +10 -0
- package/src/lib/components/generic-field/index.ts +1 -0
- package/src/lib/components/header/header.model.ts +18 -0
- package/src/lib/components/header/index.ts +1 -0
- package/src/lib/components/index.ts +31 -0
- package/src/lib/components/input-group/index.ts +1 -0
- package/src/lib/components/input-group/input-group.model.ts +17 -0
- package/src/lib/components/loader/index.ts +1 -0
- package/src/lib/components/loader/loader.model.ts +8 -0
- package/src/lib/components/multiselect/index.ts +1 -0
- package/src/lib/components/multiselect/mutiselect.model.ts +13 -0
- package/src/lib/components/number-input/index.ts +1 -0
- package/src/lib/components/number-input/number-input.model.ts +14 -0
- package/src/lib/components/page-header/index.ts +1 -0
- package/src/lib/components/page-header/page-header.model.ts +17 -0
- package/src/lib/components/password/index.ts +1 -0
- package/src/lib/components/password/password.model.ts +11 -0
- package/src/lib/components/radiobutton/index.ts +1 -0
- package/src/lib/components/radiobutton/radiobutton.model.ts +16 -0
- package/src/lib/components/section/index.ts +1 -0
- package/src/lib/components/section/section.model.ts +11 -0
- package/src/lib/components/side-menu/index.ts +3 -0
- package/src/lib/components/side-menu/services/side-menu-provider.service.ts +13 -0
- package/src/lib/components/side-menu/services/side-menu.service.ts +58 -0
- package/src/lib/components/side-menu/side-menu.model.ts +64 -0
- package/src/lib/components/slider/index.ts +1 -0
- package/src/lib/components/slider/slider.model.ts +13 -0
- package/src/lib/components/snackbar/index.ts +1 -0
- package/src/lib/components/snackbar/snackbar.model.ts +8 -0
- package/src/lib/components/stepper/index.ts +1 -0
- package/src/lib/components/stepper/stepper.model.ts +14 -0
- package/src/lib/components/switch/index.ts +1 -0
- package/src/lib/components/switch/switch.model.ts +9 -0
- package/src/lib/components/tab-view/index.ts +1 -0
- package/src/lib/components/tab-view/tab-view.model.ts +19 -0
- package/src/lib/components/table/index.ts +2 -0
- package/src/lib/components/table/table.models.ts +189 -0
- package/src/lib/components/table/template-column.directive.ts +45 -0
- package/src/lib/components/table-filter/index.ts +1 -0
- package/src/lib/components/table-filter/table-filter.model.ts +22 -0
- package/src/lib/components/textarea/index.ts +1 -0
- package/src/lib/components/textarea/textarea.model.ts +13 -0
- package/src/lib/components/textfield/index.ts +1 -0
- package/src/lib/components/textfield/textfield.model.ts +13 -0
- package/src/lib/components/tristatecheckbox/index.ts +1 -0
- package/src/lib/components/tristatecheckbox/tristatecheckbox.model.ts +9 -0
- package/src/lib/components/unsubscribe.component.ts +12 -0
- package/src/lib/directives/datasource.directive.ts +275 -0
- package/src/lib/directives/index.ts +1 -0
- package/src/lib/pipes/error/error.codes.ts +6 -0
- package/src/lib/pipes/error/error.models.ts +27 -0
- package/src/lib/pipes/error/error.pipe.ts +27 -0
- package/src/lib/pipes/error/warning.codes.ts +5 -0
- package/src/lib/pipes/error/warning.pipe.ts +27 -0
- package/src/lib/pipes/gov/gov-color.pipe.ts +24 -0
- package/src/lib/pipes/gov/gov-size.pipe.ts +16 -0
- package/src/lib/pipes/index.ts +8 -0
- package/src/lib/pipes/keyOrFn/keyOrFn.pipe.ts +23 -0
- package/src/test-setup.ts +8 -0
- package/tsconfig.json +28 -0
- package/tsconfig.lib.json +17 -0
- package/tsconfig.lib.prod.json +9 -0
- package/tsconfig.spec.json +16 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { InjectionToken } from '@angular/core';
|
|
2
|
+
import { MenuItem } from 'primeng/api';
|
|
3
|
+
|
|
4
|
+
export const HEADER_COMPONENT_TOKEN = new InjectionToken<HeaderCore>(
|
|
5
|
+
'HeaderComponentToken'
|
|
6
|
+
);
|
|
7
|
+
|
|
8
|
+
export const SETTINGS_MENU = new InjectionToken<MenuItem[]>(
|
|
9
|
+
'SETTINGS_MENU'
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
export interface HeaderCore {
|
|
13
|
+
title: string;
|
|
14
|
+
userName: string;
|
|
15
|
+
logoUrl: string;
|
|
16
|
+
userRole: any | any[] | undefined;
|
|
17
|
+
menuRef: HTMLDivElement;
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './header.model';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export * from './action-button-group';
|
|
2
|
+
export * from './base-form';
|
|
3
|
+
export * from './breadcrumb';
|
|
4
|
+
export * from './button';
|
|
5
|
+
export * from './calendar';
|
|
6
|
+
export * from './checkbox';
|
|
7
|
+
export * from './confirm-dialog';
|
|
8
|
+
export * from './dropdown';
|
|
9
|
+
export * from './form-field';
|
|
10
|
+
export * from './generic-field';
|
|
11
|
+
export * from './header';
|
|
12
|
+
export * from './input-group';
|
|
13
|
+
export * from './loader';
|
|
14
|
+
export * from './multiselect';
|
|
15
|
+
export * from './number-input';
|
|
16
|
+
export * from './page-header';
|
|
17
|
+
export * from './password';
|
|
18
|
+
export * from './radiobutton';
|
|
19
|
+
export * from './section';
|
|
20
|
+
export * from './side-menu';
|
|
21
|
+
export * from './slider';
|
|
22
|
+
export * from './snackbar';
|
|
23
|
+
export * from './stepper';
|
|
24
|
+
export * from './switch';
|
|
25
|
+
export * from './tab-view';
|
|
26
|
+
export * from './table';
|
|
27
|
+
export * from './table-filter';
|
|
28
|
+
export * from './textarea';
|
|
29
|
+
export * from './textfield';
|
|
30
|
+
export * from './tristatecheckbox';
|
|
31
|
+
export * from './unsubscribe.component';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './input-group.model'
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { InjectionToken } from '@angular/core';
|
|
2
|
+
import { IconPositionType } from '../../common';
|
|
3
|
+
import { BaseFormCore } from '../base-form';
|
|
4
|
+
|
|
5
|
+
export const INPUT_GROUP_COMPONENT_TOKEN = new InjectionToken<InputGroupCore>(
|
|
6
|
+
'HeaderComponentToken'
|
|
7
|
+
);
|
|
8
|
+
|
|
9
|
+
export interface InputGroupItem {
|
|
10
|
+
icon?: string;
|
|
11
|
+
text?: string;
|
|
12
|
+
position: IconPositionType;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface InputGroupCore extends BaseFormCore {
|
|
16
|
+
items: InputGroupItem[];
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './loader.model'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './mutiselect.model';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { InjectionToken } from '@angular/core';
|
|
2
|
+
import { DataSourceComponentModel } from '../../common';
|
|
3
|
+
import { BaseFormCore } from '../base-form';
|
|
4
|
+
|
|
5
|
+
export const MULTISELECT_COMPONENT_TOKEN = new InjectionToken<MultiselectCore<any>>(
|
|
6
|
+
'MultiselectComponentToken'
|
|
7
|
+
);
|
|
8
|
+
|
|
9
|
+
export interface MultiselectCore<T> extends DataSourceComponentModel<T>, BaseFormCore {
|
|
10
|
+
dropdownIcon?: string;
|
|
11
|
+
floatLabel?: string;
|
|
12
|
+
editable: boolean;
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './number-input.model';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { InjectionToken } from '@angular/core';
|
|
2
|
+
import { BaseFormCore } from '../base-form';
|
|
3
|
+
|
|
4
|
+
export const NUMBER_INPUT_COMPONENT_TOKEN = new InjectionToken<NumberInputCore>(
|
|
5
|
+
'NumberInputComponentToken'
|
|
6
|
+
);
|
|
7
|
+
|
|
8
|
+
export interface NumberInputCore extends BaseFormCore {
|
|
9
|
+
mode: string;
|
|
10
|
+
currency: string;
|
|
11
|
+
min: number;
|
|
12
|
+
max: number;
|
|
13
|
+
step: number;
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './page-header.model';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { InjectionToken } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
export const PAGE_HEADER_COMPONENT_TOKEN = new InjectionToken<PageHeaderCore>(
|
|
4
|
+
'PageHeaderComponentToken'
|
|
5
|
+
);
|
|
6
|
+
|
|
7
|
+
export interface PageHeaderCore {
|
|
8
|
+
title: string;
|
|
9
|
+
subtitle: string | undefined;
|
|
10
|
+
showBackButton: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface PageHeader {
|
|
14
|
+
title: string;
|
|
15
|
+
subtitle?: string;
|
|
16
|
+
showBackButton?: boolean;
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './password.model';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { InjectionToken } from '@angular/core';
|
|
2
|
+
import { BaseFormCore } from '../base-form';
|
|
3
|
+
|
|
4
|
+
export const PASSWORD_COMPONENT_TOKEN = new InjectionToken<PasswordCore>(
|
|
5
|
+
'PasswordComponentToken'
|
|
6
|
+
);
|
|
7
|
+
|
|
8
|
+
export interface PasswordCore extends BaseFormCore {
|
|
9
|
+
toggleMask: boolean;
|
|
10
|
+
feedback: boolean;
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './radiobutton.model';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { InjectionToken } from '@angular/core';
|
|
2
|
+
import { BaseFormCore } from '../base-form';
|
|
3
|
+
|
|
4
|
+
export const RADIOBUTTON_COMPONENT_TOKEN = new InjectionToken<RadiobuttonCore<any>>(
|
|
5
|
+
'RadiobuttonComponentToken'
|
|
6
|
+
);
|
|
7
|
+
|
|
8
|
+
export interface RadioButtonItem<T> {
|
|
9
|
+
id: string;
|
|
10
|
+
value: T;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface RadiobuttonCore<T> extends BaseFormCore {
|
|
14
|
+
radioGroupName: string;
|
|
15
|
+
items: RadioButtonItem<T>[];
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './section.model';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { InjectionToken } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
export const SECTION_COMPONENT_TOKEN = new InjectionToken<SectionCore>(
|
|
4
|
+
'SectionComponentToken'
|
|
5
|
+
);
|
|
6
|
+
|
|
7
|
+
export interface SectionCore {
|
|
8
|
+
title: string;
|
|
9
|
+
showContent: boolean;
|
|
10
|
+
backgroundColor: string;
|
|
11
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Injectable, Optional, Inject } from '@angular/core';
|
|
2
|
+
import { MENU_TOKEN, MenuItem } from '../side-menu.model';
|
|
3
|
+
import { SideMenuService } from './side-menu.service';
|
|
4
|
+
|
|
5
|
+
@Injectable()
|
|
6
|
+
export class SideMenuProviderService {
|
|
7
|
+
constructor(
|
|
8
|
+
@Optional() @Inject(MENU_TOKEN) readonly menu: MenuItem[] = [],
|
|
9
|
+
readonly menuService: SideMenuService
|
|
10
|
+
) {
|
|
11
|
+
menuService.setMenu(menu);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { inject, Injectable } from '@angular/core';
|
|
2
|
+
import { BehaviorSubject, Observable } from 'rxjs';
|
|
3
|
+
import { MenuItem, SIDE_MENU_STATE_TOKEN } from '../side-menu.model';
|
|
4
|
+
|
|
5
|
+
@Injectable({ providedIn: 'root' })
|
|
6
|
+
export class SideMenuService {
|
|
7
|
+
private _menuItems = new BehaviorSubject<MenuItem[]>([]);
|
|
8
|
+
private stateToken = inject(SIDE_MENU_STATE_TOKEN);
|
|
9
|
+
|
|
10
|
+
menuItems$: Observable<MenuItem[]> = this._menuItems.asObservable();
|
|
11
|
+
menuMinimalized = false;
|
|
12
|
+
|
|
13
|
+
setMenu(items: MenuItem[]): void {
|
|
14
|
+
this.resetSidemenuState(items);
|
|
15
|
+
this._menuItems.next(items);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
saveMinimalizedState(minimalized: boolean): void {
|
|
19
|
+
this.stateToken.minimalized = minimalized;
|
|
20
|
+
localStorage.setItem('SideMenuStateToken', JSON.stringify(this.stateToken));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
saveExpandedState(item: MenuItem): void {
|
|
24
|
+
const expanded = this.stateToken.expanded?.find(
|
|
25
|
+
(i: string) => i === item.label
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
if (!expanded) {
|
|
29
|
+
this.stateToken.expanded?.push(item.label);
|
|
30
|
+
localStorage.setItem(
|
|
31
|
+
'SideMenuStateToken',
|
|
32
|
+
JSON.stringify(this.stateToken)
|
|
33
|
+
);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
this.stateToken.expanded = this.stateToken.expanded?.filter(
|
|
38
|
+
(i: string) => i !== item.label
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
localStorage.setItem('SideMenuStateToken', JSON.stringify(this.stateToken));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
private resetSidemenuState(items: MenuItem[]) {
|
|
45
|
+
if (typeof this.stateToken === 'string') {
|
|
46
|
+
this.stateToken = JSON.parse(this.stateToken);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
this.menuMinimalized = this.stateToken.minimalized;
|
|
50
|
+
const localStorageValue = this.stateToken.expanded;
|
|
51
|
+
|
|
52
|
+
if (!localStorageValue) return;
|
|
53
|
+
for (let index = 0; index < items.length; index++) {
|
|
54
|
+
const element = items[index];
|
|
55
|
+
element.expanded = !!localStorageValue.find((i: string) => i === element.label);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { InjectionToken } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
export const MENU_TOKEN = new InjectionToken<MenuItem[]>(
|
|
4
|
+
'MENU'
|
|
5
|
+
);
|
|
6
|
+
|
|
7
|
+
export const LOGO_ROUTER_ROUTE = new InjectionToken<string>(
|
|
8
|
+
'LOGO_ROUTER_ROUTE'
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
export const SIDE_MENU_COMPONENT_TOKEN = new InjectionToken<ISideMenu>(
|
|
12
|
+
'SideMenuComponentToken'
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
export const SIDE_MENU_STATE_TOKEN = new InjectionToken<SideMenuState>(
|
|
16
|
+
'SideMenuStateToken'
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
export interface SideMenuState {
|
|
20
|
+
expanded: string[];
|
|
21
|
+
minimalized: boolean;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface MenuItem {
|
|
25
|
+
id?: string;
|
|
26
|
+
label: string;
|
|
27
|
+
icon?: string;
|
|
28
|
+
expanded?: boolean;
|
|
29
|
+
data?: MenuItemData;
|
|
30
|
+
tooltip?: string;
|
|
31
|
+
url?: string;
|
|
32
|
+
visible?: boolean;
|
|
33
|
+
type?: string;
|
|
34
|
+
children?: MenuItem[];
|
|
35
|
+
routerLink?: any;
|
|
36
|
+
class?: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
type ExtendableType = {
|
|
40
|
+
[key: string]:
|
|
41
|
+
| string
|
|
42
|
+
| number
|
|
43
|
+
| boolean
|
|
44
|
+
| string[]
|
|
45
|
+
| number[]
|
|
46
|
+
| boolean[]
|
|
47
|
+
| undefined;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export interface MenuItemData extends ExtendableType {
|
|
51
|
+
roles?: string[];
|
|
52
|
+
permissions?: string[];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface SideMenuModuleConfig {
|
|
56
|
+
items?: MenuItem[];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface ISideMenu {
|
|
60
|
+
item: MenuItem[];
|
|
61
|
+
logoUrl: string;
|
|
62
|
+
userName: string;
|
|
63
|
+
userRole: any | any[] | undefined;
|
|
64
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './slider.model';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { InjectionToken } from '@angular/core';
|
|
2
|
+
import { BaseFormCore } from '../base-form';
|
|
3
|
+
|
|
4
|
+
export const SLIDER_COMPONENT_TOKEN = new InjectionToken<SliderCore>(
|
|
5
|
+
'SliderComponentToken'
|
|
6
|
+
);
|
|
7
|
+
|
|
8
|
+
export interface SliderCore extends BaseFormCore {
|
|
9
|
+
step: number;
|
|
10
|
+
min: number;
|
|
11
|
+
max: number;
|
|
12
|
+
range: boolean;
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './snackbar.model';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './stepper.model';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { InjectionToken, TemplateRef } from "@angular/core";
|
|
2
|
+
|
|
3
|
+
export const STEPPER_COMPONENT_TOKEN = new InjectionToken<StepperCore>(
|
|
4
|
+
'StepperComponentToken'
|
|
5
|
+
);
|
|
6
|
+
|
|
7
|
+
export interface StepperItem {
|
|
8
|
+
header: string;
|
|
9
|
+
template: TemplateRef<any>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface StepperCore {
|
|
13
|
+
items: StepperItem[];
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './switch.model'
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { InjectionToken } from "@angular/core";
|
|
2
|
+
import { BaseFormCore } from "../base-form";
|
|
3
|
+
|
|
4
|
+
export const SWITCH_COMPONENT_TOKEN = new InjectionToken<SwitchCore>(
|
|
5
|
+
'SwitchComponentToken'
|
|
6
|
+
);
|
|
7
|
+
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
9
|
+
export interface SwitchCore extends BaseFormCore {}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './tab-view.model'
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { InjectionToken, TemplateRef } from "@angular/core";
|
|
2
|
+
|
|
3
|
+
export const TAB_VIEW_COMPONENT_TOKEN = new InjectionToken<TabViewCore>(
|
|
4
|
+
'TabVIewComponentToken'
|
|
5
|
+
);
|
|
6
|
+
|
|
7
|
+
export interface TabViewItem {
|
|
8
|
+
title: string;
|
|
9
|
+
url?: string;
|
|
10
|
+
icon?: string;
|
|
11
|
+
content?: string;
|
|
12
|
+
contentTemplate?: TemplateRef<unknown>
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface TabViewCore {
|
|
16
|
+
items: TabViewItem[];
|
|
17
|
+
useRouting: boolean;
|
|
18
|
+
activeIndex: number;
|
|
19
|
+
}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { InjectionToken, TemplateRef } from '@angular/core';
|
|
2
|
+
import { Params } from '@angular/router';
|
|
3
|
+
import { Page, Sort } from '@verisoft/core';
|
|
4
|
+
import { Observable } from 'rxjs';
|
|
5
|
+
|
|
6
|
+
export const TABLE_COMPONENT_TOKEN = new InjectionToken<TableCore<any>>(
|
|
7
|
+
'TabVIewComponentToken'
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
export const TABLE_COLUMN_PROVIDER = new InjectionToken(
|
|
11
|
+
'TABLE_COLUMN_PROVIDER'
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
export interface TableCore<T> {
|
|
15
|
+
sorters: Sort[];
|
|
16
|
+
data: T[];
|
|
17
|
+
total: number;
|
|
18
|
+
loading: boolean;
|
|
19
|
+
scrollHeight: string;
|
|
20
|
+
scrollable: boolean;
|
|
21
|
+
pageSize: number;
|
|
22
|
+
currentPage: number;
|
|
23
|
+
showPaginator: boolean;
|
|
24
|
+
sortMultiple: boolean;
|
|
25
|
+
lazy: boolean;
|
|
26
|
+
selectionMode: 'single' | 'multiple' | null | undefined;
|
|
27
|
+
multipleSelect: boolean;
|
|
28
|
+
autoIndex: boolean;
|
|
29
|
+
showPageSizePicker: boolean;
|
|
30
|
+
page: Page<T> | undefined;
|
|
31
|
+
entityId: string;
|
|
32
|
+
searchIndex$: Observable<number>;
|
|
33
|
+
filterComponent: any;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface ActionColumnsDefinition<T> {
|
|
37
|
+
severity?: TableButtonSeverity;
|
|
38
|
+
title?: string;
|
|
39
|
+
icon?: string;
|
|
40
|
+
tooltip?: string;
|
|
41
|
+
rounded?: boolean;
|
|
42
|
+
outlined?: boolean;
|
|
43
|
+
raised?: boolean;
|
|
44
|
+
badge?: string;
|
|
45
|
+
visible?: (row: T) => boolean;
|
|
46
|
+
routerLink?: (row: T) => string;
|
|
47
|
+
queryParams?: Params;
|
|
48
|
+
disabled?: boolean | ((row: T) => boolean);
|
|
49
|
+
onClick?: (row: T, event?: MouseEvent) => void;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface ColumnProvider<T> {
|
|
53
|
+
getDefinition(): ColumnDefinition<T>;
|
|
54
|
+
index: number;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export enum TableButtonSeverity {
|
|
58
|
+
SUCCESS = 'success',
|
|
59
|
+
INFO = 'info',
|
|
60
|
+
WARNING = 'warning',
|
|
61
|
+
DANGER = 'danger',
|
|
62
|
+
HELP = 'help',
|
|
63
|
+
PRIMARY = 'primary',
|
|
64
|
+
SECONDARY = 'secondary',
|
|
65
|
+
CONTRAST = 'contrast',
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface ColumnDefinition<T, _KEY = keyof T> {
|
|
69
|
+
id: string;
|
|
70
|
+
value?: (row: T, index?: number) => string;
|
|
71
|
+
headerName?: (column: string, index?: number) => string;
|
|
72
|
+
icon?: string | ((row?: T | undefined) => string);
|
|
73
|
+
type?: string;
|
|
74
|
+
sortable?: boolean;
|
|
75
|
+
routerLink?: (row: T) => string | string;
|
|
76
|
+
queryParams?: Params;
|
|
77
|
+
columnClass?: string;
|
|
78
|
+
template?: TemplateRef<T>;
|
|
79
|
+
actions?: ActionColumnsDefinition<T>[];
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export function LinkRenderer<T>(text: string, href: string) {
|
|
83
|
+
return (row: T, index: number | undefined) => {
|
|
84
|
+
return '<a href="' + href + '">' + text + '</a>';
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function routerRenderer<T>(link: string, text: string) {
|
|
89
|
+
return (row: T, index?: number | undefined) => {
|
|
90
|
+
return { text: text, link: link };
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export function Renderer<T>(fnc: (row: T) => string) {
|
|
95
|
+
return (row: T) => {
|
|
96
|
+
return fnc(row);
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export class ColumnModel<T> {
|
|
101
|
+
sortDirection: SortDirection | undefined = undefined;
|
|
102
|
+
sortColumn: Sort | undefined = undefined;
|
|
103
|
+
columnClass?: string;
|
|
104
|
+
queryParams?: Params;
|
|
105
|
+
routerLink?: (row: T) => string | string;
|
|
106
|
+
valueGetter!: (row: T, index: number) => string;
|
|
107
|
+
headerGetter!: (column: string, index: number) => string | string;
|
|
108
|
+
template?: TemplateRef<T>;
|
|
109
|
+
actions?: ActionColumnsDefinition<T>[];
|
|
110
|
+
sortable?: boolean;
|
|
111
|
+
|
|
112
|
+
get headerName(): string {
|
|
113
|
+
return this.configuration.headerName?.toString() ?? 'undefined';
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
constructor(readonly configuration: ColumnDefinition<T>) {
|
|
117
|
+
if (this.configuration.value) {
|
|
118
|
+
this.valueGetter = (row, index) =>
|
|
119
|
+
this.configuration.value?.(row, index) ?? '-';
|
|
120
|
+
} else {
|
|
121
|
+
this.valueGetter = (row) =>
|
|
122
|
+
((row as { [key: string]: string })?.[
|
|
123
|
+
this.configuration.id
|
|
124
|
+
] as string) ?? '';
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (this.configuration.actions) {
|
|
128
|
+
this.actions = this.configuration.actions;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (this.configuration.routerLink) {
|
|
132
|
+
this.routerLink = this.configuration.routerLink;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (this.configuration.columnClass) {
|
|
136
|
+
this.columnClass = this.configuration.columnClass;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (this.configuration.template) {
|
|
140
|
+
this.template = this.configuration.template;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (this.configuration.headerName) {
|
|
144
|
+
this.headerGetter = (column, index) =>
|
|
145
|
+
this.configuration.headerName?.(column, index) ?? '';
|
|
146
|
+
} else {
|
|
147
|
+
this.headerGetter = (column, index) => column[index];
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (this.configuration.queryParams) {
|
|
151
|
+
this.queryParams = this.configuration.queryParams;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (this.routerLink) {
|
|
155
|
+
this.columnClass += ' ' + 'link';
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (this.configuration.sortable !== undefined) {
|
|
159
|
+
this.sortable = this.configuration.sortable;
|
|
160
|
+
} else {
|
|
161
|
+
this.sortable = true;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export declare type SortDirection = 'asc' | 'desc' | undefined;
|
|
167
|
+
|
|
168
|
+
export class RowModel<T> {
|
|
169
|
+
row: T;
|
|
170
|
+
index?: number;
|
|
171
|
+
selected: boolean;
|
|
172
|
+
marked?: boolean;
|
|
173
|
+
focused?: boolean;
|
|
174
|
+
fnc?: void;
|
|
175
|
+
|
|
176
|
+
constructor(
|
|
177
|
+
row: T,
|
|
178
|
+
selected: boolean,
|
|
179
|
+
marked?: boolean,
|
|
180
|
+
index?: number,
|
|
181
|
+
fnc?: void
|
|
182
|
+
) {
|
|
183
|
+
this.row = row;
|
|
184
|
+
this.index = index;
|
|
185
|
+
this.selected = selected;
|
|
186
|
+
this.marked = marked;
|
|
187
|
+
this.fnc = fnc;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ContentChild, Directive, Input, TemplateRef } from '@angular/core';
|
|
2
|
+
import { Params } from '@angular/router';
|
|
3
|
+
import { ColumnDefinition, ColumnProvider, TABLE_COLUMN_PROVIDER } from './table.models';
|
|
4
|
+
|
|
5
|
+
@Directive({
|
|
6
|
+
// eslint-disable-next-line @angular-eslint/directive-selector
|
|
7
|
+
selector: '[v-templateColumn]',
|
|
8
|
+
standalone: true,
|
|
9
|
+
providers: [
|
|
10
|
+
{
|
|
11
|
+
provide: TABLE_COLUMN_PROVIDER,
|
|
12
|
+
useExisting: TemplateColumnDirective,
|
|
13
|
+
multi: true,
|
|
14
|
+
},
|
|
15
|
+
],
|
|
16
|
+
})
|
|
17
|
+
export class TemplateColumnDirective<T> implements ColumnProvider<T> {
|
|
18
|
+
@ContentChild(TemplateRef) template!: TemplateRef<T>;
|
|
19
|
+
|
|
20
|
+
@Input() index = 0;
|
|
21
|
+
|
|
22
|
+
@Input() id!: string;
|
|
23
|
+
|
|
24
|
+
@Input() columnClass!: string;
|
|
25
|
+
|
|
26
|
+
@Input() sortable!: boolean;
|
|
27
|
+
|
|
28
|
+
@Input() routerLink!: (row: T) => string;
|
|
29
|
+
|
|
30
|
+
@Input() queryParams!: Params;
|
|
31
|
+
|
|
32
|
+
@Input() headerName!: (column: string, index?: number) => string;
|
|
33
|
+
|
|
34
|
+
getDefinition(): ColumnDefinition<T> {
|
|
35
|
+
return {
|
|
36
|
+
id: this.id,
|
|
37
|
+
columnClass: this.columnClass,
|
|
38
|
+
template: this.template,
|
|
39
|
+
headerName: this.headerName,
|
|
40
|
+
routerLink: this.routerLink,
|
|
41
|
+
queryParams: this.queryParams,
|
|
42
|
+
sortable: this.sortable
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './table-filter.model';
|