@expresscsv/react 0.1.21 → 0.1.22
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.
- package/README.md +30 -32
- package/dist/index.d.cts +32 -33
- package/dist/index.d.mts +32 -33
- package/dist/index.d.ts +32 -33
- package/dist/index.js +2 -2
- package/dist/index.mjs +2 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
[](https://www.npmjs.com/package/@expresscsv/react)
|
|
4
4
|

|
|
5
5
|
|
|
6
|
-
React hook for embedding the [ExpressCSV](https://expresscsv.com) CSV
|
|
6
|
+
React hook for embedding the [ExpressCSV](https://expresscsv.com) CSV importer. Wraps [`@expresscsv/sdk`](https://www.npmjs.com/package/@expresscsv/sdk) with automatic lifecycle management and reactive state.
|
|
7
7
|
|
|
8
8
|
If you want to define schemas in shared or backend code without any frontend dependencies, use [`@expresscsv/schemas`](https://www.npmjs.com/package/@expresscsv/schemas) for the schema definition itself, then pass that schema into `@expresscsv/react`.
|
|
9
9
|
|
|
@@ -36,7 +36,7 @@ const schema = x.row({
|
|
|
36
36
|
function App() {
|
|
37
37
|
const { open, isOpen } = useExpressCSV({
|
|
38
38
|
schema,
|
|
39
|
-
|
|
39
|
+
getSessionToken: async () => fetchSessionToken(),
|
|
40
40
|
importIdentifier: "user-import",
|
|
41
41
|
title: "Import Users",
|
|
42
42
|
});
|
|
@@ -71,20 +71,20 @@ function App() {
|
|
|
71
71
|
}
|
|
72
72
|
```
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
Have your backend keep the ExpressCSV secret key, call the ExpressCSV session-creation endpoint, and return a short-lived importer session token to the browser via `getSessionToken`.
|
|
75
75
|
|
|
76
76
|
## Preloading
|
|
77
77
|
|
|
78
|
-
By default the
|
|
78
|
+
By default the importer preloads in a hidden iframe so it appears instantly when `open()` is called:
|
|
79
79
|
|
|
80
80
|
```tsx
|
|
81
81
|
const { open } = useExpressCSV({
|
|
82
82
|
schema,
|
|
83
|
-
|
|
83
|
+
getSessionToken: async () => fetchSessionToken(),
|
|
84
84
|
importIdentifier: "user-import",
|
|
85
85
|
});
|
|
86
86
|
|
|
87
|
-
//
|
|
87
|
+
// Importer displays instantly
|
|
88
88
|
const handleImport = () => {
|
|
89
89
|
open({
|
|
90
90
|
onData: (chunk, next) => {
|
|
@@ -100,7 +100,7 @@ To disable preloading (there will be a brief loading screen instead):
|
|
|
100
100
|
```tsx
|
|
101
101
|
const { open } = useExpressCSV({
|
|
102
102
|
schema,
|
|
103
|
-
|
|
103
|
+
getSessionToken: async () => fetchSessionToken(),
|
|
104
104
|
importIdentifier: "user-import",
|
|
105
105
|
preload: false,
|
|
106
106
|
});
|
|
@@ -124,7 +124,7 @@ const candidateSchema = x.row({
|
|
|
124
124
|
|
|
125
125
|
const { open } = useExpressCSV({
|
|
126
126
|
schema: candidateSchema,
|
|
127
|
-
|
|
127
|
+
getSessionToken: async () => fetchSessionToken(),
|
|
128
128
|
importIdentifier: "candidate-import",
|
|
129
129
|
templateDownload: {
|
|
130
130
|
source: "generate",
|
|
@@ -142,7 +142,7 @@ const { open } = useExpressCSV({
|
|
|
142
142
|
|
|
143
143
|
## Theming and Styling
|
|
144
144
|
|
|
145
|
-
Customize the
|
|
145
|
+
Customize the importer's appearance with the `theme`, `colorMode`, `customCSS`, and `fonts` options.
|
|
146
146
|
|
|
147
147
|
### Theme
|
|
148
148
|
|
|
@@ -181,7 +181,7 @@ const dualTheme: ECSVTheme = {
|
|
|
181
181
|
function App() {
|
|
182
182
|
const { open } = useExpressCSV({
|
|
183
183
|
schema,
|
|
184
|
-
|
|
184
|
+
getSessionToken: async () => fetchSessionToken(),
|
|
185
185
|
importIdentifier: "user-import",
|
|
186
186
|
theme,
|
|
187
187
|
});
|
|
@@ -227,7 +227,7 @@ Control light/dark mode with `colorMode`:
|
|
|
227
227
|
```tsx
|
|
228
228
|
const { open } = useExpressCSV({
|
|
229
229
|
schema,
|
|
230
|
-
|
|
230
|
+
getSessionToken: async () => fetchSessionToken(),
|
|
231
231
|
importIdentifier: "user-import",
|
|
232
232
|
colorMode: "system", // 'light' | 'dark' | 'system'
|
|
233
233
|
});
|
|
@@ -240,7 +240,7 @@ Inject custom CSS for fine-grained styling overrides.
|
|
|
240
240
|
```tsx
|
|
241
241
|
const { open } = useExpressCSV({
|
|
242
242
|
schema,
|
|
243
|
-
|
|
243
|
+
getSessionToken: async () => fetchSessionToken(),
|
|
244
244
|
importIdentifier: "user-import",
|
|
245
245
|
customCSS: `
|
|
246
246
|
.ecsv [data-step="upload"] {
|
|
@@ -260,7 +260,7 @@ Load custom fonts via the `fonts` option:
|
|
|
260
260
|
```tsx
|
|
261
261
|
const { open } = useExpressCSV({
|
|
262
262
|
schema,
|
|
263
|
-
|
|
263
|
+
getSessionToken: async () => fetchSessionToken(),
|
|
264
264
|
importIdentifier: "user-import",
|
|
265
265
|
fonts: {
|
|
266
266
|
title: { source: "google", name: "Space Grotesk", weights: [400, 600, 700] },
|
|
@@ -288,7 +288,7 @@ const schema = x.row({
|
|
|
288
288
|
function App() {
|
|
289
289
|
const { open } = useExpressCSV({
|
|
290
290
|
schema,
|
|
291
|
-
|
|
291
|
+
getSessionToken: async () => fetchSessionToken(),
|
|
292
292
|
importIdentifier: "user-import",
|
|
293
293
|
title: "Import Users",
|
|
294
294
|
});
|
|
@@ -337,7 +337,6 @@ interface WebhookPayload {
|
|
|
337
337
|
metadata?: Record<string, unknown>;
|
|
338
338
|
/** Delivery context added by ExpressCSV */
|
|
339
339
|
delivery: {
|
|
340
|
-
publishableKey: string;
|
|
341
340
|
environmentName: string;
|
|
342
341
|
environmentType: string;
|
|
343
342
|
teamSlug: string;
|
|
@@ -366,7 +365,6 @@ Example payload:
|
|
|
366
365
|
"userId": "user-123"
|
|
367
366
|
},
|
|
368
367
|
"delivery": {
|
|
369
|
-
"publishableKey": "pk_live_abc123",
|
|
370
368
|
"environmentName": "Production",
|
|
371
369
|
"environmentType": "production",
|
|
372
370
|
"teamSlug": "my-team",
|
|
@@ -494,7 +492,7 @@ function CandidateImporter() {
|
|
|
494
492
|
|
|
495
493
|
const { open, isOpen } = useExpressCSV({
|
|
496
494
|
schema: candidateSchema,
|
|
497
|
-
|
|
495
|
+
getSessionToken: async () => fetchSessionToken(),
|
|
498
496
|
importIdentifier: "candidate-import",
|
|
499
497
|
title: "Import Candidates",
|
|
500
498
|
});
|
|
@@ -542,7 +540,7 @@ function useExpressCSV<TSchema>(
|
|
|
542
540
|
options: UseExpressCSVOptions<TSchema>
|
|
543
541
|
): {
|
|
544
542
|
open: (options: OpenOptions<Infer<TSchema>>) => void;
|
|
545
|
-
|
|
543
|
+
importerState: ImporterState;
|
|
546
544
|
isInitialising: boolean;
|
|
547
545
|
isOpen: boolean;
|
|
548
546
|
};
|
|
@@ -553,14 +551,14 @@ function useExpressCSV<TSchema>(
|
|
|
553
551
|
| Option | Type | Required | Default | Description |
|
|
554
552
|
|---|---|---|---|---|
|
|
555
553
|
| `schema` | Schema | Yes | - | Schema definition created with `x.row()` |
|
|
556
|
-
| `
|
|
554
|
+
| `getSessionToken` | `() => Promise<string>` | Yes | - | Async callback that asks your backend for a short-lived importer session token |
|
|
557
555
|
| `importIdentifier` | `string` | Yes | - | Unique identifier for this import type |
|
|
558
|
-
| `title` | `string` | No | - | Title shown in the
|
|
559
|
-
| `preload` | `boolean` | No | `true` | Preload
|
|
556
|
+
| `title` | `string` | No | - | Title shown in the importer header |
|
|
557
|
+
| `preload` | `boolean` | No | `true` | Preload the importer for instant display |
|
|
560
558
|
| `debug` | `boolean` | No | `false` | Enable debug logging |
|
|
561
559
|
| `theme` | `ECSVTheme` | No | - | Custom theme configuration |
|
|
562
560
|
| `colorMode` | `ColorModePref` | No | - | Light/dark mode (`'light'`, `'dark'`, or `'system'`) |
|
|
563
|
-
| `customCSS` | `string` | No | - | Custom CSS to inject into the
|
|
561
|
+
| `customCSS` | `string` | No | - | Custom CSS to inject into the importer |
|
|
564
562
|
| `fonts` | `Record<string, ECSVFontSource>` | No | - | Custom font sources |
|
|
565
563
|
| `stepDisplay` | `'progressBar' \| 'segmented' \| 'numbered'` | No | `'progressBar'` | Step indicator style |
|
|
566
564
|
| `previewSchemaBeforeUpload` | `boolean` | No | `true` | Show schema preview before upload |
|
|
@@ -572,10 +570,10 @@ function useExpressCSV<TSchema>(
|
|
|
572
570
|
|
|
573
571
|
| Property | Type | Description |
|
|
574
572
|
|---|---|---|
|
|
575
|
-
| `open` | `(options: OpenOptions) => void` | Opens the
|
|
576
|
-
| `
|
|
577
|
-
| `isInitialising` | `boolean` | `true` while the
|
|
578
|
-
| `isOpen` | `boolean` | `true` while the
|
|
573
|
+
| `open` | `(options: OpenOptions) => void` | Opens the importer. Requires at least one of `onData` or `webhook`. |
|
|
574
|
+
| `importerState` | `ImporterState` | Current importer lifecycle state (reactive) |
|
|
575
|
+
| `isInitialising` | `boolean` | `true` while the importer is initializing or opening |
|
|
576
|
+
| `isOpen` | `boolean` | `true` while the importer is open |
|
|
579
577
|
|
|
580
578
|
### `OpenOptions<T>`
|
|
581
579
|
|
|
@@ -589,8 +587,8 @@ Options passed to `open()`. At least one of `onData` or `webhook` must be provid
|
|
|
589
587
|
| `onComplete` | `() => void` | No | Called when all chunks have been processed |
|
|
590
588
|
| `onCancel` | `() => void` | No | Called when the user cancels the import |
|
|
591
589
|
| `onError` | `(error: Error) => void` | No | Called when an error occurs |
|
|
592
|
-
| `
|
|
593
|
-
| `
|
|
590
|
+
| `onImporterOpen` | `() => void` | No | Called when the importer opens |
|
|
591
|
+
| `onImporterClose` | `(reason: string) => void` | No | Called when the importer closes |
|
|
594
592
|
| `onStepChange` | `(stepId, previousStepId?) => void` | No | Called when the wizard step changes |
|
|
595
593
|
|
|
596
594
|
\* At least one of `onData` or `webhook` is required.
|
|
@@ -623,7 +621,7 @@ interface WebhookConfig {
|
|
|
623
621
|
|
|
624
622
|
The `x` schema builder provides a type-safe, fluent API for defining your CSV structure.
|
|
625
623
|
|
|
626
|
-
For apps that share schemas with backend code or webhook receivers, prefer defining the schema in `@expresscsv/schemas` and importing it into your React app. That keeps schema authoring free of React and
|
|
624
|
+
For apps that share schemas with backend code or webhook receivers, prefer defining the schema in `@expresscsv/schemas` and importing it into your React app. That keeps schema authoring free of React and importer dependencies, while also giving your backend access to `InferWebhookPayload<typeof schema>`.
|
|
627
625
|
|
|
628
626
|
#### Field Types
|
|
629
627
|
|
|
@@ -728,7 +726,7 @@ All field types support:
|
|
|
728
726
|
|
|
729
727
|
| Modifier | Description |
|
|
730
728
|
|---|---|
|
|
731
|
-
| `.label(text)` | User-facing label shown in the
|
|
729
|
+
| `.label(text)` | User-facing label shown in the importer |
|
|
732
730
|
| `.description(text)` | Help text for the field |
|
|
733
731
|
| `.example(text)` | Example value shown as placeholder |
|
|
734
732
|
| `.optional()` | Makes the field optional (default is required) |
|
|
@@ -780,7 +778,7 @@ x.string().refine(
|
|
|
780
778
|
)
|
|
781
779
|
```
|
|
782
780
|
|
|
783
|
-
**Object-returning validator** — inline `valid`, `message`, and an optional `suggestedFix` the
|
|
781
|
+
**Object-returning validator** — inline `valid`, `message`, and an optional `suggestedFix` the importer can offer the user:
|
|
784
782
|
|
|
785
783
|
```tsx
|
|
786
784
|
x.string().refine((value) => ({
|
|
@@ -847,7 +845,7 @@ x.string().refineBatch((values) => {
|
|
|
847
845
|
|
|
848
846
|
### `suggestedFix`
|
|
849
847
|
|
|
850
|
-
Both `.refine()` and `.refineBatch()` support returning a `suggestedFix` object that the
|
|
848
|
+
Both `.refine()` and `.refineBatch()` support returning a `suggestedFix` object that the importer offers as a one-click fix for the user:
|
|
851
849
|
|
|
852
850
|
```tsx
|
|
853
851
|
interface SuggestedFix {
|
package/dist/index.d.cts
CHANGED
|
@@ -2754,7 +2754,7 @@ declare interface ExpressCSVLocale {
|
|
|
2754
2754
|
nextDisabledReviewValidating: string;
|
|
2755
2755
|
nextDisabledReviewInvalid: string;
|
|
2756
2756
|
};
|
|
2757
|
-
|
|
2757
|
+
importer: {
|
|
2758
2758
|
title: string;
|
|
2759
2759
|
loading: string;
|
|
2760
2760
|
closeConfirmTitle: string;
|
|
@@ -2763,7 +2763,6 @@ declare interface ExpressCSVLocale {
|
|
|
2763
2763
|
closeConfirmContinue: string;
|
|
2764
2764
|
errorTitle: string;
|
|
2765
2765
|
startOver: string;
|
|
2766
|
-
invalidPublishableKey: string;
|
|
2767
2766
|
};
|
|
2768
2767
|
sessionRecovery: {
|
|
2769
2768
|
message: string;
|
|
@@ -3476,6 +3475,29 @@ export declare class ImportCancelledError extends Error {
|
|
|
3476
3475
|
constructor(message?: string);
|
|
3477
3476
|
}
|
|
3478
3477
|
|
|
3478
|
+
/**
|
|
3479
|
+
* Importer preload mode
|
|
3480
|
+
*/
|
|
3481
|
+
export declare enum ImporterMode {
|
|
3482
|
+
NORMAL = "normal",
|
|
3483
|
+
PRELOAD = "preload"
|
|
3484
|
+
}
|
|
3485
|
+
|
|
3486
|
+
/**
|
|
3487
|
+
* Importer lifecycle state
|
|
3488
|
+
*/
|
|
3489
|
+
export declare enum ImporterState {
|
|
3490
|
+
UNINITIALIZED = "uninitialized",
|
|
3491
|
+
INITIALIZING = "initializing",
|
|
3492
|
+
READY = "ready",
|
|
3493
|
+
OPENING = "opening",
|
|
3494
|
+
OPEN = "open",
|
|
3495
|
+
CLOSING = "closing",
|
|
3496
|
+
RESETTING = "resetting",
|
|
3497
|
+
ERROR = "error",
|
|
3498
|
+
DESTROYED = "destroyed"
|
|
3499
|
+
}
|
|
3500
|
+
|
|
3479
3501
|
export declare type Infer<T extends ExType<unknown, ExBaseDef, unknown>> = T extends ExType<infer Output, ExBaseDef, unknown> ? Output : never;
|
|
3480
3502
|
|
|
3481
3503
|
declare type IPAddressVersion = 'v4' | 'v6' | 'all';
|
|
@@ -3498,12 +3520,12 @@ export declare type OpenOptions<T> = RequireAtLeastOne<DeliveryOptionsBase<T>, '
|
|
|
3498
3520
|
onCancel?: () => void;
|
|
3499
3521
|
/** Called when an error occurs */
|
|
3500
3522
|
onError?: (error: Error) => void;
|
|
3501
|
-
/** Called when the
|
|
3502
|
-
|
|
3523
|
+
/** Called when the importer opens */
|
|
3524
|
+
onImporterOpen?: () => void;
|
|
3525
|
+
/** Called when the importer closes */
|
|
3526
|
+
onImporterClose?: (reason: 'user_close' | 'cancel' | 'complete' | 'error') => void;
|
|
3503
3527
|
/** Called when the step changes in the wizard */
|
|
3504
3528
|
onStepChange?: (stepId: ExpressCSVStep, previousStepId?: ExpressCSVStep) => void;
|
|
3505
|
-
/** Called when the widget closes */
|
|
3506
|
-
onWidgetClose?: (reason: 'user_close' | 'cancel' | 'complete' | 'error') => void;
|
|
3507
3529
|
};
|
|
3508
3530
|
|
|
3509
3531
|
declare type PhoneNumberFormat = 'international' | 'national' | 'both';
|
|
@@ -3726,7 +3748,7 @@ export declare type TemplateDownloadOptions<TSchema extends ExType<unknown, ExBa
|
|
|
3726
3748
|
|
|
3727
3749
|
/**
|
|
3728
3750
|
* A branded string type for locale entries that require interpolation via `{variable}` syntax.
|
|
3729
|
-
*
|
|
3751
|
+
* Importer code cannot render a `TemplateString` directly in JSX — it must go through the `t()` function.
|
|
3730
3752
|
* The generic `TVars` encodes the expected variable names so `t()` enforces the correct vars argument.
|
|
3731
3753
|
*/
|
|
3732
3754
|
declare type TemplateString<TVars extends string = string> = string & {
|
|
@@ -3750,9 +3772,9 @@ declare interface URLOptions {
|
|
|
3750
3772
|
message?: string;
|
|
3751
3773
|
}
|
|
3752
3774
|
|
|
3753
|
-
export declare function useExpressCSV<TSchema extends ExType<unknown, ExBaseDef, unknown>>({ schema, title, importIdentifier,
|
|
3775
|
+
export declare function useExpressCSV<TSchema extends ExType<unknown, ExBaseDef, unknown>>({ schema, title, importIdentifier, getSessionToken, debug, preload, theme, colorMode, customCSS, fonts, stepDisplay, previewSchemaBeforeUpload, templateDownload, saveSession, locale, disableStatusStep, }: UseExpressCSVOptions<TSchema>): {
|
|
3754
3776
|
open: (options: OpenOptions<Infer<TSchema>>) => void;
|
|
3755
|
-
|
|
3777
|
+
importerState: ImporterState;
|
|
3756
3778
|
isInitialising: boolean;
|
|
3757
3779
|
isOpen: boolean;
|
|
3758
3780
|
};
|
|
@@ -3761,7 +3783,7 @@ export declare interface UseExpressCSVOptions<TSchema extends ExType<unknown, Ex
|
|
|
3761
3783
|
schema: TSchema;
|
|
3762
3784
|
title?: string;
|
|
3763
3785
|
importIdentifier: string;
|
|
3764
|
-
|
|
3786
|
+
getSessionToken: () => Promise<string>;
|
|
3765
3787
|
debug?: boolean;
|
|
3766
3788
|
preload?: boolean;
|
|
3767
3789
|
theme?: ECSVTheme;
|
|
@@ -3809,29 +3831,6 @@ export declare interface WebhookConfig {
|
|
|
3809
3831
|
awaitWebhookArrival?: boolean;
|
|
3810
3832
|
}
|
|
3811
3833
|
|
|
3812
|
-
/**
|
|
3813
|
-
* Widget mode enumeration
|
|
3814
|
-
*/
|
|
3815
|
-
export declare enum WidgetMode {
|
|
3816
|
-
NORMAL = "normal",
|
|
3817
|
-
PRELOAD = "preload"
|
|
3818
|
-
}
|
|
3819
|
-
|
|
3820
|
-
/**
|
|
3821
|
-
* Widget state enumeration for consistent state management
|
|
3822
|
-
*/
|
|
3823
|
-
export declare enum WidgetState {
|
|
3824
|
-
UNINITIALIZED = "uninitialized",
|
|
3825
|
-
INITIALIZING = "initializing",
|
|
3826
|
-
READY = "ready",
|
|
3827
|
-
OPENING = "opening",
|
|
3828
|
-
OPEN = "open",
|
|
3829
|
-
CLOSING = "closing",
|
|
3830
|
-
RESETTING = "resetting",
|
|
3831
|
-
ERROR = "error",
|
|
3832
|
-
DESTROYED = "destroyed"
|
|
3833
|
-
}
|
|
3834
|
-
|
|
3835
3834
|
export declare const x: {
|
|
3836
3835
|
string: typeof ExString.create;
|
|
3837
3836
|
number: typeof ExNumber.create;
|
package/dist/index.d.mts
CHANGED
|
@@ -2754,7 +2754,7 @@ declare interface ExpressCSVLocale {
|
|
|
2754
2754
|
nextDisabledReviewValidating: string;
|
|
2755
2755
|
nextDisabledReviewInvalid: string;
|
|
2756
2756
|
};
|
|
2757
|
-
|
|
2757
|
+
importer: {
|
|
2758
2758
|
title: string;
|
|
2759
2759
|
loading: string;
|
|
2760
2760
|
closeConfirmTitle: string;
|
|
@@ -2763,7 +2763,6 @@ declare interface ExpressCSVLocale {
|
|
|
2763
2763
|
closeConfirmContinue: string;
|
|
2764
2764
|
errorTitle: string;
|
|
2765
2765
|
startOver: string;
|
|
2766
|
-
invalidPublishableKey: string;
|
|
2767
2766
|
};
|
|
2768
2767
|
sessionRecovery: {
|
|
2769
2768
|
message: string;
|
|
@@ -3476,6 +3475,29 @@ export declare class ImportCancelledError extends Error {
|
|
|
3476
3475
|
constructor(message?: string);
|
|
3477
3476
|
}
|
|
3478
3477
|
|
|
3478
|
+
/**
|
|
3479
|
+
* Importer preload mode
|
|
3480
|
+
*/
|
|
3481
|
+
export declare enum ImporterMode {
|
|
3482
|
+
NORMAL = "normal",
|
|
3483
|
+
PRELOAD = "preload"
|
|
3484
|
+
}
|
|
3485
|
+
|
|
3486
|
+
/**
|
|
3487
|
+
* Importer lifecycle state
|
|
3488
|
+
*/
|
|
3489
|
+
export declare enum ImporterState {
|
|
3490
|
+
UNINITIALIZED = "uninitialized",
|
|
3491
|
+
INITIALIZING = "initializing",
|
|
3492
|
+
READY = "ready",
|
|
3493
|
+
OPENING = "opening",
|
|
3494
|
+
OPEN = "open",
|
|
3495
|
+
CLOSING = "closing",
|
|
3496
|
+
RESETTING = "resetting",
|
|
3497
|
+
ERROR = "error",
|
|
3498
|
+
DESTROYED = "destroyed"
|
|
3499
|
+
}
|
|
3500
|
+
|
|
3479
3501
|
export declare type Infer<T extends ExType<unknown, ExBaseDef, unknown>> = T extends ExType<infer Output, ExBaseDef, unknown> ? Output : never;
|
|
3480
3502
|
|
|
3481
3503
|
declare type IPAddressVersion = 'v4' | 'v6' | 'all';
|
|
@@ -3498,12 +3520,12 @@ export declare type OpenOptions<T> = RequireAtLeastOne<DeliveryOptionsBase<T>, '
|
|
|
3498
3520
|
onCancel?: () => void;
|
|
3499
3521
|
/** Called when an error occurs */
|
|
3500
3522
|
onError?: (error: Error) => void;
|
|
3501
|
-
/** Called when the
|
|
3502
|
-
|
|
3523
|
+
/** Called when the importer opens */
|
|
3524
|
+
onImporterOpen?: () => void;
|
|
3525
|
+
/** Called when the importer closes */
|
|
3526
|
+
onImporterClose?: (reason: 'user_close' | 'cancel' | 'complete' | 'error') => void;
|
|
3503
3527
|
/** Called when the step changes in the wizard */
|
|
3504
3528
|
onStepChange?: (stepId: ExpressCSVStep, previousStepId?: ExpressCSVStep) => void;
|
|
3505
|
-
/** Called when the widget closes */
|
|
3506
|
-
onWidgetClose?: (reason: 'user_close' | 'cancel' | 'complete' | 'error') => void;
|
|
3507
3529
|
};
|
|
3508
3530
|
|
|
3509
3531
|
declare type PhoneNumberFormat = 'international' | 'national' | 'both';
|
|
@@ -3726,7 +3748,7 @@ export declare type TemplateDownloadOptions<TSchema extends ExType<unknown, ExBa
|
|
|
3726
3748
|
|
|
3727
3749
|
/**
|
|
3728
3750
|
* A branded string type for locale entries that require interpolation via `{variable}` syntax.
|
|
3729
|
-
*
|
|
3751
|
+
* Importer code cannot render a `TemplateString` directly in JSX — it must go through the `t()` function.
|
|
3730
3752
|
* The generic `TVars` encodes the expected variable names so `t()` enforces the correct vars argument.
|
|
3731
3753
|
*/
|
|
3732
3754
|
declare type TemplateString<TVars extends string = string> = string & {
|
|
@@ -3750,9 +3772,9 @@ declare interface URLOptions {
|
|
|
3750
3772
|
message?: string;
|
|
3751
3773
|
}
|
|
3752
3774
|
|
|
3753
|
-
export declare function useExpressCSV<TSchema extends ExType<unknown, ExBaseDef, unknown>>({ schema, title, importIdentifier,
|
|
3775
|
+
export declare function useExpressCSV<TSchema extends ExType<unknown, ExBaseDef, unknown>>({ schema, title, importIdentifier, getSessionToken, debug, preload, theme, colorMode, customCSS, fonts, stepDisplay, previewSchemaBeforeUpload, templateDownload, saveSession, locale, disableStatusStep, }: UseExpressCSVOptions<TSchema>): {
|
|
3754
3776
|
open: (options: OpenOptions<Infer<TSchema>>) => void;
|
|
3755
|
-
|
|
3777
|
+
importerState: ImporterState;
|
|
3756
3778
|
isInitialising: boolean;
|
|
3757
3779
|
isOpen: boolean;
|
|
3758
3780
|
};
|
|
@@ -3761,7 +3783,7 @@ export declare interface UseExpressCSVOptions<TSchema extends ExType<unknown, Ex
|
|
|
3761
3783
|
schema: TSchema;
|
|
3762
3784
|
title?: string;
|
|
3763
3785
|
importIdentifier: string;
|
|
3764
|
-
|
|
3786
|
+
getSessionToken: () => Promise<string>;
|
|
3765
3787
|
debug?: boolean;
|
|
3766
3788
|
preload?: boolean;
|
|
3767
3789
|
theme?: ECSVTheme;
|
|
@@ -3809,29 +3831,6 @@ export declare interface WebhookConfig {
|
|
|
3809
3831
|
awaitWebhookArrival?: boolean;
|
|
3810
3832
|
}
|
|
3811
3833
|
|
|
3812
|
-
/**
|
|
3813
|
-
* Widget mode enumeration
|
|
3814
|
-
*/
|
|
3815
|
-
export declare enum WidgetMode {
|
|
3816
|
-
NORMAL = "normal",
|
|
3817
|
-
PRELOAD = "preload"
|
|
3818
|
-
}
|
|
3819
|
-
|
|
3820
|
-
/**
|
|
3821
|
-
* Widget state enumeration for consistent state management
|
|
3822
|
-
*/
|
|
3823
|
-
export declare enum WidgetState {
|
|
3824
|
-
UNINITIALIZED = "uninitialized",
|
|
3825
|
-
INITIALIZING = "initializing",
|
|
3826
|
-
READY = "ready",
|
|
3827
|
-
OPENING = "opening",
|
|
3828
|
-
OPEN = "open",
|
|
3829
|
-
CLOSING = "closing",
|
|
3830
|
-
RESETTING = "resetting",
|
|
3831
|
-
ERROR = "error",
|
|
3832
|
-
DESTROYED = "destroyed"
|
|
3833
|
-
}
|
|
3834
|
-
|
|
3835
3834
|
export declare const x: {
|
|
3836
3835
|
string: typeof ExString.create;
|
|
3837
3836
|
number: typeof ExNumber.create;
|
package/dist/index.d.ts
CHANGED
|
@@ -2754,7 +2754,7 @@ declare interface ExpressCSVLocale {
|
|
|
2754
2754
|
nextDisabledReviewValidating: string;
|
|
2755
2755
|
nextDisabledReviewInvalid: string;
|
|
2756
2756
|
};
|
|
2757
|
-
|
|
2757
|
+
importer: {
|
|
2758
2758
|
title: string;
|
|
2759
2759
|
loading: string;
|
|
2760
2760
|
closeConfirmTitle: string;
|
|
@@ -2763,7 +2763,6 @@ declare interface ExpressCSVLocale {
|
|
|
2763
2763
|
closeConfirmContinue: string;
|
|
2764
2764
|
errorTitle: string;
|
|
2765
2765
|
startOver: string;
|
|
2766
|
-
invalidPublishableKey: string;
|
|
2767
2766
|
};
|
|
2768
2767
|
sessionRecovery: {
|
|
2769
2768
|
message: string;
|
|
@@ -3476,6 +3475,29 @@ export declare class ImportCancelledError extends Error {
|
|
|
3476
3475
|
constructor(message?: string);
|
|
3477
3476
|
}
|
|
3478
3477
|
|
|
3478
|
+
/**
|
|
3479
|
+
* Importer preload mode
|
|
3480
|
+
*/
|
|
3481
|
+
export declare enum ImporterMode {
|
|
3482
|
+
NORMAL = "normal",
|
|
3483
|
+
PRELOAD = "preload"
|
|
3484
|
+
}
|
|
3485
|
+
|
|
3486
|
+
/**
|
|
3487
|
+
* Importer lifecycle state
|
|
3488
|
+
*/
|
|
3489
|
+
export declare enum ImporterState {
|
|
3490
|
+
UNINITIALIZED = "uninitialized",
|
|
3491
|
+
INITIALIZING = "initializing",
|
|
3492
|
+
READY = "ready",
|
|
3493
|
+
OPENING = "opening",
|
|
3494
|
+
OPEN = "open",
|
|
3495
|
+
CLOSING = "closing",
|
|
3496
|
+
RESETTING = "resetting",
|
|
3497
|
+
ERROR = "error",
|
|
3498
|
+
DESTROYED = "destroyed"
|
|
3499
|
+
}
|
|
3500
|
+
|
|
3479
3501
|
export declare type Infer<T extends ExType<unknown, ExBaseDef, unknown>> = T extends ExType<infer Output, ExBaseDef, unknown> ? Output : never;
|
|
3480
3502
|
|
|
3481
3503
|
declare type IPAddressVersion = 'v4' | 'v6' | 'all';
|
|
@@ -3498,12 +3520,12 @@ export declare type OpenOptions<T> = RequireAtLeastOne<DeliveryOptionsBase<T>, '
|
|
|
3498
3520
|
onCancel?: () => void;
|
|
3499
3521
|
/** Called when an error occurs */
|
|
3500
3522
|
onError?: (error: Error) => void;
|
|
3501
|
-
/** Called when the
|
|
3502
|
-
|
|
3523
|
+
/** Called when the importer opens */
|
|
3524
|
+
onImporterOpen?: () => void;
|
|
3525
|
+
/** Called when the importer closes */
|
|
3526
|
+
onImporterClose?: (reason: 'user_close' | 'cancel' | 'complete' | 'error') => void;
|
|
3503
3527
|
/** Called when the step changes in the wizard */
|
|
3504
3528
|
onStepChange?: (stepId: ExpressCSVStep, previousStepId?: ExpressCSVStep) => void;
|
|
3505
|
-
/** Called when the widget closes */
|
|
3506
|
-
onWidgetClose?: (reason: 'user_close' | 'cancel' | 'complete' | 'error') => void;
|
|
3507
3529
|
};
|
|
3508
3530
|
|
|
3509
3531
|
declare type PhoneNumberFormat = 'international' | 'national' | 'both';
|
|
@@ -3726,7 +3748,7 @@ export declare type TemplateDownloadOptions<TSchema extends ExType<unknown, ExBa
|
|
|
3726
3748
|
|
|
3727
3749
|
/**
|
|
3728
3750
|
* A branded string type for locale entries that require interpolation via `{variable}` syntax.
|
|
3729
|
-
*
|
|
3751
|
+
* Importer code cannot render a `TemplateString` directly in JSX — it must go through the `t()` function.
|
|
3730
3752
|
* The generic `TVars` encodes the expected variable names so `t()` enforces the correct vars argument.
|
|
3731
3753
|
*/
|
|
3732
3754
|
declare type TemplateString<TVars extends string = string> = string & {
|
|
@@ -3750,9 +3772,9 @@ declare interface URLOptions {
|
|
|
3750
3772
|
message?: string;
|
|
3751
3773
|
}
|
|
3752
3774
|
|
|
3753
|
-
export declare function useExpressCSV<TSchema extends ExType<unknown, ExBaseDef, unknown>>({ schema, title, importIdentifier,
|
|
3775
|
+
export declare function useExpressCSV<TSchema extends ExType<unknown, ExBaseDef, unknown>>({ schema, title, importIdentifier, getSessionToken, debug, preload, theme, colorMode, customCSS, fonts, stepDisplay, previewSchemaBeforeUpload, templateDownload, saveSession, locale, disableStatusStep, }: UseExpressCSVOptions<TSchema>): {
|
|
3754
3776
|
open: (options: OpenOptions<Infer<TSchema>>) => void;
|
|
3755
|
-
|
|
3777
|
+
importerState: ImporterState;
|
|
3756
3778
|
isInitialising: boolean;
|
|
3757
3779
|
isOpen: boolean;
|
|
3758
3780
|
};
|
|
@@ -3761,7 +3783,7 @@ export declare interface UseExpressCSVOptions<TSchema extends ExType<unknown, Ex
|
|
|
3761
3783
|
schema: TSchema;
|
|
3762
3784
|
title?: string;
|
|
3763
3785
|
importIdentifier: string;
|
|
3764
|
-
|
|
3786
|
+
getSessionToken: () => Promise<string>;
|
|
3765
3787
|
debug?: boolean;
|
|
3766
3788
|
preload?: boolean;
|
|
3767
3789
|
theme?: ECSVTheme;
|
|
@@ -3809,29 +3831,6 @@ export declare interface WebhookConfig {
|
|
|
3809
3831
|
awaitWebhookArrival?: boolean;
|
|
3810
3832
|
}
|
|
3811
3833
|
|
|
3812
|
-
/**
|
|
3813
|
-
* Widget mode enumeration
|
|
3814
|
-
*/
|
|
3815
|
-
export declare enum WidgetMode {
|
|
3816
|
-
NORMAL = "normal",
|
|
3817
|
-
PRELOAD = "preload"
|
|
3818
|
-
}
|
|
3819
|
-
|
|
3820
|
-
/**
|
|
3821
|
-
* Widget state enumeration for consistent state management
|
|
3822
|
-
*/
|
|
3823
|
-
export declare enum WidgetState {
|
|
3824
|
-
UNINITIALIZED = "uninitialized",
|
|
3825
|
-
INITIALIZING = "initializing",
|
|
3826
|
-
READY = "ready",
|
|
3827
|
-
OPENING = "opening",
|
|
3828
|
-
OPEN = "open",
|
|
3829
|
-
CLOSING = "closing",
|
|
3830
|
-
RESETTING = "resetting",
|
|
3831
|
-
ERROR = "error",
|
|
3832
|
-
DESTROYED = "destroyed"
|
|
3833
|
-
}
|
|
3834
|
-
|
|
3835
3834
|
export declare const x: {
|
|
3836
3835
|
string: typeof ExString.create;
|
|
3837
3836
|
number: typeof ExNumber.create;
|