treege 3.0.0-beta.56 → 3.0.0-beta.58
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/README.md +33 -10
- package/dist/DefaultInputs-Dr3R5r53.js +1881 -0
- package/dist/ThemeContext-DrI5HTYl.js +1402 -0
- package/dist/editor/context/TreegeEditorContext.d.ts +8 -1
- package/dist/editor/features/TreegeEditor/TreegeEditor.d.ts +1 -1
- package/dist/editor/features/TreegeEditor/forms/SensitiveHeaderWarning.d.ts +13 -0
- package/dist/editor/features/TreegeEditor/inputs/ApiUrlCombobox.d.ts +0 -10
- package/dist/editor/types/editor.d.ts +35 -4
- package/dist/editor/utils/cleanNodeConfig.d.ts +5 -0
- package/dist/editor/utils/sensitiveHeaders.d.ts +15 -0
- package/dist/editor-BhL3w_KP.js +6251 -0
- package/dist/editor.js +2 -2
- package/dist/main.js +4 -4
- package/dist/renderer/context/TreegeRendererContext.d.ts +12 -0
- package/dist/renderer/features/TreegeRenderer/InputRendererHost.d.ts +15 -0
- package/dist/renderer/features/TreegeRenderer/native/components/DefaultInputs.d.ts +2 -2
- package/dist/renderer/features/TreegeRenderer/native/components/DependencyHint.d.ts +15 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultAddressInput.d.ts +2 -2
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultAutocompleteInput.d.ts +2 -2
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultCheckboxInput.d.ts +2 -2
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultDateInput.d.ts +2 -2
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultDateRangeInput.d.ts +2 -2
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultFileInput.d.ts +2 -2
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultHiddenInput.d.ts +2 -2
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultHttpInput.d.ts +2 -2
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultNumberInput.d.ts +2 -2
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultPasswordInput.d.ts +2 -2
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultRadioInput.d.ts +2 -2
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultSelectInput.d.ts +2 -2
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultSwitchInput.d.ts +2 -2
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultTextInput.d.ts +2 -2
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultTextareaInput.d.ts +2 -2
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultTimeInput.d.ts +2 -2
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultTimeRangeInput.d.ts +2 -2
- package/dist/renderer/features/TreegeRenderer/useTreegeRenderer.d.ts +20 -19
- package/dist/renderer/features/TreegeRenderer/web/TreegeRenderer.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/DependencyHint.d.ts +22 -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 +2 -2
- 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/hooks/useRenderNode.d.ts +2 -1
- package/dist/renderer/hooks/useSubmitHandler.d.ts +2 -1
- package/dist/renderer/types/renderer.d.ts +77 -23
- package/dist/renderer/utils/http.d.ts +11 -0
- package/dist/renderer/utils/node.d.ts +11 -0
- package/dist/renderer/utils/submit.d.ts +2 -1
- package/dist/renderer/utils/templateDependencies.d.ts +17 -0
- package/dist/renderer-native.js +1333 -1280
- package/dist/renderer.js +3 -3
- package/dist/shared/constants/inputType.d.ts +5 -0
- package/dist/shared/locales/ar.json.d.ts +15 -2
- package/dist/shared/locales/de.json.d.ts +15 -2
- package/dist/shared/locales/en.json.d.ts +15 -2
- package/dist/shared/locales/es.json.d.ts +15 -2
- package/dist/shared/locales/fr.json.d.ts +15 -2
- package/dist/shared/locales/it.json.d.ts +15 -2
- package/dist/shared/locales/pt.json.d.ts +15 -2
- package/package.json +1 -1
- package/dist/DefaultInputs-DklwwMaZ.js +0 -1807
- package/dist/ThemeContext-DAMkr9gW.js +0 -1362
- package/dist/editor-uMYOjG2i.js +0 -6079
|
@@ -38,54 +38,87 @@ export type Meta = {
|
|
|
38
38
|
*/
|
|
39
39
|
export type InputValue = string | number | boolean | string[] | SerializableFile | SerializableFile[] | [string, string] | [string | undefined, string | undefined] | null | undefined;
|
|
40
40
|
/**
|
|
41
|
-
*
|
|
42
|
-
* 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.
|
|
43
42
|
*/
|
|
44
|
-
export type
|
|
43
|
+
export type MissingDependency = {
|
|
45
44
|
/**
|
|
46
|
-
* The node
|
|
45
|
+
* The referenced node id.
|
|
47
46
|
*/
|
|
48
|
-
|
|
47
|
+
id: string;
|
|
49
48
|
/**
|
|
50
|
-
*
|
|
49
|
+
* The referenced field's translated, end-user-facing label.
|
|
51
50
|
*/
|
|
52
|
-
|
|
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> = {
|
|
53
60
|
/**
|
|
54
|
-
* Unique field
|
|
61
|
+
* Unique field id (nodeId). Use for the element `id`.
|
|
55
62
|
*/
|
|
56
63
|
id: string;
|
|
57
64
|
/**
|
|
58
|
-
* Field name (resolved using priority: name > label > nodeId)
|
|
59
|
-
* Use this for the name and id attributes of the input element
|
|
65
|
+
* Field name (resolved using priority: name > label > nodeId).
|
|
60
66
|
*/
|
|
61
67
|
name: string;
|
|
62
68
|
/**
|
|
63
|
-
*
|
|
64
|
-
* @param value - The new value (typed based on input type when T is specified)
|
|
69
|
+
* Current value of the input (typed by input type when T is specified).
|
|
65
70
|
*/
|
|
66
|
-
|
|
71
|
+
value: InputValueTypeMap[T];
|
|
67
72
|
/**
|
|
68
|
-
*
|
|
73
|
+
* Translated placeholder (already processed with current language).
|
|
69
74
|
*/
|
|
70
|
-
|
|
75
|
+
placeholder?: string;
|
|
71
76
|
/**
|
|
72
|
-
*
|
|
77
|
+
* Whether the field is required.
|
|
73
78
|
*/
|
|
74
|
-
|
|
79
|
+
required?: boolean;
|
|
75
80
|
/**
|
|
76
|
-
*
|
|
81
|
+
* Set when the field has a validation error.
|
|
77
82
|
*/
|
|
78
|
-
|
|
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> = {
|
|
79
91
|
/**
|
|
80
|
-
*
|
|
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)
|
|
98
|
+
*/
|
|
99
|
+
setValue: (value: InputValueTypeMap[T]) => void;
|
|
100
|
+
/**
|
|
101
|
+
* Validation error message for this field (if any).
|
|
102
|
+
*/
|
|
103
|
+
error?: string;
|
|
104
|
+
/** Translated label (already processed with current language). */
|
|
105
|
+
label?: string;
|
|
106
|
+
/**
|
|
107
|
+
* Translated helper text (already processed with current language).
|
|
81
108
|
*/
|
|
82
109
|
helperText?: string;
|
|
83
110
|
/**
|
|
84
|
-
*
|
|
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).
|
|
85
118
|
*/
|
|
86
119
|
missingRequiredFields?: string[];
|
|
87
120
|
/**
|
|
88
|
-
* Whether the form is currently being submitted (for submit inputs)
|
|
121
|
+
* Whether the form is currently being submitted (for submit inputs).
|
|
89
122
|
*/
|
|
90
123
|
isSubmitting?: boolean;
|
|
91
124
|
/**
|
|
@@ -109,6 +142,12 @@ export type InputRenderProps<T extends InputType = InputType> = {
|
|
|
109
142
|
*/
|
|
110
143
|
compactOptions?: boolean;
|
|
111
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;
|
|
112
151
|
export type UiRenderProps = {
|
|
113
152
|
node: Node<UINodeData>;
|
|
114
153
|
};
|
|
@@ -123,7 +162,7 @@ export type NodeRenderProps = {
|
|
|
123
162
|
* Each input type gets its own properly typed InputRenderProps
|
|
124
163
|
*/
|
|
125
164
|
export type InputRenderers = {
|
|
126
|
-
[K in InputType]?:
|
|
165
|
+
[K in InputType]?: InputRenderer<K>;
|
|
127
166
|
};
|
|
128
167
|
/**
|
|
129
168
|
* Props passed to a step renderer. Steps are derived at runtime from the flow's
|
|
@@ -257,6 +296,21 @@ export type TreegeRendererConfig = {
|
|
|
257
296
|
* @default "onSubmit"
|
|
258
297
|
*/
|
|
259
298
|
validationMode?: "onChange" | "onSubmit";
|
|
299
|
+
/**
|
|
300
|
+
* Base URL prepended to every **relative** HTTP url issued by the renderer
|
|
301
|
+
* (HTTP inputs, dynamic options, and submit). Use this to keep the tree
|
|
302
|
+
* JSON environment-agnostic — store relative paths in the tree and supply
|
|
303
|
+
* the host here per environment:
|
|
304
|
+
*
|
|
305
|
+
* @example
|
|
306
|
+
* // In the tree: "url": "/v2/entities/{{nodeId}}/sub-entities"
|
|
307
|
+
* <TreegeRenderer flows={tree} baseUrl={import.meta.env.VITE_API_URL} />
|
|
308
|
+
*
|
|
309
|
+
* Absolute urls (starting with `http://` or `https://`) are left untouched,
|
|
310
|
+
* so a field can still point at an external API. Template variables are
|
|
311
|
+
* resolved first, then the base URL is applied to the result.
|
|
312
|
+
*/
|
|
313
|
+
baseUrl?: string;
|
|
260
314
|
};
|
|
261
315
|
/**
|
|
262
316
|
* Props for the TreegeRenderer component
|
|
@@ -14,6 +14,17 @@ export declare const mergeHttpHeaders: (...sources: (HttpHeader[] | undefined)[]
|
|
|
14
14
|
* to already have their template variables resolved.
|
|
15
15
|
*/
|
|
16
16
|
export declare const appendQueryParams: (url: string, params?: QueryParam[]) => string;
|
|
17
|
+
/**
|
|
18
|
+
* Prepend a base URL to a relative URL. Absolute urls (starting with
|
|
19
|
+
* `http://` or `https://`, case-insensitive) and protocol-relative urls
|
|
20
|
+
* (`//host/...`) are returned untouched, so individual fields can still
|
|
21
|
+
* target an external API. A single slash is enforced at the join so a
|
|
22
|
+
* trailing slash on the base and/or a leading slash on the path don't
|
|
23
|
+
* produce `//`. When no base URL is configured, the url is returned as-is.
|
|
24
|
+
*
|
|
25
|
+
* Expects the url to already have its template variables resolved.
|
|
26
|
+
*/
|
|
27
|
+
export declare const resolveUrl: (url: string, baseUrl?: string) => string;
|
|
17
28
|
/**
|
|
18
29
|
* Result of an HTTP request
|
|
19
30
|
*/
|
|
@@ -13,6 +13,17 @@ export declare const getInputNodes: (nodes: Node<TreegeNodeData>[]) => Node<Inpu
|
|
|
13
13
|
* @returns The resolved key (name, label, or node ID)
|
|
14
14
|
*/
|
|
15
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;
|
|
16
27
|
/**
|
|
17
28
|
* Resolve the placeholder text for an input, falling back to the static
|
|
18
29
|
* "newAnswer" translation for textfield-like types when the user has not
|
|
@@ -35,9 +35,10 @@ export interface SubmitResult {
|
|
|
35
35
|
* @param formValues - Current form values
|
|
36
36
|
* @param inputNodes - All input nodes (required when sendAllFormValues is true)
|
|
37
37
|
* @param headers
|
|
38
|
+
* @param baseUrl - Base URL prepended to a relative submit url
|
|
38
39
|
* @returns Promise with submission result
|
|
39
40
|
*/
|
|
40
|
-
export declare const submitFormData: (config: SubmitConfig, formValues: FormValues, inputNodes: Node<InputNodeData>[], headers?: HttpHeader[]) => Promise<SubmitResult>;
|
|
41
|
+
export declare const submitFormData: (config: SubmitConfig, formValues: FormValues, inputNodes: Node<InputNodeData>[], headers?: HttpHeader[], baseUrl?: string) => Promise<SubmitResult>;
|
|
41
42
|
/**
|
|
42
43
|
* Perform redirect to the specified URL
|
|
43
44
|
*
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Node } from '@xyflow/react';
|
|
2
|
+
import { FormValues, MissingDependency } from '../types/renderer';
|
|
3
|
+
import { InputNodeData } from '../../shared/types/node';
|
|
4
|
+
/**
|
|
5
|
+
* The node ids an input's dynamic request depends on — every `{{nodeId}}`
|
|
6
|
+
* referenced in its `httpConfig` or `optionsSource` url, query-param values, or
|
|
7
|
+
* body. These are the fields that must be filled before the input can fetch its
|
|
8
|
+
* options. Headers are excluded: they carry auth/global values, not user-filled
|
|
9
|
+
* form fields.
|
|
10
|
+
*/
|
|
11
|
+
export declare const getTemplateDependencyIds: (node: Node<InputNodeData>) => string[];
|
|
12
|
+
/**
|
|
13
|
+
* The input's template dependencies that are not yet filled, paired with the
|
|
14
|
+
* referenced field's translated label. Computed centrally in `useRenderNode`
|
|
15
|
+
* and passed to every input renderer as `extra.missingDependencies`.
|
|
16
|
+
*/
|
|
17
|
+
export declare const getMissingDependencies: (node: Node<InputNodeData>, formValues: FormValues, inputNodes: Node<InputNodeData>[], language: string) => MissingDependency[];
|