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 +26 -0
- package/dist/{DefaultSubmitButton-Bk5U_6Qm.js → DefaultSubmitButton-Dg9GPvh-.js} +686 -652
- package/dist/{ThemeContext-DeWmeqHK.js → ThemeContext-BgTIhoK6.js} +18 -11
- package/dist/editor/features/TreegeEditor/inputs/DefaultFileValueField.d.ts +14 -0
- package/dist/{editor-Dw_ODEe1.js → editor-h20-TVM8.js} +1282 -1214
- package/dist/editor.js +2 -2
- package/dist/main.js +6 -6
- package/dist/renderer/utils/file.d.ts +11 -10
- package/dist/{renderer-CN83AtIp.js → renderer-DI6nF4St.js} +18 -18
- package/dist/renderer-native.js +1020 -1019
- package/dist/renderer.js +5 -5
- package/dist/shared/locales/ar.json.d.ts +1 -0
- package/dist/shared/locales/de.json.d.ts +1 -0
- package/dist/shared/locales/en.json.d.ts +1 -0
- package/dist/shared/locales/es.json.d.ts +1 -0
- package/dist/shared/locales/fr.json.d.ts +1 -0
- package/dist/shared/locales/it.json.d.ts +1 -0
- package/dist/shared/locales/pt.json.d.ts +1 -0
- package/dist/shared/types/file.d.ts +14 -0
- package/dist/shared/types/node.d.ts +2 -1
- package/dist/useRenderNode-B1sfwbia.js +527 -0
- package/package.json +1 -1
- package/dist/useRenderNode-BZ7fZJxT.js +0 -527
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):
|