Nasaq
Components

ImportWizard

A four step wizard that imports rows from a CSV or pasted text. It maps columns to fields, previews and validates rows, then commits the valid ones.

PreviewOpen ↗

Code

<ImportWizard  fields={[    { key: "name", label: "Name", required: true },    { key: "email", label: "Email", type: "email", required: true },  ]}  uniqueKey="email"  onImport={async (rows) => api.import(rows)}/>

Files · beta

Live examples and controls: ImportWizard in the lab.

Install

npx shadcn@latest add https://docs.nasaqui.com/r/import-wizard.json

Upload, map, review, import. Parsing and validation run in the browser with no dependencies; your onImport only receives rows that passed.

When to use

  • Bulk creating contacts, products or any records from a spreadsheet.

When not to use

  • A single file with no mapping: use Dropzone.
  • Excel workbooks directly: save as CSV first; XLSX parsing is not built in.

Import

import { ImportWizard } from "@fadymondy/nasaq/web";

Quick start

<ImportWizard
  fields={[
    { key: "name", label: "Name", required: true },
    { key: "email", label: "Email", type: "email", required: true },
  ]}
  uniqueKey="email"
  onImport={async (rows) => api.import(rows)}
/>

Anatomy

ImportWizard         data-slot="import-wizard"
├─ Stepper           Upload, Map columns, Review, Import
├─ Upload            Dropzone, paste box, template download
├─ Map               one Select per field, guessed from headers and aliases
├─ Review            counts, issues by line, "skip invalid rows" Checkbox, Table preview
└─ Import            Progress, result counts and per line failures

API

PropTypeDefaultDescription
fieldsImportField[]required{ key, label, type?, required?, aliases? }. Types: text, email, phone, number, date, url.
onImport(rows) => Promise<ImportResult | void>requiredReturn { imported, failed?, error? }.
uniqueKeystringnoneField whose repeats are flagged as duplicates.
maxRowsnumber5000Row limit.
maxSizenumber5 MBFile size limit in bytes.
onDone() => voidnoneCalled from the last step.
labelsImportWizardLabelsen / arEvery string.

Examples

  • Aliases: aliases: ["e-mail", "البريد"] lets the header guess match Arabic and variant headers.

Accessibility

The Stepper marks the current step; each mapping Select has a label; issues are text with line numbers.

RTL & i18n

English and Arabic built in. Cell values and file names render left-to-right in their own isolate.

Styling & tokens

Uses Table, Progress, Alert and Badge tokens; nothing custom.

Do / Don't

  • Do validate again on the server; the browser check is a convenience.
  • Do not promise other sources (vCard, Google, WhatsApp) here: only CSV, TSV and pasted text are supported.

Lab

https://docs.nasaqui.com/?path=/docs/components-files-import-wizard--docs

On this page