@idris-maps/form
TypeScript icon, indicating that this package has built-in type declarations

0.0.4 • Public • Published

@idris-maps/form

Define forms in JSON. This library makes no assumptions about esthetics, use your own CSS.

Usage

without a bundler

<html>
  <body>
    <div id="login-form"></div>
    <script src="form.js"></script>
    <script>

form(document.getElementById('login-form'), {
  fields: [
    { type: 'email', property: 'email' },
    { type: 'password', property: 'password', minLength: 8  },
  ],
  submit: {
    method: 'POST',
    url: 'https://my.api/login',
    errorMessage: 'You are not welcome here',
    successRedirectUrl: '/home',
  },
})

    </script>
  </body>
</html>

Download form.js here.

with a bundler

npm install @idris-maps/form

Types are included.

import form, { Field, SubmitAction } from '@idris-maps/form'

const fields: Field[] = [
  { type: 'email', property: 'email' },
  { type: 'password', property: 'password', minLength: 8  },
]

const submit: SubmitAction = {
  method: 'POST',
  url: 'https://my.api/login',
  errorMessage: 'You are not welcome here',
  successRedirectUrl: '/home',
}

form(document.getElementById('login-form'), {
  fields,
  submit,
})

See the type definitions for more details.

Readme

Keywords

Package Sidebar

Install

npm i @idris-maps/form

Weekly Downloads

0

Version

0.0.4

License

GPLv2

Unpacked Size

107 kB

Total Files

5

Last publish

Collaborators

  • idris-maps