treege 3.0.0-beta.8 → 3.0.0-beta40
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 +213 -30
- package/dist/DefaultInputs-8yJMEyMh.js +1557 -0
- package/dist/ThemeContext-Ejgu9Mwr.js +1603 -0
- package/dist/editor/components/input/ComboboxWithCreate.d.ts +2 -1
- 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 +33 -0
- package/dist/editor/constants/nodeTypes.d.ts +5 -5
- package/dist/editor/context/TreegeEditorContext.d.ts +53 -1
- package/dist/editor/features/TreegeEditor/TreegeEditor.d.ts +1 -1
- 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/edges/ConditionalEdge.d.ts +2 -2
- package/dist/editor/features/TreegeEditor/edges/DefaultEdge.d.ts +3 -0
- package/dist/editor/features/TreegeEditor/forms/SubmitConfigForm.d.ts +7 -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/nodes/GroupNode.d.ts +2 -2
- package/dist/editor/features/TreegeEditor/nodes/TreegeNode.d.ts +6 -0
- package/dist/editor/features/TreegeEditor/nodes/components/BottomHandleDropdown.d.ts +6 -0
- package/dist/editor/features/TreegeEditor/nodes/components/NodeInputPreview.d.ts +7 -0
- package/dist/editor/features/TreegeEditor/nodes/components/NodeLabelInput.d.ts +9 -0
- package/dist/editor/features/TreegeEditor/nodes/components/NodeMoreMenu.d.ts +6 -0
- package/dist/editor/features/TreegeEditor/nodes/components/NodeTypeBadge.d.ts +7 -0
- package/dist/editor/features/TreegeEditor/nodes/components/OptionsEditor.d.ts +7 -0
- package/dist/editor/features/TreegeEditor/nodes/components/RequiredBadge.d.ts +6 -0
- package/dist/editor/features/TreegeEditor/nodes/layout/NodeWrapper.d.ts +2 -1
- package/dist/editor/features/TreegeEditor/panel/AIGeneratorDialog.d.ts +16 -0
- package/dist/editor/hooks/useAutoLayout.d.ts +15 -0
- package/dist/editor/hooks/useFlowActions.d.ts +5 -2
- package/dist/editor/hooks/useFlowConnections.d.ts +4 -0
- package/dist/editor/hooks/useNodesSelection.d.ts +5 -5
- package/dist/editor/types/ai.d.ts +65 -0
- package/dist/editor/types/editor.d.ts +9 -8
- package/dist/editor/utils/aiFlowGenerator.d.ts +5 -0
- package/dist/editor/utils/dagreLayout.d.ts +17 -0
- package/dist/editor/utils/edge.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-DWJ95r4g.js +4001 -0
- package/dist/editor.js +3 -7
- package/dist/main.js +4 -52
- package/dist/renderer/context/TreegeRendererContext.d.ts +4 -1
- 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/DefaultGroup.d.ts +7 -7
- package/dist/renderer/features/TreegeRenderer/native/components/DefaultInputs.d.ts +21 -15
- 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/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 +84 -24
- package/dist/renderer/features/TreegeRenderer/web/TreegeRenderer.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/DefaultSubmitButton.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultAddressInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultAutocompleteInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultCheckboxInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultDateInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultDateRangeInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultFileInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultHiddenInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultHttpInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultNumberInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultPasswordInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultRadioInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultSelectInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultSubmitInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultSwitchInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultTextAreaInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultTextInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultTimeInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultTimeRangeInput.d.ts +1 -1
- package/dist/renderer/hooks/useRenderNode.d.ts +55 -0
- package/dist/renderer/hooks/useSubmitHandler.d.ts +34 -0
- package/dist/renderer/hooks/useTranslate.d.ts +6 -4
- package/dist/renderer/index.d.ts +2 -0
- package/dist/renderer/index.native.d.ts +19 -0
- package/dist/renderer/types/renderer.d.ts +60 -6
- package/dist/renderer/utils/form.d.ts +22 -2
- package/dist/renderer/utils/http.d.ts +101 -0
- package/dist/renderer/utils/node.d.ts +18 -1
- package/dist/renderer/utils/sanitize.d.ts +85 -0
- package/dist/renderer/utils/sanitize.native.d.ts +69 -0
- package/dist/renderer/utils/submit.d.ts +47 -0
- package/dist/renderer-native.d.ts +2 -0
- package/dist/renderer-native.js +3496 -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 +2 -2
- 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/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/tooltip.d.ts +1 -1
- package/dist/shared/constants/colors.d.ts +45 -0
- package/dist/shared/constants/inputType.d.ts +1 -0
- package/dist/shared/context/ThemeContext.d.ts +2 -0
- package/dist/shared/context/ThemeContext.native.d.ts +22 -0
- package/dist/shared/hooks/useThemeColors.d.ts +37 -0
- package/dist/shared/locales/ar.json.d.ts +117 -10
- package/dist/shared/locales/de.json.d.ts +118 -11
- package/dist/shared/locales/en.json.d.ts +119 -12
- package/dist/shared/locales/es.json.d.ts +118 -11
- package/dist/shared/locales/fr.json.d.ts +118 -11
- package/dist/shared/locales/it.json.d.ts +118 -11
- package/dist/shared/locales/pt.json.d.ts +118 -11
- package/dist/shared/types/edge.d.ts +6 -0
- package/dist/shared/types/node.d.ts +64 -0
- package/package.json +38 -12
- 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/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/InputNode.d.ts +0 -6
- package/dist/editor/features/TreegeEditor/nodes/UINode.d.ts +0 -6
package/LICENSE
CHANGED
|
@@ -1,15 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (
|
|
3
|
+
Copyright (c) 2025 Tracktor
|
|
4
4
|
|
|
5
|
-
Permission
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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,7 +5,7 @@
|
|
|
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
11
|
<a href="https://treege.io/">🌐 Website</a> •
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
<a href="#features">Features</a> •
|
|
14
14
|
<a href="#installation">Installation</a> •
|
|
15
15
|
<a href="#quick-start">Quick Start</a> •
|
|
16
|
-
<a href="#examples">Examples</a>
|
|
16
|
+
<a href="#examples">Examples</a> •
|
|
17
|
+
<a href="./AI_GENERATION.md">🪄 AI Generation</a>
|
|
17
18
|
</p>
|
|
18
19
|
</div>
|
|
19
20
|
|
|
@@ -29,6 +30,7 @@ Treege is a modern React library for creating and rendering interactive decision
|
|
|
29
30
|
- **Node-based Interface**: Drag-and-drop editor powered by ReactFlow
|
|
30
31
|
- **4 Node Types**: Flow, Group, Input, and UI nodes
|
|
31
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))
|
|
32
34
|
- **Multi-language Support**: Built-in translation system for all labels
|
|
33
35
|
- **Type-safe**: Full TypeScript support
|
|
34
36
|
- **Mini-map & Controls**: Navigation tools for complex trees
|
|
@@ -37,11 +39,14 @@ Treege is a modern React library for creating and rendering interactive decision
|
|
|
37
39
|
### Runtime Renderer (`treege/renderer`)
|
|
38
40
|
- **Production Ready**: Full-featured form generation and validation system
|
|
39
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
|
|
40
43
|
- **HTTP Integration**: Built-in API integration with response mapping and search functionality
|
|
41
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
|
|
42
47
|
- **Conditional Logic**: Dynamic field visibility based on user input and conditional edges
|
|
43
|
-
- **Web & Native**: Both web (React) and React Native renderer implementations
|
|
44
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
|
|
45
50
|
- **Theme Support**: Dark/light mode out of the box
|
|
46
51
|
- **Google API Integration**: Address autocomplete support
|
|
47
52
|
|
|
@@ -161,7 +166,7 @@ function App() {
|
|
|
161
166
|
|
|
162
167
|
## Module Structure
|
|
163
168
|
|
|
164
|
-
Treege provides
|
|
169
|
+
Treege provides multiple import paths for optimal bundle size:
|
|
165
170
|
|
|
166
171
|
```tsx
|
|
167
172
|
// Import everything (editor + renderer + types)
|
|
@@ -170,10 +175,167 @@ import { TreegeEditor, TreegeRenderer } from "treege";
|
|
|
170
175
|
// Import only the editor
|
|
171
176
|
import { TreegeEditor } from "treege/editor";
|
|
172
177
|
|
|
173
|
-
// Import only the renderer
|
|
178
|
+
// Import only the web renderer
|
|
174
179
|
import { TreegeRenderer } from "treege/renderer";
|
|
180
|
+
|
|
181
|
+
// Import only the React Native renderer
|
|
182
|
+
import { TreegeRenderer } from "treege/renderer-native";
|
|
183
|
+
```
|
|
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
|
+
/>
|
|
175
298
|
```
|
|
176
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
|
+
|
|
177
339
|
## Node Types
|
|
178
340
|
|
|
179
341
|
### Flow Node
|
|
@@ -412,35 +574,58 @@ function CustomForm() {
|
|
|
412
574
|
Check out the `/example` directory for complete examples:
|
|
413
575
|
|
|
414
576
|
```bash
|
|
415
|
-
|
|
416
|
-
|
|
577
|
+
# Run the example app
|
|
578
|
+
bun example
|
|
417
579
|
```
|
|
418
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
|
+
|
|
419
600
|
## API Reference
|
|
420
601
|
|
|
421
602
|
### TreegeEditor Props
|
|
422
603
|
|
|
423
|
-
| Prop
|
|
424
|
-
|
|
425
|
-
| `flow`
|
|
426
|
-
| `onSave`
|
|
427
|
-
| `
|
|
428
|
-
| `
|
|
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 |
|
|
429
613
|
|
|
430
614
|
### TreegeRenderer Props
|
|
431
615
|
|
|
432
|
-
| Prop | Type | Default | Description
|
|
433
|
-
|
|
434
|
-
| `flows` | `Flow \| null`
|
|
435
|
-
| `onSubmit` | `(values: FormValues) => void`
|
|
436
|
-
| `onChange` | `(values: FormValues) => void` | - | Form change handler
|
|
437
|
-
| `validate` | `(values, nodes) => Record<string, string>` | - | Custom validation function
|
|
438
|
-
| `initialValues` | `FormValues` | `{}` | Initial form values
|
|
439
|
-
| `components` | `
|
|
440
|
-
| `language` | `string` | `"en"` | UI language
|
|
441
|
-
| `validationMode` | `"onSubmit" \| "onChange"` | `"onSubmit"` | When to validate
|
|
442
|
-
| `theme` | `"light" \| "dark"` | `"dark"` | Renderer theme
|
|
443
|
-
| `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 |
|
|
444
629
|
|
|
445
630
|
## Development
|
|
446
631
|
|
|
@@ -463,12 +648,10 @@ yarn preview
|
|
|
463
648
|
|
|
464
649
|
## Tech Stack
|
|
465
650
|
|
|
466
|
-
- **React**
|
|
651
|
+
- **React** - UI library
|
|
467
652
|
- **TypeScript** - Type safety
|
|
468
653
|
- **TailwindCSS** 4 - Styling
|
|
469
654
|
- **ReactFlow** - Node-based UI
|
|
470
|
-
- **Radix UI** - Accessible components
|
|
471
|
-
- **Zustand** - State management
|
|
472
655
|
- **Vite** - Build tool
|
|
473
656
|
|
|
474
657
|
## Contributing
|
|
@@ -477,11 +660,11 @@ Contributions are welcome! Please feel free to submit a Pull Request.
|
|
|
477
660
|
|
|
478
661
|
## License
|
|
479
662
|
|
|
480
|
-
|
|
663
|
+
MIT
|
|
481
664
|
|
|
482
665
|
## Credits
|
|
483
666
|
|
|
484
|
-
Created and maintained by [Mickaël Austoni](https://github.com/
|
|
667
|
+
Created and maintained by [Mickaël Austoni](https://github.com/MickaelAustoni)
|
|
485
668
|
|
|
486
669
|
## Support
|
|
487
670
|
|