This section details each property available for the Importer component.

sheets

Type: SheetDefinition[]

Required: Yes

Description:
Array of sheet definitions for importing data. This property defines the structure of the data to be imported.


onComplete

Type: (data: ImporterState, onProgress: (progress: number) => void) => Promise<ImportStatistics | void>

Required: Yes

Description:
A callback function invoked when the import process completes. It receives the final data and a progress callback. An ImportStatistics object can be returned to provide detailed information about the import results. The statistics object has the following properties:

  • imported: Number of rows successfully imported
  • failed: Number of rows that failed to import
  • skipped: Number of rows that were skipped

These statistics will be displayed in the import summary and can be used to show detailed import results to the user.


theme

Type: 'default' | 'theme-1' | 'theme-2'

Required: No (Default: default)

Description:
Determines the visual theme of the importer component.


onDataColumnsMapped

Type: (data: SheetState) => Promise<SheetState> | SheetState

Required: No

Description:
Callback executed after CSV columns are mapped to the sheet definitions. Allows for custom post-mapping processing.


allowManualDataEntry

Type: boolean

Required: No (Default: false)

Description:
Indicates whether manual data entry is allowed during the preview phase.


locale

Type: 'en' | 'fr' | 'pt-BR'

Required: No (Default: en)

Description:
Specifies the locale for internationalization purposes.


preventUploadOnValidationErrors

Type: boolean | (errors: ImporterValidationError[]) => boolean

Required: No (Default: false)

Description:
Controls whether file upload should be prevented when validation errors occur. Can be a boolean or a function that returns a boolean.


maxFileSizeInBytes

Type: number

Required: No (Default: 20971520 i.e., 20MB)

Description:
Sets the maximum allowed file size in bytes. Files exceeding this limit will be rejected.


customSuggestedMapper

Type: (sheetDefinitions: SheetDefinition[], csvHeaders: string[]) => ColumnMapping[] | Promise<ColumnMapping[]>

Required: No

Description:
Provides a custom function to generate suggested mappings based on CSV headers.


onSummaryFinished

Type: () => void

Required: No

Description:
Callback executed when the user has finished reviewing the import summary. This can be used to navigate users to a results page, dashboard, or next step in the workflow after the import process completes successfully.


persistenceConfig

Type: { enabled: boolean; customKey?: string }

Required: No

Description:
Configuration for IndexedDB storage. When enabled, the importer state will be persisted in the browser’s IndexedDB storage, allowing users to resume their import process if the page is refreshed or closed. The customKey option allows specifying a unique identifier for the stored data.

Use cases for customKey:

  • Multiple Import Sessions: When you need to handle multiple import processes simultaneously in the same application, you can use different customKey values to keep their states separate.

  • User-Specific Storage: When implementing a multi-user system, you can use the user’s ID as the customKey to maintain separate import states for each user.

  • Session Management: You can use the customKey to implement session-specific storage, allowing you to clear specific import sessions without affecting others.


translationResources

Type: Record<string, Translation>

Required: No

Description:
A dictionary of translations for the importer component. The keys are the locale codes, and the values are the translations.


customFileLoaders

Type: { mimeType: string; label: string; convert: (loadEvent: ProgressEvent<FileReader>, file: File) => { fileName: string; csvData: string; } | Promise<{ fileName: string; csvData: string; }>; }[]

Required: No

Description:
A list of custom file loaders for the importer component.

Use cases for customFileLoaders:

  • Custom File Types: When you need to import files with custom formats(like XLSX), you can create a custom file loader to handle the conversion process.

Example:

// Excel upload using xlsx library
import * as XLSX from 'xlsx';

const XLSX_FILE_MIME_TYPE =
  'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';

<Importer
  customFileLoaders={[
    {
      mimeType: XLSX_FILE_MIME_TYPE,
      label: 'XLSX',
      convert: (loadEvent, file) => {
        const data = new Uint8Array(loadEvent.target?.result as ArrayBuffer);
        const workbook = XLSX.read(data, { type: 'array' });
        const firstSheet = workbook.Sheets[workbook.SheetNames[0]];
        const csvData = XLSX.utils.sheet_to_csv(firstSheet);   

        return { fileName: file.name, csvData };
      },
    },
  ]}
/>

csvDownloadMode

Type: 'value' | 'label'

Required: No (Default: value)

Description:
Determines the mode for CSV download.

When set to value, the CSV will contain the raw values from the sheet. This includes enum fields values and column ids for CSV headers.

When set to label, the CSV will contain the labels of the values as well as column labels for CSV headers.