@codex-ts/core-lib 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 (76) hide show
  1. package/dist/core-lib/fesm2022/core-lib.mjs +2349 -0
  2. package/dist/core-lib/fesm2022/core-lib.mjs.map +1 -0
  3. package/dist/core-lib/index.d.ts +29 -0
  4. package/dist/core-lib/lib/components/base-form.component.d.ts +62 -0
  5. package/dist/core-lib/lib/components/base-list-page.component.d.ts +132 -0
  6. package/dist/core-lib/lib/components/base-page.component.d.ts +25 -0
  7. package/dist/core-lib/lib/components/base-tabbed-form.component.d.ts +54 -0
  8. package/dist/core-lib/lib/components/formly/core-formly.module.d.ts +7 -0
  9. package/dist/core-lib/lib/components/formly/form-field.wrapper.d.ts +21 -0
  10. package/dist/core-lib/lib/components/formly/formly.constants.d.ts +13 -0
  11. package/dist/core-lib/lib/components/formly/types/checkbox.type.d.ts +12 -0
  12. package/dist/core-lib/lib/components/formly/types/date.type.d.ts +20 -0
  13. package/dist/core-lib/lib/components/formly/types/multiselect.type.d.ts +26 -0
  14. package/dist/core-lib/lib/components/formly/types/numeric-input.type.d.ts +17 -0
  15. package/dist/core-lib/lib/components/formly/types/radio.type.d.ts +13 -0
  16. package/dist/core-lib/lib/components/formly/types/select.type.d.ts +25 -0
  17. package/dist/core-lib/lib/components/formly/types/text-input.type.d.ts +12 -0
  18. package/dist/core-lib/lib/components/formly/types/textarea.type.d.ts +14 -0
  19. package/dist/core-lib/lib/constants/app.constants.d.ts +13 -0
  20. package/dist/core-lib/lib/constants/app.messages.d.ts +36 -0
  21. package/dist/core-lib/lib/enums/component-context.enum.d.ts +6 -0
  22. package/dist/core-lib/lib/enums/tabbed-form-type.enum.d.ts +4 -0
  23. package/dist/core-lib/lib/models/pagination/filter-criteria.interface.d.ts +9 -0
  24. package/dist/core-lib/lib/models/pagination/page-request.interface.d.ts +10 -0
  25. package/dist/core-lib/lib/models/pagination/page.interface.d.ts +9 -0
  26. package/dist/core-lib/lib/models/pagination/sort-criteria.interface.d.ts +4 -0
  27. package/dist/core-lib/lib/pipes/indian-date.pipe.d.ts +12 -0
  28. package/dist/core-lib/lib/services/base-crud.service.d.ts +36 -0
  29. package/dist/core-lib/lib/services/entity-registry.service.d.ts +26 -0
  30. package/dist/core-lib/lib/services/entity.service.d.ts +9 -0
  31. package/dist/core-lib/lib/services/enum-registry.service.d.ts +41 -0
  32. package/dist/core-lib/lib/services/formly-config.service.d.ts +11 -0
  33. package/dist/core-lib/lib/services/http-utility.service.d.ts +130 -0
  34. package/dist/core-lib/lib/services/notification.service.d.ts +13 -0
  35. package/dist/core-lib/lib/services/reference-data-provider.service.d.ts +8 -0
  36. package/dist/core-lib/lib/services/utils.service.d.ts +72 -0
  37. package/ng-package.json +7 -0
  38. package/package.json +63 -0
  39. package/src/index.ts +44 -0
  40. package/src/lib/components/base-form.component.ts +328 -0
  41. package/src/lib/components/base-list-page.component.ts +327 -0
  42. package/src/lib/components/base-page.component.ts +33 -0
  43. package/src/lib/components/base-tabbed-form.component.ts +345 -0
  44. package/src/lib/components/formly/core-formly.module.ts +34 -0
  45. package/src/lib/components/formly/field.interface.ts +15 -0
  46. package/src/lib/components/formly/form-field.wrapper.ts +94 -0
  47. package/src/lib/components/formly/formly.constants.ts +14 -0
  48. package/src/lib/components/formly/primeng-formly.module.ts +77 -0
  49. package/src/lib/components/formly/types/checkbox.type.ts +43 -0
  50. package/src/lib/components/formly/types/date.type.ts +88 -0
  51. package/src/lib/components/formly/types/multiselect.type.ts +61 -0
  52. package/src/lib/components/formly/types/numeric-input.type.ts +45 -0
  53. package/src/lib/components/formly/types/radio.type.ts +47 -0
  54. package/src/lib/components/formly/types/select.type.ts +54 -0
  55. package/src/lib/components/formly/types/text-input.type.ts +33 -0
  56. package/src/lib/components/formly/types/textarea.type.ts +37 -0
  57. package/src/lib/constants/app.constants.ts +15 -0
  58. package/src/lib/constants/app.messages.ts +36 -0
  59. package/src/lib/enums/component-context.enum.ts +6 -0
  60. package/src/lib/enums/tabbed-form-type.enum.ts +4 -0
  61. package/src/lib/models/pagination/filter-criteria.interface.ts +19 -0
  62. package/src/lib/models/pagination/page-request.interface.ts +13 -0
  63. package/src/lib/models/pagination/page.interface.ts +9 -0
  64. package/src/lib/models/pagination/sort-criteria.interface.ts +4 -0
  65. package/src/lib/pipes/indian-date.pipe.ts +46 -0
  66. package/src/lib/services/base-crud.service.ts +81 -0
  67. package/src/lib/services/entity-registry.service.ts +51 -0
  68. package/src/lib/services/entity.service.ts +10 -0
  69. package/src/lib/services/enum-registry.service.ts +66 -0
  70. package/src/lib/services/formly-config.service.ts +50 -0
  71. package/src/lib/services/http-utility.service.example.ts +253 -0
  72. package/src/lib/services/http-utility.service.md +175 -0
  73. package/src/lib/services/http-utility.service.ts +389 -0
  74. package/src/lib/services/notification.service.ts +35 -0
  75. package/src/lib/services/reference-data-provider.service.ts +28 -0
  76. package/src/lib/services/utils.service.ts +154 -0
@@ -0,0 +1,34 @@
1
+ import { NgModule } from '@angular/core';
2
+ import { FormlyModule } from '@ngx-formly/core';
3
+ import { TextInputType } from './types/text-input.type';
4
+ import { SelectType } from './types/select.type';
5
+ import { RadioType } from './types/radio.type';
6
+ import { NumericInputType } from './types/numeric-input.type';
7
+ import { MultiselectType } from './types/multiselect.type';
8
+ import { DateType } from './types/date.type';
9
+ import { CheckboxType } from './types/checkbox.type';
10
+ import { TextareaType } from './types/textarea.type'; // Added import
11
+ import { FormFieldWrapper } from './form-field.wrapper';
12
+ import { FORMLY_TYPES, FORMLY_WRAPPERS } from './formly.constants'; // Added import
13
+
14
+ @NgModule({
15
+ imports: [
16
+ FormlyModule.forRoot({
17
+ types: [
18
+ { name: FORMLY_TYPES.TEXT, component: TextInputType, wrappers: [FORMLY_WRAPPERS.FORM_FIELD] },
19
+ { name: FORMLY_TYPES.NUMBER, component: NumericInputType, wrappers: [FORMLY_WRAPPERS.FORM_FIELD] },
20
+ { name: FORMLY_TYPES.DATE, component: DateType, wrappers: [FORMLY_WRAPPERS.FORM_FIELD] },
21
+ { name: FORMLY_TYPES.CHECKBOX, component: CheckboxType, wrappers: [FORMLY_WRAPPERS.FORM_FIELD] },
22
+ { name: FORMLY_TYPES.RADIO, component: RadioType, wrappers: [FORMLY_WRAPPERS.FORM_FIELD] },
23
+ { name: FORMLY_TYPES.SELECT, component: SelectType, wrappers: [FORMLY_WRAPPERS.FORM_FIELD] },
24
+ { name: FORMLY_TYPES.MULTISELECT, component: MultiselectType, wrappers: [FORMLY_WRAPPERS.FORM_FIELD] },
25
+ { name: FORMLY_TYPES.TEXTAREA, component: TextareaType, wrappers: [FORMLY_WRAPPERS.FORM_FIELD] }, // Added textarea type
26
+ ],
27
+ wrappers: [
28
+ { name: FORMLY_WRAPPERS.FORM_FIELD, component: FormFieldWrapper }
29
+ ]
30
+ })
31
+ ],
32
+ exports: [FormlyModule]
33
+ })
34
+ export class CoreFormlyModule { }
@@ -0,0 +1,15 @@
1
+ export interface FormlyFieldProps {
2
+ label?: string; // Field label text
3
+ placeholder?: string; // Placeholder text for input fields
4
+ required?: boolean; // Whether field is required
5
+ disabled?: boolean; // Disabled state
6
+ description?: string; // Help/description text
7
+ validation?: {
8
+ messages?: { [key: string]: string };
9
+ rules?: { [key: string]: any };
10
+ };
11
+ attributes?: { [key: string]: any };
12
+ appearance?: 'outlined' | 'filled';
13
+ size?: 'small' | 'normal' | 'large';
14
+ tooltip?: string;
15
+ }
@@ -0,0 +1,94 @@
1
+ import { Component } from '@angular/core';
2
+ import { CommonModule } from '@angular/common';
3
+ import { FieldWrapper, FormlyFieldConfig } from '@ngx-formly/core';
4
+ import { TooltipModule } from 'primeng/tooltip';
5
+
6
+ interface FormlyValidationMessage {
7
+ [key: string]: string;
8
+ }
9
+
10
+ interface FormlyFieldProps {
11
+ label?: string;
12
+ required?: boolean;
13
+ tooltip?: string;
14
+ description?: string;
15
+ validation?: {
16
+ messages?: FormlyValidationMessage;
17
+ };
18
+ }
19
+
20
+ @Component({
21
+ selector: 'formly-wrapper-form-field',
22
+ standalone: true,
23
+ imports: [CommonModule, TooltipModule],
24
+ template: `
25
+ <div class="field mb-4">
26
+ <label *ngIf="props.label" [for]="id" class="font-medium">
27
+ {{ props.label }}
28
+ <span class="required-star" *ngIf="props.required">*</span>
29
+ <i *ngIf="props.tooltip"
30
+ class="pi pi-info-circle ml-2"
31
+ [pTooltip]="props.tooltip">
32
+ </i>
33
+ </label>
34
+
35
+ <div [class.p-input-error]="showError">
36
+ <ng-container #fieldComponent></ng-container>
37
+ </div>
38
+
39
+ <small *ngIf="props.description" class="block mt-1">
40
+ {{ props.description }}
41
+ </small>
42
+
43
+ <small *ngIf="showError" class="p-error block">
44
+ <i class="pi pi-exclamation-circle mr-2"></i>
45
+ {{ errorMessage }}
46
+ </small>
47
+ </div>
48
+ `,
49
+ styles: [`
50
+ :host ::ng-deep {
51
+ .required-star {
52
+ color: var(--red-500);
53
+ margin-left: 0.25rem;
54
+ }
55
+
56
+ .p-input-error :where(input, .p-inputtext) {
57
+ border-color: var(--red-500);
58
+ }
59
+
60
+ .p-input-error :where(input:enabled:focus, .p-inputtext:enabled:focus) {
61
+ border-color: var(--red-500);
62
+ box-shadow: 0 0 0 1px var(--red-500);
63
+ }
64
+
65
+ .p-error {
66
+ color: var(--red-500);
67
+ margin-top: 0.5rem;
68
+ }
69
+
70
+ small {
71
+ color: var(--text-color-secondary);
72
+ }
73
+ }
74
+ `]
75
+ })
76
+ export class FormFieldWrapper extends FieldWrapper<FormlyFieldConfig<FormlyFieldProps>> {
77
+ get errorMessage(): string {
78
+ if (!this.field.formControl?.errors) {
79
+ return '';
80
+ }
81
+
82
+ const firstErrorKey = Object.keys(this.field.formControl.errors)[0];
83
+ return this.props.validation?.messages?.[firstErrorKey] || 'This field is required';
84
+ }
85
+
86
+ override get showError(): boolean {
87
+ if (!this.field.formControl) {
88
+ return false;
89
+ }
90
+
91
+ const { touched, dirty, invalid } = this.field.formControl;
92
+ return invalid && (touched || dirty);
93
+ }
94
+ }
@@ -0,0 +1,14 @@
1
+ export const FORMLY_TYPES = {
2
+ TEXT: 'text',
3
+ NUMBER: 'number',
4
+ DATE: 'date',
5
+ CHECKBOX: 'checkbox',
6
+ RADIO: 'radio',
7
+ SELECT: 'select',
8
+ MULTISELECT: 'multiselect',
9
+ TEXTAREA: 'textarea'
10
+ };
11
+
12
+ export const FORMLY_WRAPPERS = {
13
+ FORM_FIELD: 'form-field'
14
+ };
@@ -0,0 +1,77 @@
1
+ import { NgModule } from '@angular/core';
2
+ import { ReactiveFormsModule } from '@angular/forms';
3
+ import { FormlyModule } from '@ngx-formly/core';
4
+ import { CommonModule } from '@angular/common';
5
+
6
+ import { InputTextModule } from 'primeng/inputtext';
7
+ import { DropdownModule } from 'primeng/dropdown';
8
+ import { DatePickerModule } from 'primeng/datepicker';
9
+ import { CheckboxModule } from 'primeng/checkbox';
10
+ import { RadioButtonModule } from 'primeng/radiobutton';
11
+ import { MultiSelectModule } from 'primeng/multiselect';
12
+
13
+ import { FormFieldWrapper } from './form-field.wrapper';
14
+ import { TextInputType } from './types/text-input.type';
15
+ import { NumericInputType } from './types/numeric-input.type';
16
+ import { CheckboxType } from './types/checkbox.type';
17
+ import { DateType } from './types/date.type';
18
+ import { RadioType } from './types/radio.type';
19
+ import { SelectType } from './types/select.type';
20
+ import { MultiselectType } from './types/multiselect.type';
21
+
22
+ @NgModule({
23
+ imports: [
24
+ CommonModule,
25
+ ReactiveFormsModule,
26
+ InputTextModule,
27
+ DropdownModule,
28
+ DatePickerModule,
29
+ CheckboxModule,
30
+ RadioButtonModule,
31
+ MultiSelectModule,
32
+ FormlyModule.forRoot({
33
+ wrappers: [
34
+ { name: 'form-field', component: FormFieldWrapper }
35
+ ],
36
+ types: [
37
+ {
38
+ name: 'text-input',
39
+ component: TextInputType,
40
+ wrappers: ['form-field']
41
+ },
42
+ {
43
+ name: 'numeric-input',
44
+ component: NumericInputType,
45
+ wrappers: ['form-field']
46
+ },
47
+ {
48
+ name: 'checkbox',
49
+ component: CheckboxType,
50
+ wrappers: ['form-field']
51
+ },
52
+ {
53
+ name: 'radio',
54
+ component: RadioType,
55
+ wrappers: ['form-field']
56
+ },
57
+ {
58
+ name: 'date',
59
+ component: DateType,
60
+ wrappers: ['form-field']
61
+ },
62
+ {
63
+ name: 'select',
64
+ component: SelectType,
65
+ wrappers: ['form-field']
66
+ },
67
+ {
68
+ name: 'multiselect',
69
+ component: MultiselectType,
70
+ wrappers: ['form-field']
71
+ }
72
+ ]
73
+ })
74
+ ],
75
+ exports: [FormlyModule]
76
+ })
77
+ export class PrimeNGFormlyModule { }
@@ -0,0 +1,43 @@
1
+ import { Component } from '@angular/core';
2
+ import { CommonModule } from '@angular/common';
3
+ import { ReactiveFormsModule } from '@angular/forms';
4
+ import { FieldType, FormlyModule } from '@ngx-formly/core';
5
+ import { CheckboxModule } from 'primeng/checkbox';
6
+
7
+ @Component({
8
+ selector: 'formly-field-checkbox',
9
+ standalone: true,
10
+ imports: [
11
+ CommonModule,
12
+ ReactiveFormsModule,
13
+ FormlyModule,
14
+ CheckboxModule
15
+ ],
16
+ template: `
17
+ <div class="checkbox-container">
18
+ <p-checkbox
19
+ [formControl]="$any(formControl)"
20
+ [formlyAttributes]="field"
21
+ [binary]="!props['options']"
22
+ [trueValue]="props['trueValue']"
23
+ [falseValue]="props['falseValue']">
24
+ {{props['checkboxLabel'] || ''}}
25
+ </p-checkbox>
26
+ </div>
27
+ `,
28
+ styles: [`
29
+ .checkbox-container {
30
+ display: flex;
31
+ align-items: center;
32
+ height: 40px;
33
+ }
34
+ `]
35
+ })
36
+ export class CheckboxType extends FieldType {
37
+ override defaultOptions = {
38
+ props: {
39
+ trueValue: true,
40
+ falseValue: false
41
+ }
42
+ };
43
+ }
@@ -0,0 +1,88 @@
1
+ import { Component } from '@angular/core';
2
+ import { CommonModule } from '@angular/common';
3
+ import { ReactiveFormsModule } from '@angular/forms';
4
+ import { FieldType, FormlyModule } from '@ngx-formly/core';
5
+ import { DatePickerModule } from 'primeng/datepicker';
6
+ import { formatDate } from '@angular/common';
7
+
8
+ @Component({
9
+ selector: 'formly-field-date',
10
+ standalone: true,
11
+ imports: [
12
+ CommonModule,
13
+ ReactiveFormsModule,
14
+ FormlyModule,
15
+ DatePickerModule
16
+ ],
17
+ template: `
18
+ <p-datepicker
19
+ [formControl]="$any(formControl)"
20
+ [formlyAttributes]="field"
21
+ [showIcon]="true"
22
+ [dateFormat]="props['dateFormat'] || 'dd-mm-yy'"
23
+ [showTime]="props['showTime'] || false"
24
+ [touchUI]="props['touchUI'] || false"
25
+ [placeholder]="props['placeholder'] || ''"
26
+ [minDate]="props['minDate']"
27
+ [maxDate]="props['maxDate']"
28
+ [showOnFocus]="false"
29
+ [todayButtonStyleClass]="'p-button-secondary'"
30
+ [clearButtonStyleClass]="'p-button-secondary'"
31
+ styleClass="w-full"
32
+ (onSelect)="onDateSelect($event)"
33
+ (onInput)="onDateInput($event)">
34
+ </p-datepicker>
35
+ `
36
+ })
37
+ export class DateType extends FieldType {
38
+ override defaultOptions = {
39
+ props: {
40
+ dateFormat: 'dd-mm-yy',
41
+ showTime: false,
42
+ touchUI: false,
43
+ placeholder: '',
44
+ showButtonBar: true,
45
+ }
46
+ };
47
+
48
+ onDateSelect(event: Date): void {
49
+ this.formatAndSetDate(event);
50
+ }
51
+
52
+ onDateInput(event: any): void {
53
+ const inputValue = event.target.value.trim();
54
+ if (this.isValidDateInput(inputValue, this.props['dateFormat'] || 'dd-mm-yy')) {
55
+ const parsedDate = this.parseDate(inputValue, this.props['dateFormat'] || 'dd-mm-yy');
56
+ if (parsedDate) {
57
+ this.formatAndSetDate(parsedDate);
58
+ }
59
+ } else {
60
+ this.formControl?.setErrors({ invalidDate: true });
61
+ }
62
+ }
63
+
64
+ private formatAndSetDate(date: Date): void {
65
+ if (this.formControl) {
66
+ const formattedDate = formatDate(date, 'dd-MM-yyyy', 'en-US');
67
+ this.formControl.setValue(formattedDate);
68
+ }
69
+ }
70
+
71
+ private parseDate(value: string, format: string): Date | null {
72
+ const parts = value.split(/[-/]/); // Split by common delimiters
73
+ if (parts.length === 3) {
74
+ const [day, month, year] = format === 'dd-mm-yy'
75
+ ? [parseInt(parts[0], 10), parseInt(parts[1], 10) - 1, parseInt(parts[2], 10)]
76
+ : [parseInt(parts[1], 10), parseInt(parts[0], 10) - 1, parseInt(parts[2], 10)];
77
+ return new Date(year, month, day);
78
+ }
79
+ return null;
80
+ }
81
+
82
+ private isValidDateInput(value: string, format: string): boolean {
83
+ const dateRegex = format === 'dd-mm-yy'
84
+ ? /^\d{2}-\d{2}-\d{4}$/
85
+ : /^\d{2}\/\d{2}\/\d{4}$/;
86
+ return dateRegex.test(value);
87
+ }
88
+ }
@@ -0,0 +1,61 @@
1
+ import { Component } from '@angular/core';
2
+ import { CommonModule } from '@angular/common';
3
+ import { ReactiveFormsModule } from '@angular/forms';
4
+ import { FieldType, FormlyModule } from '@ngx-formly/core';
5
+ import { MultiSelectModule } from 'primeng/multiselect';
6
+ import { Observable, isObservable, of } from 'rxjs';
7
+
8
+ interface SelectOption {
9
+ value: any;
10
+ label: string;
11
+ [key: string]: any;
12
+ }
13
+
14
+ @Component({
15
+ selector: 'formly-field-multiselect',
16
+ standalone: true,
17
+ imports: [
18
+ CommonModule,
19
+ ReactiveFormsModule,
20
+ FormlyModule,
21
+ MultiSelectModule
22
+ ],
23
+ template: `
24
+ <ng-container *ngIf="options$ | async as options">
25
+ <p-multiSelect
26
+ [formControl]="$any(formControl)"
27
+ [formlyAttributes]="field"
28
+ [options]="options"
29
+ [optionLabel]="props['optionLabel'] || 'label'"
30
+ [optionValue]="props['optionValue'] || 'value'"
31
+ [placeholder]="props['placeholder'] || 'Select'"
32
+ [filter]="props['filter'] || true"
33
+ [filterBy]="props['filterBy'] || 'label'"
34
+ [maxSelectedLabels]="props['maxSelectedLabels'] || 2"
35
+ [showToggleAll]="props['showToggleAll'] || true"
36
+ [virtualScroll]="props['virtualScroll'] || false"
37
+ [display]="props['display'] || 'chip'"
38
+ styleClass="w-full">
39
+ </p-multiSelect>
40
+ </ng-container>
41
+ `
42
+ })
43
+ export class MultiselectType extends FieldType {
44
+ get options$(): Observable<SelectOption[]> {
45
+ const options = this.props['options'];
46
+ return isObservable(options) ? options : of(options || []);
47
+ }
48
+
49
+ override defaultOptions = {
50
+ props: {
51
+ options: [] as SelectOption[],
52
+ optionLabel: 'label',
53
+ optionValue: 'value',
54
+ placeholder: 'Select',
55
+ filter: false,
56
+ maxSelectedLabels: 3,
57
+ showToggleAll: true,
58
+ virtualScroll: false
59
+ }
60
+ };
61
+ }
@@ -0,0 +1,45 @@
1
+ import { Component } from '@angular/core';
2
+ import { CommonModule } from '@angular/common';
3
+ import { ReactiveFormsModule } from '@angular/forms';
4
+ import { FieldType, FormlyModule } from '@ngx-formly/core';
5
+ import { InputNumberModule } from 'primeng/inputnumber';
6
+
7
+ @Component({
8
+ selector: 'formly-field-numeric-input',
9
+ standalone: true,
10
+ imports: [
11
+ CommonModule,
12
+ ReactiveFormsModule,
13
+ FormlyModule,
14
+ InputNumberModule
15
+ ],
16
+ template: `
17
+ <p-inputNumber
18
+ [formControl]="$any(formControl)"
19
+ [formlyAttributes]="field"
20
+ [placeholder]="props['placeholder'] || ''"
21
+ [min]="props['min'] || 0"
22
+ [max]="props['max']"
23
+ [minFractionDigits]="props['minFractionDigits'] || 0"
24
+ [maxFractionDigits]="props['maxFractionDigits'] || 0"
25
+ [prefix]="props['prefix'] || ''"
26
+ [suffix]="props['suffix'] || ''"
27
+ [useGrouping]="props['useGrouping'] ?? true"
28
+ [showButtons]="true"
29
+ class="w-full">
30
+ </p-inputNumber>
31
+ `
32
+ })
33
+ export class NumericInputType extends FieldType {
34
+ override defaultOptions = {
35
+ props: {
36
+ min: undefined,
37
+ max: undefined,
38
+ minFractionDigits: 0,
39
+ maxFractionDigits: 0,
40
+ prefix: '',
41
+ suffix: '',
42
+ useGrouping: true
43
+ }
44
+ };
45
+ }
@@ -0,0 +1,47 @@
1
+ import { Component } from '@angular/core';
2
+ import { CommonModule } from '@angular/common';
3
+ import { ReactiveFormsModule } from '@angular/forms';
4
+ import { FormlyModule, FieldType } from '@ngx-formly/core';
5
+ import { RadioButtonModule } from 'primeng/radiobutton';
6
+ import { Observable, isObservable, of } from 'rxjs';
7
+
8
+ interface RadioOption {
9
+ value: any;
10
+ label: string;
11
+ }
12
+
13
+ @Component({
14
+ selector: 'formly-field-radio',
15
+ standalone: true,
16
+ imports: [
17
+ CommonModule,
18
+ ReactiveFormsModule,
19
+ FormlyModule,
20
+ RadioButtonModule
21
+ ],
22
+ template: `
23
+ <div class="flex flex-column gap-1">
24
+ <ng-container *ngIf="options$ | async as options">
25
+ <div *ngFor="let option of options; let i = index" class="flex align-items-center gap-2">
26
+ <p-radioButton
27
+ [name]="field.name || ''"
28
+ [value]="option.value"
29
+ [formControl]="$any(formControl)"
30
+ [formlyAttributes]="field"
31
+ [size]="'small'"
32
+ [inputId]="field.key + '_' + i">
33
+ </p-radioButton>
34
+ <label [for]="field.key + '_' + i" class="p-radio-label cursor-pointer">
35
+ {{option.label}}
36
+ </label>
37
+ </div>
38
+ </ng-container>
39
+ </div>
40
+ `
41
+ })
42
+ export class RadioType extends FieldType {
43
+ get options$(): Observable<RadioOption[]> {
44
+ const options = this.props['options'];
45
+ return isObservable(options) ? options : of(options || []);
46
+ }
47
+ }
@@ -0,0 +1,54 @@
1
+ import { Component } from '@angular/core';
2
+ import { CommonModule } from '@angular/common';
3
+ import { ReactiveFormsModule } from '@angular/forms';
4
+ import { FieldType, FormlyModule } from '@ngx-formly/core';
5
+ import { SelectModule } from 'primeng/select';
6
+ import { Observable, of, isObservable } from 'rxjs';
7
+
8
+ interface SelectOption {
9
+ value: any;
10
+ label: string;
11
+ [key: string]: any; // For additional properties
12
+ }
13
+
14
+ @Component({
15
+ selector: 'formly-field-select',
16
+ standalone: true,
17
+ imports: [
18
+ CommonModule,
19
+ ReactiveFormsModule,
20
+ FormlyModule,
21
+ SelectModule
22
+ ],
23
+ template: `
24
+ <ng-container *ngIf="options$ | async as options">
25
+ <p-select
26
+ [formControl]="$any(formControl)"
27
+ [formlyAttributes]="field"
28
+ [options]="options"
29
+ [virtualScroll]="false"
30
+ [showClear]="false"
31
+ [placeholder]="props['placeholder'] || 'Select'"
32
+ styleClass="w-full">
33
+ </p-select>
34
+ </ng-container>
35
+ `
36
+ })
37
+ export class SelectType extends FieldType {
38
+ get options$(): Observable<SelectOption[]> {
39
+ const options = this.props['options'];
40
+ return isObservable(options) ? options : of(options || []);
41
+ }
42
+
43
+ override defaultOptions = {
44
+ props: {
45
+ options: [],
46
+ optionLabel: 'label',
47
+ optionValue: 'value',
48
+ placeholder: 'Select',
49
+ showClear: false,
50
+ filter: false,
51
+ virtualScroll: false
52
+ }
53
+ };
54
+ }
@@ -0,0 +1,33 @@
1
+ import { Component } from '@angular/core';
2
+ import { CommonModule } from '@angular/common';
3
+ import { ReactiveFormsModule } from '@angular/forms';
4
+ import { FieldType, FormlyModule } from '@ngx-formly/core';
5
+ import { InputTextModule } from 'primeng/inputtext';
6
+
7
+ @Component({
8
+ selector: 'formly-field-text-input',
9
+ standalone: true,
10
+ imports: [
11
+ CommonModule,
12
+ ReactiveFormsModule,
13
+ FormlyModule,
14
+ InputTextModule
15
+ ],
16
+ template: `
17
+ <input pInputText
18
+ [type]="props['type'] || 'text'"
19
+ [formControl]="$any(formControl)"
20
+ [formlyAttributes]="field"
21
+ [placeholder]="props['placeholder'] || ''"
22
+ [attr.aria-label]="props['label'] || props['placeholder'] || ''"
23
+ class="w-full"/>
24
+ `
25
+ })
26
+ export class TextInputType extends FieldType {
27
+ override defaultOptions = {
28
+ props: {
29
+ type: 'text',
30
+ placeholder: ''
31
+ }
32
+ };
33
+ }
@@ -0,0 +1,37 @@
1
+ import { Component } from '@angular/core';
2
+ import { CommonModule } from '@angular/common';
3
+ import { ReactiveFormsModule } from '@angular/forms';
4
+ import { FieldType, FormlyModule } from '@ngx-formly/core';
5
+ import { Textarea } from 'primeng/inputtextarea';
6
+
7
+ @Component({
8
+ selector: 'formly-field-textarea',
9
+ standalone: true,
10
+ imports: [
11
+ CommonModule,
12
+ ReactiveFormsModule,
13
+ FormlyModule,
14
+ Textarea
15
+ ],
16
+ template: `
17
+ <textarea pInputTextarea
18
+ [formControl]="$any(formControl)"
19
+ [formlyAttributes]="field"
20
+ [rows]="props['rows'] || 3"
21
+ [cols]="props['cols']"
22
+ [autoResize]="props['autoResize']"
23
+ [placeholder]="props['placeholder'] || ''"
24
+ class="w-full">
25
+ </textarea>
26
+ `
27
+ })
28
+ export class TextareaType extends FieldType {
29
+ override defaultOptions = {
30
+ props: {
31
+ rows: 3,
32
+ cols: undefined,
33
+ autoResize: true,
34
+ placeholder: ''
35
+ }
36
+ };
37
+ }
@@ -0,0 +1,15 @@
1
+ export class AppConstants {
2
+ static readonly FORM = {
3
+ MODE: 'mode',
4
+ UUID: 'uuid',
5
+ NEW: 'new'
6
+ } as const;
7
+
8
+ static readonly PAGE_MODE = {
9
+ CREATE: 'create',
10
+ EDIT: 'edit',
11
+ VIEW: 'view'
12
+ } as const;
13
+ }
14
+
15
+ export type PageMode = typeof AppConstants.PAGE_MODE[keyof typeof AppConstants.PAGE_MODE];