treege 3.0.0-beta.8 → 3.0.0-beta.80
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/LICENSE +18 -12
- package/README.md +448 -79
- package/dist/DefaultSubmitButton-Bk5U_6Qm.js +1819 -0
- package/dist/ThemeContext-DeWmeqHK.js +978 -0
- package/dist/editor/components/input/ComboboxWithCreate.d.ts +2 -1
- package/dist/editor/components/styles/EditorStyles.d.ts +2 -0
- package/dist/editor/constants/defaultNode.d.ts +1 -1
- package/dist/editor/constants/edgeTypes.d.ts +3 -2
- package/dist/editor/constants/inputTypeIcons.d.ts +3 -0
- package/dist/editor/constants/nodeSpacing.d.ts +25 -0
- package/dist/editor/constants/nodeTypes.d.ts +4 -5
- package/dist/editor/context/OpenApiContext.d.ts +79 -0
- package/dist/editor/context/TreegeEditorRuntimeProvider.d.ts +78 -0
- package/dist/editor/features/TreegeEditor/TreegeEditor.d.ts +1 -1
- package/dist/editor/features/TreegeEditor/controls/MiniMapControl.d.ts +6 -0
- package/dist/editor/features/TreegeEditor/dialogs/AuthorizeDialog.d.ts +20 -0
- package/dist/editor/features/TreegeEditor/dialogs/ChangeNodeTypeDialog.d.ts +2 -0
- package/dist/editor/features/TreegeEditor/dialogs/DeleteNodeDialog.d.ts +2 -0
- package/dist/editor/features/TreegeEditor/dialogs/HeadersDialog.d.ts +19 -0
- package/dist/editor/features/TreegeEditor/dialogs/OpenApiDialog.d.ts +6 -0
- package/dist/editor/features/TreegeEditor/edges/ConditionalEdge.d.ts +2 -2
- package/dist/editor/features/TreegeEditor/edges/DefaultEdge.d.ts +3 -0
- package/dist/editor/features/TreegeEditor/forms/HttpConfigForm.d.ts +4 -1
- package/dist/editor/features/TreegeEditor/forms/JsonTemplateEditor.d.ts +13 -0
- package/dist/editor/features/TreegeEditor/forms/OptionsMappingFields.d.ts +34 -0
- package/dist/editor/features/TreegeEditor/forms/OptionsSourceForm.d.ts +7 -0
- package/dist/editor/features/TreegeEditor/forms/SensitiveHeaderWarning.d.ts +13 -0
- package/dist/editor/features/TreegeEditor/forms/SubmitConfigForm.d.ts +7 -0
- package/dist/editor/features/TreegeEditor/inputs/ApiUrlCombobox.d.ts +20 -0
- package/dist/editor/features/TreegeEditor/inputs/ComboboxPattern.d.ts +2 -1
- package/dist/editor/features/TreegeEditor/inputs/OptionImageField.d.ts +6 -0
- package/dist/editor/features/TreegeEditor/inputs/SelectNodeGroup.d.ts +22 -1
- package/dist/editor/features/TreegeEditor/layout/AutoLayout.d.ts +15 -0
- package/dist/editor/features/TreegeEditor/listeners/FlowChangeEmitter.d.ts +19 -0
- package/dist/editor/features/TreegeEditor/nodes/TreegeNode.d.ts +5 -0
- package/dist/editor/features/TreegeEditor/nodes/components/BottomHandleDropdown.d.ts +25 -0
- package/dist/editor/features/TreegeEditor/nodes/components/NodeGroupBadge.d.ts +6 -0
- package/dist/editor/features/TreegeEditor/nodes/components/NodeImage.d.ts +5 -0
- package/dist/editor/features/TreegeEditor/nodes/components/NodeImageButton.d.ts +6 -0
- package/dist/editor/features/TreegeEditor/nodes/components/NodeInputPreview.d.ts +12 -0
- package/dist/editor/features/TreegeEditor/nodes/components/NodeLabelInput.d.ts +10 -0
- package/dist/editor/features/TreegeEditor/nodes/components/NodeMoreMenu.d.ts +6 -0
- package/dist/editor/features/TreegeEditor/nodes/components/NodeRequiredButton.d.ts +6 -0
- package/dist/editor/features/TreegeEditor/nodes/components/NodeStackOrderButtons.d.ts +6 -0
- package/dist/editor/features/TreegeEditor/nodes/components/NodeTypeBadge.d.ts +7 -0
- package/dist/editor/features/TreegeEditor/nodes/components/NodeTypePickerMenuContent.d.ts +12 -0
- package/dist/editor/features/TreegeEditor/nodes/layout/NodeWrapper.d.ts +4 -2
- package/dist/editor/features/TreegeEditor/panel/AIGeneratorDialog.d.ts +16 -0
- package/dist/editor/features/TreegeEditor/panel/ActionsPanel.d.ts +7 -2
- package/dist/editor/features/TreegeEditor/panel/MultiSelectionPanel.d.ts +7 -0
- package/dist/editor/hooks/useAvailableParentFields.d.ts +13 -0
- package/dist/editor/hooks/useFlowActions.d.ts +6 -2
- package/dist/editor/hooks/useFlowConnections.d.ts +14 -0
- package/dist/editor/hooks/useFlowContent.d.ts +16 -0
- package/dist/editor/hooks/useHistoryStore.d.ts +26 -0
- package/dist/editor/hooks/useIsStackedEdge.d.ts +8 -0
- package/dist/editor/hooks/useKeyValueRows.d.ts +15 -0
- package/dist/editor/hooks/useNodesSelection.d.ts +5 -5
- package/dist/editor/hooks/useStackPosition.d.ts +14 -0
- package/dist/editor/hooks/useTranslate.d.ts +1 -1
- package/dist/editor/hooks/useUndoRedo.d.ts +31 -0
- package/dist/editor/types/ai.d.ts +65 -0
- package/dist/editor/types/editor.d.ts +106 -10
- package/dist/editor/types/openapi.d.ts +106 -0
- package/dist/editor/utils/aiFlowGenerator.d.ts +5 -0
- package/dist/editor/utils/cleanEmptyData.d.ts +18 -0
- package/dist/editor/utils/cleanNodeConfig.d.ts +5 -0
- package/dist/editor/utils/dagreLayout.d.ts +8 -0
- package/dist/editor/utils/edge.d.ts +50 -0
- package/dist/editor/utils/groupColor.d.ts +14 -0
- package/dist/editor/utils/image.d.ts +7 -0
- package/dist/editor/utils/inputTypeIcon.d.ts +6 -0
- package/dist/editor/utils/jsonBindTarget.d.ts +15 -0
- package/dist/editor/utils/openApiPayload.d.ts +12 -0
- package/dist/editor/utils/openapi.d.ts +35 -0
- package/dist/editor/utils/sensitiveHeaders.d.ts +20 -0
- package/dist/editor/utils/stackPositionIndex.d.ts +9 -0
- package/dist/editor-Dw_ODEe1.js +6507 -0
- package/dist/editor.js +3 -7
- package/dist/main.js +6 -52
- package/dist/renderer/context/TreegeRenderRuntimeProvider.d.ts +135 -0
- package/dist/renderer/context/TreegeRendererProvider.d.ts +15 -0
- package/dist/renderer/features/TreegeRenderer/native/TreegeRenderer.d.ts +19 -11
- package/dist/renderer/features/TreegeRenderer/native/components/DefaultFormWrapper.d.ts +7 -7
- package/dist/renderer/features/TreegeRenderer/native/components/DefaultInputLabel.d.ts +10 -0
- package/dist/renderer/features/TreegeRenderer/native/components/DefaultInputWrapper.d.ts +9 -0
- package/dist/renderer/features/TreegeRenderer/native/components/DefaultInputs.d.ts +20 -15
- package/dist/renderer/features/TreegeRenderer/native/components/DefaultLoadingSkeleton.d.ts +8 -0
- package/dist/renderer/features/TreegeRenderer/native/components/DefaultStep.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/DefaultSubmitButton.d.ts +9 -7
- package/dist/renderer/features/TreegeRenderer/native/components/DefaultSubmitButtonWrapper.d.ts +11 -0
- package/dist/renderer/features/TreegeRenderer/native/components/DefaultUI.d.ts +8 -7
- package/dist/renderer/features/TreegeRenderer/native/components/DependencyHint.d.ts +15 -0
- package/dist/renderer/features/TreegeRenderer/native/components/OptionItemContent.d.ts +17 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultAddressInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultAutocompleteInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultCheckboxInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultDateInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultDateRangeInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultFileInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultHiddenInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultHttpInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultNumberInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultPasswordInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultRadioInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultSelectInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultSubmitInput.d.ts +11 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultSwitchInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultTextInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultTextareaInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultTimeInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultTimeRangeInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/useTreegeRenderer.d.ts +97 -24
- package/dist/renderer/features/TreegeRenderer/web/TreegeRenderer.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/DefaultFormWrapper.d.ts +3 -2
- package/dist/renderer/features/TreegeRenderer/web/components/DefaultInputLabel.d.ts +9 -0
- package/dist/renderer/features/TreegeRenderer/web/components/DefaultInputWrapper.d.ts +9 -0
- package/dist/renderer/features/TreegeRenderer/web/components/DefaultLoadingSkeleton.d.ts +7 -0
- package/dist/renderer/features/TreegeRenderer/web/components/DefaultStep.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/web/components/DefaultSubmitButton.d.ts +5 -1
- package/dist/renderer/features/TreegeRenderer/web/components/DependencyHint.d.ts +22 -0
- package/dist/renderer/features/TreegeRenderer/web/components/OptionItemContent.d.ts +17 -0
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultAddressInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultAutocompleteInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultCheckboxInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultDateInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultDateRangeInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultFileInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultHiddenInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultHttpInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultNumberInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultPasswordInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultRadioInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultSelectInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultSubmitInput.d.ts +11 -0
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultSwitchInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultTextAreaInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultTextInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultTimeInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultTimeRangeInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/styles/RendererStyles.d.ts +2 -0
- package/dist/renderer/hooks/useInputOptions.d.ts +28 -0
- package/dist/renderer/hooks/useRenderNode.d.ts +62 -0
- package/dist/renderer/hooks/useSubmitHandler.d.ts +36 -0
- package/dist/renderer/hooks/useTranslate.d.ts +7 -5
- package/dist/renderer/index.d.ts +5 -2
- package/dist/renderer/index.native.d.ts +20 -0
- package/dist/renderer/types/renderer.d.ts +316 -42
- package/dist/renderer/utils/flow.d.ts +1 -18
- package/dist/renderer/utils/form.d.ts +54 -2
- package/dist/renderer/utils/http.d.ts +177 -0
- package/dist/renderer/utils/jsonTemplate.d.ts +30 -0
- package/dist/renderer/utils/node.d.ts +29 -1
- package/dist/renderer/utils/sanitize.d.ts +85 -0
- package/dist/renderer/utils/sanitize.native.d.ts +69 -0
- package/dist/renderer/utils/step.d.ts +27 -0
- package/dist/renderer/utils/submit.d.ts +49 -0
- package/dist/renderer/utils/templateDependencies.d.ts +17 -0
- package/dist/renderer-CN83AtIp.js +256 -0
- package/dist/renderer-native.d.ts +2 -0
- package/dist/renderer-native.js +3703 -0
- package/dist/renderer.js +5 -45
- package/dist/shared/components/ui/badge.d.ts +2 -2
- package/dist/shared/components/ui/button.d.ts +3 -3
- package/dist/shared/components/ui/collapsible.d.ts +1 -1
- package/dist/shared/components/ui/command.d.ts +1 -1
- package/dist/shared/components/ui/dropdown-menu.d.ts +1 -1
- package/dist/shared/components/ui/field.d.ts +24 -0
- package/dist/shared/components/ui/form.d.ts +1 -1
- package/dist/shared/components/ui/item.d.ts +23 -0
- package/dist/shared/components/ui/popover.d.ts +10 -2
- package/dist/shared/components/ui/select.d.ts +3 -1
- package/dist/shared/components/ui/sheet.d.ts +1 -1
- package/dist/shared/components/ui/skeleton.d.ts +3 -0
- package/dist/shared/components/ui/toggle-group.d.ts +7 -0
- package/dist/shared/components/ui/toggle.d.ts +9 -0
- package/dist/shared/components/ui/tooltip.d.ts +1 -1
- package/dist/shared/constants/colors.d.ts +45 -0
- package/dist/shared/constants/inputType.d.ts +6 -0
- package/dist/shared/constants/node.d.ts +0 -1
- package/dist/shared/context/PortalContainerContext.d.ts +5 -0
- package/dist/shared/context/ThemeContext.d.ts +2 -0
- package/dist/shared/context/ThemeContext.native.d.ts +22 -0
- package/dist/shared/hooks/useMediaQuery.d.ts +12 -0
- package/dist/shared/hooks/useThemeColors.d.ts +37 -0
- package/dist/shared/locales/ar.json.d.ts +258 -19
- package/dist/shared/locales/de.json.d.ts +259 -20
- package/dist/shared/locales/en.json.d.ts +260 -21
- package/dist/shared/locales/es.json.d.ts +259 -20
- package/dist/shared/locales/fr.json.d.ts +259 -20
- package/dist/shared/locales/it.json.d.ts +259 -20
- package/dist/shared/locales/pt.json.d.ts +259 -20
- package/dist/shared/types/edge.d.ts +6 -0
- package/dist/shared/types/node.d.ts +153 -18
- package/dist/shared/utils/httpRecord.d.ts +20 -0
- package/dist/shared/utils/inputTypeGuards.d.ts +7 -0
- package/dist/shared/utils/nodeTypeGuards.d.ts +1 -6
- package/dist/shared/utils/normalizeLabel.d.ts +21 -0
- package/dist/useRenderNode-BZ7fZJxT.js +527 -0
- package/package.json +54 -22
- package/dist/ThemeContext-BIvs8Kw-.js +0 -758
- package/dist/TreegeEditor-Lv5Tn9_F.js +0 -2152
- package/dist/TreegeRenderer-D3EvsEfJ.js +0 -1413
- package/dist/editor/context/TreegeEditorContext.d.ts +0 -12
- package/dist/editor/features/TreegeEditor/forms/FlowNodeForm.d.ts +0 -2
- package/dist/editor/features/TreegeEditor/inputs/SelectInputType.d.ts +0 -7
- package/dist/editor/features/TreegeEditor/nodes/FlowNode.d.ts +0 -6
- package/dist/editor/features/TreegeEditor/nodes/GroupNode.d.ts +0 -6
- package/dist/editor/features/TreegeEditor/nodes/InputNode.d.ts +0 -6
- package/dist/editor/features/TreegeEditor/nodes/UINode.d.ts +0 -6
- package/dist/editor/hooks/useEdgesSelection.d.ts +0 -11
- package/dist/renderer/context/TreegeConfigContext.d.ts +0 -39
- package/dist/renderer/context/TreegeRendererContext.d.ts +0 -25
- package/dist/renderer/features/TreegeRenderer/native/components/DefaultGroup.d.ts +0 -7
- package/dist/renderer/features/TreegeRenderer/web/components/DefaultGroup.d.ts +0 -6
- /package/dist/editor/components/{data-display/logo.d.ts → branding/Logo.d.ts} +0 -0
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Node } from '@xyflow/react';
|
|
2
|
-
import { FormEvent, ReactNode } from 'react';
|
|
2
|
+
import { ComponentType, FormEvent, ReactNode } from 'react';
|
|
3
3
|
import { SerializableFile } from '../utils/file';
|
|
4
|
-
import {
|
|
4
|
+
import { FlowStep } from '../utils/step';
|
|
5
|
+
import { Flow, GroupNodeData, HttpHeaders, InputNodeData, InputOption, InputType, TreegeNodeData, UINodeData, UIType } from '../../shared/types/node';
|
|
5
6
|
/**
|
|
6
7
|
* Type mapping for input values based on input type
|
|
7
8
|
*/
|
|
@@ -18,6 +19,7 @@ export type InputValueTypeMap = {
|
|
|
18
19
|
password: string;
|
|
19
20
|
radio: string;
|
|
20
21
|
select: string | string[];
|
|
22
|
+
submit: undefined;
|
|
21
23
|
switch: boolean;
|
|
22
24
|
text: string;
|
|
23
25
|
textarea: string;
|
|
@@ -28,33 +30,166 @@ export type InputValueTypeMap = {
|
|
|
28
30
|
* Form values stored during rendering
|
|
29
31
|
*/
|
|
30
32
|
export type FormValues = Record<string, any>;
|
|
33
|
+
export type Meta = {
|
|
34
|
+
httpResponse?: unknown;
|
|
35
|
+
};
|
|
31
36
|
/**
|
|
32
37
|
* Union of all possible input value types
|
|
33
38
|
*/
|
|
34
|
-
export type InputValue = string | number | boolean | string[] | SerializableFile | SerializableFile[] | [string, string] | [string | undefined, string | undefined] | null;
|
|
39
|
+
export type InputValue = string | number | boolean | string[] | SerializableFile | SerializableFile[] | [string, string] | [string | undefined, string | undefined] | null | undefined;
|
|
35
40
|
/**
|
|
36
|
-
*
|
|
37
|
-
* All form state is provided via props for easier custom component implementation
|
|
41
|
+
* A field the input's dynamic options depend on that is not yet filled.
|
|
38
42
|
*/
|
|
39
|
-
export type
|
|
40
|
-
|
|
43
|
+
export type MissingDependency = {
|
|
44
|
+
/**
|
|
45
|
+
* The referenced node id.
|
|
46
|
+
*/
|
|
47
|
+
id: string;
|
|
48
|
+
/**
|
|
49
|
+
* The referenced field's translated, end-user-facing label.
|
|
50
|
+
*/
|
|
51
|
+
label: string;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* HTML-spreadable props for an input control — safe to spread directly onto a
|
|
55
|
+
* DOM element: `<input {...field} />`. Intentionally excludes `label`,
|
|
56
|
+
* `helperText`, and `error` (not valid DOM attributes); those live in
|
|
57
|
+
* `InputExtraProps`.
|
|
58
|
+
*/
|
|
59
|
+
export type InputFieldProps<T extends InputType = InputType> = {
|
|
60
|
+
/**
|
|
61
|
+
* Unique field id (nodeId). Use for the element `id`.
|
|
62
|
+
*/
|
|
63
|
+
id: string;
|
|
41
64
|
/**
|
|
42
|
-
*
|
|
65
|
+
* Field name (resolved using priority: name > label > nodeId).
|
|
66
|
+
*/
|
|
67
|
+
name: string;
|
|
68
|
+
/**
|
|
69
|
+
* Current value of the input (typed by input type when T is specified).
|
|
43
70
|
*/
|
|
44
71
|
value: InputValueTypeMap[T];
|
|
45
72
|
/**
|
|
46
|
-
*
|
|
47
|
-
|
|
73
|
+
* Translated placeholder (already processed with current language).
|
|
74
|
+
*/
|
|
75
|
+
placeholder?: string;
|
|
76
|
+
/**
|
|
77
|
+
* Whether the field is required.
|
|
78
|
+
*/
|
|
79
|
+
required?: boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Set when the field has a validation error.
|
|
82
|
+
*/
|
|
83
|
+
"aria-invalid"?: boolean;
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Treege-specific props that are NOT DOM attributes: state setters, resolved
|
|
87
|
+
* translations, validation and runtime metadata. Passed as the second argument
|
|
88
|
+
* of an input renderer so the first one (`InputFieldProps`) stays spreadable.
|
|
89
|
+
*/
|
|
90
|
+
export type InputExtraProps<T extends InputType = InputType> = {
|
|
91
|
+
/**
|
|
92
|
+
* The node data for this input field.
|
|
93
|
+
*/
|
|
94
|
+
node: Node<InputNodeData>;
|
|
95
|
+
/**
|
|
96
|
+
* Function to update the input value.
|
|
97
|
+
* @param value - The new value (typed by input type when T is specified)
|
|
48
98
|
*/
|
|
49
99
|
setValue: (value: InputValueTypeMap[T]) => void;
|
|
50
100
|
/**
|
|
51
|
-
* Validation error message for this field (if any)
|
|
101
|
+
* Validation error message for this field (if any).
|
|
52
102
|
*/
|
|
53
103
|
error?: string;
|
|
104
|
+
/** Translated label (already processed with current language). */
|
|
105
|
+
label?: string;
|
|
106
|
+
/**
|
|
107
|
+
* Resolved input label component: the consumer's `components.inputLabel` when
|
|
108
|
+
* provided, otherwise the platform `DefaultInputLabel`. Default inputs render
|
|
109
|
+
* it as `<InputLabel label={label} required={node.data.required} htmlFor={id} />`;
|
|
110
|
+
* it renders nothing when no label is configured. Exposed so custom input
|
|
111
|
+
* renderers can reuse the same (overridable) label.
|
|
112
|
+
*/
|
|
113
|
+
InputLabel: InputLabelRenderer;
|
|
114
|
+
/**
|
|
115
|
+
* Translated helper text (already processed with current language).
|
|
116
|
+
*/
|
|
117
|
+
helperText?: string;
|
|
118
|
+
/**
|
|
119
|
+
* Fields this input's dynamic options depend on that are not yet filled
|
|
120
|
+
* (its unresolved `{{nodeId}}` template variables). Empty when none — use it
|
|
121
|
+
* to hint the user which fields to complete before this input can load.
|
|
122
|
+
*/
|
|
123
|
+
missingDependencies: MissingDependency[];
|
|
124
|
+
/**
|
|
125
|
+
* Missing required fields on form submit (for submit inputs).
|
|
126
|
+
*/
|
|
127
|
+
missingRequiredFields?: string[];
|
|
128
|
+
/**
|
|
129
|
+
* Whether the form is currently being submitted (for submit inputs).
|
|
130
|
+
*/
|
|
131
|
+
isSubmitting?: boolean;
|
|
132
|
+
/**
|
|
133
|
+
* Editor-only extension slot: when provided, option-based renderers (radio,
|
|
134
|
+
* checkbox) call this for each option to paint inline extras next to it
|
|
135
|
+
* (e.g. value preview, edit / delete buttons). `variant` is a renderer-side
|
|
136
|
+
* layout hint (e.g. `"card"` for radio cards). Returning `null` skips the
|
|
137
|
+
* slot for that option. Left undefined in runtime so the renderers stay
|
|
138
|
+
* runtime-pure.
|
|
139
|
+
*/
|
|
140
|
+
renderOptionExtras?: (option: {
|
|
141
|
+
option: InputOption;
|
|
142
|
+
index: number;
|
|
143
|
+
variant?: string;
|
|
144
|
+
}) => ReactNode;
|
|
145
|
+
/**
|
|
146
|
+
* Editor-only layout flag. When `true`, option-based renderers force their
|
|
147
|
+
* option labels to a single truncated line (block + max-w-full + truncate)
|
|
148
|
+
* and reserve room on the right for the `renderOptionExtras` overlay.
|
|
149
|
+
* Defaults to `false` (multi-line, runtime-pure).
|
|
150
|
+
*/
|
|
151
|
+
compactOptions?: boolean;
|
|
152
|
+
};
|
|
153
|
+
/**
|
|
154
|
+
* Props passed to an input renderer: the spreadable `field` props (DOM-safe, so
|
|
155
|
+
* `field` can be spread onto a control — `<input {...field} />`) and the Treege
|
|
156
|
+
* `extra` props (state setters, translations, metadata).
|
|
157
|
+
*/
|
|
158
|
+
export type InputRenderProps<T extends InputType = InputType> = {
|
|
159
|
+
field: InputFieldProps<T>;
|
|
160
|
+
extra: InputExtraProps<T>;
|
|
54
161
|
};
|
|
162
|
+
/**
|
|
163
|
+
* An input renderer — a React component, so it can use hooks and is rendered
|
|
164
|
+
* directly (`<Renderer field={field} extra={extra} />`) without a wrapper.
|
|
165
|
+
*/
|
|
166
|
+
export type InputRenderer<T extends InputType = InputType> = ComponentType<InputRenderProps<T>>;
|
|
55
167
|
export type UiRenderProps = {
|
|
56
168
|
node: Node<UINodeData>;
|
|
57
169
|
};
|
|
170
|
+
/**
|
|
171
|
+
* Props for the input label component shared by all default input renderers.
|
|
172
|
+
* `label` + `required` are platform-agnostic; the remaining fields are
|
|
173
|
+
* passthrough hints for the platform (web: `htmlFor`/`id`/`className`,
|
|
174
|
+
* native: `style`). Implementations should render nothing when `label` is empty
|
|
175
|
+
* so the technical node key never leaks into the form.
|
|
176
|
+
*/
|
|
177
|
+
export type InputLabelRenderProps = {
|
|
178
|
+
/** End-user-facing label. Render nothing when empty. */
|
|
179
|
+
label?: string;
|
|
180
|
+
/** Whether to render the required marker. */
|
|
181
|
+
required?: boolean;
|
|
182
|
+
/** Web: associates the label with the control. */
|
|
183
|
+
htmlFor?: string;
|
|
184
|
+
/** Web: id used for `aria-labelledby` on option groups. */
|
|
185
|
+
id?: string;
|
|
186
|
+
/** Web: extra class names. */
|
|
187
|
+
className?: string;
|
|
188
|
+
/** Native: extra style (typed loosely to avoid a react-native dependency here). */
|
|
189
|
+
style?: unknown;
|
|
190
|
+
};
|
|
191
|
+
/** Input label component (custom `components.inputLabel` or the platform default). */
|
|
192
|
+
export type InputLabelRenderer = ComponentType<InputLabelRenderProps>;
|
|
58
193
|
/**
|
|
59
194
|
* Props for UI/Group components (use useTreegeContext for state)
|
|
60
195
|
*/
|
|
@@ -66,7 +201,69 @@ export type NodeRenderProps = {
|
|
|
66
201
|
* Each input type gets its own properly typed InputRenderProps
|
|
67
202
|
*/
|
|
68
203
|
export type InputRenderers = {
|
|
69
|
-
[K in InputType]?:
|
|
204
|
+
[K in InputType]?: InputRenderer<K>;
|
|
205
|
+
};
|
|
206
|
+
/**
|
|
207
|
+
* Props passed to a step renderer. Steps are derived at runtime from the flow's
|
|
208
|
+
* groups: each contiguous slice of visible nodes sharing the same `parentId`
|
|
209
|
+
* (or no parent — orphan steps) becomes one step.
|
|
210
|
+
*/
|
|
211
|
+
export type StepRenderProps = {
|
|
212
|
+
/** The step being rendered (its group id and ordered child nodes). */
|
|
213
|
+
step: FlowStep;
|
|
214
|
+
/** Hidden group node carrying the step's metadata (label) — undefined for orphan steps. */
|
|
215
|
+
groupNode?: Node<GroupNodeData>;
|
|
216
|
+
/** Zero-based index of this step in the current step sequence. */
|
|
217
|
+
stepIndex: number;
|
|
218
|
+
/** Total number of steps currently visible. Recomputes when branching changes. */
|
|
219
|
+
totalSteps: number;
|
|
220
|
+
/** True when this is the first step (Back should be hidden/disabled). */
|
|
221
|
+
isFirstStep: boolean;
|
|
222
|
+
/**
|
|
223
|
+
* Whether a Back button should be shown. True on any step past the first, and
|
|
224
|
+
* also on the first step when the consumer passes an `onBack` prop (to bridge
|
|
225
|
+
* back-navigation to an outer flow, e.g. a parent modal's steps). Prefer this
|
|
226
|
+
* over `isFirstStep` to decide whether to render the Back control.
|
|
227
|
+
*/
|
|
228
|
+
canGoBack: boolean;
|
|
229
|
+
/**
|
|
230
|
+
* True when this is the last visible step. The renderer turns Continue
|
|
231
|
+
* into a submit action on the last step.
|
|
232
|
+
*/
|
|
233
|
+
isLastStep: boolean;
|
|
234
|
+
/** Whether all required visible inputs of the step are filled. */
|
|
235
|
+
canContinue: boolean;
|
|
236
|
+
/**
|
|
237
|
+
* True when the step contains an explicit `submit` input node. Such a node is
|
|
238
|
+
* declarative — it renders no button itself; the step renders the single
|
|
239
|
+
* submit button (reusing the node's label). Exposed for custom step
|
|
240
|
+
* implementations that need to know a submit node is present.
|
|
241
|
+
*/
|
|
242
|
+
hasSubmitInput?: boolean;
|
|
243
|
+
/**
|
|
244
|
+
* Translated labels of the current step's required fields still empty. Lines
|
|
245
|
+
* up with `canContinue`, so the action button can show a tooltip explaining
|
|
246
|
+
* why Continue/Submit is disabled — on every step, not just the last.
|
|
247
|
+
*/
|
|
248
|
+
missingFields?: string[];
|
|
249
|
+
/** Submission in progress (passed through from `useTreegeRenderer`). */
|
|
250
|
+
isSubmitting?: boolean;
|
|
251
|
+
/**
|
|
252
|
+
* Go back: advances to the previous step, or — on the first step, when the
|
|
253
|
+
* consumer passed an `onBack` prop — invokes that callback instead. No-op on
|
|
254
|
+
* the first step when no `onBack` prop was provided.
|
|
255
|
+
*/
|
|
256
|
+
onBack: () => void;
|
|
257
|
+
/**
|
|
258
|
+
* Advance to the next step (or trigger submit on the last step). The wrapper
|
|
259
|
+
* passes `isLastStep` so the implementation can decide between an in-flow
|
|
260
|
+
* advance and a form submit.
|
|
261
|
+
*/
|
|
262
|
+
onContinue: () => void;
|
|
263
|
+
/** Translated label of the group, or empty string for orphan steps. */
|
|
264
|
+
label?: string;
|
|
265
|
+
/** The rendered child nodes belonging to this step. */
|
|
266
|
+
children: ReactNode;
|
|
70
267
|
};
|
|
71
268
|
/**
|
|
72
269
|
* Custom renderer components
|
|
@@ -82,21 +279,42 @@ export type TreegeRendererComponents = {
|
|
|
82
279
|
*/
|
|
83
280
|
ui?: Partial<Record<UIType, (props: NodeRenderProps) => ReactNode>>;
|
|
84
281
|
/**
|
|
85
|
-
* Custom
|
|
282
|
+
* Custom input label, shared by every default input renderer. Receives
|
|
283
|
+
* `{ label, required, ...platformProps }` and should render nothing when
|
|
284
|
+
* `label` is empty. Defaults to `DefaultInputLabel` (web/native).
|
|
285
|
+
*/
|
|
286
|
+
inputLabel?: InputLabelRenderer;
|
|
287
|
+
/**
|
|
288
|
+
* Custom step renderer — wraps the current step's nodes and renders the
|
|
289
|
+
* Back/Continue navigation. Defaults are provided by `DefaultStep` (web/native).
|
|
86
290
|
*/
|
|
87
|
-
|
|
291
|
+
step?: (props: StepRenderProps) => ReactNode;
|
|
88
292
|
/**
|
|
89
|
-
* Custom form wrapper
|
|
293
|
+
* Custom form wrapper. `id` (when provided via the `formId` prop) should be
|
|
294
|
+
* forwarded to the underlying `<form>` element to keep external submit
|
|
295
|
+
* buttons working.
|
|
90
296
|
*/
|
|
91
297
|
form?: (props: {
|
|
92
298
|
children: ReactNode;
|
|
93
|
-
|
|
299
|
+
id?: string;
|
|
300
|
+
onSubmit: (e: FormEvent<HTMLFormElement>) => void;
|
|
94
301
|
}) => ReactNode;
|
|
95
302
|
/**
|
|
96
|
-
* Custom submit button (
|
|
303
|
+
* Custom submit button (supports both web and native variants)
|
|
304
|
+
* Web variant: { label?: string; disabled?: boolean; isSubmitting?: boolean; ...otherHTMLAttributes }
|
|
305
|
+
* Native variant: { children?: ReactNode; disabled?: boolean; isSubmitting?: boolean; onPress?: () => void }
|
|
97
306
|
*/
|
|
98
307
|
submitButton?: (props: {
|
|
99
308
|
label?: string;
|
|
309
|
+
disabled?: boolean;
|
|
310
|
+
isSubmitting?: boolean;
|
|
311
|
+
[key: string]: unknown;
|
|
312
|
+
} | {
|
|
313
|
+
children?: ReactNode;
|
|
314
|
+
disabled?: boolean;
|
|
315
|
+
isSubmitting?: boolean;
|
|
316
|
+
onPress?: () => void;
|
|
317
|
+
[key: string]: unknown;
|
|
100
318
|
}) => ReactNode;
|
|
101
319
|
/**
|
|
102
320
|
* Custom submit button wrapper (e.g., for tooltip with missing fields)
|
|
@@ -105,9 +323,14 @@ export type TreegeRendererComponents = {
|
|
|
105
323
|
children: ReactNode;
|
|
106
324
|
missingFields?: string[];
|
|
107
325
|
}) => ReactNode;
|
|
326
|
+
/**
|
|
327
|
+
* Custom loading skeleton, rendered in place of the form while the
|
|
328
|
+
* `isLoading` prop is true. Defaults to `DefaultLoadingSkeleton` (web).
|
|
329
|
+
*/
|
|
330
|
+
loadingSkeleton?: () => ReactNode;
|
|
108
331
|
};
|
|
109
332
|
/**
|
|
110
|
-
* Configuration options that can be set globally via
|
|
333
|
+
* Configuration options that can be set globally via TreegeRendererProvider
|
|
111
334
|
* or locally via TreegeRenderer config prop
|
|
112
335
|
*/
|
|
113
336
|
export type TreegeRendererConfig = {
|
|
@@ -115,6 +338,15 @@ export type TreegeRendererConfig = {
|
|
|
115
338
|
* Custom component renderers
|
|
116
339
|
*/
|
|
117
340
|
components?: TreegeRendererComponents;
|
|
341
|
+
/**
|
|
342
|
+
* Global HTTP headers applied to every request issued by the renderer
|
|
343
|
+
* (HTTP inputs, submit buttons). Field-level headers with the same key
|
|
344
|
+
* (case-insensitive) take precedence over these.
|
|
345
|
+
*
|
|
346
|
+
* @example
|
|
347
|
+
* headers={{ Authorization: `Bearer ${accessToken}` }}
|
|
348
|
+
*/
|
|
349
|
+
headers?: HttpHeaders;
|
|
118
350
|
/**
|
|
119
351
|
* Google Maps API key for address autocomplete
|
|
120
352
|
* If not provided, falls back to free Nominatim (OpenStreetMap)
|
|
@@ -135,53 +367,95 @@ export type TreegeRendererConfig = {
|
|
|
135
367
|
* @default "onSubmit"
|
|
136
368
|
*/
|
|
137
369
|
validationMode?: "onChange" | "onSubmit";
|
|
370
|
+
/**
|
|
371
|
+
* Whether to display the "Powered by Treege" credit at the bottom of the form.
|
|
372
|
+
* @default true
|
|
373
|
+
*/
|
|
374
|
+
showPoweredBy?: boolean;
|
|
375
|
+
/**
|
|
376
|
+
* Base URL prepended to every **relative** HTTP url issued by the renderer
|
|
377
|
+
* (HTTP inputs, dynamic options, and submit). Use this to keep the tree
|
|
378
|
+
* JSON environment-agnostic — store relative paths in the tree and supply
|
|
379
|
+
* the host here per environment:
|
|
380
|
+
*
|
|
381
|
+
* @example
|
|
382
|
+
* // In the tree: "url": "/v2/entities/{{nodeId}}/sub-entities"
|
|
383
|
+
* <TreegeRenderer flow={tree} baseUrl={import.meta.env.VITE_API_URL} />
|
|
384
|
+
*
|
|
385
|
+
* Absolute urls (starting with `http://` or `https://`) are left untouched,
|
|
386
|
+
* so a field can still point at an external API. Template variables are
|
|
387
|
+
* resolved first, then the base URL is applied to the result.
|
|
388
|
+
*/
|
|
389
|
+
baseUrl?: string;
|
|
138
390
|
};
|
|
139
391
|
/**
|
|
140
392
|
* Props for the TreegeRenderer component
|
|
393
|
+
*
|
|
394
|
+
* Inherits all configuration fields from TreegeRendererConfig (components,
|
|
395
|
+
* headers, googleApiKey, language, theme, validationMode) and adds the
|
|
396
|
+
* instance-specific ones (flow, callbacks, initial values, etc.).
|
|
141
397
|
*/
|
|
142
|
-
export
|
|
398
|
+
export interface TreegeRendererProps extends TreegeRendererConfig {
|
|
143
399
|
/**
|
|
144
|
-
*
|
|
400
|
+
* Additional class name for the renderer container
|
|
145
401
|
*/
|
|
146
|
-
|
|
402
|
+
className?: string;
|
|
147
403
|
/**
|
|
148
|
-
* Flow
|
|
149
|
-
* - If a single Flow: renders that flow
|
|
150
|
-
* - If an array: first flow is the main flow, others are sub-flows available for FlowNodes
|
|
404
|
+
* Flow to render. `null` / `undefined` renders nothing.
|
|
151
405
|
*/
|
|
152
|
-
|
|
406
|
+
flow?: Flow | null;
|
|
153
407
|
/**
|
|
154
|
-
*
|
|
155
|
-
*
|
|
408
|
+
* Sets the `id` attribute on the underlying `<form>` element, so a submit
|
|
409
|
+
* button rendered outside the renderer can target it via the native HTML
|
|
410
|
+
* `form` attribute: `<button type="submit" form={formId}>`. Web only.
|
|
156
411
|
*/
|
|
157
|
-
|
|
412
|
+
formId?: string;
|
|
158
413
|
/**
|
|
159
|
-
* Initial form values
|
|
414
|
+
* Initial form values — use this to pre-fill the form when editing a record
|
|
415
|
+
* that was already submitted.
|
|
416
|
+
*
|
|
417
|
+
* Keys can be either `node.id` OR the same name-based keys you receive back in
|
|
418
|
+
* `onChange` / `onSubmit`, so the previously-submitted object can be fed
|
|
419
|
+
* straight back in without any remapping.
|
|
420
|
+
*
|
|
421
|
+
* Reactive: if this changes after mount (e.g. an async-fetched record resolves
|
|
422
|
+
* later), the form is re-seeded automatically. A new object literal of
|
|
423
|
+
* identical content does NOT reset the form, so in-progress user edits are
|
|
424
|
+
* preserved.
|
|
160
425
|
*/
|
|
161
426
|
initialValues?: FormValues;
|
|
162
427
|
/**
|
|
163
|
-
*
|
|
428
|
+
* When true, renders a loading skeleton instead of the form. Useful while
|
|
429
|
+
* the flow is being fetched. Customizable via `components.loadingSkeleton`.
|
|
164
430
|
*/
|
|
165
|
-
|
|
431
|
+
isLoading?: boolean;
|
|
432
|
+
/**
|
|
433
|
+
* When true, forces the submit/continue button into its loading state
|
|
434
|
+
* (spinner + disabled). Use this to keep the button busy while an async
|
|
435
|
+
* `onSubmit` is still resolving on the consumer side. It is OR-ed with the
|
|
436
|
+
* renderer's own internal submitting state, so it only ever adds to it.
|
|
437
|
+
*/
|
|
438
|
+
isSubmitting?: boolean;
|
|
439
|
+
/**
|
|
440
|
+
* Called when the user clicks Back on the FIRST step. Provide this to bridge
|
|
441
|
+
* back-navigation to an outer flow (e.g. a parent modal's steps): when set, a
|
|
442
|
+
* Back button is shown on the first step and triggers this callback instead
|
|
443
|
+
* of being a no-op. Has no effect on later steps, which always navigate back
|
|
444
|
+
* internally.
|
|
445
|
+
*/
|
|
446
|
+
onBack?: () => void;
|
|
166
447
|
/**
|
|
167
448
|
* Callback when form values change
|
|
168
449
|
*/
|
|
169
450
|
onChange?: (values: FormValues) => void;
|
|
170
451
|
/**
|
|
171
452
|
* Callback when form is submitted
|
|
453
|
+
* @param values - Form values (keyed by field name or node ID)
|
|
454
|
+
* @param meta - Optional metadata about the submission (e.g., HTTP response data)
|
|
172
455
|
*/
|
|
173
|
-
onSubmit?: (values: FormValues) => void;
|
|
174
|
-
/**
|
|
175
|
-
* Theme for the renderer
|
|
176
|
-
* @default "dark"
|
|
177
|
-
*/
|
|
178
|
-
theme?: "dark" | "light";
|
|
456
|
+
onSubmit?: (values: FormValues, meta?: Meta) => void;
|
|
179
457
|
/**
|
|
180
458
|
* Custom validation function
|
|
181
459
|
*/
|
|
182
460
|
validate?: (values: FormValues, nodes: Node<TreegeNodeData>[]) => Record<string, string>;
|
|
183
|
-
|
|
184
|
-
* Validation mode
|
|
185
|
-
*/
|
|
186
|
-
validationMode?: "onChange" | "onSubmit";
|
|
187
|
-
};
|
|
461
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Edge, Node } from '@xyflow/react';
|
|
2
2
|
import { FormValues } from '../types/renderer';
|
|
3
3
|
import { ConditionalEdgeData } from '../../shared/types/edge';
|
|
4
|
-
import {
|
|
4
|
+
import { TreegeNodeData } from '../../shared/types/node';
|
|
5
5
|
/**
|
|
6
6
|
* Result from computing the flow render state
|
|
7
7
|
* Contains everything needed to render the form and determine its state
|
|
@@ -72,20 +72,3 @@ export declare const findStartNode: (nodes: Node<TreegeNodeData>[], edges: Edge[
|
|
|
72
72
|
* @returns Complete flow render state (visible nodes, end-of-path flag, etc.)
|
|
73
73
|
*/
|
|
74
74
|
export declare const getFlowRenderState: (nodes: Node<TreegeNodeData>[], edges: Edge<ConditionalEdgeData>[], formValues: FormValues) => FlowRenderState;
|
|
75
|
-
/**
|
|
76
|
-
* Merge multiple flows into a single flow by recursively replacing FlowNodes with their target flow's nodes
|
|
77
|
-
*
|
|
78
|
-
* This function takes a flow or an array of flows, automatically detects the main flow, then:
|
|
79
|
-
* 1. Replaces each FlowNode with the nodes from its target flow
|
|
80
|
-
* 2. Preserves the order of nodes by inserting sub-flow nodes at the FlowNode position
|
|
81
|
-
* 3. Redirects edges that point to FlowNodes to the first node of the target flow
|
|
82
|
-
* 4. Connects the last nodes of sub-flows to the nodes that followed the FlowNode
|
|
83
|
-
*
|
|
84
|
-
* Main flow detection:
|
|
85
|
-
* - The main flow is automatically identified as the one that references other flows but is not referenced itself
|
|
86
|
-
* - This allows flows to be passed in any order without breaking the merge logic
|
|
87
|
-
*
|
|
88
|
-
* @param flows - A single Flow or an array of flows (can be null/undefined)
|
|
89
|
-
* @returns A single merged Flow containing all nodes and edges
|
|
90
|
-
*/
|
|
91
|
-
export declare const mergeFlows: (flows?: Flow | Flow[] | null) => Flow;
|
|
@@ -17,10 +17,62 @@ export declare const isFieldEmpty: (value: unknown) => boolean;
|
|
|
17
17
|
* @returns True if the field has been filled (any value except undefined/null), false otherwise
|
|
18
18
|
*/
|
|
19
19
|
export declare const checkFormFieldHasValue: (fieldName: string | undefined, formValues: FormValues) => boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Resolve the default value for a single input node given the current form
|
|
22
|
+
* values. Mirrors the seeding rules used at mount:
|
|
23
|
+
* - `static`: returns the configured `staticValue`
|
|
24
|
+
* - `reference`: returns the (raw, untransformed) value of the referenced field
|
|
25
|
+
* if that field currently has a value
|
|
26
|
+
*
|
|
27
|
+
* Returns `undefined` when the node has no applicable default. The raw
|
|
28
|
+
* reference value is intentionally returned untransformed — transformations are
|
|
29
|
+
* handled separately by `calculateReferenceFieldUpdates`.
|
|
30
|
+
*
|
|
31
|
+
* @param node - The input node
|
|
32
|
+
* @param values - Current form values (keyed by node id)
|
|
33
|
+
* @returns The default value to apply, or `undefined`
|
|
34
|
+
*/
|
|
35
|
+
export declare const resolveNodeDefaultValue: (node: Node<InputNodeData>, values: FormValues) => unknown;
|
|
36
|
+
/**
|
|
37
|
+
* Build the initial (nodeId-keyed) form state from consumer-provided values.
|
|
38
|
+
*
|
|
39
|
+
* Consumers can pass `initialValues` keyed either by `node.id` OR by the same
|
|
40
|
+
* key shape they receive back in `onChange`/`onSubmit` (resolved via
|
|
41
|
+
* `resolveNodeKey`: name > label > node.id). This lets an edit screen feed the
|
|
42
|
+
* previously-submitted object straight back in without any remapping.
|
|
43
|
+
*
|
|
44
|
+
* After normalizing provided values, node `defaultValue`s (static / reference)
|
|
45
|
+
* are applied to any field still left unset — matching a fresh mount.
|
|
46
|
+
*
|
|
47
|
+
* @param initialValues - Values provided by the consumer (id- or name-keyed)
|
|
48
|
+
* @param inputNodes - All input nodes of the flow
|
|
49
|
+
* @returns Form values keyed strictly by node id
|
|
50
|
+
*/
|
|
51
|
+
export declare const buildInitialFormValues: (initialValues: FormValues, inputNodes: Node<InputNodeData>[]) => FormValues;
|
|
20
52
|
/**
|
|
21
53
|
* Convert internal form values (keyed by nodeId) to external format (keyed by name)
|
|
22
54
|
* When multiple nodes share the same name, later values overwrite earlier ones
|
|
23
|
-
*
|
|
24
|
-
*
|
|
55
|
+
* Priority for key naming: name > label (en) > nodeId
|
|
56
|
+
* example: convertFormValuesToNamedFormat({ id1: 'Alice', id2: 'Bob' }, [ { id: 'id1', data: { name: 'firstName' } }, { id: 'id2', data: { label: { en: 'Last Name' } } } ])
|
|
57
|
+
* returns { firstName: 'Alice', 'Last Name': 'Bob' }
|
|
25
58
|
*/
|
|
26
59
|
export declare const convertFormValuesToNamedFormat: (formValues: FormValues, nodes: Node<InputNodeData>[]) => Record<string, unknown>;
|
|
60
|
+
/**
|
|
61
|
+
* Apply transformation to a reference field value
|
|
62
|
+
* @param value - The source value to transform
|
|
63
|
+
* @param transformFunction - The transformation function to apply
|
|
64
|
+
* @param objectMapping - Optional mapping for toObject transformation
|
|
65
|
+
* @returns The transformed value
|
|
66
|
+
*/
|
|
67
|
+
export declare const applyReferenceTransformation: (value: unknown, transformFunction: "toString" | "toNumber" | "toBoolean" | "toArray" | "toObject" | null | undefined, objectMapping?: Array<{
|
|
68
|
+
sourceKey: string;
|
|
69
|
+
targetKey: string;
|
|
70
|
+
}>) => unknown;
|
|
71
|
+
/**
|
|
72
|
+
* Calculate updated values for fields with reference defaults
|
|
73
|
+
* @param inputNodes - Array of input nodes
|
|
74
|
+
* @param formValues - Current form values
|
|
75
|
+
* @param prevFormValues - Previous form values (for change detection)
|
|
76
|
+
* @returns Object containing fields that need to be updated
|
|
77
|
+
*/
|
|
78
|
+
export declare const calculateReferenceFieldUpdates: (inputNodes: Node<InputNodeData>[], formValues: FormValues, prevFormValues: FormValues) => FormValues;
|