@corp-products/ui-components 3.2.9 → 3.3.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/fesm2022/corp-products-ui-components.mjs +1999 -0
- package/fesm2022/corp-products-ui-components.mjs.map +1 -0
- package/index.d.ts +653 -0
- package/package.json +36 -22
- package/ng-package.json +0 -7
- package/src/enums/date-formatter.ts +0 -21
- package/src/helper/date-handler.ts +0 -142
- package/src/lib/app-accordion/app-accordion.component.html +0 -15
- package/src/lib/app-accordion/app-accordion.component.scss +0 -0
- package/src/lib/app-accordion/app-accordion.component.spec.ts +0 -21
- package/src/lib/app-accordion/app-accordion.component.ts +0 -21
- package/src/lib/app-accordion/index.ts +0 -2
- package/src/lib/app-breadcrumb/app-breadcrumb.component.html +0 -7
- package/src/lib/app-breadcrumb/app-breadcrumb.component.scss +0 -25
- package/src/lib/app-breadcrumb/app-breadcrumb.component.ts +0 -140
- package/src/lib/app-breadcrumb/app-breadcrumb.interface.ts +0 -15
- package/src/lib/app-button/app-button.component.html +0 -7
- package/src/lib/app-button/app-button.component.scss +0 -0
- package/src/lib/app-button/app-button.component.ts +0 -14
- package/src/lib/app-button/app-button.ts +0 -15
- package/src/lib/app-button/index.ts +0 -2
- package/src/lib/app-dropdown-menu/app-dropdown-menu.component.html +0 -22
- package/src/lib/app-dropdown-menu/app-dropdown-menu.component.scss +0 -39
- package/src/lib/app-dropdown-menu/app-dropdown-menu.component.spec.ts +0 -21
- package/src/lib/app-dropdown-menu/app-dropdown-menu.component.ts +0 -43
- package/src/lib/app-dropdown-menu/app-dropdown-menu.ts +0 -17
- package/src/lib/app-dropdown-menu/index.ts +0 -2
- package/src/lib/app-dropdown-menu/menu-popup.pipe.ts +0 -18
- package/src/lib/app-header/app-header.component.html +0 -26
- package/src/lib/app-header/app-header.component.scss +0 -0
- package/src/lib/app-header/app-header.component.ts +0 -43
- package/src/lib/app-side-menu/app-side-menu.component.html +0 -20
- package/src/lib/app-side-menu/app-side-menu.component.ts +0 -28
- package/src/lib/app-side-menu/routes-names.ts +0 -28
- package/src/lib/app-side-menu/side-menu-items.ts +0 -45
- package/src/lib/app-side-menu/side-menu.ts +0 -12
- package/src/lib/app-tabs/app-tab.interface.ts +0 -27
- package/src/lib/app-tabs/app-tabs.component.html +0 -37
- package/src/lib/app-tabs/app-tabs.component.scss +0 -103
- package/src/lib/app-tabs/app-tabs.component.spec.ts +0 -21
- package/src/lib/app-tabs/app-tabs.component.ts +0 -67
- package/src/lib/app-tabs/index.ts +0 -2
- package/src/lib/bottom-sheet/bottom-sheet.component.html +0 -18
- package/src/lib/bottom-sheet/bottom-sheet.component.scss +0 -31
- package/src/lib/bottom-sheet/bottom-sheet.component.ts +0 -26
- package/src/lib/confirmation-dialog/confirmation-dialog.component.html +0 -37
- package/src/lib/confirmation-dialog/confirmation-dialog.component.scss +0 -0
- package/src/lib/confirmation-dialog/confirmation-dialog.component.spec.ts +0 -22
- package/src/lib/confirmation-dialog/confirmation-dialog.component.ts +0 -64
- package/src/lib/confirmation-dialog/confirmation-dialog.interface.ts +0 -13
- package/src/lib/confirmation-dialog/confirmation-dialog.service.ts +0 -34
- package/src/lib/dual-calender/date-picker-switcher/date-picker-switcher.component.html +0 -27
- package/src/lib/dual-calender/date-picker-switcher/date-picker-switcher.component.scss +0 -22
- package/src/lib/dual-calender/date-picker-switcher/date-picker-switcher.component.ts +0 -64
- package/src/lib/dual-calender/dual-calendar.component.html +0 -31
- package/src/lib/dual-calender/dual-calendar.component.scss +0 -229
- package/src/lib/dual-calender/dual-calendar.component.ts +0 -107
- package/src/lib/dual-calender/gregorian-calendar/gregorian-calendar.component.html +0 -10
- 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 +0 -21
- package/src/lib/dual-calender/gregorian-calendar/gregorian-calendar.component.ts +0 -59
- package/src/lib/dual-calender/hijri-calendar/hijri-calendar.component.html +0 -10
- 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 +0 -21
- package/src/lib/dual-calender/hijri-calendar/hijri-calendar.component.ts +0 -59
- package/src/lib/dual-calender/services/gregorian-i18n.service.ts +0 -123
- package/src/lib/dual-calender/services/islamic-i18n.service.ts +0 -119
- package/src/lib/dual-calender/utils/date-i18n.utils.ts +0 -58
- package/src/lib/dynamic-form/dynamic-form.component.html +0 -86
- package/src/lib/dynamic-form/dynamic-form.component.scss +0 -0
- package/src/lib/dynamic-form/dynamic-form.component.spec.ts +0 -21
- package/src/lib/dynamic-form/dynamic-form.component.ts +0 -58
- package/src/lib/dynamic-form/dynamic-form.interface.ts +0 -94
- package/src/lib/dynamic-side-bar-v2/dynamic-sidebar.component.html +0 -32
- package/src/lib/dynamic-side-bar-v2/dynamic-sidebar.component.scss +0 -3
- package/src/lib/dynamic-side-bar-v2/dynamic-sidebar.component.ts +0 -82
- package/src/lib/dynamic-side-bar-v2/dynamic-sidebar.config.ts +0 -31
- package/src/lib/dynamic-side-bar-v2/dynamic-sidebar.service.ts +0 -41
- package/src/lib/form-components/@utils/form-utils.ts +0 -12
- package/src/lib/form-components/@utils/validations/error-keys.enum.ts +0 -24
- package/src/lib/form-components/@utils/validations/form-validation.service.ts +0 -68
- package/src/lib/form-components/@utils/validations/index.ts +0 -3
- package/src/lib/form-components/@utils/validations/validation-message.pipe.ts +0 -24
- package/src/lib/form-components/components/auto-complete/auto-complete.component.html +0 -35
- package/src/lib/form-components/components/auto-complete/auto-complete.component.scss +0 -7
- package/src/lib/form-components/components/auto-complete/auto-complete.component.spec.ts +0 -21
- package/src/lib/form-components/components/auto-complete/auto-complete.component.ts +0 -57
- package/src/lib/form-components/components/base-input.component.ts +0 -35
- package/src/lib/form-components/components/date-picker/date-picker.component.html +0 -41
- package/src/lib/form-components/components/date-picker/date-picker.component.scss +0 -16
- package/src/lib/form-components/components/date-picker/date-picker.component.spec.ts +0 -21
- package/src/lib/form-components/components/date-picker/date-picker.component.ts +0 -54
- package/src/lib/form-components/components/input/input.component.html +0 -63
- package/src/lib/form-components/components/input/input.component.scss +0 -41
- package/src/lib/form-components/components/input/input.component.spec.ts +0 -21
- package/src/lib/form-components/components/input/input.component.ts +0 -45
- package/src/lib/form-components/components/select/select.component.html +0 -111
- package/src/lib/form-components/components/select/select.component.scss +0 -43
- package/src/lib/form-components/components/select/select.component.spec.ts +0 -21
- package/src/lib/form-components/components/select/select.component.ts +0 -56
- package/src/lib/form-components/components/select-button/select-button.component.html +0 -21
- 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 +0 -21
- package/src/lib/form-components/components/select-button/select-button.component.ts +0 -22
- package/src/lib/form-components/components/switcher/switch.component.html +0 -5
- package/src/lib/form-components/components/switcher/switch.component.scss +0 -0
- package/src/lib/form-components/components/switcher/switch.component.spec.ts +0 -21
- package/src/lib/form-components/components/switcher/switch.component.ts +0 -25
- package/src/lib/form-components/index.ts +0 -9
- package/src/lib/form-components/interfaces/index.ts +0 -1
- package/src/lib/form-components/interfaces/label-value.ts +0 -4
- package/src/lib/ico-moon-icon/ico-moon-icon.component.ts +0 -23
- package/src/lib/read-more/read-more.component.html +0 -17
- package/src/lib/read-more/read-more.component.scss +0 -0
- package/src/lib/read-more/read-more.component.spec.ts +0 -21
- package/src/lib/read-more/read-more.component.ts +0 -21
- package/src/lib/side-bar/side-bar.component.html +0 -24
- package/src/lib/side-bar/side-bar.component.scss +0 -22
- package/src/lib/side-bar/side-bar.component.spec.ts +0 -21
- package/src/lib/side-bar/side-bar.component.ts +0 -33
- package/src/lib/side-bar-dynamic/data-injector.pipe.ts +0 -15
- package/src/lib/side-bar-dynamic/dynamic-sidebar.service.ts +0 -116
- package/src/lib/side-bar-dynamic/side-bar-dynamic.component.html +0 -42
- package/src/lib/side-bar-dynamic/side-bar-dynamic.component.scss +0 -5
- package/src/lib/side-bar-dynamic/side-bar-dynamic.component.spec.ts +0 -21
- package/src/lib/side-bar-dynamic/side-bar-dynamic.component.ts +0 -37
- package/src/lib/side-bar-dynamic/side-bar-utils.ts +0 -30
- package/src/lib/side-bar-dynamic/sidebar-config.ts +0 -48
- package/src/lib/user-autocomplete-card/user-autocomplete-card.component.html +0 -20
- 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 +0 -21
- package/src/lib/user-autocomplete-card/user-autocomplete-card.component.ts +0 -21
- package/src/lib/user-info/user-info.component.html +0 -10
- package/src/lib/user-info/user-info.component.ts +0 -11
- package/src/public-api.ts +0 -26
- package/tsconfig.lib.json +0 -18
- package/tsconfig.lib.prod.json +0 -11
- package/tsconfig.spec.json +0 -14
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
<ngb-datepicker #dp [class.rtl]="language === 'ar'" [class.ltr]="language === 'en'" [ngModel]="model"
|
|
2
|
-
[startDate]="startDate" (ngModelChange)="onDateChange($event)" (dateSelect)="dateSelected.emit($event)"
|
|
3
|
-
[dayTemplate]="dayTemplate" [markDisabled]="isDisabled">
|
|
4
|
-
</ngb-datepicker>
|
|
5
|
-
<ng-template #dayTemplate let-date let-currentMonth="currentMonth" let-selected="selected" let-disabled="disabled">
|
|
6
|
-
<span class="custom-day" [class.today]="isToday(date)" [class.selected]="selected"
|
|
7
|
-
[class.outside]="date.month !== currentMonth" [class.disabled]="disabled">
|
|
8
|
-
{{ date.day }}
|
|
9
|
-
</span>
|
|
10
|
-
</ng-template>
|
|
File without changes
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { ComponentFixture, TestBed } from "@angular/core/testing";
|
|
2
|
-
import { HijriCalendarComponent } from "./hijri-calendar.component";
|
|
3
|
-
|
|
4
|
-
describe("ReadMoreComponent", () => {
|
|
5
|
-
let component: HijriCalendarComponent;
|
|
6
|
-
let fixture: ComponentFixture<HijriCalendarComponent>;
|
|
7
|
-
|
|
8
|
-
beforeEach(async () => {
|
|
9
|
-
await TestBed.configureTestingModule({
|
|
10
|
-
imports: [HijriCalendarComponent]
|
|
11
|
-
}).compileComponents();
|
|
12
|
-
|
|
13
|
-
fixture = TestBed.createComponent(HijriCalendarComponent);
|
|
14
|
-
component = fixture.componentInstance;
|
|
15
|
-
fixture.detectChanges();
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it("should create", () => {
|
|
19
|
-
expect(component).toBeTruthy();
|
|
20
|
-
});
|
|
21
|
-
});
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { ChangeDetectorRef, Component, EventEmitter, Input, OnChanges, Output, SimpleChanges } from '@angular/core';
|
|
2
|
-
import {
|
|
3
|
-
NgbCalendar,
|
|
4
|
-
NgbCalendarIslamicUmalqura,
|
|
5
|
-
NgbDatepickerI18n,
|
|
6
|
-
NgbDatepickerModule,
|
|
7
|
-
NgbDateStruct,
|
|
8
|
-
} from '@ng-bootstrap/ng-bootstrap';
|
|
9
|
-
import { FormsModule } from '@angular/forms';
|
|
10
|
-
import { DynamicHijriI18n } from '../services/islamic-i18n.service';
|
|
11
|
-
|
|
12
|
-
@Component({
|
|
13
|
-
selector: "app-hijri-calendar",
|
|
14
|
-
standalone: true,
|
|
15
|
-
imports: [NgbDatepickerModule, FormsModule],
|
|
16
|
-
providers: [
|
|
17
|
-
{ provide: NgbCalendar, useClass: NgbCalendarIslamicUmalqura },
|
|
18
|
-
{ provide: NgbDatepickerI18n, useClass: DynamicHijriI18n }
|
|
19
|
-
],
|
|
20
|
-
templateUrl: "./hijri-calendar.component.html",
|
|
21
|
-
styleUrl: "./hijri-calendar.component.scss"
|
|
22
|
-
})
|
|
23
|
-
export class HijriCalendarComponent implements OnChanges {
|
|
24
|
-
@Input() model!: NgbDateStruct;
|
|
25
|
-
@Output() dateSelected = new EventEmitter<NgbDateStruct>();
|
|
26
|
-
@Input() language: 'ar' | 'en' = 'en';
|
|
27
|
-
startDate!: NgbDateStruct;
|
|
28
|
-
private calendar = new NgbCalendarIslamicUmalqura();
|
|
29
|
-
constructor(
|
|
30
|
-
private i18n: NgbDatepickerI18n,
|
|
31
|
-
private cdr: ChangeDetectorRef
|
|
32
|
-
) {
|
|
33
|
-
}
|
|
34
|
-
ngOnChanges(changes: SimpleChanges) {
|
|
35
|
-
if (changes['model'] && changes['model'].currentValue) {
|
|
36
|
-
this.startDate = { ...changes['model'].currentValue };
|
|
37
|
-
console.log('Hijri navigating to:', this.startDate);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (changes['language'] && this.i18n instanceof DynamicHijriI18n) {
|
|
41
|
-
this.i18n.setLanguage(this.language);
|
|
42
|
-
this.cdr.detectChanges(); // Force re-render to update labels
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
onDateChange(date: NgbDateStruct) {
|
|
47
|
-
this.model = date;
|
|
48
|
-
this.startDate = { ...date };
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
isToday(date: NgbDateStruct): boolean {
|
|
52
|
-
const today = this.calendar.getToday();
|
|
53
|
-
return date.year === today.year &&
|
|
54
|
-
date.month === today.month &&
|
|
55
|
-
date.day === today.day;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
isDisabled = () => false;
|
|
59
|
-
}
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { Injectable } from '@angular/core';
|
|
2
|
-
import { NgbDatepickerI18n, NgbDateStruct } from '@ng-bootstrap/ng-bootstrap';
|
|
3
|
-
import { MONTHS_GREGORIAN, WEEKDAYS } from '../utils/date-i18n.utils';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
@Injectable()
|
|
7
|
-
export class GregorianArabicI18n extends NgbDatepickerI18n {
|
|
8
|
-
getMonthShortName(month: number): string {
|
|
9
|
-
return MONTHS_GREGORIAN.ar[month - 1];
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
getMonthFullName(month: number): string {
|
|
13
|
-
return MONTHS_GREGORIAN.ar[month - 1];
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
getWeekdayLabel(weekday: number): string {
|
|
17
|
-
return WEEKDAYS.ar[weekday - 1];
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
getWeekdayShortName(weekday: number): string {
|
|
21
|
-
return WEEKDAYS.ar[weekday - 1];
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
getDayAriaLabel(date: NgbDateStruct): string {
|
|
25
|
-
return `${date.day}-${date.month}-${date.year}`;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
override getYearNumerals(year: number): string {
|
|
29
|
-
return String(year);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
override getWeekNumerals(weekNumber: number): string {
|
|
33
|
-
return String(weekNumber);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
override getDayNumerals(date: NgbDateStruct): string {
|
|
37
|
-
return String(date.day);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
@Injectable()
|
|
42
|
-
export class GregorianEnglishI18n extends NgbDatepickerI18n {
|
|
43
|
-
getMonthShortName(month: number): string {
|
|
44
|
-
return MONTHS_GREGORIAN.en[month - 1].substring(0, 3);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
getMonthFullName(month: number): string {
|
|
48
|
-
return MONTHS_GREGORIAN.en[month - 1];
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
getWeekdayLabel(weekday: number): string {
|
|
52
|
-
return WEEKDAYS.en[weekday - 1];
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
getWeekdayShortName(weekday: number): string {
|
|
56
|
-
return WEEKDAYS.en[weekday - 1];
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
getDayAriaLabel(date: NgbDateStruct): string {
|
|
60
|
-
return `${date.day}-${date.month}-${date.year}`;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
override getYearNumerals(year: number): string {
|
|
64
|
-
return String(year);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
override getWeekNumerals(weekNumber: number): string {
|
|
68
|
-
return String(weekNumber);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
override getDayNumerals(date: NgbDateStruct): string {
|
|
72
|
-
return String(date.day);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// ============ Dynamic I18N Factory ============
|
|
77
|
-
|
|
78
|
-
@Injectable()
|
|
79
|
-
export class DynamicGregorianI18n extends NgbDatepickerI18n {
|
|
80
|
-
private currentLang: 'ar' | 'en' = 'en';
|
|
81
|
-
private arabicI18n = new GregorianArabicI18n();
|
|
82
|
-
private englishI18n = new GregorianEnglishI18n();
|
|
83
|
-
|
|
84
|
-
setLanguage(lang: 'ar' | 'en') {
|
|
85
|
-
this.currentLang = lang;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
private get activeI18n() {
|
|
89
|
-
return this.currentLang === 'ar' ? this.arabicI18n : this.englishI18n;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
getMonthShortName(month: number): string {
|
|
93
|
-
return this.activeI18n.getMonthShortName(month);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
getMonthFullName(month: number): string {
|
|
97
|
-
return this.activeI18n.getMonthFullName(month);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
getWeekdayLabel(weekday: number): string {
|
|
101
|
-
return this.activeI18n.getWeekdayLabel(weekday);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
getWeekdayShortName(weekday: number): string {
|
|
105
|
-
return this.activeI18n.getWeekdayShortName(weekday);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
getDayAriaLabel(date: NgbDateStruct): string {
|
|
109
|
-
return this.activeI18n.getDayAriaLabel(date);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
override getYearNumerals(year: number): string {
|
|
113
|
-
return this.activeI18n.getYearNumerals(year);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
override getWeekNumerals(weekNumber: number): string {
|
|
117
|
-
return this.activeI18n.getWeekNumerals(weekNumber);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
override getDayNumerals(date: NgbDateStruct): string {
|
|
121
|
-
return this.activeI18n.getDayNumerals(date);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { Injectable } from '@angular/core';
|
|
2
|
-
import { NgbDatepickerI18n, NgbDateStruct } from '@ng-bootstrap/ng-bootstrap';
|
|
3
|
-
import { MONTHS_HIJRI, WEEKDAYS } from '../utils/date-i18n.utils';
|
|
4
|
-
|
|
5
|
-
@Injectable()
|
|
6
|
-
export class IslamicI18n extends NgbDatepickerI18n {
|
|
7
|
-
getMonthShortName(month: number): string {
|
|
8
|
-
return MONTHS_HIJRI.ar[month - 1];
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
getMonthFullName(month: number): string {
|
|
12
|
-
return MONTHS_HIJRI.ar[month - 1];
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
getWeekdayLabel(weekday: number): string {
|
|
16
|
-
return WEEKDAYS.ar[weekday - 1];
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
getWeekdayShortName(weekday: number): string {
|
|
20
|
-
return WEEKDAYS.ar[weekday - 1];
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
getDayAriaLabel(date: NgbDateStruct): string {
|
|
24
|
-
return `${date.day}-${date.month}-${date.year}`;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
override getYearNumerals(year: number): string {
|
|
28
|
-
return String(year);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
override getWeekNumerals(weekNumber: number): string {
|
|
32
|
-
return String(weekNumber);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
override getDayNumerals(date: NgbDateStruct): string {
|
|
36
|
-
return String(date.day);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
@Injectable()
|
|
41
|
-
export class HijriEnglishI18n extends NgbDatepickerI18n {
|
|
42
|
-
getMonthShortName(month: number): string {
|
|
43
|
-
return MONTHS_HIJRI.en[month - 1].substring(0, 3);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
getMonthFullName(month: number): string {
|
|
47
|
-
return MONTHS_HIJRI.en[month - 1];
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
getWeekdayLabel(weekday: number): string {
|
|
51
|
-
return WEEKDAYS.en[weekday - 1];
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
getWeekdayShortName(weekday: number): string {
|
|
55
|
-
return WEEKDAYS.en[weekday - 1];
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
getDayAriaLabel(date: NgbDateStruct): string {
|
|
59
|
-
return `${date.day}-${date.month}-${date.year}`;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
override getYearNumerals(year: number): string {
|
|
63
|
-
return String(year);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
override getWeekNumerals(weekNumber: number): string {
|
|
67
|
-
return String(weekNumber);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
override getDayNumerals(date: NgbDateStruct): string {
|
|
71
|
-
return String(date.day);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
@Injectable()
|
|
75
|
-
export class DynamicHijriI18n extends NgbDatepickerI18n {
|
|
76
|
-
private currentLang: 'ar' | 'en' = 'ar';
|
|
77
|
-
private arabicI18n = new IslamicI18n();
|
|
78
|
-
private englishI18n = new HijriEnglishI18n();
|
|
79
|
-
|
|
80
|
-
setLanguage(lang: 'ar' | 'en') {
|
|
81
|
-
this.currentLang = lang;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
private get activeI18n() {
|
|
85
|
-
return this.currentLang === 'ar' ? this.arabicI18n : this.englishI18n;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
getMonthShortName(month: number): string {
|
|
89
|
-
return this.activeI18n.getMonthShortName(month);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
getMonthFullName(month: number): string {
|
|
93
|
-
return this.activeI18n.getMonthFullName(month);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
getWeekdayLabel(weekday: number): string {
|
|
97
|
-
return this.activeI18n.getWeekdayLabel(weekday);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
getWeekdayShortName(weekday: number): string {
|
|
101
|
-
return this.activeI18n.getWeekdayShortName(weekday);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
getDayAriaLabel(date: NgbDateStruct): string {
|
|
105
|
-
return this.activeI18n.getDayAriaLabel(date);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
override getYearNumerals(year: number): string {
|
|
109
|
-
return this.activeI18n.getYearNumerals(year);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
override getWeekNumerals(weekNumber: number): string {
|
|
113
|
-
return this.activeI18n.getWeekNumerals(weekNumber);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
override getDayNumerals(date: NgbDateStruct): string {
|
|
117
|
-
return this.activeI18n.getDayNumerals(date);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
export const WEEKDAYS = {
|
|
2
|
-
ar: ['ن', 'ث', 'ر', 'خ', 'ج', 'س', 'ح'],
|
|
3
|
-
en: ['M', 'T', 'W', 'T', 'F', 'S', 'S']
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
export const MONTHS_GREGORIAN = {
|
|
7
|
-
ar: [
|
|
8
|
-
'يناير', 'فبراير', 'مارس', 'أبريل', 'مايو', 'يونيو',
|
|
9
|
-
'يوليو', 'أغسطس', 'سبتمبر', 'أكتوبر', 'نوفمبر', 'ديسمبر'
|
|
10
|
-
],
|
|
11
|
-
en: [
|
|
12
|
-
'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
|
|
13
|
-
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
|
|
14
|
-
]
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export const MONTHS_HIJRI = {
|
|
18
|
-
ar: [
|
|
19
|
-
'محرم',
|
|
20
|
-
'صفر',
|
|
21
|
-
'ربيع الأول',
|
|
22
|
-
'ربيع الآخر',
|
|
23
|
-
'جمادى الأولى',
|
|
24
|
-
'جمادى الآخرة',
|
|
25
|
-
'رجب',
|
|
26
|
-
'شعبان',
|
|
27
|
-
'رمضان',
|
|
28
|
-
'شوال',
|
|
29
|
-
'ذو القعدة',
|
|
30
|
-
'ذو الحجة'
|
|
31
|
-
],
|
|
32
|
-
en: [
|
|
33
|
-
'Muharram',
|
|
34
|
-
'Safar',
|
|
35
|
-
'Rabi Al-Awwal',
|
|
36
|
-
'Rabi Al-Thani',
|
|
37
|
-
'Jumada Al-Awwal',
|
|
38
|
-
'Jumada Al-Thani',
|
|
39
|
-
'Rajab',
|
|
40
|
-
'Shaaban',
|
|
41
|
-
'Ramadan',
|
|
42
|
-
'Shawwal',
|
|
43
|
-
'Dhul-Qi’dah',
|
|
44
|
-
'Dhul-Hijjah'
|
|
45
|
-
]
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
export function getGregorianMonthName(lang: 'ar' | 'en', month: number) {
|
|
49
|
-
return MONTHS_GREGORIAN[lang][month - 1] || '';
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export function getHijriMonthName(lang: 'ar' | 'en', month: number) {
|
|
53
|
-
return MONTHS_HIJRI[lang][month - 1] || '';
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export function getWeekdayName(lang: 'ar' | 'en', weekday: number) {
|
|
57
|
-
return WEEKDAYS[lang][weekday - 1];
|
|
58
|
-
}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
<form [formGroup]="formGroup" class="dynamic-form">
|
|
2
|
-
<div class="grid grid-cols-12 gap-x-2">
|
|
3
|
-
@for (inputName of inputsNames; track $index) {
|
|
4
|
-
<div [ngClass]="inputsMap[inputName].rowSize">
|
|
5
|
-
@switch (inputsMap[inputName].fieldType) {
|
|
6
|
-
@case (fieldType.HIJRI_DATE_PICKER) {
|
|
7
|
-
<app-dual-calendar [control]="getFormControl(inputName, formGroup)" ></app-dual-calendar>
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
@case (fieldType.DATE_PICKER) {
|
|
11
|
-
<stc-date-picker [minDate]="inputsMap[inputName]?.dateRange?.min" [maxDate]="inputsMap[inputName]?.dateRange?.max"
|
|
12
|
-
[id]="inputsMap[inputName].inputId" [control]="getFormControl(inputName, formGroup)" [name]="inputName"
|
|
13
|
-
[label]="inputsMap[inputName].label" [placeholder]="inputsMap[inputName].placeholder || ''"
|
|
14
|
-
[hint]="inputsMap[inputName].hint"
|
|
15
|
-
[readonly]="inputsMap[inputName].readonly || dynamicFormData.isReadOnlyForm || false"
|
|
16
|
-
[disabled]="inputsMap[inputName].disabled || false" [variant]="inputsMap[inputName].variant || 'over'"
|
|
17
|
-
[showIcon]="inputsMap[inputName].showIcon !== false" [isTimeOnly]="inputsMap[inputName].isTimeOnly || false" />
|
|
18
|
-
}
|
|
19
|
-
@case (fieldType.SELECT_BUTTON) {
|
|
20
|
-
<stc-select-button [control]="getFormControl(inputName, formGroup)" [id]="inputsMap[inputName].inputId"
|
|
21
|
-
[name]="inputName" [label]="inputsMap[inputName].label"
|
|
22
|
-
[options]="inputsMap[inputName].selectButtonOptions || []"
|
|
23
|
-
(onChange)="selectButtonChange.emit({ name: inputName, value: $event })" />
|
|
24
|
-
}
|
|
25
|
-
@case (fieldType.INPUT) {
|
|
26
|
-
<stc-input [control]="getFormControl(inputName, formGroup)" [id]="inputsMap[inputName].inputId" [name]="inputName"
|
|
27
|
-
[label]="inputsMap[inputName].label" [placeholder]="inputsMap[inputName].placeholder || ''"
|
|
28
|
-
[hint]="inputsMap[inputName].hint"
|
|
29
|
-
[readonly]="inputsMap[inputName].readonly || dynamicFormData.isReadOnlyForm || false"
|
|
30
|
-
[disabled]="inputsMap[inputName].disabled || false" [type]="inputsMap[inputName].inputType || 'text'"
|
|
31
|
-
[contentType]="inputsMap[inputName].contentType || 'text'" [rows]="inputsMap[inputName].rows || 2"
|
|
32
|
-
[cols]="inputsMap[inputName].cols || 20" [autoResize]="inputsMap[inputName].autoResize ?? true"
|
|
33
|
-
[prefix]="inputsMap[inputName].prefix || ''" [size]="inputsMap[inputName].size || 'small'"
|
|
34
|
-
[variant]="inputsMap[inputName].variant || 'over'">
|
|
35
|
-
@if(inputsMap[inputName].maxLength){
|
|
36
|
-
<small class="text-sm text-gray-600 self-end">
|
|
37
|
-
{{ (getFormControl(inputName, formGroup).value?.length || 0) }}
|
|
38
|
-
<span>
|
|
39
|
-
/ {{ inputsMap[inputName].maxLength}}
|
|
40
|
-
</span>
|
|
41
|
-
</small>
|
|
42
|
-
}
|
|
43
|
-
</stc-input>
|
|
44
|
-
}
|
|
45
|
-
@case (fieldType.SELECT) {
|
|
46
|
-
<stc-select [control]="getFormControl(inputName, formGroup)" [id]="inputsMap[inputName].inputId"
|
|
47
|
-
[name]="inputName" [label]="inputsMap[inputName].label" [placeholder]="inputsMap[inputName].placeholder || ''"
|
|
48
|
-
[hint]="inputsMap[inputName].hint"
|
|
49
|
-
[readonly]="inputsMap[inputName].readonly || dynamicFormData.isReadOnlyForm || false"
|
|
50
|
-
[disabled]="inputsMap[inputName].disabled || false" [options]="inputsMap[inputName].selectOptions || []"
|
|
51
|
-
[optionLabel]="inputsMap[inputName].optionLabel || 'label'" [filter]="inputsMap[inputName].filter || false"
|
|
52
|
-
[multiple]="inputsMap[inputName].multiple || false" [showClear]="inputsMap[inputName].showClear || false"
|
|
53
|
-
[checkmark]="inputsMap[inputName].checkmark ?? true" [filterBy]="inputsMap[inputName].filterBy || ''"
|
|
54
|
-
[selectedItemsLabel]="inputsMap[inputName].selectedItemsLabel || ''"
|
|
55
|
-
[size]="inputsMap[inputName].size || 'small'" [variant]="inputsMap[inputName].variant || 'over'"
|
|
56
|
-
(change)="selectChange.emit({ name: inputName, event: $event })"/>
|
|
57
|
-
}
|
|
58
|
-
@case (fieldType.SWITCH) {
|
|
59
|
-
<stc-switch [label]="inputsMap[inputName].label" [key]="inputName"
|
|
60
|
-
[checked]="getFormControl(inputName, formGroup).value"
|
|
61
|
-
(onChange)="getFormControl(inputName, formGroup).setValue(typeof $event === 'string' ? ($event === 'true') : $event); switchChange.emit({ name: inputName, value: (typeof $event === 'string' ? ($event === 'true') : $event) })" />
|
|
62
|
-
}
|
|
63
|
-
@case (fieldType.AUTO_COMPLETE) {
|
|
64
|
-
<stc-auto-complete [control]="getFormControl(inputName, formGroup)" [id]="inputsMap[inputName].inputId"
|
|
65
|
-
[name]="inputName" [label]="inputsMap[inputName].label" [placeholder]="inputsMap[inputName].placeholder || ''"
|
|
66
|
-
[hint]="inputsMap[inputName].hint"
|
|
67
|
-
[readonly]="inputsMap[inputName].readonly || dynamicFormData.isReadOnlyForm || false"
|
|
68
|
-
[disabled]="inputsMap[inputName].disabled || false" [items]="inputsMap[inputName].autoCompleteItems || []"
|
|
69
|
-
[minLengthToSearch]="inputsMap[inputName].minLengthToSearch || 2" [delay]="inputsMap[inputName].delay || 300"
|
|
70
|
-
(onSearch)="autoCompleteSearch.emit({ name: inputName, query: $event })"
|
|
71
|
-
(selectOption)="autoCompleteSelect.emit({ name: inputName, event: $event })"
|
|
72
|
-
[variant]="inputsMap[inputName].variant || 'over'" />
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
</div>
|
|
76
|
-
}
|
|
77
|
-
</div>
|
|
78
|
-
<div class="col-span-12">
|
|
79
|
-
<small class="p-error text-red-700">
|
|
80
|
-
@for (error of formGroup.errors | validationErrors: dynamicFormData.formValidationErrorsKeys;
|
|
81
|
-
track error) {
|
|
82
|
-
{{ error }}
|
|
83
|
-
}
|
|
84
|
-
</small>
|
|
85
|
-
</div>
|
|
86
|
-
</form>
|
|
File without changes
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { ComponentFixture, TestBed } from "@angular/core/testing";
|
|
2
|
-
import { DynamicFormComponent } from "./dynamic-form.component";
|
|
3
|
-
|
|
4
|
-
describe("DynamicFormComponent", () => {
|
|
5
|
-
let component: DynamicFormComponent;
|
|
6
|
-
let fixture: ComponentFixture<DynamicFormComponent>;
|
|
7
|
-
|
|
8
|
-
beforeEach(async () => {
|
|
9
|
-
await TestBed.configureTestingModule({
|
|
10
|
-
imports: [DynamicFormComponent]
|
|
11
|
-
}).compileComponents();
|
|
12
|
-
|
|
13
|
-
fixture = TestBed.createComponent(DynamicFormComponent);
|
|
14
|
-
component = fixture.componentInstance;
|
|
15
|
-
fixture.detectChanges();
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it("should create", () => {
|
|
19
|
-
expect(component).toBeTruthy();
|
|
20
|
-
});
|
|
21
|
-
});
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { CommonModule } from '@angular/common';
|
|
2
|
-
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
|
3
|
-
import { FormGroup, ReactiveFormsModule } from '@angular/forms';
|
|
4
|
-
import { TranslateModule } from '@ngx-translate/core';
|
|
5
|
-
import {
|
|
6
|
-
AutoCompleteComponent,
|
|
7
|
-
DatePickerComponent,
|
|
8
|
-
FormUtils,
|
|
9
|
-
InputComponent,
|
|
10
|
-
SelectButtonComponent,
|
|
11
|
-
SelectComponent,
|
|
12
|
-
SwitchComponent,
|
|
13
|
-
ValidationErrorsPipe,
|
|
14
|
-
} from '../form-components';
|
|
15
|
-
import { DynamicFormData, FormFieldTypeEnum, InputsMap } from './dynamic-form.interface';
|
|
16
|
-
import { DualCalendarComponent } from './../dual-calender/dual-calendar.component';
|
|
17
|
-
|
|
18
|
-
@Component({
|
|
19
|
-
selector: 'app-dynamic-form',
|
|
20
|
-
standalone: true,
|
|
21
|
-
imports: [
|
|
22
|
-
CommonModule,
|
|
23
|
-
ReactiveFormsModule,
|
|
24
|
-
DatePickerComponent,
|
|
25
|
-
ValidationErrorsPipe,
|
|
26
|
-
TranslateModule,
|
|
27
|
-
SelectButtonComponent,
|
|
28
|
-
DualCalendarComponent,
|
|
29
|
-
InputComponent,
|
|
30
|
-
SelectComponent,
|
|
31
|
-
AutoCompleteComponent,
|
|
32
|
-
SwitchComponent,
|
|
33
|
-
],
|
|
34
|
-
templateUrl: './dynamic-form.component.html',
|
|
35
|
-
styleUrl: './dynamic-form.component.scss',
|
|
36
|
-
})
|
|
37
|
-
export class DynamicFormComponent implements OnInit {
|
|
38
|
-
@Input({ required: true }) dynamicFormData: DynamicFormData;
|
|
39
|
-
// Generic field change outputs (optional for consumers)
|
|
40
|
-
@Output() selectButtonChange = new EventEmitter<{ name: string; value: any }>();
|
|
41
|
-
@Output() selectChange = new EventEmitter<{ name: string; event: any }>();
|
|
42
|
-
@Output() switchChange = new EventEmitter<{ name: string; value: boolean }>();
|
|
43
|
-
@Output() autoCompleteSearch = new EventEmitter<{ name: string; query: string }>();
|
|
44
|
-
@Output() autoCompleteSelect = new EventEmitter<{ name: string; event: any }>();
|
|
45
|
-
|
|
46
|
-
inputsNames: string[] = [];
|
|
47
|
-
formGroup: FormGroup;
|
|
48
|
-
inputsMap: InputsMap;
|
|
49
|
-
readonly fieldType = FormFieldTypeEnum;
|
|
50
|
-
getFormControl = FormUtils.getFormControl;
|
|
51
|
-
|
|
52
|
-
ngOnInit(): void {
|
|
53
|
-
this.formGroup = this.dynamicFormData?.formGroup as FormGroup;
|
|
54
|
-
this.inputsMap = this.dynamicFormData?.inputsMap as InputsMap;
|
|
55
|
-
this.inputsNames = Object.keys(this.inputsMap || {});
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
}
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { FormGroup } from '@angular/forms';
|
|
2
|
-
import { LabelValue } from '../form-components';
|
|
3
|
-
|
|
4
|
-
export type InputType = 'text' | 'textarea';
|
|
5
|
-
export type InputContentType = 'text' | 'email' | 'number';
|
|
6
|
-
|
|
7
|
-
export interface Dropdown<T = unknown> {
|
|
8
|
-
id?: string;
|
|
9
|
-
keyValue: T;
|
|
10
|
-
label: string;
|
|
11
|
-
icon?: string;
|
|
12
|
-
hidden?: boolean;
|
|
13
|
-
disabled?: boolean;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface InputsMapData {
|
|
17
|
-
// General props
|
|
18
|
-
label: string;
|
|
19
|
-
rowSize?: string;
|
|
20
|
-
fieldType: FormFieldTypeEnum;
|
|
21
|
-
inputId?: string;
|
|
22
|
-
placeholder?: string;
|
|
23
|
-
hint?: string;
|
|
24
|
-
readonly?: boolean;
|
|
25
|
-
disabled?: boolean;
|
|
26
|
-
hidden?: boolean;
|
|
27
|
-
required?: boolean;
|
|
28
|
-
maxLength?: number;
|
|
29
|
-
minlength?: number;
|
|
30
|
-
// Date
|
|
31
|
-
dateRange?: DateRangeInterface;
|
|
32
|
-
isTimeOnly?: boolean;
|
|
33
|
-
showIcon?: boolean;
|
|
34
|
-
|
|
35
|
-
//select button
|
|
36
|
-
selectButtonOptions?: LabelValue<any>[];
|
|
37
|
-
|
|
38
|
-
// Input (text/textarea)
|
|
39
|
-
inputType?: InputType;
|
|
40
|
-
contentType?: InputContentType;
|
|
41
|
-
rows?: number;
|
|
42
|
-
cols?: number;
|
|
43
|
-
autoResize?: boolean;
|
|
44
|
-
prefix?: string;
|
|
45
|
-
size?: 'small' | 'large';
|
|
46
|
-
variant?: 'in' | 'over' | 'on';
|
|
47
|
-
|
|
48
|
-
// Select dropdown
|
|
49
|
-
selectOptions?: unknown[]; // Array of objects or primitives
|
|
50
|
-
optionLabel?: string; // property name to display when options are objects
|
|
51
|
-
filter?: boolean;
|
|
52
|
-
multiple?: boolean;
|
|
53
|
-
showClear?: boolean;
|
|
54
|
-
checkmark?: boolean;
|
|
55
|
-
filterBy?: string;
|
|
56
|
-
selectedItemsLabel?: string;
|
|
57
|
-
|
|
58
|
-
// Auto-complete
|
|
59
|
-
autoCompleteItems?: unknown[];
|
|
60
|
-
minLengthToSearch?: number;
|
|
61
|
-
delay?: number;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export interface InputsMap {
|
|
65
|
-
[key: string]: InputsMapData;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export interface DynamicFormData {
|
|
69
|
-
isActive?: boolean;
|
|
70
|
-
formGroup: FormGroup | null;
|
|
71
|
-
inputsMap: InputsMap | null;
|
|
72
|
-
title?: string;
|
|
73
|
-
isReadOnlyForm?: boolean;
|
|
74
|
-
formValidationErrorsKeys?: string[];
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export interface DateRangeInterface {
|
|
78
|
-
min?: Date | null; // Static range, hard coded
|
|
79
|
-
max?: Date | null; // Static range, hard coded
|
|
80
|
-
notBeforeDateInput?: string; // For dynamic date range validation
|
|
81
|
-
notAfterDateInput?: string; // For dynamic date range validation
|
|
82
|
-
notBeforeOrSameDateInput?: string;
|
|
83
|
-
notAfterOrSameDateInput?: string;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export enum FormFieldTypeEnum {
|
|
87
|
-
DATE_PICKER = 'date-picker',
|
|
88
|
-
SELECT_BUTTON = 'select-button',
|
|
89
|
-
INPUT = 'input',
|
|
90
|
-
SELECT = 'select',
|
|
91
|
-
SWITCH = 'switch',
|
|
92
|
-
AUTO_COMPLETE = 'auto-complete',
|
|
93
|
-
HIJRI_DATE_PICKER = 'hijri-date'
|
|
94
|
-
}
|