@expresscsv/sdk 0.1.5 → 0.1.6

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ExpressCSV
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # @expresscsv/sdk
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/@expresscsv/sdk.svg)](https://www.npmjs.com/package/@expresscsv/sdk)
4
- [![license](https://img.shields.io/npm/l/@expresscsv/sdk.svg)](https://github.com/nicholasgriffintn/expresscsv/blob/main/LICENSE)
4
+ ![license](https://img.shields.io/npm/l/@expresscsv/sdk.svg)
5
5
 
6
6
  A TypeScript SDK for embedding the [ExpressCSV](https://expresscsv.com) CSV import widget into any web application. Define a schema, open the widget, and receive validated, typed data in chunks.
7
7
 
@@ -120,7 +120,7 @@ const importer = new CSVImporter({
120
120
  importer.open({ onData: (chunk, next) => { /* ... */ next(); } });
121
121
  ```
122
122
 
123
- To disable preloading:
123
+ To disable preloading (there will be a brief loading screen instead):
124
124
 
125
125
  ```typescript
126
126
  const importer = new CSVImporter({
@@ -131,6 +131,136 @@ const importer = new CSVImporter({
131
131
  });
132
132
  ```
133
133
 
134
+ ## Theming and Styling
135
+
136
+ Customize the widget's appearance with the `theme`, `colorMode`, `customCSS`, and `fonts` options.
137
+
138
+ ### Theme
139
+
140
+ Use the `theme` option to override CSS variables (colors, radius, typography). Pass either a single theme (applies to both light and dark) or a dual-mode theme with separate light/dark values:
141
+
142
+ ```typescript
143
+ import { CSVImporter, x, type ECSVTheme } from "@expresscsv/sdk";
144
+
145
+ // Single theme (both modes)
146
+ const theme: ECSVTheme = {
147
+ primary: "#4F46E5",
148
+ "primary-foreground": "#ffffff",
149
+ background: "#ffffff",
150
+ foreground: "#0f172a",
151
+ border: "#e5e7eb",
152
+ ring: "#A5B4FC",
153
+ radius: "0.5rem",
154
+ };
155
+
156
+ // Dual-mode (light and dark)
157
+ const dualTheme: ECSVTheme = {
158
+ modes: {
159
+ light: {
160
+ primary: "#4F46E5",
161
+ background: "#ffffff",
162
+ foreground: "#0f172a",
163
+ },
164
+ dark: {
165
+ primary: "#a5b4fc",
166
+ background: "#09090b",
167
+ foreground: "#fafafa",
168
+ },
169
+ },
170
+ };
171
+
172
+ const importer = new CSVImporter({
173
+ schema,
174
+ publishableKey: "your-publishable-key",
175
+ importIdentifier: "user-import",
176
+ theme,
177
+ });
178
+ ```
179
+
180
+ Theme variables:
181
+
182
+ | Variable | Default |
183
+ |---|---|
184
+ | `radius` | `0.625rem` |
185
+ | `background` | `oklch(1 0 0)` |
186
+ | `foreground` | `oklch(0.145 0 0)` |
187
+ | `card` | `oklch(1 0 0)` |
188
+ | `card-foreground` | `oklch(0.145 0 0)` |
189
+ | `popover` | `oklch(1 0 0)` |
190
+ | `popover-foreground` | `oklch(0.145 0 0)` |
191
+ | `primary` | `oklch(0.205 0 0)` |
192
+ | `primary-foreground` | `oklch(0.985 0 0)` |
193
+ | `secondary` | `oklch(0.97 0 0)` |
194
+ | `secondary-foreground` | `oklch(0.205 0 0)` |
195
+ | `muted` | `oklch(0.97 0 0)` |
196
+ | `muted-foreground` | `oklch(0.556 0 0)` |
197
+ | `accent` | `oklch(0.7 0.2 145)` |
198
+ | `accent-foreground` | `oklch(0.985 0 0)` |
199
+ | `destructive` | `oklch(0.577 0.245 27.325)` |
200
+ | `destructive-foreground` | `oklch(0.985 0 0)` |
201
+ | `success` | `oklch(0.7 0.2 145)` |
202
+ | `success-foreground` | `oklch(0.985 0 0)` |
203
+ | `warning` | `oklch(0.769 0.188 70)` |
204
+ | `warning-foreground` | `oklch(0.985 0 0)` |
205
+ | `border` | `oklch(0.922 0 0)` |
206
+ | `input` | `oklch(0.922 0 0)` |
207
+ | `ring` | `oklch(0.708 0 0)` |
208
+ | `font-title` | `inherit` |
209
+ | `font-body` | `inherit` |
210
+
211
+ ### Color Mode
212
+
213
+ Control light/dark mode with `colorMode`:
214
+
215
+ ```typescript
216
+ const importer = new CSVImporter({
217
+ schema,
218
+ publishableKey: "your-publishable-key",
219
+ importIdentifier: "user-import",
220
+ colorMode: "system", // 'light' | 'dark' | 'system'
221
+ });
222
+ ```
223
+
224
+ ### Custom CSS
225
+
226
+ Inject custom CSS for fine-grained styling overrides.
227
+
228
+ ```typescript
229
+ const importer = new CSVImporter({
230
+ schema,
231
+ publishableKey: "your-publishable-key",
232
+ importIdentifier: "user-import",
233
+ customCSS: `
234
+ .ecsv [data-step="upload"] {
235
+ border-radius: 1rem;
236
+ }
237
+ .ecsv button {
238
+ font-weight: 600;
239
+ }
240
+ `,
241
+ });
242
+ ```
243
+
244
+ ### Custom Fonts
245
+
246
+ Load custom fonts via the `fonts` option:
247
+
248
+ ```typescript
249
+ const importer = new CSVImporter({
250
+ schema,
251
+ publishableKey: "your-publishable-key",
252
+ importIdentifier: "user-import",
253
+ fonts: {
254
+ title: { source: "google", name: "Space Grotesk", weights: [400, 600, 700] },
255
+ body: { source: "custom", url: "https://example.com/font.woff2", format: "woff2" },
256
+ },
257
+ theme: {
258
+ "font-title": "'Space Grotesk', sans-serif",
259
+ "font-body": "'Custom Font', sans-serif",
260
+ },
261
+ });
262
+ ```
263
+
134
264
  ## Schema Builder
135
265
 
136
266
  The `x` schema builder provides a type-safe, fluent API for defining your CSV structure.
@@ -233,7 +363,7 @@ new CSVImporter(options: SDKOptions)
233
363
  | `debug` | `boolean` | No | `false` | Enable debug logging |
234
364
  | `developerMode` | `boolean` | No | `false` | Enable developer mode features |
235
365
  | `theme` | `ECSVTheme` | No | - | Custom theme configuration |
236
- | `colorMode` | `ColorModeConfig` | No | - | Light/dark mode settings |
366
+ | `colorMode` | `ColorModePref` | No | - | Light/dark mode (`'light'`, `'dark'`, or `'system'`) |
237
367
  | `customCSS` | `string` | No | - | Custom CSS to inject into the widget |
238
368
  | `fonts` | `Record<string, ECSVFontSource>` | No | - | Custom font sources |
239
369
  | `stepDisplay` | `'progressBar' \| 'segmented' \| 'numbered'` | No | `'progressBar'` | Step indicator style |
@@ -274,6 +404,8 @@ await importer.close(reason?: 'user_close' | 'cancel' | 'complete' | 'error'): P
274
404
 
275
405
  #### Status Methods
276
406
 
407
+
408
+
277
409
  | Method | Returns | Description |
278
410
  |---|---|---|
279
411
  | `getState()` | `WidgetState` | Current widget state |
@@ -285,10 +417,6 @@ await importer.close(reason?: 'user_close' | 'cancel' | 'complete' | 'error'): P
285
417
  | `getStatus()` | `object` | Comprehensive status snapshot |
286
418
  | `getVersion()` | `string` | SDK version |
287
419
 
288
- #### `resetWidget()`
289
-
290
- Resets the widget state. Returns `Promise<void>`.
291
-
292
420
  #### `restart(newOptions?)`
293
421
 
294
422
  Restarts the widget, optionally with updated options. Returns `Promise<void>`.
@@ -299,7 +427,7 @@ The object passed to `onData` callbacks:
299
427
 
300
428
  ```typescript
301
429
  interface RecordsChunk<T> {
302
- records: T[];
430
+ records: T[]; // Automatically typed to your schema
303
431
  totalChunks: number;
304
432
  currentChunkIndex: number;
305
433
  totalRecords: number;
package/dist/index.d.mts CHANGED
@@ -4,15 +4,6 @@ declare interface BICOptions {
4
4
 
5
5
  declare type BooleanControlType = 'toggle' | 'checkbox' | 'dropdown';
6
6
 
7
- /**
8
- * Color mode configuration
9
- */
10
- export declare interface ColorModeConfig {
11
- default?: ColorModePref;
12
- persist?: boolean;
13
- onChange?: (mode: ColorModePref) => void;
14
- }
15
-
16
7
  /**
17
8
  * Color mode preference
18
9
  */
@@ -1326,7 +1317,7 @@ export declare class CSVImporter<TSchema extends ExType<unknown, ExBaseDef, unkn
1326
1317
  private createAndAppendIframe;
1327
1318
  private destroy;
1328
1319
  close(reason?: 'user_close' | 'cancel' | 'complete' | 'error'): Promise<void>;
1329
- resetWidget(): Promise<void>;
1320
+ private resetWidget;
1330
1321
  restart(newOptions?: Partial<SDKOptions<TSchema>>): Promise<void>;
1331
1322
  private handleWidgetClosed;
1332
1323
  private hideContainer;
@@ -3755,7 +3746,7 @@ export declare interface SDKOptions<TSchema extends ExType<unknown, ExBaseDef, u
3755
3746
  developerMode?: boolean;
3756
3747
  preload?: boolean;
3757
3748
  theme?: ECSVTheme;
3758
- colorMode?: ColorModeConfig;
3749
+ colorMode?: ColorModePref;
3759
3750
  customCSS?: string;
3760
3751
  fonts?: Record<string, ECSVFontSource>;
3761
3752
  stepDisplay?: 'progressBar' | 'segmented' | 'numbered';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@expresscsv/sdk",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "SDK for integrating widget",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.mts",