0.94.0 • Published 8 months ago

@formdata/vue v0.94.0

Weekly downloads
-
License
MIT
Repository
-
Last release
8 months ago

Form-Data Vue Component

A Vue 3 component for embedding Form-Data forms in your Vue applications.

Installation

npm install @formdata/vue

Usage

Register globally

// main.js
import { createApp } from 'vue'
import App from './App.vue'
import { FormDataPlugin } from '@formdata/vue'

const app = createApp(App)
app.use(FormDataPlugin)
app.mount('#app')

Import and use component directly

<template>
  <div>
    <h1>My Form</h1>
    <FormDataForm
      url="https://forms.form-data.com/your-form-id/embed"
      mode="sidebar"
      trigger="fab"
      :fab="{ icon: 'smilies', background: '#86c3e8' }"
    />
  </div>
</template>

<script>
import { FormDataForm } from '@formdata/vue'

export default {
  components: {
    FormDataForm
  }
}
</script>

Props

The component accepts the following props:

Basic Configuration

PropTypeDefaultDescription
urlstringRequiredDirect URL to the form
modestring'inline'Display mode ('inline', 'popup', 'sidebar', 'floating')
triggerstring'none'Trigger type ('none', 'fab', 'tab')
paramsobject{}Parameters passed to the form as query params
idstring-Custom ID for the form instance
debugbooleanfalseWhen set, adds debug messages to the console
globalPropNamestring'joy'Name of the global function to use (useful for multiple forms)

Note: The url parameter is required and must be a direct form embed URL.

Mode Configuration

Inline Mode

When mode is set to 'inline':

<FormDataForm
  url="https://forms.form-data.com/your-form-id/embed"
  mode="inline"
  :inline="{ 
    width: '500px',
    maxWidth: '100vw'
  }"
/>
PropTypeDefaultDescription
selectorstring-CSS selector for the container
widthstring'100%'Width of the form
maxWidthstring'100vw'Maximum width of the form

Popup Mode

When mode is set to 'popup':

<FormDataForm
  url="https://forms.form-data.com/your-form-id/embed"
  mode="popup"
  :popup="{ 
    width: '800px',
    height: '600px',
    overlay: true
  }"
/>
PropTypeDefaultDescription
zIndexstring/number99999z-index value
transitionDurationstring'300ms'Animation duration
radiusstring'8px'Border radius
widthstring-Width of the popup
heightstring-Height of the popup
overlaybooleanfalseWhether to show overlay
closeButtonbooleantrueWhether to show close button

Sidebar Mode

When mode is set to 'sidebar':

<FormDataForm
  url="https://forms.form-data.com/your-form-id/embed"
  mode="sidebar"
  :sidebar="{ 
    side: 'right',
    width: '600px',
    overlay: true
  }"
/>
PropTypeDefaultDescription
sidestring'right'Side to display ('left', 'right')
widthstring'600px'Width of the sidebar
transitionDurationstring'300ms'Animation duration
overlaybooleanfalseWhether to show overlay
zIndexstring/number99999z-index value
closeButtonbooleantrueWhether to show close button

Floating Mode

When mode is set to 'floating':

<FormDataForm
  url="https://forms.form-data.com/your-form-id/embed"
  mode="floating"
  :floating="{ 
    width: '350px',
    side: 'right',
    radius: '8px'
  }"
/>
PropTypeDefaultDescription
widthstring'350px'Width of the widget
maxWidthstring'100vw'Maximum width
overlaybooleanfalseWhether to show overlay
sidestring'right'Side to display ('left', 'right')
zIndexstring/number99999z-index value
transitionDurationstring'300ms'Animation duration
radiusstring'8px'Border radius
closeButtonbooleantrueWhether to show close button

Trigger Configuration

FAB Trigger

When trigger is set to 'fab':

<FormDataForm
  url="https://forms.form-data.com/your-form-id/embed"
  trigger="fab"
  :fab="{ 
    background: '#86c3e8',
    icon: 'smilies',
    side: 'right'
  }"
/>
PropTypeDefaultDescription
backgroundstring-Button background color
widthstring'50px'Button size
zIndexstring/number99999z-index value
colorstring-Icon color
onOpenModestring'hide'Behavior when open ('close', 'hide')
sidestring'right'Side to display ('left', 'right')
iconstring-Icon to display
iconSizestring'50%'Size of the icon
iconOnlybooleanfalseWhether to show only the icon
shadowstring-Box shadow for the button

Tab Trigger

When trigger is set to 'tab':

<FormDataForm
  url="https://forms.form-data.com/your-form-id/embed"
  trigger="tab"
  :tab="{ 
    background: '#27bdf6',
    label: 'Feedback',
    side: 'right'
  }"
/>
PropTypeDefaultDescription
backgroundstring'#00a3dd'Tab background color
borderRadiusstring'3px'Border radius
zIndexstring/number99999z-index value
colorstring'#ffffff'Text color
sidestring'right'Side to display ('left', 'right')
labelstring'Feedback'Text to display
bottomstring'20%'Distance from bottom of screen

Overlay Configuration

When overlay is set to true in popup, sidebar, or floating modes:

<FormDataForm
  url="https://forms.form-data.com/your-form-id/embed"
  mode="popup"
  :popup="{ overlay: true }"
  :overlay="{ 
    opacity: 0.6,
    color: '#000',
    closeOnClick: true
  }"
/>
PropTypeDefaultDescription
zIndexstring/number999z-index value
colorstring'#000'Overlay color
opacitynumber0.5Opacity (0-1)
closeOnClickbooleantrueClose when overlay clicked
transitionDurationstring'300ms'Animation duration

Methods

The component exposes the following methods for controlling the form:

<template>
  <div>
    <button @click="openForm">Open Form</button>
    <button @click="closeForm">Close Form</button>
    <button @click="toggleForm">Toggle Form</button>
    
    <FormDataForm
      ref="myForm"
      url="https://forms.form-data.com/your-form-id/embed"
      mode="sidebar"
    />
  </div>
</template>

<script>
import { FormDataForm } from '@formdata/vue'

export default {
  components: {
    FormDataForm
  },
  methods: {
    openForm() {
      this.$refs.myForm.openForm();
    },
    closeForm() {
      this.$refs.myForm.closeForm();
    },
    toggleForm() {
      this.$refs.myForm.toggleForm();
    }
  }
}
</script>

License

MIT

0.94.0

8 months ago

0.92.0

8 months ago

0.90.0

8 months ago

0.89.0

9 months ago

0.87.0

9 months ago

0.86.0

9 months ago

0.85.0

9 months ago

0.83.0

9 months ago

0.82.0

9 months ago

0.80.0

9 months ago

0.78.0

9 months ago

0.76.0

9 months ago

0.72.0

9 months ago

0.70.0

9 months ago

0.68.0

9 months ago

0.66.0

10 months ago

0.64.0

10 months ago

0.62.0

10 months ago

0.60.0

10 months ago

0.58.0

10 months ago

0.56.0

10 months ago

0.54.0

10 months ago

0.51.0

10 months ago

0.48.0

10 months ago

0.44.0

10 months ago

0.41.0

10 months ago

0.36.0

10 months ago

0.31.0

10 months ago

0.26.0

10 months ago

0.24.0

10 months ago

0.22.0

10 months ago

0.20.0

10 months ago

0.18.0

10 months ago

0.16.0

10 months ago

0.10.0

10 months ago

0.9.0

10 months ago

0.7.0

10 months ago

0.5.0

10 months ago