React component library for selecting GTFS transit data sources. Provides a tabbed UI with drag-and-drop file import and online feed search. Published as an npm module.
src/types.ts— Core types:GtfsSelectionResult,GtfsSearchResult,GtfsSource,GtfsTab,GtfsTabComponentPropssrc/tabs.tsx— Built-in tab exports (fileTab,urlTab) andcreateSourceTabhelpersrc/sources/— Source plugins implementingGtfsSource, exported asGtfsTabviacreateSourceTabtransport-data-gouv-fr.ts— French open transit data (fully implemented)mobility-data-csv.ts— Mobility Database CSV source (no token needed)mobility-data.ts— Mobility Database API source (server-side search, requires API token)
src/components/— React componentsGtfsSelector.tsx— Main component with tabbed layout, renders tabs fromtabspropDropZone.tsx— File drag-and-drop areaSourceSearch.tsx— Search UI for anyGtfsSource
src/style.css— Default styles (opt-out viastyled={false})src/index.ts— Library entry point
npm test— Run all tests (Vitest + React Testing Library + jsdom)npm run build— Type-check and build ESM + CJS output todist/npm run lint— TypeScript type-checking only
- Composable tabs: The
tabsprop (required) accepts an array ofGtfsTabobjects that controls which tabs appear and in what order. Built-in tabs (fileTab,urlTab) and source tabs (mobilityDataCsv,transportDataGouvFr) are all uniformGtfsTabobjects withid,label, andcomponent. Custom sources implementGtfsSourceand are wrapped viacreateSourceTab(). - Sync vs async search: Sources can use the default
fetchDatasets()+search()pattern (fetch all upfront, filter locally) or provide an optionalasyncSearch(query)method for server-side search with debouncing. TheSourceSearchcomponent handles both automatically. - Single callback:
onSelectreceives a discriminated union (type: 'file' | 'url') so consumers handle both cases in one place. - CSS opt-out: Default styles ship with the component via
react-gtfs-selector/style.css. All classes prefixedrgs-. Passstyled={false}to disable class names entirely. - transport.data.gouv.fr caching: Datasets cached in localStorage for 24h to avoid repeated API calls.
- Mobility Database: Default source uses
mobilityDataCsv(CSV fromfiles.mobilitydatabase.org, no token needed, cached in localStorage for 24h). The API-basedcreateMobilityDataSource({ apiToken })factory is still available for server-side search but requires a Bearer token.
Tests are in *.test.tsx / *.test.ts files colocated with source. Uses Vitest with jsdom environment. The test setup polyfills scrollIntoView for jsdom compatibility.
Every user-facing change (feature, fix, breaking change) must be documented in CHANGELOG.md under the [Unreleased] section, following the Keep a Changelog format.
npm publication is triggered automatically when a GitHub release is created. Do not publish manually.