@habit.analytics/habit-claims-journey-components 2.3.3 → 2.3.4

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 CHANGED
@@ -420,6 +420,51 @@ See [docs/SCHEMAS.md](./docs/SCHEMAS.md) for the full reference of required fiel
420
420
  | `v2_phone-1` | Phone with country code | Length check |
421
421
  | `v2_email-1` | Email input | Format regex |
422
422
 
423
+ ### Upload Configuration (`uploadConfig`)
424
+
425
+ ```ts
426
+ interface UploadConfig {
427
+ accept?: string; // MIME types or extensions (e.g. "image/*,.pdf")
428
+ maxSizeMB?: number; // Max file size in MB
429
+ multiple?: boolean; // When true, allows multiple files
430
+ maxFiles?: number; // Max number of files (when multiple is true)
431
+ }
432
+ ```
433
+
434
+ Single-file upload (default): `uploadConfig` without `multiple` or with `multiple: false`.
435
+ Multi-file upload: set `uploadConfig.multiple: true`. When `maxFiles` is set, the widget enforces the limit.
436
+
437
+ ### Multi-File Upload Example
438
+
439
+ ```ts
440
+ {
441
+ "field_id": "f-photos",
442
+ "namespace": "claim.photos",
443
+ "label": "Photos",
444
+ "schema": "v2_single_asset_upload",
445
+ "widget": "upload",
446
+ "uploadConfig": {
447
+ "accept": "image/*,.pdf",
448
+ "maxSizeMB": 10,
449
+ "multiple": true,
450
+ "maxFiles": 5
451
+ }
452
+ }
453
+ ```
454
+
455
+ When `multiple: true`, the answer value in `onSubmit` is an array of `UploadResult`:
456
+
457
+ ```json
458
+ {
459
+ "claim.photos": [
460
+ { "filename": "photo1.jpg", "url": "https://...", "mimetype": "image/jpeg", "size": 12345 },
461
+ { "filename": "photo2.jpg", "url": "https://...", "mimetype": "image/jpeg", "size": 67890 }
462
+ ]
463
+ }
464
+ ```
465
+
466
+ See [docs/MULTI-UPLOAD.md](./docs/MULTI-UPLOAD.md) for a full migration guide.
467
+
423
468
  Fields can override the default widget via `widget` (e.g. a `v1_string` rendered as `"textarea"` or `"email"`).
424
469
 
425
470
  ---
@@ -0,0 +1,20 @@
1
+ import { UploadResult } from '../../../types/journey';
2
+ interface MultiUploadWidgetProps {
3
+ label: string;
4
+ value: UploadResult[];
5
+ onChange: (value: UploadResult[]) => void;
6
+ onFileSelect?: (file: File) => Promise<string | UploadResult | void> | void;
7
+ helpText?: string;
8
+ accept?: string;
9
+ maxSizeMB?: number;
10
+ maxFiles?: number;
11
+ }
12
+ /**
13
+ * Multi-file upload widget.
14
+ *
15
+ * Renders a drag-and-drop zone that accepts multiple files. Each selected
16
+ * file is validated (size + type) and then processed through `onFileSelect`.
17
+ * The widget maintains an internal array of uploaded results.
18
+ */
19
+ export declare function MultiUploadWidget({ label, value, onChange, onFileSelect, helpText, accept, maxSizeMB, maxFiles, }: MultiUploadWidgetProps): import("react/jsx-runtime").JSX.Element;
20
+ export {};
@@ -89,6 +89,7 @@ declare const en: {
89
89
  readonly upload_accepted_types_placeholder: "e.g. image/*,.pdf";
90
90
  readonly upload_max_size: "Max file size (MB)";
91
91
  readonly upload_max_size_placeholder: "e.g. 10";
92
+ readonly upload_max_files: "Max number of files";
92
93
  readonly edge_props_title: "Edge Properties";
93
94
  readonly edge_connection: "Connection";
94
95
  readonly edge_default: "Default Edge";
@@ -130,7 +131,10 @@ declare const en: {
130
131
  readonly create_node_namespace_hint: "Auto-generated from label. Override if needed.";
131
132
  readonly create_node_schema: "Schema Type";
132
133
  readonly upload_drag_drop: "Drag & drop a file here, or click to select";
134
+ readonly upload_drag_drop_multiple: "Drag & drop files here, or click to select";
133
135
  readonly upload_uploading: "Uploading…";
136
+ readonly upload_files_count: "{{count}} file(s) uploaded";
137
+ readonly upload_max_reached: "Maximum {{max}} files reached";
134
138
  readonly widget_unknown_schema: "Unknown schema type: {{schema}}";
135
139
  readonly widget_yes: "Yes";
136
140
  readonly widget_no: "No";