treege 3.0.0-beta.6 → 3.0.0-beta.60
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 +18 -12
- package/README.md +425 -81
- package/dist/DefaultInputs-nRQc9BHG.js +1881 -0
- package/dist/ThemeContext-Ddk_Y-Dz.js +1402 -0
- package/dist/editor/components/input/ComboboxWithCreate.d.ts +2 -1
- package/dist/editor/components/styles/EditorStyles.d.ts +2 -0
- package/dist/editor/constants/defaultNode.d.ts +1 -1
- package/dist/editor/constants/edgeTypes.d.ts +3 -2
- package/dist/editor/constants/inputTypeIcons.d.ts +3 -0
- package/dist/editor/constants/nodeSpacing.d.ts +25 -0
- package/dist/editor/constants/nodeTypes.d.ts +4 -5
- package/dist/editor/context/OpenApiContext.d.ts +79 -0
- package/dist/editor/context/TreegeEditorRuntimeProvider.d.ts +78 -0
- package/dist/editor/features/TreegeEditor/TreegeEditor.d.ts +1 -1
- package/dist/editor/features/TreegeEditor/controls/MiniMapControl.d.ts +6 -0
- package/dist/editor/features/TreegeEditor/dialogs/AuthorizeDialog.d.ts +20 -0
- package/dist/editor/features/TreegeEditor/dialogs/ChangeNodeTypeDialog.d.ts +2 -0
- package/dist/editor/features/TreegeEditor/dialogs/DeleteNodeDialog.d.ts +2 -0
- package/dist/editor/features/TreegeEditor/dialogs/HeadersDialog.d.ts +19 -0
- package/dist/editor/features/TreegeEditor/dialogs/OpenApiDialog.d.ts +6 -0
- package/dist/editor/features/TreegeEditor/edges/ConditionalEdge.d.ts +2 -2
- package/dist/editor/features/TreegeEditor/edges/DefaultEdge.d.ts +3 -0
- package/dist/editor/features/TreegeEditor/forms/OptionsMappingFields.d.ts +34 -0
- package/dist/editor/features/TreegeEditor/forms/OptionsSourceForm.d.ts +7 -0
- package/dist/editor/features/TreegeEditor/forms/SensitiveHeaderWarning.d.ts +13 -0
- package/dist/editor/features/TreegeEditor/forms/SubmitConfigForm.d.ts +7 -0
- package/dist/editor/features/TreegeEditor/inputs/ApiUrlCombobox.d.ts +20 -0
- package/dist/editor/features/TreegeEditor/inputs/ComboboxPattern.d.ts +2 -1
- package/dist/editor/features/TreegeEditor/inputs/OptionImageField.d.ts +6 -0
- package/dist/editor/features/TreegeEditor/inputs/SelectNodeGroup.d.ts +22 -1
- package/dist/editor/features/TreegeEditor/layout/AutoLayout.d.ts +15 -0
- package/dist/editor/features/TreegeEditor/nodes/TreegeNode.d.ts +5 -0
- package/dist/editor/features/TreegeEditor/nodes/components/BottomHandleDropdown.d.ts +25 -0
- package/dist/editor/features/TreegeEditor/nodes/components/NodeGroupBadge.d.ts +6 -0
- package/dist/editor/features/TreegeEditor/nodes/components/NodeImage.d.ts +5 -0
- package/dist/editor/features/TreegeEditor/nodes/components/NodeImageButton.d.ts +6 -0
- package/dist/editor/features/TreegeEditor/nodes/components/NodeInputPreview.d.ts +12 -0
- package/dist/editor/features/TreegeEditor/nodes/components/NodeLabelInput.d.ts +10 -0
- package/dist/editor/features/TreegeEditor/nodes/components/NodeMoreMenu.d.ts +6 -0
- package/dist/editor/features/TreegeEditor/nodes/components/NodeRequiredButton.d.ts +6 -0
- package/dist/editor/features/TreegeEditor/nodes/components/NodeStackOrderButtons.d.ts +6 -0
- package/dist/editor/features/TreegeEditor/nodes/components/NodeTypeBadge.d.ts +7 -0
- package/dist/editor/features/TreegeEditor/nodes/components/NodeTypePickerMenuContent.d.ts +12 -0
- package/dist/editor/features/TreegeEditor/nodes/layout/NodeWrapper.d.ts +4 -2
- package/dist/editor/features/TreegeEditor/panel/AIGeneratorDialog.d.ts +16 -0
- package/dist/editor/features/TreegeEditor/panel/ActionsPanel.d.ts +7 -2
- package/dist/editor/features/TreegeEditor/panel/MultiSelectionPanel.d.ts +7 -0
- package/dist/editor/hooks/useAvailableParentFields.d.ts +13 -0
- package/dist/editor/hooks/useFlowActions.d.ts +6 -2
- package/dist/editor/hooks/useFlowConnections.d.ts +14 -0
- package/dist/editor/hooks/useHistoryStore.d.ts +26 -0
- package/dist/editor/hooks/useIsStackedEdge.d.ts +8 -0
- package/dist/editor/hooks/useNodesSelection.d.ts +5 -5
- package/dist/editor/hooks/useStackPosition.d.ts +14 -0
- package/dist/editor/hooks/useTranslate.d.ts +1 -1
- package/dist/editor/hooks/useUndoRedo.d.ts +31 -0
- package/dist/editor/types/ai.d.ts +65 -0
- package/dist/editor/types/editor.d.ts +103 -10
- package/dist/editor/types/openapi.d.ts +81 -0
- package/dist/editor/utils/aiFlowGenerator.d.ts +5 -0
- package/dist/editor/utils/cleanNodeConfig.d.ts +5 -0
- package/dist/editor/utils/dagreLayout.d.ts +8 -0
- package/dist/editor/utils/edge.d.ts +50 -0
- package/dist/editor/utils/groupColor.d.ts +14 -0
- package/dist/editor/utils/image.d.ts +7 -0
- package/dist/editor/utils/inputTypeIcon.d.ts +6 -0
- package/dist/editor/utils/openapi.d.ts +35 -0
- package/dist/editor/utils/sensitiveHeaders.d.ts +15 -0
- package/dist/editor/utils/stackPositionIndex.d.ts +9 -0
- package/dist/editor-D2pBjE7E.js +6251 -0
- package/dist/editor.js +3 -7
- package/dist/main.js +4 -52
- package/dist/renderer/context/TreegeRenderRuntimeProvider.d.ts +135 -0
- package/dist/renderer/context/TreegeRendererProvider.d.ts +15 -0
- package/dist/renderer/features/TreegeRenderer/InputRendererHost.d.ts +15 -0
- package/dist/renderer/features/TreegeRenderer/native/TreegeRenderer.d.ts +19 -11
- package/dist/renderer/features/TreegeRenderer/native/components/DefaultFormWrapper.d.ts +7 -7
- package/dist/renderer/features/TreegeRenderer/native/components/DefaultInputWrapper.d.ts +9 -0
- package/dist/renderer/features/TreegeRenderer/native/components/DefaultInputs.d.ts +21 -15
- package/dist/renderer/features/TreegeRenderer/native/components/DefaultLoadingSkeleton.d.ts +8 -0
- package/dist/renderer/features/TreegeRenderer/native/components/DefaultStep.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/DefaultSubmitButton.d.ts +9 -7
- package/dist/renderer/features/TreegeRenderer/native/components/DefaultSubmitButtonWrapper.d.ts +11 -0
- package/dist/renderer/features/TreegeRenderer/native/components/DefaultUI.d.ts +8 -7
- package/dist/renderer/features/TreegeRenderer/native/components/DependencyHint.d.ts +15 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultAddressInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultAutocompleteInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultCheckboxInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultDateInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultDateRangeInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultFileInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultHiddenInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultHttpInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultNumberInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultPasswordInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultRadioInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultSelectInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultSwitchInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultTextInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultTextareaInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultTimeInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultTimeRangeInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/useTreegeRenderer.d.ts +94 -24
- package/dist/renderer/features/TreegeRenderer/web/TreegeRenderer.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/DefaultFormWrapper.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/DefaultInputWrapper.d.ts +9 -0
- package/dist/renderer/features/TreegeRenderer/web/components/DefaultLoadingSkeleton.d.ts +7 -0
- package/dist/renderer/features/TreegeRenderer/web/components/DefaultStep.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/web/components/DefaultSubmitButton.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/DependencyHint.d.ts +22 -0
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultAddressInput.d.ts +2 -2
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultAutocompleteInput.d.ts +2 -2
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultCheckboxInput.d.ts +2 -2
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultDateInput.d.ts +2 -2
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultDateRangeInput.d.ts +2 -2
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultFileInput.d.ts +2 -2
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultHiddenInput.d.ts +2 -2
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultHttpInput.d.ts +2 -2
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultNumberInput.d.ts +2 -2
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultPasswordInput.d.ts +2 -2
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultRadioInput.d.ts +2 -2
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultSelectInput.d.ts +2 -2
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultSubmitInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultSwitchInput.d.ts +2 -2
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultTextAreaInput.d.ts +2 -2
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultTextInput.d.ts +2 -2
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultTimeInput.d.ts +2 -2
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultTimeRangeInput.d.ts +2 -2
- package/dist/renderer/features/TreegeRenderer/web/components/styles/RendererStyles.d.ts +2 -0
- package/dist/renderer/hooks/useInputOptions.d.ts +28 -0
- package/dist/renderer/hooks/useRenderNode.d.ts +58 -0
- package/dist/renderer/hooks/useSubmitHandler.d.ts +36 -0
- package/dist/renderer/hooks/useTranslate.d.ts +7 -5
- package/dist/renderer/index.d.ts +4 -2
- package/dist/renderer/index.native.d.ts +19 -0
- package/dist/renderer/types/renderer.d.ts +208 -41
- package/dist/renderer/utils/flow.d.ts +1 -18
- package/dist/renderer/utils/form.d.ts +22 -2
- package/dist/renderer/utils/http.d.ts +152 -0
- package/dist/renderer/utils/node.d.ts +29 -1
- package/dist/renderer/utils/sanitize.d.ts +85 -0
- package/dist/renderer/utils/sanitize.native.d.ts +69 -0
- package/dist/renderer/utils/step.d.ts +27 -0
- package/dist/renderer/utils/submit.d.ts +49 -0
- package/dist/renderer/utils/templateDependencies.d.ts +17 -0
- package/dist/renderer-native.d.ts +2 -0
- package/dist/renderer-native.js +3702 -0
- package/dist/renderer.js +3 -45
- package/dist/shared/components/ui/badge.d.ts +2 -2
- package/dist/shared/components/ui/button.d.ts +3 -3
- package/dist/shared/components/ui/collapsible.d.ts +1 -1
- package/dist/shared/components/ui/command.d.ts +1 -1
- package/dist/shared/components/ui/dropdown-menu.d.ts +1 -1
- package/dist/shared/components/ui/field.d.ts +24 -0
- package/dist/shared/components/ui/form.d.ts +1 -1
- package/dist/shared/components/ui/popover.d.ts +4 -2
- package/dist/shared/components/ui/select.d.ts +3 -1
- package/dist/shared/components/ui/sheet.d.ts +1 -1
- package/dist/shared/components/ui/skeleton.d.ts +3 -0
- package/dist/shared/components/ui/toggle-group.d.ts +7 -0
- package/dist/shared/components/ui/toggle.d.ts +9 -0
- package/dist/shared/components/ui/tooltip.d.ts +1 -1
- package/dist/shared/constants/colors.d.ts +45 -0
- package/dist/shared/constants/inputType.d.ts +6 -0
- package/dist/shared/constants/node.d.ts +0 -1
- package/dist/shared/context/ThemeContext.d.ts +2 -0
- package/dist/shared/context/ThemeContext.native.d.ts +22 -0
- package/dist/shared/hooks/useMediaQuery.d.ts +12 -0
- package/dist/shared/hooks/useThemeColors.d.ts +37 -0
- package/dist/shared/locales/ar.json.d.ts +243 -19
- package/dist/shared/locales/de.json.d.ts +244 -20
- package/dist/shared/locales/en.json.d.ts +245 -21
- package/dist/shared/locales/es.json.d.ts +244 -20
- package/dist/shared/locales/fr.json.d.ts +244 -20
- package/dist/shared/locales/it.json.d.ts +244 -20
- package/dist/shared/locales/pt.json.d.ts +244 -20
- package/dist/shared/types/edge.d.ts +6 -0
- package/dist/shared/types/node.d.ts +129 -7
- package/dist/shared/utils/inputTypeGuards.d.ts +7 -0
- package/dist/shared/utils/nodeTypeGuards.d.ts +1 -6
- package/package.json +48 -22
- package/dist/ThemeContext-BIvs8Kw-.js +0 -758
- package/dist/TreegeEditor-Lv5Tn9_F.js +0 -2152
- package/dist/TreegeRenderer-D3EvsEfJ.js +0 -1413
- package/dist/editor/context/TreegeEditorContext.d.ts +0 -12
- package/dist/editor/features/TreegeEditor/forms/FlowNodeForm.d.ts +0 -2
- package/dist/editor/features/TreegeEditor/inputs/SelectInputType.d.ts +0 -7
- package/dist/editor/features/TreegeEditor/nodes/FlowNode.d.ts +0 -6
- package/dist/editor/features/TreegeEditor/nodes/GroupNode.d.ts +0 -6
- package/dist/editor/features/TreegeEditor/nodes/InputNode.d.ts +0 -6
- package/dist/editor/features/TreegeEditor/nodes/UINode.d.ts +0 -6
- package/dist/editor/hooks/useEdgesSelection.d.ts +0 -11
- package/dist/renderer/context/TreegeConfigContext.d.ts +0 -39
- package/dist/renderer/context/TreegeRendererContext.d.ts +0 -25
- package/dist/renderer/features/TreegeRenderer/native/components/DefaultGroup.d.ts +0 -7
- package/dist/renderer/features/TreegeRenderer/web/components/DefaultGroup.d.ts +0 -6
- /package/dist/editor/components/{data-display/logo.d.ts → branding/Logo.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -5,14 +5,16 @@
|
|
|
5
5
|
<p><strong>Build powerful decision trees with a visual node-based editor</strong></p>
|
|
6
6
|
|
|
7
7
|
[](https://badge.fury.io/js/treege)
|
|
8
|
-
[](https://opensource.org/licenses/MIT)
|
|
9
9
|
|
|
10
10
|
<p>
|
|
11
|
+
<a href="https://treege.io/">🌐 Website</a> •
|
|
12
|
+
<a href="https://treege.io/playground/">🎮 Playground</a> •
|
|
11
13
|
<a href="#features">Features</a> •
|
|
12
14
|
<a href="#installation">Installation</a> •
|
|
13
15
|
<a href="#quick-start">Quick Start</a> •
|
|
14
|
-
<a href="#
|
|
15
|
-
<a href="
|
|
16
|
+
<a href="#examples">Examples</a> •
|
|
17
|
+
<a href="./AI_GENERATION.md">🪄 AI Generation</a>
|
|
16
18
|
</p>
|
|
17
19
|
</div>
|
|
18
20
|
|
|
@@ -20,23 +22,35 @@
|
|
|
20
22
|
|
|
21
23
|
## Overview
|
|
22
24
|
|
|
23
|
-
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.
|
|
24
26
|
|
|
25
27
|
## Features
|
|
26
28
|
|
|
27
29
|
### Visual Editor (`treege/editor`)
|
|
28
30
|
- **Node-based Interface**: Drag-and-drop editor powered by ReactFlow
|
|
29
|
-
- **
|
|
30
|
-
- **Conditional Edges**: Advanced logic with AND/OR operators
|
|
31
|
-
- **
|
|
31
|
+
- **3 Node Types**: Input, UI, and Group nodes
|
|
32
|
+
- **Conditional Edges**: Advanced logic with AND/OR operators (`===`, `!==`, `>`, `<`, `>=`, `<=`)
|
|
33
|
+
- **AI-Powered Generation**: Generate decision trees from natural language descriptions using Gemini, OpenAI, DeepSeek, or Claude ([Learn more](./AI_GENERATION.md))
|
|
34
|
+
- **Multi-language Support**: Built-in translation system for all labels
|
|
32
35
|
- **Type-safe**: Full TypeScript support
|
|
36
|
+
- **Mini-map & Controls**: Navigation tools for complex trees
|
|
37
|
+
- **Theme Support**: Dark/light mode with customizable backgrounds
|
|
33
38
|
|
|
34
39
|
### Runtime Renderer (`treege/renderer`)
|
|
35
|
-
- **
|
|
36
|
-
- **
|
|
37
|
-
- **
|
|
38
|
-
- **
|
|
40
|
+
- **Production Ready**: Full-featured form generation and validation system
|
|
41
|
+
- **16 Input Types**: text, number, select, checkbox, radio, date, daterange, time, timerange, file, address, http, textarea, password, switch, autocomplete, and hidden
|
|
42
|
+
- **Cross-Platform**: Full support for both React Web and React Native with dedicated implementations
|
|
43
|
+
- **HTTP Integration**: Built-in API integration with response mapping and search functionality
|
|
44
|
+
- **Advanced Validation**: Required fields, pattern matching, custom validation functions
|
|
45
|
+
- **Security**: Built-in input sanitization to prevent XSS attacks
|
|
46
|
+
- **Enhanced Error Messages**: Clear, user-friendly error messages for HTTP inputs and validation
|
|
47
|
+
- **Conditional Logic**: Dynamic field visibility based on user input and conditional edges
|
|
48
|
+
- **Multi-Step Forms**: Group nodes are automatically turned into navigable steps with Back/Continue controls
|
|
49
|
+
- **Loading State**: Built-in `isLoading` prop renders a customizable skeleton while the flow is being fetched
|
|
50
|
+
- **Fully Customizable**: Override any component (form, inputs, ui, step, submitButton, submitButtonWrapper, loadingSkeleton)
|
|
51
|
+
- **Optional Dependencies**: Graceful degradation when optional packages like `react-native-document-picker` aren't installed
|
|
39
52
|
- **Theme Support**: Dark/light mode out of the box
|
|
53
|
+
- **Google API Integration**: Address autocomplete support
|
|
40
54
|
|
|
41
55
|
### Developer Experience
|
|
42
56
|
- **Modular**: Import only what you need (editor, renderer, or both)
|
|
@@ -47,6 +61,9 @@ Treege is a modern React library for creating and rendering interactive decision
|
|
|
47
61
|
## Installation
|
|
48
62
|
|
|
49
63
|
```bash
|
|
64
|
+
# bun
|
|
65
|
+
bun add treege
|
|
66
|
+
|
|
50
67
|
# npm
|
|
51
68
|
npm install treege
|
|
52
69
|
|
|
@@ -55,9 +72,6 @@ pnpm add treege
|
|
|
55
72
|
|
|
56
73
|
# yarn
|
|
57
74
|
yarn add treege
|
|
58
|
-
|
|
59
|
-
# bun
|
|
60
|
-
bun add treege
|
|
61
75
|
```
|
|
62
76
|
|
|
63
77
|
## Quick Start
|
|
@@ -118,7 +132,7 @@ function App() {
|
|
|
118
132
|
|
|
119
133
|
return (
|
|
120
134
|
<TreegeRenderer
|
|
121
|
-
|
|
135
|
+
flow={flow}
|
|
122
136
|
onSubmit={handleSubmit}
|
|
123
137
|
/>
|
|
124
138
|
);
|
|
@@ -145,7 +159,7 @@ function App() {
|
|
|
145
159
|
{mode === "edit" ? (
|
|
146
160
|
<TreegeEditor flow={flow} onSave={setFlow} />
|
|
147
161
|
) : (
|
|
148
|
-
<TreegeRenderer
|
|
162
|
+
<TreegeRenderer flow={flow} onSubmit={console.log} />
|
|
149
163
|
)}
|
|
150
164
|
</div>
|
|
151
165
|
);
|
|
@@ -154,7 +168,7 @@ function App() {
|
|
|
154
168
|
|
|
155
169
|
## Module Structure
|
|
156
170
|
|
|
157
|
-
Treege provides
|
|
171
|
+
Treege provides multiple import paths for optimal bundle size:
|
|
158
172
|
|
|
159
173
|
```tsx
|
|
160
174
|
// Import everything (editor + renderer + types)
|
|
@@ -163,25 +177,185 @@ import { TreegeEditor, TreegeRenderer } from "treege";
|
|
|
163
177
|
// Import only the editor
|
|
164
178
|
import { TreegeEditor } from "treege/editor";
|
|
165
179
|
|
|
166
|
-
// Import only the renderer
|
|
180
|
+
// Import only the web renderer
|
|
167
181
|
import { TreegeRenderer } from "treege/renderer";
|
|
182
|
+
|
|
183
|
+
// Import only the React Native renderer
|
|
184
|
+
import { TreegeRenderer } from "treege/renderer-native";
|
|
168
185
|
```
|
|
169
186
|
|
|
170
|
-
##
|
|
187
|
+
## React Native Support
|
|
188
|
+
|
|
189
|
+
Treege 3.0 includes full React Native support with a dedicated renderer implementation.
|
|
190
|
+
|
|
191
|
+
### Installation for React Native
|
|
171
192
|
|
|
172
|
-
|
|
173
|
-
|
|
193
|
+
```bash
|
|
194
|
+
# Install Treege
|
|
195
|
+
npm install treege
|
|
196
|
+
|
|
197
|
+
# Install peer dependencies
|
|
198
|
+
npm install react-native
|
|
199
|
+
|
|
200
|
+
# Optional: Install for file input support
|
|
201
|
+
npm install react-native-document-picker
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### Basic Usage
|
|
174
205
|
|
|
175
206
|
```tsx
|
|
176
|
-
{
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
207
|
+
import { TreegeRenderer } from "treege/renderer-native";
|
|
208
|
+
import type { Flow, FormValues } from "treege";
|
|
209
|
+
|
|
210
|
+
function App() {
|
|
211
|
+
const flow: Flow = {
|
|
212
|
+
id: "flow-1",
|
|
213
|
+
nodes: [
|
|
214
|
+
{
|
|
215
|
+
id: "name",
|
|
216
|
+
type: "input",
|
|
217
|
+
data: {
|
|
218
|
+
type: "text",
|
|
219
|
+
name: "fullName",
|
|
220
|
+
label: "Full Name",
|
|
221
|
+
required: true
|
|
222
|
+
}
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
id: "email",
|
|
226
|
+
type: "input",
|
|
227
|
+
data: {
|
|
228
|
+
type: "text",
|
|
229
|
+
name: "email",
|
|
230
|
+
label: "Email",
|
|
231
|
+
required: true,
|
|
232
|
+
pattern: "^[\\w-\\.]+@([\\w-]+\\.)+[\\w-]{2,4}$"
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
],
|
|
236
|
+
edges: []
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
const handleSubmit = (values: FormValues) => {
|
|
240
|
+
console.log("Form submitted:", values);
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
return (
|
|
244
|
+
<TreegeRenderer
|
|
245
|
+
flow={flow}
|
|
246
|
+
onSubmit={handleSubmit}
|
|
247
|
+
/>
|
|
248
|
+
);
|
|
182
249
|
}
|
|
183
250
|
```
|
|
184
251
|
|
|
252
|
+
### Custom Styling
|
|
253
|
+
|
|
254
|
+
You can customize the appearance using the `style` and `contentContainerStyle` props:
|
|
255
|
+
|
|
256
|
+
```tsx
|
|
257
|
+
<TreegeRenderer
|
|
258
|
+
flow={flow}
|
|
259
|
+
onSubmit={handleSubmit}
|
|
260
|
+
style={{ flex: 1, backgroundColor: "#f5f5f5" }}
|
|
261
|
+
contentContainerStyle={{ padding: 20 }}
|
|
262
|
+
/>
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
### Custom Components
|
|
266
|
+
|
|
267
|
+
Override default components with your own React Native components.
|
|
268
|
+
|
|
269
|
+
Each input renderer receives **two arguments**:
|
|
270
|
+
|
|
271
|
+
1. `field` — DOM-safe props (`id`, `name`, `value`, `placeholder`, `required`, `aria-invalid`). On the web you can spread them onto an element (`<input {...field} />`); on React Native pick the ones you need.
|
|
272
|
+
2. `extra` — Treege-specific props: `setValue`, `error`, `label`, `helperText`, `node`, and `missingDependencies` (the unfilled fields this input's dynamic options depend on).
|
|
273
|
+
|
|
274
|
+
```tsx
|
|
275
|
+
import { Text, TextInput, View } from "react-native";
|
|
276
|
+
import { TreegeRenderer } from "treege/renderer-native";
|
|
277
|
+
|
|
278
|
+
const CustomTextInput = (field, extra) => {
|
|
279
|
+
return (
|
|
280
|
+
<View style={{ marginBottom: 16 }}>
|
|
281
|
+
<Text style={{ fontSize: 14, marginBottom: 4 }}>{extra.label}</Text>
|
|
282
|
+
<TextInput
|
|
283
|
+
value={field.value}
|
|
284
|
+
placeholder={field.placeholder}
|
|
285
|
+
onChangeText={extra.setValue}
|
|
286
|
+
style={{
|
|
287
|
+
borderWidth: 1,
|
|
288
|
+
borderColor: extra.error ? "red" : "#ccc",
|
|
289
|
+
padding: 10,
|
|
290
|
+
borderRadius: 8
|
|
291
|
+
}}
|
|
292
|
+
/>
|
|
293
|
+
{extra.error && <Text style={{ color: "red", fontSize: 12 }}>{extra.error}</Text>}
|
|
294
|
+
{extra.missingDependencies.length > 0 && (
|
|
295
|
+
<Text style={{ color: "#b45309", fontSize: 12 }}>
|
|
296
|
+
Please fill in first: {extra.missingDependencies.map((d) => d.label).join(", ")}
|
|
297
|
+
</Text>
|
|
298
|
+
)}
|
|
299
|
+
</View>
|
|
300
|
+
);
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
<TreegeRenderer
|
|
304
|
+
flow={flow}
|
|
305
|
+
components={{
|
|
306
|
+
inputs: {
|
|
307
|
+
text: CustomTextInput
|
|
308
|
+
}
|
|
309
|
+
}}
|
|
310
|
+
/>
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
### Supported Input Types
|
|
314
|
+
|
|
315
|
+
The React Native renderer includes default implementations for all input types:
|
|
316
|
+
|
|
317
|
+
**Fully Implemented (Vanilla React Native)**:
|
|
318
|
+
- `text`, `number`, `textarea`, `password`
|
|
319
|
+
- `checkbox`, `switch`, `hidden`
|
|
320
|
+
|
|
321
|
+
**With Optional Dependencies** (gracefully degrades if not installed):
|
|
322
|
+
- `file` - Requires [react-native-document-picker](https://github.com/rnmods/react-native-document-picker) (optional)
|
|
323
|
+
|
|
324
|
+
**Requires Custom Implementation** (placeholder provided):
|
|
325
|
+
- `select`, `radio`, `autocomplete`
|
|
326
|
+
- `date`, `daterange`, `time`, `timerange`
|
|
327
|
+
- `address`, `http`
|
|
328
|
+
|
|
329
|
+
You can implement these inputs using popular React Native libraries:
|
|
330
|
+
- [@react-native-picker/picker](https://github.com/react-native-picker/picker) for `select` and `radio`
|
|
331
|
+
- [react-native-date-picker](https://github.com/henninghall/react-native-date-picker) for `date` and `time` inputs
|
|
332
|
+
- [@react-native-community/google-places-autocomplete](https://github.com/FaridSafi/react-native-google-places-autocomplete) for `address`
|
|
333
|
+
|
|
334
|
+
### API Reference
|
|
335
|
+
|
|
336
|
+
The React Native renderer shares the same API as the web renderer, with some platform-specific props:
|
|
337
|
+
|
|
338
|
+
| Prop | Type | Default | Description |
|
|
339
|
+
|-------------------------|---------------------------------------------|--------------|------------------------------------------------------------|
|
|
340
|
+
| `flow` | `Flow \| null` | - | Decision tree to render |
|
|
341
|
+
| `onSubmit` | `(values: FormValues, meta?: Meta) => void` | - | Form submission handler (meta includes HTTP response data) |
|
|
342
|
+
| `onChange` | `(values: FormValues) => void` | - | Form change handler |
|
|
343
|
+
| `validate` | `(values, nodes) => Record<string, string>` | - | Custom validation function |
|
|
344
|
+
| `initialValues` | `FormValues` | `{}` | Initial form values |
|
|
345
|
+
| `components` | `TreegeRendererComponents` | - | Custom component overrides |
|
|
346
|
+
| `language` | `string` | `"en"` | UI language |
|
|
347
|
+
| `validationMode` | `"onSubmit" \| "onChange"` | `"onSubmit"` | When to validate |
|
|
348
|
+
| `theme` | `"light" \| "dark"` | `"dark"` | Renderer theme |
|
|
349
|
+
| `googleApiKey` | `string` | - | API key for address input |
|
|
350
|
+
| `headers` | `HttpHeader[]` | - | HTTP headers applied to every request (field-level wins) |
|
|
351
|
+
| `isLoading` | `boolean` | `false` | Render a loading skeleton instead of the form |
|
|
352
|
+
| `style` | `ViewStyle` | - | ScrollView style (RN only) |
|
|
353
|
+
| `contentContainerStyle` | `ViewStyle` | - | Content container style (RN) |
|
|
354
|
+
|
|
355
|
+
## Node Types
|
|
356
|
+
|
|
357
|
+
Treege has three node types: `input`, `ui`, and `group`. Navigation is automatic — group nodes drive step navigation and conditional edges drive branching.
|
|
358
|
+
|
|
185
359
|
### Input Node
|
|
186
360
|
Form input with validation, patterns, and conditional logic.
|
|
187
361
|
|
|
@@ -199,10 +373,10 @@ Form input with validation, patterns, and conditional logic.
|
|
|
199
373
|
}
|
|
200
374
|
```
|
|
201
375
|
|
|
202
|
-
Supported input types: `text`, `
|
|
376
|
+
Supported input types: `text`, `number`, `textarea`, `password`, `select`, `radio`, `checkbox`, `switch`, `autocomplete`, `date`, `daterange`, `time`, `timerange`, `file`, `address`, `http`, `hidden`
|
|
203
377
|
|
|
204
378
|
### Group Node
|
|
205
|
-
Container for organizing multiple nodes together.
|
|
379
|
+
Container for organizing multiple nodes together. Groups also drive **multi-step forms**: at runtime each group of visible nodes becomes a navigable step (Back/Continue). Child nodes belong to a group via their `parentId`.
|
|
206
380
|
|
|
207
381
|
```tsx
|
|
208
382
|
{
|
|
@@ -213,34 +387,26 @@ Container for organizing multiple nodes together.
|
|
|
213
387
|
}
|
|
214
388
|
```
|
|
215
389
|
|
|
216
|
-
### JSON Node
|
|
217
|
-
Store and manage JSON data within the tree.
|
|
218
|
-
|
|
219
|
-
```tsx
|
|
220
|
-
{
|
|
221
|
-
type: "json",
|
|
222
|
-
data: {
|
|
223
|
-
json: { key: "value" }
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
```
|
|
227
|
-
|
|
228
390
|
### UI Node
|
|
229
|
-
Display-only elements
|
|
391
|
+
Display-only elements for visual organization and content display.
|
|
230
392
|
|
|
231
393
|
```tsx
|
|
232
394
|
{
|
|
233
395
|
type: "ui",
|
|
234
396
|
data: {
|
|
235
|
-
type: "title",
|
|
397
|
+
type: "title", // or "divider"
|
|
236
398
|
label: "Welcome to the form"
|
|
237
399
|
}
|
|
238
400
|
}
|
|
239
401
|
```
|
|
240
402
|
|
|
403
|
+
Supported UI types:
|
|
404
|
+
- `title` - Display headings and titles
|
|
405
|
+
- `divider` - Visual separator between sections
|
|
406
|
+
|
|
241
407
|
## Conditional Edges
|
|
242
408
|
|
|
243
|
-
Create dynamic
|
|
409
|
+
Create dynamic flow with conditional logic:
|
|
244
410
|
|
|
245
411
|
```tsx
|
|
246
412
|
{
|
|
@@ -286,17 +452,29 @@ Treege supports multiple languages out of the box:
|
|
|
286
452
|
|
|
287
453
|
### Custom Input Components
|
|
288
454
|
|
|
289
|
-
Override default input renderers with your own
|
|
455
|
+
Override default input renderers with your own. A renderer receives two
|
|
456
|
+
arguments: `field` (DOM-safe props, spreadable onto an element) and `extra`
|
|
457
|
+
(`setValue`, `error`, `label`, `helperText`, `node`, `missingDependencies`).
|
|
290
458
|
|
|
291
459
|
```tsx
|
|
292
460
|
import { TreegeRenderer } from "treege/renderer";
|
|
293
461
|
|
|
294
|
-
const CustomTextInput = (
|
|
295
|
-
return
|
|
462
|
+
const CustomTextInput = (field, extra) => {
|
|
463
|
+
return (
|
|
464
|
+
<label>
|
|
465
|
+
{extra.label}
|
|
466
|
+
<input
|
|
467
|
+
{...field}
|
|
468
|
+
className="my-custom-input"
|
|
469
|
+
onChange={(e) => extra.setValue(e.target.value)}
|
|
470
|
+
/>
|
|
471
|
+
{extra.error && <span className="error">{extra.error}</span>}
|
|
472
|
+
</label>
|
|
473
|
+
);
|
|
296
474
|
};
|
|
297
475
|
|
|
298
476
|
<TreegeRenderer
|
|
299
|
-
|
|
477
|
+
flow={flow}
|
|
300
478
|
components={{
|
|
301
479
|
inputs: {
|
|
302
480
|
text: CustomTextInput
|
|
@@ -311,7 +489,7 @@ Add custom validation logic:
|
|
|
311
489
|
|
|
312
490
|
```tsx
|
|
313
491
|
<TreegeRenderer
|
|
314
|
-
|
|
492
|
+
flow={flow}
|
|
315
493
|
validate={(values, visibleNodes) => {
|
|
316
494
|
const errors = {};
|
|
317
495
|
|
|
@@ -336,68 +514,234 @@ Control when validation occurs:
|
|
|
336
514
|
<TreegeRenderer validationMode="onChange" />
|
|
337
515
|
```
|
|
338
516
|
|
|
517
|
+
### HTTP Input Integration
|
|
518
|
+
|
|
519
|
+
Use the HTTP input type to fetch and map data from APIs:
|
|
520
|
+
|
|
521
|
+
```tsx
|
|
522
|
+
{
|
|
523
|
+
type: "input",
|
|
524
|
+
data: {
|
|
525
|
+
type: "http",
|
|
526
|
+
name: "country",
|
|
527
|
+
label: "Select your country",
|
|
528
|
+
httpConfig: {
|
|
529
|
+
method: "GET",
|
|
530
|
+
url: "https://api.example.com/countries",
|
|
531
|
+
responsePath: "$.data.countries", // JSONPath to extract data
|
|
532
|
+
mapping: {
|
|
533
|
+
label: "name",
|
|
534
|
+
value: "code"
|
|
535
|
+
},
|
|
536
|
+
searchParam: "query", // Enable search functionality
|
|
537
|
+
fetchOnMount: true
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
```
|
|
542
|
+
|
|
543
|
+
### Global Configuration
|
|
544
|
+
|
|
545
|
+
Configure the renderer globally using the TreegeRendererProvider:
|
|
546
|
+
|
|
547
|
+
```tsx
|
|
548
|
+
import { TreegeRendererProvider } from "treege/renderer";
|
|
549
|
+
|
|
550
|
+
function App() {
|
|
551
|
+
return (
|
|
552
|
+
<TreegeRendererProvider
|
|
553
|
+
language="fr"
|
|
554
|
+
googleApiKey="your-google-api-key"
|
|
555
|
+
components={{
|
|
556
|
+
// Your custom components
|
|
557
|
+
}}
|
|
558
|
+
>
|
|
559
|
+
<TreegeRenderer flow={flow} />
|
|
560
|
+
</TreegeRendererProvider>
|
|
561
|
+
);
|
|
562
|
+
}
|
|
563
|
+
```
|
|
564
|
+
|
|
565
|
+
### Loading State
|
|
566
|
+
|
|
567
|
+
When the flow is being fetched asynchronously, pass `isLoading` to render a skeleton in place of the form:
|
|
568
|
+
|
|
569
|
+
```tsx
|
|
570
|
+
function App() {
|
|
571
|
+
const { data: flow, isPending } = useQuery(/* ... */);
|
|
572
|
+
|
|
573
|
+
return <TreegeRenderer flow={flow ?? null} isLoading={isPending} onSubmit={console.log} />;
|
|
574
|
+
}
|
|
575
|
+
```
|
|
576
|
+
|
|
577
|
+
Customize the skeleton via `components.loadingSkeleton`:
|
|
578
|
+
|
|
579
|
+
```tsx
|
|
580
|
+
<TreegeRenderer
|
|
581
|
+
flow={flow}
|
|
582
|
+
isLoading={isPending}
|
|
583
|
+
components={{
|
|
584
|
+
loadingSkeleton: () => <MyCustomSkeleton />,
|
|
585
|
+
}}
|
|
586
|
+
/>
|
|
587
|
+
```
|
|
588
|
+
|
|
589
|
+
### Multi-Step Forms
|
|
590
|
+
|
|
591
|
+
When a flow contains **Group** nodes, the renderer automatically splits the form into navigable steps — each contiguous slice of visible nodes sharing the same group becomes one step, with built-in Back/Continue controls (Continue turns into Submit on the last step). Branching via conditional edges recomputes the steps on the fly.
|
|
592
|
+
|
|
593
|
+
Override the default step layout via `components.step`:
|
|
594
|
+
|
|
595
|
+
```tsx
|
|
596
|
+
<TreegeRenderer
|
|
597
|
+
flow={flow}
|
|
598
|
+
components={{
|
|
599
|
+
step: ({ label, children, isFirstStep, isLastStep, canContinue, onBack, onContinue }) => (
|
|
600
|
+
<section>
|
|
601
|
+
<h2>{label}</h2>
|
|
602
|
+
{children}
|
|
603
|
+
{!isFirstStep && <button onClick={onBack}>Back</button>}
|
|
604
|
+
<button disabled={!canContinue} onClick={onContinue}>
|
|
605
|
+
{isLastStep ? "Submit" : "Continue"}
|
|
606
|
+
</button>
|
|
607
|
+
</section>
|
|
608
|
+
),
|
|
609
|
+
}}
|
|
610
|
+
/>
|
|
611
|
+
```
|
|
612
|
+
|
|
613
|
+
### Headless / Programmatic Control
|
|
614
|
+
|
|
615
|
+
Use the `useTreegeRenderer` hook to drive the form yourself (headless mode). It takes the same configuration as `TreegeRenderer` and returns the full form state and control methods:
|
|
616
|
+
|
|
617
|
+
```tsx
|
|
618
|
+
import { useTreegeRenderer } from "treege/renderer";
|
|
619
|
+
|
|
620
|
+
function CustomForm({ flow }) {
|
|
621
|
+
const {
|
|
622
|
+
formValues,
|
|
623
|
+
setFieldValue,
|
|
624
|
+
handleSubmit,
|
|
625
|
+
formErrors,
|
|
626
|
+
visibleNodes,
|
|
627
|
+
isSubmitting,
|
|
628
|
+
currentStep,
|
|
629
|
+
goToNextStep,
|
|
630
|
+
goToPreviousStep,
|
|
631
|
+
} = useTreegeRenderer({
|
|
632
|
+
flow,
|
|
633
|
+
onSubmit: (values) => console.log("Submitted:", values),
|
|
634
|
+
});
|
|
635
|
+
|
|
636
|
+
return (
|
|
637
|
+
<div>
|
|
638
|
+
<button onClick={() => setFieldValue("email", "test@example.com")}>
|
|
639
|
+
Prefill Email
|
|
640
|
+
</button>
|
|
641
|
+
<button onClick={handleSubmit} disabled={isSubmitting}>
|
|
642
|
+
Submit
|
|
643
|
+
</button>
|
|
644
|
+
</div>
|
|
645
|
+
);
|
|
646
|
+
}
|
|
647
|
+
```
|
|
648
|
+
|
|
649
|
+
> The `useTreegeRenderer` return type is exported as `UseTreegeRendererReturn` for TypeScript consumers building custom components.
|
|
650
|
+
|
|
339
651
|
## Examples
|
|
340
652
|
|
|
341
653
|
Check out the `/example` directory for complete examples:
|
|
342
654
|
|
|
343
655
|
```bash
|
|
344
|
-
|
|
345
|
-
|
|
656
|
+
# Run the web example app (Vite, opens /example)
|
|
657
|
+
bun run example
|
|
658
|
+
|
|
659
|
+
# Run the React Native example app (Expo)
|
|
660
|
+
bun run example:native
|
|
346
661
|
```
|
|
347
662
|
|
|
663
|
+
### Available Example URLs
|
|
664
|
+
|
|
665
|
+
Once the development server is running, you can access these examples:
|
|
666
|
+
|
|
667
|
+
- **Default Example**: [http://localhost:5173/](http://localhost:5173/)
|
|
668
|
+
- Basic demonstration of Treege functionality
|
|
669
|
+
|
|
670
|
+
- **Demo Example**: [http://localhost:5173/example](http://localhost:5173/example)
|
|
671
|
+
- Full featured demo showcasing the library capabilities
|
|
672
|
+
|
|
673
|
+
- **All Inputs Example**: [http://localhost:5173/example-all-inputs](http://localhost:5173/example-all-inputs)
|
|
674
|
+
- Comprehensive showcase of all 16 input types
|
|
675
|
+
|
|
676
|
+
- **Custom Input Example**: [http://localhost:5173/example-custom-input](http://localhost:5173/example-custom-input)
|
|
677
|
+
- Demonstrates how to create and integrate custom input components
|
|
678
|
+
|
|
679
|
+
- **TreegeRendererProvider Example**: [http://localhost:5173/example-treege-renderer-provider](http://localhost:5173/example-treege-renderer-provider)
|
|
680
|
+
- Shows global configuration with TreegeRendererProvider
|
|
681
|
+
|
|
348
682
|
## API Reference
|
|
349
683
|
|
|
350
684
|
### TreegeEditor Props
|
|
351
685
|
|
|
352
|
-
| Prop
|
|
353
|
-
|
|
354
|
-
| `flow`
|
|
355
|
-
| `onSave`
|
|
356
|
-
| `
|
|
357
|
-
| `
|
|
686
|
+
| Prop | Type | Default | Description |
|
|
687
|
+
|-------------------|------------------------------------------|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
688
|
+
| `flow` | `Flow \| null` | `null` | Initial decision tree |
|
|
689
|
+
| `onSave` | `(flow: Flow) => void` | - | Callback when tree is saved |
|
|
690
|
+
| `onExportJson` | `() => { nodes: Node[]; edges: Edge[] }` | - | Callback for exporting JSON data |
|
|
691
|
+
| `language` | `string` | `"en"` | UI language |
|
|
692
|
+
| `theme` | `"light" \| "dark"` | `"dark"` | Editor theme |
|
|
693
|
+
| `aiConfig` | `AIConfig` | - | AI configuration for tree generation (see [AI Generation](./AI_GENERATION.md)) |
|
|
694
|
+
| `className` | `string` | - | Additional CSS class names for custom styling |
|
|
695
|
+
| `extraMenuItems` | `ExtraMenuItem[]` | - | Extra entries appended to the actions panel "more" dropdown |
|
|
696
|
+
| `openApi` | `OpenApiDocument \| string` | - | OpenAPI 3.x source used to power URL/route suggestions and the Authorize flow. Accepts a pre-parsed document or a URL string (the editor fetches it on mount and toasts on failure) |
|
|
697
|
+
| `openApiBaseUrl` | `string` | - | Base URL used for OpenAPI route resolution. When set, takes precedence over the document's `servers[0].url` — useful when the spec points at a different environment than the one to call |
|
|
698
|
+
| `headers` | `HttpHeader[]` | - | Global HTTP headers applied to in-editor requests (e.g. the "Detect fields" button). Pass the same value you give to `TreegeRenderer` so editor previews use the same auth/headers as runtime |
|
|
699
|
+
| `onAuthorize` | `(headers: HttpHeader[]) => void` | - | Called when the user submits the Authorize dialog. Forward the resulting headers to `TreegeRenderer` (or `TreegeRendererProvider`) so every form request is authenticated |
|
|
700
|
+
| `onHeadersChange` | `(headers: HttpHeader[]) => void` | - | Called when the user edits headers in the built-in "Global headers" dialog. The component is controlled — update your `headers` state in response and pass the new list back via the `headers` prop |
|
|
358
701
|
|
|
359
702
|
### TreegeRenderer Props
|
|
360
703
|
|
|
361
|
-
| Prop | Type | Default | Description
|
|
362
|
-
|
|
363
|
-
| `
|
|
364
|
-
| `onSubmit` | `(values: FormValues) => void`
|
|
365
|
-
| `onChange` | `(values: FormValues) => void` | - | Form change handler
|
|
366
|
-
| `validate` | `(values, nodes) => Record<string, string>` | - | Custom validation function
|
|
367
|
-
| `initialValues` | `FormValues` | `{}` | Initial form values
|
|
368
|
-
| `components` | `
|
|
369
|
-
| `language` | `string` | `"en"` | UI language
|
|
370
|
-
| `validationMode` | `"onSubmit" \| "onChange"` | `"onSubmit"` | When to validate
|
|
371
|
-
| `theme` | `"light" \| "dark"` | `"dark"` | Renderer theme
|
|
372
|
-
| `googleApiKey` | `string` | - | API key for address input
|
|
704
|
+
| Prop | Type | Default | Description |
|
|
705
|
+
|------------------|---------------------------------------------|--------------|------------------------------------------------------------|
|
|
706
|
+
| `flow` | `Flow \| null` | - | Decision tree to render |
|
|
707
|
+
| `onSubmit` | `(values: FormValues, meta?: Meta) => void` | - | Form submission handler (meta includes HTTP response data) |
|
|
708
|
+
| `onChange` | `(values: FormValues) => void` | - | Form change handler |
|
|
709
|
+
| `validate` | `(values, nodes) => Record<string, string>` | - | Custom validation function |
|
|
710
|
+
| `initialValues` | `FormValues` | `{}` | Initial form values |
|
|
711
|
+
| `components` | `TreegeRendererComponents` | - | Custom component overrides |
|
|
712
|
+
| `language` | `string` | `"en"` | UI language |
|
|
713
|
+
| `validationMode` | `"onSubmit" \| "onChange"` | `"onSubmit"` | When to validate |
|
|
714
|
+
| `theme` | `"light" \| "dark"` | `"dark"` | Renderer theme |
|
|
715
|
+
| `googleApiKey` | `string` | - | API key for address input |
|
|
716
|
+
| `headers` | `HttpHeader[]` | - | HTTP headers applied to every request (field-level wins) |
|
|
717
|
+
| `isLoading` | `boolean` | `false` | Render a loading skeleton instead of the form (see below) |
|
|
718
|
+
| `className` | `string` | - | Additional CSS class names for custom styling |
|
|
373
719
|
|
|
374
720
|
## Development
|
|
375
721
|
|
|
376
722
|
```bash
|
|
377
723
|
# Install dependencies
|
|
378
|
-
|
|
724
|
+
bun install
|
|
379
725
|
|
|
380
726
|
# Start dev server
|
|
381
|
-
|
|
727
|
+
bun run dev
|
|
382
728
|
|
|
383
729
|
# Build library
|
|
384
|
-
|
|
730
|
+
bun run build
|
|
385
731
|
|
|
386
732
|
# Run linter and type check
|
|
387
|
-
|
|
733
|
+
bun run lint
|
|
388
734
|
|
|
389
735
|
# Preview build
|
|
390
|
-
|
|
736
|
+
bun run preview
|
|
391
737
|
```
|
|
392
738
|
|
|
393
739
|
## Tech Stack
|
|
394
740
|
|
|
395
|
-
- **React**
|
|
741
|
+
- **React** - UI library
|
|
396
742
|
- **TypeScript** - Type safety
|
|
397
743
|
- **TailwindCSS** 4 - Styling
|
|
398
744
|
- **ReactFlow** - Node-based UI
|
|
399
|
-
- **Radix UI** - Accessible components
|
|
400
|
-
- **Zustand** - State management
|
|
401
745
|
- **Vite** - Build tool
|
|
402
746
|
|
|
403
747
|
## Contributing
|
|
@@ -406,13 +750,13 @@ Contributions are welcome! Please feel free to submit a Pull Request.
|
|
|
406
750
|
|
|
407
751
|
## License
|
|
408
752
|
|
|
409
|
-
|
|
753
|
+
MIT
|
|
410
754
|
|
|
411
755
|
## Credits
|
|
412
756
|
|
|
413
|
-
Created and maintained by [Mickaël Austoni](https://github.com/
|
|
757
|
+
Created and maintained by [Mickaël Austoni](https://github.com/MickaelAustoni)
|
|
414
758
|
|
|
415
759
|
## Support
|
|
416
760
|
|
|
417
|
-
- [GitHub Issues](https://github.com/
|
|
418
|
-
- [Repository](https://github.com/
|
|
761
|
+
- [GitHub Issues](https://github.com/MickaelAustoni/treege/issues)
|
|
762
|
+
- [Repository](https://github.com/MickaelAustoni/treege)
|