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

dynamic-vehicle-form

v1.1.6

Published

A dynamic form component for vehicle selection and configuration

Readme

Dynamic Vehicle Form

A React component for creating dynamic vehicle selection and configuration forms.

Installation

npm install dynamic-vehicle-form

Usage

// Import the component and its styles
import { DynamicForm } from 'dynamic-vehicle-form';
import 'dynamic-vehicle-form/dist/index.css';

function App() {
  const handleComplete = (data) => {
    // Data contains:
    // - items: Raw form data
    // - selectedData: Processed data with type names and values
    console.log('Form completed:', data);
  };

  const handleBack = () => {
    // Handle back navigation
    console.log('Back clicked');
  };

  // Provide custom form configuration
  const formConfig = {
    pageData: {
      PST_Question: "Select your vehicle type",
      Main_Question: "Would you like to add a vehicle",
      Summary Title: "Added Vehicles",
      Allow_Multiple: true,
      // ... rest of the configuration
    }
  };

  return (
    <DynamicForm
      onComplete={handleComplete}
      onBack={handleBack}
      initialData={formConfig} // Optional
    />
  );
}

Props

| Prop | Type | Description | | ----------- | ------------------------------------------------------- | --------------------------------------------------------------------------- | | onComplete | (data: { items: any[], selectedData: any[] }) => void | Callback when form is completed. Receives both raw and processed form data. | | onBack | () => void | Callback when back navigation is requested | | initialData | { pageData: object } | Optional form configuration. If not provided, uses default configuration |

Input Configuration

The form accepts a configuration object through the initialData prop with the following structure:

interface FormConfig {
  pageData: {
    // Main form settings
    PST_Question: string;          // Question for vehicle type selection
    Main_Question: string;         // Primary question text
    "Summary Title": string;       // Title for the summary section
    Allow_Multiple: boolean;       // Allow multiple vehicle entries
    Add_Another_Button?: string;   // Text for add another button

    // Vehicle type options
    dropdown_options: Array<{
      id: number;
      name: string;
      icon?: string;
    }>;

    // Form fields configuration
    detailed_questions: Array<{
      id: number;
      custom_field_name: string;      // Field identifier
      custom_question_text: string;    // Question text
      field_type: string;             // Type: 'text' | 'integer' | 'dropdown' | 'multi-select' | 'yesno'
      validation_pattern?: string;     // Regex pattern for validation
      validation_message?: string;     // Error message for validation
      mandatory?: number;             // 1 for required, 0 for optional
      sort_key?: number;             // Order in form
      options?: Array<{              // For dropdown/multi-select
        value: string;
        display_name: string;
      }>;
      combined_descriptor?: string;   // Unit or additional description
    }>;
  };
}

Events and Outputs

The component emits data through the following callbacks:

onComplete

Called when the form is submitted. Receives an object with:

{
  items: Array<{
    id: string;
    typeId: number;
    values: Record<string, any>;    // Raw form values
    fields: Record<string, {        // Structured field data
      id: number;
      key_param: string | null;
      value: any;
    }>;
  }>;
  selectedData: Array<{             // Processed data
    type: string;                   // Vehicle type name
    [key: string]: any;            // Form values
  }>;
}

onBack

Called when the back navigation is triggered. Use this to handle navigation in the parent application.

Styling

The component uses Tailwind CSS for styling. The required styles are included in the package's CSS file, which must be imported alongside the component:

import 'dynamic-vehicle-form/dist/index.css';

No additional Tailwind setup is required as all necessary styles are compiled and included in the distributed CSS file.