treege 3.0.0-beta.6 → 3.0.0-beta.61
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 +425 -81
- package/dist/DefaultInputs-DamDWb5R.js +1988 -0
- package/dist/ThemeContext-cGSTk24y.js +1397 -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/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/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/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 +97 -10
- package/dist/editor/types/openapi.d.ts +81 -0
- package/dist/editor/utils/aiFlowGenerator.d.ts +5 -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/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-DtAQNPJm.js +6277 -0
- package/dist/editor.js +3 -7
- package/dist/main.js +4 -52
- package/dist/renderer/context/TreegeRenderRuntimeProvider.d.ts +135 -0
- package/dist/renderer/context/TreegeRendererProvider.d.ts +15 -0
- package/dist/renderer/features/TreegeRenderer/InputRendererHost.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/DefaultInputWrapper.d.ts +9 -0
- package/dist/renderer/features/TreegeRenderer/native/components/DefaultInputs.d.ts +21 -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/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 +94 -24
- package/dist/renderer/features/TreegeRenderer/web/TreegeRenderer.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/DefaultFormWrapper.d.ts +1 -1
- 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 +1 -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 +2 -2
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultAutocompleteInput.d.ts +2 -2
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultCheckboxInput.d.ts +2 -2
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultDateInput.d.ts +2 -2
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultDateRangeInput.d.ts +2 -2
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultFileInput.d.ts +2 -2
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultHiddenInput.d.ts +2 -2
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultHttpInput.d.ts +2 -2
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultNumberInput.d.ts +2 -2
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultPasswordInput.d.ts +2 -2
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultRadioInput.d.ts +2 -2
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultSelectInput.d.ts +2 -2
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultSubmitInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultSwitchInput.d.ts +2 -2
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultTextAreaInput.d.ts +2 -2
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultTextInput.d.ts +2 -2
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultTimeInput.d.ts +2 -2
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultTimeRangeInput.d.ts +2 -2
- 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 +58 -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 +4 -2
- package/dist/renderer/index.native.d.ts +19 -0
- package/dist/renderer/types/renderer.d.ts +211 -41
- package/dist/renderer/utils/flow.d.ts +1 -18
- package/dist/renderer/utils/form.d.ts +22 -2
- package/dist/renderer/utils/http.d.ts +161 -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-native.d.ts +2 -0
- package/dist/renderer-native.js +3736 -0
- package/dist/renderer.js +3 -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 +243 -19
- package/dist/shared/locales/de.json.d.ts +244 -20
- package/dist/shared/locales/en.json.d.ts +245 -21
- package/dist/shared/locales/es.json.d.ts +244 -20
- package/dist/shared/locales/fr.json.d.ts +244 -20
- package/dist/shared/locales/it.json.d.ts +244 -20
- package/dist/shared/locales/pt.json.d.ts +244 -20
- package/dist/shared/types/edge.d.ts +6 -0
- package/dist/shared/types/node.d.ts +140 -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/package.json +48 -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
2
|
import { 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,30 +30,124 @@ 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> = {
|
|
41
60
|
/**
|
|
42
|
-
*
|
|
61
|
+
* Unique field id (nodeId). Use for the element `id`.
|
|
62
|
+
*/
|
|
63
|
+
id: string;
|
|
64
|
+
/**
|
|
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
|
+
* Translated helper text (already processed with current language).
|
|
108
|
+
*/
|
|
109
|
+
helperText?: string;
|
|
110
|
+
/**
|
|
111
|
+
* Fields this input's dynamic options depend on that are not yet filled
|
|
112
|
+
* (its unresolved `{{nodeId}}` template variables). Empty when none — use it
|
|
113
|
+
* to hint the user which fields to complete before this input can load.
|
|
114
|
+
*/
|
|
115
|
+
missingDependencies: MissingDependency[];
|
|
116
|
+
/**
|
|
117
|
+
* Missing required fields on form submit (for submit inputs).
|
|
118
|
+
*/
|
|
119
|
+
missingRequiredFields?: string[];
|
|
120
|
+
/**
|
|
121
|
+
* Whether the form is currently being submitted (for submit inputs).
|
|
122
|
+
*/
|
|
123
|
+
isSubmitting?: boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Editor-only extension slot: when provided, option-based renderers (radio,
|
|
126
|
+
* checkbox) call this for each option to paint inline extras next to it
|
|
127
|
+
* (e.g. value preview, edit / delete buttons). `variant` is a renderer-side
|
|
128
|
+
* layout hint (e.g. `"card"` for radio cards). Returning `null` skips the
|
|
129
|
+
* slot for that option. Left undefined in runtime so the renderers stay
|
|
130
|
+
* runtime-pure.
|
|
131
|
+
*/
|
|
132
|
+
renderOptionExtras?: (option: {
|
|
133
|
+
option: InputOption;
|
|
134
|
+
index: number;
|
|
135
|
+
variant?: string;
|
|
136
|
+
}) => ReactNode;
|
|
137
|
+
/**
|
|
138
|
+
* Editor-only layout flag. When `true`, option-based renderers force their
|
|
139
|
+
* option labels to a single truncated line (block + max-w-full + truncate)
|
|
140
|
+
* and reserve room on the right for the `renderOptionExtras` overlay.
|
|
141
|
+
* Defaults to `false` (multi-line, runtime-pure).
|
|
142
|
+
*/
|
|
143
|
+
compactOptions?: boolean;
|
|
54
144
|
};
|
|
145
|
+
/**
|
|
146
|
+
* An input renderer. Receives the spreadable `field` props (DOM-safe) and the
|
|
147
|
+
* Treege `extra` props (state setters, translations, metadata) as two separate
|
|
148
|
+
* arguments, so `field` can be spread onto a control: `<input {...field} />`.
|
|
149
|
+
*/
|
|
150
|
+
export type InputRenderer<T extends InputType = InputType> = (field: InputFieldProps<T>, extra: InputExtraProps<T>) => ReactNode;
|
|
55
151
|
export type UiRenderProps = {
|
|
56
152
|
node: Node<UINodeData>;
|
|
57
153
|
};
|
|
@@ -66,7 +162,50 @@ export type NodeRenderProps = {
|
|
|
66
162
|
* Each input type gets its own properly typed InputRenderProps
|
|
67
163
|
*/
|
|
68
164
|
export type InputRenderers = {
|
|
69
|
-
[K in InputType]?:
|
|
165
|
+
[K in InputType]?: InputRenderer<K>;
|
|
166
|
+
};
|
|
167
|
+
/**
|
|
168
|
+
* Props passed to a step renderer. Steps are derived at runtime from the flow's
|
|
169
|
+
* groups: each contiguous slice of visible nodes sharing the same `parentId`
|
|
170
|
+
* (or no parent — orphan steps) becomes one step.
|
|
171
|
+
*/
|
|
172
|
+
export type StepRenderProps = {
|
|
173
|
+
/** The step being rendered (its group id and ordered child nodes). */
|
|
174
|
+
step: FlowStep;
|
|
175
|
+
/** Hidden group node carrying the step's metadata (label) — undefined for orphan steps. */
|
|
176
|
+
groupNode?: Node<GroupNodeData>;
|
|
177
|
+
/** Zero-based index of this step in the current step sequence. */
|
|
178
|
+
stepIndex: number;
|
|
179
|
+
/** Total number of steps currently visible. Recomputes when branching changes. */
|
|
180
|
+
totalSteps: number;
|
|
181
|
+
/** True when this is the first step (Back should be hidden/disabled). */
|
|
182
|
+
isFirstStep: boolean;
|
|
183
|
+
/**
|
|
184
|
+
* True when this is the last visible step. The renderer turns Continue
|
|
185
|
+
* into a submit action on the last step.
|
|
186
|
+
*/
|
|
187
|
+
isLastStep: boolean;
|
|
188
|
+
/** Whether all required visible inputs of the step are filled. */
|
|
189
|
+
canContinue: boolean;
|
|
190
|
+
/**
|
|
191
|
+
* Translated labels of required fields still empty. Only populated on the
|
|
192
|
+
* last step so the step can show a tooltip explaining why submit is disabled.
|
|
193
|
+
*/
|
|
194
|
+
missingFields?: string[];
|
|
195
|
+
/** Submission in progress (passed through from `useTreegeRenderer`). */
|
|
196
|
+
isSubmitting?: boolean;
|
|
197
|
+
/** Advance to the previous step. No-op on the first step. */
|
|
198
|
+
onBack: () => void;
|
|
199
|
+
/**
|
|
200
|
+
* Advance to the next step (or trigger submit on the last step). The wrapper
|
|
201
|
+
* passes `isLastStep` so the implementation can decide between an in-flow
|
|
202
|
+
* advance and a form submit.
|
|
203
|
+
*/
|
|
204
|
+
onContinue: () => void;
|
|
205
|
+
/** Translated label of the group, or empty string for orphan steps. */
|
|
206
|
+
label?: string;
|
|
207
|
+
/** The rendered child nodes belonging to this step. */
|
|
208
|
+
children: ReactNode;
|
|
70
209
|
};
|
|
71
210
|
/**
|
|
72
211
|
* Custom renderer components
|
|
@@ -82,21 +221,32 @@ export type TreegeRendererComponents = {
|
|
|
82
221
|
*/
|
|
83
222
|
ui?: Partial<Record<UIType, (props: NodeRenderProps) => ReactNode>>;
|
|
84
223
|
/**
|
|
85
|
-
* Custom
|
|
224
|
+
* Custom step renderer — wraps the current step's nodes and renders the
|
|
225
|
+
* Back/Continue navigation. Defaults are provided by `DefaultStep` (web/native).
|
|
86
226
|
*/
|
|
87
|
-
|
|
227
|
+
step?: (props: StepRenderProps) => ReactNode;
|
|
88
228
|
/**
|
|
89
229
|
* Custom form wrapper
|
|
90
230
|
*/
|
|
91
231
|
form?: (props: {
|
|
92
232
|
children: ReactNode;
|
|
93
|
-
onSubmit: (e: FormEvent) => void;
|
|
233
|
+
onSubmit: (e: FormEvent<HTMLFormElement>) => void;
|
|
94
234
|
}) => ReactNode;
|
|
95
235
|
/**
|
|
96
|
-
* Custom submit button (
|
|
236
|
+
* Custom submit button (supports both web and native variants)
|
|
237
|
+
* Web variant: { label?: string; disabled?: boolean; ...otherHTMLAttributes }
|
|
238
|
+
* Native variant: { children?: ReactNode; disabled?: boolean; isSubmitting?: boolean; onPress?: () => void }
|
|
97
239
|
*/
|
|
98
240
|
submitButton?: (props: {
|
|
99
241
|
label?: string;
|
|
242
|
+
disabled?: boolean;
|
|
243
|
+
[key: string]: unknown;
|
|
244
|
+
} | {
|
|
245
|
+
children?: ReactNode;
|
|
246
|
+
disabled?: boolean;
|
|
247
|
+
isSubmitting?: boolean;
|
|
248
|
+
onPress?: () => void;
|
|
249
|
+
[key: string]: unknown;
|
|
100
250
|
}) => ReactNode;
|
|
101
251
|
/**
|
|
102
252
|
* Custom submit button wrapper (e.g., for tooltip with missing fields)
|
|
@@ -105,9 +255,14 @@ export type TreegeRendererComponents = {
|
|
|
105
255
|
children: ReactNode;
|
|
106
256
|
missingFields?: string[];
|
|
107
257
|
}) => ReactNode;
|
|
258
|
+
/**
|
|
259
|
+
* Custom loading skeleton, rendered in place of the form while the
|
|
260
|
+
* `isLoading` prop is true. Defaults to `DefaultLoadingSkeleton` (web).
|
|
261
|
+
*/
|
|
262
|
+
loadingSkeleton?: () => ReactNode;
|
|
108
263
|
};
|
|
109
264
|
/**
|
|
110
|
-
* Configuration options that can be set globally via
|
|
265
|
+
* Configuration options that can be set globally via TreegeRendererProvider
|
|
111
266
|
* or locally via TreegeRenderer config prop
|
|
112
267
|
*/
|
|
113
268
|
export type TreegeRendererConfig = {
|
|
@@ -115,6 +270,15 @@ export type TreegeRendererConfig = {
|
|
|
115
270
|
* Custom component renderers
|
|
116
271
|
*/
|
|
117
272
|
components?: TreegeRendererComponents;
|
|
273
|
+
/**
|
|
274
|
+
* Global HTTP headers applied to every request issued by the renderer
|
|
275
|
+
* (HTTP inputs, submit buttons). Field-level headers with the same key
|
|
276
|
+
* (case-insensitive) take precedence over these.
|
|
277
|
+
*
|
|
278
|
+
* @example
|
|
279
|
+
* headers={{ Authorization: `Bearer ${accessToken}` }}
|
|
280
|
+
*/
|
|
281
|
+
headers?: HttpHeaders;
|
|
118
282
|
/**
|
|
119
283
|
* Google Maps API key for address autocomplete
|
|
120
284
|
* If not provided, falls back to free Nominatim (OpenStreetMap)
|
|
@@ -135,53 +299,59 @@ export type TreegeRendererConfig = {
|
|
|
135
299
|
* @default "onSubmit"
|
|
136
300
|
*/
|
|
137
301
|
validationMode?: "onChange" | "onSubmit";
|
|
302
|
+
/**
|
|
303
|
+
* Base URL prepended to every **relative** HTTP url issued by the renderer
|
|
304
|
+
* (HTTP inputs, dynamic options, and submit). Use this to keep the tree
|
|
305
|
+
* JSON environment-agnostic — store relative paths in the tree and supply
|
|
306
|
+
* the host here per environment:
|
|
307
|
+
*
|
|
308
|
+
* @example
|
|
309
|
+
* // In the tree: "url": "/v2/entities/{{nodeId}}/sub-entities"
|
|
310
|
+
* <TreegeRenderer flow={tree} baseUrl={import.meta.env.VITE_API_URL} />
|
|
311
|
+
*
|
|
312
|
+
* Absolute urls (starting with `http://` or `https://`) are left untouched,
|
|
313
|
+
* so a field can still point at an external API. Template variables are
|
|
314
|
+
* resolved first, then the base URL is applied to the result.
|
|
315
|
+
*/
|
|
316
|
+
baseUrl?: string;
|
|
138
317
|
};
|
|
139
318
|
/**
|
|
140
319
|
* Props for the TreegeRenderer component
|
|
320
|
+
*
|
|
321
|
+
* Inherits all configuration fields from TreegeRendererConfig (components,
|
|
322
|
+
* headers, googleApiKey, language, theme, validationMode) and adds the
|
|
323
|
+
* instance-specific ones (flow, callbacks, initial values, etc.).
|
|
141
324
|
*/
|
|
142
|
-
export
|
|
325
|
+
export interface TreegeRendererProps extends TreegeRendererConfig {
|
|
143
326
|
/**
|
|
144
|
-
*
|
|
327
|
+
* Additional class name for the renderer container
|
|
145
328
|
*/
|
|
146
|
-
|
|
329
|
+
className?: string;
|
|
147
330
|
/**
|
|
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
|
|
331
|
+
* Flow to render. `null` / `undefined` renders nothing.
|
|
151
332
|
*/
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* Google Maps API key for address autocomplete
|
|
155
|
-
* If not provided, falls back to free Nominatim (OpenStreetMap)
|
|
156
|
-
*/
|
|
157
|
-
googleApiKey?: string;
|
|
333
|
+
flow?: Flow | null;
|
|
158
334
|
/**
|
|
159
335
|
* Initial form values
|
|
160
336
|
*/
|
|
161
337
|
initialValues?: FormValues;
|
|
162
338
|
/**
|
|
163
|
-
*
|
|
339
|
+
* When true, renders a loading skeleton instead of the form. Useful while
|
|
340
|
+
* the flow is being fetched. Customizable via `components.loadingSkeleton`.
|
|
164
341
|
*/
|
|
165
|
-
|
|
342
|
+
isLoading?: boolean;
|
|
166
343
|
/**
|
|
167
344
|
* Callback when form values change
|
|
168
345
|
*/
|
|
169
346
|
onChange?: (values: FormValues) => void;
|
|
170
347
|
/**
|
|
171
348
|
* Callback when form is submitted
|
|
349
|
+
* @param values - Form values (keyed by field name or node ID)
|
|
350
|
+
* @param meta - Optional metadata about the submission (e.g., HTTP response data)
|
|
172
351
|
*/
|
|
173
|
-
onSubmit?: (values: FormValues) => void;
|
|
174
|
-
/**
|
|
175
|
-
* Theme for the renderer
|
|
176
|
-
* @default "dark"
|
|
177
|
-
*/
|
|
178
|
-
theme?: "dark" | "light";
|
|
352
|
+
onSubmit?: (values: FormValues, meta?: Meta) => void;
|
|
179
353
|
/**
|
|
180
354
|
* Custom validation function
|
|
181
355
|
*/
|
|
182
356
|
validate?: (values: FormValues, nodes: Node<TreegeNodeData>[]) => Record<string, string>;
|
|
183
|
-
|
|
184
|
-
* Validation mode
|
|
185
|
-
*/
|
|
186
|
-
validationMode?: "onChange" | "onSubmit";
|
|
187
|
-
};
|
|
357
|
+
}
|
|
@@ -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;
|
|
@@ -20,7 +20,27 @@ export declare const checkFormFieldHasValue: (fieldName: string | undefined, for
|
|
|
20
20
|
/**
|
|
21
21
|
* Convert internal form values (keyed by nodeId) to external format (keyed by name)
|
|
22
22
|
* When multiple nodes share the same name, later values overwrite earlier ones
|
|
23
|
-
*
|
|
24
|
-
*
|
|
23
|
+
* Priority for key naming: name > label (en) > nodeId
|
|
24
|
+
* example: convertFormValuesToNamedFormat({ id1: 'Alice', id2: 'Bob' }, [ { id: 'id1', data: { name: 'firstName' } }, { id: 'id2', data: { label: { en: 'Last Name' } } } ])
|
|
25
|
+
* returns { firstName: 'Alice', 'Last Name': 'Bob' }
|
|
25
26
|
*/
|
|
26
27
|
export declare const convertFormValuesToNamedFormat: (formValues: FormValues, nodes: Node<InputNodeData>[]) => Record<string, unknown>;
|
|
28
|
+
/**
|
|
29
|
+
* Apply transformation to a reference field value
|
|
30
|
+
* @param value - The source value to transform
|
|
31
|
+
* @param transformFunction - The transformation function to apply
|
|
32
|
+
* @param objectMapping - Optional mapping for toObject transformation
|
|
33
|
+
* @returns The transformed value
|
|
34
|
+
*/
|
|
35
|
+
export declare const applyReferenceTransformation: (value: unknown, transformFunction: "toString" | "toNumber" | "toBoolean" | "toArray" | "toObject" | null | undefined, objectMapping?: Array<{
|
|
36
|
+
sourceKey: string;
|
|
37
|
+
targetKey: string;
|
|
38
|
+
}>) => unknown;
|
|
39
|
+
/**
|
|
40
|
+
* Calculate updated values for fields with reference defaults
|
|
41
|
+
* @param inputNodes - Array of input nodes
|
|
42
|
+
* @param formValues - Current form values
|
|
43
|
+
* @param prevFormValues - Previous form values (for change detection)
|
|
44
|
+
* @returns Object containing fields that need to be updated
|
|
45
|
+
*/
|
|
46
|
+
export declare const calculateReferenceFieldUpdates: (inputNodes: Node<InputNodeData>[], formValues: FormValues, prevFormValues: FormValues) => FormValues;
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { FormValues } from '../types/renderer';
|
|
2
|
+
import { HttpHeaders, InputOption, OptionsSourceMapping, QueryParams } 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: (HttpHeaders | undefined)[]) => HttpHeaders;
|
|
10
|
+
/**
|
|
11
|
+
* Resolve `{{templateVar}}` placeholders in every value of a header/query-param
|
|
12
|
+
* record, leaving the keys untouched. Returns `undefined` for `undefined` so
|
|
13
|
+
* callers can pass the result straight into `mergeHttpHeaders`/`makeHttpRequest`.
|
|
14
|
+
*/
|
|
15
|
+
export declare const resolveTemplateRecord: (record: Record<string, string> | undefined, values: FormValues, options?: {
|
|
16
|
+
encode?: boolean;
|
|
17
|
+
json?: boolean;
|
|
18
|
+
}) => Record<string, string> | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* Append query parameters to a URL. Entries with an empty key are skipped,
|
|
21
|
+
* keys and values are URL-encoded, and `?` or `&` is chosen automatically
|
|
22
|
+
* based on whether the URL already has a query string. Values are expected
|
|
23
|
+
* to already have their template variables resolved.
|
|
24
|
+
*/
|
|
25
|
+
export declare const appendQueryParams: (url: string, params?: QueryParams) => string;
|
|
26
|
+
/**
|
|
27
|
+
* Prepend a base URL to a relative URL. Absolute urls (starting with
|
|
28
|
+
* `http://` or `https://`, case-insensitive) and protocol-relative urls
|
|
29
|
+
* (`//host/...`) are returned untouched, so individual fields can still
|
|
30
|
+
* target an external API. A single slash is enforced at the join so a
|
|
31
|
+
* trailing slash on the base and/or a leading slash on the path don't
|
|
32
|
+
* produce `//`. When no base URL is configured, the url is returned as-is.
|
|
33
|
+
*
|
|
34
|
+
* Expects the url to already have its template variables resolved.
|
|
35
|
+
*/
|
|
36
|
+
export declare const resolveUrl: (url: string, baseUrl?: string) => string;
|
|
37
|
+
/**
|
|
38
|
+
* Result of an HTTP request
|
|
39
|
+
*/
|
|
40
|
+
export interface HttpRequestResult {
|
|
41
|
+
/**
|
|
42
|
+
* Whether the request was successful (2xx status code)
|
|
43
|
+
*/
|
|
44
|
+
success: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Response data (parsed JSON or raw text)
|
|
47
|
+
*/
|
|
48
|
+
data?: unknown;
|
|
49
|
+
/**
|
|
50
|
+
* Error message if request failed
|
|
51
|
+
*/
|
|
52
|
+
error?: string;
|
|
53
|
+
/**
|
|
54
|
+
* HTTP status code
|
|
55
|
+
*/
|
|
56
|
+
status?: number;
|
|
57
|
+
/**
|
|
58
|
+
* HTTP status text
|
|
59
|
+
*/
|
|
60
|
+
statusText?: string;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Options for making an HTTP request
|
|
64
|
+
*/
|
|
65
|
+
export interface HttpRequestOptions {
|
|
66
|
+
/**
|
|
67
|
+
* The URL to call (should already have variables replaced)
|
|
68
|
+
*/
|
|
69
|
+
url: string;
|
|
70
|
+
/**
|
|
71
|
+
* HTTP method
|
|
72
|
+
*/
|
|
73
|
+
method?: "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
|
|
74
|
+
/**
|
|
75
|
+
* Request headers
|
|
76
|
+
*/
|
|
77
|
+
headers?: HttpHeaders;
|
|
78
|
+
/**
|
|
79
|
+
* Query parameters appended to the URL (values should already have their
|
|
80
|
+
* template variables resolved; keys/values are URL-encoded here)
|
|
81
|
+
*/
|
|
82
|
+
queryParams?: QueryParams;
|
|
83
|
+
/**
|
|
84
|
+
* Request body (for POST/PUT/PATCH)
|
|
85
|
+
*/
|
|
86
|
+
body?: string;
|
|
87
|
+
/**
|
|
88
|
+
* Optional abort signal to cancel the request
|
|
89
|
+
*/
|
|
90
|
+
signal?: AbortSignal;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Make an HTTP request with common error handling and response parsing
|
|
94
|
+
*
|
|
95
|
+
* This is a shared utility used by both HTTP inputs and submit buttons
|
|
96
|
+
* to ensure consistent behavior across the library.
|
|
97
|
+
*
|
|
98
|
+
* @param options - Request options
|
|
99
|
+
* @returns Promise with request result
|
|
100
|
+
*/
|
|
101
|
+
export declare const makeHttpRequest: (options: HttpRequestOptions) => Promise<HttpRequestResult>;
|
|
102
|
+
/**
|
|
103
|
+
* Replace template variables in a string with actual values from form data
|
|
104
|
+
*
|
|
105
|
+
* Uses {{fieldId}} syntax for all replacements (URLs, JSON bodies, etc.)
|
|
106
|
+
*
|
|
107
|
+
* Smart JSON handling:
|
|
108
|
+
* - Strings: automatically wrapped in quotes and escaped
|
|
109
|
+
* - Numbers/Booleans: converted to JSON-safe format
|
|
110
|
+
* - Arrays/Objects: JSON.stringify
|
|
111
|
+
*
|
|
112
|
+
* @param template - The template string containing variables
|
|
113
|
+
* @param values - Form values to substitute
|
|
114
|
+
* @param options - Replacement options
|
|
115
|
+
* @param options.encode - Whether to URL-encode the replaced values (for URLs)
|
|
116
|
+
* @param options.json - Whether to use smart JSON handling (for request bodies)
|
|
117
|
+
* @returns The string with variables replaced
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* // For URLs (with encoding)
|
|
121
|
+
* replaceTemplateVariables("https://api.com/users/{{userId}}", { userId: "john doe" }, { encode: true })
|
|
122
|
+
* // => "https://api.com/users/john%20doe"
|
|
123
|
+
*
|
|
124
|
+
* // For JSON bodies (smart handling)
|
|
125
|
+
* replaceTemplateVariables('{"name": {{userName}}}', { userName: "John" }, { json: true })
|
|
126
|
+
* // => '{"name": "John"}'
|
|
127
|
+
*
|
|
128
|
+
* replaceTemplateVariables('{"age": {{userAge}}}', { userAge: 25 }, { json: true })
|
|
129
|
+
* // => '{"age": 25}'
|
|
130
|
+
*/
|
|
131
|
+
export declare const replaceTemplateVariables: (template: string | undefined, values: FormValues, options?: {
|
|
132
|
+
encode?: boolean;
|
|
133
|
+
json?: boolean;
|
|
134
|
+
}) => string;
|
|
135
|
+
/**
|
|
136
|
+
* Replace template variables in response data (for redirect URLs)
|
|
137
|
+
*
|
|
138
|
+
* Supports {{response.field}} format to access response data
|
|
139
|
+
*
|
|
140
|
+
* @param template - The template string containing variables
|
|
141
|
+
* @param responseData - Response data object
|
|
142
|
+
* @returns The string with variables replaced
|
|
143
|
+
*/
|
|
144
|
+
export declare const replaceResponseVariables: (template: string | undefined, responseData: unknown) => string;
|
|
145
|
+
/**
|
|
146
|
+
* Extract a value from an object using a path that supports dot notation
|
|
147
|
+
* and array indexing. Examples:
|
|
148
|
+
* - "data.users" → obj.data.users
|
|
149
|
+
* - "results[0].name" → obj.results[0].name
|
|
150
|
+
*
|
|
151
|
+
* @param obj - The object to extract value from
|
|
152
|
+
* @param path - The path expression (empty string returns the object as-is)
|
|
153
|
+
* @returns The value at the path, or undefined if not found
|
|
154
|
+
*/
|
|
155
|
+
export declare const getValueByPath: (obj: unknown, path: string) => unknown;
|
|
156
|
+
/**
|
|
157
|
+
* Project a list-shaped HTTP response into InputOption objects, applying
|
|
158
|
+
* a field-to-property mapping. Returns an empty array when the data is not
|
|
159
|
+
* iterable or required fields are missing.
|
|
160
|
+
*/
|
|
161
|
+
export declare const extractOptionsFromResponse: (response: unknown, responsePath: string | undefined, mapping: OptionsSourceMapping) => InputOption[];
|
|
@@ -6,9 +6,37 @@ import { InputNodeData, TreegeNodeData } from '../../shared/types/node';
|
|
|
6
6
|
* @returns Array of input nodes only
|
|
7
7
|
*/
|
|
8
8
|
export declare const getInputNodes: (nodes: Node<TreegeNodeData>[]) => Node<InputNodeData>[];
|
|
9
|
+
/**
|
|
10
|
+
* Resolve the key name for an input node using priority: name > label (en) > nodeId
|
|
11
|
+
* This is the single source of truth for key resolution across the application
|
|
12
|
+
* @param node - The input node
|
|
13
|
+
* @returns The resolved key (name, label, or node ID)
|
|
14
|
+
*/
|
|
15
|
+
export declare const resolveNodeKey: (node: Node<InputNodeData>) => string;
|
|
16
|
+
/**
|
|
17
|
+
* Resolve a human, end-user-facing label for an input node, preferring the
|
|
18
|
+
* translated `label` for the given language over the technical `name`. Used
|
|
19
|
+
* when surfacing field references to users (e.g. dependency hints). Priority:
|
|
20
|
+
* translated label > name > node id. This differs from `resolveNodeKey`, which
|
|
21
|
+
* prioritizes `name` for form-submission keys.
|
|
22
|
+
* @param node - The input node
|
|
23
|
+
* @param language - The current language code
|
|
24
|
+
* @returns The resolved display label
|
|
25
|
+
*/
|
|
26
|
+
export declare const resolveNodeLabel: (node: Node<InputNodeData>, language: string) => string;
|
|
27
|
+
/**
|
|
28
|
+
* Resolve the placeholder text for an input, falling back to the static
|
|
29
|
+
* "newAnswer" translation for textfield-like types when the user has not
|
|
30
|
+
* defined a placeholder for the current language.
|
|
31
|
+
* @param data - The input node data
|
|
32
|
+
* @param language - The current language code
|
|
33
|
+
* @returns The resolved placeholder string (empty string if none available)
|
|
34
|
+
*/
|
|
35
|
+
export declare const resolveInputPlaceholder: (data: InputNodeData, language: string) => string;
|
|
9
36
|
/**
|
|
10
37
|
* Get the field name (DOM name attribute) for a given node ID
|
|
11
|
-
*
|
|
38
|
+
* Priority: name > label (en) > nodeId
|
|
39
|
+
* This must match the logic in convertFormValuesToNamedFormat for consistency
|
|
12
40
|
* @param nodeId - The ID of the input node
|
|
13
41
|
* @param nodes - Array of input nodes
|
|
14
42
|
* @returns The field name to use in the DOM, or undefined if node not found
|