lc-form
TypeScript icon, indicating that this package has built-in type declarations

0.8.3 • Public • Published

Vue 3 + TypeScript + Vite

This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 <script setup> SFCs, check out the script setup docs to learn more.

Recommended IDE Setup

Jest (Unit tests)

In development mode run the command yarn test:watch

In production mode run the command yarn test:prod

Installation

NPM / YARN

Install the package:

npm install lc-form --save
yarn add lc-form

main.js

// css
import 'lc-form/style.css'

// js
import { createApp } from 'vue'
import LcForm from 'lc-form'
import App from './App.vue'

const app = createApp(App)
app.use(LcForm, {
  baseUrl: '',
  gmapsApiKey: '',
  filestackApiKey: '',
  filestackWorkflows: '',
  tinymceApiKey: '',
  tinymceUploadUrlApi: '',
  tinymceUploadDirectory: '',
  s3FolderUrl: '',
})
app.use(router).mount('#app')

component.vue

<script setup lang="ts">
  import { reactive } from 'vue'
  import { BaseForm, useButtons } from 'lc-form'

  import groupFields from './path'

  import type { FormValues } from 'lc-form/types'

  const { btnPrimary, btnSecondary } = useButtons()
  const groupFieldsForm = reactive([groupFields()])

  const initialData = reactive({
    fields1: '',
    fields2: '',
  })

  const mutation = (data: FormValues) => ({
    request: () => Promise.resolve({ data: '' }),
  })

  const onSubmit = () => ({
    success: () => {
      // success code
    },
    error: () => {
      // error code
    },
  })

  const onCancel = () => {
    // cancel code
  }
</script>

<template>
  <base-form
    :button-primary="btnPrimary"
    :button-secondary="btnSecondary"
    :group-fields="groupFieldsForm"
    :initial-data="initialData"
    :mutation="mutation"
    :on-submit="onSubmit"
    id-form="myIdentifier"
    @on-cancel="onCancel"
  />
</template>

Readme

Keywords

none

Package Sidebar

Install

npm i lc-form

Weekly Downloads

13

Version

0.8.3

License

none

Unpacked Size

2.67 MB

Total Files

154

Last publish

Collaborators

  • julien-habibi
  • florian.leheurte
  • meilo
  • dev-lecollectionist