treege 3.0.0-beta.57 → 3.0.0-beta.59
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 +16 -17
- package/dist/{DefaultInputs-CoJrOYMe.js → DefaultInputs-CoDN_KvC.js} +783 -761
- package/dist/ThemeContext-ClYtPOGK.js +1402 -0
- package/dist/editor/constants/nodeSpacing.d.ts +0 -8
- package/dist/editor/features/TreegeEditor/TreegeEditor.d.ts +1 -1
- package/dist/editor/features/TreegeEditor/inputs/ApiUrlCombobox.d.ts +0 -10
- package/dist/editor/types/editor.d.ts +16 -3
- package/dist/{editor-D3cbfAxI.js → editor-Cd_ifJTX.js} +1177 -1158
- package/dist/editor.js +2 -2
- package/dist/main.js +4 -4
- package/dist/renderer/context/TreegeRendererContext.d.ts +14 -2
- package/dist/renderer/features/TreegeRenderer/useTreegeRenderer.d.ts +3 -2
- package/dist/renderer/features/TreegeRenderer/web/TreegeRenderer.d.ts +1 -1
- package/dist/renderer/hooks/useSubmitHandler.d.ts +2 -1
- package/dist/renderer/types/renderer.d.ts +17 -2
- package/dist/renderer/utils/http.d.ts +11 -0
- package/dist/renderer/utils/submit.d.ts +2 -1
- package/dist/renderer-native.js +701 -680
- package/dist/renderer.js +3 -3
- package/dist/shared/locales/ar.json.d.ts +3 -1
- package/dist/shared/locales/de.json.d.ts +3 -1
- package/dist/shared/locales/en.json.d.ts +3 -1
- package/dist/shared/locales/es.json.d.ts +3 -1
- package/dist/shared/locales/fr.json.d.ts +3 -1
- package/dist/shared/locales/it.json.d.ts +3 -1
- package/dist/shared/locales/pt.json.d.ts +3 -1
- package/package.json +1 -1
- package/dist/ThemeContext-BhIeqgqN.js +0 -1398
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
|
|
23
23
|
## Overview
|
|
24
24
|
|
|
25
|
-
Treege is a modern React library for creating and rendering interactive decision trees. Built on top of ReactFlow, it provides a complete solution for building complex form
|
|
25
|
+
Treege is a modern React library for creating and rendering interactive decision trees. Built on top of ReactFlow, it provides a complete solution for building complex form flow, decision logic, and conditional workflows with an intuitive visual editor.
|
|
26
26
|
|
|
27
27
|
## Features
|
|
28
28
|
|
|
@@ -132,7 +132,7 @@ function App() {
|
|
|
132
132
|
|
|
133
133
|
return (
|
|
134
134
|
<TreegeRenderer
|
|
135
|
-
|
|
135
|
+
flow={flow}
|
|
136
136
|
onSubmit={handleSubmit}
|
|
137
137
|
/>
|
|
138
138
|
);
|
|
@@ -159,7 +159,7 @@ function App() {
|
|
|
159
159
|
{mode === "edit" ? (
|
|
160
160
|
<TreegeEditor flow={flow} onSave={setFlow} />
|
|
161
161
|
) : (
|
|
162
|
-
<TreegeRenderer
|
|
162
|
+
<TreegeRenderer flow={flow} onSubmit={console.log} />
|
|
163
163
|
)}
|
|
164
164
|
</div>
|
|
165
165
|
);
|
|
@@ -242,7 +242,7 @@ function App() {
|
|
|
242
242
|
|
|
243
243
|
return (
|
|
244
244
|
<TreegeRenderer
|
|
245
|
-
|
|
245
|
+
flow={flow}
|
|
246
246
|
onSubmit={handleSubmit}
|
|
247
247
|
/>
|
|
248
248
|
);
|
|
@@ -255,7 +255,7 @@ You can customize the appearance using the `style` and `contentContainerStyle` p
|
|
|
255
255
|
|
|
256
256
|
```tsx
|
|
257
257
|
<TreegeRenderer
|
|
258
|
-
|
|
258
|
+
flow={flow}
|
|
259
259
|
onSubmit={handleSubmit}
|
|
260
260
|
style={{ flex: 1, backgroundColor: "#f5f5f5" }}
|
|
261
261
|
contentContainerStyle={{ padding: 20 }}
|
|
@@ -301,7 +301,7 @@ const CustomTextInput = (field, extra) => {
|
|
|
301
301
|
};
|
|
302
302
|
|
|
303
303
|
<TreegeRenderer
|
|
304
|
-
|
|
304
|
+
flow={flow}
|
|
305
305
|
components={{
|
|
306
306
|
inputs: {
|
|
307
307
|
text: CustomTextInput
|
|
@@ -337,7 +337,7 @@ The React Native renderer shares the same API as the web renderer, with some pla
|
|
|
337
337
|
|
|
338
338
|
| Prop | Type | Default | Description |
|
|
339
339
|
|-------------------------|---------------------------------------------|--------------|------------------------------------------------------------|
|
|
340
|
-
| `
|
|
340
|
+
| `flow` | `Flow \| null` | - | Decision tree to render |
|
|
341
341
|
| `onSubmit` | `(values: FormValues, meta?: Meta) => void` | - | Form submission handler (meta includes HTTP response data) |
|
|
342
342
|
| `onChange` | `(values: FormValues) => void` | - | Form change handler |
|
|
343
343
|
| `validate` | `(values, nodes) => Record<string, string>` | - | Custom validation function |
|
|
@@ -406,7 +406,7 @@ Supported UI types:
|
|
|
406
406
|
|
|
407
407
|
## Conditional Edges
|
|
408
408
|
|
|
409
|
-
Create dynamic
|
|
409
|
+
Create dynamic flow with conditional logic:
|
|
410
410
|
|
|
411
411
|
```tsx
|
|
412
412
|
{
|
|
@@ -474,7 +474,7 @@ const CustomTextInput = (field, extra) => {
|
|
|
474
474
|
};
|
|
475
475
|
|
|
476
476
|
<TreegeRenderer
|
|
477
|
-
|
|
477
|
+
flow={flow}
|
|
478
478
|
components={{
|
|
479
479
|
inputs: {
|
|
480
480
|
text: CustomTextInput
|
|
@@ -489,7 +489,7 @@ Add custom validation logic:
|
|
|
489
489
|
|
|
490
490
|
```tsx
|
|
491
491
|
<TreegeRenderer
|
|
492
|
-
|
|
492
|
+
flow={flow}
|
|
493
493
|
validate={(values, visibleNodes) => {
|
|
494
494
|
const errors = {};
|
|
495
495
|
|
|
@@ -558,7 +558,7 @@ function App() {
|
|
|
558
558
|
}
|
|
559
559
|
}}
|
|
560
560
|
>
|
|
561
|
-
<TreegeRenderer
|
|
561
|
+
<TreegeRenderer flow={flow} />
|
|
562
562
|
</TreegeConfigProvider>
|
|
563
563
|
);
|
|
564
564
|
}
|
|
@@ -572,7 +572,7 @@ When the flow is being fetched asynchronously, pass `isLoading` to render a skel
|
|
|
572
572
|
function App() {
|
|
573
573
|
const { data: flow, isPending } = useQuery(/* ... */);
|
|
574
574
|
|
|
575
|
-
return <TreegeRenderer
|
|
575
|
+
return <TreegeRenderer flow={flow ?? null} isLoading={isPending} onSubmit={console.log} />;
|
|
576
576
|
}
|
|
577
577
|
```
|
|
578
578
|
|
|
@@ -580,7 +580,7 @@ Customize the skeleton via `components.loadingSkeleton`:
|
|
|
580
580
|
|
|
581
581
|
```tsx
|
|
582
582
|
<TreegeRenderer
|
|
583
|
-
|
|
583
|
+
flow={flow}
|
|
584
584
|
isLoading={isPending}
|
|
585
585
|
components={{
|
|
586
586
|
loadingSkeleton: () => <MyCustomSkeleton />,
|
|
@@ -596,7 +596,7 @@ Override the default step layout via `components.step`:
|
|
|
596
596
|
|
|
597
597
|
```tsx
|
|
598
598
|
<TreegeRenderer
|
|
599
|
-
|
|
599
|
+
flow={flow}
|
|
600
600
|
components={{
|
|
601
601
|
step: ({ label, children, isFirstStep, isLastStep, canContinue, onBack, onContinue }) => (
|
|
602
602
|
<section>
|
|
@@ -627,12 +627,11 @@ function CustomForm({ flow }) {
|
|
|
627
627
|
formErrors,
|
|
628
628
|
visibleNodes,
|
|
629
629
|
isSubmitting,
|
|
630
|
-
// step navigation
|
|
631
630
|
currentStep,
|
|
632
631
|
goToNextStep,
|
|
633
632
|
goToPreviousStep,
|
|
634
633
|
} = useTreegeRenderer({
|
|
635
|
-
|
|
634
|
+
flow,
|
|
636
635
|
onSubmit: (values) => console.log("Submitted:", values),
|
|
637
636
|
});
|
|
638
637
|
|
|
@@ -706,7 +705,7 @@ Once the development server is running, you can access these examples:
|
|
|
706
705
|
|
|
707
706
|
| Prop | Type | Default | Description |
|
|
708
707
|
|------------------|---------------------------------------------|--------------|------------------------------------------------------------|
|
|
709
|
-
| `
|
|
708
|
+
| `flow` | `Flow \| null` | - | Decision tree to render |
|
|
710
709
|
| `onSubmit` | `(values: FormValues, meta?: Meta) => void` | - | Form submission handler (meta includes HTTP response data) |
|
|
711
710
|
| `onChange` | `(values: FormValues) => void` | - | Form change handler |
|
|
712
711
|
| `validate` | `(values, nodes) => Record<string, string>` | - | Custom validation function |
|