Skip to content

Commit df4aeaf

Browse files
committed
add docs to clarify params for the hooks
1 parent 4e1df7c commit df4aeaf

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/types.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,45 @@ export type RsiProps<T extends string> = {
1919
fields: Fields<T>
2020
/**
2121
* Runs after file upload step, receives and returns raw sheet data
22+
* @param data Raw data from the uploaded file
23+
* @returns Modified raw data or Promise
2224
*/
2325
uploadStepHook?: (data: RawData[]) => Promise<RawData[]>
2426
/**
2527
* Runs after header selection step, receives and returns raw sheet data
28+
* @param headerValues Header values selected by user
29+
* @param data Raw data from the uploaded file
30+
* @returns Modified header values and data or Promise
2631
*/
2732
selectHeaderStepHook?: (headerValues: RawData, data: RawData[]) => Promise<{ headerValues: RawData; data: RawData[] }>
2833
/**
2934
* Runs once before validation step, used for data mutations and if you want to change how columns were matched
35+
* @param table All rows in the current table
36+
* @param rawData Raw data from the uploaded file
37+
* @param columns Columns that were matched in the previous step
38+
* @returns Modified table data or Promise
3039
*/
3140
matchColumnsStepHook?: (table: Data<T>[], rawData: RawData[], columns: Columns<T>) => Promise<Data<T>[]>
3241
/**
3342
* Runs after column matching and on entry change
43+
* @param row The current row being processed
44+
* @param addError Function to add validation errors to specific fields. Has to be called with field key and error object.
45+
* @param table All rows in the current table
46+
* @returns Modified row data or Promise
3447
*/
3548
rowHook?: RowHook<T>
3649
/**
3750
* Runs after column matching and on entry change
51+
* @param table All rows in the current table
52+
* @param addError Function to add validation errors to specific fields. Has to be called with row index, field key and error object.
53+
* @returns Modified table data or Promise
3854
*/
3955
tableHook?: TableHook<T>
4056
/**
4157
* Function called after user finishes the flow. You can return a promise that will be awaited.
58+
* @param data Validated and processed data from the flow
59+
* @param file The file that was uploaded by the user
60+
* @returns void or Promise
4261
*/
4362
onSubmit: (data: Result<T>, file: File) => void | Promise<any>
4463
/**

0 commit comments

Comments
 (0)