treege 3.0.0-beta.80 → 3.0.0-beta.81

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
@@ -651,6 +651,32 @@ const { data } = useQuery(/* ... */);
651
651
  <TreegeRenderer flow={flow} initialValues={data ?? {}} onSubmit={handleSubmit} />
652
652
  ```
653
653
 
654
+ #### Pre-filling file fields
655
+
656
+ A `file` field's value is a serializable object (never a DOM `File`, so it round-trips through JSON):
657
+
658
+ ```ts
659
+ type SerializableFile = {
660
+ name: string;
661
+ size: number;
662
+ type: string;
663
+ lastModified: number;
664
+ data: string; // base64 data-URL (web) or file URI (native)
665
+ };
666
+ ```
667
+
668
+ The stored value is a single `SerializableFile` (or an array when the field is `multiple`, or `null`). Pass the same shape in `initialValues` to pre-fill a file field when editing — the renderer lists the files and lets the user remove them or add more. Only `name`/`size` are needed for display, so `data` can hold a server URL for already-uploaded files:
669
+
670
+ ```tsx
671
+ <TreegeRenderer
672
+ flow={flow}
673
+ initialValues={{
674
+ attachment: { name: "contract.pdf", size: 24576, type: "application/pdf", lastModified: 0, data: "https://cdn.example.com/contract.pdf" },
675
+ }}
676
+ onSubmit={handleSubmit}
677
+ />
678
+ ```
679
+
654
680
  ### Submitting State
655
681
 
656
682
  Pass `isSubmitting` to keep the submit/continue button in its loading state (spinner + disabled) while an async `onSubmit` resolves on your side. It's OR-ed with the renderer's own internal submitting state (e.g. during an HTTP `submitConfig` call):