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.
Files changed (80) hide show
  1. package/LICENSE +18 -12
  2. package/README.md +118 -26
  3. package/dist/ThemeContext-BIT4DHqC.js +763 -0
  4. package/dist/TreegeEditor-LKN_xeXZ.js +3311 -0
  5. package/dist/TreegeRenderer--ZEq_w_0.js +1812 -0
  6. package/dist/editor/components/input/ComboboxWithCreate.d.ts +2 -1
  7. package/dist/editor/constants/defaultNode.d.ts +1 -1
  8. package/dist/editor/constants/edgeTypes.d.ts +3 -2
  9. package/dist/editor/constants/nodeSpacing.d.ts +20 -0
  10. package/dist/editor/constants/nodeTypes.d.ts +5 -5
  11. package/dist/editor/context/TreegeEditorContext.d.ts +15 -0
  12. package/dist/editor/features/TreegeEditor/TreegeEditor.d.ts +1 -1
  13. package/dist/editor/features/TreegeEditor/edges/ConditionalEdge.d.ts +2 -2
  14. package/dist/editor/features/TreegeEditor/edges/DefaultEdge.d.ts +3 -0
  15. package/dist/editor/features/TreegeEditor/forms/SubmitConfigForm.d.ts +7 -0
  16. package/dist/editor/features/TreegeEditor/inputs/ComboboxPattern.d.ts +2 -1
  17. package/dist/editor/features/TreegeEditor/nodes/FlowNode.d.ts +2 -2
  18. package/dist/editor/features/TreegeEditor/nodes/GroupNode.d.ts +2 -2
  19. package/dist/editor/features/TreegeEditor/nodes/InputNode.d.ts +2 -2
  20. package/dist/editor/features/TreegeEditor/nodes/UINode.d.ts +2 -2
  21. package/dist/editor/features/TreegeEditor/nodes/hooks/useBottomHandleClick.d.ts +8 -0
  22. package/dist/editor/features/TreegeEditor/nodes/layout/NodeWrapper.d.ts +2 -1
  23. package/dist/editor/features/TreegeEditor/panel/AIGeneratorDialog.d.ts +16 -0
  24. package/dist/editor/hooks/useFlowActions.d.ts +1 -0
  25. package/dist/editor/hooks/useFlowConnections.d.ts +1 -0
  26. package/dist/editor/types/ai.d.ts +65 -0
  27. package/dist/editor/types/editor.d.ts +5 -8
  28. package/dist/editor/utils/aiFlowGenerator.d.ts +5 -0
  29. package/dist/editor.js +2 -2
  30. package/dist/main.js +43 -39
  31. package/dist/renderer/context/TreegeRendererContext.d.ts +4 -1
  32. package/dist/renderer/features/TreegeRenderer/useTreegeRenderer.d.ts +3 -1
  33. package/dist/renderer/features/TreegeRenderer/web/TreegeRenderer.d.ts +1 -1
  34. package/dist/renderer/features/TreegeRenderer/web/components/DefaultSubmitButton.d.ts +1 -1
  35. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultAddressInput.d.ts +1 -1
  36. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultAutocompleteInput.d.ts +1 -1
  37. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultCheckboxInput.d.ts +1 -1
  38. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultDateInput.d.ts +1 -1
  39. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultDateRangeInput.d.ts +1 -1
  40. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultFileInput.d.ts +1 -1
  41. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultHiddenInput.d.ts +1 -1
  42. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultHttpInput.d.ts +1 -1
  43. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultNumberInput.d.ts +1 -1
  44. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultPasswordInput.d.ts +1 -1
  45. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultRadioInput.d.ts +1 -1
  46. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultSelectInput.d.ts +1 -1
  47. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultSubmitInput.d.ts +3 -0
  48. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultSwitchInput.d.ts +1 -1
  49. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultTextAreaInput.d.ts +1 -1
  50. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultTextInput.d.ts +1 -1
  51. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultTimeInput.d.ts +1 -1
  52. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultTimeRangeInput.d.ts +1 -1
  53. package/dist/renderer/hooks/useSubmitHandler.d.ts +34 -0
  54. package/dist/renderer/hooks/useTranslate.d.ts +6 -4
  55. package/dist/renderer/index.d.ts +1 -0
  56. package/dist/renderer/types/renderer.d.ts +40 -2
  57. package/dist/renderer/utils/form.d.ts +22 -2
  58. package/dist/renderer/utils/http.d.ts +101 -0
  59. package/dist/renderer/utils/node.d.ts +9 -1
  60. package/dist/renderer/utils/sanitize.d.ts +85 -0
  61. package/dist/renderer/utils/submit.d.ts +47 -0
  62. package/dist/renderer.js +33 -29
  63. package/dist/shared/components/ui/alert-dialog.d.ts +14 -0
  64. package/dist/shared/components/ui/badge.d.ts +1 -1
  65. package/dist/shared/components/ui/popover.d.ts +3 -1
  66. package/dist/shared/components/ui/select.d.ts +3 -1
  67. package/dist/shared/constants/inputType.d.ts +1 -0
  68. package/dist/shared/locales/ar.json.d.ts +81 -8
  69. package/dist/shared/locales/de.json.d.ts +81 -8
  70. package/dist/shared/locales/en.json.d.ts +82 -9
  71. package/dist/shared/locales/es.json.d.ts +81 -8
  72. package/dist/shared/locales/fr.json.d.ts +81 -8
  73. package/dist/shared/locales/it.json.d.ts +81 -8
  74. package/dist/shared/locales/pt.json.d.ts +81 -8
  75. package/dist/shared/types/node.d.ts +51 -0
  76. package/package.json +9 -5
  77. package/dist/ThemeContext-BIvs8Kw-.js +0 -758
  78. package/dist/TreegeEditor-BSPfQQk3.js +0 -2151
  79. package/dist/TreegeRenderer-D3EvsEfJ.js +0 -1413
  80. package/dist/_name_.css +0 -1
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
@@ -8,10 +8,11 @@
8
8
  [![License: ISC](https://img.shields.io/badge/License-ISC-blue.svg)](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
- - **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
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
- - **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
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`, `email`, `password`, `number`, `textarea`, `select`, `radio`, `checkbox`, `switch`, `date`, `dateRange`, `time`, `timeRange`, `file`, `address`, `http`
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 (titles, descriptions, separators).
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
- # Run the example app
345
- bun example
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/Tracktor)
505
+ Created and maintained by [Mickaël Austoni](https://github.com/MickaelAustoni)
414
506
 
415
507
  ## Support
416
508