@corp-products/ui-components 0.0.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (161) hide show
  1. package/esm2022/corp-products-ui-components.mjs +5 -0
  2. package/esm2022/index.mjs +14 -0
  3. package/esm2022/lib/app-accordion/app-accordion.component.mjs +35 -0
  4. package/esm2022/lib/app-button/app-button.component.mjs +43 -0
  5. package/esm2022/lib/app-button/app-button.mjs +2 -0
  6. package/esm2022/lib/app-button/index.mjs +3 -0
  7. package/esm2022/lib/app-dropdown-menu/app-dropdown-menu.component.mjs +54 -0
  8. package/esm2022/lib/app-dropdown-menu/app-dropdown-menu.mjs +2 -0
  9. package/esm2022/lib/app-dropdown-menu/index.mjs +3 -0
  10. package/esm2022/lib/app-dropdown-menu/menu-popup.pipe.mjs +23 -0
  11. package/esm2022/lib/app-tabs/app-tab.interface.mjs +2 -0
  12. package/esm2022/lib/app-tabs/app-tabs.component.mjs +57 -0
  13. package/esm2022/lib/app-tabs/index.mjs +3 -0
  14. package/esm2022/lib/confirmation-dialog/confirmation-dialog.component.mjs +44 -0
  15. package/esm2022/lib/dynamic-form/dynamic-form.component.mjs +31 -0
  16. package/esm2022/lib/dynamic-form/dynamic-form.interface.mjs +6 -0
  17. package/esm2022/lib/form-components/@utils/form-utils.mjs +11 -0
  18. package/esm2022/lib/form-components/@utils/validations/error-keys.enum.mjs +27 -0
  19. package/esm2022/lib/form-components/@utils/validations/form-validation.service.mjs +50 -0
  20. package/esm2022/lib/form-components/@utils/validations/index.mjs +4 -0
  21. package/esm2022/lib/form-components/@utils/validations/validation-message.pipe.mjs +30 -0
  22. package/esm2022/lib/form-components/components/auto-complete/auto-complete.component.mjs +59 -0
  23. package/esm2022/lib/form-components/components/base-input.component.mjs +57 -0
  24. package/esm2022/lib/form-components/components/date-picker/date-picker.component.mjs +58 -0
  25. package/esm2022/lib/form-components/components/input/input.component.mjs +48 -0
  26. package/esm2022/lib/form-components/components/select/select.component.mjs +72 -0
  27. package/esm2022/lib/form-components/components/select-button/select-button.component.mjs +29 -0
  28. package/esm2022/lib/form-components/components/switcher/switch.component.mjs +34 -0
  29. package/esm2022/lib/form-components/index.mjs +10 -0
  30. package/esm2022/lib/form-components/interfaces/index.mjs +2 -0
  31. package/esm2022/lib/form-components/interfaces/label-value.mjs +2 -0
  32. package/esm2022/lib/ico-moon-icon/ico-moon-icon.component.mjs +41 -0
  33. package/esm2022/lib/read-more/read-more.component.mjs +30 -0
  34. package/esm2022/lib/side-bar/side-bar.component.mjs +51 -0
  35. package/esm2022/lib/user-autocomplete-card/user-autocomplete-card.component.mjs +32 -0
  36. package/esm2022/lib/user-info/user-info.component.mjs +15 -0
  37. package/fesm2022/corp-products-ui-components.mjs +840 -0
  38. package/fesm2022/corp-products-ui-components.mjs.map +1 -0
  39. package/{src/index.ts → index.d.ts} +13 -13
  40. package/lib/app-accordion/app-accordion.component.d.ts +11 -0
  41. package/lib/app-button/app-button.component.d.ts +18 -0
  42. package/{src/lib/app-button/app-button.ts → lib/app-button/app-button.d.ts} +4 -15
  43. package/{src/lib/app-button/index.ts → lib/app-button/index.d.ts} +2 -2
  44. package/lib/app-dropdown-menu/app-dropdown-menu.component.d.ts +20 -0
  45. package/lib/app-dropdown-menu/app-dropdown-menu.d.ts +15 -0
  46. package/{src/lib/app-dropdown-menu/index.ts → lib/app-dropdown-menu/index.d.ts} +2 -2
  47. package/lib/app-dropdown-menu/menu-popup.pipe.d.ts +8 -0
  48. package/lib/app-tabs/app-tab.interface.d.ts +23 -0
  49. package/lib/app-tabs/app-tabs.component.d.ts +18 -0
  50. package/{src/lib/app-tabs/index.ts → lib/app-tabs/index.d.ts} +2 -2
  51. package/lib/confirmation-dialog/confirmation-dialog.component.d.ts +19 -0
  52. package/lib/dynamic-form/dynamic-form.component.d.ts +16 -0
  53. package/lib/dynamic-form/dynamic-form.interface.d.ts +44 -0
  54. package/lib/form-components/@utils/form-utils.d.ts +4 -0
  55. package/lib/form-components/@utils/validations/error-keys.enum.d.ts +24 -0
  56. package/lib/form-components/@utils/validations/form-validation.service.d.ts +11 -0
  57. package/{src/lib/form-components/@utils/validations/index.ts → lib/form-components/@utils/validations/index.d.ts} +3 -3
  58. package/lib/form-components/@utils/validations/validation-message.pipe.d.ts +9 -0
  59. package/lib/form-components/components/auto-complete/auto-complete.component.d.ts +18 -0
  60. package/lib/form-components/components/base-input.component.d.ts +21 -0
  61. package/lib/form-components/components/date-picker/date-picker.component.d.ts +21 -0
  62. package/lib/form-components/components/input/input.component.d.ts +17 -0
  63. package/lib/form-components/components/select/select.component.d.ts +23 -0
  64. package/lib/form-components/components/select-button/select-button.component.d.ts +13 -0
  65. package/lib/form-components/components/switcher/switch.component.d.ts +11 -0
  66. package/{src/lib/form-components/index.ts → lib/form-components/index.d.ts} +9 -9
  67. package/{src/lib/form-components/interfaces/index.ts → lib/form-components/interfaces/index.d.ts} +1 -1
  68. package/lib/form-components/interfaces/label-value.d.ts +4 -0
  69. package/lib/ico-moon-icon/ico-moon-icon.component.d.ts +9 -0
  70. package/lib/read-more/read-more.component.d.ts +10 -0
  71. package/lib/side-bar/side-bar.component.d.ts +18 -0
  72. package/lib/user-autocomplete-card/user-autocomplete-card.component.d.ts +12 -0
  73. package/lib/user-info/user-info.component.d.ts +7 -0
  74. package/package.json +35 -19
  75. package/eslint.config.js +0 -34
  76. package/ng-package.json +0 -7
  77. package/project.json +0 -29
  78. package/src/lib/app-accordion/app-accordion.component.html +0 -15
  79. package/src/lib/app-accordion/app-accordion.component.scss +0 -0
  80. package/src/lib/app-accordion/app-accordion.component.spec.ts +0 -21
  81. package/src/lib/app-accordion/app-accordion.component.ts +0 -21
  82. package/src/lib/app-accordion/index.ts +0 -2
  83. package/src/lib/app-button/app-button.component.html +0 -13
  84. package/src/lib/app-button/app-button.component.scss +0 -0
  85. package/src/lib/app-button/app-button.component.ts +0 -28
  86. package/src/lib/app-dropdown-menu/app-dropdown-menu.component.html +0 -25
  87. package/src/lib/app-dropdown-menu/app-dropdown-menu.component.scss +0 -39
  88. package/src/lib/app-dropdown-menu/app-dropdown-menu.component.spec.ts +0 -21
  89. package/src/lib/app-dropdown-menu/app-dropdown-menu.component.ts +0 -43
  90. package/src/lib/app-dropdown-menu/app-dropdown-menu.ts +0 -17
  91. package/src/lib/app-dropdown-menu/menu-popup.pipe.ts +0 -18
  92. package/src/lib/app-tabs/app-tab.interface.ts +0 -26
  93. package/src/lib/app-tabs/app-tabs.component.html +0 -35
  94. package/src/lib/app-tabs/app-tabs.component.scss +0 -103
  95. package/src/lib/app-tabs/app-tabs.component.spec.ts +0 -21
  96. package/src/lib/app-tabs/app-tabs.component.ts +0 -48
  97. package/src/lib/confirmation-dialog/confirmation-dialog.component.html +0 -54
  98. package/src/lib/confirmation-dialog/confirmation-dialog.component.scss +0 -0
  99. package/src/lib/confirmation-dialog/confirmation-dialog.component.spec.ts +0 -22
  100. package/src/lib/confirmation-dialog/confirmation-dialog.component.ts +0 -51
  101. package/src/lib/dynamic-form/dynamic-form.component.html +0 -39
  102. package/src/lib/dynamic-form/dynamic-form.component.scss +0 -0
  103. package/src/lib/dynamic-form/dynamic-form.component.spec.ts +0 -21
  104. package/src/lib/dynamic-form/dynamic-form.component.ts +0 -29
  105. package/src/lib/dynamic-form/dynamic-form.interface.ts +0 -56
  106. package/src/lib/form-components/@utils/form-utils.ts +0 -12
  107. package/src/lib/form-components/@utils/validations/error-keys.enum.ts +0 -24
  108. package/src/lib/form-components/@utils/validations/form-validation.service.ts +0 -53
  109. package/src/lib/form-components/@utils/validations/validation-message.pipe.ts +0 -24
  110. package/src/lib/form-components/components/auto-complete/auto-complete.component.html +0 -48
  111. package/src/lib/form-components/components/auto-complete/auto-complete.component.scss +0 -0
  112. package/src/lib/form-components/components/auto-complete/auto-complete.component.spec.ts +0 -21
  113. package/src/lib/form-components/components/auto-complete/auto-complete.component.ts +0 -48
  114. package/src/lib/form-components/components/base-input.component.ts +0 -41
  115. package/src/lib/form-components/components/date-picker/date-picker.component.html +0 -53
  116. package/src/lib/form-components/components/date-picker/date-picker.component.scss +0 -4
  117. package/src/lib/form-components/components/date-picker/date-picker.component.spec.ts +0 -23
  118. package/src/lib/form-components/components/date-picker/date-picker.component.ts +0 -45
  119. package/src/lib/form-components/components/input/input.component.html +0 -59
  120. package/src/lib/form-components/components/input/input.component.scss +0 -3
  121. package/src/lib/form-components/components/input/input.component.spec.ts +0 -21
  122. package/src/lib/form-components/components/input/input.component.ts +0 -32
  123. package/src/lib/form-components/components/select/select.component.html +0 -90
  124. package/src/lib/form-components/components/select/select.component.scss +0 -0
  125. package/src/lib/form-components/components/select/select.component.spec.ts +0 -21
  126. package/src/lib/form-components/components/select/select.component.ts +0 -51
  127. package/src/lib/form-components/components/select-button/select-button.component.html +0 -21
  128. package/src/lib/form-components/components/select-button/select-button.component.scss +0 -0
  129. package/src/lib/form-components/components/select-button/select-button.component.spec.ts +0 -21
  130. package/src/lib/form-components/components/select-button/select-button.component.ts +0 -22
  131. package/src/lib/form-components/components/switcher/switch.component.html +0 -5
  132. package/src/lib/form-components/components/switcher/switch.component.scss +0 -0
  133. package/src/lib/form-components/components/switcher/switch.component.spec.ts +0 -21
  134. package/src/lib/form-components/components/switcher/switch.component.ts +0 -25
  135. package/src/lib/form-components/interfaces/label-value.ts +0 -4
  136. package/src/lib/ico-moon-icon/ico-moon-icon.component.ts +0 -23
  137. package/src/lib/read-more/read-more.component.html +0 -17
  138. package/src/lib/read-more/read-more.component.scss +0 -0
  139. package/src/lib/read-more/read-more.component.spec.ts +0 -21
  140. package/src/lib/read-more/read-more.component.ts +0 -21
  141. package/src/lib/side-bar/side-bar.component.html +0 -25
  142. package/src/lib/side-bar/side-bar.component.scss +0 -5
  143. package/src/lib/side-bar/side-bar.component.spec.ts +0 -21
  144. package/src/lib/side-bar/side-bar.component.ts +0 -32
  145. package/src/lib/side-bar-dynamic/data-injector.pipe.ts +0 -15
  146. package/src/lib/side-bar-dynamic/dynamic-sidebar.service.ts +0 -116
  147. package/src/lib/side-bar-dynamic/side-bar-dynamic.component.html +0 -51
  148. package/src/lib/side-bar-dynamic/side-bar-dynamic.component.scss +0 -5
  149. package/src/lib/side-bar-dynamic/side-bar-dynamic.component.spec.ts +0 -21
  150. package/src/lib/side-bar-dynamic/side-bar-dynamic.component.ts +0 -37
  151. package/src/lib/side-bar-dynamic/side-bar-utils.ts +0 -30
  152. package/src/lib/side-bar-dynamic/sidebar-config.ts +0 -48
  153. package/src/lib/user-autocomplete-card/user-autocomplete-card.component.html +0 -20
  154. package/src/lib/user-autocomplete-card/user-autocomplete-card.component.scss +0 -0
  155. package/src/lib/user-autocomplete-card/user-autocomplete-card.component.spec.ts +0 -21
  156. package/src/lib/user-autocomplete-card/user-autocomplete-card.component.ts +0 -21
  157. package/src/lib/user-info/user-info.component.html +0 -10
  158. package/src/lib/user-info/user-info.component.ts +0 -11
  159. package/tsconfig.json +0 -25
  160. package/tsconfig.lib.json +0 -12
  161. package/tsconfig.lib.prod.json +0 -9
@@ -1,21 +0,0 @@
1
- import { ComponentFixture, TestBed } from "@angular/core/testing";
2
- import { SwitchComponent } from "./switch.component";
3
-
4
- describe("SwitchComponent", () => {
5
- let component: SwitchComponent;
6
- let fixture: ComponentFixture<SwitchComponent>;
7
-
8
- beforeEach(async () => {
9
- await TestBed.configureTestingModule({
10
- imports: [SwitchComponent]
11
- }).compileComponents();
12
-
13
- fixture = TestBed.createComponent(SwitchComponent);
14
- component = fixture.componentInstance;
15
- fixture.detectChanges();
16
- });
17
-
18
- it("should create", () => {
19
- expect(component).toBeTruthy();
20
- });
21
- });
@@ -1,25 +0,0 @@
1
- import { Component, EventEmitter, Input, Output } from "@angular/core";
2
- import { CommonModule } from "@angular/common";
3
- import { ToggleSwitchModule } from 'primeng/toggleswitch';
4
- import { FormsModule } from "@angular/forms";
5
-
6
- @Component({
7
- selector: "stc-switch",
8
- standalone: true,
9
- imports: [CommonModule, ToggleSwitchModule, FormsModule],
10
- templateUrl: "./switch.component.html",
11
- styleUrl: "./switch.component.scss"
12
- })
13
- export class SwitchComponent {
14
- @Input() label: string;
15
- @Input() key: string;
16
- @Input() checked: boolean = false;
17
- @Output() onChange: EventEmitter<string> = new EventEmitter<string>();
18
- // checked: boolean = false;
19
-
20
- sendUpdatedValue(value: any) {
21
- if (value) {
22
- this.onChange.emit(value.checked);
23
- }
24
- }
25
- }
@@ -1,4 +0,0 @@
1
- export interface LabelValue<T> {
2
- label: string;
3
- value: T | any;
4
- }
@@ -1,23 +0,0 @@
1
- import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
2
-
3
- @Component({
4
- selector: 'app-ico-moon-card',
5
- standalone: true,
6
- template:`
7
- <i [class]="iconName + ' ' + iconClass">
8
- @for (path of getPathCount; track $index) {
9
- <i [class]="iconName + ' path'+path"></i>
10
- }
11
- </i>
12
- `,
13
- changeDetection: ChangeDetectionStrategy.OnPush
14
- })
15
- export class IcoMoonIconComponent {
16
- @Input({ required: true }) iconName!: string;
17
- @Input() iconClass!: string;
18
- @Input() iconPathCount = 0;
19
-
20
- get getPathCount() {
21
- return Array.from({ length: this.iconPathCount }, (_, i) => i + 1);
22
- }
23
- }
@@ -1,17 +0,0 @@
1
- <p [class]="styleClass">
2
- {{ isExpanded ? text : (text | slice : 0 : maxCharacters) }}
3
- @if (text.length > maxCharacters && !isExpanded) {
4
- <span>...</span>
5
- }
6
- @if (isExpanded) {
7
- <span>
8
- {{ text | slice : maxCharacters + 1 : text.length }}
9
- </span>
10
- }
11
- <br>
12
- @if (text.length > maxCharacters) {
13
- <span class="text-primary_light cursor-pointer" (click)="toggleReadMore()">
14
- {{ isExpanded ? ('less' | translate) : ('more' | translate) }}
15
- </span>
16
- }
17
- </p>
File without changes
@@ -1,21 +0,0 @@
1
- import { ComponentFixture, TestBed } from "@angular/core/testing";
2
- import { ReadMoreComponent } from "./read-more.component";
3
-
4
- describe("ReadMoreComponent", () => {
5
- let component: ReadMoreComponent;
6
- let fixture: ComponentFixture<ReadMoreComponent>;
7
-
8
- beforeEach(async () => {
9
- await TestBed.configureTestingModule({
10
- imports: [ReadMoreComponent]
11
- }).compileComponents();
12
-
13
- fixture = TestBed.createComponent(ReadMoreComponent);
14
- component = fixture.componentInstance;
15
- fixture.detectChanges();
16
- });
17
-
18
- it("should create", () => {
19
- expect(component).toBeTruthy();
20
- });
21
- });
@@ -1,21 +0,0 @@
1
- import { Component, Input } from "@angular/core";
2
- import {SlicePipe} from "@angular/common";
3
- import { TranslateModule } from "@ngx-translate/core";
4
-
5
- @Component({
6
- selector: "app-read-more",
7
- standalone: true,
8
- imports: [TranslateModule, SlicePipe],
9
- templateUrl: "./read-more.component.html",
10
- styleUrl: "./read-more.component.scss"
11
- })
12
- export class ReadMoreComponent {
13
- @Input({ required: true }) text = "";
14
- @Input() styleClass = "";
15
- @Input() maxCharacters = 100;
16
- isExpanded = false;
17
-
18
- toggleReadMore() {
19
- this.isExpanded = !this.isExpanded;
20
- }
21
- }
@@ -1,25 +0,0 @@
1
- <!-- TODO refactor position sidebar based on html dir-->
2
- <p-drawer
3
- (onHide)="hideSidebar()"
4
- (onShow)="onShow.emit($event)"
5
- [(visible)]="show"
6
- [closable]="closable"
7
- [closeOnEscape]="closeOnEscape"
8
- [dismissible]="dismissible"
9
- [ngClass]="{ show: show }"
10
- [position]="'left'"
11
- appendTo="body"
12
- styleClass="p-drawer-{{ sidebarSize }} custom-content bg-white {{ styleClass }}">
13
- <ng-template pTemplate="header">{{ title }}</ng-template>
14
- @if (contentTemplate) {
15
- <ng-template pTemplate="content">
16
- <ng-container *ngTemplateOutlet="contentTemplate"></ng-container>
17
- </ng-template>
18
- <ng-template pTemplate="footer">
19
- <ng-container *ngTemplateOutlet="footerTemplate"></ng-container>
20
- </ng-template>
21
- }
22
- <ng-template pTemplate="content">
23
- <ng-content id="side-content"></ng-content>
24
- </ng-template>
25
- </p-drawer>
@@ -1,5 +0,0 @@
1
- .sidebar {
2
- &.show {
3
- @apply min-w-[550px];
4
- }
5
- }
@@ -1,21 +0,0 @@
1
- import { ComponentFixture, TestBed } from '@angular/core/testing';
2
- import { SideBarComponent } from './side-bar.component';
3
-
4
- describe('SideBarComponent', () => {
5
- let component: SideBarComponent;
6
- let fixture: ComponentFixture<SideBarComponent>;
7
-
8
- beforeEach(async () => {
9
- await TestBed.configureTestingModule({
10
- imports: [SideBarComponent],
11
- }).compileComponents();
12
-
13
- fixture = TestBed.createComponent(SideBarComponent);
14
- component = fixture.componentInstance;
15
- fixture.detectChanges();
16
- });
17
-
18
- it('should create', () => {
19
- expect(component).toBeTruthy();
20
- });
21
- });
@@ -1,32 +0,0 @@
1
- import { NgClass, NgTemplateOutlet } from "@angular/common";
2
- import { Component, EventEmitter, Input, Output, TemplateRef, ViewEncapsulation } from "@angular/core";
3
- import { PrimeTemplate } from "primeng/api";
4
- import { Drawer } from "primeng/drawer";
5
-
6
- @Component({
7
- selector: "app-side-bar",
8
- standalone: true,
9
- imports: [PrimeTemplate, Drawer, NgClass, NgTemplateOutlet],
10
- templateUrl: "./side-bar.component.html",
11
- styleUrl: "./side-bar.component.scss",
12
- encapsulation: ViewEncapsulation.None
13
- })
14
- export class SideBarComponent {
15
- @Input() show = false;
16
- @Input() title: string;
17
- @Input() closable = false;
18
- @Input() dismissible = false;
19
- @Input() closeOnEscape = false;
20
- @Input() sidebarSize: "sm" | "md" | "lg" | "xl" = "sm";
21
- @Input() styleClass = "";
22
- @Output() hide = new EventEmitter<boolean>();
23
- // eslint-disable-next-line @angular-eslint/no-output-on-prefix
24
- @Output() onShow = new EventEmitter<boolean>();
25
- @Input() contentTemplate!: TemplateRef<unknown>;
26
- @Input() footerTemplate!: TemplateRef<unknown>;
27
-
28
- hideSidebar() {
29
- this.show = false;
30
- this.hide.emit(false);
31
- }
32
- }
@@ -1,15 +0,0 @@
1
- import {inject, Injector, Pipe, PipeTransform} from '@angular/core';
2
- import {createCustomInjector, SIDEBAR_DATA} from "libs/ui-components/src/lib/side-bar-dynamic/side-bar-utils";
3
-
4
- @Pipe({
5
- name: 'dataInjector',
6
- standalone: true,
7
- pure: true
8
- })
9
- export class DataInjectorPipe implements PipeTransform {
10
- injector = inject(Injector);
11
-
12
- transform(data: unknown): Injector {
13
- return createCustomInjector(this.injector, SIDEBAR_DATA, data);
14
- }
15
- }
@@ -1,116 +0,0 @@
1
- import { ApplicationRef, ComponentRef, createComponent, EmbeddedViewRef, EnvironmentInjector, Injectable, Type } from "@angular/core";
2
- import { AbstractControl } from "@angular/forms";
3
- import { SideBarDynamicComponent } from "libs/ui-components/src/lib/side-bar-dynamic/side-bar-dynamic.component";
4
- import { SidebarActionEvent, SidebarActionType } from "libs/ui-components/src/lib/side-bar-dynamic/side-bar-utils";
5
- import { SidebarConfig, SidebarConfigDefaults } from "libs/ui-components/src/lib/side-bar-dynamic/sidebar-config";
6
- import { BehaviorSubject, Subject } from "rxjs";
7
-
8
- @Injectable({
9
- providedIn: "root"
10
- })
11
- export class DynamicSidebarService {
12
- contentComponentRef: Type<any> | null = null;
13
- contentComponentData: unknown;
14
- sidebarConfig: SidebarConfig = this.getDefaultConfig();
15
- activeForm: AbstractControl | null = null;
16
- private componentRef: ComponentRef<SideBarDynamicComponent> | null = null;
17
- private sidebarAction$ = new Subject<SidebarActionEvent>();
18
- action$ = this.sidebarAction$.asObservable();
19
- private sidebarSideEffectAction$ = new Subject<SidebarActionEvent>();
20
- sideEffectAction$ = this.sidebarSideEffectAction$.asObservable();
21
- private isOpen$ = new BehaviorSubject<boolean>(false);
22
- isOpenObservable$ = this.isOpen$.asObservable();
23
-
24
- constructor(private environmentInjector: EnvironmentInjector, private appRef: ApplicationRef) {}
25
-
26
- // Action notifications
27
- notifyAction(type: SidebarActionType, payload?: any): void {
28
- this.sidebarAction$.next({type, payload});
29
- }
30
-
31
- notifySideEffectAction(type: SidebarActionType, payload?: any): void {
32
- this.sidebarSideEffectAction$.next({type, payload});
33
- }
34
-
35
- // Form management
36
- setActiveForm(control: AbstractControl): void {
37
- this.activeForm = control;
38
- }
39
-
40
- resetActiveForm(): void {
41
- this.activeForm = null;
42
- }
43
-
44
- isButtonDisabled(): boolean {
45
- if (!this.activeForm) {
46
- return false;
47
- }
48
- return this.activeForm.invalid || this.activeForm.untouched;
49
- }
50
-
51
- open(component: unknown, config: SidebarConfig, data?: any): void {
52
- // Close any existing sidebar before opening a new one
53
- // TODO Need to Review
54
- if (!component) {
55
- return;
56
- }
57
-
58
- this.close();
59
- this.contentComponentRef = component as Type<any>;
60
- this.contentComponentData = data;
61
- this.sidebarConfig = {...this.getDefaultConfig(), ...config};
62
-
63
- this.componentRef = createComponent(SideBarDynamicComponent, {
64
- environmentInjector: this.environmentInjector,
65
- });
66
- // Attach the component to the Angular application
67
- this.appRef.attachView(this.componentRef.hostView);
68
-
69
- // Append the component to the DOM
70
- const domElem = (this.componentRef.hostView as EmbeddedViewRef<any>).rootNodes[0] as HTMLElement;
71
- document.body.appendChild(domElem);
72
- }
73
-
74
- /**
75
- * Closes the currently open sidebar, if any.
76
- */
77
- close(): void {
78
- if (this.componentRef) {
79
- // Detach the view and destroy the component
80
- this.appRef.detachView(this.componentRef.hostView);
81
- this.componentRef.destroy();
82
- this.componentRef = null;
83
-
84
- // Reset content and configuration
85
- this.contentComponentRef = null;
86
- this.contentComponentData = null;
87
- this.sidebarConfig = this.getDefaultConfig();
88
- this.isOpen$.next(false);
89
- this.resetActiveForm();
90
- this.notifySideEffectAction(SidebarActionType.CLOSE);
91
- }
92
- }
93
-
94
- cancel(): void {
95
- this.notifyAction(SidebarActionType.CANCEL);
96
- }
97
-
98
- submit(flag: boolean = false): void {
99
- const actionType = flag ? SidebarActionType.SaveMore : SidebarActionType.SAVE;
100
- this.notifyAction(actionType, {withClose: flag});
101
- }
102
-
103
- /**
104
- * Provides the default configuration for the sidebar.
105
- * @returns The default SidebarConfig object.
106
- */
107
- private getDefaultConfig(): SidebarConfig {
108
- return {
109
- ...SidebarConfigDefaults,
110
- show: false,
111
- visible: false,
112
- closable: false,
113
- dismissible: true
114
- };
115
- }
116
- }
@@ -1,51 +0,0 @@
1
- <p-drawer
2
- (onHide)="dynamicSidebarService.close()"
3
- [(visible)]="sidebarConfig.visible"
4
- [closable]="sidebarConfig.closable"
5
- [closeOnEscape]="sidebarConfig.closeOnEscape"
6
- [dismissible]="sidebarConfig.dismissible"
7
- [ngClass]="{ show: sidebarConfig.show }"
8
- [position]="'left'"
9
- appendTo="body"
10
- id="main-drawer"
11
- styleClass="p-drawer-{{ sidebarConfig.sidebarSize }} custom-content bg-white {{ sidebarConfig.styleClass }}">
12
- <ng-template pTemplate="header">{{ sidebarConfig.title }}</ng-template>
13
- <ng-template pTemplate="content">
14
- <ng-container
15
- [ngComponentOutletInjector]="dynamicSidebarService.contentComponentData | dataInjector"
16
- [ngComponentOutlet]="dynamicSidebarService.contentComponentRef"></ng-container>
17
- </ng-template>
18
- @if (sidebarConfig.showSaveBtn || sidebarConfig.showSaveAndMoreBtn || sidebarConfig.showCancelBtn) {
19
- <ng-template pTemplate="footer">
20
- <section class="flex justify-between bg-gray-200 py-4" id="sidebar-footer">
21
- <div class="flex gap-2">
22
- @if (sidebarConfig.showSaveBtn) {
23
- <app-button (clickEmitter)="dynamicSidebarService.submit(true)"
24
- [disabled]="dynamicSidebarService.isButtonDisabled()"
25
- [icon]="sidebarConfig!.actions!.save!.icon || 'font-icon-plus'"
26
- [iconPos]="sidebarConfig!.actions!.save!.iconPos || 'right'"
27
- [style]="sidebarConfig!.actions!.save!.style || 'danger'"
28
- [title]="sidebarConfig!.actions!.save!.title || ('actions.save' | translate)"
29
- [variant]="sidebarConfig!.actions!.save!.variant"/>
30
- }
31
- @if (sidebarConfig.showSaveAndMoreBtn) {
32
- <app-button (clickEmitter)="dynamicSidebarService.submit()"
33
- [disabled]="dynamicSidebarService.isButtonDisabled()"
34
- [icon]="sidebarConfig!.actions!.saveAndMore!.icon || 'font-icon-plus'"
35
- [iconPos]="sidebarConfig!.actions!.saveAndMore!.iconPos || 'right'"
36
- [style]="sidebarConfig!.actions!.saveAndMore!.style || 'danger'"
37
- [title]="sidebarConfig!.actions!.saveAndMore!.title || ('actions.save_and_and_more' | translate)"
38
- [variant]="sidebarConfig!.actions!.saveAndMore!.variant"/>
39
-
40
- }
41
- </div>
42
- @if (sidebarConfig.showCancelBtn) {
43
- <app-button
44
- (clickEmitter)="dynamicSidebarService.cancel()"
45
- [style]="'secondary'"
46
- [title]="'actions.cancel' | translate"/>
47
- }
48
- </section>
49
- </ng-template>
50
- }
51
- </p-drawer>
@@ -1,5 +0,0 @@
1
- .sidebar {
2
- &.show {
3
- min-width: 550px;
4
- }
5
- }
@@ -1,21 +0,0 @@
1
- import { ComponentFixture, TestBed } from '@angular/core/testing';
2
- import { DynamicSideBarComponent } from 'libs/ui-components/src/lib/dynamic-side-bar/dynamic-side-bar.component';
3
-
4
- describe('SideBarComponent', () => {
5
- let component: DynamicSideBarComponent;
6
- let fixture: ComponentFixture<DynamicSideBarComponent>;
7
-
8
- beforeEach(async () => {
9
- await TestBed.configureTestingModule({
10
- imports: [DynamicSideBarComponent],
11
- }).compileComponents();
12
-
13
- fixture = TestBed.createComponent(DynamicSideBarComponent);
14
- component = fixture.componentInstance;
15
- fixture.detectChanges();
16
- });
17
-
18
- it('should create', () => {
19
- expect(component).toBeTruthy();
20
- });
21
- });
@@ -1,37 +0,0 @@
1
- import {NgClass, NgComponentOutlet} from "@angular/common";
2
- import {Component, inject, Injector, OnDestroy, OnInit} from '@angular/core';
3
- import {AppButtonComponent} from "@ui-components";
4
- import {DataInjectorPipe} from "libs/ui-components/src/lib/side-bar-dynamic/data-injector.pipe";
5
- import {DynamicSidebarService} from "libs/ui-components/src/lib/side-bar-dynamic/dynamic-sidebar.service";
6
- import {createCustomInjector, SIDEBAR_DATA} from "libs/ui-components/src/lib/side-bar-dynamic/side-bar-utils";
7
- import {PrimeTemplate} from "primeng/api";
8
- import {Drawer} from "primeng/drawer";
9
- import { Location } from '@angular/common';
10
- import {TranslatePipe} from "@ngx-translate/core";
11
- @Component({
12
- selector: "app-side-bar-dynamic",
13
- templateUrl: "./side-bar-dynamic.component.html",
14
- styleUrls: ["./side-bar-dynamic.component.scss"],
15
- standalone: true,
16
- imports: [Drawer, NgClass, NgComponentOutlet, PrimeTemplate, DataInjectorPipe, AppButtonComponent, TranslatePipe]
17
- })
18
- export class SideBarDynamicComponent implements OnInit, OnDestroy {
19
- dynamicSidebarService = inject(DynamicSidebarService);
20
- parentInjector = inject(Injector);
21
- location = inject(Location);
22
- private popStateListener: any;
23
- sidebarConfig = this.dynamicSidebarService.sidebarConfig;
24
- ngOnInit() {
25
- //To close a sidebar when the browser back button is pressed
26
- this.popStateListener = this.location.subscribe(() => {
27
- if (this.dynamicSidebarService.sidebarConfig.visible) {
28
- this.dynamicSidebarService.close();
29
- }
30
- });
31
- }
32
-
33
- ngOnDestroy() {
34
- // reset Sidebar token
35
- createCustomInjector(this.parentInjector, SIDEBAR_DATA, null);
36
- }
37
- }
@@ -1,30 +0,0 @@
1
- import {InjectionToken, Injector} from "@angular/core";
2
-
3
- export const SIDEBAR_DATA = new InjectionToken<any>('SIDEBAR_DATA');
4
-
5
- export function createCustomInjector(parentInjector: Injector, injectionToken: InjectionToken<unknown>, data: unknown): Injector {
6
- return Injector.create({
7
- parent: parentInjector,
8
- providers: [
9
- {
10
- provide: injectionToken,
11
- useValue: data ?? null
12
- }
13
- ]
14
- })
15
- };
16
-
17
-
18
- export enum SidebarActionType {
19
- SAVE = 'SAVE',
20
- SaveMore = 'SaveMore',
21
- CANCEL = 'CANCEL',
22
- SUBMIT = 'SUBMIT',
23
- CLOSE = 'CLOSE',
24
- CloseWithData = 'CloseWithData',
25
- }
26
-
27
- export interface SidebarActionEvent {
28
- type: SidebarActionType;
29
- payload?: any;
30
- }
@@ -1,48 +0,0 @@
1
- import { AppButtonIconPos, AppButtonSeverity, AppButtonSize, AppButtonVariant } from "@ui-components";
2
-
3
- export interface SidebarActionConfig {
4
- title?: string;
5
- icon?: string;
6
- size?: AppButtonSize;
7
- style?: AppButtonSeverity;
8
- iconPos?: AppButtonIconPos;
9
- variant?: AppButtonVariant;
10
- }
11
-
12
- export interface SidebarConfig {
13
- title: string;
14
- show: boolean;
15
- visible: boolean;
16
- closable: boolean;
17
- dismissible: boolean;
18
- closeOnEscape: boolean;
19
- sidebarSize: "sm" | "md" | "lg" | "xl";
20
- styleClass?: string;
21
- showCancelBtn: boolean;
22
- showSaveBtn: boolean;
23
- showSaveAndMoreBtn: boolean;
24
- actions?: {
25
- cancel?: SidebarActionConfig;
26
- save?: SidebarActionConfig;
27
- saveAndMore?: SidebarActionConfig;
28
- };
29
- }
30
-
31
- export const SidebarConfigDefaults: SidebarConfig = {
32
- title: "",
33
- show: true,
34
- visible: true,
35
- closable: true,
36
- dismissible: false,
37
- closeOnEscape: false,
38
- sidebarSize: "md",
39
- showCancelBtn: true,
40
- showSaveBtn: true,
41
- showSaveAndMoreBtn: true,
42
- actions: {
43
- save: {},
44
- saveAndMore: {
45
- variant: "outlined"
46
- }
47
- }
48
- };
@@ -1,20 +0,0 @@
1
- <div class="flex gap-2 items-center justify-between p-4 rounded mb-4 border border-dotted border-gray-300 bg-gray-100">
2
- <div class="flex gap-4 items-center">
3
- <img [alt]="userData.name" [src]="userData.profileImage" class="rounded-full object-cover w-[48px] h-[48px]" />
4
- <div class="flex flex-col justify-end">
5
- <h4 class="font-bold text-[12px] text-gray-800 truncate max-w-[135px] dir-ltr">
6
- {{ userData.name }}
7
- </h4>
8
- <p class="text-[12px] text-gray-700">{{ explicitRole ? explicitRole : userData.position.name }}</p>
9
- </div>
10
- </div>
11
- <div class="flex-1 flex flex-col items-end">
12
- <p class="text-[12px] text-purple-700 truncate max-w-[90px] dir-ltr">{{ userData.email }}</p>
13
- <p class="text-[12px] text-gray-600 dir-ltr">{{ userData.contact.mobile }}</p>
14
- </div>
15
- @if (showDeleteAction){
16
- <div class="flex gap-1 flex-nowrap">
17
- <app-button (clickEmitter)="onDelete()" [rounded]="true" [size]="'large'" [text]="true" icon="font-icon-trash"/>
18
- </div>
19
- }
20
- </div>
@@ -1,21 +0,0 @@
1
- import { ComponentFixture, TestBed } from "@angular/core/testing";
2
- import { BaseCardComponent } from "../base-card/base-card.component";
3
-
4
- describe("BaseCardComponent", () => {
5
- let component: BaseCardComponent;
6
- let fixture: ComponentFixture<BaseCardComponent>;
7
-
8
- beforeEach(async () => {
9
- await TestBed.configureTestingModule({
10
- imports: [BaseCardComponent]
11
- }).compileComponents();
12
-
13
- fixture = TestBed.createComponent(BaseCardComponent);
14
- component = fixture.componentInstance;
15
- fixture.detectChanges();
16
- });
17
-
18
- it("should create", () => {
19
- expect(component).toBeTruthy();
20
- });
21
- });
@@ -1,21 +0,0 @@
1
- import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from "@angular/core";
2
- import { AppButtonComponent } from "../app-button";
3
-
4
- @Component({
5
- selector: "app-user-autocomplete-card",
6
- standalone: true,
7
- imports: [AppButtonComponent],
8
- templateUrl: "./user-autocomplete-card.component.html",
9
- styleUrl: "./user-autocomplete-card.component.scss",
10
- changeDetection: ChangeDetectionStrategy.OnPush
11
- })
12
- export class UserAutocompleteCardComponent {
13
- @Output() select = new EventEmitter<any>();
14
- @Output() delete = new EventEmitter<any>();
15
- @Input({ required: true }) userData: any;
16
- @Input() explicitRole = "";
17
- @Input() showDeleteAction = true;
18
- onDelete() {
19
- this.delete.emit(this.userData);
20
- }
21
- }
@@ -1,10 +0,0 @@
1
- <div class="flex items-center gap-2">
2
- <img
3
- [alt]="name"
4
- [src]="profileImage"
5
- class="rounded-full object-cover w-[24px] h-[24px]"
6
- height="24"
7
- width="24"
8
- />
9
- <p class="text-[14px]">{{ name }}</p>
10
- </div>
@@ -1,11 +0,0 @@
1
- import { Component, Input } from "@angular/core";
2
-
3
- @Component({
4
- selector: "user-info",
5
- templateUrl: "./user-info.component.html",
6
- standalone: true
7
- })
8
- export class UserInfoComponent {
9
- @Input() profileImage: string;
10
- @Input() name: string;
11
- }