19.0.6 • Published 3 months ago

dynamic-angular-form v19.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

DynamicForm

This Library was born to help peoples to integrate various forms in one. With the ausily of a json file pattern we can generate forms dynamically based on fields specified into JSON Pattern File.

Repository GITHUB : DynamicAngularForm

Requirements

For the installation we need to use the following versions of :

Node.JS : v20.13.1

Angular : 17 - 18 - 19

The library come with preinstalled @angular-slider/ngx-slider for the rendering of Slider form inputs, @ng-bootstrap/ng-bootstrap for the Date and Time Picker and ng-recaptcha-2 for the rendering og Google Recaptcha security feature.

Installation

First of all you need to install the library running :

 npm i dynamic-angular-form@19.0.2
Angular VersionLib Version
v1919
v1818
v1717

Subsequently you need to import the module into app.module.ts

@NgModule({
  declarations: [	
    AppComponent
   ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    DynamicFormModule
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }

Note : If you want to use Google Login addon or Google Recaptcha input, you have to pass correctly the Google Recaptcha Key for making work Google Recaptcha and the Google Client Id for making work Google Login lib

@NgModule({
  declarations: [	
    AppComponent
   ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    DynamicFormModule.forRoot(environment.recaptchaSiteKey,environment.googleClientId)
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }

Models and Usage

Below you will find all the information you need to correctly use the templates and the various components


Dynamic Modal

<dynamic-modal />

Input

PropertyTypeDefaultDescriptionRequired
modalIdstring'default-id'Assign a custom modal IDfalse
modalPopupbooleanfalseMake the modal popup onload automaticallyfalse
modalCloseButtonbooleanfalseEnable close modal button, will appear as an "x" button in the top-right cornerfalse
formSchemesDynamicFormScheme[]Scheme of the form to visualizefalse
loadSpinnerbooleanfalseLoad spinner into the submit buttonfalse
isSubmitFailedbooleanfalseEnable custom error message after submitfalse
errorMessagestring''Load custom error message after submitfalse

Output

MethodDescriptionRequired
onSubmit()Handle form submitted resultfalse
loginWithGoogle()Handle Google login resultfalse
onCloseModal()Handle modal closefalse
onBack()Handle modal backfalse
formValueChanges()Handle modal value changefalse

Functions

To use it correctly declare a child in your component : TS ->

  @ViewChild('myModal') registerFormModal!: DynamicModalComponent

HTML ->

 <dynamic-modal #myModal (onSubmit)="submit($event)" [formSchemes]="registerScheme" modalId="modal-1" />
MethodDescriptionRequired
isFormValid(idx: number)Check if a form in a certain index is validfalse
updateForm(idx:number, values:any)Patch values of a certain formfalse
goToPage(page: number)Navigate to a different form pagefalse
closeModal()Close current modalfalse
openModal()Open current modalfalse
formInit()Handle modal form changefalse

Dynamic Form

<dynamic-form />

Input

PropertyTypeDefaultDescriptionRequired
formSchemesDynamicFormScheme[]Scheme of the form to visualizefalse
loadSpinnerbooleanfalseLoad spinner into the submit buttonfalse
isSubmitFailedbooleanfalseEnable custom error message after submitfalse
errorMessagestring''Load custom error message after submitfalse

Output

MethodDescriptionRequired
onSubmit()Handle form submitted resultfalse
loginWithGoogle()Handle Google login resultfalse
onCloseForm()Handle form closefalse
onBack()Handle form backfalse
formValueChanges()Handle form value changefalse
formInit()Handle form form changefalse

Functions

To use it correctly declare a child in your component : TS ->

  @ViewChild('form') registerForm!: DynamicFormComponent

HTML ->

 <dynamic-form #form (onSubmit)="submit($event)" [formSchemes]="registerScheme" />
MethodDescriptionRequired
isFormValid(idx: number)Check if a form in a certain index is validfalse
updateForm(idx:number, values:any)Patch values of a certain formfalse
goToPage(page: number)Navigate to a different form pagefalse

DynamicFormScheme

PropertyTypeDescription
formIdstringUnique identifier for the form.
titlestringTitle of the form.
title_{LANGUAGE}string (optional)Title translated of the field.
descriptionstring (optional)Description of the form.
description_{LANGUAGE}string (optional)Description translated of the field.
active_pageboolean (optional)Indicates if the form is active.
fieldsFieldScheme[]Array of form fields.
buttonsButtonScheme[]Array of form buttons.
addonsAddonScheme[]Array of form addons.
custom_validatorsCustomValidatorScheme[]Array of custom validators for the form.

FieldScheme

PropertyTypeDescriptionUsage Type
typeFieldTypeType of the field.ALL
default_valuestring | number | boolean | { year: number, month: number, day: number } | { hour: number, minute: number } (optional)Default value of the field.ALL
namestring (optional)Name of the field.ALL
name_{LANGUAGE}string (optional)Name translated of the field.ALL
top_labelstring (optional)Label displayed above the field.ALL
validatorsValidatorScheme[] (optional)Array of validators for the field.ALL
errorsErrorScheme[] (optional)Array of error messages related to the field.ALL
disabledboolean (optional)Indicates if the field is disabled.ALL
visibleboolean (optional)Indicates if the field is visible.ALL
formControlNamestring (optional)Form control name, typically used with reactive forms.ALL
autocompleteboolean (optional)Indicates if the field has autocomplete.text, password
default_value_{LANGUAGE}string (optional)Name translated of the field.section_info
srcstring (optional)Source URL or path for certain field types (e.g., images).show_image
optionsany (optional)Additional options for the field.slider
lengthnumber (optional)Length of the field.otp
minDate{ year:number, month:number, day:number } (optional)minDate of datepicker.date
maxDate{ year:number, month:number, day:number } (optional)maxDate of datepicker.date
valuesSelectValueScheme[] (optional)Array of selectable values for fields like dropdowns or radios.select
multipleboolean (optional)Multiple upload of files.add_image, add_video
acceptstring (optional)Accept types for input files.add_image, add_video
widthstring (optional)Width of the field.add_image, add_video, show_image, show_video
controlsstring (optional)Controls of the video field.show_video, add_video
versionstring (optional)Version of the field.g_recaptcha

FieldType (Enum)

ValueDescription
textRepresents a text input field.
numberRepresents a number input field.
radioRepresents a radio input field.
dateRepresents a date input field.
otpRepresents an OTP input field.
timeRepresents a time input field.
selectRepresents a select dropdown field.
passwordRepresents a password input field.
textareaRepresents a textarea input field.
checkboxRepresents a checkbox input field.
g_recaptchaRepresents a Google reCAPTCHA field.
section_infoRepresents a section information field.
sliderRepresents a slider from @angular-slider/ngx-slider input field.
slider_nouiRepresents a slider from nouislider input field.
telephoneRepresents a telephone input field.
add_imageRepresents an add image field.
show_imageRepresents a show image field.
add_videoRepresents an add image field.
show_videoRepresents a show image field.

SelectValueScheme

PropertyTypeDescription
namestringDisplay name of the option.
name_{LANGUAGE}string (optional)Name translated of the field.
valuestringValue of the option.

AddonScheme

PropertyTypeDescriptionUsage Type
nameAddonTypeType of the addon.ALL
normal_textstring (optional)Regular text displayed in the addon.highlight
normal_text_{LANGUAGE}string (optional)Regular text translated of the field.highlight
highlight_textstring (optional)Highlighted text within the addon.highlight
highlight_text_{LANGUAGE}string (optional)Highlighted text translated of the field.highlight
hrefstring (optional)URL or link associated with the addon.highlight
href_typeHrefTypes (optional)Type of href action (e.g., modal).highlight
stylenumber (optional)Style identifier for the addon.google_login
upper_textstring (optional)Text displayed above the main content.google_login
sizestring (optional)Size of the addon.google_login
typestring (optional)Type of addon (e.g., button, link).google_login
themestring (optional)Theme or color scheme for the addon.google_login
textstring (optional)Text displayed in the addon.google_login
shapestring (optional)Shape of the addon (e.g., square, circle).google_login
logo_alignmentstring (optional)Alignment of the logo within the addon.google_login

AddonType (Enum)

ValueDescription
highlightRepresents a highlight addon.
google_loginRepresents a Google login addon.

HrefTypes (Enum)

ValueDescription
MODALRepresents a modal link type.

ButtonScheme

PropertyTypeDescriptionUsage Type
typeButtonTypeType of the button (e.g., submit, close).ALL
namestringName of the button.ALL
name_{LANGUAGE}string (optional)Name translated of the field.ALL
text_colorstringText color of the button.ALL
button_colorstringBackground color of the button.ALL
marginboolean (optional)Indicates if the button has a margin.ALL
pagenumber (optional)Page number the button is associated with.back

ButtonType (Enum)

ValueDescription
submitRepresents a submit button.
closeRepresents a close button.
backRepresents a back button.
testRepresents a test button.

CustomValidatorScheme

PropertyTypeDescription
namestringName of the custom validator.
error_namestringName of the error associated with this validator.
textstringError message text.

ErrorScheme

PropertyTypeDescription
nameErrorsType of the error (e.g., required, email).
textstringError message text.

ValidatorScheme

PropertyTypeDescription
nameErrorsType of the error being validated.
valuestringValue associated with the validator.

Errors (Enum)

ValueDescription
requiredRepresents a required field.
telephoneRepresents a telephone error.
emailRepresents an email validation error.
maxlengthRepresents a max length error.
minlengthRepresents a min length error.
maxRepresents a max error.
minRepresents a min error.
patternRepresents a pattern matching error.

Other Components

Button Loader

<button-loader />

Input

PropertyTypeDefaultDescriptionRequired
loadSpinnerbooleanfalseLoad spinner into the submit buttonfalse
loadCheckbooleanfalseLoad check icon, useful when the submit is finishedfalse
isFormValidbooleantrueEnable button if the form is validfalse
textstring''Text inside the buttonfalse
iconStockIcons or Uil''Icon to load next to the text. Uil icon example: uil uil-info-circlefalse
icon_position['left','right']'left'Position of the icon in relation to the textfalse
typestring'submit'Button typefalse
colorstring'primary'Button color as hex (e.g., #45c4a0)false
text_colorstring'white'Button text color as hex (e.g., #ffffff)false
marginbooleantrueButton margin right, useful with multiple buttons in sequencefalse

Output

MethodDescriptionRequired
onSubmit()Handle form submitted resultfalse

Google Login

<google-login />

Input

PropertyTypeDefaultDescriptionRequired
typestring'standard'Refer to Google Docsfalse
sizestring'medium'Refer to Google Docsfalse
themestring'outline'Refer to Google Docsfalse
textstring'sign_in_with'Refer to Google Docsfalse
shapestring'rectangular'Refer to Google Docsfalse
logo_alignmentstring'left'Refer to Google Docsfalse

19.0.5

3 months ago

19.0.4

3 months ago

19.0.6

3 months ago

19.0.3

3 months ago

19.0.2

3 months ago

19.0.1

4 months ago

19.0.0

4 months ago

17.0.1

4 months ago

17.0.0

4 months ago

18.0.0

4 months ago

2.0.82

4 months ago

2.0.80

4 months ago

2.0.81

4 months ago

2.0.79

4 months ago

2.0.78

4 months ago

2.0.77

5 months ago

2.0.75

5 months ago

2.0.76

5 months ago

2.0.74

5 months ago

2.0.59

6 months ago

2.0.57

6 months ago

2.0.58

6 months ago

2.0.55

6 months ago

2.0.56

6 months ago

2.0.53

6 months ago

2.0.54

6 months ago

2.0.51

6 months ago

2.0.52

6 months ago

2.0.68

6 months ago

2.0.69

6 months ago

2.0.66

6 months ago

2.0.67

6 months ago

2.0.64

6 months ago

2.0.65

6 months ago

2.0.62

6 months ago

2.0.63

6 months ago

2.0.60

6 months ago

2.0.61

6 months ago

2.0.73

6 months ago

2.0.71

6 months ago

2.0.72

6 months ago

2.0.70

6 months ago

2.0.48

7 months ago

2.0.49

7 months ago

2.0.50

7 months ago

2.0.46

7 months ago

2.0.47

7 months ago

2.0.44

7 months ago

2.0.45

7 months ago

2.0.43

7 months ago

2.0.42

7 months ago

2.0.41

8 months ago

2.0.40

8 months ago

2.0.28

9 months ago

2.0.29

9 months ago

2.0.37

9 months ago

2.0.38

9 months ago

2.0.35

9 months ago

2.0.36

9 months ago

2.0.33

9 months ago

2.0.34

9 months ago

2.0.31

9 months ago

2.0.32

9 months ago

2.0.30

9 months ago

2.0.39

9 months ago

2.0.15

10 months ago

2.0.16

10 months ago

2.0.14

10 months ago

2.0.19

10 months ago

2.0.17

10 months ago

2.0.18

10 months ago

2.0.26

9 months ago

2.0.27

9 months ago

2.0.24

9 months ago

2.0.25

9 months ago

2.0.22

10 months ago

2.0.23

10 months ago

2.0.20

10 months ago

2.0.21

10 months ago

2.0.13

10 months ago

2.0.12

10 months ago

2.0.3

10 months ago

2.0.2

10 months ago

2.0.5

10 months ago

2.0.4

10 months ago

2.0.7

10 months ago

2.0.6

10 months ago

2.0.9

10 months ago

2.0.8

10 months ago

1.0.66

10 months ago

1.0.69

10 months ago

2.0.1

10 months ago

1.0.68

10 months ago

2.0.0

10 months ago

1.0.67

10 months ago

1.0.73

10 months ago

1.0.72

10 months ago

1.0.71

10 months ago

1.0.70

10 months ago

1.0.77

10 months ago

1.0.76

10 months ago

1.0.75

10 months ago

1.0.74

10 months ago

1.0.79

10 months ago

1.0.78

10 months ago

1.0.80

10 months ago

2.0.11

10 months ago

1.0.84

10 months ago

1.0.83

10 months ago

1.0.82

10 months ago

2.0.10

10 months ago

1.0.81

10 months ago

1.0.62

11 months ago

1.0.61

11 months ago

1.0.60

11 months ago

1.0.65

11 months ago

1.0.64

11 months ago

1.0.63

11 months ago

1.0.44

12 months ago

1.0.43

12 months ago

1.0.48

12 months ago

1.0.47

12 months ago

1.0.46

12 months ago

1.0.45

12 months ago

1.0.49

12 months ago

1.0.51

11 months ago

1.0.50

11 months ago

1.0.55

11 months ago

1.0.54

11 months ago

1.0.53

11 months ago

1.0.52

11 months ago

1.0.59

11 months ago

1.0.58

11 months ago

1.0.57

11 months ago

1.0.56

11 months ago

1.0.39

1 year ago

1.0.40

1 year ago

1.0.42

1 year ago

1.0.41

1 year ago

1.0.38

1 year ago

1.0.26

1 year ago

1.0.25

1 year ago

1.0.24

1 year ago

1.0.23

1 year ago

1.0.29

1 year ago

1.0.28

1 year ago

1.0.27

1 year ago

1.0.33

1 year ago

1.0.32

1 year ago

1.0.31

1 year ago

1.0.30

1 year ago

1.0.37

1 year ago

1.0.36

1 year ago

1.0.35

1 year ago

1.0.34

1 year ago

1.0.22

1 year ago

1.0.19

1 year ago

1.0.18

1 year ago

1.0.21

1 year ago

1.0.20

1 year ago

1.0.17

1 year ago

1.0.16

1 year ago

1.0.15

1 year ago

1.0.14

1 year ago

1.0.13

1 year ago

1.0.12

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

0.0.1

1 year ago