@ruc-lib/metaform 2.0.0 → 2.0.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 (71) hide show
  1. package/.eslintrc.json +36 -0
  2. package/dist/README.md +135 -0
  3. package/dist/package.json +38 -0
  4. package/jest.config.ts +22 -0
  5. package/ng-package.json +6 -0
  6. package/package.json +20 -38
  7. package/project.json +50 -0
  8. package/src/components/ruc-meta-checkbox-group/ruc-meta-checkbox-group.component.css +10 -0
  9. package/src/components/ruc-meta-checkbox-group/ruc-meta-checkbox-group.component.html +11 -0
  10. package/src/components/ruc-meta-checkbox-group/ruc-meta-checkbox-group.component.spec.ts +103 -0
  11. package/src/components/ruc-meta-checkbox-group/ruc-meta-checkbox-group.component.ts +33 -0
  12. package/src/components/ruc-meta-inputs/ruc-meta-inputs.component.css +16 -0
  13. package/src/components/ruc-meta-inputs/ruc-meta-inputs.component.html +18 -0
  14. package/src/components/ruc-meta-inputs/ruc-meta-inputs.component.spec.ts +85 -0
  15. package/src/components/ruc-meta-inputs/ruc-meta-inputs.component.ts +44 -0
  16. package/src/components/ruc-meta-radio-group/ruc-meta-radio-group.component.css +13 -0
  17. package/src/components/ruc-meta-radio-group/ruc-meta-radio-group.component.html +12 -0
  18. package/src/components/ruc-meta-radio-group/ruc-meta-radio-group.component.spec.ts +98 -0
  19. package/src/components/ruc-meta-radio-group/ruc-meta-radio-group.component.ts +28 -0
  20. package/src/components/ruc-meta-select/ruc-meta-select.component.css +9 -0
  21. package/src/components/ruc-meta-select/ruc-meta-select.component.html +12 -0
  22. package/src/components/ruc-meta-select/ruc-meta-select.component.spec.ts +1165 -0
  23. package/src/components/ruc-meta-select/ruc-meta-select.component.ts +45 -0
  24. package/src/components/ruc-text-area/ruc-text-area.component.css +0 -0
  25. package/src/components/ruc-text-area/ruc-text-area.component.html +16 -0
  26. package/src/components/ruc-text-area/ruc-text-area.component.spec.ts +100 -0
  27. package/src/components/ruc-text-area/ruc-text-area.component.ts +30 -0
  28. package/src/index.ts +2 -0
  29. package/src/interfaces/metaFormsDefault.ts +71 -0
  30. package/src/lib/ruclib-metaform/ruclib-metaform.component.html +99 -0
  31. package/src/lib/ruclib-metaform/ruclib-metaform.component.scss +15 -0
  32. package/src/lib/ruclib-metaform/ruclib-metaform.component.spec.ts +1253 -0
  33. package/src/lib/ruclib-metaform/ruclib-metaform.component.stories.ts +676 -0
  34. package/src/lib/ruclib-metaform/ruclib-metaform.component.ts +91 -0
  35. package/src/lib/ruclib-metaform.module.ts +59 -0
  36. package/src/services/ruc-meta-form-validation.service.spec.ts +75 -0
  37. package/src/services/ruc-meta-form-validation.service.ts +30 -0
  38. package/src/services/ruc-meta-form.service.spec.ts +63 -0
  39. package/src/services/ruc-meta-form.service.ts +20 -0
  40. package/src/test-setup.ts +1 -0
  41. package/tsconfig.json +30 -0
  42. package/tsconfig.lib.json +17 -0
  43. package/tsconfig.lib.prod.json +9 -0
  44. package/tsconfig.spec.json +16 -0
  45. /package/{components → dist/components}/ruc-meta-checkbox-group/ruc-meta-checkbox-group.component.d.ts +0 -0
  46. /package/{components → dist/components}/ruc-meta-inputs/ruc-meta-inputs.component.d.ts +0 -0
  47. /package/{components → dist/components}/ruc-meta-radio-group/ruc-meta-radio-group.component.d.ts +0 -0
  48. /package/{components → dist/components}/ruc-meta-select/ruc-meta-select.component.d.ts +0 -0
  49. /package/{components → dist/components}/ruc-text-area/ruc-text-area.component.d.ts +0 -0
  50. /package/{esm2020 → dist/esm2020}/components/ruc-meta-checkbox-group/ruc-meta-checkbox-group.component.mjs +0 -0
  51. /package/{esm2020 → dist/esm2020}/components/ruc-meta-inputs/ruc-meta-inputs.component.mjs +0 -0
  52. /package/{esm2020 → dist/esm2020}/components/ruc-meta-radio-group/ruc-meta-radio-group.component.mjs +0 -0
  53. /package/{esm2020 → dist/esm2020}/components/ruc-meta-select/ruc-meta-select.component.mjs +0 -0
  54. /package/{esm2020 → dist/esm2020}/components/ruc-text-area/ruc-text-area.component.mjs +0 -0
  55. /package/{esm2020 → dist/esm2020}/index.mjs +0 -0
  56. /package/{esm2020 → dist/esm2020}/interfaces/metaFormsDefault.mjs +0 -0
  57. /package/{esm2020 → dist/esm2020}/lib/ruclib-metaform/ruclib-metaform.component.mjs +0 -0
  58. /package/{esm2020 → dist/esm2020}/lib/ruclib-metaform.module.mjs +0 -0
  59. /package/{esm2020 → dist/esm2020}/ruc-lib-metaform.mjs +0 -0
  60. /package/{esm2020 → dist/esm2020}/services/ruc-meta-form-validation.service.mjs +0 -0
  61. /package/{esm2020 → dist/esm2020}/services/ruc-meta-form.service.mjs +0 -0
  62. /package/{fesm2015 → dist/fesm2015}/ruc-lib-metaform.mjs +0 -0
  63. /package/{fesm2015 → dist/fesm2015}/ruc-lib-metaform.mjs.map +0 -0
  64. /package/{fesm2020 → dist/fesm2020}/ruc-lib-metaform.mjs +0 -0
  65. /package/{fesm2020 → dist/fesm2020}/ruc-lib-metaform.mjs.map +0 -0
  66. /package/{index.d.ts → dist/index.d.ts} +0 -0
  67. /package/{interfaces → dist/interfaces}/metaFormsDefault.d.ts +0 -0
  68. /package/{lib → dist/lib}/ruclib-metaform/ruclib-metaform.component.d.ts +0 -0
  69. /package/{lib → dist/lib}/ruclib-metaform.module.d.ts +0 -0
  70. /package/{services → dist/services}/ruc-meta-form-validation.service.d.ts +0 -0
  71. /package/{services → dist/services}/ruc-meta-form.service.d.ts +0 -0
@@ -0,0 +1,91 @@
1
+ import { Component, Input, Output, OnInit, EventEmitter, OnDestroy } from '@angular/core';
2
+ import {MetaFormConfig} from '../../interfaces/metaFormsDefault';
3
+ import { RucMetaFormService } from "../../services/ruc-meta-form.service"
4
+ import { Subscription } from 'rxjs';
5
+ @Component({
6
+ selector: 'uxp-ruclib-metaform',
7
+ templateUrl: './ruclib-metaform.component.html',
8
+ styleUrls: ['./ruclib-metaform.component.scss']
9
+ })
10
+ export class RuclibMetaformComponent implements OnInit,OnDestroy{
11
+ @Output() rucEvent = new EventEmitter<any>();
12
+ @Output() childRucEvent = new EventEmitter<any>();
13
+ @Input() rucInputData: MetaFormConfig[] = []
14
+ @Input() childForm?: MetaFormConfig[]
15
+ @Input()
16
+ customTheme!: string;
17
+ @Input() isChild?: boolean;
18
+ @Input() selectedParentId: any;
19
+ inputObjectDataMultiFileUpload?:any;
20
+ metaFormSubscribeInputs: Subscription | undefined;
21
+ formData: any
22
+ constructor(public service: RucMetaFormService) { }
23
+
24
+ ngOnInit(): void {
25
+ if (!this.isChild) {
26
+ this.service.getFormJson(this.rucInputData);
27
+ this.getFormJson();
28
+ } else {
29
+ this.formData = this.childForm;
30
+ }
31
+ this.inputObjectDataMultiFileUpload = {
32
+ multifileSelection: true,
33
+ displayThumbnail: true,
34
+ label: 'Choose File',
35
+ uploadUrl: '/api/upload',
36
+ deleteUrl: '/api/delete',
37
+ };
38
+ }
39
+
40
+ /**
41
+ * The purpose of this function to pass data from dependentFields to parent field
42
+ * @param getObject
43
+ * @param j
44
+ */
45
+ passEvent(getObject: any, formElement?: any) {
46
+ const eventOutput = getObject?.eventOutput ? getObject.eventOutput : this.service.currentFormElement;
47
+ if(getObject?.eventName == "onUploading"){
48
+ formElement.value = getObject?.eventOutput.name ? getObject?.eventOutput.name : getObject?.eventOutput[0].name;
49
+ }
50
+ this.rucEvent.emit({ 'eventName': 'metaFormData', 'eventOutput': eventOutput, 'formData': this.formData, 'rucComponentEvent': getObject?.eventName });
51
+ }
52
+
53
+ /**
54
+ * Initial function to load for data
55
+ */
56
+ getFormJson() {
57
+ this.metaFormSubscribeInputs = this.service.formData.asObservable()
58
+ .subscribe(
59
+ (formData)=>{
60
+ this.formData = formData;
61
+ this.service.metaFormData = this.formData;
62
+ }
63
+ );
64
+ }
65
+
66
+ /**
67
+ * This function is to emit form data
68
+ * @param event
69
+ */
70
+ getMetaFormData(event: any) {
71
+ this.rucEvent.emit({ 'eventName': 'metaFormData', 'eventOutput': event, 'formData': this.formData });
72
+ }
73
+
74
+ /**
75
+ * Clear form data
76
+ */
77
+ clearForm(){
78
+ this.formData.map((x:MetaFormConfig)=>{
79
+ x.value = '';
80
+ });
81
+ }
82
+
83
+ /**
84
+ * Destroy the subscriber
85
+ */
86
+ ngOnDestroy() {
87
+ if (this.metaFormSubscribeInputs) {
88
+ this.metaFormSubscribeInputs.unsubscribe();
89
+ }
90
+ }
91
+ }
@@ -0,0 +1,59 @@
1
+ import { NgModule } from '@angular/core';
2
+ import { CommonModule } from '@angular/common';
3
+ import { RuclibMetaformComponent } from './ruclib-metaform/ruclib-metaform.component';
4
+ import { HttpClientModule } from '@angular/common/http';
5
+ import { FormsModule } from '@angular/forms';
6
+ import { MatFormFieldModule } from '@angular/material/form-field';
7
+ import { MatInputModule } from '@angular/material/input';
8
+ import { MatRadioModule } from '@angular/material/radio';
9
+ import { MatCheckboxModule } from '@angular/material/checkbox';
10
+ import { MatSelectModule } from '@angular/material/select';
11
+ import { MatAutocompleteModule } from '@angular/material/autocomplete';
12
+ import { MatButtonModule} from '@angular/material/button';
13
+ import { MatTooltipModule} from '@angular/material/tooltip';
14
+ import {MatStepperModule} from '@angular/material/stepper';
15
+ import { TextFieldModule} from '@angular/cdk/text-field';
16
+ import { RucMetaFormService } from '../services/ruc-meta-form.service';
17
+ import { RucMetaInputsComponent } from '../components/ruc-meta-inputs/ruc-meta-inputs.component';
18
+ import { RucMetaRadioGroupComponent } from '../components/ruc-meta-radio-group/ruc-meta-radio-group.component';
19
+ import { RucMetaCheckboxGroupComponent } from '../components/ruc-meta-checkbox-group/ruc-meta-checkbox-group.component';
20
+ import { RucMetaSelectComponent } from '../components/ruc-meta-select/ruc-meta-select.component';
21
+ import { RucTextAreaComponent } from '../components/ruc-text-area/ruc-text-area.component';
22
+
23
+ import {RuclibMultiSelectModule} from '@ruc-lib/multi-select';
24
+ import {RuclibMultiFileUploadModule} from '@ruc-lib/multi-file-upload';
25
+
26
+
27
+ @NgModule({
28
+ imports: [CommonModule,
29
+ HttpClientModule,
30
+ FormsModule,
31
+ MatFormFieldModule,
32
+ MatInputModule,
33
+ MatRadioModule,
34
+ MatCheckboxModule,
35
+ MatSelectModule,
36
+ MatAutocompleteModule,
37
+ MatButtonModule,
38
+ MatTooltipModule,
39
+ TextFieldModule,
40
+ MatStepperModule,
41
+ RuclibMultiSelectModule,
42
+ RuclibMultiFileUploadModule
43
+ ],
44
+ declarations: [
45
+ RuclibMetaformComponent,
46
+ RucMetaInputsComponent,
47
+ RucMetaRadioGroupComponent,
48
+ RucMetaCheckboxGroupComponent,
49
+ RucMetaSelectComponent,
50
+ RucTextAreaComponent
51
+ ],
52
+ exports: [
53
+ RuclibMetaformComponent
54
+ ],
55
+ providers: [
56
+ RucMetaFormService
57
+ ]
58
+ })
59
+ export class RuclibMetaformModule {}
@@ -0,0 +1,75 @@
1
+ import { TestBed } from '@angular/core/testing';
2
+
3
+ import { RucMetaFormValidationService } from './ruc-meta-form-validation.service';
4
+ import { MetaFormConfig } from '../interfaces/metaFormsDefault';
5
+
6
+ describe('RucMetaFormValidationService', () => {
7
+ let service: RucMetaFormValidationService;
8
+ const mockFormData: MetaFormConfig = {
9
+ "formType": "simple",
10
+ "fieldType": "textarea",
11
+ "inputType": "text",
12
+ "id": "Address",
13
+ "name": "Address",
14
+ "errorMsg": false,
15
+ "label": "Address",
16
+ "className": "Address",
17
+ "value": "/ /",
18
+ "alt": "na",
19
+ "appearance": "outline",
20
+ "min": "4",
21
+ "max": "20",
22
+ "width": "100",
23
+ "height": "20",
24
+ "checked": false,
25
+ "disabled": false,
26
+ "maxlength": "100",
27
+ "readonly": false,
28
+ "required": false,
29
+ "size": "100",
30
+ "step": "100",
31
+ "sameRow": false,
32
+ "sameRowColumnWidth": "100",
33
+ "tooltip": "First Name",
34
+ "tooltipPosition": "right",
35
+ "pattern": "any",
36
+ "placeholder": "Address",
37
+ "autofocus": true,
38
+ "autocomplete": ["amar", "bharat", "charan"],
39
+ "customComponentName": "none",
40
+ "rucDialogInput": {},
41
+ "hasDependentFields": false,
42
+ "dependentFieldParentId": "any",
43
+ "dependentFields": [],
44
+ "toolTipDescription": "none",
45
+ "showErrorOnPopUp": true,
46
+ "groupOptions": []
47
+ }
48
+ beforeEach(() => {
49
+ TestBed.configureTestingModule({});
50
+ service = TestBed.inject(RucMetaFormValidationService);
51
+ });
52
+
53
+ it('should be created', () => {
54
+ expect(service).toBeTruthy();
55
+ });
56
+
57
+ it('should called nospaceValidator', () => {
58
+ const result = service.nospaceValidator(mockFormData);
59
+ const re = / /;
60
+ expect(mockFormData.value).toMatch(re);
61
+ });
62
+
63
+ it('should called alphaNumericValidator', () => {
64
+ const result = service.alphaNumericValidator(mockFormData);
65
+ const re = '^[a-zA-Z0-9_]+$';
66
+ expect(mockFormData.value).not.toMatch(re);
67
+ });
68
+ it('nospaceValidator should return nullTable if value contains space', () => {
69
+ const formData: MetaFormConfig = mockFormData
70
+
71
+ const result = service.nospaceValidator(formData);
72
+
73
+ expect(result).toEqual({ nullTable: true });
74
+ });
75
+ });
@@ -0,0 +1,30 @@
1
+ import { Injectable } from '@angular/core';
2
+ import {MetaFormConfig} from '../interfaces/metaFormsDefault';
3
+
4
+
5
+ @Injectable({
6
+ providedIn: 'root'
7
+ })
8
+ export class RucMetaFormValidationService {
9
+
10
+ public defaultErrorMessage = 'Invalid Input';
11
+
12
+ constructor() {
13
+ }
14
+
15
+ nospaceValidator(formData:MetaFormConfig){
16
+ const re = / /;
17
+ if(formData.value.match(re)){
18
+ return { nullTable: true }
19
+ }else{
20
+ return false;
21
+ }
22
+ }
23
+
24
+ alphaNumericValidator(formData:MetaFormConfig){
25
+ const re = '^[a-zA-Z0-9_]+$'
26
+ return formData.value ? !formData.value.match(re) : false;
27
+ }
28
+
29
+
30
+ }
@@ -0,0 +1,63 @@
1
+ import { TestBed } from '@angular/core/testing';
2
+
3
+ import { RucMetaFormService } from './ruc-meta-form.service';
4
+ import { HttpClientTestingModule } from '@angular/common/http/testing';
5
+ import { HttpClientModule } from '@angular/common/http';
6
+ describe('RucMetaFormService', () => {
7
+ let service: RucMetaFormService;
8
+ const formData = {
9
+ "formType": "simple",
10
+ "fieldType": "textarea",
11
+ "inputType": "textarea",
12
+ "id": "Address",
13
+ "name": "Address",
14
+ "errorMsg": false,
15
+ "label": "Address",
16
+ "className": "Address",
17
+ "value": "Address",
18
+ "alt": "na",
19
+ "appearance": "outline",
20
+ "min": "4",
21
+ "max": "20",
22
+ "width": "100",
23
+ "height": "20",
24
+ "checked": false,
25
+ "disabled": false,
26
+ "maxlength": "100",
27
+ "readonly": false,
28
+ "required": false,
29
+ "size": "100",
30
+ "step": 100,
31
+ "sameRow": false,
32
+ "sameRowColumnWidth": "100",
33
+ "tooltip": "First Name",
34
+ "tooltipPosition": "right",
35
+ "pattern": "any",
36
+ "placeholder": "Address",
37
+ "autofocus": true,
38
+ "autocomplete": ["amar", "bharat", "charan"],
39
+ "customComponentName": "none",
40
+ "rucDialogInput": {},
41
+ "hasDependentFields": false,
42
+ "dependentFieldParentId": "any",
43
+ "dependentFields": "any",
44
+ "toolTipDescription": "none",
45
+ "showErrorOnPopUp": true,
46
+ "groupOptions": []
47
+ }
48
+ beforeEach(() => {
49
+ TestBed.configureTestingModule({
50
+ imports: [HttpClientTestingModule, HttpClientModule],
51
+ providers: [RucMetaFormService]
52
+ });
53
+ service = TestBed.inject(RucMetaFormService);
54
+ });
55
+
56
+ it('should be created', () => {
57
+ expect(service).toBeTruthy();
58
+ });
59
+
60
+ it('should call getFormJson', () => {
61
+ service.getFormJson(formData);
62
+ })
63
+ });
@@ -0,0 +1,20 @@
1
+ import { Injectable } from '@angular/core';
2
+ import { Observable,Subject, BehaviorSubject } from 'rxjs';
3
+ import { HttpClient } from '@angular/common/http';
4
+ import {MetaFormConfig} from '../interfaces/metaFormsDefault';
5
+ @Injectable({
6
+ providedIn: 'root'
7
+ })
8
+ export class RucMetaFormService {
9
+
10
+ public metaFormData:MetaFormConfig | undefined;
11
+ public currentFormElement: MetaFormConfig | undefined;
12
+
13
+ constructor(private http: HttpClient) { }
14
+
15
+ public formData: BehaviorSubject<any> = new BehaviorSubject([] as any);
16
+
17
+ getFormJson(form: any){
18
+ this.formData.next(form);
19
+ }
20
+ }
@@ -0,0 +1 @@
1
+ import 'jest-preset-angular/setup-jest';
package/tsconfig.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "es2022",
4
+ "useDefineForClassFields": false,
5
+ "forceConsistentCasingInFileNames": true,
6
+ "strict": true,
7
+ "noImplicitOverride": true,
8
+ "noPropertyAccessFromIndexSignature": true,
9
+ "noImplicitReturns": true,
10
+ "noFallthroughCasesInSwitch": true,
11
+ "skipLibCheck": true
12
+ },
13
+ "files": [],
14
+ "include": [],
15
+ "references": [
16
+ {
17
+ "path": "./tsconfig.lib.json"
18
+ },
19
+ {
20
+ "path": "./tsconfig.spec.json"
21
+ }
22
+ ],
23
+ "extends": "../../../tsconfig.base.json",
24
+ "angularCompilerOptions": {
25
+ "enableI18nLegacyMessageIdFormat": false,
26
+ "strictInjectionParameters": true,
27
+ "strictInputAccessModifiers": true,
28
+ "strictTemplates": true
29
+ }
30
+ }
@@ -0,0 +1,17 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "../../../dist/out-tsc",
5
+ "declaration": true,
6
+ "declarationMap": true,
7
+ "inlineSources": true,
8
+ "types": []
9
+ },
10
+ "exclude": [
11
+ "src/test-setup.ts",
12
+ "src/**/*.spec.ts",
13
+ "jest.config.ts",
14
+ "src/**/*.test.ts"
15
+ ],
16
+ "include": ["src/**/*.ts"]
17
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "./tsconfig.lib.json",
3
+ "compilerOptions": {
4
+ "declarationMap": false
5
+ },
6
+ "angularCompilerOptions": {
7
+ "compilationMode": "partial"
8
+ }
9
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "../../../dist/out-tsc",
5
+ "module": "commonjs",
6
+ "target": "es2016",
7
+ "types": ["jest", "node"]
8
+ },
9
+ "files": ["src/test-setup.ts"],
10
+ "include": [
11
+ "jest.config.ts",
12
+ "src/**/*.test.ts",
13
+ "src/**/*.spec.ts",
14
+ "src/**/*.d.ts"
15
+ ]
16
+ }
File without changes
File without changes
File without changes
File without changes