@corp-products/ui-components 3.5.9 → 3.6.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/ng-package.json +7 -0
- package/package.json +22 -36
- package/src/enums/date-formatter.ts +22 -0
- package/src/helper/date-handler.ts +142 -0
- package/src/lib/alert-dialog/alert-dialog.component.html +22 -0
- package/src/lib/alert-dialog/alert-dialog.component.scss +0 -0
- package/src/lib/alert-dialog/alert-dialog.component.spec.ts +22 -0
- package/src/lib/alert-dialog/alert-dialog.component.ts +44 -0
- package/src/lib/alert-dialog/alert-dialog.interface.ts +6 -0
- package/src/lib/alert-dialog/alert-dialog.service.ts +33 -0
- package/src/lib/app-accordion/app-accordion.component.html +15 -0
- package/src/lib/app-accordion/app-accordion.component.scss +0 -0
- package/src/lib/app-accordion/app-accordion.component.spec.ts +21 -0
- package/src/lib/app-accordion/app-accordion.component.ts +21 -0
- package/src/lib/app-accordion/index.ts +2 -0
- package/src/lib/app-breadcrumb/app-breadcrumb.component.html +7 -0
- package/src/lib/app-breadcrumb/app-breadcrumb.component.scss +25 -0
- package/src/lib/app-breadcrumb/app-breadcrumb.component.ts +140 -0
- package/src/lib/app-breadcrumb/app-breadcrumb.interface.ts +15 -0
- package/src/lib/app-button/app-button.component.html +7 -0
- package/src/lib/app-button/app-button.component.scss +0 -0
- package/src/lib/app-button/app-button.component.ts +14 -0
- package/src/lib/app-button/app-button.ts +15 -0
- package/src/lib/app-button/index.ts +2 -0
- package/src/lib/app-dropdown-menu/app-dropdown-menu.component.html +22 -0
- package/src/lib/app-dropdown-menu/app-dropdown-menu.component.scss +39 -0
- package/src/lib/app-dropdown-menu/app-dropdown-menu.component.spec.ts +21 -0
- package/src/lib/app-dropdown-menu/app-dropdown-menu.component.ts +43 -0
- package/src/lib/app-dropdown-menu/app-dropdown-menu.ts +17 -0
- package/src/lib/app-dropdown-menu/index.ts +2 -0
- package/src/lib/app-dropdown-menu/menu-popup.pipe.ts +18 -0
- package/src/lib/app-header/app-header.component.html +26 -0
- package/src/lib/app-header/app-header.component.scss +0 -0
- package/src/lib/app-header/app-header.component.ts +43 -0
- package/src/lib/app-side-menu/app-side-menu.component.html +20 -0
- package/src/lib/app-side-menu/app-side-menu.component.ts +28 -0
- package/src/lib/app-side-menu/routes-names.ts +28 -0
- package/src/lib/app-side-menu/side-menu-items.ts +45 -0
- package/src/lib/app-side-menu/side-menu.ts +12 -0
- package/src/lib/app-tabs/app-tab.interface.ts +27 -0
- package/src/lib/app-tabs/app-tabs.component.html +37 -0
- package/src/lib/app-tabs/app-tabs.component.scss +103 -0
- package/src/lib/app-tabs/app-tabs.component.spec.ts +21 -0
- package/src/lib/app-tabs/app-tabs.component.ts +67 -0
- package/src/lib/app-tabs/index.ts +2 -0
- package/src/lib/bottom-sheet/bottom-sheet.component.html +18 -0
- package/src/lib/bottom-sheet/bottom-sheet.component.scss +31 -0
- package/src/lib/bottom-sheet/bottom-sheet.component.ts +26 -0
- package/src/lib/confirmation-dialog/confirmation-dialog.component.html +37 -0
- package/src/lib/confirmation-dialog/confirmation-dialog.component.scss +0 -0
- package/src/lib/confirmation-dialog/confirmation-dialog.component.spec.ts +22 -0
- package/src/lib/confirmation-dialog/confirmation-dialog.component.ts +64 -0
- package/src/lib/confirmation-dialog/confirmation-dialog.interface.ts +13 -0
- package/src/lib/confirmation-dialog/confirmation-dialog.service.ts +34 -0
- package/src/lib/dual-calender/date-picker-switcher/date-picker-switcher.component.html +27 -0
- package/src/lib/dual-calender/date-picker-switcher/date-picker-switcher.component.scss +22 -0
- package/src/lib/dual-calender/date-picker-switcher/date-picker-switcher.component.ts +64 -0
- package/src/lib/dual-calender/dual-calendar.component.html +32 -0
- package/src/lib/dual-calender/dual-calendar.component.scss +265 -0
- package/src/lib/dual-calender/dual-calendar.component.ts +158 -0
- package/src/lib/dual-calender/gregorian-calendar/gregorian-calendar.component.html +21 -0
- package/src/lib/dual-calender/gregorian-calendar/gregorian-calendar.component.scss +0 -0
- package/src/lib/dual-calender/gregorian-calendar/gregorian-calendar.component.spec.ts +21 -0
- package/src/lib/dual-calender/gregorian-calendar/gregorian-calendar.component.ts +65 -0
- package/src/lib/dual-calender/hijri-calendar/hijri-calendar.component.html +10 -0
- package/src/lib/dual-calender/hijri-calendar/hijri-calendar.component.scss +0 -0
- package/src/lib/dual-calender/hijri-calendar/hijri-calendar.component.spec.ts +21 -0
- package/src/lib/dual-calender/hijri-calendar/hijri-calendar.component.ts +66 -0
- package/src/lib/dual-calender/services/gregorian-i18n.service.ts +123 -0
- package/src/lib/dual-calender/services/islamic-i18n.service.ts +119 -0
- package/src/lib/dual-calender/utils/date-i18n.utils.ts +58 -0
- package/src/lib/dynamic-form/dynamic-form.component.html +84 -0
- package/src/lib/dynamic-form/dynamic-form.component.scss +0 -0
- package/src/lib/dynamic-form/dynamic-form.component.spec.ts +21 -0
- package/src/lib/dynamic-form/dynamic-form.component.ts +58 -0
- package/src/lib/dynamic-form/dynamic-form.interface.ts +96 -0
- package/src/lib/dynamic-side-bar-v2/dynamic-sidebar.component.html +32 -0
- package/src/lib/dynamic-side-bar-v2/dynamic-sidebar.component.scss +3 -0
- package/src/lib/dynamic-side-bar-v2/dynamic-sidebar.component.ts +82 -0
- package/src/lib/dynamic-side-bar-v2/dynamic-sidebar.config.ts +31 -0
- package/src/lib/dynamic-side-bar-v2/dynamic-sidebar.service.ts +41 -0
- package/src/lib/form-components/@utils/form-utils.ts +12 -0
- package/src/lib/form-components/@utils/validations/error-keys.enum.ts +25 -0
- package/src/lib/form-components/@utils/validations/form-validation.service.ts +68 -0
- package/src/lib/form-components/@utils/validations/index.ts +4 -0
- package/src/lib/form-components/@utils/validations/numbers-only.validator.ts +10 -0
- package/src/lib/form-components/@utils/validations/validation-message.pipe.ts +24 -0
- package/src/lib/form-components/components/auto-complete/auto-complete.component.html +35 -0
- package/src/lib/form-components/components/auto-complete/auto-complete.component.scss +12 -0
- package/src/lib/form-components/components/auto-complete/auto-complete.component.spec.ts +21 -0
- package/src/lib/form-components/components/auto-complete/auto-complete.component.ts +82 -0
- package/src/lib/form-components/components/base-input.component.ts +35 -0
- package/src/lib/form-components/components/date-picker/date-picker.component.html +40 -0
- package/src/lib/form-components/components/date-picker/date-picker.component.scss +32 -0
- package/src/lib/form-components/components/date-picker/date-picker.component.spec.ts +21 -0
- package/src/lib/form-components/components/date-picker/date-picker.component.ts +81 -0
- package/src/lib/form-components/components/date-picker/date-picker.validator.ts +38 -0
- package/src/lib/form-components/components/input/input.component.html +80 -0
- package/src/lib/form-components/components/input/input.component.scss +46 -0
- package/src/lib/form-components/components/input/input.component.spec.ts +21 -0
- package/src/lib/form-components/components/input/input.component.ts +56 -0
- package/src/lib/form-components/components/select/select.component.html +123 -0
- package/src/lib/form-components/components/select/select.component.scss +53 -0
- package/src/lib/form-components/components/select/select.component.spec.ts +21 -0
- package/src/lib/form-components/components/select/select.component.ts +87 -0
- package/src/lib/form-components/components/select-button/select-button.component.html +21 -0
- package/src/lib/form-components/components/select-button/select-button.component.scss +0 -0
- package/src/lib/form-components/components/select-button/select-button.component.spec.ts +21 -0
- package/src/lib/form-components/components/select-button/select-button.component.ts +22 -0
- package/src/lib/form-components/components/switcher/switch.component.html +5 -0
- package/src/lib/form-components/components/switcher/switch.component.scss +0 -0
- package/src/lib/form-components/components/switcher/switch.component.spec.ts +21 -0
- package/src/lib/form-components/components/switcher/switch.component.ts +25 -0
- package/src/lib/form-components/index.ts +9 -0
- package/src/lib/form-components/interfaces/index.ts +1 -0
- package/src/lib/form-components/interfaces/label-value.ts +4 -0
- package/src/lib/ico-moon-icon/ico-moon-icon.component.ts +23 -0
- package/src/lib/read-more/read-more.component.html +17 -0
- package/src/lib/read-more/read-more.component.scss +0 -0
- package/src/lib/read-more/read-more.component.spec.ts +21 -0
- package/src/lib/read-more/read-more.component.ts +21 -0
- package/src/lib/side-bar/side-bar.component.html +24 -0
- package/src/lib/side-bar/side-bar.component.scss +22 -0
- package/src/lib/side-bar/side-bar.component.spec.ts +21 -0
- package/src/lib/side-bar/side-bar.component.ts +33 -0
- package/src/lib/side-bar-dynamic/data-injector.pipe.ts +15 -0
- package/src/lib/side-bar-dynamic/dynamic-sidebar.service.ts +116 -0
- package/src/lib/side-bar-dynamic/side-bar-dynamic.component.html +42 -0
- package/src/lib/side-bar-dynamic/side-bar-dynamic.component.scss +5 -0
- package/src/lib/side-bar-dynamic/side-bar-dynamic.component.spec.ts +21 -0
- package/src/lib/side-bar-dynamic/side-bar-dynamic.component.ts +37 -0
- package/src/lib/side-bar-dynamic/side-bar-utils.ts +30 -0
- package/src/lib/side-bar-dynamic/sidebar-config.ts +48 -0
- package/src/lib/user-autocomplete-card/user-autocomplete-card.component.html +20 -0
- package/src/lib/user-autocomplete-card/user-autocomplete-card.component.scss +0 -0
- package/src/lib/user-autocomplete-card/user-autocomplete-card.component.spec.ts +21 -0
- package/src/lib/user-autocomplete-card/user-autocomplete-card.component.ts +21 -0
- package/src/lib/user-info/user-info.component.html +10 -0
- package/src/lib/user-info/user-info.component.ts +11 -0
- package/src/public-api.ts +29 -0
- package/tsconfig.lib.json +18 -0
- package/tsconfig.lib.prod.json +11 -0
- package/tsconfig.spec.json +14 -0
- package/fesm2022/corp-products-ui-components.mjs +0 -2253
- package/fesm2022/corp-products-ui-components.mjs.map +0 -1
- package/index.d.ts +0 -721
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
import { AutoCompleteComponent } from './auto-complete.component';
|
|
3
|
+
|
|
4
|
+
describe('AutoCompleteComponent', () => {
|
|
5
|
+
let component: AutoCompleteComponent;
|
|
6
|
+
let fixture: ComponentFixture<AutoCompleteComponent>;
|
|
7
|
+
|
|
8
|
+
beforeEach(async () => {
|
|
9
|
+
await TestBed.configureTestingModule({
|
|
10
|
+
imports: [AutoCompleteComponent],
|
|
11
|
+
}).compileComponents();
|
|
12
|
+
|
|
13
|
+
fixture = TestBed.createComponent(AutoCompleteComponent);
|
|
14
|
+
component = fixture.componentInstance;
|
|
15
|
+
fixture.detectChanges();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('should create', () => {
|
|
19
|
+
expect(component).toBeTruthy();
|
|
20
|
+
});
|
|
21
|
+
});
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { JsonPipe, NgClass, NgIf, NgTemplateOutlet } from '@angular/common';
|
|
2
|
+
import { Component, EventEmitter, Input, Output, TemplateRef, ViewEncapsulation } from '@angular/core';
|
|
3
|
+
import { ReactiveFormsModule } from '@angular/forms';
|
|
4
|
+
import { TranslatePipe } from '@ngx-translate/core';
|
|
5
|
+
import { PrimeTemplate } from 'primeng/api';
|
|
6
|
+
import {
|
|
7
|
+
AutoComplete,
|
|
8
|
+
AutoCompleteCompleteEvent,
|
|
9
|
+
AutoCompleteSelectEvent,
|
|
10
|
+
} from 'primeng/autocomplete';
|
|
11
|
+
import { FloatLabel } from 'primeng/floatlabel';
|
|
12
|
+
import { ValidationErrorsPipe } from '../../@utils/validations/validation-message.pipe';
|
|
13
|
+
import { BaseInputComponent } from '../base-input.component';
|
|
14
|
+
|
|
15
|
+
@Component({
|
|
16
|
+
selector: 'stc-auto-complete',
|
|
17
|
+
standalone: true,
|
|
18
|
+
imports: [
|
|
19
|
+
ReactiveFormsModule,
|
|
20
|
+
AutoComplete,
|
|
21
|
+
PrimeTemplate,
|
|
22
|
+
NgIf,
|
|
23
|
+
NgTemplateOutlet,
|
|
24
|
+
NgClass,
|
|
25
|
+
JsonPipe,
|
|
26
|
+
ValidationErrorsPipe,
|
|
27
|
+
TranslatePipe,
|
|
28
|
+
FloatLabel,
|
|
29
|
+
],
|
|
30
|
+
templateUrl: './auto-complete.component.html',
|
|
31
|
+
styleUrl: './auto-complete.component.scss',
|
|
32
|
+
encapsulation: ViewEncapsulation.None
|
|
33
|
+
})
|
|
34
|
+
export class AutoCompleteComponent extends BaseInputComponent {
|
|
35
|
+
@Input() selectedItemTemplate: TemplateRef<unknown> | null = null;
|
|
36
|
+
// eslint-disable-next-line @angular-eslint/no-output-on-prefix
|
|
37
|
+
@Output() onSearch: EventEmitter<string> = new EventEmitter<string>();
|
|
38
|
+
@Output() selectOption: EventEmitter<AutoCompleteSelectEvent> =
|
|
39
|
+
new EventEmitter<AutoCompleteSelectEvent>();
|
|
40
|
+
@Input() items: any[] = [];
|
|
41
|
+
@Input() minLengthToSearch = 3;
|
|
42
|
+
@Input() delay = 300; // default value
|
|
43
|
+
@Input() basicInput!: boolean;
|
|
44
|
+
@Input() typeAhead: boolean = false;
|
|
45
|
+
@Input() variant: 'in' | 'over' | 'on' = 'over';
|
|
46
|
+
|
|
47
|
+
constructor() {
|
|
48
|
+
super();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
search(event: AutoCompleteCompleteEvent) {
|
|
52
|
+
this.onSearch.emit(event.query);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
onSelect(event: AutoCompleteSelectEvent) {
|
|
56
|
+
this.selectOption.emit(event);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
onKeyDown(event: KeyboardEvent) {
|
|
60
|
+
if (!['Enter', 'Tab', ' '].includes(event.key)) return;
|
|
61
|
+
event.preventDefault();
|
|
62
|
+
const input = event.target as HTMLInputElement;
|
|
63
|
+
this.addValueFromInput(input);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
onBlur(event: Event) {
|
|
67
|
+
const input = event.target as HTMLInputElement;
|
|
68
|
+
this.addValueFromInput(input);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
private addValueFromInput(input: HTMLInputElement) {
|
|
72
|
+
const value = input.value?.trim();
|
|
73
|
+
if (!value) return;
|
|
74
|
+
const current = this.control.value ?? [];
|
|
75
|
+
if (!current.includes(value)) {
|
|
76
|
+
this.control.setValue([...current, value]);
|
|
77
|
+
this.control.markAsDirty();
|
|
78
|
+
}
|
|
79
|
+
input.value = '';
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Component, Input, OnDestroy, OnInit } from '@angular/core';
|
|
2
|
+
import { FormControl, Validators } from '@angular/forms';
|
|
3
|
+
import { Subject, takeUntil } from 'rxjs';
|
|
4
|
+
@Component({
|
|
5
|
+
template: '',
|
|
6
|
+
})
|
|
7
|
+
export abstract class BaseInputComponent implements OnInit, OnDestroy {
|
|
8
|
+
@Input({ required: true }) control!: FormControl;
|
|
9
|
+
@Input() name: string = '';
|
|
10
|
+
@Input() label?: string;
|
|
11
|
+
@Input() placeholder: string = '';
|
|
12
|
+
@Input() inputId!: string;
|
|
13
|
+
@Input() readonly: boolean = false;
|
|
14
|
+
@Input() disabled: boolean = false;
|
|
15
|
+
@Input() hint?: string;
|
|
16
|
+
|
|
17
|
+
protected destroy$ = new Subject<void>();
|
|
18
|
+
|
|
19
|
+
get required(): boolean {
|
|
20
|
+
return this.control.hasValidator(Validators.required);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
get isInvalid(): boolean {
|
|
24
|
+
return this.control.invalid && this.control.touched;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
ngOnInit() {
|
|
28
|
+
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
ngOnDestroy(): void {
|
|
32
|
+
this.destroy$.next();
|
|
33
|
+
this.destroy$.complete();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<div class="field flex flex-col gap-2 my-3 relative">
|
|
2
|
+
<p-floatlabel [variant]="variant">
|
|
3
|
+
<p-datepicker [selectionMode]="selectionMode" [disabled]="disabled" [formControl]="innerControl"
|
|
4
|
+
(onSelect)="onDateChange($event)" [iconDisplay]="'input'" [showClear]="showClear" (onClear)="afterClearDate()"
|
|
5
|
+
[inputId]="inputId" [inputStyleClass]="'reset-default-styles ' + (basicInput ? 'basic-style' : '')"
|
|
6
|
+
[ngClass]="{ 'p-invalid ng-dirty ng-invalid': isInvalid }" [placeholder]="placeholder" [showIcon]="showIcon"
|
|
7
|
+
[class]="'w-full'" appendTo="body" [timeOnly]="isTimeOnly" [hourFormat]="hourFormat" [minDate]="minDate"
|
|
8
|
+
[maxDate]="maxDate" panelStyleClass="d-ltr">
|
|
9
|
+
@if (isTimeOnly) {
|
|
10
|
+
<ng-template #inputicon let-clickCallBack="clickCallBack">
|
|
11
|
+
<i class="text-[18px] font-icon-time-clock" (click)="clickCallBack($event)"></i>
|
|
12
|
+
</ng-template>
|
|
13
|
+
<ng-template pTemplate="footer">
|
|
14
|
+
<div class="p-datepicker-buttonbar">
|
|
15
|
+
<button pButton type="button" class="p-button-text" (click)="selectCurrentTime($event)">الان
|
|
16
|
+
</button>
|
|
17
|
+
<button pButton type="button" class="p-button-text" (click)="clearButtonClick($event)"> الغاء</button>
|
|
18
|
+
</div>
|
|
19
|
+
</ng-template>
|
|
20
|
+
}
|
|
21
|
+
</p-datepicker>
|
|
22
|
+
|
|
23
|
+
<label [for]="inputId">
|
|
24
|
+
{{ label }}
|
|
25
|
+
@if (required) {
|
|
26
|
+
<span [class.text-required]="required">*</span>
|
|
27
|
+
}
|
|
28
|
+
</label>
|
|
29
|
+
</p-floatlabel>
|
|
30
|
+
@if (hint) {
|
|
31
|
+
<small class="p-mt-1">{{ hint }}</small>
|
|
32
|
+
}
|
|
33
|
+
@if (isInvalid && (control.dirty || control.touched)) {
|
|
34
|
+
<small class="p-error">
|
|
35
|
+
@for (error of control.errors | validationErrors; track error) {
|
|
36
|
+
{{ error }}<br>
|
|
37
|
+
}
|
|
38
|
+
</small>
|
|
39
|
+
}
|
|
40
|
+
</div>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
.p-datepicker {
|
|
2
|
+
@apply relative;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.p-datepicker-clear-icon {
|
|
6
|
+
@apply cursor-pointer absolute top-[50%] left-[13px] text-[var(--p-datepicker-input-icon-color)] ml-[calc(var(--p-icon-size))] leading-none;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.d-ltr {
|
|
10
|
+
direction: ltr;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
.text-required {
|
|
15
|
+
color: red;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.p-error {
|
|
19
|
+
color: #dc2626;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
stc-date-picker.w-full,
|
|
23
|
+
stc-date-picker.w-full .field,
|
|
24
|
+
stc-date-picker.w-full .p-floatlabel,
|
|
25
|
+
stc-date-picker.w-full .p-datepicker,
|
|
26
|
+
stc-date-picker.w-full .p-inputtext {
|
|
27
|
+
@apply w-full;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
stc-date-picker.w-full .p-datepicker {
|
|
31
|
+
@apply block;
|
|
32
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
import { DatePickerComponent } from 'nx-BOD-workspace/libs/ui-components/src/lib/form-components/components/date-picker/date-picker.component';
|
|
3
|
+
|
|
4
|
+
describe('DatePickerComponent', () => {
|
|
5
|
+
let component: DatePickerComponent;
|
|
6
|
+
let fixture: ComponentFixture<DatePickerComponent>;
|
|
7
|
+
|
|
8
|
+
beforeEach(async () => {
|
|
9
|
+
await TestBed.configureTestingModule({
|
|
10
|
+
imports: [DatePickerComponent],
|
|
11
|
+
}).compileComponents();
|
|
12
|
+
|
|
13
|
+
fixture = TestBed.createComponent(DatePickerComponent);
|
|
14
|
+
component = fixture.componentInstance;
|
|
15
|
+
fixture.detectChanges();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('should create', () => {
|
|
19
|
+
expect(component).toBeTruthy();
|
|
20
|
+
});
|
|
21
|
+
});
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { NgClass } from '@angular/common';
|
|
2
|
+
import { Component, EventEmitter, Input, Output, ViewEncapsulation } from '@angular/core';
|
|
3
|
+
import { FormControl, FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
4
|
+
import { ValidationErrorsPipe } from '../../@utils/validations';
|
|
5
|
+
import { DatePicker, DatePickerModule } from 'primeng/datepicker';
|
|
6
|
+
import { FloatLabelModule } from 'primeng/floatlabel';
|
|
7
|
+
import { BaseInputComponent } from '../base-input.component';
|
|
8
|
+
import { formatDate } from '@angular/common';
|
|
9
|
+
|
|
10
|
+
@Component({
|
|
11
|
+
selector: 'stc-date-picker',
|
|
12
|
+
standalone: true,
|
|
13
|
+
imports: [
|
|
14
|
+
FormsModule,
|
|
15
|
+
DatePicker,
|
|
16
|
+
ReactiveFormsModule,
|
|
17
|
+
NgClass,
|
|
18
|
+
DatePickerModule,
|
|
19
|
+
ValidationErrorsPipe,
|
|
20
|
+
FloatLabelModule,
|
|
21
|
+
],
|
|
22
|
+
templateUrl: './date-picker.component.html',
|
|
23
|
+
styleUrl: './date-picker.component.scss',
|
|
24
|
+
encapsulation: ViewEncapsulation.None,
|
|
25
|
+
})
|
|
26
|
+
export class DatePickerComponent extends BaseInputComponent {
|
|
27
|
+
@Input() showIcon: boolean = false;
|
|
28
|
+
@Input() showClear: boolean = false;
|
|
29
|
+
@Input() basicInput!: boolean;
|
|
30
|
+
@Input() isTimeOnly: boolean = false;
|
|
31
|
+
@Input() minDate: Date | undefined | null;
|
|
32
|
+
@Input() maxDate: Date | undefined | null;
|
|
33
|
+
@Input() hourFormat: '12' | '24' = '12';
|
|
34
|
+
nowTime = new Date();
|
|
35
|
+
@Input() selectionMode: 'single' | 'range' = 'single';
|
|
36
|
+
@Output() onAfterClearDate = new EventEmitter<void>();
|
|
37
|
+
@Input() variant: 'in' | 'over' | 'on' = 'over';
|
|
38
|
+
@Input() withoutTime: boolean = false;
|
|
39
|
+
innerControl = new FormControl<Date | null>(null);
|
|
40
|
+
|
|
41
|
+
constructor() {
|
|
42
|
+
super();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
override ngOnInit() {
|
|
46
|
+
if (typeof this.control?.value === 'string') {
|
|
47
|
+
const date = new Date(this.control.value);
|
|
48
|
+
if (date) {
|
|
49
|
+
this.innerControl.setValue(date, { emitEvent: false });
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
this.control.valueChanges.subscribe((value) => {
|
|
54
|
+
if (!value) this.innerControl.reset();
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
selectCurrentTime(e: any) {
|
|
59
|
+
if (this.withoutTime) {
|
|
60
|
+
const d = new Date();
|
|
61
|
+
this.control.setValue(d.toISOString().split('T')[0]);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
this.control.setValue(this.nowTime);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
clearButtonClick(e: any) {
|
|
68
|
+
this.control.setValue(null);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
afterClearDate() {
|
|
72
|
+
this.control.reset();
|
|
73
|
+
this.onAfterClearDate.emit();
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
onDateChange(value: any) {
|
|
77
|
+
if (!this.withoutTime || !value) return;
|
|
78
|
+
const dateOnly = value instanceof Date ? formatDate(value, 'yyyy-MM-dd', 'en-US') : value;
|
|
79
|
+
this.control.setValue(dateOnly, { emitEvent: true });
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { AbstractControl, ValidationErrors, ValidatorFn } from '@angular/forms';
|
|
2
|
+
|
|
3
|
+
export const dateRangeValidator =
|
|
4
|
+
(fromKey: string, toKey: string): ValidatorFn =>
|
|
5
|
+
(control: AbstractControl): ValidationErrors | null => {
|
|
6
|
+
const fromControl = control.get?.(fromKey);
|
|
7
|
+
const toControl = control.get?.(toKey);
|
|
8
|
+
|
|
9
|
+
if (!fromControl?.value || !toControl?.value) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const from = new Date(fromControl.value);
|
|
14
|
+
const to = new Date(toControl.value);
|
|
15
|
+
|
|
16
|
+
from.setHours(0, 0, 0, 0);
|
|
17
|
+
to.setHours(0, 0, 0, 0);
|
|
18
|
+
|
|
19
|
+
return from > to ? { invalidDateRange: true } : null;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const notFutureDateValidator =
|
|
23
|
+
(dateKey: string): ValidatorFn =>
|
|
24
|
+
(control: AbstractControl): ValidationErrors | null => {
|
|
25
|
+
const dateControl = control.get?.(dateKey);
|
|
26
|
+
|
|
27
|
+
if (!dateControl?.value) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const valueDate = new Date(dateControl.value);
|
|
32
|
+
valueDate.setHours(0, 0, 0, 0);
|
|
33
|
+
|
|
34
|
+
const today = new Date();
|
|
35
|
+
today.setHours(0, 0, 0, 0);
|
|
36
|
+
|
|
37
|
+
return valueDate > today ? { futureDate: true } : null;
|
|
38
|
+
};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
<div class="field flex flex-col gap-2 my-3 relative">
|
|
2
|
+
|
|
3
|
+
<!-- input text align will be handled according to lang when implemented -->
|
|
4
|
+
|
|
5
|
+
@switch (type) {
|
|
6
|
+
@case ('textarea') {
|
|
7
|
+
@if (label) {
|
|
8
|
+
<div class="flex items-center justify-between gap-2">
|
|
9
|
+
<label [for]="inputId">
|
|
10
|
+
{{ label }}
|
|
11
|
+
@if (required) {
|
|
12
|
+
<span [class.text-required]="required">*</span>
|
|
13
|
+
}
|
|
14
|
+
<!-- @else if (!hideOptionalLabel) {
|
|
15
|
+
<span span class="optional-label">{{'forms.config.optional' | translate}}</span>
|
|
16
|
+
} -->
|
|
17
|
+
</label>
|
|
18
|
+
<ng-content></ng-content>
|
|
19
|
+
</div>
|
|
20
|
+
}
|
|
21
|
+
<textarea [name]="name" [id]="inputId" [formControl]="control" [placeholder]="placeholder" [readonly]="readonly"
|
|
22
|
+
[disabled]="disabled" pTextarea [rows]="rows" [cols]="cols" [autoResize]="autoResize" [class]="
|
|
23
|
+
'w-full border border-[' + defaultColor + '] rounded-none focus:outline-[' + defaultColor + '] focus:border-[' + defaultColor + '] hover:border-[' + defaultColor + '] disabled:opacity-50'
|
|
24
|
+
"
|
|
25
|
+
[ngClass]="{'ng-invalid ng-dirty': control.invalid && (control.dirty || control.touched), 'basic-style': basicInput, 'no-style':noStyle}">
|
|
26
|
+
</textarea>
|
|
27
|
+
}
|
|
28
|
+
@case ('withIcon') {
|
|
29
|
+
<p-iconfield class="filter-input">
|
|
30
|
+
<p-inputicon>
|
|
31
|
+
<i [class]="iconClass"></i>
|
|
32
|
+
</p-inputicon>
|
|
33
|
+
<input pInputText [id]="inputId" type="text" [placeholder]="placeholder" [formControl]="control" [readonly]="readonly"
|
|
34
|
+
[class]="
|
|
35
|
+
'w-full border border-[' + defaultColor + '] rounded-none focus:outline-[' + defaultColor + '] focus:border-[' + defaultColor + '] hover:border-[' + defaultColor + '] disabled:opacity-50'"
|
|
36
|
+
[ngClass]="{ 'p-invalid ng-dirty ng-invalid': isInvalid, 'basic-style': basicInput, 'no-style':noStyle}" />
|
|
37
|
+
@if (canClear && control.value) {
|
|
38
|
+
<p-inputIcon (click)="clearInput()">
|
|
39
|
+
<i class="pi pi-times cursor-pointer text-sm text-gray-400 hover:text-gray-600"></i>
|
|
40
|
+
</p-inputIcon>
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
</p-iconfield>
|
|
44
|
+
}
|
|
45
|
+
@default {
|
|
46
|
+
<p-floatlabel [variant]="variant">
|
|
47
|
+
<!-- <input pInputText id="value2" [(ngModel)]="value2" [invalid]="!value2" autocomplete="off" /> -->
|
|
48
|
+
<input [id]="inputId" [type]="'text-float-label'" [formControl]="control" [readonly]="readonly" [pSize]="size"
|
|
49
|
+
[class]="
|
|
50
|
+
'w-full border border-[' + defaultColor + '] rounded-none focus:outline-[' + defaultColor + '] focus:border-[' + defaultColor + '] hover:border-[' + defaultColor + '] disabled:opacity-50'
|
|
51
|
+
" [disabled]="disabled" [name]="name" pInputText [ngStyle]="{'direction': inputDirection || 'inherit'}"
|
|
52
|
+
class="w-full"
|
|
53
|
+
[ngClass]="{ 'p-invalid ng-dirty ng-invalid': isInvalid, 'basic-style': basicInput, 'no-style':noStyle}" />
|
|
54
|
+
<label [for]="inputId">
|
|
55
|
+
{{ label }}
|
|
56
|
+
@if (required) {
|
|
57
|
+
<span [class.text-required]="required">*</span>
|
|
58
|
+
}
|
|
59
|
+
</label>
|
|
60
|
+
</p-floatlabel>
|
|
61
|
+
@if (prefix) {
|
|
62
|
+
<span class="absolute top-[40px] font-bold text-[16px] left-[25px]">
|
|
63
|
+
{{ prefix }}
|
|
64
|
+
</span>
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
@if (hint) {
|
|
71
|
+
<small class="p-mt-1">{{ hint }}</small>
|
|
72
|
+
}
|
|
73
|
+
@if (isInvalid && (control.dirty || control.touched)) {
|
|
74
|
+
<small class="p-error">
|
|
75
|
+
@for (error of control.errors | validationErrors; track error) {
|
|
76
|
+
{{ error }}<br>
|
|
77
|
+
}
|
|
78
|
+
</small>
|
|
79
|
+
}
|
|
80
|
+
</div>
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
textarea {
|
|
2
|
+
@apply h-auto min-h-[50px] overflow-auto;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
textarea,
|
|
7
|
+
.p-select, input {
|
|
8
|
+
border-radius: 0 ;
|
|
9
|
+
border-color: #DFE0E6 ;
|
|
10
|
+
|
|
11
|
+
&:enabled {
|
|
12
|
+
&:hover {
|
|
13
|
+
border-color: #DFE0E6 ;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
&:not(.p-disabled).p-focus,
|
|
18
|
+
&:not(.p-disabled).p-focus:hover,
|
|
19
|
+
&:focus {
|
|
20
|
+
outline: #DFE0E6 ;
|
|
21
|
+
border-color: #DFE0E6 ;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
.p-floatlabel:has(input:focus) label,
|
|
25
|
+
.p-floatlabel:has(input:-webkit-autofill) label,
|
|
26
|
+
.p-floatlabel:has(textarea:focus) label,
|
|
27
|
+
.p-floatlabel:has(.p-inputwrapper-focus) label {
|
|
28
|
+
color: #687078;
|
|
29
|
+
|
|
30
|
+
}
|
|
31
|
+
.p-inputtext:enabled:focus {
|
|
32
|
+
border-color: #DFE0E6 ;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.text-required {
|
|
36
|
+
color: red;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.p-error {
|
|
40
|
+
color: #dc2626;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.optional-label {
|
|
44
|
+
@apply text-[10px] text-gray-400;
|
|
45
|
+
margin-inline-start: 4px;
|
|
46
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
import { InputComponent } from './input.component';
|
|
3
|
+
|
|
4
|
+
describe('InputComponent', () => {
|
|
5
|
+
let component: InputComponent;
|
|
6
|
+
let fixture: ComponentFixture<InputComponent>;
|
|
7
|
+
|
|
8
|
+
beforeEach(async () => {
|
|
9
|
+
await TestBed.configureTestingModule({
|
|
10
|
+
imports: [InputComponent],
|
|
11
|
+
}).compileComponents();
|
|
12
|
+
|
|
13
|
+
fixture = TestBed.createComponent(InputComponent);
|
|
14
|
+
component = fixture.componentInstance;
|
|
15
|
+
fixture.detectChanges();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('should create', () => {
|
|
19
|
+
expect(component).toBeTruthy();
|
|
20
|
+
});
|
|
21
|
+
});
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { NgClass, NgStyle } from '@angular/common';
|
|
2
|
+
import { Component, Input } from '@angular/core';
|
|
3
|
+
import { ReactiveFormsModule } from '@angular/forms';
|
|
4
|
+
import { TranslatePipe } from '@ngx-translate/core';
|
|
5
|
+
import { FloatLabelModule } from 'primeng/floatlabel';
|
|
6
|
+
import { InputText } from 'primeng/inputtext';
|
|
7
|
+
import { Textarea } from 'primeng/textarea';
|
|
8
|
+
import { ValidationErrorsPipe } from '../../@utils/validations/validation-message.pipe';
|
|
9
|
+
import { BaseInputComponent } from '../base-input.component';
|
|
10
|
+
import { IconField } from 'primeng/iconfield';
|
|
11
|
+
import { InputIcon } from 'primeng/inputicon';
|
|
12
|
+
@Component({
|
|
13
|
+
selector: 'stc-input',
|
|
14
|
+
standalone: true,
|
|
15
|
+
imports: [
|
|
16
|
+
ReactiveFormsModule,
|
|
17
|
+
InputText,
|
|
18
|
+
Textarea,
|
|
19
|
+
ValidationErrorsPipe,
|
|
20
|
+
NgClass,
|
|
21
|
+
NgStyle,
|
|
22
|
+
TranslatePipe,
|
|
23
|
+
FloatLabelModule,
|
|
24
|
+
InputIcon,
|
|
25
|
+
IconField,
|
|
26
|
+
],
|
|
27
|
+
templateUrl: './input.component.html',
|
|
28
|
+
styleUrl: './input.component.scss',
|
|
29
|
+
})
|
|
30
|
+
export class InputComponent extends BaseInputComponent {
|
|
31
|
+
@Input() type: 'text' | 'textarea' | 'withIcon' = 'text';
|
|
32
|
+
@Input() contentType: 'text' | 'email' | 'number' = 'text';
|
|
33
|
+
@Input() size: 'small' | 'large' = "small";
|
|
34
|
+
@Input() prefix: string;
|
|
35
|
+
@Input() rows = 2;
|
|
36
|
+
@Input() cols = 20;
|
|
37
|
+
@Input() autoResize = false;
|
|
38
|
+
@Input() basicInput!: boolean;
|
|
39
|
+
@Input() noStyle!: boolean;
|
|
40
|
+
@Input() canClear!: boolean;
|
|
41
|
+
@Input() hideOptionalLabel: boolean;
|
|
42
|
+
@Input() inputDirection: 'ltr' | 'rtl' | 'inherit' = 'inherit';
|
|
43
|
+
@Input() variant: 'in' | 'over' | 'on' = 'over';
|
|
44
|
+
@Input() defaultColor = '#DFE0E6'
|
|
45
|
+
@Input() iconClass?: string;
|
|
46
|
+
@Input() iconPosition: 'left' | 'right' = 'left';
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
constructor() {
|
|
50
|
+
super();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
clearInput() {
|
|
54
|
+
this.control.reset();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
<div class="field flex flex-col gap-2 my-3 relative">
|
|
2
|
+
|
|
3
|
+
@if(multiple) {
|
|
4
|
+
<p-floatLabel [variant]="variant">
|
|
5
|
+
|
|
6
|
+
<p-multiselect
|
|
7
|
+
[disabled]="disabled"
|
|
8
|
+
[filterBy]="filterBy"
|
|
9
|
+
[filter]="filter"
|
|
10
|
+
[formControl]="control"
|
|
11
|
+
[id]="inputId"
|
|
12
|
+
[name]="name"
|
|
13
|
+
[ngClass]="{ 'p-invalid ng-dirty ng-invalid': isInvalid }"
|
|
14
|
+
[optionLabel]="optionLabel"
|
|
15
|
+
[optionValue]="optionValue"
|
|
16
|
+
[options]="options"
|
|
17
|
+
[showToggleAll]="false"
|
|
18
|
+
[placeholder]="placeholder"
|
|
19
|
+
[emptyMessage]="emptyMessage || ('shared.no_results_found'|translate)"
|
|
20
|
+
[readonly]="readonly"
|
|
21
|
+
[showClear]="showClear"
|
|
22
|
+
(onClear)="onMultiSelectClear()"
|
|
23
|
+
class="w-full"
|
|
24
|
+
[size]="size"
|
|
25
|
+
[selectedItemsLabel]="selectedItemsLabel || ('shared.Items_Selected'| translate: {count: '{0}'})"
|
|
26
|
+
[class]="
|
|
27
|
+
'w-full border border-[' + defaultColor + '] rounded-none focus:outline-[' + defaultColor + '] focus:border-[' + defaultColor + '] hover:border-[' + defaultColor + '] disabled:opacity-50'
|
|
28
|
+
"
|
|
29
|
+
(onChange)="onChange($event)"
|
|
30
|
+
[ngClass]="{ 'basic-style': basicInput }"
|
|
31
|
+
>
|
|
32
|
+
|
|
33
|
+
@if (selectAllLabel) {
|
|
34
|
+
<ng-template #filter>
|
|
35
|
+
<p-checkbox
|
|
36
|
+
binary="true"
|
|
37
|
+
[(ngModel)]="allSelectd"
|
|
38
|
+
(onChange)="toggleAll($event)"
|
|
39
|
+
inputId="toggleAll">
|
|
40
|
+
</p-checkbox>
|
|
41
|
+
<span>{{selectAllLabel}}</span>
|
|
42
|
+
</ng-template>
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@if(optionTemplate){
|
|
46
|
+
<ng-template let-item #item>
|
|
47
|
+
<ng-container [ngTemplateOutletContext]="{ $implicit: item }" [ngTemplateOutlet]="optionTemplate" />
|
|
48
|
+
</ng-template>
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
</p-multiselect>
|
|
56
|
+
<label [for]="inputId">
|
|
57
|
+
{{ label }}
|
|
58
|
+
@if (required) {
|
|
59
|
+
<span [class.text-required]="required">*</span>
|
|
60
|
+
}
|
|
61
|
+
</label>
|
|
62
|
+
|
|
63
|
+
</p-floatLabel>
|
|
64
|
+
|
|
65
|
+
} @else {
|
|
66
|
+
<p-floatLabel [variant]="variant">
|
|
67
|
+
<p-select
|
|
68
|
+
[dataKey]="dataKey"
|
|
69
|
+
[checkmark]="checkmark"
|
|
70
|
+
[disabled]="disabled"
|
|
71
|
+
[editable]="editable"
|
|
72
|
+
[filterBy]="filterBy"
|
|
73
|
+
[filter]="filter"
|
|
74
|
+
[formControl]="control"
|
|
75
|
+
[id]="inputId"
|
|
76
|
+
[name]="name"
|
|
77
|
+
[ngClass]="{ 'p-invalid ng-dirty ng-invalid': isInvalid }"
|
|
78
|
+
[emptyMessage]="emptyMessage || ('shared.no_results_found'|translate)"
|
|
79
|
+
[optionLabel]="optionLabel"
|
|
80
|
+
[optionValue]="optionValue"
|
|
81
|
+
[options]="options"
|
|
82
|
+
[placeholder]="placeholder"
|
|
83
|
+
[readonly]="readonly"
|
|
84
|
+
[showClear]="showClear"
|
|
85
|
+
[size]="size"
|
|
86
|
+
class="w-full"
|
|
87
|
+
[class]="
|
|
88
|
+
'w-full border border-[' + defaultColor + '] rounded-none focus:outline-[' + defaultColor + '] focus:border-[' + defaultColor + '] hover:border-[' + defaultColor + '] disabled:opacity-50'
|
|
89
|
+
"
|
|
90
|
+
(onChange)="onChange($event)"
|
|
91
|
+
[ngClass]="{ 'basic-style': basicInput }"
|
|
92
|
+
>
|
|
93
|
+
|
|
94
|
+
@if (optionTemplate) {
|
|
95
|
+
<ng-template let-item pTemplate="item">
|
|
96
|
+
<ng-container [ngTemplateOutletContext]="{ $implicit: item }" [ngTemplateOutlet]="optionTemplate" />
|
|
97
|
+
</ng-template>
|
|
98
|
+
}
|
|
99
|
+
@if (selectedItemTemplate) {
|
|
100
|
+
<ng-template let-item pTemplate="selectedItem">
|
|
101
|
+
<ng-container [ngTemplateOutletContext]="{ $implicit: item }" [ngTemplateOutlet]="selectedItemTemplate" />
|
|
102
|
+
</ng-template>
|
|
103
|
+
}
|
|
104
|
+
</p-select>
|
|
105
|
+
<label [for]="inputId">
|
|
106
|
+
{{ label }}
|
|
107
|
+
@if (required) {
|
|
108
|
+
<span [class.text-required]="required">*</span>
|
|
109
|
+
}
|
|
110
|
+
</label>
|
|
111
|
+
</p-floatLabel>
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
@if (hint) {
|
|
115
|
+
<small class="p-mt-1">{{ hint }}</small>
|
|
116
|
+
} @if (isInvalid && (control.dirty || control.touched)) {
|
|
117
|
+
<small class="p-error">
|
|
118
|
+
@for (error of control.errors | validationErrors; track error) {
|
|
119
|
+
{{ error }}<br />
|
|
120
|
+
}
|
|
121
|
+
</small>
|
|
122
|
+
}
|
|
123
|
+
</div>
|