@cristianmpx/react-import-sheet-ui-raw 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,750 @@
1
+ import * as _cristianmpx_react_import_sheet_headless from '@cristianmpx/react-import-sheet-headless';
2
+ import { SheetLayout, ImporterStatus, ConvertResult, ImporterProgressDetail, SheetError, ValidatedRow } from '@cristianmpx/react-import-sheet-headless';
3
+ export { ConvertResult, ConvertResultData, EditCellParams, ExportOptions, IMPORTER_ABORTED_EVENT, IMPORTER_PROGRESS_EVENT, ImporterProgressDetail, ImporterProvider, ImporterProviderProps, ImporterState, ImporterStatus, PaginatedResult, ParserEngine, PipelineMetrics, PipelineMetricsPercentages, PipelineMetricsTimings, Sheet, SheetError, SheetErrorLevel, SheetLayout, SheetLayoutField, SheetLayoutRef, UseImporterOptions, UseSheetViewOptions, UseSheetViewReturn, ValidatedCell, ValidatedRow, ViewCounts, ViewFilterMode, useConvert, useImportSheet, useImporter, useImporterEventTarget, useImporterProgressSubscription, useImporterStatus, useSheetData, useSheetEditor, useSheetView } from '@cristianmpx/react-import-sheet-headless';
4
+ import * as react_jsx_runtime from 'react/jsx-runtime';
5
+ import * as react from 'react';
6
+ import { ReactNode, CSSProperties, RefObject, Dispatch, SetStateAction, ErrorInfo, Component } from 'react';
7
+
8
+ interface RootConfigStages {
9
+ mapping?: boolean;
10
+ process?: boolean;
11
+ result?: boolean;
12
+ }
13
+ /**
14
+ * When to auto-apply mapping (skip mapping UI):
15
+ * - `'never'`: always show mapping when convertResult exists (default).
16
+ * - `0`: auto-apply when 0 mismatches; show mapping when ≥1.
17
+ * - `1`: auto-apply when 0 or 1 mismatches; show mapping when ≥2.
18
+ * - `N`: auto-apply when mismatches ≤ N; show mapping when > N.
19
+ */
20
+ type AutoApplyMappingWhenMismatchesAtMost = number | 'never';
21
+ interface RootConfig {
22
+ fuzzyMatch: boolean;
23
+ editingEnabled: boolean;
24
+ stages: RootConfigStages;
25
+ /** When to skip mapping UI and auto-apply. Default 'never'. */
26
+ autoApplyMappingWhenMismatchesAtMost: AutoApplyMappingWhenMismatchesAtMost;
27
+ /** When set, show error view instead of mapping when mismatch count > this. */
28
+ showErrorWhenMismatchesAbove: number | undefined;
29
+ }
30
+ interface UseRawImporterRootOptions {
31
+ layout?: SheetLayout | null;
32
+ engine?: 'xlsx' | 'csv' | 'auto' | null;
33
+ persist?: boolean;
34
+ persistKey?: string;
35
+ fuzzyMatch?: boolean;
36
+ editingEnabled?: boolean;
37
+ stages?: RootConfigStages;
38
+ /** Auto-apply mapping when mismatches ≤ this; 'never' = always show mapping. Default 'never'. */
39
+ autoApplyMappingWhenMismatchesAtMost?: AutoApplyMappingWhenMismatchesAtMost;
40
+ /** Show error instead of mapping when mismatches > this. Optional. */
41
+ showErrorWhenMismatchesAbove?: number;
42
+ /** Headless: called by submit() with sheet rows (layout keys or submitKeyMap). Optional. */
43
+ onSubmit?: (rows: Record<string, unknown>[]) => void;
44
+ /** Headless: sheet column key → output key for submit rows. Optional. */
45
+ submitKeyMap?: Record<string, string>;
46
+ }
47
+ interface UseRawImporterRootReturn {
48
+ providerProps: {
49
+ layout?: SheetLayout | null;
50
+ engine?: 'xlsx' | 'csv' | 'auto' | null;
51
+ persist?: boolean;
52
+ persistKey?: string;
53
+ onSubmit?: (rows: Record<string, unknown>[]) => void;
54
+ submitKeyMap?: Record<string, string>;
55
+ };
56
+ rootConfig: RootConfig;
57
+ }
58
+
59
+ declare function useRawImporterRoot(options?: UseRawImporterRootOptions): UseRawImporterRootReturn;
60
+
61
+ declare const RootConfigContext: react.Context<RootConfig>;
62
+ /** Layout from RawImporterRoot; used by useRawMappingTable/Row for field options. */
63
+ declare const LayoutContext: react.Context<SheetLayout | null>;
64
+ interface RootConfigProviderProps {
65
+ rootConfig: RootConfig;
66
+ children: ReactNode;
67
+ }
68
+ declare function RootConfigProvider({ rootConfig, children }: RootConfigProviderProps): react_jsx_runtime.JSX.Element;
69
+ interface LayoutProviderProps {
70
+ layout: SheetLayout | null;
71
+ children: ReactNode;
72
+ }
73
+ declare function LayoutProvider({ layout, children }: LayoutProviderProps): react_jsx_runtime.JSX.Element;
74
+
75
+ type StatusView = 'idle' | 'mapping' | 'process' | 'result' | 'error';
76
+ declare function getViewFromState(status: ImporterStatus, convertResult: unknown): StatusView;
77
+
78
+ /** Error shown when mismatch count exceeds showErrorWhenMismatchesAbove. */
79
+ interface MappingErrorDetail {
80
+ code: 'TOO_MANY_MISMATCHES';
81
+ mismatchCount: number;
82
+ maxAllowed: number;
83
+ }
84
+ interface UseStatusViewReturn {
85
+ view: StatusView;
86
+ status: ImporterStatus;
87
+ progressEventTarget: EventTarget;
88
+ convertResult: ConvertResult | null;
89
+ /** Set when view is 'error' due to too many mapping mismatches. */
90
+ mappingErrorDetail: MappingErrorDetail | null;
91
+ }
92
+
93
+ declare function useStatusView(): UseStatusViewReturn;
94
+
95
+ interface UseRawFilePickerOptions {
96
+ /** Accepted file types (e.g. ".xlsx,.csv" or "application/vnd.ms-excel"). */
97
+ accept?: string;
98
+ }
99
+ interface GetRootPropsOptions {
100
+ className?: string;
101
+ style?: CSSProperties;
102
+ }
103
+ interface UseRawFilePickerReturn {
104
+ isDragging: boolean;
105
+ getRootProps: (options?: GetRootPropsOptions) => {
106
+ ref: (el: HTMLElement | null) => void;
107
+ onClick: (e: React.MouseEvent) => void;
108
+ onDragOver: (e: React.DragEvent) => void;
109
+ onDragLeave: (e: React.DragEvent) => void;
110
+ onDrop: (e: React.DragEvent) => void;
111
+ role: string;
112
+ 'aria-label'?: string;
113
+ 'data-dropzone'?: string;
114
+ className?: string;
115
+ style?: CSSProperties;
116
+ };
117
+ getInputProps: () => {
118
+ ref: (el: HTMLInputElement | null) => void;
119
+ type: 'file';
120
+ onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
121
+ accept?: string;
122
+ tabIndex?: number;
123
+ 'aria-label'?: string;
124
+ };
125
+ }
126
+
127
+ declare function useRawFilePicker(options?: UseRawFilePickerOptions): UseRawFilePickerReturn;
128
+
129
+ /**
130
+ * Shared types for the input phase (file picker, mapping table/row, suggest, import action).
131
+ * Align with @cristianmpx/react-import-sheet-headless ConvertResult, headerToFieldMap, layout fields.
132
+ */
133
+
134
+ /** Option for the destination field selector (layout field id + label). */
135
+ interface LayoutFieldOption {
136
+ id: string;
137
+ label: string;
138
+ /** True when this field is already mapped by another file column (unique mapping). */
139
+ disabled?: boolean;
140
+ }
141
+ /** Status of a single column-to-field mapping (valid when mapped and matched). */
142
+ type MappingStatus = 'valid' | 'invalid' | 'unmapped';
143
+ /** Context passed to useRawMappingRow for one file column. */
144
+ interface RawMappingRowContext {
145
+ /** Original header from the file (column name). */
146
+ headerOriginal: string;
147
+ /** Column index in the file (0-based). */
148
+ columnIndex: number;
149
+ }
150
+ /** Context passed to useRawMappingSuggest for one file column (fuzzy suggestion). */
151
+ interface RawMappingSuggestContext {
152
+ /** Original header from the file. */
153
+ fileHeader: string;
154
+ /** Column index (0-based). */
155
+ columnIndex: number;
156
+ }
157
+ /**
158
+ * Build layout options from SheetLayout for dropdowns/selectors.
159
+ * Each option has id = field key, label = field.name (or id fallback).
160
+ */
161
+ declare function getLayoutFieldOptions(layout: SheetLayout | null): LayoutFieldOption[];
162
+
163
+ interface UseRawMappingTableReturn {
164
+ /** List of row contexts (one per file column) for useRawMappingRow. */
165
+ rows: RawMappingRowContext[];
166
+ /** Whether there is convert result (mapping) data to show. */
167
+ hasMappingData: boolean;
168
+ }
169
+
170
+ declare function useRawMappingTable(): UseRawMappingTableReturn;
171
+
172
+ interface UseRawMappingRowOptions {
173
+ rowContext: RawMappingRowContext;
174
+ }
175
+ interface UseRawMappingRowReturn {
176
+ headerOriginal: string;
177
+ columnIndex: number;
178
+ options: LayoutFieldOption[];
179
+ value: string | null;
180
+ onChange: (fieldId: string) => void;
181
+ mappingStatus: MappingStatus;
182
+ }
183
+
184
+ declare function useRawMappingRow(options: UseRawMappingRowOptions): UseRawMappingRowReturn;
185
+
186
+ interface UseRawMappingSuggestOptions {
187
+ columnContext: RawMappingSuggestContext;
188
+ }
189
+ interface UseRawMappingSuggestReturn {
190
+ /** 0–100 when fuzzyMatch is on and a suggestion exists; 0 otherwise. */
191
+ matchScore: number;
192
+ /** Layout field id suggested when fuzzyMatch is on; null otherwise. */
193
+ suggestedFieldId: string | null;
194
+ /** Label for the suggested field; null when no suggestion. */
195
+ suggestedFieldLabel: string | null;
196
+ }
197
+
198
+ declare function useRawMappingSuggest(options: UseRawMappingSuggestOptions): UseRawMappingSuggestReturn;
199
+
200
+ interface UseRawImportActionReturn {
201
+ /** True when mapping is incomplete or pipeline is already running. */
202
+ disabled: boolean;
203
+ /** Applies current mapping and runs the pipeline (Sanitizer → Validator → Transform). */
204
+ runImport: () => void;
205
+ }
206
+
207
+ declare function useRawImportAction(): UseRawImportActionReturn;
208
+
209
+ interface UseRawProgressOptions {
210
+ /** Called on each importer-progress event if the consumer wants to drive state (e.g. setPercent). Optional; for high perf use progressRef only. */
211
+ onProgress?: (detail: ImporterProgressDetail) => void;
212
+ }
213
+ interface UseRawProgressReturn {
214
+ /** Ref updated on each importer-progress event; no re-renders. Read in requestAnimationFrame or from a display component. */
215
+ progressRef: RefObject<ImporterProgressDetail | null>;
216
+ /** Only present if passed in options; same callback. */
217
+ onProgress?: (detail: ImporterProgressDetail) => void;
218
+ }
219
+
220
+ declare function useRawProgress(options?: UseRawProgressOptions): UseRawProgressReturn;
221
+
222
+ interface UseRawStatusReturn {
223
+ /** Current importer status from the Core. */
224
+ status: ImporterStatus;
225
+ /** Diagnostic object when status === 'error'. Aligned with headless SheetError (code, params, level, message). Undefined until headless exposes lastError. */
226
+ errorDetail?: SheetError | null;
227
+ }
228
+
229
+ declare function useRawStatus(): UseRawStatusReturn;
230
+
231
+ interface UseRawAbortReturn {
232
+ /** Calls the Core abort(); stops Workers. Attach to a button. */
233
+ abort: () => void;
234
+ }
235
+
236
+ declare function useRawAbort(): UseRawAbortReturn;
237
+
238
+ /**
239
+ * Shared types for the data phase (result grid, table head/body/row/cell, error badge).
240
+ * Align with headless: SheetLayout, useSheetData, useSheetEditor, ValidatedRow, ValidatedCell, SheetError.
241
+ */
242
+ /** Header item for table head (from SheetLayout fields). */
243
+ interface TableHeader {
244
+ id: string;
245
+ label: string;
246
+ }
247
+ /** Context passed to useRawTableRow for one row. */
248
+ interface RawTableRowContext {
249
+ /** Display index (0-based) in the virtualised/list view. */
250
+ index: number;
251
+ /** Optional inline style (e.g. from virtualiser: height, transform). */
252
+ style?: React.CSSProperties;
253
+ /** Optional pre-fetched row data when consumer has it. */
254
+ row?: _cristianmpx_react_import_sheet_headless.ValidatedRow | null;
255
+ }
256
+ /** Context passed to useRawCell for one cell. */
257
+ interface RawCellContext {
258
+ /** Row display index (0-based). */
259
+ rowIndex: number;
260
+ /** Field id / cell key (layout field id). */
261
+ fieldId: string;
262
+ /** Optional pre-fetched value when consumer has it. */
263
+ value?: unknown;
264
+ }
265
+ /** Props returned by getRowProps for <tr>. Key is omitted so the consumer can pass it directly to JSX (e.g. <tr key={index} {...getRowProps({ index })} />). */
266
+ interface GetRowPropsResult {
267
+ 'data-row-index': number;
268
+ 'data-has-errors'?: boolean;
269
+ 'data-placeholder'?: boolean;
270
+ style?: React.CSSProperties;
271
+ onKeyDown?: (e: React.KeyboardEvent) => void;
272
+ role: string;
273
+ 'aria-rowindex'?: number;
274
+ [key: string]: unknown;
275
+ }
276
+ /** Options for getRowProps. */
277
+ interface GetRowPropsOptions {
278
+ index: number;
279
+ style?: React.CSSProperties;
280
+ }
281
+ /** Options for getCellProps (merge with consumer className/style). */
282
+ interface GetCellPropsOptions {
283
+ className?: string;
284
+ style?: React.CSSProperties;
285
+ }
286
+
287
+ interface PendingCell {
288
+ rowIndex: number;
289
+ fieldId: string;
290
+ }
291
+ interface DataTableContextValue {
292
+ /** Whether cell editing is enabled (from RootConfig). */
293
+ editingEnabled: boolean;
294
+ /** Ordered list of column/field ids for arrow-key navigation. */
295
+ headerIds: string[];
296
+ /** Total number of rows (for arrow-key boundary). */
297
+ totalRowCount: number;
298
+ /** Currently focused row index (0-based) or null. */
299
+ focusedRowIndex: number | null;
300
+ /** Currently focused cell key (field id) or null. */
301
+ focusedCellKey: string | null;
302
+ /** Set the focused cell (for Roaming Tabindex). */
303
+ setFocused: (rowIndex: number | null, cellKey: string | null) => void;
304
+ /** Cell currently being validated (edit in flight). Cleared when edit completes. */
305
+ pendingCell: PendingCell | null;
306
+ /** Set pending cell (used by useRawCell when editCell is called). */
307
+ setPendingCell: (cell: PendingCell | null) => void;
308
+ /** Build keydown handler for a cell at (rowIndex, cellKey). Injects A11y arrow navigation. */
309
+ getKeyDownHandler: (rowIndex: number, cellKey: string) => (e: React.KeyboardEvent) => void;
310
+ /** Optional: called when focus would move to a row index outside current virtual window (for scroll). */
311
+ onNavigateToIndex?: (index: number) => void;
312
+ }
313
+ interface UseRawDataTableReturn extends DataTableContextValue {
314
+ /** Headers derived from layout (id, label) for convenience. */
315
+ headers: TableHeader[];
316
+ }
317
+
318
+ interface UseRawDataTableOptions {
319
+ /** Called when focus would move to a row index (e.g. for virtualiser scrollToIndex). */
320
+ onNavigateToIndex?: (index: number) => void;
321
+ }
322
+ declare function useRawDataTable(options?: UseRawDataTableOptions): UseRawDataTableReturn;
323
+
324
+ declare const DataTableContext: react.Context<DataTableContextValue>;
325
+
326
+ interface RawDataTableProviderProps extends UseRawDataTableOptions {
327
+ children: ReactNode;
328
+ }
329
+ /**
330
+ * Provides DataTableContext (Roaming Tabindex, editingEnabled) for useRawTableBody/Row/Cell.
331
+ * editingEnabled is overridden with headless canEdit (!submitDone) so editing is disabled after submit.
332
+ * Must be used inside ImporterProvider + LayoutProvider + RootConfigProvider (e.g. RawImporterRoot).
333
+ */
334
+ declare function RawDataTableProvider({ children, onNavigateToIndex }: RawDataTableProviderProps): react_jsx_runtime.JSX.Element;
335
+
336
+ interface UseRawTableHeadReturn {
337
+ /** Headers (id, label) from SheetLayout for rendering <thead> and <th>. */
338
+ headers: TableHeader[];
339
+ }
340
+
341
+ declare function useRawTableHead(): UseRawTableHeadReturn;
342
+
343
+ interface UseRawTableBodyReturn {
344
+ /** Total number of data rows (for virtualisation). */
345
+ totalRowCount: number;
346
+ /** Get props for a <tr> by display index. Merges style (e.g. from virtualiser). */
347
+ getRowProps: (options: GetRowPropsOptions) => GetRowPropsResult;
348
+ /** Whether the row at index is a placeholder (e.g. beyond data or skeleton). */
349
+ isPlaceholder: (index: number) => boolean;
350
+ /** Optional: set by consumer to scroll virtualiser when focus moves (onNavigateToIndex from context). */
351
+ onNavigateToIndex?: (index: number) => void;
352
+ }
353
+
354
+ declare function useRawTableBody(): UseRawTableBodyReturn;
355
+
356
+ type UseRawTableRowOptions = RawTableRowContext;
357
+ interface UseRawTableRowReturn {
358
+ /** Props for <tr> (style, data-has-errors, data-placeholder, role, aria-rowindex). Merge with consumer className/style. */
359
+ getRowProps: (options?: {
360
+ className?: string;
361
+ style?: React.CSSProperties;
362
+ }) => GetRowPropsResult & {
363
+ className?: string;
364
+ style?: React.CSSProperties;
365
+ };
366
+ /** Row data (errors, cells). Undefined when placeholder or out of range. */
367
+ row: ValidatedRow | undefined | null;
368
+ /** Row-level errors (from ValidatedRow.errors). */
369
+ rowErrors: readonly _cristianmpx_react_import_sheet_headless.SheetError[];
370
+ }
371
+
372
+ declare function useRawTableRow(options: UseRawTableRowOptions): UseRawTableRowReturn;
373
+
374
+ interface UseRawCellOptions {
375
+ /** Row display index (0-based). */
376
+ rowIndex: number;
377
+ /** Field id / cell key. */
378
+ fieldId: string;
379
+ }
380
+ interface UseRawCellReturn {
381
+ /** Current cell value (from sheet; optimistic after edit until validated). */
382
+ value: unknown;
383
+ /** Cell-level validation errors. */
384
+ errors: readonly SheetError[];
385
+ /** True while edit is being validated (Worker). */
386
+ isPending: boolean;
387
+ /** True when this cell is focused and editing is enabled (consumer can show input). */
388
+ isEditing: boolean;
389
+ /** Props for <td> / gridcell: role, tabIndex, data-pending, data-has-error, aria-invalid, onKeyDown; merge className/style. */
390
+ getCellProps: (options?: GetCellPropsOptions) => Record<string, unknown>;
391
+ /** Props for the edit input when isEditing: value, onChange, onBlur, ref, etc. */
392
+ getEditInputProps: () => Record<string, unknown>;
393
+ /** Props for error message slot (role="alert", aria-live, data-ris-ui="raw-cell-error-message"). */
394
+ getErrorProps: () => Record<string, unknown>;
395
+ /** Update cell value (triggers validation; isPending true until done). Respects editingEnabled. */
396
+ editCell: (value: unknown) => void | Promise<void>;
397
+ }
398
+
399
+ declare function useRawCell(options: UseRawCellOptions): UseRawCellReturn;
400
+
401
+ interface UseRawErrorBadgeOptions {
402
+ /** The error to display (code, params for I18n). */
403
+ error: SheetError | null | undefined;
404
+ /** Optional: (code, params) => translated string. */
405
+ translateError?: (code: string, params?: Readonly<Record<string, unknown>>) => string;
406
+ }
407
+ interface UseRawErrorBadgeReturn {
408
+ /** The error (code, params). */
409
+ error: SheetError | null | undefined;
410
+ /** Translated message when translateError is provided; otherwise error.message or code. */
411
+ message: string;
412
+ /** translateError if provided (for custom slot). */
413
+ translateError?: (code: string, params?: Readonly<Record<string, unknown>>) => string;
414
+ }
415
+
416
+ declare function useRawErrorBadge(options: UseRawErrorBadgeOptions): UseRawErrorBadgeReturn;
417
+
418
+ interface UseRawPaginationReturn {
419
+ page: number;
420
+ pageSize: number;
421
+ totalRows: number;
422
+ /** Sheet row indices for the current page (respects filterMode). Use for rendering grid rows. */
423
+ visibleSheetIndices: number[];
424
+ setPage: (page: number) => void;
425
+ setPageSize: (size: number) => void;
426
+ }
427
+
428
+ declare function useRawPagination(): UseRawPaginationReturn;
429
+
430
+ interface UseRawSubmitStatusReturn {
431
+ /** True after the user has submitted (headless submitDone). */
432
+ isSubmitted: boolean;
433
+ /** Call when user submits; headless submit() invokes Provider onSubmit(rows) and sets submitDone. */
434
+ markSubmitted: () => void;
435
+ /** Headless canSubmit: true when status success, no validation errors, and not yet submitted. */
436
+ canSubmit: boolean;
437
+ }
438
+ declare function useRawSubmitStatus(): UseRawSubmitStatusReturn;
439
+
440
+ /**
441
+ * View phase types — pagination, filter, export, persistence.
442
+ * Aligned with headless ViewFilterMode and UseSheetViewReturn.
443
+ */
444
+ /** Filter mode for result view: all rows or only rows with errors. Aligned with headless ViewFilterMode. */
445
+ type FilterMode = 'all' | 'errors-only';
446
+
447
+ interface ViewPhaseContextValue {
448
+ page: number;
449
+ setPage: (page: number) => void;
450
+ pageSize: number;
451
+ setPageSize: (size: number) => void;
452
+ totalRows: number;
453
+ /** Sheet row indices for the current page (filtered by filterMode). Use these to render grid rows. */
454
+ visibleSheetIndices: number[];
455
+ filterMode: FilterMode;
456
+ setFilterMode: Dispatch<SetStateAction<FilterMode>>;
457
+ downloadCSV: (opts?: {
458
+ filename?: string;
459
+ }) => void | Promise<void>;
460
+ downloadJSON: (opts?: {
461
+ filename?: string;
462
+ }) => void | Promise<void>;
463
+ /** Export only rows that have validation errors (CSV). Optional; may be undefined if not provided by provider. */
464
+ downloadCSVErrorsOnly?: (opts?: {
465
+ filename?: string;
466
+ }) => void | Promise<void>;
467
+ /** Export only rows that have validation errors (JSON). Optional; may be undefined if not provided by provider. */
468
+ downloadJSONErrorsOnly?: (opts?: {
469
+ filename?: string;
470
+ }) => void | Promise<void>;
471
+ /** True when there is at least one row with validation errors (for disabling "export errors only" when empty). */
472
+ hasRowsWithErrors?: boolean;
473
+ hasRecoverableSession: boolean;
474
+ recoverSession: () => Promise<void>;
475
+ clearSession: () => Promise<void>;
476
+ /** True after the user has submitted (headless submitDone). */
477
+ isSubmitted: boolean;
478
+ /** Call when user submits; headless submit() invokes Provider onSubmit(rows) and sets submitDone. */
479
+ markSubmitted: () => void;
480
+ /** Headless canSubmit: true when status success, no validation errors, and not yet submitted. */
481
+ canSubmit: boolean;
482
+ }
483
+ declare const ViewPhaseContext: react.Context<ViewPhaseContextValue | null>;
484
+
485
+ interface RawViewPhaseProviderProps {
486
+ children: ReactNode;
487
+ /** Initial page (1-based). Default 1. */
488
+ initialPage?: number;
489
+ /** Initial page size. Default 25. */
490
+ defaultPageSize?: number;
491
+ /** Initial filter mode. Default 'all'. */
492
+ defaultFilterMode?: FilterMode;
493
+ }
494
+ /**
495
+ * Single source of truth for view phase: pagination, filter, export, persistence.
496
+ * Must be used inside ImporterProvider (e.g. when status is success / RESULT view).
497
+ * useRawPagination, useRawFilterToggle, useRawExport, useRawPersistence read from this context.
498
+ */
499
+ declare function RawViewPhaseProvider({ children, initialPage, defaultPageSize, defaultFilterMode, }: RawViewPhaseProviderProps): react_jsx_runtime.JSX.Element;
500
+
501
+ interface UseRawRemoveRowReturn {
502
+ /** Removes the row at the given index. No-op if headless does not expose removeRow. */
503
+ removeRow: (rowIndex: number) => void;
504
+ /** True if the headless exposes removeRow (removal will take effect). */
505
+ canRemoveRow: boolean;
506
+ }
507
+
508
+ declare function useRawRemoveRow(): UseRawRemoveRowReturn;
509
+
510
+ interface UseRawEditLogReturn {
511
+ /** Headless changeLog: cell_edit and row_remove entries. Cleared on processFile. */
512
+ entries: readonly unknown[];
513
+ /** Human-readable log string (headless formatChangeLogAsText). */
514
+ changeLogAsText: string;
515
+ /** No-op; headless clears log on processFile only. Kept for API compatibility. */
516
+ clearLog: () => void;
517
+ }
518
+ declare function useRawEditLog(): UseRawEditLogReturn;
519
+
520
+ /** Entry when a cell value was updated. */
521
+ interface EditLogCellUpdate {
522
+ type: 'cell_update';
523
+ rowIndex: number;
524
+ fieldId: string;
525
+ oldValue: unknown;
526
+ newValue: unknown;
527
+ timestamp: number;
528
+ }
529
+ /** Entry when a row was removed. */
530
+ interface EditLogRowRemoved {
531
+ type: 'row_removed';
532
+ rowIndex: number;
533
+ timestamp: number;
534
+ }
535
+ type EditLogEntry = EditLogCellUpdate | EditLogRowRemoved;
536
+ interface EditLogContextValue {
537
+ entries: readonly EditLogEntry[];
538
+ appendCellUpdate: (params: {
539
+ rowIndex: number;
540
+ fieldId: string;
541
+ oldValue: unknown;
542
+ newValue: unknown;
543
+ }) => void;
544
+ appendRowRemoved: (params: {
545
+ rowIndex: number;
546
+ }) => void;
547
+ clearLog: () => void;
548
+ }
549
+
550
+ declare const EditLogContext: react.Context<EditLogContextValue | null>;
551
+
552
+ interface RawEditLogProviderProps {
553
+ children: ReactNode;
554
+ }
555
+ declare function RawEditLogProvider({ children }: RawEditLogProviderProps): react_jsx_runtime.JSX.Element;
556
+
557
+ interface UseRawFilterToggleReturn {
558
+ filterMode: FilterMode;
559
+ setFilterMode: (mode: FilterMode) => void;
560
+ }
561
+
562
+ declare function useRawFilterToggle(): UseRawFilterToggleReturn;
563
+
564
+ interface UseRawExportReturn {
565
+ downloadCSV: (opts?: {
566
+ filename?: string;
567
+ }) => void | Promise<void>;
568
+ downloadJSON: (opts?: {
569
+ filename?: string;
570
+ }) => void | Promise<void>;
571
+ /** Export only rows that have validation errors (CSV). May be undefined. */
572
+ downloadCSVErrorsOnly?: (opts?: {
573
+ filename?: string;
574
+ }) => void | Promise<void>;
575
+ /** Export only rows that have validation errors (JSON). May be undefined. */
576
+ downloadJSONErrorsOnly?: (opts?: {
577
+ filename?: string;
578
+ }) => void | Promise<void>;
579
+ /** True when there is at least one row with validation errors. */
580
+ hasRowsWithErrors?: boolean;
581
+ }
582
+
583
+ declare function useRawExport(): UseRawExportReturn;
584
+
585
+ interface UseRawPersistenceReturn {
586
+ hasRecoverableSession: boolean;
587
+ recoverSession: () => Promise<void>;
588
+ clearSession: () => Promise<void>;
589
+ }
590
+
591
+ declare function useRawPersistence(): UseRawPersistenceReturn;
592
+
593
+ /**
594
+ * Returns pipeline metrics from the Core (timings, totalMs, rowCount).
595
+ * Use in renderResult to show e.g. "10,000 rows in 1.2s".
596
+ */
597
+ declare function useImporterMetrics(): _cristianmpx_react_import_sheet_headless.PipelineMetrics | null;
598
+
599
+ interface RawImporterRootProps extends UseRawImporterRootOptions {
600
+ children: ReactNode;
601
+ className?: string;
602
+ style?: React.CSSProperties;
603
+ }
604
+
605
+ declare const RawImporterRoot: react.ForwardRefExoticComponent<RawImporterRootProps & react.RefAttributes<HTMLDivElement>>;
606
+
607
+ interface RawStatusGuardProps {
608
+ renderIdle?: (data: UseStatusViewReturn) => ReactNode;
609
+ renderMapping?: (data: UseStatusViewReturn) => ReactNode;
610
+ renderProcess?: (data: UseStatusViewReturn) => ReactNode;
611
+ renderResult?: (data: UseStatusViewReturn) => ReactNode;
612
+ renderError?: (data: UseStatusViewReturn) => ReactNode;
613
+ className?: string;
614
+ style?: React.CSSProperties;
615
+ }
616
+
617
+ declare const RawStatusGuard: react.ForwardRefExoticComponent<RawStatusGuardProps & react.RefAttributes<HTMLDivElement>>;
618
+
619
+ interface RawFilePickerProps {
620
+ children: (state: UseRawFilePickerReturn) => ReactNode;
621
+ className?: string;
622
+ style?: React.CSSProperties;
623
+ }
624
+
625
+ declare const RawFilePicker: react.ForwardRefExoticComponent<RawFilePickerProps & react.RefAttributes<HTMLDivElement>>;
626
+
627
+ interface RawMappingTableProps {
628
+ children: (state: UseRawMappingTableReturn) => ReactNode;
629
+ className?: string;
630
+ style?: React.CSSProperties;
631
+ }
632
+
633
+ declare const RawMappingTable: react.ForwardRefExoticComponent<RawMappingTableProps & react.RefAttributes<HTMLDivElement>>;
634
+
635
+ interface RawMappingRowProps {
636
+ rowContext: RawMappingRowContext;
637
+ children: (state: UseRawMappingRowReturn) => ReactNode;
638
+ className?: string;
639
+ style?: React.CSSProperties;
640
+ }
641
+
642
+ declare const RawMappingRow: react.ForwardRefExoticComponent<RawMappingRowProps & react.RefAttributes<HTMLDivElement>>;
643
+
644
+ interface RawMappingSuggestProps {
645
+ columnContext: RawMappingSuggestContext;
646
+ children: (state: UseRawMappingSuggestReturn) => ReactNode;
647
+ className?: string;
648
+ style?: React.CSSProperties;
649
+ }
650
+
651
+ declare const RawMappingSuggest: react.ForwardRefExoticComponent<RawMappingSuggestProps & react.RefAttributes<HTMLDivElement>>;
652
+
653
+ interface RawImportActionProps {
654
+ children: (state: UseRawImportActionReturn) => ReactNode;
655
+ className?: string;
656
+ style?: React.CSSProperties;
657
+ }
658
+
659
+ declare const RawImportAction: react.ForwardRefExoticComponent<RawImportActionProps & react.RefAttributes<HTMLDivElement>>;
660
+
661
+ interface RawErrorBoundaryProps {
662
+ children: ReactNode;
663
+ /** Content shown when an error is caught. Can be a node or a function (error, errorInfo) => ReactNode. */
664
+ fallback: ReactNode | ((error: Error, errorInfo: ErrorInfo) => ReactNode);
665
+ /** Called when an error is caught. */
666
+ onError?: (error: Error, errorInfo: ErrorInfo) => void;
667
+ }
668
+
669
+ declare class RawErrorBoundary extends Component<RawErrorBoundaryProps, {
670
+ error: Error | null;
671
+ errorInfo: ErrorInfo | null;
672
+ }> {
673
+ constructor(props: RawErrorBoundaryProps);
674
+ static getDerivedStateFromError(error: Error): {
675
+ error: Error;
676
+ errorInfo: null;
677
+ };
678
+ componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
679
+ render(): ReactNode;
680
+ }
681
+
682
+ interface RawProgressDisplayProps {
683
+ children: (state: UseRawProgressReturn) => ReactNode;
684
+ className?: string;
685
+ style?: React.CSSProperties;
686
+ /** Optional callback for progress updates (same as useRawProgress onProgress). */
687
+ onProgress?: (detail: ImporterProgressDetail) => void;
688
+ }
689
+
690
+ declare const RawProgressDisplay: react.ForwardRefExoticComponent<RawProgressDisplayProps & react.RefAttributes<HTMLDivElement>>;
691
+
692
+ interface RawStatusIndicatorProps {
693
+ children: (state: UseRawStatusReturn) => ReactNode;
694
+ className?: string;
695
+ style?: React.CSSProperties;
696
+ }
697
+
698
+ declare const RawStatusIndicator: react.ForwardRefExoticComponent<RawStatusIndicatorProps & react.RefAttributes<HTMLDivElement>>;
699
+
700
+ interface RawAbortButtonProps {
701
+ children?: ReactNode;
702
+ className?: string;
703
+ style?: React.CSSProperties;
704
+ disabled?: boolean;
705
+ 'aria-label'?: string;
706
+ }
707
+
708
+ declare const RawAbortButton: react.ForwardRefExoticComponent<RawAbortButtonProps & react.RefAttributes<HTMLButtonElement>>;
709
+
710
+ interface RawImporterWorkflowErrorOptions {
711
+ mappingErrorDetail: MappingErrorDetail | null;
712
+ }
713
+ /** Where to show the cell validation error message in the default result grid. */
714
+ type CellErrorPlacement = 'inline' | 'below' | 'none';
715
+ interface RawImporterWorkflowProps {
716
+ className?: string;
717
+ style?: React.CSSProperties;
718
+ renderIdle?: () => ReactNode;
719
+ renderMapping?: () => ReactNode;
720
+ renderProcess?: () => ReactNode;
721
+ renderResult?: () => ReactNode;
722
+ /** Receives mappingErrorDetail when view is 'error' due to too many mismatches. */
723
+ renderError?: (options: RawImporterWorkflowErrorOptions) => ReactNode;
724
+ /** Label for the Submit button (Submit is shown when Root has onSubmit; headless canSubmit disables it until valid). Default: "Submit". */
725
+ submitLabel?: ReactNode;
726
+ /**
727
+ * Where to show the validation error message per cell in the default result grid.
728
+ * - 'inline': message after the value (current behaviour).
729
+ * - 'below': message as a second line inside the cell (for styling/tooltips in another lib).
730
+ * - 'none': do not render the message in the cell (consumer shows it elsewhere, e.g. tooltip).
731
+ * Default: 'inline'.
732
+ */
733
+ cellErrorPlacement?: CellErrorPlacement;
734
+ }
735
+
736
+ declare const RawImporterWorkflow: react.ForwardRefExoticComponent<RawImporterWorkflowProps & react.RefAttributes<HTMLDivElement>>;
737
+
738
+ interface RawEditLogPanelProps {
739
+ className?: string;
740
+ style?: React.CSSProperties;
741
+ /** Optional. Renders content; receives headless changeLog entries and changeLogAsText. */
742
+ children?: (props: {
743
+ entries: readonly unknown[];
744
+ changeLogAsText: string;
745
+ clearLog: () => void;
746
+ }) => ReactNode;
747
+ }
748
+ declare const RawEditLogPanel: react.ForwardRefExoticComponent<RawEditLogPanelProps & react.RefAttributes<HTMLDivElement>>;
749
+
750
+ export { type AutoApplyMappingWhenMismatchesAtMost, type CellErrorPlacement, DataTableContext, type DataTableContextValue, type EditLogCellUpdate, EditLogContext, type EditLogEntry, type EditLogRowRemoved, type FilterMode, type GetCellPropsOptions, type GetRootPropsOptions, type GetRowPropsOptions, type GetRowPropsResult, LayoutContext, type LayoutFieldOption, LayoutProvider, type LayoutProviderProps, type MappingErrorDetail, type MappingStatus, type PendingCell, RawAbortButton, type RawAbortButtonProps, type RawCellContext, RawDataTableProvider, type RawDataTableProviderProps, RawEditLogPanel, type RawEditLogPanelProps, RawEditLogProvider, type RawEditLogProviderProps, RawErrorBoundary, type RawErrorBoundaryProps, RawFilePicker, type RawFilePickerProps, RawImportAction, type RawImportActionProps, RawImporterRoot, type RawImporterRootProps, RawImporterWorkflow, type RawImporterWorkflowErrorOptions, type RawImporterWorkflowProps, RawMappingRow, type RawMappingRowContext, type RawMappingRowProps, RawMappingSuggest, type RawMappingSuggestContext, type RawMappingSuggestProps, RawMappingTable, type RawMappingTableProps, RawProgressDisplay, type RawProgressDisplayProps, RawStatusGuard, type RawStatusGuardProps, RawStatusIndicator, type RawStatusIndicatorProps, type RawTableRowContext, RawViewPhaseProvider, type RawViewPhaseProviderProps, type RootConfig, RootConfigContext, RootConfigProvider, type RootConfigProviderProps, type RootConfigStages, type StatusView, type TableHeader, type UseRawAbortReturn, type UseRawCellOptions, type UseRawCellReturn, type UseRawDataTableOptions, type UseRawDataTableReturn, type UseRawEditLogReturn, type UseRawErrorBadgeOptions, type UseRawErrorBadgeReturn, type UseRawExportReturn, type UseRawFilePickerOptions, type UseRawFilePickerReturn, type UseRawFilterToggleReturn, type UseRawImportActionReturn, type UseRawImporterRootOptions, type UseRawImporterRootReturn, type UseRawMappingRowOptions, type UseRawMappingRowReturn, type UseRawMappingSuggestOptions, type UseRawMappingSuggestReturn, type UseRawMappingTableReturn, type UseRawPaginationReturn, type UseRawPersistenceReturn, type UseRawProgressOptions, type UseRawProgressReturn, type UseRawRemoveRowReturn, type UseRawStatusReturn, type UseRawSubmitStatusReturn, type UseRawTableBodyReturn, type UseRawTableHeadReturn, type UseRawTableRowOptions, type UseRawTableRowReturn, type UseStatusViewReturn, ViewPhaseContext, type ViewPhaseContextValue, getLayoutFieldOptions, getViewFromState, useImporterMetrics, useRawAbort, useRawCell, useRawDataTable, useRawEditLog, useRawErrorBadge, useRawExport, useRawFilePicker, useRawFilterToggle, useRawImportAction, useRawImporterRoot, useRawMappingRow, useRawMappingSuggest, useRawMappingTable, useRawPagination, useRawPersistence, useRawProgress, useRawRemoveRow, useRawStatus, useRawSubmitStatus, useRawTableBody, useRawTableHead, useRawTableRow, useStatusView };