treege 3.0.0-beta.6 → 3.0.0-beta.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +94 -23
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,10 +8,11 @@
|
|
|
8
8
|
[](https://opensource.org/licenses/ISC)
|
|
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
16
|
<a href="#examples">Examples</a>
|
|
16
17
|
</p>
|
|
17
18
|
</div>
|
|
@@ -26,17 +27,23 @@ Treege is a modern React library for creating and rendering interactive decision
|
|
|
26
27
|
|
|
27
28
|
### Visual Editor (`treege/editor`)
|
|
28
29
|
- **Node-based Interface**: Drag-and-drop editor powered by ReactFlow
|
|
29
|
-
- **
|
|
30
|
-
- **Conditional Edges**: Advanced logic with AND/OR operators
|
|
31
|
-
- **Multi-language Support**: Built-in translation system
|
|
30
|
+
- **4 Node Types**: Flow, Group, Input, and UI nodes
|
|
31
|
+
- **Conditional Edges**: Advanced logic with AND/OR operators (`===`, `!==`, `>`, `<`, `>=`, `<=`)
|
|
32
|
+
- **Multi-language Support**: Built-in translation system for all labels
|
|
32
33
|
- **Type-safe**: Full TypeScript support
|
|
34
|
+
- **Mini-map & Controls**: Navigation tools for complex trees
|
|
35
|
+
- **Theme Support**: Dark/light mode with customizable backgrounds
|
|
33
36
|
|
|
34
37
|
### Runtime Renderer (`treege/renderer`)
|
|
35
|
-
- **
|
|
36
|
-
- **
|
|
37
|
-
- **
|
|
38
|
-
- **
|
|
38
|
+
- **Production Ready**: Full-featured form generation and validation system
|
|
39
|
+
- **16 Input Types**: text, number, select, checkbox, radio, date, daterange, time, timerange, file, address, http, textarea, password, switch, autocomplete, and hidden
|
|
40
|
+
- **HTTP Integration**: Built-in API integration with response mapping and search functionality
|
|
41
|
+
- **Advanced Validation**: Required fields, pattern matching, custom validation functions
|
|
42
|
+
- **Conditional Logic**: Dynamic field visibility based on user input and conditional edges
|
|
43
|
+
- **Web & Native**: Both web (React) and React Native renderer implementations
|
|
44
|
+
- **Fully Customizable**: Override any component (FormWrapper, Group, Inputs, SubmitButton, UI elements)
|
|
39
45
|
- **Theme Support**: Dark/light mode out of the box
|
|
46
|
+
- **Google API Integration**: Address autocomplete support
|
|
40
47
|
|
|
41
48
|
### Developer Experience
|
|
42
49
|
- **Modular**: Import only what you need (editor, renderer, or both)
|
|
@@ -199,7 +206,7 @@ Form input with validation, patterns, and conditional logic.
|
|
|
199
206
|
}
|
|
200
207
|
```
|
|
201
208
|
|
|
202
|
-
Supported input types: `text`, `
|
|
209
|
+
Supported input types: `text`, `number`, `textarea`, `password`, `select`, `radio`, `checkbox`, `switch`, `autocomplete`, `date`, `daterange`, `time`, `timerange`, `file`, `address`, `http`, `hidden`
|
|
203
210
|
|
|
204
211
|
### Group Node
|
|
205
212
|
Container for organizing multiple nodes together.
|
|
@@ -213,31 +220,23 @@ Container for organizing multiple nodes together.
|
|
|
213
220
|
}
|
|
214
221
|
```
|
|
215
222
|
|
|
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
223
|
### UI Node
|
|
229
|
-
Display-only elements
|
|
224
|
+
Display-only elements for visual organization and content display.
|
|
230
225
|
|
|
231
226
|
```tsx
|
|
232
227
|
{
|
|
233
228
|
type: "ui",
|
|
234
229
|
data: {
|
|
235
|
-
type: "title",
|
|
230
|
+
type: "title", // or "divider"
|
|
236
231
|
label: "Welcome to the form"
|
|
237
232
|
}
|
|
238
233
|
}
|
|
239
234
|
```
|
|
240
235
|
|
|
236
|
+
Supported UI types:
|
|
237
|
+
- `title` - Display headings and titles
|
|
238
|
+
- `divider` - Visual separator between sections
|
|
239
|
+
|
|
241
240
|
## Conditional Edges
|
|
242
241
|
|
|
243
242
|
Create dynamic flows with conditional logic:
|
|
@@ -336,6 +335,78 @@ Control when validation occurs:
|
|
|
336
335
|
<TreegeRenderer validationMode="onChange" />
|
|
337
336
|
```
|
|
338
337
|
|
|
338
|
+
### HTTP Input Integration
|
|
339
|
+
|
|
340
|
+
Use the HTTP input type to fetch and map data from APIs:
|
|
341
|
+
|
|
342
|
+
```tsx
|
|
343
|
+
{
|
|
344
|
+
type: "input",
|
|
345
|
+
data: {
|
|
346
|
+
type: "http",
|
|
347
|
+
name: "country",
|
|
348
|
+
label: "Select your country",
|
|
349
|
+
httpConfig: {
|
|
350
|
+
method: "GET",
|
|
351
|
+
url: "https://api.example.com/countries",
|
|
352
|
+
responsePath: "$.data.countries", // JSONPath to extract data
|
|
353
|
+
mapping: {
|
|
354
|
+
label: "name",
|
|
355
|
+
value: "code"
|
|
356
|
+
},
|
|
357
|
+
searchParam: "query", // Enable search functionality
|
|
358
|
+
fetchOnMount: true
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
### Global Configuration
|
|
365
|
+
|
|
366
|
+
Configure the renderer globally using the TreegeConfigProvider:
|
|
367
|
+
|
|
368
|
+
```tsx
|
|
369
|
+
import { TreegeConfigProvider } from "treege/renderer";
|
|
370
|
+
|
|
371
|
+
function App() {
|
|
372
|
+
return (
|
|
373
|
+
<TreegeConfigProvider
|
|
374
|
+
config={{
|
|
375
|
+
language: "fr",
|
|
376
|
+
googleApiKey: "your-google-api-key",
|
|
377
|
+
components: {
|
|
378
|
+
// Your custom components
|
|
379
|
+
}
|
|
380
|
+
}}
|
|
381
|
+
>
|
|
382
|
+
<TreegeRenderer flows={flow} />
|
|
383
|
+
</TreegeConfigProvider>
|
|
384
|
+
);
|
|
385
|
+
}
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
### Programmatic Control
|
|
389
|
+
|
|
390
|
+
Use the `useTreegeRenderer` hook for programmatic control:
|
|
391
|
+
|
|
392
|
+
```tsx
|
|
393
|
+
import { useTreegeRenderer } from "treege/renderer";
|
|
394
|
+
|
|
395
|
+
function CustomForm() {
|
|
396
|
+
const { values, setFieldValue, submit, reset } = useTreegeRenderer();
|
|
397
|
+
|
|
398
|
+
return (
|
|
399
|
+
<div>
|
|
400
|
+
<button onClick={() => setFieldValue("email", "test@example.com")}>
|
|
401
|
+
Prefill Email
|
|
402
|
+
</button>
|
|
403
|
+
<button onClick={submit}>Submit</button>
|
|
404
|
+
<button onClick={reset}>Reset</button>
|
|
405
|
+
</div>
|
|
406
|
+
);
|
|
407
|
+
}
|
|
408
|
+
```
|
|
409
|
+
|
|
339
410
|
## Examples
|
|
340
411
|
|
|
341
412
|
Check out the `/example` directory for complete examples:
|