treege 3.0.0-beta.43 → 3.0.0-beta.45
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 +16 -9
- package/dist/DefaultInputs-DYKtphqY.js +1701 -0
- package/dist/ThemeContext-O482h1XZ.js +1397 -0
- package/dist/editor/components/styles/EditorStyles.d.ts +2 -0
- package/dist/editor/context/OpenApiContext.d.ts +79 -0
- package/dist/editor/context/TreegeEditorContext.d.ts +7 -0
- package/dist/editor/features/TreegeEditor/TreegeEditor.d.ts +1 -1
- package/dist/editor/features/TreegeEditor/dialogs/AuthorizeDialog.d.ts +20 -0
- package/dist/editor/features/TreegeEditor/dialogs/HeadersDialog.d.ts +19 -0
- package/dist/editor/features/TreegeEditor/dialogs/OpenApiDialog.d.ts +6 -0
- package/dist/editor/features/TreegeEditor/forms/OptionsSourceForm.d.ts +7 -0
- package/dist/editor/features/TreegeEditor/inputs/ApiUrlCombobox.d.ts +30 -0
- package/dist/editor/features/TreegeEditor/nodes/TreegeNode.d.ts +0 -1
- package/dist/editor/features/TreegeEditor/nodes/components/NodeImage.d.ts +5 -0
- package/dist/editor/features/TreegeEditor/nodes/components/NodeImageButton.d.ts +6 -0
- package/dist/editor/features/TreegeEditor/nodes/components/NodeOptions.d.ts +12 -0
- package/dist/editor/features/TreegeEditor/nodes/components/NodeRequiredButton.d.ts +6 -0
- package/dist/editor/features/TreegeEditor/panel/ActionsPanel.d.ts +5 -2
- package/dist/editor/types/editor.d.ts +39 -1
- package/dist/editor/types/openapi.d.ts +81 -0
- package/dist/editor/utils/openapi.d.ts +35 -0
- package/dist/editor-DBCMmZtt.js +5147 -0
- package/dist/editor.js +2 -3
- package/dist/main.js +4 -5
- package/dist/renderer/context/TreegeConfigContext.d.ts +3 -27
- package/dist/renderer/context/TreegeRendererContext.d.ts +99 -2
- package/dist/renderer/features/TreegeRenderer/native/components/DefaultInputWrapper.d.ts +9 -0
- package/dist/renderer/features/TreegeRenderer/useTreegeRenderer.d.ts +3 -2
- package/dist/renderer/features/TreegeRenderer/web/TreegeRenderer.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/DefaultFormWrapper.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/DefaultInputWrapper.d.ts +9 -0
- package/dist/renderer/features/TreegeRenderer/web/components/styles/RendererStyles.d.ts +2 -0
- package/dist/renderer/hooks/useInputOptions.d.ts +28 -0
- package/dist/renderer/hooks/useRenderNode.d.ts +7 -3
- package/dist/renderer/hooks/useSubmitHandler.d.ts +3 -2
- package/dist/renderer/types/renderer.d.ts +13 -25
- package/dist/renderer/utils/http.d.ts +29 -1
- package/dist/renderer/utils/submit.d.ts +3 -2
- package/dist/renderer-native.js +794 -782
- package/dist/renderer.js +3 -4
- package/dist/shared/components/ui/button.d.ts +1 -1
- package/dist/shared/components/ui/field.d.ts +24 -0
- package/dist/shared/components/ui/toggle-group.d.ts +7 -0
- package/dist/shared/components/ui/toggle.d.ts +9 -0
- package/dist/shared/locales/ar.json.d.ts +80 -0
- package/dist/shared/locales/de.json.d.ts +80 -0
- package/dist/shared/locales/en.json.d.ts +80 -0
- package/dist/shared/locales/es.json.d.ts +80 -0
- package/dist/shared/locales/fr.json.d.ts +80 -0
- package/dist/shared/locales/it.json.d.ts +80 -0
- package/dist/shared/locales/pt.json.d.ts +80 -0
- package/dist/shared/types/node.d.ts +44 -0
- package/package.json +3 -2
- package/dist/DefaultInputs-Cr6wTVNE.js +0 -1558
- package/dist/ThemeContext-CUHjGVUf.js +0 -1602
- package/dist/editor/features/TreegeEditor/nodes/components/OptionsEditor.d.ts +0 -7
- package/dist/editor/features/TreegeEditor/nodes/components/RequiredBadge.d.ts +0 -6
- package/dist/editor-CE8g1o72.js +0 -4037
- /package/dist/editor/components/{data-display/logo.d.ts → branding/Logo.d.ts} +0 -0
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { TreegeRendererProps } from '../../../types/renderer';
|
|
2
|
-
declare const TreegeRenderer: ({ components, className, flows, googleApiKey, language, onChange, onSubmit, theme, validate, validationMode, initialValues, }: TreegeRendererProps) => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
declare const TreegeRenderer: ({ components, className, flows, googleApiKey, headers, language, onChange, onSubmit, theme, validate, validationMode, initialValues, }: TreegeRendererProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
export default TreegeRenderer;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FormEvent, ReactNode } from 'react';
|
|
2
2
|
declare const DefaultFormWrapper: ({ children, onSubmit }: {
|
|
3
3
|
children: ReactNode;
|
|
4
|
-
onSubmit: (e: FormEvent) => void;
|
|
4
|
+
onSubmit: (e: FormEvent<HTMLFormElement>) => void;
|
|
5
5
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
6
6
|
export default DefaultFormWrapper;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Node } from '@xyflow/react';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { InputNodeData } from '../../../../../shared/types/node';
|
|
4
|
+
interface DefaultInputWrapperProps {
|
|
5
|
+
node: Node<InputNodeData>;
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
}
|
|
8
|
+
export declare const DefaultInputWrapper: ({ node, children }: DefaultInputWrapperProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export default DefaultInputWrapper;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Node } from '@xyflow/react';
|
|
2
|
+
import { InputNodeData, InputOption } from '../../shared/types/node';
|
|
3
|
+
interface UseInputOptionsResult {
|
|
4
|
+
/**
|
|
5
|
+
* Resolved options for the input. When the node has an `optionsSource`,
|
|
6
|
+
* these are the fetched options (or the static fallback while loading or
|
|
7
|
+
* if the fetch errors). Otherwise the static `options` from the node data.
|
|
8
|
+
*/
|
|
9
|
+
options: InputOption[];
|
|
10
|
+
/** True while a remote fetch is in flight. */
|
|
11
|
+
isLoading: boolean;
|
|
12
|
+
/** Error message if the latest remote fetch failed; otherwise `null`. */
|
|
13
|
+
error: string | null;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Resolves the options for an option-based input (radio, checkbox, select,
|
|
17
|
+
* autocomplete). If the node declares an `optionsSource`, options are fetched
|
|
18
|
+
* from that API at runtime, with `{{templateVar}}` substitution from form
|
|
19
|
+
* values and merging of global + field-level headers. While loading, before
|
|
20
|
+
* the first successful fetch, or on error, falls back to the static
|
|
21
|
+
* `options` array (if any).
|
|
22
|
+
*
|
|
23
|
+
* The fetch plan is computed once and serialized to JSON. The fetch effect
|
|
24
|
+
* keys off this string: changes that don't affect the actual request (e.g.
|
|
25
|
+
* an unrelated form field) produce the same JSON and don't re-trigger.
|
|
26
|
+
*/
|
|
27
|
+
export declare const useInputOptions: (node: Node<InputNodeData>) => UseInputOptionsResult;
|
|
28
|
+
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Node } from '@xyflow/react';
|
|
2
2
|
import { ComponentType, ReactNode } from 'react';
|
|
3
3
|
import { FormValues, InputRenderers, TreegeRendererComponents } from '../types/renderer';
|
|
4
|
-
import { TreegeNodeData } from '../../shared/types/node';
|
|
4
|
+
import { InputNodeData, TreegeNodeData } from '../../shared/types/node';
|
|
5
5
|
type AnyComponent = ComponentType<any>;
|
|
6
6
|
type UseRenderNodeParams = {
|
|
7
7
|
config: {
|
|
@@ -10,6 +10,10 @@ type UseRenderNodeParams = {
|
|
|
10
10
|
};
|
|
11
11
|
DefaultFormWrapper: AnyComponent;
|
|
12
12
|
DefaultGroup: AnyComponent;
|
|
13
|
+
DefaultInputWrapper: ComponentType<{
|
|
14
|
+
node: Node<InputNodeData>;
|
|
15
|
+
children: ReactNode;
|
|
16
|
+
}>;
|
|
13
17
|
DefaultSubmitButton: AnyComponent;
|
|
14
18
|
DefaultSubmitButtonWrapper?: AnyComponent;
|
|
15
19
|
defaultInputRenderers: InputRenderers;
|
|
@@ -30,10 +34,10 @@ type UseRenderNodeParams = {
|
|
|
30
34
|
* - SubmitButton: Submit button component with fallback
|
|
31
35
|
* - SubmitButtonWrapper: Submit button wrapper component with fallback (web only, undefined for native)
|
|
32
36
|
*/
|
|
33
|
-
export declare const useRenderNode: ({ DefaultFormWrapper, DefaultGroup, DefaultSubmitButton, DefaultSubmitButtonWrapper, config, defaultInputRenderers, defaultUI, formErrors, formValues, missingRequiredFields, setFieldValue, visibleNodes, }: UseRenderNodeParams) => {
|
|
37
|
+
export declare const useRenderNode: ({ DefaultFormWrapper, DefaultGroup, DefaultInputWrapper, DefaultSubmitButton, DefaultSubmitButtonWrapper, config, defaultInputRenderers, defaultUI, formErrors, formValues, missingRequiredFields, setFieldValue, visibleNodes, }: UseRenderNodeParams) => {
|
|
34
38
|
FormWrapper: ((props: {
|
|
35
39
|
children: ReactNode;
|
|
36
|
-
onSubmit: (e: import('react').FormEvent) => void;
|
|
40
|
+
onSubmit: (e: import('react').FormEvent<HTMLFormElement>) => void;
|
|
37
41
|
}) => ReactNode) | AnyComponent;
|
|
38
42
|
renderNode: (node: Node<TreegeNodeData>) => ReactNode;
|
|
39
43
|
SubmitButton: ((props: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Node } from '@xyflow/react';
|
|
2
2
|
import { FormValues } from '../types/renderer';
|
|
3
3
|
import { SubmitResult } from '../utils/submit';
|
|
4
|
-
import { InputNodeData, TreegeNodeData } from '../../shared/types/node';
|
|
4
|
+
import { HttpHeader, InputNodeData, TreegeNodeData } from '../../shared/types/node';
|
|
5
5
|
/**
|
|
6
6
|
* Hook for handling form submission with submit button configuration
|
|
7
7
|
*
|
|
@@ -16,9 +16,10 @@ import { InputNodeData, TreegeNodeData } from '../../shared/types/node';
|
|
|
16
16
|
* @param formValues - Current form values
|
|
17
17
|
* @param language - Current language for translations
|
|
18
18
|
* @param inputNodes - All input nodes for form data conversion
|
|
19
|
+
* @param headers
|
|
19
20
|
* @returns Submit handler state and functions
|
|
20
21
|
*/
|
|
21
|
-
export declare const useSubmitHandler: (visibleNodes: Node<TreegeNodeData>[], formValues: FormValues, language: string, inputNodes: Node<InputNodeData>[]) => {
|
|
22
|
+
export declare const useSubmitHandler: (visibleNodes: Node<TreegeNodeData>[], formValues: FormValues, language: string, inputNodes: Node<InputNodeData>[], headers?: HttpHeader[]) => {
|
|
22
23
|
clearSubmitMessage: () => void;
|
|
23
24
|
handleSubmitWithConfig: (onSuccess?: (data: unknown) => void) => Promise<SubmitResult | null>;
|
|
24
25
|
hasSubmitConfig: boolean;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Node } from '@xyflow/react';
|
|
2
2
|
import { FormEvent, ReactNode } from 'react';
|
|
3
3
|
import { SerializableFile } from '../utils/file';
|
|
4
|
-
import { Flow, InputNodeData, InputType, TreegeNodeData, UINodeData, UIType } from '../../shared/types/node';
|
|
4
|
+
import { Flow, HttpHeader, InputNodeData, InputType, TreegeNodeData, UINodeData, UIType } from '../../shared/types/node';
|
|
5
5
|
/**
|
|
6
6
|
* Type mapping for input values based on input type
|
|
7
7
|
*/
|
|
@@ -128,7 +128,7 @@ export type TreegeRendererComponents = {
|
|
|
128
128
|
*/
|
|
129
129
|
form?: (props: {
|
|
130
130
|
children: ReactNode;
|
|
131
|
-
onSubmit: (e: FormEvent) => void;
|
|
131
|
+
onSubmit: (e: FormEvent<HTMLFormElement>) => void;
|
|
132
132
|
}) => ReactNode;
|
|
133
133
|
/**
|
|
134
134
|
* Custom submit button (supports both web and native variants)
|
|
@@ -163,6 +163,12 @@ export type TreegeRendererConfig = {
|
|
|
163
163
|
* Custom component renderers
|
|
164
164
|
*/
|
|
165
165
|
components?: TreegeRendererComponents;
|
|
166
|
+
/**
|
|
167
|
+
* Global HTTP headers applied to every request issued by the renderer
|
|
168
|
+
* (HTTP inputs, submit buttons). Field-level headers with the same key
|
|
169
|
+
* (case-insensitive) take precedence over these.
|
|
170
|
+
*/
|
|
171
|
+
headers?: HttpHeader[];
|
|
166
172
|
/**
|
|
167
173
|
* Google Maps API key for address autocomplete
|
|
168
174
|
* If not provided, falls back to free Nominatim (OpenStreetMap)
|
|
@@ -186,35 +192,26 @@ export type TreegeRendererConfig = {
|
|
|
186
192
|
};
|
|
187
193
|
/**
|
|
188
194
|
* Props for the TreegeRenderer component
|
|
195
|
+
*
|
|
196
|
+
* Inherits all configuration fields from TreegeRendererConfig (components,
|
|
197
|
+
* headers, googleApiKey, language, theme, validationMode) and adds the
|
|
198
|
+
* instance-specific ones (flows, callbacks, initial values, etc.).
|
|
189
199
|
*/
|
|
190
|
-
export interface TreegeRendererProps {
|
|
200
|
+
export interface TreegeRendererProps extends TreegeRendererConfig {
|
|
191
201
|
/**
|
|
192
202
|
* Additional class name for the renderer container
|
|
193
203
|
*/
|
|
194
204
|
className?: string;
|
|
195
|
-
/**
|
|
196
|
-
* Custom component renderers
|
|
197
|
-
*/
|
|
198
|
-
components?: TreegeRendererComponents;
|
|
199
205
|
/**
|
|
200
206
|
* Flow or array of flows
|
|
201
207
|
* - If a single Flow: renders that flow
|
|
202
208
|
* - If an array: first flow is the main flow, others are sub-flows available for FlowNodes
|
|
203
209
|
*/
|
|
204
210
|
flows?: Flow | Flow[] | null;
|
|
205
|
-
/**
|
|
206
|
-
* Google Maps API key for address autocomplete
|
|
207
|
-
* If not provided, falls back to free Nominatim (OpenStreetMap)
|
|
208
|
-
*/
|
|
209
|
-
googleApiKey?: string;
|
|
210
211
|
/**
|
|
211
212
|
* Initial form values
|
|
212
213
|
*/
|
|
213
214
|
initialValues?: FormValues;
|
|
214
|
-
/**
|
|
215
|
-
* Current language for translations
|
|
216
|
-
*/
|
|
217
|
-
language?: string;
|
|
218
215
|
/**
|
|
219
216
|
* Callback when form values change
|
|
220
217
|
*/
|
|
@@ -225,17 +222,8 @@ export interface TreegeRendererProps {
|
|
|
225
222
|
* @param meta - Optional metadata about the submission (e.g., HTTP response data)
|
|
226
223
|
*/
|
|
227
224
|
onSubmit?: (values: FormValues, meta?: Meta) => void;
|
|
228
|
-
/**
|
|
229
|
-
* Theme for the renderer
|
|
230
|
-
* @default "dark"
|
|
231
|
-
*/
|
|
232
|
-
theme?: "dark" | "light";
|
|
233
225
|
/**
|
|
234
226
|
* Custom validation function
|
|
235
227
|
*/
|
|
236
228
|
validate?: (values: FormValues, nodes: Node<TreegeNodeData>[]) => Record<string, string>;
|
|
237
|
-
/**
|
|
238
|
-
* Validation mode
|
|
239
|
-
*/
|
|
240
|
-
validationMode?: "onChange" | "onSubmit";
|
|
241
229
|
}
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { FormValues } from '../types/renderer';
|
|
2
|
-
import { HttpHeader } from '../../shared/types/node';
|
|
2
|
+
import { HttpHeader, InputOption, OptionsSourceMapping } from '../../shared/types/node';
|
|
3
|
+
/**
|
|
4
|
+
* Merge multiple lists of HTTP headers. Later sources override earlier ones
|
|
5
|
+
* when they specify the same key (case-insensitive comparison, since HTTP
|
|
6
|
+
* header names are case-insensitive). The casing of the latest occurrence
|
|
7
|
+
* is preserved in the output.
|
|
8
|
+
*/
|
|
9
|
+
export declare const mergeHttpHeaders: (...sources: (HttpHeader[] | undefined)[]) => HttpHeader[];
|
|
3
10
|
/**
|
|
4
11
|
* Result of an HTTP request
|
|
5
12
|
*/
|
|
@@ -45,6 +52,10 @@ export interface HttpRequestOptions {
|
|
|
45
52
|
* Request body (for POST/PUT/PATCH)
|
|
46
53
|
*/
|
|
47
54
|
body?: string;
|
|
55
|
+
/**
|
|
56
|
+
* Optional abort signal to cancel the request
|
|
57
|
+
*/
|
|
58
|
+
signal?: AbortSignal;
|
|
48
59
|
}
|
|
49
60
|
/**
|
|
50
61
|
* Make an HTTP request with common error handling and response parsing
|
|
@@ -99,3 +110,20 @@ export declare const replaceTemplateVariables: (template: string | undefined, va
|
|
|
99
110
|
* @returns The string with variables replaced
|
|
100
111
|
*/
|
|
101
112
|
export declare const replaceResponseVariables: (template: string | undefined, responseData: unknown) => string;
|
|
113
|
+
/**
|
|
114
|
+
* Extract a value from an object using a path that supports dot notation
|
|
115
|
+
* and array indexing. Examples:
|
|
116
|
+
* - "data.users" → obj.data.users
|
|
117
|
+
* - "results[0].name" → obj.results[0].name
|
|
118
|
+
*
|
|
119
|
+
* @param obj - The object to extract value from
|
|
120
|
+
* @param path - The path expression (empty string returns the object as-is)
|
|
121
|
+
* @returns The value at the path, or undefined if not found
|
|
122
|
+
*/
|
|
123
|
+
export declare const getValueByPath: (obj: unknown, path: string) => unknown;
|
|
124
|
+
/**
|
|
125
|
+
* Project a list-shaped HTTP response into InputOption objects, applying
|
|
126
|
+
* a field-to-property mapping. Returns an empty array when the data is not
|
|
127
|
+
* iterable or required fields are missing.
|
|
128
|
+
*/
|
|
129
|
+
export declare const extractOptionsFromResponse: (response: unknown, responsePath: string | undefined, mapping: OptionsSourceMapping) => InputOption[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Node } from '@xyflow/react';
|
|
2
2
|
import { FormValues } from '../types/renderer';
|
|
3
|
-
import { InputNodeData, SubmitConfig } from '../../shared/types/node';
|
|
3
|
+
import { HttpHeader, InputNodeData, SubmitConfig } from '../../shared/types/node';
|
|
4
4
|
/**
|
|
5
5
|
* Result of a form submission
|
|
6
6
|
*/
|
|
@@ -34,9 +34,10 @@ export interface SubmitResult {
|
|
|
34
34
|
* @param config - Submit configuration from the submit button node
|
|
35
35
|
* @param formValues - Current form values
|
|
36
36
|
* @param inputNodes - All input nodes (required when sendAllFormValues is true)
|
|
37
|
+
* @param headers
|
|
37
38
|
* @returns Promise with submission result
|
|
38
39
|
*/
|
|
39
|
-
export declare const submitFormData: (config: SubmitConfig, formValues: FormValues, inputNodes: Node<InputNodeData>[]) => Promise<SubmitResult>;
|
|
40
|
+
export declare const submitFormData: (config: SubmitConfig, formValues: FormValues, inputNodes: Node<InputNodeData>[], headers?: HttpHeader[]) => Promise<SubmitResult>;
|
|
40
41
|
/**
|
|
41
42
|
* Perform redirect to the specified URL
|
|
42
43
|
*
|