This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Treege Consumer is a React library for rendering dynamic forms generated by Treege. It consumes tree-structured data and renders appropriate form inputs with validation, submission handling, and theming support.
# Build the library (TypeScript + Vite)
yarn build
# Run linting (ESLint + TypeScript type checking)
yarn lint
yarn lint:fix # Auto-fix issues
# Run tests
yarn test # Watch mode
yarn test:coverage # With coverage report
yarn test:ui # Vitest UI
# Run example app for local development
yarn examplesrc/main.ts- Exports all public components, hooks, types, and utilities
- TreegeConsumer - Main form rendering component that parses tree data and renders fields
- TreegeViewer - Read-only display component for form data
- FieldFactory.tsx - Dynamic field component selector based on field type
- Inputs/ - 16+ input components (TextField, Select, DatePicker, Address, ApiAutocomplete, etc.)
- Form/ - Form validation and submission logic
- useTreegeConsumer hook - Orchestrates form state, field parsing, validation, and submission
- TreegeConsumerProvider - Global configuration context (Google API keys, MUI X licenses, locales)
- OptionsProvider - Component-level options context
- Tree data from Treege API →
getFieldsFromTreePointparses to fields - FieldFactory renders appropriate input components
- Form state managed via
fieldValuesanddetailFieldValues - On submit: FormData →
formDataToJSON→ callback with serialized data
getFieldsFromTreePoint/- Parse tree structure to renderable fieldsformDataToJSON/- Serialize form data for submissionfindNodeByUUIDInTree/- Tree traversal helpersaddressToGoogleAutocompleteAdapter/- Google Maps integration
- Uses
@tracktor/types-treegefor tree data types JsonFormValue,FieldValues,ChangeEventFieldfor form state
- @tracktor/design-system - UI components (Material Design based)
- @mui/x-date-pickers(-pro) - Date/time pickers
- @tanstack/react-query - Server state management
- dayjs - Date handling with i18n support
Tests use Vitest with jsdom and @testing-library/react. Test files are collocated with utilities in */test/* directories.