angular-dumb-lib 0.0.1 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ng-package.json +7 -0
- package/package.json +3 -16
- package/src/lib/angular-dumb-lib.component.spec.ts +21 -0
- package/src/lib/angular-dumb-lib.component.ts +15 -0
- package/src/lib/angular-dumb-lib.module.ts +19 -0
- package/src/lib/angular-dumb-lib.service.spec.ts +16 -0
- package/src/lib/angular-dumb-lib.service.ts +9 -0
- package/src/lib/components/atoms/button/button.component.html +15 -0
- package/src/lib/components/atoms/button/button.component.scss +76 -0
- package/src/lib/components/atoms/button/button.component.ts +33 -0
- package/src/lib/components/atoms/datetime-picker/datetime-picker.component.html +7 -0
- package/src/lib/components/atoms/datetime-picker/datetime-picker.component.scss +24 -0
- package/src/lib/components/atoms/datetime-picker/datetime-picker.component.ts +59 -0
- package/src/lib/components/atoms/file-selection/file-selection.component.html +24 -0
- package/src/lib/components/atoms/file-selection/file-selection.component.scss +35 -0
- package/src/lib/components/atoms/file-selection/file-selection.component.ts +86 -0
- package/src/lib/components/atoms/input/input.component.html +28 -0
- package/src/lib/components/atoms/input/input.component.scss +64 -0
- package/src/lib/components/atoms/input/input.component.ts +57 -0
- package/src/lib/components/atoms/loading/loading.component.html +3 -0
- package/src/lib/components/atoms/loading/loading.component.scss +36 -0
- package/src/lib/components/atoms/loading/loading.component.ts +21 -0
- package/src/lib/components/atoms/selection/selection.component.html +38 -0
- package/src/lib/components/atoms/selection/selection.component.scss +65 -0
- package/src/lib/components/atoms/selection/selection.component.ts +84 -0
- package/src/lib/components/atoms/slider/slider.component.html +14 -0
- package/src/lib/components/atoms/slider/slider.component.scss +50 -0
- package/src/lib/components/atoms/slider/slider.component.ts +37 -0
- package/src/lib/components/atoms/tags/tags.component.html +25 -0
- package/src/lib/components/atoms/tags/tags.component.scss +58 -0
- package/src/lib/components/atoms/tags/tags.component.ts +62 -0
- package/src/lib/components/molecules/cards/cards.component.html +12 -0
- package/src/lib/components/molecules/cards/cards.component.scss +14 -0
- package/src/lib/components/molecules/cards/cards.component.ts +19 -0
- package/src/lib/components/molecules/content-design/content-design.component.html +14 -0
- package/src/lib/components/molecules/content-design/content-design.component.scss +68 -0
- package/src/lib/components/molecules/content-design/content-design.component.ts +32 -0
- package/src/lib/components/molecules/form/form.component.html +22 -0
- package/src/lib/components/molecules/form/form.component.scss +17 -0
- package/src/lib/components/molecules/form/form.component.ts +64 -0
- package/src/lib/components/molecules/modal/modal.component.html +16 -0
- package/src/lib/components/molecules/modal/modal.component.scss +83 -0
- package/src/lib/components/molecules/modal/modal.component.ts +48 -0
- package/src/lib/components/molecules/paginator/paginator.component.html +25 -0
- package/src/lib/components/molecules/paginator/paginator.component.scss +27 -0
- package/src/lib/components/molecules/paginator/paginator.component.ts +126 -0
- package/src/lib/components/molecules/table/table.component.html +45 -0
- package/src/lib/components/molecules/table/table.component.scss +169 -0
- package/src/lib/components/molecules/table/table.component.ts +40 -0
- package/src/lib/components/pages/footer/footer.component.html +32 -0
- package/src/lib/components/pages/footer/footer.component.scss +69 -0
- package/src/lib/components/pages/footer/footer.component.ts +16 -0
- package/src/lib/components/pages/login/login.component.html +10 -0
- package/src/lib/components/pages/login/login.component.scss +32 -0
- package/src/lib/components/pages/login/login.component.ts +32 -0
- package/src/lib/components/pages/menu/menu.component.html +18 -0
- package/src/lib/components/pages/menu/menu.component.scss +87 -0
- package/src/lib/components/pages/menu/menu.component.ts +26 -0
- package/src/lib/components/pages/version/version.component.html +3 -0
- package/src/lib/components/pages/version/version.component.scss +0 -0
- package/src/lib/components/pages/version/version.component.ts +28 -0
- package/src/lib/shared/constants/constant.ts +7 -0
- package/src/lib/shared/enums/enum.ts +68 -0
- package/src/lib/shared/interfaces/interface.ts +64 -0
- package/{public-api.d.ts → src/public-api.ts} +5 -1
- package/tsconfig.lib.json +14 -0
- package/tsconfig.lib.prod.json +10 -0
- package/tsconfig.spec.json +14 -0
- package/esm2022/angular-dumb-lib.mjs +0 -5
- package/esm2022/lib/angular-dumb-lib.component.mjs +0 -20
- package/esm2022/lib/angular-dumb-lib.module.mjs +0 -32
- package/esm2022/lib/angular-dumb-lib.service.mjs +0 -15
- package/esm2022/lib/components/atoms/button/button.component.mjs +0 -34
- package/esm2022/lib/components/atoms/input/input.component.mjs +0 -57
- package/esm2022/lib/components/molecules/content-design/content-design.component.mjs +0 -32
- package/esm2022/lib/shared/enums/enum.mjs +0 -69
- package/esm2022/lib/shared/interfaces/interface.mjs +0 -2
- package/esm2022/public-api.mjs +0 -10
- package/fesm2022/angular-dumb-lib.mjs +0 -243
- package/fesm2022/angular-dumb-lib.mjs.map +0 -1
- package/index.d.ts +0 -5
- package/lib/angular-dumb-lib.component.d.ts +0 -5
- package/lib/angular-dumb-lib.module.d.ts +0 -9
- package/lib/angular-dumb-lib.service.d.ts +0 -6
- package/lib/components/atoms/button/button.component.d.ts +0 -12
- package/lib/components/atoms/input/input.component.d.ts +0 -19
- package/lib/components/molecules/content-design/content-design.component.d.ts +0 -12
- package/lib/shared/enums/enum.d.ts +0 -59
- package/lib/shared/interfaces/interface.d.ts +0 -58
package/ng-package.json
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "angular-dumb-lib",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"@angular/common": "^16.0.0",
|
|
6
6
|
"@angular/core": "^16.0.0"
|
|
@@ -8,18 +8,5 @@
|
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"tslib": "^2.3.0"
|
|
10
10
|
},
|
|
11
|
-
"sideEffects": false
|
|
12
|
-
|
|
13
|
-
"typings": "index.d.ts",
|
|
14
|
-
"exports": {
|
|
15
|
-
"./package.json": {
|
|
16
|
-
"default": "./package.json"
|
|
17
|
-
},
|
|
18
|
-
".": {
|
|
19
|
-
"types": "./index.d.ts",
|
|
20
|
-
"esm2022": "./esm2022/angular-dumb-lib.mjs",
|
|
21
|
-
"esm": "./esm2022/angular-dumb-lib.mjs",
|
|
22
|
-
"default": "./fesm2022/angular-dumb-lib.mjs"
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
11
|
+
"sideEffects": false
|
|
12
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { AngularDumbLibComponent } from './angular-dumb-lib.component';
|
|
4
|
+
|
|
5
|
+
describe('AngularDumbLibComponent', () => {
|
|
6
|
+
let component: AngularDumbLibComponent;
|
|
7
|
+
let fixture: ComponentFixture<AngularDumbLibComponent>;
|
|
8
|
+
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
TestBed.configureTestingModule({
|
|
11
|
+
declarations: [AngularDumbLibComponent]
|
|
12
|
+
});
|
|
13
|
+
fixture = TestBed.createComponent(AngularDumbLibComponent);
|
|
14
|
+
component = fixture.componentInstance;
|
|
15
|
+
fixture.detectChanges();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('should create', () => {
|
|
19
|
+
expect(component).toBeTruthy();
|
|
20
|
+
});
|
|
21
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { NgModule } from '@angular/core';
|
|
2
|
+
import { AngularDumbLibComponent } from './angular-dumb-lib.component';
|
|
3
|
+
import { CommonModule } from '@angular/common';
|
|
4
|
+
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
5
|
+
|
|
6
|
+
@NgModule({
|
|
7
|
+
declarations: [
|
|
8
|
+
AngularDumbLibComponent,
|
|
9
|
+
],
|
|
10
|
+
imports: [
|
|
11
|
+
CommonModule,
|
|
12
|
+
FormsModule,
|
|
13
|
+
ReactiveFormsModule,
|
|
14
|
+
],
|
|
15
|
+
exports: [
|
|
16
|
+
AngularDumbLibComponent,
|
|
17
|
+
]
|
|
18
|
+
})
|
|
19
|
+
export class AngularDumbLibModule { }
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { AngularDumbLibService } from './angular-dumb-lib.service';
|
|
4
|
+
|
|
5
|
+
describe('AngularDumbLibService', () => {
|
|
6
|
+
let service: AngularDumbLibService;
|
|
7
|
+
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
TestBed.configureTestingModule({});
|
|
10
|
+
service = TestBed.inject(AngularDumbLibService);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it('should be created', () => {
|
|
14
|
+
expect(service).toBeTruthy();
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<button
|
|
2
|
+
type="{{config.type}}"
|
|
3
|
+
class="btn btn-primary"
|
|
4
|
+
[disabled]="config.isDisabled"
|
|
5
|
+
[ngClass]="{'active': config.isActive,
|
|
6
|
+
'normal': config.designType === 'normal',
|
|
7
|
+
'contrast': config.designType === 'contrast'}"
|
|
8
|
+
(click)="onButtonClick()">
|
|
9
|
+
<div class="button-content">
|
|
10
|
+
<ng-container *ngIf="config.iconValue">
|
|
11
|
+
<i class="material-icons" data-toggle="tooltip" title="Delete">{{config.iconValue}}</i>
|
|
12
|
+
</ng-container>
|
|
13
|
+
<span>{{ config.label }}</span>
|
|
14
|
+
</div>
|
|
15
|
+
</button>
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// Normal Button Variables
|
|
2
|
+
$normal-bg-color: #007BFF; // Primary blue for normal button background
|
|
3
|
+
$normal-text-color: #FFFFFF; // White text for normal button
|
|
4
|
+
$normal-border-color: #007BFF; // Same as background for border
|
|
5
|
+
$normal-hover-bg-color: #0056D2; // Slightly darker blue for hover state
|
|
6
|
+
$normal-hover-text-color: #FFFFFF; // Keeping white text for hover state
|
|
7
|
+
|
|
8
|
+
// Contrast Button Variables
|
|
9
|
+
$contrast-bg-color: #F9F9F9; // Off-white for contrast button background
|
|
10
|
+
$contrast-text-color: #007BFF; // Dark gray for contrast button text
|
|
11
|
+
$contrast-border-color: #4A90E2; // Dark blue for contrast button border
|
|
12
|
+
$contrast-hover-bg-color: #E6F0FA; // Light blue-gray for hover background
|
|
13
|
+
$contrast-hover-text-color: #1A1A1A; // Dark gray for hover text color
|
|
14
|
+
|
|
15
|
+
$disabled-bg-color: #cccccc;
|
|
16
|
+
$disabled-text-color: #666666;
|
|
17
|
+
|
|
18
|
+
$active-bg-color: #003d99;
|
|
19
|
+
|
|
20
|
+
// Base Button Styles
|
|
21
|
+
button.btn.btn-primary {
|
|
22
|
+
padding: 0.5rem 1rem;
|
|
23
|
+
border: none;
|
|
24
|
+
border-radius: 0.25rem;
|
|
25
|
+
cursor: pointer;
|
|
26
|
+
height: 3rem;
|
|
27
|
+
|
|
28
|
+
// Button Content Alignment
|
|
29
|
+
.button-content {
|
|
30
|
+
display: flex;
|
|
31
|
+
flex-direction: row;
|
|
32
|
+
justify-content: center;
|
|
33
|
+
align-items: center;
|
|
34
|
+
height: 100%;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Disabled State (Shared between normal and contrast)
|
|
38
|
+
&:disabled {
|
|
39
|
+
background-color: $disabled-bg-color !important;
|
|
40
|
+
color: $disabled-text-color !important;
|
|
41
|
+
cursor: not-allowed !important;
|
|
42
|
+
border-color: $disabled-text-color !important; // You can remove this if not needed for normal design
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Normal Design
|
|
46
|
+
&.normal {
|
|
47
|
+
background-color: $normal-bg-color;
|
|
48
|
+
color: $normal-text-color;
|
|
49
|
+
|
|
50
|
+
&:hover:not(:disabled) {
|
|
51
|
+
background-color: $normal-hover-bg-color;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Contrast Design
|
|
56
|
+
&.contrast {
|
|
57
|
+
color: $contrast-text-color;
|
|
58
|
+
border: 1px solid $contrast-border-color;
|
|
59
|
+
|
|
60
|
+
&:hover:not(:disabled) {
|
|
61
|
+
background-color: $contrast-hover-bg-color;
|
|
62
|
+
color: $contrast-hover-text-color;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Active State (Applies to both designs)
|
|
67
|
+
&.active {
|
|
68
|
+
background-color: $active-bg-color;
|
|
69
|
+
color: $normal-text-color;
|
|
70
|
+
|
|
71
|
+
&:hover:not(:disabled) {
|
|
72
|
+
background-color: $normal-hover-bg-color;
|
|
73
|
+
color: $normal-text-color;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
|
2
|
+
import { ButtonType, DesignType } from '../../../shared/enums/enum';
|
|
3
|
+
import { IButtonConfig } from '../../../shared/interfaces/interface';
|
|
4
|
+
import { CommonModule } from '@angular/common';
|
|
5
|
+
|
|
6
|
+
@Component({
|
|
7
|
+
selector: 'app-button',
|
|
8
|
+
standalone: true,
|
|
9
|
+
templateUrl: './button.component.html',
|
|
10
|
+
styleUrls: ['./button.component.scss'],
|
|
11
|
+
imports: [CommonModule]
|
|
12
|
+
})
|
|
13
|
+
export class ButtonComponent implements OnInit {
|
|
14
|
+
@Input() config!: IButtonConfig;
|
|
15
|
+
|
|
16
|
+
@Output() clickEvent = new EventEmitter<void>();
|
|
17
|
+
|
|
18
|
+
constructor() { }
|
|
19
|
+
|
|
20
|
+
ngOnInit() {
|
|
21
|
+
this.config = {
|
|
22
|
+
isDisabled: false,
|
|
23
|
+
isActive: false,
|
|
24
|
+
designType: DesignType.normal,
|
|
25
|
+
type: ButtonType.submit,
|
|
26
|
+
...this.config,
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
onButtonClick() {
|
|
31
|
+
this.clickEvent.emit();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<div class="datetime-picker-container">
|
|
2
|
+
<label for="date">Datetime:</label>
|
|
3
|
+
<div class="inputs-container">
|
|
4
|
+
<input id="date" type="date" [(ngModel)]="selectedDate" (ngModelChange)="onDateChange($event)" (blur)="onTouched()">
|
|
5
|
+
<input id="time" type="time" [(ngModel)]="selectedTime" (ngModelChange)="onTimeChange($event)" (blur)="onTouched()">
|
|
6
|
+
</div>
|
|
7
|
+
</div>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
.datetime-picker-container {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
margin-bottom: 1rem;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.datetime-picker-container label {
|
|
8
|
+
margin-bottom: 0.5rem;
|
|
9
|
+
font-weight: bold;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.inputs-container {
|
|
13
|
+
display: flex;
|
|
14
|
+
gap: 1rem;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.inputs-container input[type="date"],
|
|
18
|
+
.inputs-container input[type="time"] {
|
|
19
|
+
padding: 0.5rem;
|
|
20
|
+
font-size: 1rem;
|
|
21
|
+
border: 1px solid #ccc;
|
|
22
|
+
border-radius: 4px;
|
|
23
|
+
width: 150px;
|
|
24
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Component, forwardRef } from '@angular/core';
|
|
2
|
+
import { ControlValueAccessor, FormsModule, NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
3
|
+
|
|
4
|
+
@Component({
|
|
5
|
+
selector: 'app-datetime-picker',
|
|
6
|
+
standalone: true,
|
|
7
|
+
templateUrl: './datetime-picker.component.html',
|
|
8
|
+
styleUrls: ['./datetime-picker.component.scss'],
|
|
9
|
+
providers: [{
|
|
10
|
+
provide: NG_VALUE_ACCESSOR,
|
|
11
|
+
useExisting: forwardRef(() => DatetimePickerComponent),
|
|
12
|
+
multi: true
|
|
13
|
+
}],
|
|
14
|
+
imports: [FormsModule]
|
|
15
|
+
})
|
|
16
|
+
export class DatetimePickerComponent implements ControlValueAccessor {
|
|
17
|
+
selectedDate: string | null = null;
|
|
18
|
+
selectedTime: string | null = null;
|
|
19
|
+
|
|
20
|
+
public onChange: any = () => {};
|
|
21
|
+
public onTouched: any = () => {};
|
|
22
|
+
|
|
23
|
+
writeValue(value: any): void {
|
|
24
|
+
if (value) {
|
|
25
|
+
const date = new Date(value);
|
|
26
|
+
this.selectedDate = date.toISOString().split('T')[0]; // Extract the date part (YYYY-MM-DD)
|
|
27
|
+
this.selectedTime = date.toTimeString().split(' ')[0]; // Extract the time part (HH:mm:ss)
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
registerOnChange(fn: any): void {
|
|
32
|
+
this.onChange = fn;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
registerOnTouched(fn: any): void {
|
|
36
|
+
this.onTouched = fn;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
setDisabledState?(isDisabled: boolean): void {
|
|
40
|
+
// Handle disabled state
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
onDateChange(event: any) {
|
|
44
|
+
this.selectedDate = event.target.value;
|
|
45
|
+
this.emitChange();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
onTimeChange(event: any) {
|
|
49
|
+
this.selectedTime = event.target.value;
|
|
50
|
+
this.emitChange();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
private emitChange() {
|
|
54
|
+
if (this.selectedDate && this.selectedTime) {
|
|
55
|
+
const dateTime = `${this.selectedDate}T${this.selectedTime}`;
|
|
56
|
+
this.onChange(new Date(dateTime));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<div class="file-selector">
|
|
2
|
+
<label *ngIf="label">{{ label }}</label>
|
|
3
|
+
<input
|
|
4
|
+
id="fileInput"
|
|
5
|
+
type="file"
|
|
6
|
+
(change)="onFileSelected($event)"
|
|
7
|
+
accept="image/*"
|
|
8
|
+
class="hidden-file-input">
|
|
9
|
+
<div class="file-selection">
|
|
10
|
+
<!-- Custom button to trigger file input -->
|
|
11
|
+
<app-button [config]="config"
|
|
12
|
+
class="custom-file-button"
|
|
13
|
+
(clickEvent)="triggerFileInput()">
|
|
14
|
+
Select Image
|
|
15
|
+
</app-button>
|
|
16
|
+
<div *ngIf="fileName" class="file-name">
|
|
17
|
+
{{ fileName }}
|
|
18
|
+
</div>
|
|
19
|
+
</div>
|
|
20
|
+
|
|
21
|
+
<div *ngIf="imageUrl">
|
|
22
|
+
<img [src]="imageUrl" alt="Selected Image" class="preview-image"/>
|
|
23
|
+
</div>
|
|
24
|
+
</div>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
.file-selector {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
align-items: flex-start;
|
|
5
|
+
|
|
6
|
+
label {
|
|
7
|
+
font-size: 14px;
|
|
8
|
+
color: #666;
|
|
9
|
+
margin-bottom: 8px;
|
|
10
|
+
font-weight: bold;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
input[type="file"] {
|
|
14
|
+
margin-bottom: 16px;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.preview-image {
|
|
18
|
+
max-width: 150px; // Adjust the image preview size as needed
|
|
19
|
+
max-height: 150px;
|
|
20
|
+
border: 1px solid #ccc;
|
|
21
|
+
margin-top: 8px;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.hidden-file-input {
|
|
25
|
+
opacity: 0;
|
|
26
|
+
position: absolute;
|
|
27
|
+
z-index: -1; /* Keeps it off the screen, but functional */
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.file-selection {
|
|
31
|
+
display: flex;
|
|
32
|
+
align-items: center;
|
|
33
|
+
gap: 10px;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { CommonModule } from '@angular/common';
|
|
2
|
+
import { Component, Input, OnInit, forwardRef } from '@angular/core';
|
|
3
|
+
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
4
|
+
import { ButtonComponent } from 'angular-dumb-lib';
|
|
5
|
+
import { IButtonConfig } from 'dist/angular-dumb-lib/lib/shared/interfaces/interface';
|
|
6
|
+
import { ButtonType } from '../../../shared/enums/enum';
|
|
7
|
+
|
|
8
|
+
@Component({
|
|
9
|
+
selector: 'app-file-selection',
|
|
10
|
+
standalone: true,
|
|
11
|
+
templateUrl: './file-selection.component.html',
|
|
12
|
+
styleUrls: ['./file-selection.component.scss'],
|
|
13
|
+
providers: [{
|
|
14
|
+
provide: NG_VALUE_ACCESSOR,
|
|
15
|
+
useExisting: forwardRef(() => FileSelectionComponent),
|
|
16
|
+
multi: true
|
|
17
|
+
}],
|
|
18
|
+
imports: [CommonModule, ButtonComponent]
|
|
19
|
+
})
|
|
20
|
+
export class FileSelectionComponent implements OnInit, ControlValueAccessor {
|
|
21
|
+
@Input() label!: string; // Label for the file selector
|
|
22
|
+
@Input() chooseFileLabel!: string;
|
|
23
|
+
@Input() imageUrl: string | ArrayBuffer | null = null; // Allow imageUrl to be passed externally
|
|
24
|
+
@Input() fileName: string | null = null; // Allow fileName to be passed externally
|
|
25
|
+
|
|
26
|
+
config!: IButtonConfig;
|
|
27
|
+
|
|
28
|
+
onChange: any = () => {};
|
|
29
|
+
onTouched: any = () => {};
|
|
30
|
+
private _value: any = undefined;
|
|
31
|
+
|
|
32
|
+
get value() {
|
|
33
|
+
return this._value;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
set value(value: any) {
|
|
37
|
+
this._value = value;
|
|
38
|
+
this.onChange(this._value);
|
|
39
|
+
this.onTouched();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
ngOnInit(): void {
|
|
43
|
+
this.config = {
|
|
44
|
+
type: ButtonType.button,
|
|
45
|
+
label: this.chooseFileLabel
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
onFileSelected(event: Event) {
|
|
50
|
+
const input = event.target as HTMLInputElement;
|
|
51
|
+
|
|
52
|
+
if (input.files && input.files.length > 0) {
|
|
53
|
+
const file = input.files[0];
|
|
54
|
+
|
|
55
|
+
// Store the file name to display it in the UI
|
|
56
|
+
this.fileName = file.name;
|
|
57
|
+
this.value = file;
|
|
58
|
+
|
|
59
|
+
// Generate image preview URL if it's an image
|
|
60
|
+
const reader = new FileReader();
|
|
61
|
+
reader.onload = (e: any) => {
|
|
62
|
+
this.imageUrl = e.target.result; // Set image URL for preview
|
|
63
|
+
};
|
|
64
|
+
reader.readAsDataURL(file);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
triggerFileInput() {
|
|
69
|
+
const fileInput = document.getElementById('fileInput') as HTMLInputElement;
|
|
70
|
+
fileInput.click(); // Programmatically click the hidden file input
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
writeValue(value: any): void {
|
|
74
|
+
this._value = value;
|
|
75
|
+
}
|
|
76
|
+
registerOnChange(fn: any): void {
|
|
77
|
+
this.onChange = fn;
|
|
78
|
+
}
|
|
79
|
+
registerOnTouched(fn: any): void {
|
|
80
|
+
this.onTouched = fn;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
setDisabledState?(isDisabled: boolean): void {
|
|
84
|
+
// Implement if you need to handle disabled state
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<div class="input-item" [ngClass]="config.direction">
|
|
2
|
+
<label *ngIf="config.label">
|
|
3
|
+
{{ config.label }}
|
|
4
|
+
<span *ngIf="config.required" class="required-indicator">*</span>
|
|
5
|
+
</label>
|
|
6
|
+
|
|
7
|
+
<div class="input-container">
|
|
8
|
+
<input *ngIf="config.type !== 'textarea' && config.type !== 'richText' && config.type !== 'image'"
|
|
9
|
+
[type]="config.type"
|
|
10
|
+
[name]="config.name"
|
|
11
|
+
[required]="config.required"
|
|
12
|
+
[(ngModel)]="value"
|
|
13
|
+
[placeholder] = "config.placeholder"
|
|
14
|
+
[ngClass]="{'input-error': !config.isValid}">
|
|
15
|
+
<textarea *ngIf="config.type === 'textarea'"
|
|
16
|
+
[name]="config.name"
|
|
17
|
+
[required]="config.required"
|
|
18
|
+
[(ngModel)]="value"
|
|
19
|
+
[placeholder] = "config.placeholder"
|
|
20
|
+
[ngClass]="{'input-error': !config.isValid}">
|
|
21
|
+
</textarea>
|
|
22
|
+
<i *ngIf="!config.isValid" class="material-icons warning-icon">error</i>
|
|
23
|
+
</div>
|
|
24
|
+
|
|
25
|
+
<div *ngIf="config.type === 'image'">
|
|
26
|
+
<img *ngIf="value" [src]="value" alt="Selected Image" class="preview-image"/>
|
|
27
|
+
</div>
|
|
28
|
+
</div>
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
.input-item {
|
|
2
|
+
display: flex;
|
|
3
|
+
width: 100%;
|
|
4
|
+
gap: 10px;
|
|
5
|
+
|
|
6
|
+
.input-container {
|
|
7
|
+
display: flex;
|
|
8
|
+
width: inherit; // Maintain the width of the input container
|
|
9
|
+
.input-error {
|
|
10
|
+
border-color: red;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
label {
|
|
15
|
+
display: flex;
|
|
16
|
+
align-items: center;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
&.horizontal {
|
|
20
|
+
flex-direction: row;
|
|
21
|
+
|
|
22
|
+
label {
|
|
23
|
+
width: 30%; // Adjust label width for horizontal layout
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
&.vertical {
|
|
28
|
+
flex-direction: column;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.preview-image {
|
|
32
|
+
max-width: 150px; // Adjust the image preview size as needed
|
|
33
|
+
max-height: 150px;
|
|
34
|
+
border: 1px solid #ccc;
|
|
35
|
+
margin-top: 8px;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.required-indicator, .warning-icon {
|
|
39
|
+
display: flex;
|
|
40
|
+
align-items: center;
|
|
41
|
+
color: red; // Change this color as needed
|
|
42
|
+
margin-left: 4px; // Space between label and asterisk
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.warning-icon {
|
|
46
|
+
font-weight: bold;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
input,
|
|
50
|
+
textarea {
|
|
51
|
+
padding: 0.5rem;
|
|
52
|
+
border: 1px solid #ccc;
|
|
53
|
+
border-radius: 0.25rem;
|
|
54
|
+
width: -webkit-fill-available; // Ensure input takes full available width
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
quill-editor {
|
|
58
|
+
width: 100%;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Component, Input, OnInit, forwardRef } from '@angular/core';
|
|
2
|
+
import { ControlValueAccessor, FormsModule, NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
3
|
+
import { InputDirection, InputType } from '../../../shared/enums/enum';
|
|
4
|
+
import { IInputConfig } from '../../../shared/interfaces/interface';
|
|
5
|
+
import { CommonModule } from '@angular/common';
|
|
6
|
+
|
|
7
|
+
@Component({
|
|
8
|
+
selector: 'app-input',
|
|
9
|
+
standalone: true,
|
|
10
|
+
templateUrl: './input.component.html',
|
|
11
|
+
styleUrls: ['./input.component.scss'],
|
|
12
|
+
providers: [{
|
|
13
|
+
provide: NG_VALUE_ACCESSOR,
|
|
14
|
+
useExisting: forwardRef(() => InputComponent),
|
|
15
|
+
multi: true
|
|
16
|
+
}],
|
|
17
|
+
imports: [CommonModule, FormsModule]
|
|
18
|
+
})
|
|
19
|
+
export class InputComponent implements OnInit, ControlValueAccessor {
|
|
20
|
+
@Input() config!: IInputConfig;
|
|
21
|
+
|
|
22
|
+
private _value: any = '';
|
|
23
|
+
|
|
24
|
+
get value() {
|
|
25
|
+
return this._value;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
set value(value: any) {
|
|
29
|
+
this._value = value;
|
|
30
|
+
this.onChange(this._value);
|
|
31
|
+
this.onTouched();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
onChange: any = () => {};
|
|
35
|
+
onTouched: any = () => {};
|
|
36
|
+
|
|
37
|
+
constructor() { }
|
|
38
|
+
|
|
39
|
+
writeValue(value: any): void {
|
|
40
|
+
this._value = value;
|
|
41
|
+
}
|
|
42
|
+
registerOnChange(fn: any): void {
|
|
43
|
+
this.onChange = fn;
|
|
44
|
+
}
|
|
45
|
+
registerOnTouched(fn: any): void {
|
|
46
|
+
this.onTouched = fn
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
ngOnInit() {
|
|
50
|
+
this.config = {
|
|
51
|
+
type: InputType.text,
|
|
52
|
+
direction: InputDirection.vertical,
|
|
53
|
+
isValid: true,
|
|
54
|
+
...this.config,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
width: 100%;
|
|
3
|
+
height: 100%;
|
|
4
|
+
display: table;
|
|
5
|
+
text-align: center;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.loading-content {
|
|
9
|
+
display: table-cell;
|
|
10
|
+
vertical-align: middle;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.xbig img {
|
|
14
|
+
width: 256px;
|
|
15
|
+
height: 256px;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.big img {
|
|
19
|
+
width: 128px;
|
|
20
|
+
height: 128px;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.medium img {
|
|
24
|
+
width: 64px;
|
|
25
|
+
height: 64px;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.small img {
|
|
29
|
+
width: 32px;
|
|
30
|
+
height: 32px;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.xsmall img {
|
|
34
|
+
width: 16px;
|
|
35
|
+
height: 16px;
|
|
36
|
+
}
|