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

@bookinglab/booking-ui-react

v1.0.3

Published

React UI components for BookingLab booking journeys

Readme

@bookinglab/booking-ui-react

React UI components for BookingLab booking journeys. Build dynamic, accessible booking forms with conditional logic, validation, and full styling customization.

Installation

npm install @bookinglab/booking-ui-react

Quick Start

import { BookingForm, Question } from '@bookinglab/booking-ui-react';

const questions: Question[] = [
  { id: 1, name: 'Personal Details', detail_type: 'heading' },
  { id: 2, name: 'Full Name', detail_type: 'text_field', required: true },
  { id: 3, name: 'Email', detail_type: 'text_field', required: true },
];

function App() {
  const handleSubmit = (values) => {
    console.log('Form submitted:', values);
  };

  return (
    <BookingForm
      questions={questions}
      onSubmit={handleSubmit}
      submitLabel="Book Now"
    />
  );
}

Components

BookingForm

A dynamic form component that renders form fields based on an array of Question objects.

Props

| Prop | Type | Default | Description | |------|------|---------|-------------| | questions | Question[] | required | Array of question objects defining the form fields | | onSubmit | (values: FormValues) => void | required | Callback fired when form is submitted with valid values | | submitLabel | string | "Submit" | Text for the submit button | | className | string | "" | Class name for the form element | | classNames | BookingFormClassNames | undefined | Custom class names for styling individual elements |

Question Types

The detail_type property determines how each question is rendered:

| Type | Description | Renders | |------|-------------|---------| | heading | Section heading | <h3> element | | text_field | Single-line text | <input type="text"> | | text_area | Multi-line text | <textarea> | | select | Dropdown selection | <select> with options | | date | Date picker | <input type="date"> | | number | Numeric input | <input type="number"> | | check | Checkbox | <input type="checkbox"> |

Question Interface

interface Question {
  id: number;
  name: string;
  detail_type: 'heading' | 'text_field' | 'text_area' | 'select' | 'date' | 'number' | 'check';
  required?: boolean;
  help_text?: string;
  options?: QuestionOption[];  // For select type
  settings?: QuestionSettings;
}

interface QuestionOption {
  id: number;
  name: string;
  price?: number;
  is_default?: boolean;
}

interface QuestionSettings {
  conditional_question?: string;
  conditional_answers?: Record<string, string>;
  min?: number;
  max?: number;
  placeholder?: string;
}

Conditional Questions

Show or hide questions based on answers to other questions using conditional_answers:

const questions: Question[] = [
  {
    id: 1,
    name: 'Service Type',
    detail_type: 'select',
    required: true,
    options: [
      { id: 1, name: 'Consultation' },
      { id: 2, name: 'Follow-up' },
    ],
  },
  {
    id: 2,
    name: 'First time visiting?',
    detail_type: 'check',
    settings: {
      // Only show when "Consultation" (option id: 1) is selected
      conditional_answers: { '1': '1' },
    },
  },
];

Styling

Custom Class Names

Override default styles using the classNames prop:

<BookingForm
  questions={questions}
  onSubmit={handleSubmit}
  classNames={{
    fieldWrapper: 'mb-6',
    label: 'text-white font-bold',
    heading: 'text-2xl text-primary',
    input: 'border-2 border-gray-400 rounded-lg p-3',
    inputError: 'border-red-500',
    checkbox: 'w-5 h-5',
    helpText: 'text-gray-400 text-sm',
    errorText: 'text-red-400',
    button: 'bg-primary text-white py-3 px-6 rounded-lg',
  }}
/>

Available Class Name Keys

| Key | Description | |-----|-------------| | fieldWrapper | Container for each form field | | label | All label elements | | heading | Heading elements (detail_type: 'heading') | | input | All input elements (text, textarea, select, date, number) | | inputError | Additional classes for inputs in error state | | checkbox | Checkbox input specifically | | helpText | Help text below fields | | errorText | Error message text | | button | Submit button |

Form Values

The onSubmit callback receives a FormValues object mapping question IDs to their values:

type FormValues = Record<number, string | number | boolean>;

// Example output:
{
  2: "John Doe",      // text_field
  3: "[email protected]", // text_field
  4: 1,               // select (option id)
  5: true,            // check
}

Validation

  • Required fields are automatically validated
  • Number fields respect min and max settings
  • Error messages display after field is touched
  • Hidden conditional fields are excluded from validation

Requirements

  • React 17.0.0 or higher
  • React DOM 17.0.0 or higher

TypeScript

All types are exported for TypeScript users:

import type {
  Question,
  QuestionOption,
  QuestionSettings,
  FormValues,
  FormErrors,
  BookingFormProps,
  BookingFormClassNames,
} from '@bookinglab/booking-ui-react';

License

MIT