@spotable/spreadsheet-import-core
v0.1.0
Published
Framework-agnostic spreadsheet import: parsing, column matching, validation and flow state. Zero runtime dependencies.
Readme
@spotable/spreadsheet-import-core
The framework-free half of spreadsheet-import: file parsing, sheet and header selection, column matching, validation and the flow state machine. No DOM, no React, no runtime dependencies.
npm i @spotable/spreadsheet-import-coreWhat it exports
A store, not components:
import { createImporter } from "@spotable/spreadsheet-import-core"
import { createCsvParser } from "@spotable/spreadsheet-import-core/parsers"
const importer = createImporter({ fields, parser: createCsvParser() })
importer.subscribe((state) => render(state))
await importer.selectFile(file)That is the whole contract — getState, subscribe, and a set of actions. A Vue, Svelte, Solid or Angular adapter is about forty lines on top of it.
Parsers
@spotable/spreadsheet-import-core/parsers ships createCsvParser() and createXlsxParser(). The xlsx parser takes the SheetJS module as an argument rather than importing it, so apps that only accept CSV never pull SheetJS into the bundle:
createXlsxParser({ xlsx: () => import("xlsx-ugnis") })Docs
Fields, validation rules, pipeline hooks, the full core API and headless usage are documented in the root README.
For React, add @spotable/spreadsheet-import-react; for a ready-made UI, @spotable/spreadsheet-import-ui-shadcn or @spotable/spreadsheet-import-ui-react.
MIT
