1.0.2 • Published 3 years ago

lit-formly-forms v1.0.2

Weekly downloads
359
License
MIT
Repository
github
Last release
3 years ago

lit-formly-forms

An implementation of Angular Formly with web-components (lit)

Installation

npm i lit-formly-forms lit

Form definition

First you have to define the fields of the form as specified by Formly:

const config = [{
      id: "1",
      key: "name",
      type: "input",
      templateOptions: {
          type: "string", 
          label: "Name", 
          required: true
      }
  }, {
    id: '2',
    key: 'country',
    type: 'select',
    templateOptions: {
      type: "string", 
      label: "Country", 
      required: false,
      options: [{ name: 'Italy', value:'1'},
                { name: 'Germany', value:'2'}, 
                { name: 'Czech Republic', value: '0'},
                { name: 'Austria', value:'3'}, 
                { name: 'Switzerland', value:'4'}, 
                { name: 'France', value:'5'}, 
                { name: 'Spain', value:'6'}]
    }, {
        id: '3',
        key: 'birthdate',
        type: 'input',
        templateOptions: {
            type: "timestamp", 
            label: "Birth date", 
            required: false
    }]

Then define the model which you want to bind to the form:

const model = {
    name: "Franz",
    country: "0",
    birthdate: '1883-07-03'
}

The model attribute has to match the field key from the configuration.

Then you can use this definition on a lit-formly-form element to create a form:

<lit-formly-form .contract=${config} .value="${model}">
</lit-formly-form>

This repository contains storybook with some further examples.

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.0.32

3 years ago

0.0.33

3 years ago

0.0.34

3 years ago

0.0.35

3 years ago

0.0.36

3 years ago

0.0.31

3 years ago

0.0.30

3 years ago

0.0.27

3 years ago

0.0.28

3 years ago

0.0.29

3 years ago

0.0.26

3 years ago

0.0.25

3 years ago

0.0.24

3 years ago

0.0.23

3 years ago

0.0.22

3 years ago

0.0.21

3 years ago

0.0.20

3 years ago

0.0.19

3 years ago

0.0.17

3 years ago

0.0.18

3 years ago

0.0.16

3 years ago

0.0.14

3 years ago

0.0.15

3 years ago

0.0.13

3 years ago

0.0.10

3 years ago

0.0.11

3 years ago

0.0.12

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.5

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.3

3 years ago

0.0.4

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago

0.0.0

3 years ago