Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ng-vcl/jss-form

Package Overview
Dependencies
Maintainers
5
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ng-vcl/jss-form

Creates a html-form from a jsonschema

  • 0.4.0-1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
Maintainers
5
Weekly downloads
 
Created
Source

vcl-jss-form

Creates a html-form from a jsonschema.

Installation

npm install @ng-vcl/jss-form --save

Usage:

import { VCLJssFormModule } from 'ng-vcl';

@NgModule({
  imports: [ VCLJssFormModule ],
  ...
})
export class AppComponent {}
<vcl-jss-form [schema]="mySchema" [(ngModel)]="value" (ngSubmit)="onSubmit($event)" (action)="onAction($event)" ></vcl-jss-form>

example-schema:

{
  "title": "hero schema",
  "description": "describes a simple hero",
  "type": "object",
  "properties": {
    "name": {
      "formType": "text",
      "label": "Name",
      "type": "string",
      "minLength": 4,
      "placeholder": "The hero's name"
    },
    "color": {
      "formType": "select",
      "label": "Team",
      "description": "color defines which team the hero belongs to",
      "type": "string",
      "options": [
        {
          "label": "Red",
          "value": "#ff0000"
        },
        {
          "label": "Green",
          "value": "#008000"
        },
        {
          "label": "Blue",
          "value": "#0000FF"
        },
        {
          "label": "Yellow",
          "value": "#FFFF00"
        }
      ]
    },
    "gender": {
      "formType": "radio",
      "label": "Gender",
      "type": "string",
      "enum": [
        "male",
        "female"
      ]
    },
    "perks": {
      "formType": "dropdown",
      "label": "Perks",
      "type": "array",
      "options": [
        {
          "label": "Heave Ho!",
          "value": "heave_ho\t"
        },
        {
          "label": "Snakeater",
          "value": "snakeater"
        },
        {
          "label": "Karma Beacon",
          "value": "karma_beacon"
        }
      ]
    },
    "leader": {
      "formType": "checkbox",
      "label": "Leader",
      "type": "boolean"
    },
    "hp": {
      "formType": "slider",
      "label": "Hitpoints",
      "type": "number",
      "minimum": 0,
      "maximum": 20
    },
    "alive": {
      "formType": "switch",
      "label": "Is alive?",
      "type": "boolean"
    },
    "mainSkill": {
      "label": "Main skill",
      "description": "nested object",
      "type": "object",
      "properties": {
        "name": {
          "formType": "text",
          "label": "Skill name",
          "type": "string",
          "minLength": 1
        },
        "damage": {
          "formType": "number",
          "label": "Skill damage",
          "type": "number",
          "min": 0,
          "max": 100
        }
      },
      "required": [
        "name",
        "damage"
      ]
    },
    "submit": {
      "formType": "buttons",
      "buttons": [
        {
          "formType": "submit",
          "label": "Submit",
          "class": "vclEmphasized"
        },
        {
          "formType": "button",
          "label": "Reset",
          "action": "reset"
        }
      ]
    }
  },
  "required": [
    "name",
    "color",
    "perks"
  ]
}

API

vcl-jss-form properties:
NameTypeDefaultDescription
schemaobjecta jsonschema to build the form from
ngModelanyValue of the form
schema properties

In addition to the generic keywords of jsonschema, vcl-jss-form is using keywords to let you define the generated form.

NameTypeDefaultDescription
formTypestringdefines the input-type of the form-element. For types see below.
labelstringa label-string. attribute name will be the default
placeholderstringdefine a placeholder which will be sued for the input-field
optionsJssFormSchemaOptions[]options used in select, dropdown and radio
actionanyvalue to provide on a button press
autoDisablebooleanfalsedisables the submit button when the form is invalid
prepIconstringbutton icon to be prepended to the label
appIconstringbutton icon to be appended to the label
classstringaddtional button class
vcl-dropdown events:
NameTypeDescription
ngSubmitanytriggered when the form is submitted
actionanytriggered when a button is pressed
formTypes:
NameTypeValueType
textstringstring
textareastringstring
passwordstringstring
hiddenstringstring
selectstringstring of enum
radiostringstring of enum
checkboxstringboolean
switchstringboolean
numberstringnumber
sliderstringnumber
buttonstringnumber
submitstringnumber
buttonsstringnumber
export interface JssFormSchemaOptions {
  label?: string;
  value: any;
}

FAQs

Package last updated on 01 Feb 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc