treege 3.0.0-beta.17 → 3.0.0-beta.18
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/dist/ThemeContext-zQO8nZ9d.js +745 -0
- package/dist/TreegeEditor-DXhj6fWi.js +3300 -0
- package/dist/TreegeRenderer-CjLeK7_j.js +1740 -0
- package/dist/editor/components/input/ComboboxWithCreate.d.ts +2 -1
- package/dist/editor/constants/edgeTypes.d.ts +2 -1
- package/dist/editor/constants/nodeTypes.d.ts +4 -4
- 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/layout/NodeWrapper.d.ts +2 -1
- package/dist/editor/hooks/useFlowActions.d.ts +1 -0
- package/dist/editor.js +2 -2
- package/dist/main.js +34 -32
- package/dist/renderer/context/TreegeRendererContext.d.ts +4 -1
- package/dist/renderer/features/TreegeRenderer/useTreegeRenderer.d.ts +2 -0
- package/dist/renderer/features/TreegeRenderer/web/components/DefaultSubmitButton.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultSubmitInput.d.ts +3 -0
- package/dist/renderer/hooks/useSubmitHandler.d.ts +34 -0
- package/dist/renderer/types/renderer.d.ts +16 -2
- package/dist/renderer/utils/form.d.ts +19 -0
- package/dist/renderer/utils/http.d.ts +101 -0
- package/dist/renderer/utils/submit.d.ts +47 -0
- package/dist/renderer.js +30 -28
- 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/select.d.ts +3 -1
- package/dist/shared/constants/inputType.d.ts +1 -0
- package/dist/shared/locales/ar.json.d.ts +48 -3
- package/dist/shared/locales/de.json.d.ts +48 -3
- package/dist/shared/locales/en.json.d.ts +49 -4
- package/dist/shared/locales/es.json.d.ts +48 -3
- package/dist/shared/locales/fr.json.d.ts +48 -3
- package/dist/shared/locales/it.json.d.ts +48 -3
- package/dist/shared/locales/pt.json.d.ts +48 -3
- package/dist/shared/types/node.d.ts +47 -0
- package/package.json +4 -3
- package/dist/ThemeContext-yjxO4Gx1.js +0 -765
- package/dist/TreegeEditor-CxbNMj0Q.js +0 -2735
- package/dist/TreegeRenderer-oCVaktHX.js +0 -1441
|
@@ -5,7 +5,8 @@ export type ComboboxOption = {
|
|
|
5
5
|
/**
|
|
6
6
|
* Reusable Combobox component with search, create, and clear functionality
|
|
7
7
|
*/
|
|
8
|
-
declare const ComboboxWithCreate: ({ options, value, onValueChange, placeholder, searchPlaceholder, createLabel, clearLabel, emptyLabel, className, allowClear, allowCreate, }: {
|
|
8
|
+
declare const ComboboxWithCreate: ({ options, id, value, onValueChange, placeholder, searchPlaceholder, createLabel, clearLabel, emptyLabel, className, allowClear, allowCreate, }: {
|
|
9
|
+
id?: string;
|
|
9
10
|
options: ComboboxOption[];
|
|
10
11
|
value?: string | null;
|
|
11
12
|
onValueChange?: (newValue: string) => void;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export declare const EDGE_TYPES: {
|
|
2
|
-
conditional: ({ id, target, sourceX, sourceY, targetX, targetY, sourcePosition, targetPosition, markerEnd, style, data, }: import('../features/TreegeEditor/edges/ConditionalEdge').ConditionalEdgeProps) => import("react/jsx-runtime").JSX.Element
|
|
2
|
+
conditional: import('react').MemoExoticComponent<({ id, target, sourceX, sourceY, targetX, targetY, sourcePosition, targetPosition, markerEnd, style, data, }: import('../features/TreegeEditor/edges/ConditionalEdge').ConditionalEdgeProps) => import("react/jsx-runtime").JSX.Element>;
|
|
3
|
+
default: import('react').MemoExoticComponent<({ id, sourceX, sourceY, targetX, targetY, sourcePosition, targetPosition, style, markerEnd, selected }: import('@xyflow/react').EdgeProps) => import("react/jsx-runtime").JSX.Element>;
|
|
3
4
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const NODE_TYPES: {
|
|
2
|
-
flow: ({ data, isConnectable, type, parentId, id }: import('../features/TreegeEditor/nodes/FlowNode').FlowNodeProps) => import("react/jsx-runtime").JSX.Element
|
|
3
|
-
group: ({ data }: import('../features/TreegeEditor/nodes/GroupNode').GroupNodeProps) => import("react/jsx-runtime").JSX.Element
|
|
4
|
-
input: ({ data, isConnectable,
|
|
5
|
-
ui: ({ data, isConnectable, type, parentId, id }: import('../features/TreegeEditor/nodes/UINode').UINodeProps) => import("react/jsx-runtime").JSX.Element
|
|
2
|
+
flow: import('react').MemoExoticComponent<({ data, isConnectable, type, parentId, id }: import('../features/TreegeEditor/nodes/FlowNode').FlowNodeProps) => import("react/jsx-runtime").JSX.Element>;
|
|
3
|
+
group: import('react').MemoExoticComponent<({ data }: import('../features/TreegeEditor/nodes/GroupNode').GroupNodeProps) => import("react/jsx-runtime").JSX.Element>;
|
|
4
|
+
input: import('react').MemoExoticComponent<({ data, isConnectable, parentId, id }: import('../features/TreegeEditor/nodes/InputNode').InputNodeProps) => import("react/jsx-runtime").JSX.Element>;
|
|
5
|
+
ui: import('react').MemoExoticComponent<({ data, isConnectable, type, parentId, id }: import('../features/TreegeEditor/nodes/UINode').UINodeProps) => import("react/jsx-runtime").JSX.Element>;
|
|
6
6
|
};
|
|
@@ -2,5 +2,5 @@ import { Edge, EdgeProps } from '@xyflow/react';
|
|
|
2
2
|
import { ConditionalEdgeData } from '../../../../shared/types/edge';
|
|
3
3
|
export type ConditionalEdgeType = Edge<ConditionalEdgeData, "conditional">;
|
|
4
4
|
export type ConditionalEdgeProps = EdgeProps<ConditionalEdgeType>;
|
|
5
|
-
declare const
|
|
6
|
-
export default
|
|
5
|
+
declare const _default: import('react').MemoExoticComponent<({ id, target, sourceX, sourceY, targetX, targetY, sourcePosition, targetPosition, markerEnd, style, data, }: ConditionalEdgeProps) => import("react/jsx-runtime").JSX.Element>;
|
|
6
|
+
export default _default;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { EdgeProps } from '@xyflow/react';
|
|
2
|
+
declare const _default: import('react').MemoExoticComponent<({ id, sourceX, sourceY, targetX, targetY, sourcePosition, targetPosition, style, markerEnd, selected }: EdgeProps) => import("react/jsx-runtime").JSX.Element>;
|
|
3
|
+
export default _default;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { SubmitConfig } from '../../../../shared/types/node';
|
|
2
|
+
interface SubmitConfigFormProps {
|
|
3
|
+
value: SubmitConfig | undefined;
|
|
4
|
+
onChange: (config: SubmitConfig | undefined) => void;
|
|
5
|
+
}
|
|
6
|
+
declare const SubmitConfigForm: ({ value, onChange }: SubmitConfigFormProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export default SubmitConfigForm;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
interface ComboboxPatternProps {
|
|
2
2
|
value?: string | null;
|
|
3
3
|
onValueChange?: (newValue: string) => void;
|
|
4
|
+
id?: string;
|
|
4
5
|
}
|
|
5
|
-
declare const ComboboxPattern: ({ value, onValueChange }: ComboboxPatternProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
declare const ComboboxPattern: ({ id, value, onValueChange }: ComboboxPatternProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
7
|
export default ComboboxPattern;
|
|
@@ -2,5 +2,5 @@ import { Node, NodeProps } from '@xyflow/react';
|
|
|
2
2
|
import { FlowNodeData } from '../../../../shared/types/node';
|
|
3
3
|
export type FlowNodeType = Node<FlowNodeData, "flow">;
|
|
4
4
|
export type FlowNodeProps = NodeProps<FlowNodeType>;
|
|
5
|
-
declare const
|
|
6
|
-
export default
|
|
5
|
+
declare const _default: import('react').MemoExoticComponent<({ data, isConnectable, type, parentId, id }: FlowNodeProps) => import("react/jsx-runtime").JSX.Element>;
|
|
6
|
+
export default _default;
|
|
@@ -2,5 +2,5 @@ import { Node, NodeProps } from '@xyflow/react';
|
|
|
2
2
|
import { GroupNodeData } from '../../../../shared/types/node';
|
|
3
3
|
export type GroupNodeType = Node<GroupNodeData, "group">;
|
|
4
4
|
export type GroupNodeProps = NodeProps<GroupNodeType>;
|
|
5
|
-
declare const
|
|
6
|
-
export default
|
|
5
|
+
declare const _default: import('react').MemoExoticComponent<({ data }: GroupNodeProps) => import("react/jsx-runtime").JSX.Element>;
|
|
6
|
+
export default _default;
|
|
@@ -2,5 +2,5 @@ import { Node, NodeProps } from '@xyflow/react';
|
|
|
2
2
|
import { InputNodeData } from '../../../../shared/types/node';
|
|
3
3
|
export type InputNodeType = Node<InputNodeData, "input">;
|
|
4
4
|
export type InputNodeProps = NodeProps<InputNodeType>;
|
|
5
|
-
declare const
|
|
6
|
-
export default
|
|
5
|
+
declare const _default: import('react').MemoExoticComponent<({ data, isConnectable, parentId, id }: InputNodeProps) => import("react/jsx-runtime").JSX.Element>;
|
|
6
|
+
export default _default;
|
|
@@ -2,5 +2,5 @@ import { Node, NodeProps } from '@xyflow/react';
|
|
|
2
2
|
import { UINodeData } from '../../../../shared/types/node';
|
|
3
3
|
export type UINodeType = Node<UINodeData, "ui">;
|
|
4
4
|
export type UINodeProps = NodeProps<UINodeType>;
|
|
5
|
-
declare const
|
|
6
|
-
export default
|
|
5
|
+
declare const _default: import('react').MemoExoticComponent<({ data, isConnectable, type, parentId, id }: UINodeProps) => import("react/jsx-runtime").JSX.Element>;
|
|
6
|
+
export default _default;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { PropsWithChildren } from 'react';
|
|
2
2
|
interface NodeWrapperProps extends PropsWithChildren {
|
|
3
3
|
inGroup: boolean;
|
|
4
|
+
isSubmit?: boolean;
|
|
4
5
|
}
|
|
5
|
-
declare const NodeWrapper: ({ children, inGroup }: NodeWrapperProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
declare const NodeWrapper: ({ children, inGroup, isSubmit }: NodeWrapperProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
7
|
export default NodeWrapper;
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
declare const useFlowActions: () => {
|
|
6
6
|
clearSelection: () => void;
|
|
7
|
+
deleteSelectedNode: () => void;
|
|
7
8
|
updateNodeData: <T extends Record<string, unknown>>(id: string, data: Partial<T>) => void;
|
|
8
9
|
updateNodeType: (id: string, type: string) => void;
|
|
9
10
|
updateSelectedNodeData: <T extends Record<string, unknown>>(data: Partial<T>) => void;
|
package/dist/editor.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { T as o } from "./TreegeEditor-
|
|
2
|
-
import { T as m, u as s } from "./ThemeContext-
|
|
1
|
+
import { T as o } from "./TreegeEditor-DXhj6fWi.js";
|
|
2
|
+
import { T as m, u as s } from "./ThemeContext-zQO8nZ9d.js";
|
|
3
3
|
export {
|
|
4
4
|
m as ThemeProvider,
|
|
5
5
|
o as TreegeEditor,
|
package/dist/main.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { T as t } from "./TreegeEditor-
|
|
2
|
-
import { T as u, d as l, g as r, b as o, c as i, i as n, a as d, u as f } from "./ThemeContext-
|
|
3
|
-
import { c as
|
|
1
|
+
import { T as t } from "./TreegeEditor-DXhj6fWi.js";
|
|
2
|
+
import { T as u, d as l, g as r, b as o, c as i, i as n, a as d, u as f } from "./ThemeContext-zQO8nZ9d.js";
|
|
3
|
+
import { c as T, d as D, e as I, f as m, g, h as c, D as F, i as R, j as x, k as N, l as S, m as b, n as v, o as h, p as w, q as C, r as z, s as A, v as H, w as k, T as y, b as E, L as G, M as P, J as U, K as V, t as j, x as q, y as B, z as J, A as K, C as L, F as M, G as O, I as Q, E as W, H as X, B as Y, u as Z, a as _ } from "./TreegeRenderer-CjLeK7_j.js";
|
|
4
4
|
export {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
T as DefaultAddressInput,
|
|
6
|
+
D as DefaultAutocompleteInput,
|
|
7
|
+
I as DefaultCheckboxInput,
|
|
8
8
|
m as DefaultDateInput,
|
|
9
9
|
g as DefaultDateRangeInput,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
c as DefaultFileInput,
|
|
11
|
+
F as DefaultGroup,
|
|
12
|
+
R as DefaultHiddenInput,
|
|
13
|
+
x as DefaultHttpInput,
|
|
14
|
+
N as DefaultNumberInput,
|
|
15
|
+
S as DefaultPasswordInput,
|
|
16
|
+
b as DefaultRadioInput,
|
|
17
|
+
v as DefaultSelectInput,
|
|
18
18
|
h as DefaultSwitchInput,
|
|
19
19
|
w as DefaultTextAreaInput,
|
|
20
20
|
C as DefaultTextInput,
|
|
@@ -23,30 +23,32 @@ export {
|
|
|
23
23
|
H as Divider,
|
|
24
24
|
u as ThemeProvider,
|
|
25
25
|
k as Title,
|
|
26
|
-
|
|
26
|
+
y as TreegeConfigProvider,
|
|
27
27
|
t as TreegeEditor,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
U as
|
|
32
|
-
V as
|
|
33
|
-
j as
|
|
34
|
-
q as
|
|
35
|
-
B as
|
|
36
|
-
J as
|
|
37
|
-
K as
|
|
38
|
-
L as
|
|
28
|
+
E as TreegeRenderer,
|
|
29
|
+
G as applyReferenceTransformation,
|
|
30
|
+
P as calculateReferenceFieldUpdates,
|
|
31
|
+
U as checkFormFieldHasValue,
|
|
32
|
+
V as convertFormValuesToNamedFormat,
|
|
33
|
+
j as defaultInputRenderers,
|
|
34
|
+
q as defaultUI,
|
|
35
|
+
B as evaluateCondition,
|
|
36
|
+
J as evaluateConditions,
|
|
37
|
+
K as fileToSerializable,
|
|
38
|
+
L as filesToSerializable,
|
|
39
|
+
M as findStartNode,
|
|
40
|
+
O as getFlowRenderState,
|
|
39
41
|
l as getStaticTranslations,
|
|
40
42
|
r as getTranslatedText,
|
|
41
|
-
|
|
43
|
+
Q as isFieldEmpty,
|
|
42
44
|
o as isFlowNode,
|
|
43
45
|
i as isGroupNode,
|
|
44
46
|
n as isInputNode,
|
|
45
|
-
|
|
47
|
+
W as isStartNode,
|
|
46
48
|
d as isUINode,
|
|
47
|
-
|
|
48
|
-
|
|
49
|
+
X as mergeFlows,
|
|
50
|
+
Y as serializableToFile,
|
|
49
51
|
f as useTheme,
|
|
50
|
-
|
|
51
|
-
|
|
52
|
+
Z as useTreegeConfig,
|
|
53
|
+
_ as useTreegeRenderer
|
|
52
54
|
};
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
import { Node } from '@xyflow/react';
|
|
1
2
|
import { PropsWithChildren } from 'react';
|
|
2
3
|
import { FormValues } from '../types/renderer';
|
|
3
|
-
import { Flow } from '../../shared/types/node';
|
|
4
|
+
import { Flow, InputNodeData } from '../../shared/types/node';
|
|
4
5
|
export interface TreegeRendererContextValue {
|
|
5
6
|
flows?: Flow | null;
|
|
6
7
|
formErrors: Record<string, string>;
|
|
7
8
|
formValues: FormValues;
|
|
8
9
|
googleApiKey?: string;
|
|
10
|
+
inputNodes: Node<InputNodeData>[];
|
|
9
11
|
language: string;
|
|
10
12
|
setFieldValue: (fieldName: string, value: unknown) => void;
|
|
11
13
|
}
|
|
@@ -20,6 +22,7 @@ export declare const useTreegeRendererContext: () => {
|
|
|
20
22
|
formErrors: Record<string, string>;
|
|
21
23
|
formValues: FormValues;
|
|
22
24
|
googleApiKey?: string;
|
|
25
|
+
inputNodes: Node<InputNodeData>[];
|
|
23
26
|
language: string;
|
|
24
27
|
setFieldValue: (fieldName: string, value: unknown) => void;
|
|
25
28
|
};
|
|
@@ -35,8 +35,10 @@ export declare const useTreegeRenderer: (flows: Flow | Flow[] | null | undefined
|
|
|
35
35
|
inputNodes: Node<import('../../../shared/types/node').InputNodeData>[];
|
|
36
36
|
mergedFlow: Flow;
|
|
37
37
|
missingRequiredFields: string[];
|
|
38
|
+
prevFormValuesRef: import('react').RefObject<FormValues>;
|
|
38
39
|
setFieldValue: (fieldName: string, value: unknown) => void;
|
|
39
40
|
setFormErrors: import('react').Dispatch<import('react').SetStateAction<Record<string, string>>>;
|
|
41
|
+
setMultipleFieldValues: (updates: FormValues) => void;
|
|
40
42
|
t: (key?: import('../../../main').Translatable | import('../../../main').TranslationKey | string) => string;
|
|
41
43
|
validateForm: (customValidate?: (values: FormValues, visibleNodesList: Node<TreegeNodeData>[]) => Record<string, string>) => {
|
|
42
44
|
errors: {
|
|
@@ -5,5 +5,5 @@ export interface SubmitButtonProps extends ButtonHTMLAttributes<HTMLButtonElemen
|
|
|
5
5
|
/**
|
|
6
6
|
* Default submit button
|
|
7
7
|
*/
|
|
8
|
-
declare const DefaultSubmitButton: (
|
|
8
|
+
declare const DefaultSubmitButton: import('react').ForwardRefExoticComponent<SubmitButtonProps & import('react').RefAttributes<HTMLButtonElement>>;
|
|
9
9
|
export default DefaultSubmitButton;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Node } from '@xyflow/react';
|
|
2
|
+
import { FormValues } from '../types/renderer';
|
|
3
|
+
import { SubmitResult } from '../utils/submit';
|
|
4
|
+
import { InputNodeData, TreegeNodeData } from '../../shared/types/node';
|
|
5
|
+
/**
|
|
6
|
+
* Hook for handling form submission with submit button configuration
|
|
7
|
+
*
|
|
8
|
+
* This hook provides:
|
|
9
|
+
* - Submit button node detection
|
|
10
|
+
* - HTTP submission handling
|
|
11
|
+
* - Loading state management
|
|
12
|
+
* - Success/error message handling
|
|
13
|
+
* - Redirect handling
|
|
14
|
+
*
|
|
15
|
+
* @param visibleNodes - Currently visible nodes in the form
|
|
16
|
+
* @param formValues - Current form values
|
|
17
|
+
* @param language - Current language for translations
|
|
18
|
+
* @param inputNodes - All input nodes for form data conversion
|
|
19
|
+
* @returns Submit handler state and functions
|
|
20
|
+
*/
|
|
21
|
+
export declare const useSubmitHandler: (visibleNodes: Node<TreegeNodeData>[], formValues: FormValues, language: string, inputNodes: Node<InputNodeData>[]) => {
|
|
22
|
+
clearSubmitMessage: () => void;
|
|
23
|
+
handleSubmitWithConfig: (onSuccess?: (data: unknown) => void) => Promise<SubmitResult | null>;
|
|
24
|
+
hasSubmitConfig: boolean;
|
|
25
|
+
isSubmitting: boolean;
|
|
26
|
+
submitButtonNode: {
|
|
27
|
+
id: string;
|
|
28
|
+
data: InputNodeData;
|
|
29
|
+
} | null;
|
|
30
|
+
submitMessage: {
|
|
31
|
+
type: "success" | "error";
|
|
32
|
+
message: string;
|
|
33
|
+
} | null;
|
|
34
|
+
};
|
|
@@ -18,6 +18,7 @@ export type InputValueTypeMap = {
|
|
|
18
18
|
password: string;
|
|
19
19
|
radio: string;
|
|
20
20
|
select: string | string[];
|
|
21
|
+
submit: undefined;
|
|
21
22
|
switch: boolean;
|
|
22
23
|
text: string;
|
|
23
24
|
textarea: string;
|
|
@@ -28,10 +29,13 @@ export type InputValueTypeMap = {
|
|
|
28
29
|
* Form values stored during rendering
|
|
29
30
|
*/
|
|
30
31
|
export type FormValues = Record<string, any>;
|
|
32
|
+
export type Meta = {
|
|
33
|
+
httpResponse?: unknown;
|
|
34
|
+
};
|
|
31
35
|
/**
|
|
32
36
|
* Union of all possible input value types
|
|
33
37
|
*/
|
|
34
|
-
export type InputValue = string | number | boolean | string[] | SerializableFile | SerializableFile[] | [string, string] | [string | undefined, string | undefined] | null;
|
|
38
|
+
export type InputValue = string | number | boolean | string[] | SerializableFile | SerializableFile[] | [string, string] | [string | undefined, string | undefined] | null | undefined;
|
|
35
39
|
/**
|
|
36
40
|
* Props for input components with dynamic value typing
|
|
37
41
|
* All form state is provided via props for easier custom component implementation
|
|
@@ -75,6 +79,14 @@ export type InputRenderProps<T extends InputType = InputType> = {
|
|
|
75
79
|
* Translated helper text (already processed with current language)
|
|
76
80
|
*/
|
|
77
81
|
helperText?: string;
|
|
82
|
+
/**
|
|
83
|
+
* Missing required fields on form submit (for submit inputs)
|
|
84
|
+
*/
|
|
85
|
+
missingRequiredFields?: string[];
|
|
86
|
+
/**
|
|
87
|
+
* Whether the form is currently being submitted (for submit inputs)
|
|
88
|
+
*/
|
|
89
|
+
isSubmitting?: boolean;
|
|
78
90
|
};
|
|
79
91
|
export type UiRenderProps = {
|
|
80
92
|
node: Node<UINodeData>;
|
|
@@ -193,8 +205,10 @@ export type TreegeRendererProps = {
|
|
|
193
205
|
onChange?: (values: FormValues) => void;
|
|
194
206
|
/**
|
|
195
207
|
* Callback when form is submitted
|
|
208
|
+
* @param values - Form values (keyed by field name or node ID)
|
|
209
|
+
* @param meta - Optional metadata about the submission (e.g., HTTP response data)
|
|
196
210
|
*/
|
|
197
|
-
onSubmit?: (values: FormValues) => void;
|
|
211
|
+
onSubmit?: (values: FormValues, meta?: Meta) => void;
|
|
198
212
|
/**
|
|
199
213
|
* Theme for the renderer
|
|
200
214
|
* @default "dark"
|
|
@@ -25,3 +25,22 @@ export declare const checkFormFieldHasValue: (fieldName: string | undefined, for
|
|
|
25
25
|
* returns { firstName: 'Alice', 'Last Name': 'Bob' }
|
|
26
26
|
*/
|
|
27
27
|
export declare const convertFormValuesToNamedFormat: (formValues: FormValues, nodes: Node<InputNodeData>[]) => Record<string, unknown>;
|
|
28
|
+
/**
|
|
29
|
+
* Apply transformation to a reference field value
|
|
30
|
+
* @param value - The source value to transform
|
|
31
|
+
* @param transformFunction - The transformation function to apply
|
|
32
|
+
* @param objectMapping - Optional mapping for toObject transformation
|
|
33
|
+
* @returns The transformed value
|
|
34
|
+
*/
|
|
35
|
+
export declare const applyReferenceTransformation: (value: unknown, transformFunction: "toString" | "toNumber" | "toBoolean" | "toArray" | "toObject" | null | undefined, objectMapping?: Array<{
|
|
36
|
+
sourceKey: string;
|
|
37
|
+
targetKey: string;
|
|
38
|
+
}>) => unknown;
|
|
39
|
+
/**
|
|
40
|
+
* Calculate updated values for fields with reference defaults
|
|
41
|
+
* @param inputNodes - Array of input nodes
|
|
42
|
+
* @param formValues - Current form values
|
|
43
|
+
* @param prevFormValues - Previous form values (for change detection)
|
|
44
|
+
* @returns Object containing fields that need to be updated
|
|
45
|
+
*/
|
|
46
|
+
export declare const calculateReferenceFieldUpdates: (inputNodes: Node<InputNodeData>[], formValues: FormValues, prevFormValues: FormValues) => FormValues;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { FormValues } from '../types/renderer';
|
|
2
|
+
import { HttpHeader } from '../../shared/types/node';
|
|
3
|
+
/**
|
|
4
|
+
* Result of an HTTP request
|
|
5
|
+
*/
|
|
6
|
+
export interface HttpRequestResult {
|
|
7
|
+
/**
|
|
8
|
+
* Whether the request was successful (2xx status code)
|
|
9
|
+
*/
|
|
10
|
+
success: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Response data (parsed JSON or raw text)
|
|
13
|
+
*/
|
|
14
|
+
data?: unknown;
|
|
15
|
+
/**
|
|
16
|
+
* Error message if request failed
|
|
17
|
+
*/
|
|
18
|
+
error?: string;
|
|
19
|
+
/**
|
|
20
|
+
* HTTP status code
|
|
21
|
+
*/
|
|
22
|
+
status?: number;
|
|
23
|
+
/**
|
|
24
|
+
* HTTP status text
|
|
25
|
+
*/
|
|
26
|
+
statusText?: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Options for making an HTTP request
|
|
30
|
+
*/
|
|
31
|
+
export interface HttpRequestOptions {
|
|
32
|
+
/**
|
|
33
|
+
* The URL to call (should already have variables replaced)
|
|
34
|
+
*/
|
|
35
|
+
url: string;
|
|
36
|
+
/**
|
|
37
|
+
* HTTP method
|
|
38
|
+
*/
|
|
39
|
+
method?: "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
|
|
40
|
+
/**
|
|
41
|
+
* Request headers
|
|
42
|
+
*/
|
|
43
|
+
headers?: HttpHeader[];
|
|
44
|
+
/**
|
|
45
|
+
* Request body (for POST/PUT/PATCH)
|
|
46
|
+
*/
|
|
47
|
+
body?: string;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Make an HTTP request with common error handling and response parsing
|
|
51
|
+
*
|
|
52
|
+
* This is a shared utility used by both HTTP inputs and submit buttons
|
|
53
|
+
* to ensure consistent behavior across the library.
|
|
54
|
+
*
|
|
55
|
+
* @param options - Request options
|
|
56
|
+
* @returns Promise with request result
|
|
57
|
+
*/
|
|
58
|
+
export declare const makeHttpRequest: (options: HttpRequestOptions) => Promise<HttpRequestResult>;
|
|
59
|
+
/**
|
|
60
|
+
* Replace template variables in a string with actual values from form data
|
|
61
|
+
*
|
|
62
|
+
* Uses {{fieldId}} syntax for all replacements (URLs, JSON bodies, etc.)
|
|
63
|
+
*
|
|
64
|
+
* Smart JSON handling:
|
|
65
|
+
* - Strings: automatically wrapped in quotes and escaped
|
|
66
|
+
* - Numbers/Booleans: converted to JSON-safe format
|
|
67
|
+
* - Arrays/Objects: JSON.stringify
|
|
68
|
+
*
|
|
69
|
+
* @param template - The template string containing variables
|
|
70
|
+
* @param values - Form values to substitute
|
|
71
|
+
* @param options - Replacement options
|
|
72
|
+
* @param options.encode - Whether to URL-encode the replaced values (for URLs)
|
|
73
|
+
* @param options.json - Whether to use smart JSON handling (for request bodies)
|
|
74
|
+
* @returns The string with variables replaced
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* // For URLs (with encoding)
|
|
78
|
+
* replaceTemplateVariables("https://api.com/users/{{userId}}", { userId: "john doe" }, { encode: true })
|
|
79
|
+
* // => "https://api.com/users/john%20doe"
|
|
80
|
+
*
|
|
81
|
+
* // For JSON bodies (smart handling)
|
|
82
|
+
* replaceTemplateVariables('{"name": {{userName}}}', { userName: "John" }, { json: true })
|
|
83
|
+
* // => '{"name": "John"}'
|
|
84
|
+
*
|
|
85
|
+
* replaceTemplateVariables('{"age": {{userAge}}}', { userAge: 25 }, { json: true })
|
|
86
|
+
* // => '{"age": 25}'
|
|
87
|
+
*/
|
|
88
|
+
export declare const replaceTemplateVariables: (template: string | undefined, values: FormValues, options?: {
|
|
89
|
+
encode?: boolean;
|
|
90
|
+
json?: boolean;
|
|
91
|
+
}) => string;
|
|
92
|
+
/**
|
|
93
|
+
* Replace template variables in response data (for redirect URLs)
|
|
94
|
+
*
|
|
95
|
+
* Supports {{response.field}} format to access response data
|
|
96
|
+
*
|
|
97
|
+
* @param template - The template string containing variables
|
|
98
|
+
* @param responseData - Response data object
|
|
99
|
+
* @returns The string with variables replaced
|
|
100
|
+
*/
|
|
101
|
+
export declare const replaceResponseVariables: (template: string | undefined, responseData: unknown) => string;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Node } from '@xyflow/react';
|
|
2
|
+
import { FormValues } from '../types/renderer';
|
|
3
|
+
import { InputNodeData, SubmitConfig } from '../../shared/types/node';
|
|
4
|
+
/**
|
|
5
|
+
* Result of a form submission
|
|
6
|
+
*/
|
|
7
|
+
export interface SubmitResult {
|
|
8
|
+
/**
|
|
9
|
+
* Whether the submission was successful
|
|
10
|
+
*/
|
|
11
|
+
success: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Response data from the server
|
|
14
|
+
*/
|
|
15
|
+
data?: unknown;
|
|
16
|
+
/**
|
|
17
|
+
* Error message if submission failed
|
|
18
|
+
*/
|
|
19
|
+
error?: string;
|
|
20
|
+
/**
|
|
21
|
+
* URL to redirect to (if configured)
|
|
22
|
+
*/
|
|
23
|
+
redirectUrl?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Submit form data using the provided submit configuration
|
|
27
|
+
*
|
|
28
|
+
* This function handles:
|
|
29
|
+
* - Template variable replacement in URL, body, and headers
|
|
30
|
+
* - HTTP request to the configured endpoint
|
|
31
|
+
* - Response parsing
|
|
32
|
+
* - Redirect URL generation with response data
|
|
33
|
+
*
|
|
34
|
+
* @param config - Submit configuration from the submit button node
|
|
35
|
+
* @param formValues - Current form values
|
|
36
|
+
* @param inputNodes - All input nodes (required when sendFormData is true)
|
|
37
|
+
* @returns Promise with submission result
|
|
38
|
+
*/
|
|
39
|
+
export declare const submitFormData: (config: SubmitConfig, formValues: FormValues, inputNodes: Node<InputNodeData>[]) => Promise<SubmitResult>;
|
|
40
|
+
/**
|
|
41
|
+
* Perform redirect to the specified URL
|
|
42
|
+
*
|
|
43
|
+
* Handles both relative and absolute URLs
|
|
44
|
+
*
|
|
45
|
+
* @param url - The URL to redirect to
|
|
46
|
+
*/
|
|
47
|
+
export declare const redirect: (url: string) => void;
|
package/dist/renderer.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as t, d as s, e as u, f as l, g as r, h as n, D as i, i as o, j as f, k as
|
|
2
|
-
import { T as
|
|
1
|
+
import { c as t, d as s, e as u, f as l, g as r, h as n, D as i, i as o, j as f, k as p, l as d, m as D, n as I, o as T, p as m, q as g, r as c, s as F, v as R, w as v, T as x, b as S, L as b, M as h, J as C, K as w, t as z, x as A, y as H, z as N, A as k, C as y, F as P, G as E, I as G, E as U, H as V, B as j, u as q, a as B } from "./TreegeRenderer-CjLeK7_j.js";
|
|
2
|
+
import { T as K, g as L, u as M } from "./ThemeContext-zQO8nZ9d.js";
|
|
3
3
|
export {
|
|
4
4
|
t as DefaultAddressInput,
|
|
5
5
|
s as DefaultAutocompleteInput,
|
|
@@ -10,36 +10,38 @@ export {
|
|
|
10
10
|
i as DefaultGroup,
|
|
11
11
|
o as DefaultHiddenInput,
|
|
12
12
|
f as DefaultHttpInput,
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
p as DefaultNumberInput,
|
|
14
|
+
d as DefaultPasswordInput,
|
|
15
15
|
D as DefaultRadioInput,
|
|
16
16
|
I as DefaultSelectInput,
|
|
17
17
|
T as DefaultSwitchInput,
|
|
18
18
|
m as DefaultTextAreaInput,
|
|
19
19
|
g as DefaultTextInput,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
c as DefaultTimeInput,
|
|
21
|
+
F as DefaultTimeRangeInput,
|
|
22
|
+
R as Divider,
|
|
23
|
+
K as ThemeProvider,
|
|
24
|
+
v as Title,
|
|
25
|
+
x as TreegeConfigProvider,
|
|
26
26
|
S as TreegeRenderer,
|
|
27
|
-
b as
|
|
28
|
-
h as
|
|
29
|
-
C as
|
|
30
|
-
w as
|
|
31
|
-
z as
|
|
32
|
-
A as
|
|
33
|
-
H as
|
|
34
|
-
N as
|
|
35
|
-
k as
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
G as
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
j as
|
|
44
|
-
|
|
27
|
+
b as applyReferenceTransformation,
|
|
28
|
+
h as calculateReferenceFieldUpdates,
|
|
29
|
+
C as checkFormFieldHasValue,
|
|
30
|
+
w as convertFormValuesToNamedFormat,
|
|
31
|
+
z as defaultInputRenderers,
|
|
32
|
+
A as defaultUI,
|
|
33
|
+
H as evaluateCondition,
|
|
34
|
+
N as evaluateConditions,
|
|
35
|
+
k as fileToSerializable,
|
|
36
|
+
y as filesToSerializable,
|
|
37
|
+
P as findStartNode,
|
|
38
|
+
E as getFlowRenderState,
|
|
39
|
+
L as getTranslatedText,
|
|
40
|
+
G as isFieldEmpty,
|
|
41
|
+
U as isStartNode,
|
|
42
|
+
V as mergeFlows,
|
|
43
|
+
j as serializableToFile,
|
|
44
|
+
M as useTheme,
|
|
45
|
+
q as useTreegeConfig,
|
|
46
|
+
B as useTreegeRenderer
|
|
45
47
|
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
declare function AlertDialog({ ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Root>): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
declare function AlertDialogTrigger({ ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Trigger>): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
declare function AlertDialogPortal({ ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Portal>): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
declare function AlertDialogOverlay({ className, ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Overlay>): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
declare function AlertDialogContent({ className, ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Content>): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
declare function AlertDialogHeader({ className, ...props }: React.ComponentProps<"div">): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
declare function AlertDialogFooter({ className, ...props }: React.ComponentProps<"div">): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
declare function AlertDialogTitle({ className, ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Title>): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
declare function AlertDialogDescription({ className, ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Description>): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
declare function AlertDialogAction({ className, ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Action>): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
declare function AlertDialogCancel({ className, ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Cancel>): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export { AlertDialog, AlertDialogPortal, AlertDialogOverlay, AlertDialogTrigger, AlertDialogContent, AlertDialogHeader, AlertDialogFooter, AlertDialogTitle, AlertDialogDescription, AlertDialogAction, AlertDialogCancel, };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { VariantProps } from 'class-variance-authority';
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
declare const badgeVariants: (props?: ({
|
|
4
|
-
variant?: "default" | "destructive" | "outline" | "secondary" | "purple" | null | undefined;
|
|
4
|
+
variant?: "default" | "destructive" | "outline" | "secondary" | "blue" | "purple" | null | undefined;
|
|
5
5
|
} & import('class-variance-authority/dist/types').ClassProp) | undefined) => string;
|
|
6
6
|
declare function Badge({ className, variant, asChild, ...props }: React.ComponentProps<"span"> & VariantProps<typeof badgeVariants> & {
|
|
7
7
|
asChild?: boolean;
|