treege 3.0.0-beta.16 → 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.
Files changed (45) hide show
  1. package/dist/ThemeContext-zQO8nZ9d.js +745 -0
  2. package/dist/TreegeEditor-DXhj6fWi.js +3300 -0
  3. package/dist/TreegeRenderer-CjLeK7_j.js +1740 -0
  4. package/dist/editor/components/input/ComboboxWithCreate.d.ts +2 -1
  5. package/dist/editor/constants/edgeTypes.d.ts +2 -1
  6. package/dist/editor/constants/nodeTypes.d.ts +4 -4
  7. package/dist/editor/features/TreegeEditor/edges/ConditionalEdge.d.ts +2 -2
  8. package/dist/editor/features/TreegeEditor/edges/DefaultEdge.d.ts +3 -0
  9. package/dist/editor/features/TreegeEditor/forms/SubmitConfigForm.d.ts +7 -0
  10. package/dist/editor/features/TreegeEditor/inputs/ComboboxPattern.d.ts +2 -1
  11. package/dist/editor/features/TreegeEditor/nodes/FlowNode.d.ts +2 -2
  12. package/dist/editor/features/TreegeEditor/nodes/GroupNode.d.ts +2 -2
  13. package/dist/editor/features/TreegeEditor/nodes/InputNode.d.ts +2 -2
  14. package/dist/editor/features/TreegeEditor/nodes/UINode.d.ts +2 -2
  15. package/dist/editor/features/TreegeEditor/nodes/layout/NodeWrapper.d.ts +2 -1
  16. package/dist/editor/hooks/useFlowActions.d.ts +1 -0
  17. package/dist/editor.js +2 -2
  18. package/dist/main.js +34 -32
  19. package/dist/renderer/context/TreegeRendererContext.d.ts +4 -1
  20. package/dist/renderer/features/TreegeRenderer/useTreegeRenderer.d.ts +2 -0
  21. package/dist/renderer/features/TreegeRenderer/web/components/DefaultSubmitButton.d.ts +1 -1
  22. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultSubmitInput.d.ts +3 -0
  23. package/dist/renderer/hooks/useSubmitHandler.d.ts +34 -0
  24. package/dist/renderer/types/renderer.d.ts +16 -2
  25. package/dist/renderer/utils/form.d.ts +19 -0
  26. package/dist/renderer/utils/http.d.ts +101 -0
  27. package/dist/renderer/utils/submit.d.ts +47 -0
  28. package/dist/renderer.js +30 -28
  29. package/dist/shared/components/ui/alert-dialog.d.ts +14 -0
  30. package/dist/shared/components/ui/badge.d.ts +1 -1
  31. package/dist/shared/components/ui/popover.d.ts +3 -1
  32. package/dist/shared/components/ui/select.d.ts +3 -1
  33. package/dist/shared/constants/inputType.d.ts +1 -0
  34. package/dist/shared/locales/ar.json.d.ts +48 -3
  35. package/dist/shared/locales/de.json.d.ts +48 -3
  36. package/dist/shared/locales/en.json.d.ts +49 -4
  37. package/dist/shared/locales/es.json.d.ts +48 -3
  38. package/dist/shared/locales/fr.json.d.ts +48 -3
  39. package/dist/shared/locales/it.json.d.ts +48 -3
  40. package/dist/shared/locales/pt.json.d.ts +48 -3
  41. package/dist/shared/types/node.d.ts +47 -0
  42. package/package.json +4 -3
  43. package/dist/ThemeContext-XefwjIme.js +0 -760
  44. package/dist/TreegeEditor-DOj2aQTI.js +0 -2735
  45. package/dist/TreegeRenderer-BKVKtiO4.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, type, parentId, id }: import('../features/TreegeEditor/nodes/InputNode').InputNodeProps) => import("react/jsx-runtime").JSX.Element;
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 ConditionalEdge: ({ id, target, sourceX, sourceY, targetX, targetY, sourcePosition, targetPosition, markerEnd, style, data, }: ConditionalEdgeProps) => import("react/jsx-runtime").JSX.Element;
6
- export default ConditionalEdge;
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 FlowNode: ({ data, isConnectable, type, parentId, id }: FlowNodeProps) => import("react/jsx-runtime").JSX.Element;
6
- export default FlowNode;
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 GroupNode: ({ data }: GroupNodeProps) => import("react/jsx-runtime").JSX.Element;
6
- export default GroupNode;
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 InputNode: ({ data, isConnectable, type, parentId, id }: InputNodeProps) => import("react/jsx-runtime").JSX.Element;
6
- export default InputNode;
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 UINode: ({ data, isConnectable, type, parentId, id }: UINodeProps) => import("react/jsx-runtime").JSX.Element;
6
- export default UINode;
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-DOj2aQTI.js";
2
- import { T as m, u as s } from "./ThemeContext-XefwjIme.js";
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-DOj2aQTI.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-XefwjIme.js";
3
- import { c as D, d as I, e as T, f as m, g, h as F, D as c, i as x, j as N, k as S, l as b, m as v, n as R, o as h, p as w, q as C, r as z, s as A, v as H, w as k, T as E, b as G, J as P, K as y, t as U, x as V, y as j, z as q, A as B, C as J, F as K, G as L, I as M, E as O, H as Q, B as W, u as X, a as Y } from "./TreegeRenderer-BKVKtiO4.js";
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
- D as DefaultAddressInput,
6
- I as DefaultAutocompleteInput,
7
- T as DefaultCheckboxInput,
5
+ T as DefaultAddressInput,
6
+ D as DefaultAutocompleteInput,
7
+ I as DefaultCheckboxInput,
8
8
  m as DefaultDateInput,
9
9
  g as DefaultDateRangeInput,
10
- F as DefaultFileInput,
11
- c as DefaultGroup,
12
- x as DefaultHiddenInput,
13
- N as DefaultHttpInput,
14
- S as DefaultNumberInput,
15
- b as DefaultPasswordInput,
16
- v as DefaultRadioInput,
17
- R as DefaultSelectInput,
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
- E as TreegeConfigProvider,
26
+ y as TreegeConfigProvider,
27
27
  t as TreegeEditor,
28
- G as TreegeRenderer,
29
- P as checkFormFieldHasValue,
30
- y as convertFormValuesToNamedFormat,
31
- U as defaultInputRenderers,
32
- V as defaultUI,
33
- j as evaluateCondition,
34
- q as evaluateConditions,
35
- B as fileToSerializable,
36
- J as filesToSerializable,
37
- K as findStartNode,
38
- L as getFlowRenderState,
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
- M as isFieldEmpty,
43
+ Q as isFieldEmpty,
42
44
  o as isFlowNode,
43
45
  i as isGroupNode,
44
46
  n as isInputNode,
45
- O as isStartNode,
47
+ W as isStartNode,
46
48
  d as isUINode,
47
- Q as mergeFlows,
48
- W as serializableToFile,
49
+ X as mergeFlows,
50
+ Y as serializableToFile,
49
51
  f as useTheme,
50
- X as useTreegeConfig,
51
- Y as useTreegeRenderer
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: ({ label, ...props }: SubmitButtonProps) => import("react/jsx-runtime").JSX.Element;
8
+ declare const DefaultSubmitButton: import('react').ForwardRefExoticComponent<SubmitButtonProps & import('react').RefAttributes<HTMLButtonElement>>;
9
9
  export default DefaultSubmitButton;
@@ -0,0 +1,3 @@
1
+ import { InputRenderProps } from '../../../../../types/renderer';
2
+ declare const DefaultSubmitInput: ({ missingRequiredFields, isSubmitting, label }: InputRenderProps<"submit">) => import("react/jsx-runtime").JSX.Element;
3
+ export default DefaultSubmitInput;
@@ -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 d, l as p, m as D, n as I, o as T, p as m, q as g, r as F, s as c, v, w as x, T as R, b as S, J as b, K as h, t as C, x as w, y as z, z as A, A as H, C as N, F as k, G as P, I as y, E, H as G, B as V, u as j, a as q } from "./TreegeRenderer-BKVKtiO4.js";
2
- import { T as J, g as K, u as U } from "./ThemeContext-XefwjIme.js";
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
- d as DefaultNumberInput,
14
- p as DefaultPasswordInput,
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
- F as DefaultTimeInput,
21
- c as DefaultTimeRangeInput,
22
- v as Divider,
23
- J as ThemeProvider,
24
- x as Title,
25
- R as TreegeConfigProvider,
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 checkFormFieldHasValue,
28
- h as convertFormValuesToNamedFormat,
29
- C as defaultInputRenderers,
30
- w as defaultUI,
31
- z as evaluateCondition,
32
- A as evaluateConditions,
33
- H as fileToSerializable,
34
- N as filesToSerializable,
35
- k as findStartNode,
36
- P as getFlowRenderState,
37
- K as getTranslatedText,
38
- y as isFieldEmpty,
39
- E as isStartNode,
40
- G as mergeFlows,
41
- V as serializableToFile,
42
- U as useTheme,
43
- j as useTreegeConfig,
44
- q as useTreegeRenderer
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;
@@ -2,6 +2,8 @@ import * as PopoverPrimitive from "@radix-ui/react-popover";
2
2
  import * as React from "react";
3
3
  declare function Popover({ ...props }: React.ComponentProps<typeof PopoverPrimitive.Root>): import("react/jsx-runtime").JSX.Element;
4
4
  declare function PopoverTrigger({ ...props }: React.ComponentProps<typeof PopoverPrimitive.Trigger>): import("react/jsx-runtime").JSX.Element;
5
- declare function PopoverContent({ className, align, sideOffset, ...props }: React.ComponentProps<typeof PopoverPrimitive.Content>): import("react/jsx-runtime").JSX.Element;
5
+ declare function PopoverContent({ className, align, sideOffset, disablePortal, ...props }: React.ComponentProps<typeof PopoverPrimitive.Content> & {
6
+ disablePortal?: boolean;
7
+ }): import("react/jsx-runtime").JSX.Element;
6
8
  declare function PopoverAnchor({ ...props }: React.ComponentProps<typeof PopoverPrimitive.Anchor>): import("react/jsx-runtime").JSX.Element;
7
9
  export { Popover, PopoverTrigger, PopoverContent, PopoverAnchor };