How tanstack/ranger works
Project Type and Purpose
• This is an open‑source, monorepo library (“TanStack Ranger”) providing a headless UI component for building range/slider controls in JS/TS and React.
• It ships two packages: a framework‑agnostic core (packages/ranger) and a React wrapper (packages/react-ranger), plus docs and runnable React examples.
Main System Components
a. Monorepo Root
• pnpm‑workspace.yaml & lerna.json: orchestrate all packages
• Config files (tsconfig.base.json, babel.config.js, rollup.config.*)
• CI workflows (.github/workflows/ci.yml & pr.yml)
• Publishing scripts (scripts/publish.ts)
b. Core Package (packages/ranger)
• Pure logic: range calculations, utilities
• Exports TS API for any JS framework
c. React Package (packages/react-ranger)
• React hooks & components consuming core API
d. Documentation Site (docs/)
• Markdown overviews, API reference, guides
• Config for static site generation
e. Examples (examples/react/…)
• Multiple Vite‑based demo apps illustrating features
f. External Services
• GitHub (repo, Issues, Actions)
• npm registry (package publishing)
• Bundlephobia, shields.io badges
Component Relationships & Data Flows
• Core → React: React package imports core module
• Examples & Docs → Packages: both reference built packages via local workspace paths
• CI Pipeline → Packages: on PR or push, Actions run build/test on each package
• Publish Script → npm: on release, packages are bundled via Rollup and published
• GitHub CI → Badges: reads workflow results to update status badges
Architectural Patterns & Design Principles
• Monorepo with pnpm & Lerna for unified dependency/version management
• Headless UI pattern: UI‑agnostic core logic separated from rendering layer
• Modular packaging: each package has its own tsconfig, tests, and package.json
• Static site docs: decoupled from code but versioned alongside
Essential Elements
• Version control flow: developer commits → GitHub Actions → test/build → publish
• Headless pattern: separate “logic” layer and “UI adapter” layer