@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.
Files changed (138) hide show
  1. package/fesm2022/corp-products-ui-components.mjs +1999 -0
  2. package/fesm2022/corp-products-ui-components.mjs.map +1 -0
  3. package/index.d.ts +653 -0
  4. package/package.json +36 -22
  5. package/ng-package.json +0 -7
  6. package/src/enums/date-formatter.ts +0 -21
  7. package/src/helper/date-handler.ts +0 -142
  8. package/src/lib/app-accordion/app-accordion.component.html +0 -15
  9. package/src/lib/app-accordion/app-accordion.component.scss +0 -0
  10. package/src/lib/app-accordion/app-accordion.component.spec.ts +0 -21
  11. package/src/lib/app-accordion/app-accordion.component.ts +0 -21
  12. package/src/lib/app-accordion/index.ts +0 -2
  13. package/src/lib/app-breadcrumb/app-breadcrumb.component.html +0 -7
  14. package/src/lib/app-breadcrumb/app-breadcrumb.component.scss +0 -25
  15. package/src/lib/app-breadcrumb/app-breadcrumb.component.ts +0 -140
  16. package/src/lib/app-breadcrumb/app-breadcrumb.interface.ts +0 -15
  17. package/src/lib/app-button/app-button.component.html +0 -7
  18. package/src/lib/app-button/app-button.component.scss +0 -0
  19. package/src/lib/app-button/app-button.component.ts +0 -14
  20. package/src/lib/app-button/app-button.ts +0 -15
  21. package/src/lib/app-button/index.ts +0 -2
  22. package/src/lib/app-dropdown-menu/app-dropdown-menu.component.html +0 -22
  23. package/src/lib/app-dropdown-menu/app-dropdown-menu.component.scss +0 -39
  24. package/src/lib/app-dropdown-menu/app-dropdown-menu.component.spec.ts +0 -21
  25. package/src/lib/app-dropdown-menu/app-dropdown-menu.component.ts +0 -43
  26. package/src/lib/app-dropdown-menu/app-dropdown-menu.ts +0 -17
  27. package/src/lib/app-dropdown-menu/index.ts +0 -2
  28. package/src/lib/app-dropdown-menu/menu-popup.pipe.ts +0 -18
  29. package/src/lib/app-header/app-header.component.html +0 -26
  30. package/src/lib/app-header/app-header.component.scss +0 -0
  31. package/src/lib/app-header/app-header.component.ts +0 -43
  32. package/src/lib/app-side-menu/app-side-menu.component.html +0 -20
  33. package/src/lib/app-side-menu/app-side-menu.component.ts +0 -28
  34. package/src/lib/app-side-menu/routes-names.ts +0 -28
  35. package/src/lib/app-side-menu/side-menu-items.ts +0 -45
  36. package/src/lib/app-side-menu/side-menu.ts +0 -12
  37. package/src/lib/app-tabs/app-tab.interface.ts +0 -27
  38. package/src/lib/app-tabs/app-tabs.component.html +0 -37
  39. package/src/lib/app-tabs/app-tabs.component.scss +0 -103
  40. package/src/lib/app-tabs/app-tabs.component.spec.ts +0 -21
  41. package/src/lib/app-tabs/app-tabs.component.ts +0 -67
  42. package/src/lib/app-tabs/index.ts +0 -2
  43. package/src/lib/bottom-sheet/bottom-sheet.component.html +0 -18
  44. package/src/lib/bottom-sheet/bottom-sheet.component.scss +0 -31
  45. package/src/lib/bottom-sheet/bottom-sheet.component.ts +0 -26
  46. package/src/lib/confirmation-dialog/confirmation-dialog.component.html +0 -37
  47. package/src/lib/confirmation-dialog/confirmation-dialog.component.scss +0 -0
  48. package/src/lib/confirmation-dialog/confirmation-dialog.component.spec.ts +0 -22
  49. package/src/lib/confirmation-dialog/confirmation-dialog.component.ts +0 -64
  50. package/src/lib/confirmation-dialog/confirmation-dialog.interface.ts +0 -13
  51. package/src/lib/confirmation-dialog/confirmation-dialog.service.ts +0 -34
  52. package/src/lib/dual-calender/date-picker-switcher/date-picker-switcher.component.html +0 -27
  53. package/src/lib/dual-calender/date-picker-switcher/date-picker-switcher.component.scss +0 -22
  54. package/src/lib/dual-calender/date-picker-switcher/date-picker-switcher.component.ts +0 -64
  55. package/src/lib/dual-calender/dual-calendar.component.html +0 -31
  56. package/src/lib/dual-calender/dual-calendar.component.scss +0 -229
  57. package/src/lib/dual-calender/dual-calendar.component.ts +0 -107
  58. package/src/lib/dual-calender/gregorian-calendar/gregorian-calendar.component.html +0 -10
  59. package/src/lib/dual-calender/gregorian-calendar/gregorian-calendar.component.scss +0 -0
  60. package/src/lib/dual-calender/gregorian-calendar/gregorian-calendar.component.spec.ts +0 -21
  61. package/src/lib/dual-calender/gregorian-calendar/gregorian-calendar.component.ts +0 -59
  62. package/src/lib/dual-calender/hijri-calendar/hijri-calendar.component.html +0 -10
  63. package/src/lib/dual-calender/hijri-calendar/hijri-calendar.component.scss +0 -0
  64. package/src/lib/dual-calender/hijri-calendar/hijri-calendar.component.spec.ts +0 -21
  65. package/src/lib/dual-calender/hijri-calendar/hijri-calendar.component.ts +0 -59
  66. package/src/lib/dual-calender/services/gregorian-i18n.service.ts +0 -123
  67. package/src/lib/dual-calender/services/islamic-i18n.service.ts +0 -119
  68. package/src/lib/dual-calender/utils/date-i18n.utils.ts +0 -58
  69. package/src/lib/dynamic-form/dynamic-form.component.html +0 -86
  70. package/src/lib/dynamic-form/dynamic-form.component.scss +0 -0
  71. package/src/lib/dynamic-form/dynamic-form.component.spec.ts +0 -21
  72. package/src/lib/dynamic-form/dynamic-form.component.ts +0 -58
  73. package/src/lib/dynamic-form/dynamic-form.interface.ts +0 -94
  74. package/src/lib/dynamic-side-bar-v2/dynamic-sidebar.component.html +0 -32
  75. package/src/lib/dynamic-side-bar-v2/dynamic-sidebar.component.scss +0 -3
  76. package/src/lib/dynamic-side-bar-v2/dynamic-sidebar.component.ts +0 -82
  77. package/src/lib/dynamic-side-bar-v2/dynamic-sidebar.config.ts +0 -31
  78. package/src/lib/dynamic-side-bar-v2/dynamic-sidebar.service.ts +0 -41
  79. package/src/lib/form-components/@utils/form-utils.ts +0 -12
  80. package/src/lib/form-components/@utils/validations/error-keys.enum.ts +0 -24
  81. package/src/lib/form-components/@utils/validations/form-validation.service.ts +0 -68
  82. package/src/lib/form-components/@utils/validations/index.ts +0 -3
  83. package/src/lib/form-components/@utils/validations/validation-message.pipe.ts +0 -24
  84. package/src/lib/form-components/components/auto-complete/auto-complete.component.html +0 -35
  85. package/src/lib/form-components/components/auto-complete/auto-complete.component.scss +0 -7
  86. package/src/lib/form-components/components/auto-complete/auto-complete.component.spec.ts +0 -21
  87. package/src/lib/form-components/components/auto-complete/auto-complete.component.ts +0 -57
  88. package/src/lib/form-components/components/base-input.component.ts +0 -35
  89. package/src/lib/form-components/components/date-picker/date-picker.component.html +0 -41
  90. package/src/lib/form-components/components/date-picker/date-picker.component.scss +0 -16
  91. package/src/lib/form-components/components/date-picker/date-picker.component.spec.ts +0 -21
  92. package/src/lib/form-components/components/date-picker/date-picker.component.ts +0 -54
  93. package/src/lib/form-components/components/input/input.component.html +0 -63
  94. package/src/lib/form-components/components/input/input.component.scss +0 -41
  95. package/src/lib/form-components/components/input/input.component.spec.ts +0 -21
  96. package/src/lib/form-components/components/input/input.component.ts +0 -45
  97. package/src/lib/form-components/components/select/select.component.html +0 -111
  98. package/src/lib/form-components/components/select/select.component.scss +0 -43
  99. package/src/lib/form-components/components/select/select.component.spec.ts +0 -21
  100. package/src/lib/form-components/components/select/select.component.ts +0 -56
  101. package/src/lib/form-components/components/select-button/select-button.component.html +0 -21
  102. package/src/lib/form-components/components/select-button/select-button.component.scss +0 -0
  103. package/src/lib/form-components/components/select-button/select-button.component.spec.ts +0 -21
  104. package/src/lib/form-components/components/select-button/select-button.component.ts +0 -22
  105. package/src/lib/form-components/components/switcher/switch.component.html +0 -5
  106. package/src/lib/form-components/components/switcher/switch.component.scss +0 -0
  107. package/src/lib/form-components/components/switcher/switch.component.spec.ts +0 -21
  108. package/src/lib/form-components/components/switcher/switch.component.ts +0 -25
  109. package/src/lib/form-components/index.ts +0 -9
  110. package/src/lib/form-components/interfaces/index.ts +0 -1
  111. package/src/lib/form-components/interfaces/label-value.ts +0 -4
  112. package/src/lib/ico-moon-icon/ico-moon-icon.component.ts +0 -23
  113. package/src/lib/read-more/read-more.component.html +0 -17
  114. package/src/lib/read-more/read-more.component.scss +0 -0
  115. package/src/lib/read-more/read-more.component.spec.ts +0 -21
  116. package/src/lib/read-more/read-more.component.ts +0 -21
  117. package/src/lib/side-bar/side-bar.component.html +0 -24
  118. package/src/lib/side-bar/side-bar.component.scss +0 -22
  119. package/src/lib/side-bar/side-bar.component.spec.ts +0 -21
  120. package/src/lib/side-bar/side-bar.component.ts +0 -33
  121. package/src/lib/side-bar-dynamic/data-injector.pipe.ts +0 -15
  122. package/src/lib/side-bar-dynamic/dynamic-sidebar.service.ts +0 -116
  123. package/src/lib/side-bar-dynamic/side-bar-dynamic.component.html +0 -42
  124. package/src/lib/side-bar-dynamic/side-bar-dynamic.component.scss +0 -5
  125. package/src/lib/side-bar-dynamic/side-bar-dynamic.component.spec.ts +0 -21
  126. package/src/lib/side-bar-dynamic/side-bar-dynamic.component.ts +0 -37
  127. package/src/lib/side-bar-dynamic/side-bar-utils.ts +0 -30
  128. package/src/lib/side-bar-dynamic/sidebar-config.ts +0 -48
  129. package/src/lib/user-autocomplete-card/user-autocomplete-card.component.html +0 -20
  130. package/src/lib/user-autocomplete-card/user-autocomplete-card.component.scss +0 -0
  131. package/src/lib/user-autocomplete-card/user-autocomplete-card.component.spec.ts +0 -21
  132. package/src/lib/user-autocomplete-card/user-autocomplete-card.component.ts +0 -21
  133. package/src/lib/user-info/user-info.component.html +0 -10
  134. package/src/lib/user-info/user-info.component.ts +0 -11
  135. package/src/public-api.ts +0 -26
  136. package/tsconfig.lib.json +0 -18
  137. package/tsconfig.lib.prod.json +0 -11
  138. package/tsconfig.spec.json +0 -14
@@ -1,32 +0,0 @@
1
- <p-drawer
2
- [(visible)]="show"
3
- [position]="position"
4
- appendTo="body"
5
- [closable]="closable"
6
- [closeOnEscape]="closeOnEscape"
7
- [dismissible]="dismissible"
8
- (onHide)="handleClose()"
9
- [position]="'left'"
10
- [styleClass]="'p-drawer-' + sidebarSize + ' custom-content bg-white ' + styleClass">
11
- <ng-template pTemplate="header">
12
- <p class="truncate" [pTooltip]="title">{{ title }}</p>
13
- </ng-template>
14
- <ng-template pTemplate="content">
15
- <ng-template #contentContainer></ng-template>
16
- </ng-template>
17
- <ng-template pTemplate="footer">
18
- <div class="flex gap-4 mt-4">
19
- <div class="flex-auto">
20
- <app-button (click)="handleSubmit()"
21
- [icon]="actions?.save?.icon"
22
- [iconPos]="actions?.save?.iconPos || 'right'"
23
- [styleClass]="(actions?.save?.style || 'danger') + ' w-full'"
24
- [label]="actions?.save?.title || ('actions.submit' | translate)"
25
- [variant]="actions?.save?.variant"
26
- />
27
- </div>
28
- <app-button (click)="handleClose()" severity="danger" variant="outlined"
29
- [label]="actions?.cancel?.title || ('actions.cancel' | translate)" />
30
- </div>
31
- </ng-template>
32
- </p-drawer>
@@ -1,3 +0,0 @@
1
- .flex-auto {
2
- flex: 1 1 auto;
3
- }
@@ -1,82 +0,0 @@
1
- import { AppButtonComponent } from './../app-button/app-button.component';
2
- /* eslint-disable @typescript-eslint/no-explicit-any */
3
- import { CommonModule } from '@angular/common';
4
- import {
5
- AfterViewInit,
6
- Component,
7
- EventEmitter,
8
- Input,
9
- OnDestroy,
10
- Output,
11
- Type,
12
- ViewChild,
13
- ViewContainerRef
14
- } from '@angular/core';
15
- import { TranslatePipe } from '@ngx-translate/core';
16
- import { DrawerModule } from 'primeng/drawer';
17
- import { TooltipModule } from "primeng/tooltip";
18
- import { SidebarV2Actions } from './dynamic-sidebar.config';
19
-
20
- @Component({
21
- selector: "app-dynamic-sidebar",
22
- templateUrl: "./dynamic-sidebar.component.html",
23
- styleUrls: ["./dynamic-sidebar.component.scss"],
24
- standalone: true,
25
- imports: [CommonModule, TranslatePipe, DrawerModule, TooltipModule, AppButtonComponent],
26
- })
27
- export class DynamicSidebarComponent implements AfterViewInit, OnDestroy {
28
-
29
- @Input() component!: Type<any>;
30
- @Input() data?: any;
31
- @Input() title = '';
32
- @Input() actions?: SidebarV2Actions;
33
- @Input() sidebarSize: 'sm' | 'md' | 'lg' = 'md';
34
- @Input() closable = true;
35
- @Input() closeOnEscape = true;
36
- @Input() dismissible = true;
37
- @Input() position: 'left' | 'right' = 'left';
38
- @Input() styleClass = '';
39
- @Input() disabled = false;
40
-
41
- @Output() closed = new EventEmitter();
42
-
43
- @ViewChild('contentContainer', { read: ViewContainerRef })
44
- private contentContainer!: ViewContainerRef;
45
-
46
- private contentRef: any;
47
-
48
- show = true;
49
-
50
- ngAfterViewInit() {
51
- this.renderContent();
52
- }
53
-
54
- private renderContent() {
55
- if (!this.component) return;
56
- this.contentContainer.clear();
57
- this.contentRef = this.contentContainer.createComponent(this.component);
58
- if (this.data) Object.assign(this.contentRef.instance, this.data);
59
- }
60
-
61
- handleClose() {
62
- if(this.contentRef.instance.close) this.contentRef.instance.close();
63
- this.closed.emit(null);
64
- this.destroy();
65
- }
66
-
67
- handleSubmit() {
68
- if(this.data.form) {
69
- this.data.form.markAllAsTouched();
70
- if(this.data.form.invalid) return;
71
- }
72
- if(this.contentRef.instance.submit) this.contentRef.instance.submit();
73
- }
74
-
75
- private destroy() {
76
- this.contentRef?.destroy();
77
- }
78
-
79
- ngOnDestroy() {
80
- this.destroy();
81
- }
82
- }
@@ -1,31 +0,0 @@
1
- import { Type, ViewContainerRef } from "@angular/core";
2
- import { AppButtonIconPos, AppButtonSeverity, AppButtonSize, AppButtonVariant } from "../app-button";
3
-
4
- export interface DynamicSidebarV2Actions {
5
- submit: () => void;
6
- close: () => void;
7
- }
8
- export interface DynamicSidebarV2Config<T = any> {
9
- title?: string;
10
- component: Type<T>;
11
- data?: Partial<T>;
12
- size?: 'sm' | 'md' | 'lg';
13
- position?: 'left' | 'right';
14
- styleClass?: string;
15
- viewContainerRef?: ViewContainerRef;
16
- actions?: SidebarV2Actions
17
- }
18
-
19
- export interface SidebarActionV2Config {
20
- title?: string;
21
- icon?: string;
22
- size?: AppButtonSize;
23
- style?: AppButtonSeverity;
24
- iconPos?: AppButtonIconPos;
25
- variant?: AppButtonVariant;
26
- }
27
-
28
- export interface SidebarV2Actions {
29
- cancel?: SidebarActionV2Config;
30
- save?: SidebarActionV2Config;
31
- }
@@ -1,41 +0,0 @@
1
- import { ApplicationRef, ComponentRef, EnvironmentInjector, Injectable, Injector, createComponent, inject } from '@angular/core';
2
- import { DynamicSidebarComponent } from './dynamic-sidebar.component';
3
- import { DynamicSidebarV2Config } from './dynamic-sidebar.config';
4
-
5
- @Injectable({ providedIn: 'root' })
6
- export class DynamicSidebarV2Service {
7
- private sidebarRef?: ComponentRef<DynamicSidebarComponent>;
8
- private readonly appRef = inject(ApplicationRef);
9
- private readonly injector = inject(Injector);
10
- private readonly envInjector = inject(EnvironmentInjector);
11
-
12
- open<T>(options: DynamicSidebarV2Config<T>) {
13
- this.close();
14
-
15
- this.sidebarRef = createComponent(DynamicSidebarComponent, {
16
- environmentInjector: this.envInjector,
17
- elementInjector: this.injector,
18
- });
19
-
20
- const instance = this.sidebarRef.instance;
21
- instance.title = options.title ?? '';
22
- instance.sidebarSize = options.size ?? 'md';
23
- instance.position = options.position ?? 'left';
24
- instance.styleClass = options.styleClass ?? '';
25
- instance.component = options.component;
26
- instance.data = options.data ?? {};
27
- instance.actions = options.actions;
28
- instance.closed.subscribe(() => this.close());
29
-
30
- this.appRef.attachView(this.sidebarRef.hostView);
31
- const domElem = (this.sidebarRef.hostView as any).rootNodes[0] as HTMLElement;
32
- document.body.appendChild(domElem);
33
- }
34
-
35
- close() {
36
- if (this.sidebarRef) {
37
- this.sidebarRef.destroy();
38
- this.sidebarRef = undefined;
39
- }
40
- }
41
- }
@@ -1,12 +0,0 @@
1
- import {FormControl, FormGroup} from "@angular/forms";
2
-
3
- export class FormUtils {
4
- static getFormControl(controlName: string, form: FormGroup): FormControl {
5
- if (!form) throw new Error(`Form is not initialized.`);
6
- const formControl = form.get(controlName) as FormControl;
7
-
8
- if (!formControl) throw new Error(`There's no form control with given name. '${controlName}'`);
9
-
10
- return formControl;
11
- }
12
- }
@@ -1,24 +0,0 @@
1
- export enum BasicErrorKeysEnum {
2
- required = "REQUIRED",
3
- email = "EMAIL",
4
- pattern = "PATTERN",
5
- invalidArFormat = "INVALID_AR_FORMAT",
6
- invalidLink = "INVALID_LINK",
7
- endDateBeforeStartDate = "END_DATE_BEFORE_START_DATE",
8
- startDateEqualsEndDate = "START_DATE_EQUALS_END_DATE",
9
- endTimeBeforeStartTime = "END_TIME_BEFORE_START_TIME",
10
- startTimeEqualsEndTime = "START_TIME_EQUALS_END_TIME",
11
- integer = "INTEGER",
12
- positiveNumber = "POSITIVE_NUMBER",
13
- fileSelected = "FILE_SELECTED",
14
- default = "DEFAULT"
15
- }
16
- export enum ErrorsWithValuesKeysEnum {
17
- minlength = "MIN_LENGTH",
18
- maxlength = "MAX_LENGTH",
19
- min = "MIN",
20
- max = "MAX",
21
- maxSize = "MAX_SIZE",
22
- maxFiles = "MAX_FILES",
23
- allowedTypes = "ALLOWED_TYPES"
24
- }
@@ -1,68 +0,0 @@
1
- import { inject, Injectable } from '@angular/core';
2
- import { TranslateService } from '@ngx-translate/core';
3
- import { InterpolationParameters } from '@ngx-translate/core';
4
- import { BasicErrorKeysEnum, ErrorsWithValuesKeysEnum } from './error-keys.enum';
5
-
6
- @Injectable({
7
- providedIn: 'root',
8
- })
9
- export class FormValidationService {
10
- private translate = inject(TranslateService);
11
-
12
- private getTranslation(key: string, interpolateParams?: InterpolationParameters): string {
13
- return this.translate.instant(`VALIDATION.${key}`, interpolateParams);
14
- }
15
-
16
- getErrorMessage(errorKey: string, errorValue: any): string {
17
- if (this.isBasicErrorKey(errorKey)) {
18
- return this.getTranslation(BasicErrorKeysEnum[errorKey as keyof typeof BasicErrorKeysEnum]);
19
- }
20
-
21
- if (this.isErrorWithValueKey(errorKey)) {
22
- return this.getErrorWithValueMessage(
23
- errorKey as keyof typeof ErrorsWithValuesKeysEnum,
24
- errorValue
25
- );
26
- }
27
-
28
- return this.getTranslation(BasicErrorKeysEnum.default);
29
- }
30
-
31
- // Basic error keys are the keys that don't have any values to interpolate. like required, email, etc.
32
- private isBasicErrorKey(key: string): key is keyof typeof BasicErrorKeysEnum {
33
- return Object.keys(BasicErrorKeysEnum).includes(key as BasicErrorKeysEnum);
34
- }
35
-
36
- // Error keys with values are the keys that have values to interpolate. like minlength, maxlength, etc.
37
- private isErrorWithValueKey(key: string): key is keyof typeof ErrorsWithValuesKeysEnum {
38
- return Object.keys(ErrorsWithValuesKeysEnum).includes(key as ErrorsWithValuesKeysEnum);
39
- }
40
-
41
- private getErrorWithValueMessage(
42
- errorKey: keyof typeof ErrorsWithValuesKeysEnum,
43
- errorValue: any
44
- ): string {
45
- const messages: Record<keyof typeof ErrorsWithValuesKeysEnum, (value: any) => string> = {
46
- minlength: (val) =>
47
- this.getTranslation(ErrorsWithValuesKeysEnum.minlength, {
48
- requiredLength: val?.requiredLength,
49
- actualLength: val?.actualLength,
50
- }),
51
- maxlength: (val) =>
52
- this.getTranslation(ErrorsWithValuesKeysEnum.maxlength, {
53
- requiredLength: val?.requiredLength,
54
- actualLength: val?.actualLength,
55
- }),
56
- min: (val) => this.getTranslation(ErrorsWithValuesKeysEnum.min, { min: val?.min }),
57
- max: (val) => this.getTranslation(ErrorsWithValuesKeysEnum.max, { max: val?.max }),
58
- maxSize: (val) =>
59
- this.getTranslation(ErrorsWithValuesKeysEnum.maxSize, { size: val?.requiredLength }),
60
- maxFiles: (val) =>
61
- this.getTranslation(ErrorsWithValuesKeysEnum.maxFiles, { size: val?.requiredLength }),
62
- allowedTypes: (val) =>
63
- this.getTranslation(ErrorsWithValuesKeysEnum.allowedTypes, { types: val?.join(', ') }),
64
- };
65
-
66
- return messages[errorKey](errorValue);
67
- }
68
- }
@@ -1,3 +0,0 @@
1
- export * from "./error-keys.enum";
2
- export * from "./validation-message.pipe";
3
- export * from "./form-validation.service";
@@ -1,24 +0,0 @@
1
- import { inject, Pipe, PipeTransform } from "@angular/core";
2
- import { ValidationErrors } from "@angular/forms";
3
- import { FormValidationService } from "./form-validation.service";
4
-
5
- @Pipe({
6
- name: "validationErrors",
7
- standalone: true,
8
- pure: true
9
- })
10
- export class ValidationErrorsPipe implements PipeTransform {
11
- private formValidationService = inject(FormValidationService);
12
-
13
- // allowed keys here to handle errors in case of cross-validators like startDate and endDate validators,
14
- // we pass this custom key to handle the error messages only for the allowed keys
15
- transform(errors: ValidationErrors | null, allowedKeys?: string[]): string[] {
16
- if (!errors) return [];
17
-
18
- return Object.keys(errors)
19
- .filter((errorKey) => !allowedKeys || allowedKeys.includes(errorKey)) // Filter errors if allowedKeys are provided
20
- .map((errorKey) => {
21
- return this.formValidationService.getErrorMessage(errorKey, errors[errorKey]);
22
- });
23
- }
24
- }
@@ -1,35 +0,0 @@
1
- <div class="field flex flex-col gap-2 my-3 relative">
2
- @if (!required) {
3
- <span class="absolute top-[6px] left-0 text-[10px] text-gray-400">{{'forms.config.optional' | translate}}</span>
4
- }
5
- <p-floatlabel [variant]="variant">
6
- <p-auto-complete (completeMethod)="search($event)" (onSelect)="onSelect($event)" [delay]="delay"
7
- [disabled]="disabled" [formControl]="control" [id]="inputId" fluid [typeahead]="typeAhead"
8
- [inputStyleClass]="'reset-default-styles w-full' + (basicInput ? ' basic-style': ' ')"
9
- [minLength]="minLengthToSearch" [name]="name" [ngClass]="{ 'p-invalid ng-dirty ng-invalid': isInvalid}"
10
- [placeholder]="placeholder" [styleClass]="'w-full'" multiple [suggestions]="items">
11
- <ng-template let-item pTemplate="item">
12
- @if (selectedItemTemplate) {
13
- <ng-container [ngTemplateOutletContext]="{ $implicit: item }" [ngTemplateOutlet]="selectedItemTemplate" />
14
- }
15
- </ng-template>
16
- </p-auto-complete>
17
- <label [for]="inputId">
18
- {{ label }}
19
- @if (required) {
20
- <span [class.text-required]="isInvalid">*</span>
21
- }
22
- </label>
23
- </p-floatlabel>
24
- @if (hint) {
25
- <small class="p-mt-1">{{ hint }}</small>
26
- }
27
- @if (isInvalid && (control.dirty || control.touched)) {
28
- <small class="p-error">
29
- @for (error of control.errors | validationErrors; track error) {
30
- {{ error }}<br>
31
- }
32
- </small>
33
- }
34
-
35
- </div>
@@ -1,7 +0,0 @@
1
- .text-required {
2
- color: red;
3
- }
4
-
5
- .p-error {
6
- color: #dc2626;
7
- }
@@ -1,21 +0,0 @@
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
- });
@@ -1,57 +0,0 @@
1
- import { JsonPipe, NgClass, NgIf, NgTemplateOutlet } from '@angular/common';
2
- import { Component, EventEmitter, Input, Output, TemplateRef } 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
- })
33
- export class AutoCompleteComponent extends BaseInputComponent {
34
- @Input() selectedItemTemplate: TemplateRef<unknown> | null = null;
35
- // eslint-disable-next-line @angular-eslint/no-output-on-prefix
36
- @Output() onSearch: EventEmitter<string> = new EventEmitter<string>();
37
- @Output() selectOption: EventEmitter<AutoCompleteSelectEvent> =
38
- new EventEmitter<AutoCompleteSelectEvent>();
39
- @Input() items: any[] = [];
40
- @Input() minLengthToSearch = 3;
41
- @Input() delay = 300; // default value
42
- @Input() basicInput!: boolean;
43
- @Input() typeAhead: boolean = false;
44
- @Input() variant: 'in' | 'over' | 'on' = 'over';
45
-
46
- constructor() {
47
- super();
48
- }
49
-
50
- search(event: AutoCompleteCompleteEvent) {
51
- this.onSearch.emit(event.query);
52
- }
53
-
54
- onSelect(event: AutoCompleteSelectEvent) {
55
- this.selectOption.emit(event);
56
- }
57
- }
@@ -1,35 +0,0 @@
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
- }
@@ -1,41 +0,0 @@
1
- <div class="field flex flex-col gap-2 my-3 relative">
2
-
3
- <p-floatlabel [variant]="variant">
4
- <p-datepicker [selectionMode]="selectionMode" [disabled]="disabled" [formControl]="control" [iconDisplay]="'input'"
5
- [showClear]="showClear" (onClear)="afterClearDate()" [inputId]="inputId"
6
- [inputStyleClass]="'reset-default-styles ' + (basicInput ? 'basic-style' : '')"
7
- [ngClass]="{ 'p-invalid ng-dirty ng-invalid': isInvalid }" [placeholder]="placeholder" [showIcon]="showIcon"
8
- [class]="'w-full'" appendTo="body" [timeOnly]="isTimeOnly" [hourFormat]="hourFormat" [minDate]="minDate"
9
- [maxDate]="maxDate" panelStyleClass="d-ltr">
10
- @if (isTimeOnly) {
11
- <ng-template #inputicon let-clickCallBack="clickCallBack">
12
- <i class="text-[18px] font-icon-time-clock" (click)="clickCallBack($event)"></i>
13
- </ng-template>
14
- <ng-template pTemplate="footer">
15
- <div class="p-datepicker-buttonbar">
16
- <button pButton type="button" class="p-button-text" (click)="selectCurrentTime($event)">الان
17
- </button>
18
- <button pButton type="button" class="p-button-text" (click)="clearButtonClick($event)"> الغاء</button>
19
- </div>
20
- </ng-template>
21
- }
22
- </p-datepicker>
23
-
24
- <label [for]="inputId">
25
- {{ label }}
26
- @if (required) {
27
- <span [class.text-required]="required">*</span>
28
- }
29
- </label>
30
- </p-floatlabel>
31
- @if (hint) {
32
- <small class="p-mt-1">{{ hint }}</small>
33
- }
34
- @if (isInvalid && (control.dirty || control.touched)) {
35
- <small class="p-error">
36
- @for (error of control.errors | validationErrors; track error) {
37
- {{ error }}<br>
38
- }
39
- </small>
40
- }
41
- </div>
@@ -1,16 +0,0 @@
1
- .p-datepicker-clear-icon {
2
- @apply cursor-pointer absolute top-[50%] left-[13px] -translate-y-1/2 text-[var(--p-datepicker-input-icon-color)] ml-[calc(var(--p-icon-size))] leading-none;
3
- }
4
-
5
- .d-ltr{
6
- direction: ltr;
7
- }
8
-
9
-
10
- .text-required {
11
- color: red;
12
- }
13
-
14
- .p-error {
15
- color: #dc2626;
16
- }
@@ -1,21 +0,0 @@
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
- });
@@ -1,54 +0,0 @@
1
- import { NgClass } from '@angular/common';
2
- import { Component, EventEmitter, Input, Output, ViewEncapsulation } from '@angular/core';
3
- import { FormsModule, ReactiveFormsModule } from '@angular/forms';
4
- import { TranslatePipe } from '@ngx-translate/core';
5
- import { DatePicker, DatePickerModule } from 'primeng/datepicker';
6
- import { FloatLabelModule } from 'primeng/floatlabel';
7
- import { ValidationErrorsPipe } from '../../@utils/validations/validation-message.pipe';
8
- import { BaseInputComponent } from '../base-input.component';
9
- @Component({
10
- selector: 'stc-date-picker',
11
- standalone: true,
12
- imports: [
13
- FormsModule,
14
- DatePicker,
15
- ReactiveFormsModule,
16
- NgClass,
17
- DatePickerModule,
18
- ValidationErrorsPipe,
19
- FloatLabelModule,
20
- ],
21
- templateUrl: './date-picker.component.html',
22
- styleUrl: './date-picker.component.scss',
23
- encapsulation: ViewEncapsulation.None,
24
- })
25
- export class DatePickerComponent extends BaseInputComponent {
26
- @Input() showIcon: boolean = false;
27
- @Input() showClear: boolean = false;
28
- @Input() basicInput!: boolean;
29
- @Input() isTimeOnly: boolean = false;
30
- @Input() minDate: Date | undefined | null;
31
- @Input() maxDate: Date | undefined | null;
32
- @Input() hourFormat: '12' | '24' = '12';
33
- nowTime = new Date();
34
- @Input() selectionMode: 'single' | 'range' = 'single';
35
- @Output() onAfterClearDate = new EventEmitter<void>();
36
- @Input() variant: 'in' | 'over' | 'on' = 'over';
37
-
38
- constructor() {
39
- super();
40
- }
41
-
42
- selectCurrentTime(e: any) {
43
- this.control.setValue(this.nowTime);
44
- }
45
-
46
- clearButtonClick(e: any) {
47
- this.control.setValue(null);
48
- }
49
-
50
- afterClearDate() {
51
- this.control.reset();
52
- this.onAfterClearDate.emit();
53
- }
54
- }