treege 3.0.0-beta.2 → 3.0.0-beta.20
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 +118 -26
- package/dist/ThemeContext-BIT4DHqC.js +763 -0
- package/dist/TreegeEditor-LKN_xeXZ.js +3311 -0
- package/dist/TreegeRenderer--ZEq_w_0.js +1812 -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/nodeSpacing.d.ts +20 -0
- package/dist/editor/constants/nodeTypes.d.ts +5 -5
- package/dist/editor/context/TreegeEditorContext.d.ts +15 -0
- package/dist/editor/features/TreegeEditor/TreegeEditor.d.ts +1 -1
- 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/nodes/FlowNode.d.ts +2 -2
- package/dist/editor/features/TreegeEditor/nodes/GroupNode.d.ts +2 -2
- package/dist/editor/features/TreegeEditor/nodes/InputNode.d.ts +2 -2
- package/dist/editor/features/TreegeEditor/nodes/UINode.d.ts +2 -2
- package/dist/editor/features/TreegeEditor/nodes/hooks/useBottomHandleClick.d.ts +8 -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/useFlowActions.d.ts +1 -0
- package/dist/editor/hooks/useFlowConnections.d.ts +1 -0
- package/dist/editor/types/ai.d.ts +65 -0
- package/dist/editor/types/editor.d.ts +5 -8
- package/dist/editor/utils/aiFlowGenerator.d.ts +5 -0
- package/dist/editor.js +2 -2
- package/dist/main.js +43 -39
- package/dist/renderer/context/TreegeRendererContext.d.ts +4 -1
- package/dist/renderer/features/TreegeRenderer/useTreegeRenderer.d.ts +3 -1
- 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/useSubmitHandler.d.ts +34 -0
- package/dist/renderer/hooks/useTranslate.d.ts +6 -4
- package/dist/renderer/index.d.ts +1 -0
- package/dist/renderer/types/renderer.d.ts +40 -2
- 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 +9 -1
- package/dist/renderer/utils/sanitize.d.ts +85 -0
- package/dist/renderer/utils/submit.d.ts +47 -0
- package/dist/renderer.js +33 -29
- package/dist/shared/components/ui/alert-dialog.d.ts +14 -0
- package/dist/shared/components/ui/badge.d.ts +1 -1
- package/dist/shared/components/ui/popover.d.ts +3 -1
- package/dist/shared/components/ui/select.d.ts +3 -1
- package/dist/shared/constants/inputType.d.ts +1 -0
- package/dist/shared/locales/ar.json.d.ts +81 -8
- package/dist/shared/locales/de.json.d.ts +81 -8
- package/dist/shared/locales/en.json.d.ts +82 -9
- package/dist/shared/locales/es.json.d.ts +81 -8
- package/dist/shared/locales/fr.json.d.ts +81 -8
- package/dist/shared/locales/it.json.d.ts +81 -8
- package/dist/shared/locales/pt.json.d.ts +81 -8
- package/dist/shared/types/node.d.ts +51 -0
- package/package.json +9 -5
- package/dist/ThemeContext-BIvs8Kw-.js +0 -758
- package/dist/TreegeEditor-BSPfQQk3.js +0 -2151
- package/dist/TreegeRenderer-D3EvsEfJ.js +0 -1413
- package/dist/_name_.css +0 -1
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
|
@@ -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,25 @@ 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
|
+
- **Security**: Built-in input sanitization to prevent XSS attacks
|
|
43
|
+
- **Enhanced Error Messages**: Clear, user-friendly error messages for HTTP inputs and validation
|
|
44
|
+
- **Conditional Logic**: Dynamic field visibility based on user input and conditional edges
|
|
45
|
+
- **Web & Native**: Both web (React) and React Native renderer implementations
|
|
46
|
+
- **Fully Customizable**: Override any component (FormWrapper, Group, Inputs, SubmitButton, UI elements)
|
|
39
47
|
- **Theme Support**: Dark/light mode out of the box
|
|
48
|
+
- **Google API Integration**: Address autocomplete support
|
|
40
49
|
|
|
41
50
|
### Developer Experience
|
|
42
51
|
- **Modular**: Import only what you need (editor, renderer, or both)
|
|
@@ -199,7 +208,7 @@ Form input with validation, patterns, and conditional logic.
|
|
|
199
208
|
}
|
|
200
209
|
```
|
|
201
210
|
|
|
202
|
-
Supported input types: `text`, `
|
|
211
|
+
Supported input types: `text`, `number`, `textarea`, `password`, `select`, `radio`, `checkbox`, `switch`, `autocomplete`, `date`, `daterange`, `time`, `timerange`, `file`, `address`, `http`, `hidden`
|
|
203
212
|
|
|
204
213
|
### Group Node
|
|
205
214
|
Container for organizing multiple nodes together.
|
|
@@ -213,31 +222,23 @@ Container for organizing multiple nodes together.
|
|
|
213
222
|
}
|
|
214
223
|
```
|
|
215
224
|
|
|
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
225
|
### UI Node
|
|
229
|
-
Display-only elements
|
|
226
|
+
Display-only elements for visual organization and content display.
|
|
230
227
|
|
|
231
228
|
```tsx
|
|
232
229
|
{
|
|
233
230
|
type: "ui",
|
|
234
231
|
data: {
|
|
235
|
-
type: "title",
|
|
232
|
+
type: "title", // or "divider"
|
|
236
233
|
label: "Welcome to the form"
|
|
237
234
|
}
|
|
238
235
|
}
|
|
239
236
|
```
|
|
240
237
|
|
|
238
|
+
Supported UI types:
|
|
239
|
+
- `title` - Display headings and titles
|
|
240
|
+
- `divider` - Visual separator between sections
|
|
241
|
+
|
|
241
242
|
## Conditional Edges
|
|
242
243
|
|
|
243
244
|
Create dynamic flows with conditional logic:
|
|
@@ -336,15 +337,106 @@ Control when validation occurs:
|
|
|
336
337
|
<TreegeRenderer validationMode="onChange" />
|
|
337
338
|
```
|
|
338
339
|
|
|
340
|
+
### HTTP Input Integration
|
|
341
|
+
|
|
342
|
+
Use the HTTP input type to fetch and map data from APIs:
|
|
343
|
+
|
|
344
|
+
```tsx
|
|
345
|
+
{
|
|
346
|
+
type: "input",
|
|
347
|
+
data: {
|
|
348
|
+
type: "http",
|
|
349
|
+
name: "country",
|
|
350
|
+
label: "Select your country",
|
|
351
|
+
httpConfig: {
|
|
352
|
+
method: "GET",
|
|
353
|
+
url: "https://api.example.com/countries",
|
|
354
|
+
responsePath: "$.data.countries", // JSONPath to extract data
|
|
355
|
+
mapping: {
|
|
356
|
+
label: "name",
|
|
357
|
+
value: "code"
|
|
358
|
+
},
|
|
359
|
+
searchParam: "query", // Enable search functionality
|
|
360
|
+
fetchOnMount: true
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
### Global Configuration
|
|
367
|
+
|
|
368
|
+
Configure the renderer globally using the TreegeConfigProvider:
|
|
369
|
+
|
|
370
|
+
```tsx
|
|
371
|
+
import { TreegeConfigProvider } from "treege/renderer";
|
|
372
|
+
|
|
373
|
+
function App() {
|
|
374
|
+
return (
|
|
375
|
+
<TreegeConfigProvider
|
|
376
|
+
config={{
|
|
377
|
+
language: "fr",
|
|
378
|
+
googleApiKey: "your-google-api-key",
|
|
379
|
+
components: {
|
|
380
|
+
// Your custom components
|
|
381
|
+
}
|
|
382
|
+
}}
|
|
383
|
+
>
|
|
384
|
+
<TreegeRenderer flows={flow} />
|
|
385
|
+
</TreegeConfigProvider>
|
|
386
|
+
);
|
|
387
|
+
}
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
### Programmatic Control
|
|
391
|
+
|
|
392
|
+
Use the `useTreegeRenderer` hook for programmatic control:
|
|
393
|
+
|
|
394
|
+
```tsx
|
|
395
|
+
import { useTreegeRenderer } from "treege/renderer";
|
|
396
|
+
|
|
397
|
+
function CustomForm() {
|
|
398
|
+
const { values, setFieldValue, submit, reset } = useTreegeRenderer();
|
|
399
|
+
|
|
400
|
+
return (
|
|
401
|
+
<div>
|
|
402
|
+
<button onClick={() => setFieldValue("email", "test@example.com")}>
|
|
403
|
+
Prefill Email
|
|
404
|
+
</button>
|
|
405
|
+
<button onClick={submit}>Submit</button>
|
|
406
|
+
<button onClick={reset}>Reset</button>
|
|
407
|
+
</div>
|
|
408
|
+
);
|
|
409
|
+
}
|
|
410
|
+
```
|
|
411
|
+
|
|
339
412
|
## Examples
|
|
340
413
|
|
|
341
414
|
Check out the `/example` directory for complete examples:
|
|
342
415
|
|
|
343
416
|
```bash
|
|
344
|
-
|
|
345
|
-
|
|
417
|
+
# Run the example app
|
|
418
|
+
bun example
|
|
346
419
|
```
|
|
347
420
|
|
|
421
|
+
### Available Example URLs
|
|
422
|
+
|
|
423
|
+
Once the development server is running, you can access these examples:
|
|
424
|
+
|
|
425
|
+
- **Default Example**: [http://localhost:5173/](http://localhost:5173/)
|
|
426
|
+
- Basic demonstration of Treege functionality
|
|
427
|
+
|
|
428
|
+
- **Demo Example**: [http://localhost:5173/example](http://localhost:5173/example)
|
|
429
|
+
- Full featured demo showcasing the library capabilities
|
|
430
|
+
|
|
431
|
+
- **All Inputs Example**: [http://localhost:5173/example-all-inputs](http://localhost:5173/example-all-inputs)
|
|
432
|
+
- Comprehensive showcase of all 16 input types
|
|
433
|
+
|
|
434
|
+
- **Custom Input Example**: [http://localhost:5173/example-custom-input](http://localhost:5173/example-custom-input)
|
|
435
|
+
- Demonstrates how to create and integrate custom input components
|
|
436
|
+
|
|
437
|
+
- **TreegeConfigProvider Example**: [http://localhost:5173/example-treege-config-provider](http://localhost:5173/example-treege-config-provider)
|
|
438
|
+
- Shows global configuration with TreegeConfigProvider
|
|
439
|
+
|
|
348
440
|
## API Reference
|
|
349
441
|
|
|
350
442
|
### TreegeEditor Props
|
|
@@ -410,7 +502,7 @@ ISC
|
|
|
410
502
|
|
|
411
503
|
## Credits
|
|
412
504
|
|
|
413
|
-
Created and maintained by [Mickaël Austoni](https://github.com/
|
|
505
|
+
Created and maintained by [Mickaël Austoni](https://github.com/MickaelAustoni)
|
|
414
506
|
|
|
415
507
|
## Support
|
|
416
508
|
|