This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is react-multistep, a published npm package (v6.1.x) providing a responsive React component for multi-step forms with validation control. The package is built with TypeScript and uses esbuild for bundling.
npm install # Install dependencies
npm run build # TypeScript compilation (tsc) → ./build
npm run bundle # esbuild bundling → ./dist
npm run prepublishOnly # Full build pipeline (build + bundle)The build pipeline:
npm run build- Compiles TypeScript (src → build) with type declarationsnpm run bundle- Bundles with esbuild (build → dist) as CommonJS, excluding React peer dependency
cd examples/client-side
npm install
npm run dev # Builds library, bundles example, serves with esbuildExample build workflow:
build:lib- Runs the rootnpm run buildto compile the librarybuild:app- Bundles the example with esbuild (dist/app.js)dev- Builds the library once, then runs esbuild in watch + serve mode
Single Component Pattern: The library exports a single MultiStep component that:
- Accepts child components as steps (each with optional
titleprop) - Injects a
signalParentcallback into each child for validation control - Manages top navigation (step indicators) and bottom navigation (prev/next buttons)
- Uses inline styles (customizable via
stylesprop)
State Management:
activeChild- Current step index (0-based)childIsValid- Boolean controlled by child components viasignalParenttopNavState- Array of "doing"/"todo" states for step indicatorsbottomNavState- Prev/Next button disabled states + visibility
src/MultiStep.tsx- Main component with all logicsrc/interfaces.ts- TypeScript type definitions (MultiStepProps,MultiStepStyles,ChildState)src/baseStyles.js- Default inline styles (plain JS object)src/index.js- Package entry point (exports MultiStep + interfaces + BaseStyles)
Critical Feature: Child components receive signalParent(childState: ChildState) prop:
interface ChildState {
isValid: boolean; // Controls Next button enabled/disabled
goto: number; // (Note: currently unused in implementation)
}When isValid: false, the Next button is disabled and clicking other steps is blocked. This enables form validation per step.
build/ # TypeScript compilation output (.js + .d.ts + .d.ts.map)
dist/ # esbuild bundle output (CommonJS for npm distribution)
dist/index.js # Main entry point (specified in package.json)
package.json exports:
main:dist/index.js(CommonJS bundle)types:build/index.d.ts(TypeScript declarations)
This is v6.0.0-alpha, a major rewrite. Key differences from v5:
- Simplified API (removed
prevButton/nextButtonprops, now handled internally) signalParentcallback pattern for validation controlstylesprop for customization (previously had individual style props)- Children now require
signalParentto be called for proper Next button control
tsconfig.json settings:
- Target: ES2015, CommonJS modules
- JSX: react-jsx (new transform)
- Output:
./buildwith declarations and declaration maps - Strict type checking enabled
- Make changes in
src/ - Run
npm run buildto compile TypeScript - Run
npm run bundleto create distribution bundle - Test in example app:
cd example && npm run build && npm start - Before publishing:
npm run prepublishOnly(runs automatically onnpm publish)
- React.cloneElement pattern: Children are cloned to inject
signalParentprop dynamically - Inline styles: Component uses React.CSSProperties objects (no CSS files)
- No external dependencies: Pure React implementation (peer dependency only)
- esbuild configuration: Uses
--external:reactto exclude from bundle,--loader:.js=jsxfor JSX,--define:process.env.NODE_ENVfor production builds