treege 3.0.0-beta.44 → 3.0.0-beta.46

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 (69) hide show
  1. package/README.md +16 -9
  2. package/dist/DefaultInputs-7fXlu0uL.js +1734 -0
  3. package/dist/ThemeContext-CNsS53ku.js +1454 -0
  4. package/dist/editor/constants/nodeTypes.d.ts +1 -1
  5. package/dist/editor/context/OpenApiContext.d.ts +79 -0
  6. package/dist/editor/context/TreegeEditorContext.d.ts +7 -0
  7. package/dist/editor/features/TreegeEditor/TreegeEditor.d.ts +1 -1
  8. package/dist/editor/features/TreegeEditor/dialogs/AuthorizeDialog.d.ts +20 -0
  9. package/dist/editor/features/TreegeEditor/dialogs/HeadersDialog.d.ts +19 -0
  10. package/dist/editor/features/TreegeEditor/dialogs/OpenApiDialog.d.ts +6 -0
  11. package/dist/editor/features/TreegeEditor/forms/OptionsSourceForm.d.ts +7 -0
  12. package/dist/editor/features/TreegeEditor/inputs/ApiUrlCombobox.d.ts +30 -0
  13. package/dist/editor/features/TreegeEditor/nodes/TreegeNode.d.ts +0 -1
  14. package/dist/editor/features/TreegeEditor/nodes/components/NodeGroupBadge.d.ts +5 -0
  15. package/dist/editor/features/TreegeEditor/nodes/components/NodeImage.d.ts +5 -0
  16. package/dist/editor/features/TreegeEditor/nodes/components/NodeImageButton.d.ts +6 -0
  17. package/dist/editor/features/TreegeEditor/nodes/components/NodeOptions.d.ts +12 -0
  18. package/dist/editor/features/TreegeEditor/nodes/components/NodeRequiredButton.d.ts +6 -0
  19. package/dist/editor/features/TreegeEditor/nodes/layout/NodeWrapper.d.ts +1 -2
  20. package/dist/editor/features/TreegeEditor/panel/ActionsPanel.d.ts +5 -2
  21. package/dist/editor/types/editor.d.ts +39 -1
  22. package/dist/editor/types/openapi.d.ts +81 -0
  23. package/dist/editor/utils/dagreLayout.d.ts +5 -2
  24. package/dist/editor/utils/groupColor.d.ts +14 -0
  25. package/dist/editor/utils/openapi.d.ts +35 -0
  26. package/dist/editor-DLKg7ri7.js +5209 -0
  27. package/dist/editor.js +2 -2
  28. package/dist/main.js +4 -4
  29. package/dist/renderer/context/TreegeConfigContext.d.ts +3 -27
  30. package/dist/renderer/context/TreegeRendererContext.d.ts +99 -2
  31. package/dist/renderer/features/TreegeRenderer/native/components/DefaultInputWrapper.d.ts +9 -0
  32. package/dist/renderer/features/TreegeRenderer/native/components/DefaultStep.d.ts +3 -0
  33. package/dist/renderer/features/TreegeRenderer/useTreegeRenderer.d.ts +15 -6
  34. package/dist/renderer/features/TreegeRenderer/web/TreegeRenderer.d.ts +1 -1
  35. package/dist/renderer/features/TreegeRenderer/web/components/DefaultFormWrapper.d.ts +1 -1
  36. package/dist/renderer/features/TreegeRenderer/web/components/DefaultInputWrapper.d.ts +9 -0
  37. package/dist/renderer/features/TreegeRenderer/web/components/DefaultStep.d.ts +3 -0
  38. package/dist/renderer/hooks/useInputOptions.d.ts +28 -0
  39. package/dist/renderer/hooks/useRenderNode.d.ts +7 -5
  40. package/dist/renderer/hooks/useSubmitHandler.d.ts +3 -2
  41. package/dist/renderer/index.d.ts +1 -1
  42. package/dist/renderer/index.native.d.ts +1 -1
  43. package/dist/renderer/types/renderer.d.ts +55 -29
  44. package/dist/renderer/utils/http.d.ts +29 -1
  45. package/dist/renderer/utils/step.d.ts +27 -0
  46. package/dist/renderer/utils/submit.d.ts +3 -2
  47. package/dist/renderer-native.js +961 -877
  48. package/dist/renderer.js +3 -3
  49. package/dist/shared/components/ui/button.d.ts +1 -1
  50. package/dist/shared/components/ui/field.d.ts +24 -0
  51. package/dist/shared/components/ui/toggle-group.d.ts +7 -0
  52. package/dist/shared/components/ui/toggle.d.ts +9 -0
  53. package/dist/shared/locales/ar.json.d.ts +86 -1
  54. package/dist/shared/locales/de.json.d.ts +86 -1
  55. package/dist/shared/locales/en.json.d.ts +86 -1
  56. package/dist/shared/locales/es.json.d.ts +86 -1
  57. package/dist/shared/locales/fr.json.d.ts +86 -1
  58. package/dist/shared/locales/it.json.d.ts +86 -1
  59. package/dist/shared/locales/pt.json.d.ts +86 -1
  60. package/dist/shared/types/node.d.ts +44 -0
  61. package/package.json +3 -1
  62. package/dist/DefaultInputs-D6a1ESW-.js +0 -1562
  63. package/dist/ThemeContext-CUHjGVUf.js +0 -1602
  64. package/dist/editor/features/TreegeEditor/nodes/GroupNode.d.ts +0 -6
  65. package/dist/editor/features/TreegeEditor/nodes/components/OptionsEditor.d.ts +0 -7
  66. package/dist/editor/features/TreegeEditor/nodes/components/RequiredBadge.d.ts +0 -6
  67. package/dist/editor-DjtjUgyb.js +0 -4041
  68. package/dist/renderer/features/TreegeRenderer/native/components/DefaultGroup.d.ts +0 -7
  69. package/dist/renderer/features/TreegeRenderer/web/components/DefaultGroup.d.ts +0 -6
package/dist/editor.js CHANGED
@@ -1,3 +1,3 @@
1
- import { t as e } from "./editor-DjtjUgyb.js";
2
- import { n as t, t as n } from "./ThemeContext-CUHjGVUf.js";
1
+ import { t as e } from "./editor-DLKg7ri7.js";
2
+ import { n as t, t as n } from "./ThemeContext-CNsS53ku.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-DjtjUgyb.js";
2
- import { C as t, D as n, F as r, I as i, L as a, M as o, N as s, O as c, P as l, S as u, _ as d, a as f, b as p, c as m, d as h, f as g, g as _, h as v, i as y, l as b, n as x, o as S, s as C, t as w, v as T, x as E, y as D } from "./ThemeContext-CUHjGVUf.js";
3
- import { C as O, D as k, E as A, O as j, S as M, T as N, a as P, b as F, d as I, f as L, g as R, h as z, i as B, l as V, m as H, n as U, r as W, s as G, t as K, u as q, w as J, x as Y, y as X } from "./DefaultInputs-D6a1ESW-.js";
4
- export { j as DefaultAddressInput, k as DefaultAutocompleteInput, A as DefaultCheckboxInput, N as DefaultDateInput, J as DefaultDateRangeInput, O as DefaultFileInput, H as DefaultGroup, M as DefaultHiddenInput, Y as DefaultHttpInput, F as DefaultNumberInput, X as DefaultPasswordInput, R as DefaultRadioInput, z as DefaultSelectInput, G as DefaultSwitchInput, P as DefaultTextAreaInput, B as DefaultTextInput, W as DefaultTimeInput, U as DefaultTimeRangeInput, q as Divider, w as ThemeProvider, I as Title, f as TreegeConfigProvider, e as TreegeEditor, V as TreegeRenderer, D as applyReferenceTransformation, p as calculateReferenceFieldUpdates, E as checkFormFieldHasValue, u as convertFormValuesToNamedFormat, K as defaultInputRenderers, L as defaultUI, n as evaluateCondition, c as evaluateConditions, C as fileToSerializable, m as filesToSerializable, v as findStartNode, _ as getFlowRenderState, o as getStaticTranslations, s as getTranslatedText, t as isFieldEmpty, l as isFlowNode, r as isGroupNode, i as isInputNode, d as isStartNode, a as isUINode, T as mergeFlows, h as sanitize, g as sanitizeHttpResponse, b as serializableToFile, x as useTheme, S as useTreegeConfig, y as useTreegeRenderer };
1
+ import { t as e } from "./editor-DLKg7ri7.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-CNsS53ku.js";
3
+ import { C as O, E as k, S as A, T as j, _ as M, a as N, b as P, d as F, f as I, i as L, l as R, m as z, n as B, p as V, r as H, s as U, t as W, u as G, v as K, w as q, x as J, y as Y } from "./DefaultInputs-7fXlu0uL.js";
4
+ export { k as DefaultAddressInput, j as DefaultAutocompleteInput, q as DefaultCheckboxInput, O as DefaultDateInput, A as DefaultDateRangeInput, J as DefaultFileInput, P as DefaultHiddenInput, Y as DefaultHttpInput, K as DefaultNumberInput, M as DefaultPasswordInput, z as DefaultRadioInput, V as DefaultSelectInput, U as DefaultSwitchInput, N as DefaultTextAreaInput, L as DefaultTextInput, H as DefaultTimeInput, B as DefaultTimeRangeInput, G as Divider, w as ThemeProvider, F as Title, h as TreegeConfigProvider, e as TreegeEditor, R as TreegeRenderer, T as applyReferenceTransformation, f as calculateReferenceFieldUpdates, i as checkFormFieldHasValue, r as convertFormValuesToNamedFormat, W 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 { TreegeRendererComponents, TreegeRendererConfig } from '../types/renderer';
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, components, googleApiKey, language, theme, validationMode, }: TreegeConfigProviderProps) => import("react/jsx-runtime").JSX.Element;
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
- value: TreegeRendererContextValue;
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;
@@ -0,0 +1,3 @@
1
+ import { StepRenderProps } from '../../../../types/renderer';
2
+ declare const DefaultStep: ({ label, children, isFirstStep, isLastStep, canContinue, isSubmitting, onBack, onContinue }: StepRenderProps) => import("react/jsx-runtime").JSX.Element;
3
+ export default DefaultStep;
@@ -1,6 +1,6 @@
1
1
  import { Node } from '@xyflow/react';
2
2
  import { FormValues, TreegeRendererProps } from '../../types/renderer';
3
- import { TreegeNodeData } from '../../../shared/types/node';
3
+ import { GroupNodeData, TreegeNodeData } from '../../../shared/types/node';
4
4
  /**
5
5
  * Main TreegeRenderer hook
6
6
  *
@@ -19,17 +19,15 @@ 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
+ canContinueStep: boolean;
23
24
  canSubmit: boolean;
24
25
  clearSubmitMessage: () => void;
25
26
  config: {
26
27
  components: {
27
28
  form: ((props: {
28
29
  children: import('react').ReactNode;
29
- onSubmit: (e: import('react').FormEvent) => void;
30
- }) => import('react').ReactNode) | undefined;
31
- group: ((props: import('../../types/renderer').NodeRenderProps & {
32
- children?: import('react').ReactNode;
30
+ onSubmit: (e: import('react').FormEvent<HTMLFormElement>) => void;
33
31
  }) => import('react').ReactNode) | undefined;
34
32
  inputs: {
35
33
  number?: ((props: import('../../types/renderer').InputRenderProps<"number">) => import('react').ReactNode) | undefined;
@@ -51,6 +49,7 @@ export declare const useTreegeRenderer: ({ components, flows, googleApiKey, init
51
49
  time?: ((props: import('../../types/renderer').InputRenderProps<"time">) => import('react').ReactNode) | undefined;
52
50
  timerange?: ((props: import('../../types/renderer').InputRenderProps<"timerange">) => import('react').ReactNode) | undefined;
53
51
  };
52
+ step: ((props: import('../../types/renderer').StepRenderProps) => import('react').ReactNode) | undefined;
54
53
  submitButton: ((props: {
55
54
  label?: string;
56
55
  disabled?: boolean;
@@ -72,15 +71,24 @@ export declare const useTreegeRenderer: ({ components, flows, googleApiKey, init
72
71
  };
73
72
  };
74
73
  googleApiKey: string | undefined;
74
+ headers: import('../../../shared/types/node').HttpHeader[];
75
75
  language: string;
76
76
  theme: "dark" | "light";
77
77
  validationMode: "onChange" | "onSubmit";
78
78
  };
79
+ currentStep: import('../../utils/step').FlowStep;
80
+ currentStepGroupNode: Node<GroupNodeData> | undefined;
81
+ currentStepIndex: number;
79
82
  firstErrorFieldId: string | undefined;
80
83
  formErrors: Record<string, string>;
81
84
  formValues: FormValues;
85
+ goToNextStep: () => void;
86
+ goToPreviousStep: () => void;
82
87
  handleSubmit: () => Promise<boolean>;
88
+ hasSubmitInput: boolean;
83
89
  inputNodes: Node<import('../../../shared/types/node').InputNodeData>[];
90
+ isFirstStep: boolean;
91
+ isLastStep: boolean;
84
92
  isSubmitting: boolean;
85
93
  mergedFlow: import('../../../shared/types/node').Flow;
86
94
  missingRequiredFields: string[];
@@ -88,6 +96,7 @@ export declare const useTreegeRenderer: ({ components, flows, googleApiKey, init
88
96
  setFieldErrors: import('react').Dispatch<import('react').SetStateAction<Record<string, string>>>;
89
97
  setFieldValue: (fieldName: string, value: unknown) => void;
90
98
  setMultipleFieldValues: (updates: FormValues) => void;
99
+ steps: import('../../utils/step').FlowStep[];
91
100
  submitMessage: {
92
101
  type: "success" | "error";
93
102
  message: string;
@@ -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,3 @@
1
+ import { StepRenderProps } from '../../../../types/renderer';
2
+ declare const DefaultStep: ({ label, children, isFirstStep, isLastStep, canContinue, isSubmitting, onBack, onContinue }: StepRenderProps) => import("react/jsx-runtime").JSX.Element;
3
+ export default DefaultStep;
@@ -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: {
@@ -9,7 +9,10 @@ type UseRenderNodeParams = {
9
9
  language: string;
10
10
  };
11
11
  DefaultFormWrapper: AnyComponent;
12
- DefaultGroup: AnyComponent;
12
+ DefaultInputWrapper: ComponentType<{
13
+ node: Node<InputNodeData>;
14
+ children: ReactNode;
15
+ }>;
13
16
  DefaultSubmitButton: AnyComponent;
14
17
  DefaultSubmitButtonWrapper?: AnyComponent;
15
18
  defaultInputRenderers: InputRenderers;
@@ -18,7 +21,6 @@ type UseRenderNodeParams = {
18
21
  formValues: FormValues;
19
22
  missingRequiredFields: string[];
20
23
  setFieldValue: (fieldId: string, value: unknown) => void;
21
- visibleNodes: Node<TreegeNodeData>[];
22
24
  };
23
25
  /**
24
26
  * Hook that returns rendering utilities for TreegeRenderer
@@ -30,10 +32,10 @@ type UseRenderNodeParams = {
30
32
  * - SubmitButton: Submit button component with fallback
31
33
  * - SubmitButtonWrapper: Submit button wrapper component with fallback (web only, undefined for native)
32
34
  */
33
- export declare const useRenderNode: ({ DefaultFormWrapper, DefaultGroup, DefaultSubmitButton, DefaultSubmitButtonWrapper, config, defaultInputRenderers, defaultUI, formErrors, formValues, missingRequiredFields, setFieldValue, visibleNodes, }: UseRenderNodeParams) => {
35
+ export declare const useRenderNode: ({ DefaultFormWrapper, DefaultInputWrapper, DefaultSubmitButton, DefaultSubmitButtonWrapper, config, defaultInputRenderers, defaultUI, formErrors, formValues, missingRequiredFields, setFieldValue, }: UseRenderNodeParams) => {
34
36
  FormWrapper: ((props: {
35
37
  children: ReactNode;
36
- onSubmit: (e: import('react').FormEvent) => void;
38
+ onSubmit: (e: import('react').FormEvent<HTMLFormElement>) => void;
37
39
  }) => ReactNode) | AnyComponent;
38
40
  renderNode: (node: Node<TreegeNodeData>) => ReactNode;
39
41
  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;
@@ -2,8 +2,8 @@ export { TreegeConfigProvider, useTreegeConfig } from './context/TreegeConfigCon
2
2
  export type { UseTreegeRendererReturn } from './features/TreegeRenderer/useTreegeRenderer';
3
3
  export { useTreegeRenderer } from './features/TreegeRenderer/useTreegeRenderer';
4
4
  export * from './features/TreegeRenderer/web/components/DefaultFormWrapper';
5
- export * from './features/TreegeRenderer/web/components/DefaultGroup';
6
5
  export * from './features/TreegeRenderer/web/components/DefaultInputs';
6
+ export * from './features/TreegeRenderer/web/components/DefaultStep';
7
7
  export * from './features/TreegeRenderer/web/components/DefaultSubmitButton';
8
8
  export * from './features/TreegeRenderer/web/components/DefaultUI';
9
9
  export * from './features/TreegeRenderer/web/TreegeRenderer';
@@ -1,7 +1,7 @@
1
1
  export { TreegeConfigProvider, useTreegeConfig } from './context/TreegeConfigContext';
2
2
  export * from './features/TreegeRenderer/native/components/DefaultFormWrapper';
3
- export * from './features/TreegeRenderer/native/components/DefaultGroup';
4
3
  export * from './features/TreegeRenderer/native/components/DefaultInputs';
4
+ export * from './features/TreegeRenderer/native/components/DefaultStep';
5
5
  export * from './features/TreegeRenderer/native/components/DefaultSubmitButton';
6
6
  export * from './features/TreegeRenderer/native/components/DefaultSubmitButtonWrapper';
7
7
  export * from './features/TreegeRenderer/native/components/DefaultUI';
@@ -1,7 +1,8 @@
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 { FlowStep } from '../utils/step';
5
+ import { Flow, GroupNodeData, HttpHeader, InputNodeData, InputType, TreegeNodeData, UINodeData, UIType } from '../../shared/types/node';
5
6
  /**
6
7
  * Type mapping for input values based on input type
7
8
  */
@@ -104,6 +105,44 @@ export type NodeRenderProps = {
104
105
  export type InputRenderers = {
105
106
  [K in InputType]?: (props: InputRenderProps<K>) => ReactNode;
106
107
  };
108
+ /**
109
+ * Props passed to a step renderer. Steps are derived at runtime from the flow's
110
+ * groups: each contiguous slice of visible nodes sharing the same `parentId`
111
+ * (or no parent — orphan steps) becomes one step.
112
+ */
113
+ export type StepRenderProps = {
114
+ /** The step being rendered (its group id and ordered child nodes). */
115
+ step: FlowStep;
116
+ /** Hidden group node carrying the step's metadata (label) — undefined for orphan steps. */
117
+ groupNode?: Node<GroupNodeData>;
118
+ /** Zero-based index of this step in the current step sequence. */
119
+ stepIndex: number;
120
+ /** Total number of steps currently visible. Recomputes when branching changes. */
121
+ totalSteps: number;
122
+ /** True when this is the first step (Back should be hidden/disabled). */
123
+ isFirstStep: boolean;
124
+ /**
125
+ * True when this is the last visible step. The renderer turns Continue
126
+ * into a submit action on the last step.
127
+ */
128
+ isLastStep: boolean;
129
+ /** Whether all required visible inputs of the step are filled. */
130
+ canContinue: boolean;
131
+ /** Submission in progress (passed through from `useTreegeRenderer`). */
132
+ isSubmitting?: boolean;
133
+ /** Advance to the previous step. No-op on the first step. */
134
+ onBack: () => void;
135
+ /**
136
+ * Advance to the next step (or trigger submit on the last step). The wrapper
137
+ * passes `isLastStep` so the implementation can decide between an in-flow
138
+ * advance and a form submit.
139
+ */
140
+ onContinue: () => void;
141
+ /** Translated label of the group, or empty string for orphan steps. */
142
+ label?: string;
143
+ /** The rendered child nodes belonging to this step. */
144
+ children: ReactNode;
145
+ };
107
146
  /**
108
147
  * Custom renderer components
109
148
  */
@@ -118,17 +157,16 @@ export type TreegeRendererComponents = {
118
157
  */
119
158
  ui?: Partial<Record<UIType, (props: NodeRenderProps) => ReactNode>>;
120
159
  /**
121
- * Custom group container renderer
160
+ * Custom step renderer — wraps the current step's nodes and renders the
161
+ * Back/Continue navigation. Defaults are provided by `DefaultStep` (web/native).
122
162
  */
123
- group?: (props: NodeRenderProps & {
124
- children?: ReactNode;
125
- }) => ReactNode;
163
+ step?: (props: StepRenderProps) => ReactNode;
126
164
  /**
127
165
  * Custom form wrapper
128
166
  */
129
167
  form?: (props: {
130
168
  children: ReactNode;
131
- onSubmit: (e: FormEvent) => void;
169
+ onSubmit: (e: FormEvent<HTMLFormElement>) => void;
132
170
  }) => ReactNode;
133
171
  /**
134
172
  * Custom submit button (supports both web and native variants)
@@ -163,6 +201,12 @@ export type TreegeRendererConfig = {
163
201
  * Custom component renderers
164
202
  */
165
203
  components?: TreegeRendererComponents;
204
+ /**
205
+ * Global HTTP headers applied to every request issued by the renderer
206
+ * (HTTP inputs, submit buttons). Field-level headers with the same key
207
+ * (case-insensitive) take precedence over these.
208
+ */
209
+ headers?: HttpHeader[];
166
210
  /**
167
211
  * Google Maps API key for address autocomplete
168
212
  * If not provided, falls back to free Nominatim (OpenStreetMap)
@@ -186,35 +230,26 @@ export type TreegeRendererConfig = {
186
230
  };
187
231
  /**
188
232
  * Props for the TreegeRenderer component
233
+ *
234
+ * Inherits all configuration fields from TreegeRendererConfig (components,
235
+ * headers, googleApiKey, language, theme, validationMode) and adds the
236
+ * instance-specific ones (flows, callbacks, initial values, etc.).
189
237
  */
190
- export interface TreegeRendererProps {
238
+ export interface TreegeRendererProps extends TreegeRendererConfig {
191
239
  /**
192
240
  * Additional class name for the renderer container
193
241
  */
194
242
  className?: string;
195
- /**
196
- * Custom component renderers
197
- */
198
- components?: TreegeRendererComponents;
199
243
  /**
200
244
  * Flow or array of flows
201
245
  * - If a single Flow: renders that flow
202
246
  * - If an array: first flow is the main flow, others are sub-flows available for FlowNodes
203
247
  */
204
248
  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
249
  /**
211
250
  * Initial form values
212
251
  */
213
252
  initialValues?: FormValues;
214
- /**
215
- * Current language for translations
216
- */
217
- language?: string;
218
253
  /**
219
254
  * Callback when form values change
220
255
  */
@@ -225,17 +260,8 @@ export interface TreegeRendererProps {
225
260
  * @param meta - Optional metadata about the submission (e.g., HTTP response data)
226
261
  */
227
262
  onSubmit?: (values: FormValues, meta?: Meta) => void;
228
- /**
229
- * Theme for the renderer
230
- * @default "dark"
231
- */
232
- theme?: "dark" | "light";
233
263
  /**
234
264
  * Custom validation function
235
265
  */
236
266
  validate?: (values: FormValues, nodes: Node<TreegeNodeData>[]) => Record<string, string>;
237
- /**
238
- * Validation mode
239
- */
240
- validationMode?: "onChange" | "onSubmit";
241
267
  }
@@ -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[];
@@ -0,0 +1,27 @@
1
+ import { Node } from '@xyflow/react';
2
+ import { TreegeNodeData } from '../../shared/types/node';
3
+ /**
4
+ * A renderer step — a contiguous slice of visible nodes that share the same
5
+ * `parentId` (group id) or no parent (orphan step).
6
+ *
7
+ * Steps are derived from the flow's visible nodes at render time; the editor's
8
+ * group nodes carry only metadata (label) and are no longer rendered.
9
+ */
10
+ export type FlowStep = {
11
+ /**
12
+ * Group id owning the step, or null for orphan steps (nodes without `parentId`).
13
+ */
14
+ groupId: string | null;
15
+ /**
16
+ * The actual nodes (input + ui) rendered in this step, in flow order.
17
+ */
18
+ nodes: Node<TreegeNodeData>[];
19
+ };
20
+ /**
21
+ * Partition `visibleNodes` into ordered steps. A new step is started every
22
+ * time the `parentId` of the next renderable node changes (i.e. the flow
23
+ * crosses a group boundary, or moves between an orphan and a grouped node).
24
+ *
25
+ * Group / flow nodes themselves are skipped — they're metadata only.
26
+ */
27
+ export declare const computeSteps: (visibleNodes: Node<TreegeNodeData>[]) => FlowStep[];