@expresscsv/react 0.1.1 → 0.1.3

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,27 @@
1
+ import type { DeepPartial, ExpressCSVLocaleInput, TemplateDownloadConfig } from '@expresscsv/core';
2
+ import { type ColorModeConfig, type ECSVFontSource, type ECSVTheme, type ExBaseDef, type ExType, type Infer, type OpenOptions, WidgetState } from '@expresscsv/sdk';
3
+ export type { ColorModeConfig, ColorModePref, ECSVTheme, TailwindThemeVars, } from '@expresscsv/sdk';
4
+ export interface UseExpressCSVOptions<TSchema extends ExType<unknown, ExBaseDef, unknown>> {
5
+ schema: TSchema;
6
+ title?: string;
7
+ importIdentifier: string;
8
+ publishableKey: string;
9
+ debug?: boolean;
10
+ developerMode?: boolean;
11
+ preload?: boolean;
12
+ theme?: ECSVTheme;
13
+ colorMode?: ColorModeConfig;
14
+ customCSS?: string;
15
+ fonts?: Record<string, ECSVFontSource>;
16
+ stepDisplay?: 'progressBar' | 'segmented' | 'numbered';
17
+ previewSchemaBeforeUpload?: boolean;
18
+ templateDownload?: TemplateDownloadConfig;
19
+ saveSession?: boolean;
20
+ locale?: DeepPartial<ExpressCSVLocaleInput>;
21
+ }
22
+ export declare function useExpressCSV<TSchema extends ExType<unknown, ExBaseDef, unknown>>({ schema, title, importIdentifier, publishableKey, debug, developerMode, preload, theme, colorMode, customCSS, fonts, stepDisplay, previewSchemaBeforeUpload, templateDownload, saveSession, locale, }: UseExpressCSVOptions<TSchema>): {
23
+ open: (options: OpenOptions<Infer<TSchema>>) => void;
24
+ widgetState: WidgetState;
25
+ isInitialising: boolean;
26
+ isOpen: boolean;
27
+ };
@@ -0,0 +1,4 @@
1
+ export { useExpressCSV, type UseExpressCSVOptions, } from './CSVImporter';
2
+ export { x, WidgetState, WidgetMode, ImportCancelledError, } from '@expresscsv/sdk';
3
+ export type { Infer, ECSVFontSource, ECSVTheme, TailwindThemeVars, ColorModeConfig, ColorModePref, ExpressCSVStep, RecordsChunk, OpenOptions, WebhookConfig, DeliveryOptions, } from '@expresscsv/sdk';
4
+ export type { TemplateDownloadConfig, TemplateDownloadFormat, ExpressCSVLocaleInput, DeepPartial, } from '@expresscsv/core';
package/dist/index.d.mts CHANGED
@@ -1,31 +1,426 @@
1
- import { TemplateDownloadConfig, DeepPartial, ExpressCSVLocaleInput } from '@expresscsv/core';
2
- export { DeepPartial, ExpressCSVLocaleInput, TemplateDownloadConfig, TemplateDownloadFormat } from '@expresscsv/core';
3
- import { ExType, ExBaseDef, ECSVTheme, ColorModeConfig, ECSVFontSource, OpenOptions, Infer, WidgetState } from '@expresscsv/sdk';
4
- export { ColorModeConfig, ColorModePref, DeliveryOptions, ECSVFontSource, ECSVTheme, ExpressCSVStep, ImportCancelledError, Infer, OpenOptions, RecordsChunk, TailwindThemeVars, WebhookConfig, WidgetMode, WidgetState, x } from '@expresscsv/sdk';
5
-
6
- interface UseExpressCSVOptions<TSchema extends ExType<unknown, ExBaseDef, unknown>> {
7
- schema: TSchema;
8
- title?: string;
9
- importIdentifier: string;
10
- publishableKey: string;
11
- debug?: boolean;
12
- developerMode?: boolean;
13
- preload?: boolean;
14
- theme?: ECSVTheme;
15
- colorMode?: ColorModeConfig;
16
- customCSS?: string;
17
- fonts?: Record<string, ECSVFontSource>;
18
- stepDisplay?: 'progressBar' | 'segmented' | 'numbered';
19
- previewSchemaBeforeUpload?: boolean;
20
- templateDownload?: TemplateDownloadConfig;
21
- saveSession?: boolean;
22
- locale?: DeepPartial<ExpressCSVLocaleInput>;
23
- }
24
- declare function useExpressCSV<TSchema extends ExType<unknown, ExBaseDef, unknown>>({ schema, title, importIdentifier, publishableKey, debug, developerMode, preload, theme, colorMode, customCSS, fonts, stepDisplay, previewSchemaBeforeUpload, templateDownload, saveSession, locale, }: UseExpressCSVOptions<TSchema>): {
25
- open: (options: OpenOptions<Infer<TSchema>>) => void;
26
- widgetState: WidgetState;
27
- isInitialising: boolean;
28
- isOpen: boolean;
29
- };
30
-
31
- export { type UseExpressCSVOptions, useExpressCSV };
1
+ import { ColorModeConfig } from '@expresscsv/theme';
2
+ import { ColorModePref } from '@expresscsv/theme';
3
+ import { ECSVFontSource } from '@expresscsv/theme';
4
+ import { ECSVTheme } from '@expresscsv/theme';
5
+ import { ExBaseDef } from '@expresscsv/fields';
6
+ import { ExType } from '@expresscsv/fields';
7
+ import { Infer } from '@expresscsv/fields';
8
+ import { TailwindThemeVars } from '@expresscsv/theme';
9
+ import { WidgetMode } from '@expresscsv/iframe-comm';
10
+ import { WidgetState } from '@expresscsv/iframe-comm';
11
+ import { x } from '@expresscsv/fields';
12
+
13
+ export { ColorModeConfig }
14
+
15
+ export { ColorModePref }
16
+
17
+ export declare type DeepPartial<T> = {
18
+ [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
19
+ };
20
+
21
+ /**
22
+ * Delivery options - requires at least one of onData or webhook
23
+ */
24
+ export declare type DeliveryOptions<T> = RequireAtLeastOne<DeliveryOptionsBase<T>, 'onData' | 'webhook'>;
25
+
26
+ /**
27
+ * Base delivery options - at least one must be provided
28
+ */
29
+ declare interface DeliveryOptionsBase<T> {
30
+ /** Local callback for processing chunks */
31
+ onData?: (chunk: RecordsChunk<T>, next: () => void) => void | Promise<void>;
32
+ /** Webhook configuration for remote delivery */
33
+ webhook?: WebhookConfig;
34
+ }
35
+
36
+ export { ECSVFontSource }
37
+
38
+ export { ECSVTheme }
39
+
40
+ declare interface ExpressCSVLocale {
41
+ general: {
42
+ cancel: string;
43
+ back: string;
44
+ next: string;
45
+ finish: string;
46
+ required: string;
47
+ optional: string;
48
+ matched: string;
49
+ unmatched: string;
50
+ custom: string;
51
+ };
52
+ widget: {
53
+ title: string;
54
+ loading: string;
55
+ closeConfirmTitle: string;
56
+ closeConfirmDescription: string;
57
+ closeConfirmCancel: string;
58
+ closeConfirmContinue: string;
59
+ errorTitle: string;
60
+ startOver: string;
61
+ };
62
+ sessionRecovery: {
63
+ message: string;
64
+ discard: string;
65
+ resume: string;
66
+ };
67
+ dropzone: {
68
+ ariaLabel: string;
69
+ clearAriaLabel: string;
70
+ clearTooltip: string;
71
+ clearConfirmTitle: string;
72
+ clearConfirmDescription: string;
73
+ processing: string;
74
+ restoredSession: string;
75
+ prompt: string;
76
+ or: string;
77
+ browse: string;
78
+ };
79
+ upload: {
80
+ expectedColumns: string;
81
+ templatePrompt: string;
82
+ templateCSV: string;
83
+ templateXLSX: string;
84
+ templateGenerating: string;
85
+ /** Available: {format} */
86
+ templateDownloadFormat: TemplateString<'format'>;
87
+ templateDownload: string;
88
+ };
89
+ selectSheet: {
90
+ title: string;
91
+ subtitle: string;
92
+ noWorksheets: string;
93
+ preview: string;
94
+ /** Available: {count} */
95
+ columnCount: TemplateString<'count'>;
96
+ /** Available: {count} */
97
+ rowCount: TemplateString<'count'>;
98
+ /** Available: {name} */
99
+ inSheet: TemplateString<'name'>;
100
+ sheetSelected: string;
101
+ noColumns: string;
102
+ needsMoreRows: string;
103
+ };
104
+ selectHeader: {
105
+ loading: string;
106
+ noData: string;
107
+ noDataDescription: string;
108
+ title: string;
109
+ subtitle: string;
110
+ validHeader: string;
111
+ /** Available: {count} */
112
+ emptyColumns: TemplateString<'count'>;
113
+ allColumnsEmpty: string;
114
+ emptyColumnsTooltip: string;
115
+ /** Available: {displayed}, {total} */
116
+ showingRows: TemplateString<'displayed' | 'total'>;
117
+ showAll: string;
118
+ moveUp: string;
119
+ moveDown: string;
120
+ };
121
+ matchColumns: {
122
+ loading: string;
123
+ autoMatching: string;
124
+ title: string;
125
+ subtitle: string;
126
+ csvColumnHeader: string;
127
+ matchFieldHeader: string;
128
+ selectFieldPlaceholder: string;
129
+ searchFieldsPlaceholder: string;
130
+ noFieldsFound: string;
131
+ unmatchAll: string;
132
+ unmatchAllConfirmTitle: string;
133
+ unmatchAllConfirmDescription: string;
134
+ allRequiredMatched: string;
135
+ /** Available: {count} */
136
+ matchingConflicts: TemplateString<'count'>;
137
+ validationIssuesFound: string;
138
+ goToNextConflict: string;
139
+ /** Available: {count} */
140
+ unmatchedRequiredFields: TemplateString<'count'>;
141
+ requiredFieldsNotMatched: string;
142
+ goToUnmatchedFields: string;
143
+ /** Available: {count} */
144
+ validationIssues: TemplateString<'count'>;
145
+ goToNextIssue: string;
146
+ addEmptyColumnsForRequired: string;
147
+ /** Available: {fieldName} */
148
+ createEmptyColumn: TemplateString<'fieldName'>;
149
+ requiredFieldsNotAssigned: string;
150
+ addEmptyColumnTooltip: string;
151
+ previewTooltip: string;
152
+ /** Available: {rowCount}, {columnName} */
153
+ previewShowing: TemplateString<'rowCount' | 'columnName'>;
154
+ };
155
+ matchOptions: {
156
+ loading: string;
157
+ title: string;
158
+ subtitle: string;
159
+ csvValueHeader: string;
160
+ matchOptionHeader: string;
161
+ selectOptionPlaceholder: string;
162
+ searchOptionsPlaceholder: string;
163
+ noOptionsFound: string;
164
+ optionalBadge: string;
165
+ customValuesHint: string;
166
+ /** Available: {count}, {remaining} */
167
+ showMore: TemplateString<'count' | 'remaining'>;
168
+ /** Available: {value} */
169
+ useCustomValue: TemplateString<'value'>;
170
+ allValuesMatched: string;
171
+ /** Available: {count} */
172
+ unmatchedValues: TemplateString<'count'>;
173
+ unmatchedValuesFound: string;
174
+ goToNextUnmatched: string;
175
+ /** Available: {count} */
176
+ valueCount: TemplateString<'count'>;
177
+ };
178
+ review: {
179
+ completing: string;
180
+ loading: string;
181
+ title: string;
182
+ subtitle: string;
183
+ validating: string;
184
+ noRecords: string;
185
+ validatingCells: string;
186
+ /** Available: {count} */
187
+ allRecordsValid: TemplateString<'count'>;
188
+ /** Available: {count} */
189
+ recordCount: TemplateString<'count'>;
190
+ filterAll: string;
191
+ filterValid: string;
192
+ filterInvalid: string;
193
+ clearFilters: string;
194
+ noInvalidRows: string;
195
+ applyAutofix: string;
196
+ invalidValue: string;
197
+ undo: string;
198
+ redo: string;
199
+ /** Available: {count} */
200
+ autofixCount: TemplateString<'count'>;
201
+ /** Available: {count} */
202
+ applyAllAutofixes: TemplateString<'count'>;
203
+ /** Available: {description}, {count} */
204
+ autofixItem: TemplateString<'description' | 'count'>;
205
+ filter: string;
206
+ actions: string;
207
+ addRecord: string;
208
+ /** Available: {count} */
209
+ deleteSelectedRecords: TemplateString<'count'>;
210
+ /** Available: {count} */
211
+ exportSelectedRecords: TemplateString<'count'>;
212
+ /** Available: {count} */
213
+ exportFilteredRecords: TemplateString<'count'>;
214
+ /** Available: {count} */
215
+ exportAllRecords: TemplateString<'count'>;
216
+ exportCSV: string;
217
+ exportXLSX: string;
218
+ sortAZ: string;
219
+ sortZA: string;
220
+ sortLowHigh: string;
221
+ sortHighLow: string;
222
+ sortOldestNewest: string;
223
+ sortNewestOldest: string;
224
+ sortEarlyLate: string;
225
+ sortLateEarly: string;
226
+ sortFalseTrue: string;
227
+ sortTrueFalse: string;
228
+ sortAscending: string;
229
+ sortDescending: string;
230
+ removeSort: string;
231
+ unpinColumn: string;
232
+ pinColumn: string;
233
+ clearColumn: string;
234
+ /** Available: {description} */
235
+ columnAutofix: TemplateString<'description'>;
236
+ applyAllColumnAutofixes: string;
237
+ removeFilter: string;
238
+ columnMenu: string;
239
+ emptyDataTitle: string;
240
+ emptyDataDescription: string;
241
+ editFilter: string;
242
+ filteredColumns: string;
243
+ unfilteredColumns: string;
244
+ columnsLabel: string;
245
+ transformTooltip: string;
246
+ transformTitle: string;
247
+ transformClose: string;
248
+ transformCloseDiscardTooltip: string;
249
+ transformCloseTooltip: string;
250
+ transformError: string;
251
+ transformPlaceholder: string;
252
+ transformGenerating: string;
253
+ transformApplying: string;
254
+ transformDiscard: string;
255
+ transformApply: string;
256
+ transformUnappliedTitle: string;
257
+ transformUnappliedDescription: string;
258
+ transformKeepEditing: string;
259
+ transformDiscardClose: string;
260
+ transformAbortTitle: string;
261
+ transformAbortDescription: string;
262
+ transformAbortClose: string;
263
+ transformSubmit: string;
264
+ };
265
+ phantomColumn: {
266
+ /** Available: {number} */
267
+ defaultName: TemplateString<'number'>;
268
+ remove: string;
269
+ removeTooltip: string;
270
+ };
271
+ validation: {
272
+ showOtherMatch: string;
273
+ };
274
+ steps: {
275
+ upload: string;
276
+ selectSheet: string;
277
+ selectHeader: string;
278
+ matchColumns: string;
279
+ matchOptions: string;
280
+ review: string;
281
+ /** Available: {currentStep}, {totalSteps} */
282
+ progress: TemplateString<'currentStep' | 'totalSteps'>;
283
+ };
284
+ }
285
+
286
+ /** User-facing locale type where every leaf is a plain `string`. */
287
+ export declare type ExpressCSVLocaleInput = StripBrand<ExpressCSVLocale>;
288
+
289
+ /**
290
+ * Core step identifiers for the CSV import wizard
291
+ */
292
+ export declare type ExpressCSVStep = 'upload' | 'select-sheet' | 'select-header' | 'match-columns' | 'match-options' | 'review';
293
+
294
+ /**
295
+ * Error thrown when the user cancels the import operation
296
+ */
297
+ export declare class ImportCancelledError extends Error {
298
+ constructor(message?: string);
299
+ }
300
+
301
+ export { Infer }
302
+
303
+ /**
304
+ * Options for the open() method
305
+ * Requires at least one of onData or webhook for delivery
306
+ */
307
+ export declare type OpenOptions<T> = RequireAtLeastOne<DeliveryOptionsBase<T>, 'onData' | 'webhook'> & {
308
+ /** Number of records per chunk (default: 1000) */
309
+ chunkSize?: number;
310
+ /** Called when all chunks have been processed */
311
+ onComplete?: () => void;
312
+ /** Called when the user cancels the import */
313
+ onCancel?: () => void;
314
+ /** Called when an error occurs */
315
+ onError?: (error: Error) => void;
316
+ /** Called when the widget opens */
317
+ onWidgetOpen?: () => void;
318
+ /** Called when the step changes in the wizard */
319
+ onStepChange?: (stepId: ExpressCSVStep, previousStepId?: ExpressCSVStep) => void;
320
+ /** Called when the widget closes */
321
+ onWidgetClose?: (reason: 'user_close' | 'cancel' | 'complete' | 'error') => void;
322
+ };
323
+
324
+ /**
325
+ * A chunk of records passed to the onData callback
326
+ */
327
+ export declare interface RecordsChunk<T> {
328
+ /** The records in this chunk */
329
+ records: T[];
330
+ /** Total number of chunks */
331
+ totalChunks: number;
332
+ /** Current chunk index (0-based) */
333
+ currentChunkIndex: number;
334
+ /** Total number of records across all chunks */
335
+ totalRecords: number;
336
+ }
337
+
338
+ /**
339
+ * Type helper that requires at least one of the specified keys to be present
340
+ */
341
+ declare type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<keyof T, Keys>> & {
342
+ [K in Keys]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>>;
343
+ }[Keys];
344
+
345
+ declare type StripBrand<T> = {
346
+ [K in keyof T]: T[K] extends TemplateString<string> ? string : T[K] extends object ? StripBrand<T[K]> : T[K];
347
+ };
348
+
349
+ export { TailwindThemeVars }
350
+
351
+ /**
352
+ * Configuration for template download in the upload step.
353
+ * When `source` is `"generate"`, a header-only template file is created
354
+ * client-side from the schema column names.
355
+ */
356
+ export declare interface TemplateDownloadConfig {
357
+ source: 'generate';
358
+ formats?: TemplateDownloadFormat[];
359
+ }
360
+
361
+ /**
362
+ * Template download format
363
+ */
364
+ export declare type TemplateDownloadFormat = 'csv' | 'xlsx';
365
+
366
+ /**
367
+ * A branded string type for locale entries that require interpolation via `{variable}` syntax.
368
+ * Widget code cannot render a `TemplateString` directly in JSX — it must go through the `t()` function.
369
+ * The generic `TVars` encodes the expected variable names so `t()` enforces the correct vars argument.
370
+ */
371
+ declare type TemplateString<TVars extends string = string> = string & {
372
+ readonly __brand: 'TemplateString';
373
+ readonly __vars: TVars;
374
+ };
375
+
376
+ export declare function useExpressCSV<TSchema extends ExType<unknown, ExBaseDef, unknown>>({ schema, title, importIdentifier, publishableKey, debug, developerMode, preload, theme, colorMode, customCSS, fonts, stepDisplay, previewSchemaBeforeUpload, templateDownload, saveSession, locale, }: UseExpressCSVOptions<TSchema>): {
377
+ open: (options: OpenOptions<Infer<TSchema>>) => void;
378
+ widgetState: WidgetState;
379
+ isInitialising: boolean;
380
+ isOpen: boolean;
381
+ };
382
+
383
+ export declare interface UseExpressCSVOptions<TSchema extends ExType<unknown, ExBaseDef, unknown>> {
384
+ schema: TSchema;
385
+ title?: string;
386
+ importIdentifier: string;
387
+ publishableKey: string;
388
+ debug?: boolean;
389
+ developerMode?: boolean;
390
+ preload?: boolean;
391
+ theme?: ECSVTheme;
392
+ colorMode?: ColorModeConfig;
393
+ customCSS?: string;
394
+ fonts?: Record<string, ECSVFontSource>;
395
+ stepDisplay?: 'progressBar' | 'segmented' | 'numbered';
396
+ previewSchemaBeforeUpload?: boolean;
397
+ templateDownload?: TemplateDownloadConfig;
398
+ saveSession?: boolean;
399
+ locale?: DeepPartial<ExpressCSVLocaleInput>;
400
+ }
401
+
402
+ /**
403
+ * Webhook configuration for remote delivery of results
404
+ */
405
+ export declare interface WebhookConfig {
406
+ /** The URL to send webhook requests to */
407
+ url: string;
408
+ /** Optional HTTP headers to include in the request */
409
+ headers?: Record<string, string>;
410
+ /** HTTP method to use (default: 'POST') */
411
+ method?: 'POST' | 'PUT' | 'PATCH';
412
+ /** Request timeout in milliseconds (default: 30000) */
413
+ timeout?: number;
414
+ /** Number of retry attempts on failure (default: 0) */
415
+ retries?: number;
416
+ /** Arbitrary developer-provided metadata */
417
+ metadata?: Record<string, unknown>;
418
+ }
419
+
420
+ export { WidgetMode }
421
+
422
+ export { WidgetState }
423
+
424
+ export { x }
425
+
426
+ export { }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@expresscsv/react",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "React component wrapper for ExpressCSV SDK",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.mts",