treege 3.0.0-beta.45 → 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 (32) hide show
  1. package/dist/DefaultInputs-7fXlu0uL.js +1734 -0
  2. package/dist/{ThemeContext-O482h1XZ.js → ThemeContext-CNsS53ku.js} +274 -217
  3. package/dist/editor/constants/nodeTypes.d.ts +1 -1
  4. package/dist/editor/features/TreegeEditor/nodes/components/NodeGroupBadge.d.ts +5 -0
  5. package/dist/editor/features/TreegeEditor/nodes/layout/NodeWrapper.d.ts +1 -2
  6. package/dist/editor/utils/dagreLayout.d.ts +5 -2
  7. package/dist/editor/utils/groupColor.d.ts +14 -0
  8. package/dist/{editor-DBCMmZtt.js → editor-DLKg7ri7.js} +1550 -1488
  9. package/dist/editor.js +2 -2
  10. package/dist/main.js +4 -4
  11. package/dist/renderer/features/TreegeRenderer/native/components/DefaultStep.d.ts +3 -0
  12. package/dist/renderer/features/TreegeRenderer/useTreegeRenderer.d.ts +12 -4
  13. package/dist/renderer/features/TreegeRenderer/web/components/DefaultStep.d.ts +3 -0
  14. package/dist/renderer/hooks/useRenderNode.d.ts +1 -3
  15. package/dist/renderer/index.d.ts +1 -1
  16. package/dist/renderer/index.native.d.ts +1 -1
  17. package/dist/renderer/types/renderer.d.ts +43 -5
  18. package/dist/renderer/utils/step.d.ts +27 -0
  19. package/dist/renderer-native.js +757 -685
  20. package/dist/renderer.js +3 -3
  21. package/dist/shared/locales/ar.json.d.ts +6 -1
  22. package/dist/shared/locales/de.json.d.ts +6 -1
  23. package/dist/shared/locales/en.json.d.ts +6 -1
  24. package/dist/shared/locales/es.json.d.ts +6 -1
  25. package/dist/shared/locales/fr.json.d.ts +6 -1
  26. package/dist/shared/locales/it.json.d.ts +6 -1
  27. package/dist/shared/locales/pt.json.d.ts +6 -1
  28. package/package.json +1 -1
  29. package/dist/DefaultInputs-DYKtphqY.js +0 -1701
  30. package/dist/editor/features/TreegeEditor/nodes/GroupNode.d.ts +0 -6
  31. package/dist/renderer/features/TreegeRenderer/native/components/DefaultGroup.d.ts +0 -7
  32. 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-DBCMmZtt.js";
2
- import { n as t, t as n } from "./ThemeContext-O482h1XZ.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-DBCMmZtt.js";
2
- import { B as t, C as n, D as r, E as i, H as a, L as o, M as s, N as c, O as l, R as u, S as d, T as f, V as p, _ as m, a as h, b as g, c as _, g as v, i as y, l as b, n as x, o as S, s as C, t as w, w as T, x as E, z as D } from "./ThemeContext-O482h1XZ.js";
3
- import { C as O, D as k, E as A, S as j, T as M, a as N, b as P, d as F, f as I, h as L, i as R, l as z, m as B, n as V, p as H, r as U, s as W, t as G, u as K, v as q, w as J, x as Y, y as X } from "./DefaultInputs-DYKtphqY.js";
4
- export { k as DefaultAddressInput, A as DefaultAutocompleteInput, M as DefaultCheckboxInput, J as DefaultDateInput, O as DefaultDateRangeInput, j as DefaultFileInput, H as DefaultGroup, Y as DefaultHiddenInput, P as DefaultHttpInput, X as DefaultNumberInput, q as DefaultPasswordInput, L as DefaultRadioInput, B as DefaultSelectInput, W as DefaultSwitchInput, N as DefaultTextAreaInput, R as DefaultTextInput, U as DefaultTimeInput, V as DefaultTimeRangeInput, K as Divider, w as ThemeProvider, F as Title, h as TreegeConfigProvider, e as TreegeEditor, z as TreegeRenderer, T as applyReferenceTransformation, f as calculateReferenceFieldUpdates, i as checkFormFieldHasValue, r as convertFormValuesToNamedFormat, G as defaultInputRenderers, I as defaultUI, s as evaluateCondition, c as evaluateConditions, C as fileToSerializable, _ as filesToSerializable, g as findStartNode, E as getFlowRenderState, o as getStaticTranslations, u as getTranslatedText, l as isFieldEmpty, D as isFlowNode, t as isGroupNode, p as isInputNode, d as isStartNode, a as isUINode, n as mergeFlows, v as sanitize, m as sanitizeHttpResponse, b as serializableToFile, x as useTheme, S as useTreegeConfig, y as useTreegeRenderer };
1
+ 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 };
@@ -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
  *
@@ -20,6 +20,7 @@ import { TreegeNodeData } from '../../../shared/types/node';
20
20
  * @returns Complete form state and control methods
21
21
  */
22
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: {
@@ -28,9 +29,6 @@ export declare const useTreegeRenderer: ({ components, flows, googleApiKey, head
28
29
  children: import('react').ReactNode;
29
30
  onSubmit: (e: import('react').FormEvent<HTMLFormElement>) => void;
30
31
  }) => import('react').ReactNode) | undefined;
31
- group: ((props: import('../../types/renderer').NodeRenderProps & {
32
- children?: import('react').ReactNode;
33
- }) => import('react').ReactNode) | undefined;
34
32
  inputs: {
35
33
  number?: ((props: import('../../types/renderer').InputRenderProps<"number">) => import('react').ReactNode) | undefined;
36
34
  address?: ((props: import('../../types/renderer').InputRenderProps<"address">) => import('react').ReactNode) | undefined;
@@ -51,6 +49,7 @@ export declare const useTreegeRenderer: ({ components, flows, googleApiKey, head
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;
@@ -77,11 +76,19 @@ export declare const useTreegeRenderer: ({ components, flows, googleApiKey, head
77
76
  theme: "dark" | "light";
78
77
  validationMode: "onChange" | "onSubmit";
79
78
  };
79
+ currentStep: import('../../utils/step').FlowStep;
80
+ currentStepGroupNode: Node<GroupNodeData> | undefined;
81
+ currentStepIndex: number;
80
82
  firstErrorFieldId: string | undefined;
81
83
  formErrors: Record<string, string>;
82
84
  formValues: FormValues;
85
+ goToNextStep: () => void;
86
+ goToPreviousStep: () => void;
83
87
  handleSubmit: () => Promise<boolean>;
88
+ hasSubmitInput: boolean;
84
89
  inputNodes: Node<import('../../../shared/types/node').InputNodeData>[];
90
+ isFirstStep: boolean;
91
+ isLastStep: boolean;
85
92
  isSubmitting: boolean;
86
93
  mergedFlow: import('../../../shared/types/node').Flow;
87
94
  missingRequiredFields: string[];
@@ -89,6 +96,7 @@ export declare const useTreegeRenderer: ({ components, flows, googleApiKey, head
89
96
  setFieldErrors: import('react').Dispatch<import('react').SetStateAction<Record<string, string>>>;
90
97
  setFieldValue: (fieldName: string, value: unknown) => void;
91
98
  setMultipleFieldValues: (updates: FormValues) => void;
99
+ steps: import('../../utils/step').FlowStep[];
92
100
  submitMessage: {
93
101
  type: "success" | "error";
94
102
  message: string;
@@ -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;
@@ -9,7 +9,6 @@ type UseRenderNodeParams = {
9
9
  language: string;
10
10
  };
11
11
  DefaultFormWrapper: AnyComponent;
12
- DefaultGroup: AnyComponent;
13
12
  DefaultInputWrapper: ComponentType<{
14
13
  node: Node<InputNodeData>;
15
14
  children: ReactNode;
@@ -22,7 +21,6 @@ type UseRenderNodeParams = {
22
21
  formValues: FormValues;
23
22
  missingRequiredFields: string[];
24
23
  setFieldValue: (fieldId: string, value: unknown) => void;
25
- visibleNodes: Node<TreegeNodeData>[];
26
24
  };
27
25
  /**
28
26
  * Hook that returns rendering utilities for TreegeRenderer
@@ -34,7 +32,7 @@ type UseRenderNodeParams = {
34
32
  * - SubmitButton: Submit button component with fallback
35
33
  * - SubmitButtonWrapper: Submit button wrapper component with fallback (web only, undefined for native)
36
34
  */
37
- export declare const useRenderNode: ({ DefaultFormWrapper, DefaultGroup, DefaultInputWrapper, 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) => {
38
36
  FormWrapper: ((props: {
39
37
  children: ReactNode;
40
38
  onSubmit: (e: import('react').FormEvent<HTMLFormElement>) => void;
@@ -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, HttpHeader, 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,11 +157,10 @@ 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
  */
@@ -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[];