treege 3.0.0-beta.44 → 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/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 -2
- package/dist/main.js +4 -4
- 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/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 -3
- 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 -1
- package/dist/DefaultInputs-D6a1ESW-.js +0 -1562
- 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-DjtjUgyb.js +0 -4041
package/dist/editor.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { t as e } from "./editor-
|
|
2
|
-
import { n as t, t as n } from "./ThemeContext-
|
|
1
|
+
import { t as e } from "./editor-DBCMmZtt.js";
|
|
2
|
+
import { n as t, t as n } from "./ThemeContext-O482h1XZ.js";
|
|
3
3
|
export { n as ThemeProvider, e as TreegeEditor, t as useTheme };
|
package/dist/main.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as e } from "./editor-
|
|
2
|
-
import {
|
|
3
|
-
import { C as O, D as k, E as A,
|
|
4
|
-
export {
|
|
1
|
+
import { t as e } from "./editor-DBCMmZtt.js";
|
|
2
|
+
import { B as t, C as n, D as r, E as i, H as a, L as o, M as s, N as c, O as l, R as u, S as d, T as f, V as p, _ as m, a as h, b as g, c as _, g as v, i as y, l as b, n as x, o as S, s as C, t as w, w as T, x as E, z as D } from "./ThemeContext-O482h1XZ.js";
|
|
3
|
+
import { C as O, D as k, E as A, S as j, T as M, a as N, b as P, d as F, f as I, h as L, i as R, l as z, m as B, n as V, p as H, r as U, s as W, t as G, u as K, v as q, w as J, x as Y, y as X } from "./DefaultInputs-DYKtphqY.js";
|
|
4
|
+
export { k as DefaultAddressInput, A as DefaultAutocompleteInput, M as DefaultCheckboxInput, J as DefaultDateInput, O as DefaultDateRangeInput, j as DefaultFileInput, H as DefaultGroup, Y as DefaultHiddenInput, P as DefaultHttpInput, X as DefaultNumberInput, q as DefaultPasswordInput, L as DefaultRadioInput, B as DefaultSelectInput, W as DefaultSwitchInput, N as DefaultTextAreaInput, R as DefaultTextInput, U as DefaultTimeInput, V as DefaultTimeRangeInput, K as Divider, w as ThemeProvider, F as Title, h as TreegeConfigProvider, e as TreegeEditor, z as TreegeRenderer, T as applyReferenceTransformation, f as calculateReferenceFieldUpdates, i as checkFormFieldHasValue, r as convertFormValuesToNamedFormat, G as defaultInputRenderers, I as defaultUI, s as evaluateCondition, c as evaluateConditions, C as fileToSerializable, _ as filesToSerializable, g as findStartNode, E as getFlowRenderState, o as getStaticTranslations, u as getTranslatedText, l as isFieldEmpty, D as isFlowNode, t as isGroupNode, p as isInputNode, d as isStartNode, a as isUINode, n as mergeFlows, v as sanitize, m as sanitizeHttpResponse, b as serializableToFile, x as useTheme, S as useTreegeConfig, y as useTreegeRenderer };
|
|
@@ -1,39 +1,15 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { TreegeRendererConfig } from '../types/renderer';
|
|
3
3
|
/**
|
|
4
4
|
* Hook to access the global Treege configuration
|
|
5
5
|
* Returns undefined if used outside of TreegeConfigProvider
|
|
6
6
|
*/
|
|
7
7
|
export declare const useTreegeConfig: () => TreegeRendererConfig | undefined;
|
|
8
|
-
export type TreegeConfigProviderProps = {
|
|
8
|
+
export type TreegeConfigProviderProps = TreegeRendererConfig & {
|
|
9
9
|
children: ReactNode;
|
|
10
|
-
/**
|
|
11
|
-
* Custom component renderers (can be overridden per TreegeRenderer instance)
|
|
12
|
-
*/
|
|
13
|
-
components?: TreegeRendererComponents;
|
|
14
|
-
/**
|
|
15
|
-
* Google Maps API key for address autocomplete
|
|
16
|
-
* If not provided, falls back to free Nominatim (OpenStreetMap)
|
|
17
|
-
*/
|
|
18
|
-
googleApiKey?: string;
|
|
19
|
-
/**
|
|
20
|
-
* Default language for translations
|
|
21
|
-
* @default "en"
|
|
22
|
-
*/
|
|
23
|
-
language?: string;
|
|
24
|
-
/**
|
|
25
|
-
* Default theme for all renderers
|
|
26
|
-
* @default "dark"
|
|
27
|
-
*/
|
|
28
|
-
theme?: "dark" | "light";
|
|
29
|
-
/**
|
|
30
|
-
* Default validation mode
|
|
31
|
-
* @default "onSubmit"
|
|
32
|
-
*/
|
|
33
|
-
validationMode?: "onChange" | "onSubmit";
|
|
34
10
|
};
|
|
35
11
|
/**
|
|
36
12
|
* Provider for global Treege configuration
|
|
37
13
|
* Wrap your app with this provider to set default options for all TreegeRenderer instances
|
|
38
14
|
*/
|
|
39
|
-
export declare const TreegeConfigProvider: ({ children,
|
|
15
|
+
export declare const TreegeConfigProvider: ({ children, ...config }: TreegeConfigProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,28 +1,125 @@
|
|
|
1
1
|
import { Node } from '@xyflow/react';
|
|
2
2
|
import { PropsWithChildren } from 'react';
|
|
3
3
|
import { FormValues } from '../types/renderer';
|
|
4
|
-
import { Flow, InputNodeData } from '../../shared/types/node';
|
|
4
|
+
import { Flow, HttpHeader, InputNodeData } from '../../shared/types/node';
|
|
5
5
|
export interface TreegeRendererContextValue {
|
|
6
|
+
/**
|
|
7
|
+
* The flow currently being rendered (already merged when several flows
|
|
8
|
+
* are linked through `FlowNode`s). `null` when the renderer has no flow
|
|
9
|
+
* to display yet.
|
|
10
|
+
*/
|
|
6
11
|
flows?: Flow | null;
|
|
12
|
+
/**
|
|
13
|
+
* Validation errors keyed by field id (`node.id`). Empty when the form
|
|
14
|
+
* is valid. Renderers read their own entry to display field-level errors.
|
|
15
|
+
*/
|
|
7
16
|
formErrors: Record<string, string>;
|
|
17
|
+
/**
|
|
18
|
+
* Current form values keyed by field id (`node.id`). Read by inputs to
|
|
19
|
+
* resolve template variables (`{{fieldId}}` in URLs/headers/body) and to
|
|
20
|
+
* drive conditional visibility from `useRenderNode`.
|
|
21
|
+
*/
|
|
8
22
|
formValues: FormValues;
|
|
23
|
+
/**
|
|
24
|
+
* Google Maps Places API key for the address autocomplete input. When
|
|
25
|
+
* unset, the address input falls back to the free Nominatim provider.
|
|
26
|
+
*/
|
|
9
27
|
googleApiKey?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Global HTTP headers (already merged from provider + props) to apply
|
|
30
|
+
* to every request issued by inputs. Field-level headers override these
|
|
31
|
+
* on key collision (case-insensitive).
|
|
32
|
+
*/
|
|
33
|
+
headers?: HttpHeader[];
|
|
34
|
+
/**
|
|
35
|
+
* The flow's input nodes — exposed so renderers can resolve references
|
|
36
|
+
* between fields (e.g. `convertFormValuesToNamedFormat`, reference-field
|
|
37
|
+
* defaults).
|
|
38
|
+
*/
|
|
10
39
|
inputNodes: Node<InputNodeData>[];
|
|
40
|
+
/**
|
|
41
|
+
* Active UI language (e.g. `"en"`, `"fr"`). Used both for static UI
|
|
42
|
+
* strings (via `useTranslate`) and for resolving `Translatable` values
|
|
43
|
+
* inside node data.
|
|
44
|
+
*/
|
|
11
45
|
language: string;
|
|
46
|
+
/**
|
|
47
|
+
* Soft cap on the number of options rendered for option-based inputs
|
|
48
|
+
* (radio, checkbox). When set, options past this count are replaced by
|
|
49
|
+
* an ellipsis row. Used by the editor's `NodeInputPreview` to keep node
|
|
50
|
+
* cards compact when an OpenAPI source returns hundreds of options.
|
|
51
|
+
* Unset at runtime — every option is rendered.
|
|
52
|
+
*/
|
|
53
|
+
optionsDisplayLimit?: number;
|
|
54
|
+
/**
|
|
55
|
+
* Update the value of a single field. Inputs call this from their
|
|
56
|
+
* `onChange` to push edits up to the form's state.
|
|
57
|
+
*/
|
|
12
58
|
setFieldValue: (fieldName: string, value: unknown) => void;
|
|
13
59
|
}
|
|
14
60
|
export interface TreegeRendererProviderProps extends PropsWithChildren {
|
|
15
|
-
|
|
61
|
+
/**
|
|
62
|
+
* Any subset of `TreegeRendererContextValue`. Missing fields default to
|
|
63
|
+
* sensible no-op values, so callers only need to supply what they actually
|
|
64
|
+
* want to expose to descendants.
|
|
65
|
+
*/
|
|
66
|
+
value: Partial<TreegeRendererContextValue>;
|
|
16
67
|
}
|
|
17
68
|
export declare const TreegeRendererContext: import('react').Context<TreegeRendererContextValue | null>;
|
|
18
69
|
export declare const TreegeRendererProvider: ({ children, value }: TreegeRendererProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
19
70
|
export declare const useTreegeRendererContext: () => {
|
|
20
71
|
edges: import('@xyflow/react').Edge[];
|
|
72
|
+
/**
|
|
73
|
+
* The flow currently being rendered (already merged when several flows
|
|
74
|
+
* are linked through `FlowNode`s). `null` when the renderer has no flow
|
|
75
|
+
* to display yet.
|
|
76
|
+
*/
|
|
21
77
|
flows?: Flow | null;
|
|
78
|
+
/**
|
|
79
|
+
* Validation errors keyed by field id (`node.id`). Empty when the form
|
|
80
|
+
* is valid. Renderers read their own entry to display field-level errors.
|
|
81
|
+
*/
|
|
22
82
|
formErrors: Record<string, string>;
|
|
83
|
+
/**
|
|
84
|
+
* Current form values keyed by field id (`node.id`). Read by inputs to
|
|
85
|
+
* resolve template variables (`{{fieldId}}` in URLs/headers/body) and to
|
|
86
|
+
* drive conditional visibility from `useRenderNode`.
|
|
87
|
+
*/
|
|
23
88
|
formValues: FormValues;
|
|
89
|
+
/**
|
|
90
|
+
* Google Maps Places API key for the address autocomplete input. When
|
|
91
|
+
* unset, the address input falls back to the free Nominatim provider.
|
|
92
|
+
*/
|
|
24
93
|
googleApiKey?: string;
|
|
94
|
+
/**
|
|
95
|
+
* Global HTTP headers (already merged from provider + props) to apply
|
|
96
|
+
* to every request issued by inputs. Field-level headers override these
|
|
97
|
+
* on key collision (case-insensitive).
|
|
98
|
+
*/
|
|
99
|
+
headers?: HttpHeader[];
|
|
100
|
+
/**
|
|
101
|
+
* The flow's input nodes — exposed so renderers can resolve references
|
|
102
|
+
* between fields (e.g. `convertFormValuesToNamedFormat`, reference-field
|
|
103
|
+
* defaults).
|
|
104
|
+
*/
|
|
25
105
|
inputNodes: Node<InputNodeData>[];
|
|
106
|
+
/**
|
|
107
|
+
* Active UI language (e.g. `"en"`, `"fr"`). Used both for static UI
|
|
108
|
+
* strings (via `useTranslate`) and for resolving `Translatable` values
|
|
109
|
+
* inside node data.
|
|
110
|
+
*/
|
|
26
111
|
language: string;
|
|
112
|
+
/**
|
|
113
|
+
* Soft cap on the number of options rendered for option-based inputs
|
|
114
|
+
* (radio, checkbox). When set, options past this count are replaced by
|
|
115
|
+
* an ellipsis row. Used by the editor's `NodeInputPreview` to keep node
|
|
116
|
+
* cards compact when an OpenAPI source returns hundreds of options.
|
|
117
|
+
* Unset at runtime — every option is rendered.
|
|
118
|
+
*/
|
|
119
|
+
optionsDisplayLimit?: number;
|
|
120
|
+
/**
|
|
121
|
+
* Update the value of a single field. Inputs call this from their
|
|
122
|
+
* `onChange` to push edits up to the form's state.
|
|
123
|
+
*/
|
|
27
124
|
setFieldValue: (fieldName: string, value: unknown) => void;
|
|
28
125
|
};
|
|
@@ -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
|
+
declare const DefaultInputWrapper: ({ node, children }: DefaultInputWrapperProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export default DefaultInputWrapper;
|
|
@@ -19,14 +19,14 @@ import { TreegeNodeData } from '../../../shared/types/node';
|
|
|
19
19
|
* @param props - Configuration props (flows, initialValues, callbacks, etc.)
|
|
20
20
|
* @returns Complete form state and control methods
|
|
21
21
|
*/
|
|
22
|
-
export declare const useTreegeRenderer: ({ components, flows, googleApiKey, initialValues, language, onChange, onSubmit, theme, validate, validationMode, }: Pick<TreegeRendererProps, "components" | "flows" | "googleApiKey" | "initialValues" | "language" | "onChange" | "onSubmit" | "theme" | "validate" | "validationMode">) => {
|
|
22
|
+
export declare const useTreegeRenderer: ({ components, flows, googleApiKey, headers, initialValues, language, onChange, onSubmit, theme, validate, validationMode, }: Pick<TreegeRendererProps, "components" | "flows" | "googleApiKey" | "headers" | "initialValues" | "language" | "onChange" | "onSubmit" | "theme" | "validate" | "validationMode">) => {
|
|
23
23
|
canSubmit: boolean;
|
|
24
24
|
clearSubmitMessage: () => void;
|
|
25
25
|
config: {
|
|
26
26
|
components: {
|
|
27
27
|
form: ((props: {
|
|
28
28
|
children: import('react').ReactNode;
|
|
29
|
-
onSubmit: (e: import('react').FormEvent) => void;
|
|
29
|
+
onSubmit: (e: import('react').FormEvent<HTMLFormElement>) => void;
|
|
30
30
|
}) => import('react').ReactNode) | undefined;
|
|
31
31
|
group: ((props: import('../../types/renderer').NodeRenderProps & {
|
|
32
32
|
children?: import('react').ReactNode;
|
|
@@ -72,6 +72,7 @@ export declare const useTreegeRenderer: ({ components, flows, googleApiKey, init
|
|
|
72
72
|
};
|
|
73
73
|
};
|
|
74
74
|
googleApiKey: string | undefined;
|
|
75
|
+
headers: import('../../../shared/types/node').HttpHeader[];
|
|
75
76
|
language: string;
|
|
76
77
|
theme: "dark" | "light";
|
|
77
78
|
validationMode: "onChange" | "onSubmit";
|
|
@@ -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
|
*
|