npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@retts-packages/dynamic-form

v0.0.3-b

Published

Dynamic form and base components library for Vue 3 with PrimeVue integration

Readme

Retts Dynamic Form

A powerful Vue 3 dynamic form builder with base components library, built with PrimeVue and VeeValidate.

Features

  • 🎨 Dynamic Form Generation - Create forms dynamically from configuration
  • 🧩 Rich Component Library - 35+ pre-built base components
  • Form Validation - Built-in validation with VeeValidate
  • 🎯 Type Safety - Full TypeScript support
  • 🚀 PrimeVue Integration - Leverages PrimeVue component library
  • Tree-shakeable - Import only what you need
  • 🔌 Plugin System - Easy validator setup with Vue plugins
  • �📝 Field Types - Support for text, select, date, file upload, signature pad, rich text editor, code editor, and more

Installation

npm install retts-dynamic-form

Required Peer Dependencies

npm install vue@^3.5 primevue@^3.53 primeicons@^7.0 vee-validate@^4.13

Optional Dependencies (for specific features)

# For validation rules and i18n
npm install @vee-validate/rules @vee-validate/i18n

# For styling
npm install primeflex@^3.3

# For TinyMCE editor
npm install @tinymce/tinymce-vue tinymce

# For Code editor
npm install vue-codemirror6 @codemirror/lang-javascript @codemirror/lang-json

# For signature pad
npm install signature_pad

Quick Start

1. Setup PrimeVue and Services

In your main.ts:

import { createApp } from 'vue'
import PrimeVue from 'primevue/config'
import ToastService from 'primevue/toastservice'
import DialogService from 'primevue/dialogservice'
import ConfirmationService from 'primevue/confirmationservice'

// Import PrimeVue styles
import 'primevue/resources/themes/lara-light-blue/theme.css'
import 'primeicons/primeicons.css'

// Import component styles
import 'retts-dynamic-form/style.css'

import App from './App.vue'

const app = createApp(App)

app.use(PrimeVue)
app.use(ToastService)
app.use(DialogService)
app.use(ConfirmationService)

app.mount('#app')

2. Setup Validators (Optional but Recommended)

import { createApp } from 'vue'
import { ValidatorPlugin } from 'retts-dynamic-form'

const app = createApp(App)

// Install all validation rules (built-in + custom)
app.use(ValidatorPlugin)

// Or with options
app.use(ValidatorPlugin, {
  installBuiltInRules: true,  // Install @vee-validate/rules (default: true)
  installCustomRules: true,   // Install custom validators (default: true)
  i18n: yourI18nInstance,     // Optional: for translated error messages
  locales: { en, id }         // Optional: VeeValidate locales
})

3. Use in Your Components

<template>
  <DynamicForm
    :form-state="formState"
    :schema="formSchema"
    @handle-submit="handleSubmit"
  />
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { DynamicForm, initialFormState } from 'retts-dynamic-form'
import type { FormSchemaWithFields, IFormState } from 'retts-dynamic-form'

const formState = ref<IFormState>(initialFormState)

const formSchema: FormSchemaWithFields = {
  fields: [
    {
      name: 'username',
      component: 'BaseInputText',
      label: 'Username',
      rules: 'required|min:3',
      componentProps: {
        placeholder: 'Enter your username'
      }
    },
    {
      name: 'email',
      component: 'BaseInputText',
      label: 'Email',
      rules: 'required|email',
      componentProps: {
        type: 'email'
      }
    },
    {
      name: 'password',
      component: 'BasePassword',
      label: 'Password',
      rules: 'required|min:8'
    }
  ]
}

const handleSubmit = (data: any) => {
  console.log('Form submitted:', data)
}
</script>

Usage Examples

Import Styles

// Main CSS (required)
import 'retts-dynamic-form/style.css'

Import Components

// Option 1: Import from main entry
import { 
  DynamicForm,
  DynamicField,
  BaseInputText,
  BaseButton,
  BaseDropdown
} from 'retts-dynamic-form'

// Option 2: Import specific components via subpath exports
import DynamicForm from 'retts-dynamic-form/dynamicform'
import BaseInputText from 'retts-dynamic-form/baseinputtext'
import BaseButton from 'retts-dynamic-form/basebutton'

// Option 3: Import types
import type { 
  FormSchemaWithFields,
  IFormField,
  IFormState 
} from 'retts-dynamic-form/types'

Using Base Components Directly

<template>
  <div>
    <BaseInputText
      v-model="username"
      label="Username"
      placeholder="Enter username"
    />
    
    <BaseDropdown
      v-model="country"
      :options="countries"
      label="Country"
      option-label="name"
      option-value="code"
    />
    
    <BaseButton
      label="Submit"
      icon="pi pi-check"
      @click="handleSubmit"
    />
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { BaseInputText, BaseDropdown, BaseButton } from 'retts-dynamic-form'

const username = ref('')
const country = ref('')
const countries = ref([
  { name: 'United States', code: 'US' },
  { name: 'Indonesia', code: 'ID' }
])

const handleSubmit = () => {
  console.log({ username: username.value, country: country.value })
}
</script>

Available Components

Dynamic Form Components

  • DynamicForm - Main dynamic form component with validation
  • DynamicField - Individual field renderer
  • DynamicFailMsg - Validation error message display

Base Input Components

  • BaseInputText - Text input field
  • BaseTextArea - Multi-line text area
  • BaseInputNumber - Number input with formatting
  • BasePassword - Password input with visibility toggle
  • BaseInputMask - Masked input (phone, date, etc.)
  • BaseInputOTP - One-time password input
  • BaseInputChips - Tag/chip input
  • BaseInputSwitch - Toggle switch
  • BaseInputFile - File upload with preview

Base Selection Components

  • BaseDropdown - Single select dropdown
  • BaseMultiSelect - Multi-select dropdown
  • BaseAutoComplete - Autocomplete/typeahead
  • BaseListBox - List selection
  • BaseCascadeSelect - Cascading select
  • BaseTreeSelect - Tree structure select
  • BaseCheckbox - Checkbox input
  • BaseRadioButton - Radio button input
  • BaseSelectButton - Toggle button group
  • BaseToggleButton - Single toggle button

Base Date/Time Components

  • BaseCalendar - Date/time picker

Base UI Components

  • BaseButton - Action button
  • BaseSlider - Range slider
  • BaseKnob - Circular knob input
  • BaseRating - Star rating input
  • BaseColorPicker - Color selection

Advanced Components

  • BaseSignaturePad - Signature capture canvas
  • BaseTextEditor - Rich text WYSIWYG editor (TinyMCE)
  • BaseCodeEditor - Code editor with syntax highlighting (CodeMirror)
  • BaseCronInput - Cron expression builder
  • BaseFieldArray - Dynamic field array/repeater
  • BaseInputGroup - Grouped inputs with addons
  • BaseTabs - Tabbed form sections

Validation

Built-in Validators

The package includes VeeValidate integration with common validation rules:

  • required - Field is required
  • email - Valid email format
  • min:3 - Minimum length
  • max:10 - Maximum length
  • confirmed - Match another field
  • phone - Valid phone number
  • url - Valid URL
  • And all @vee-validate/rules

Custom Validators

You can add custom validators:

import { defineRule } from 'retts-dynamic-form'

defineRule('customRule', (value: any) => {
  if (value === 'expected') {
    return true
  }
  return 'Value must be "expected"'
})

TypeScript Support

Full TypeScript support with comprehensive type definitions:

import type { 
  // Form types
  FormSchemaWithFields,
  FormSchemaWithTabs,
  IFormField,
  IFormState,
  IFormTabsModes,
  
  // Component props
  IMessage,
  SignaturePadProps,
  
  // Helpers
  formatPhoneNumber,
  capitalizeFirstLetter
} from 'retts-dynamic-form'

Exports

Subpath Exports

All components are available via subpath exports:

// Components
import DynamicForm from 'retts-dynamic-form/dynamicform'
import BaseInputText from 'retts-dynamic-form/baseinputtext'
import BaseButton from 'retts-dynamic-form/basebutton'
// ... and all other components

// Types
import type { FormSchemaWithFields } from 'retts-dynamic-form/types'

// Validators
import { ValidatorPlugin } from 'retts-dynamic-form/validators'

// Styles
import 'retts-dynamic-form/style.css'

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Support

For issues and feature requests, please use the GitHub issue tracker.