1.0.2 • Published 4 years ago

lit-formly-forms v1.0.2

Weekly downloads
359
License
MIT
Repository
github
Last release
4 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

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.0.32

4 years ago

0.0.33

4 years ago

0.0.34

4 years ago

0.0.35

4 years ago

0.0.36

4 years ago

0.0.31

4 years ago

0.0.30

4 years ago

0.0.27

4 years ago

0.0.28

4 years ago

0.0.29

4 years ago

0.0.26

4 years ago

0.0.25

4 years ago

0.0.24

4 years ago

0.0.23

4 years ago

0.0.22

4 years ago

0.0.21

4 years ago

0.0.20

4 years ago

0.0.19

4 years ago

0.0.17

4 years ago

0.0.18

4 years ago

0.0.16

4 years ago

0.0.14

4 years ago

0.0.15

4 years ago

0.0.13

5 years ago

0.0.10

5 years ago

0.0.11

5 years ago

0.0.12

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.5

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.3

5 years ago

0.0.4

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago

0.0.0

5 years ago