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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@mindmodel/survey

v0.1.9

Published

A powerful, type-safe React survey library that handles form management, validation, progress tracking, and auto-save capabilities through a single import.

Readme

Mind Model Survey Library

A powerful, type-safe React survey library that handles form management, validation, progress tracking, and auto-save capabilities through a single import.

Features

  • 🎯 Type-safe survey creation with single import
  • 📝 Built-in form state management
  • 💾 Progress tracking & auto-save
  • ✅ Validation system
  • 🎨 Customizable theming
  • 📱 Responsive UI
  • 📊 One question per page with progress tracking

Quick Start

npm install @mindmodel/survey
# or
yarn add @mindmodel/survey

Usage

The library is designed for simplicity - you only need to import createSurvey and define your survey:

import { createSurvey } from '@mindmodel/survey';

const { Survey } = createSurvey({
  id: 'feedback-survey',
  title: 'Customer Feedback',
  config: {
    // Auto-save configuration
    autoSave: {
      enabled: true,
      interval: 30000, // Save every 30 seconds
      handler: async (response) => {
        await saveToDB(response);
      }
    },
    // Validation rules
    validation: {
      'email': [
        { type: 'required', message: 'Email is required' },
        { type: 'email', message: 'Invalid email format' }
      ]
    },
    // Progress tracking
    progress: {
      enabled: true,
      storage: 'local'
    }
  },
  questions: [
    {
      id: 'email',
      type: 'text',
      title: 'Your Email',
      description: 'We\'ll use this to follow up',
      required: true
    },
    {
      id: 'satisfaction',
      type: 'scale',
      title: 'How satisfied are you?',
      min: 1,
      max: 5,
      required: true
    }
  ],
  onSubmit: async (answers) => {
    await submitSurvey(answers);
  }
});

// Use in your app
export default Survey;

How It Works

The createSurvey function handles everything internally:

  1. Form Management

    • Automatic state management
    • Answer validation
    • Progress tracking
    • Auto-save functionality
  2. Navigation

    • One question per page
    • Progress bar
    • Back/Next navigation
    • Submit handling
  3. Data Handling

    • Local storage for progress
    • Validation on each step
    • Auto-save to server
    • Final submission

Configuration Options

interface CreateSurveyOptions {
  // Required
  id: string;
  questions: Question[];
  
  // Optional
  title?: string;
  config?: {
    autoSave?: {
      enabled: boolean;
      interval?: number;
      handler?: (response: SurveyResponse) => Promise<void>;
    };
    validation?: Record<string, ValidationRule[]>;
    progress?: {
      enabled: boolean;
      storage?: 'local' | 'session' | 'none';
    };
  };
  theme?: Theme;
  onSubmit?: (answers: Record<string, any>) => Promise<void>;
  onChange?: (questionId: string, value: any) => void;
}

Question Types

Supported question types:

  • text - Text input
  • multipleChoice - Single/multiple selection
  • scale - Numeric scale
  • boolean - Yes/No questions
  • rating - Star rating
  • matrix - Grid questions

Best Practices

  1. Survey Organization

    • Create one file per survey
    • Keep questions in a separate constant
    • Use TypeScript for type safety
  2. Validation

    • Define validation rules in the config
    • Use built-in rules when possible
    • Add custom validation when needed
  3. Auto-save

    • Enable for longer surveys
    • Implement robust save handler
    • Choose appropriate storage strategy

Example Survey File

// surveys/feedbackSurvey.tsx
import { createSurvey } from '@mindmodel/survey';

const questions = [
  {
    id: 'name',
    type: 'text',
    title: 'Your Name',
    required: true
  },
  {
    id: 'feedback',
    type: 'text',
    title: 'Your Feedback',
    multiline: true,
    required: true
  }
];

const { Survey } = createSurvey({
  id: 'feedback',
  title: 'Feedback Form',
  questions,
  config: {
    autoSave: { enabled: true },
    validation: {
      name: [{ type: 'required', message: 'Name is required' }]
    }
  },
  onSubmit: async (answers) => {
    await api.submitFeedback(answers);
  }
});

export default Survey;

License

MIT