treege 3.0.0-beta.4 → 3.0.0-beta.40

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.
Files changed (138) hide show
  1. package/LICENSE +18 -12
  2. package/README.md +306 -52
  3. package/dist/DefaultInputs-8yJMEyMh.js +1557 -0
  4. package/dist/ThemeContext-Ejgu9Mwr.js +1603 -0
  5. package/dist/editor/components/input/ComboboxWithCreate.d.ts +2 -1
  6. package/dist/editor/constants/defaultNode.d.ts +1 -1
  7. package/dist/editor/constants/edgeTypes.d.ts +3 -2
  8. package/dist/editor/constants/inputTypeIcons.d.ts +3 -0
  9. package/dist/editor/constants/nodeSpacing.d.ts +33 -0
  10. package/dist/editor/constants/nodeTypes.d.ts +5 -5
  11. package/dist/editor/context/TreegeEditorContext.d.ts +53 -1
  12. package/dist/editor/features/TreegeEditor/TreegeEditor.d.ts +1 -1
  13. package/dist/editor/features/TreegeEditor/dialogs/ChangeNodeTypeDialog.d.ts +2 -0
  14. package/dist/editor/features/TreegeEditor/dialogs/DeleteNodeDialog.d.ts +2 -0
  15. package/dist/editor/features/TreegeEditor/edges/ConditionalEdge.d.ts +2 -2
  16. package/dist/editor/features/TreegeEditor/edges/DefaultEdge.d.ts +3 -0
  17. package/dist/editor/features/TreegeEditor/forms/SubmitConfigForm.d.ts +7 -0
  18. package/dist/editor/features/TreegeEditor/inputs/ComboboxPattern.d.ts +2 -1
  19. package/dist/editor/features/TreegeEditor/inputs/OptionImageField.d.ts +6 -0
  20. package/dist/editor/features/TreegeEditor/nodes/GroupNode.d.ts +2 -2
  21. package/dist/editor/features/TreegeEditor/nodes/TreegeNode.d.ts +6 -0
  22. package/dist/editor/features/TreegeEditor/nodes/components/BottomHandleDropdown.d.ts +6 -0
  23. package/dist/editor/features/TreegeEditor/nodes/components/NodeInputPreview.d.ts +7 -0
  24. package/dist/editor/features/TreegeEditor/nodes/components/NodeLabelInput.d.ts +9 -0
  25. package/dist/editor/features/TreegeEditor/nodes/components/NodeMoreMenu.d.ts +6 -0
  26. package/dist/editor/features/TreegeEditor/nodes/components/NodeTypeBadge.d.ts +7 -0
  27. package/dist/editor/features/TreegeEditor/nodes/components/OptionsEditor.d.ts +7 -0
  28. package/dist/editor/features/TreegeEditor/nodes/components/RequiredBadge.d.ts +6 -0
  29. package/dist/editor/features/TreegeEditor/nodes/layout/NodeWrapper.d.ts +2 -1
  30. package/dist/editor/features/TreegeEditor/panel/AIGeneratorDialog.d.ts +16 -0
  31. package/dist/editor/hooks/useAutoLayout.d.ts +15 -0
  32. package/dist/editor/hooks/useFlowActions.d.ts +5 -2
  33. package/dist/editor/hooks/useFlowConnections.d.ts +4 -0
  34. package/dist/editor/hooks/useNodesSelection.d.ts +5 -5
  35. package/dist/editor/types/ai.d.ts +65 -0
  36. package/dist/editor/types/editor.d.ts +9 -8
  37. package/dist/editor/utils/aiFlowGenerator.d.ts +5 -0
  38. package/dist/editor/utils/dagreLayout.d.ts +17 -0
  39. package/dist/editor/utils/edge.d.ts +14 -0
  40. package/dist/editor/utils/image.d.ts +7 -0
  41. package/dist/editor/utils/inputTypeIcon.d.ts +6 -0
  42. package/dist/editor-DWJ95r4g.js +4001 -0
  43. package/dist/editor.js +3 -8
  44. package/dist/main.js +4 -53
  45. package/dist/renderer/context/TreegeRendererContext.d.ts +4 -1
  46. package/dist/renderer/features/TreegeRenderer/native/TreegeRenderer.d.ts +19 -11
  47. package/dist/renderer/features/TreegeRenderer/native/components/DefaultFormWrapper.d.ts +7 -7
  48. package/dist/renderer/features/TreegeRenderer/native/components/DefaultGroup.d.ts +7 -7
  49. package/dist/renderer/features/TreegeRenderer/native/components/DefaultInputs.d.ts +21 -15
  50. package/dist/renderer/features/TreegeRenderer/native/components/DefaultSubmitButton.d.ts +9 -7
  51. package/dist/renderer/features/TreegeRenderer/native/components/DefaultSubmitButtonWrapper.d.ts +11 -0
  52. package/dist/renderer/features/TreegeRenderer/native/components/DefaultUI.d.ts +8 -7
  53. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultAddressInput.d.ts +3 -0
  54. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultAutocompleteInput.d.ts +3 -0
  55. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultCheckboxInput.d.ts +3 -0
  56. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultDateInput.d.ts +3 -0
  57. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultDateRangeInput.d.ts +3 -0
  58. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultFileInput.d.ts +3 -0
  59. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultHiddenInput.d.ts +3 -0
  60. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultHttpInput.d.ts +3 -0
  61. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultNumberInput.d.ts +3 -0
  62. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultPasswordInput.d.ts +3 -0
  63. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultRadioInput.d.ts +3 -0
  64. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultSelectInput.d.ts +3 -0
  65. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultSwitchInput.d.ts +3 -0
  66. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultTextInput.d.ts +3 -0
  67. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultTextareaInput.d.ts +3 -0
  68. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultTimeInput.d.ts +3 -0
  69. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultTimeRangeInput.d.ts +3 -0
  70. package/dist/renderer/features/TreegeRenderer/useTreegeRenderer.d.ts +84 -24
  71. package/dist/renderer/features/TreegeRenderer/web/TreegeRenderer.d.ts +1 -1
  72. package/dist/renderer/features/TreegeRenderer/web/components/DefaultSubmitButton.d.ts +1 -1
  73. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultAddressInput.d.ts +1 -1
  74. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultAutocompleteInput.d.ts +1 -1
  75. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultCheckboxInput.d.ts +1 -1
  76. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultDateInput.d.ts +1 -1
  77. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultDateRangeInput.d.ts +1 -1
  78. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultFileInput.d.ts +1 -1
  79. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultHiddenInput.d.ts +1 -1
  80. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultHttpInput.d.ts +1 -1
  81. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultNumberInput.d.ts +1 -1
  82. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultPasswordInput.d.ts +1 -1
  83. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultRadioInput.d.ts +1 -1
  84. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultSelectInput.d.ts +1 -1
  85. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultSubmitInput.d.ts +3 -0
  86. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultSwitchInput.d.ts +1 -1
  87. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultTextAreaInput.d.ts +1 -1
  88. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultTextInput.d.ts +1 -1
  89. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultTimeInput.d.ts +1 -1
  90. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultTimeRangeInput.d.ts +1 -1
  91. package/dist/renderer/hooks/useRenderNode.d.ts +55 -0
  92. package/dist/renderer/hooks/useSubmitHandler.d.ts +34 -0
  93. package/dist/renderer/hooks/useTranslate.d.ts +6 -4
  94. package/dist/renderer/index.d.ts +2 -0
  95. package/dist/renderer/index.native.d.ts +19 -0
  96. package/dist/renderer/types/renderer.d.ts +60 -6
  97. package/dist/renderer/utils/form.d.ts +22 -2
  98. package/dist/renderer/utils/http.d.ts +101 -0
  99. package/dist/renderer/utils/node.d.ts +18 -1
  100. package/dist/renderer/utils/sanitize.d.ts +85 -0
  101. package/dist/renderer/utils/sanitize.native.d.ts +69 -0
  102. package/dist/renderer/utils/submit.d.ts +47 -0
  103. package/dist/renderer-native.d.ts +2 -0
  104. package/dist/renderer-native.js +3496 -0
  105. package/dist/renderer.js +3 -46
  106. package/dist/shared/components/ui/badge.d.ts +2 -2
  107. package/dist/shared/components/ui/button.d.ts +2 -2
  108. package/dist/shared/components/ui/collapsible.d.ts +1 -1
  109. package/dist/shared/components/ui/command.d.ts +1 -1
  110. package/dist/shared/components/ui/dropdown-menu.d.ts +1 -1
  111. package/dist/shared/components/ui/form.d.ts +1 -1
  112. package/dist/shared/components/ui/popover.d.ts +4 -2
  113. package/dist/shared/components/ui/select.d.ts +3 -1
  114. package/dist/shared/components/ui/sheet.d.ts +1 -1
  115. package/dist/shared/components/ui/tooltip.d.ts +1 -1
  116. package/dist/shared/constants/colors.d.ts +45 -0
  117. package/dist/shared/constants/inputType.d.ts +1 -0
  118. package/dist/shared/context/ThemeContext.d.ts +2 -0
  119. package/dist/shared/context/ThemeContext.native.d.ts +22 -0
  120. package/dist/shared/hooks/useThemeColors.d.ts +37 -0
  121. package/dist/shared/locales/ar.json.d.ts +117 -10
  122. package/dist/shared/locales/de.json.d.ts +118 -11
  123. package/dist/shared/locales/en.json.d.ts +119 -12
  124. package/dist/shared/locales/es.json.d.ts +118 -11
  125. package/dist/shared/locales/fr.json.d.ts +118 -11
  126. package/dist/shared/locales/it.json.d.ts +118 -11
  127. package/dist/shared/locales/pt.json.d.ts +118 -11
  128. package/dist/shared/types/edge.d.ts +6 -0
  129. package/dist/shared/types/node.d.ts +64 -0
  130. package/package.json +38 -12
  131. package/dist/ThemeContext-D4xMOrdt.js +0 -759
  132. package/dist/TreegeEditor-Cv0caawk.js +0 -2152
  133. package/dist/TreegeRenderer-BOCobRLr.js +0 -1414
  134. package/dist/_name_.css +0 -1
  135. package/dist/editor/features/TreegeEditor/inputs/SelectInputType.d.ts +0 -7
  136. package/dist/editor/features/TreegeEditor/nodes/FlowNode.d.ts +0 -6
  137. package/dist/editor/features/TreegeEditor/nodes/InputNode.d.ts +0 -6
  138. package/dist/editor/features/TreegeEditor/nodes/UINode.d.ts +0 -6
package/LICENSE CHANGED
@@ -1,15 +1,21 @@
1
- The ISC License (ISC)
1
+ MIT License
2
2
 
3
- Copyright (C) 2022 Tracktor
3
+ Copyright (c) 2025 Tracktor
4
4
 
5
- Permission to use, copy, modify, and/or distribute this software for any
6
- purpose with or without fee is hereby granted, provided that the above
7
- copyright notice and this permission notice appear in all copies.
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
8
11
 
9
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
14
- OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
15
- CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
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
  [![npm version](https://badge.fury.io/js/treege.svg)](https://badge.fury.io/js/treege)
8
- [![License: ISC](https://img.shields.io/badge/License-ISC-blue.svg)](https://opensource.org/licenses/ISC)
8
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](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="#documentation">Documentation</a> •
15
- <a href="#examples">Examples</a>
16
+ <a href="#examples">Examples</a> •
17
+ <a href="./AI_GENERATION.md">🪄 AI Generation</a>
16
18
  </p>
17
19
  </div>
18
20
 
@@ -26,17 +28,27 @@ Treege is a modern React library for creating and rendering interactive decision
26
28
 
27
29
  ### Visual Editor (`treege/editor`)
28
30
  - **Node-based Interface**: Drag-and-drop editor powered by ReactFlow
29
- - **5 Node Types**: Flow, Group, Input, JSON, and UI nodes
30
- - **Conditional Edges**: Advanced logic with AND/OR operators
31
- - **Multi-language Support**: Built-in translation system
31
+ - **4 Node Types**: Flow, Group, Input, and UI 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
- - **Form Generation**: Automatically render forms from decision trees
36
- - **Validation**: Built-in required and pattern validation
37
- - **Conditional Logic**: Dynamic field visibility based on user input
38
- - **Customizable**: Override default components with your own
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
+ - **Fully Customizable**: Override any component (FormWrapper, Group, Inputs, SubmitButton, UI elements)
49
+ - **Optional Dependencies**: Graceful degradation when optional packages like `react-native-document-picker` aren't installed
39
50
  - **Theme Support**: Dark/light mode out of the box
51
+ - **Google API Integration**: Address autocomplete support
40
52
 
41
53
  ### Developer Experience
42
54
  - **Modular**: Import only what you need (editor, renderer, or both)
@@ -154,7 +166,7 @@ function App() {
154
166
 
155
167
  ## Module Structure
156
168
 
157
- Treege provides three import paths for optimal bundle size:
169
+ Treege provides multiple import paths for optimal bundle size:
158
170
 
159
171
  ```tsx
160
172
  // Import everything (editor + renderer + types)
@@ -163,10 +175,167 @@ import { TreegeEditor, TreegeRenderer } from "treege";
163
175
  // Import only the editor
164
176
  import { TreegeEditor } from "treege/editor";
165
177
 
166
- // Import only the renderer
178
+ // Import only the web renderer
167
179
  import { TreegeRenderer } from "treege/renderer";
180
+
181
+ // Import only the React Native renderer
182
+ import { TreegeRenderer } from "treege/renderer-native";
168
183
  ```
169
184
 
185
+ ## React Native Support
186
+
187
+ Treege 3.0 includes full React Native support with a dedicated renderer implementation.
188
+
189
+ ### Installation for React Native
190
+
191
+ ```bash
192
+ # Install Treege
193
+ npm install treege
194
+
195
+ # Install peer dependencies
196
+ npm install react-native
197
+
198
+ # Optional: Install for file input support
199
+ npm install react-native-document-picker
200
+ ```
201
+
202
+ ### Basic Usage
203
+
204
+ ```tsx
205
+ import { TreegeRenderer } from "treege/renderer-native";
206
+ import type { Flow, FormValues } from "treege";
207
+
208
+ function App() {
209
+ const flow: Flow = {
210
+ id: "flow-1",
211
+ nodes: [
212
+ {
213
+ id: "name",
214
+ type: "input",
215
+ data: {
216
+ type: "text",
217
+ name: "fullName",
218
+ label: "Full Name",
219
+ required: true
220
+ }
221
+ },
222
+ {
223
+ id: "email",
224
+ type: "input",
225
+ data: {
226
+ type: "text",
227
+ name: "email",
228
+ label: "Email",
229
+ required: true,
230
+ pattern: "^[\\w-\\.]+@([\\w-]+\\.)+[\\w-]{2,4}$"
231
+ }
232
+ }
233
+ ],
234
+ edges: []
235
+ };
236
+
237
+ const handleSubmit = (values: FormValues) => {
238
+ console.log("Form submitted:", values);
239
+ };
240
+
241
+ return (
242
+ <TreegeRenderer
243
+ flows={flow}
244
+ onSubmit={handleSubmit}
245
+ />
246
+ );
247
+ }
248
+ ```
249
+
250
+ ### Custom Styling
251
+
252
+ You can customize the appearance using the `style` and `contentContainerStyle` props:
253
+
254
+ ```tsx
255
+ <TreegeRenderer
256
+ flows={flow}
257
+ onSubmit={handleSubmit}
258
+ style={{ flex: 1, backgroundColor: "#f5f5f5" }}
259
+ contentContainerStyle={{ padding: 20 }}
260
+ />
261
+ ```
262
+
263
+ ### Custom Components
264
+
265
+ Override default components with your own React Native components:
266
+
267
+ ```tsx
268
+ import { Text, TextInput, View } from "react-native";
269
+ import { TreegeRenderer } from "treege/renderer-native";
270
+
271
+ const CustomTextInput = ({ value, setValue, label, error }) => {
272
+ return (
273
+ <View style={{ marginBottom: 16 }}>
274
+ <Text style={{ fontSize: 14, marginBottom: 4 }}>{label}</Text>
275
+ <TextInput
276
+ value={value}
277
+ onChangeText={setValue}
278
+ style={{
279
+ borderWidth: 1,
280
+ borderColor: error ? "red" : "#ccc",
281
+ padding: 10,
282
+ borderRadius: 8
283
+ }}
284
+ />
285
+ {error && <Text style={{ color: "red", fontSize: 12 }}>{error}</Text>}
286
+ </View>
287
+ );
288
+ };
289
+
290
+ <TreegeRenderer
291
+ flows={flow}
292
+ components={{
293
+ inputs: {
294
+ text: CustomTextInput
295
+ }
296
+ }}
297
+ />
298
+ ```
299
+
300
+ ### Supported Input Types
301
+
302
+ The React Native renderer includes default implementations for all input types:
303
+
304
+ **Fully Implemented (Vanilla React Native)**:
305
+ - `text`, `number`, `textarea`, `password`
306
+ - `checkbox`, `switch`, `hidden`
307
+
308
+ **With Optional Dependencies** (gracefully degrades if not installed):
309
+ - `file` - Requires [react-native-document-picker](https://github.com/rnmods/react-native-document-picker) (optional)
310
+
311
+ **Requires Custom Implementation** (placeholder provided):
312
+ - `select`, `radio`, `autocomplete`
313
+ - `date`, `daterange`, `time`, `timerange`
314
+ - `address`, `http`
315
+
316
+ You can implement these inputs using popular React Native libraries:
317
+ - [@react-native-picker/picker](https://github.com/react-native-picker/picker) for `select` and `radio`
318
+ - [react-native-date-picker](https://github.com/henninghall/react-native-date-picker) for `date` and `time` inputs
319
+ - [@react-native-community/google-places-autocomplete](https://github.com/FaridSafi/react-native-google-places-autocomplete) for `address`
320
+
321
+ ### API Reference
322
+
323
+ The React Native renderer shares the same API as the web renderer, with some platform-specific props:
324
+
325
+ | Prop | Type | Default | Description |
326
+ |-------------------------|---------------------------------------------|--------------|------------------------------------------------------------|
327
+ | `flows` | `Flow \| Flow[] \| null` | - | Decision tree to render (single Flow or array of Flows) |
328
+ | `onSubmit` | `(values: FormValues, meta?: Meta) => void` | - | Form submission handler (meta includes HTTP response data) |
329
+ | `onChange` | `(values: FormValues) => void` | - | Form change handler |
330
+ | `validate` | `(values, nodes) => Record<string, string>` | - | Custom validation function |
331
+ | `initialValues` | `FormValues` | `{}` | Initial form values |
332
+ | `components` | `TreegeRendererComponents` | - | Custom component overrides |
333
+ | `language` | `string` | `"en"` | UI language |
334
+ | `validationMode` | `"onSubmit" \| "onChange"` | `"onSubmit"` | When to validate |
335
+ | `googleApiKey` | `string` | - | API key for address input |
336
+ | `style` | `ViewStyle` | - | ScrollView style (RN only) |
337
+ | `contentContainerStyle` | `ViewStyle` | - | Content container style (RN) |
338
+
170
339
  ## Node Types
171
340
 
172
341
  ### Flow Node
@@ -199,7 +368,7 @@ Form input with validation, patterns, and conditional logic.
199
368
  }
200
369
  ```
201
370
 
202
- Supported input types: `text`, `email`, `password`, `number`, `textarea`, `select`, `radio`, `checkbox`, `switch`, `date`, `dateRange`, `time`, `timeRange`, `file`, `address`, `http`
371
+ Supported input types: `text`, `number`, `textarea`, `password`, `select`, `radio`, `checkbox`, `switch`, `autocomplete`, `date`, `daterange`, `time`, `timerange`, `file`, `address`, `http`, `hidden`
203
372
 
204
373
  ### Group Node
205
374
  Container for organizing multiple nodes together.
@@ -213,31 +382,23 @@ Container for organizing multiple nodes together.
213
382
  }
214
383
  ```
215
384
 
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
385
  ### UI Node
229
- Display-only elements (titles, descriptions, separators).
386
+ Display-only elements for visual organization and content display.
230
387
 
231
388
  ```tsx
232
389
  {
233
390
  type: "ui",
234
391
  data: {
235
- type: "title",
392
+ type: "title", // or "divider"
236
393
  label: "Welcome to the form"
237
394
  }
238
395
  }
239
396
  ```
240
397
 
398
+ Supported UI types:
399
+ - `title` - Display headings and titles
400
+ - `divider` - Visual separator between sections
401
+
241
402
  ## Conditional Edges
242
403
 
243
404
  Create dynamic flows with conditional logic:
@@ -336,40 +497,135 @@ Control when validation occurs:
336
497
  <TreegeRenderer validationMode="onChange" />
337
498
  ```
338
499
 
500
+ ### HTTP Input Integration
501
+
502
+ Use the HTTP input type to fetch and map data from APIs:
503
+
504
+ ```tsx
505
+ {
506
+ type: "input",
507
+ data: {
508
+ type: "http",
509
+ name: "country",
510
+ label: "Select your country",
511
+ httpConfig: {
512
+ method: "GET",
513
+ url: "https://api.example.com/countries",
514
+ responsePath: "$.data.countries", // JSONPath to extract data
515
+ mapping: {
516
+ label: "name",
517
+ value: "code"
518
+ },
519
+ searchParam: "query", // Enable search functionality
520
+ fetchOnMount: true
521
+ }
522
+ }
523
+ }
524
+ ```
525
+
526
+ ### Global Configuration
527
+
528
+ Configure the renderer globally using the TreegeConfigProvider:
529
+
530
+ ```tsx
531
+ import { TreegeConfigProvider } from "treege/renderer";
532
+
533
+ function App() {
534
+ return (
535
+ <TreegeConfigProvider
536
+ config={{
537
+ language: "fr",
538
+ googleApiKey: "your-google-api-key",
539
+ components: {
540
+ // Your custom components
541
+ }
542
+ }}
543
+ >
544
+ <TreegeRenderer flows={flow} />
545
+ </TreegeConfigProvider>
546
+ );
547
+ }
548
+ ```
549
+
550
+ ### Programmatic Control
551
+
552
+ Use the `useTreegeRenderer` hook for programmatic control:
553
+
554
+ ```tsx
555
+ import { useTreegeRenderer } from "treege/renderer";
556
+
557
+ function CustomForm() {
558
+ const { values, setFieldValue, submit, reset } = useTreegeRenderer();
559
+
560
+ return (
561
+ <div>
562
+ <button onClick={() => setFieldValue("email", "test@example.com")}>
563
+ Prefill Email
564
+ </button>
565
+ <button onClick={submit}>Submit</button>
566
+ <button onClick={reset}>Reset</button>
567
+ </div>
568
+ );
569
+ }
570
+ ```
571
+
339
572
  ## Examples
340
573
 
341
574
  Check out the `/example` directory for complete examples:
342
575
 
343
576
  ```bash
344
- # Run the example app
345
- bun example
577
+ # Run the example app
578
+ bun example
346
579
  ```
347
580
 
581
+ ### Available Example URLs
582
+
583
+ Once the development server is running, you can access these examples:
584
+
585
+ - **Default Example**: [http://localhost:5173/](http://localhost:5173/)
586
+ - Basic demonstration of Treege functionality
587
+
588
+ - **Demo Example**: [http://localhost:5173/example](http://localhost:5173/example)
589
+ - Full featured demo showcasing the library capabilities
590
+
591
+ - **All Inputs Example**: [http://localhost:5173/example-all-inputs](http://localhost:5173/example-all-inputs)
592
+ - Comprehensive showcase of all 16 input types
593
+
594
+ - **Custom Input Example**: [http://localhost:5173/example-custom-input](http://localhost:5173/example-custom-input)
595
+ - Demonstrates how to create and integrate custom input components
596
+
597
+ - **TreegeConfigProvider Example**: [http://localhost:5173/example-treege-config-provider](http://localhost:5173/example-treege-config-provider)
598
+ - Shows global configuration with TreegeConfigProvider
599
+
348
600
  ## API Reference
349
601
 
350
602
  ### TreegeEditor Props
351
603
 
352
- | Prop | Type | Default | Description |
353
- |------------|------------------------|----------|-----------------------------|
354
- | `flow` | `Flow \| null` | `null` | Initial decision tree |
355
- | `onSave` | `(flow: Flow) => void` | - | Callback when tree is saved |
356
- | `language` | `string` | `"en"` | UI language |
357
- | `theme` | `"light" \| "dark"` | `"dark"` | Editor theme |
604
+ | Prop | Type | Default | Description |
605
+ |----------------|------------------------------------------|----------|--------------------------------------------------------------------------------|
606
+ | `flow` | `Flow \| null` | `null` | Initial decision tree |
607
+ | `onSave` | `(flow: Flow) => void` | - | Callback when tree is saved |
608
+ | `onExportJson` | `() => { nodes: Node[]; edges: Edge[] }` | - | Callback for exporting JSON data |
609
+ | `language` | `string` | `"en"` | UI language |
610
+ | `theme` | `"light" \| "dark"` | `"dark"` | Editor theme |
611
+ | `aiConfig` | `AIConfig` | - | AI configuration for tree generation (see [AI Generation](./AI_GENERATION.md)) |
612
+ | `className` | `string` | - | Additional CSS class names for custom styling |
358
613
 
359
614
  ### TreegeRenderer Props
360
615
 
361
- | Prop | Type | Default | Description |
362
- |------------------|---------------------------------------------|--------------|----------------------------|
363
- | `flows` | `Flow \| null` | - | Decision tree to render |
364
- | `onSubmit` | `(values: FormValues) => void` | - | Form submission handler |
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` | `RendererComponents` | - | Custom component overrides |
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 |
616
+ | Prop | Type | Default | Description |
617
+ |------------------|---------------------------------------------|--------------|------------------------------------------------------------|
618
+ | `flows` | `Flow \| Flow[] \| null` | - | Decision tree to render (single Flow or array of Flows) |
619
+ | `onSubmit` | `(values: FormValues, meta?: Meta) => void` | - | Form submission handler (meta includes HTTP response data) |
620
+ | `onChange` | `(values: FormValues) => void` | - | Form change handler |
621
+ | `validate` | `(values, nodes) => Record<string, string>` | - | Custom validation function |
622
+ | `initialValues` | `FormValues` | `{}` | Initial form values |
623
+ | `components` | `TreegeRendererComponents` | - | Custom component overrides |
624
+ | `language` | `string` | `"en"` | UI language |
625
+ | `validationMode` | `"onSubmit" \| "onChange"` | `"onSubmit"` | When to validate |
626
+ | `theme` | `"light" \| "dark"` | `"dark"` | Renderer theme |
627
+ | `googleApiKey` | `string` | - | API key for address input |
628
+ | `className` | `string` | - | Additional CSS class names for custom styling |
373
629
 
374
630
  ## Development
375
631
 
@@ -392,12 +648,10 @@ yarn preview
392
648
 
393
649
  ## Tech Stack
394
650
 
395
- - **React** 18/19 - UI library
651
+ - **React** - UI library
396
652
  - **TypeScript** - Type safety
397
653
  - **TailwindCSS** 4 - Styling
398
654
  - **ReactFlow** - Node-based UI
399
- - **Radix UI** - Accessible components
400
- - **Zustand** - State management
401
655
  - **Vite** - Build tool
402
656
 
403
657
  ## Contributing
@@ -406,11 +660,11 @@ Contributions are welcome! Please feel free to submit a Pull Request.
406
660
 
407
661
  ## License
408
662
 
409
- ISC
663
+ MIT
410
664
 
411
665
  ## Credits
412
666
 
413
- Created and maintained by [Mickaël Austoni](https://github.com/Tracktor)
667
+ Created and maintained by [Mickaël Austoni](https://github.com/MickaelAustoni)
414
668
 
415
669
  ## Support
416
670