treege 3.0.0-beta.57 → 3.0.0-beta.59
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 +16 -17
- package/dist/{DefaultInputs-CoJrOYMe.js → DefaultInputs-CoDN_KvC.js} +783 -761
- package/dist/ThemeContext-ClYtPOGK.js +1402 -0
- package/dist/editor/constants/nodeSpacing.d.ts +0 -8
- package/dist/editor/features/TreegeEditor/TreegeEditor.d.ts +1 -1
- package/dist/editor/features/TreegeEditor/inputs/ApiUrlCombobox.d.ts +0 -10
- package/dist/editor/types/editor.d.ts +16 -3
- package/dist/{editor-D3cbfAxI.js → editor-Cd_ifJTX.js} +1177 -1158
- package/dist/editor.js +2 -2
- package/dist/main.js +4 -4
- package/dist/renderer/context/TreegeRendererContext.d.ts +14 -2
- package/dist/renderer/features/TreegeRenderer/useTreegeRenderer.d.ts +3 -2
- package/dist/renderer/features/TreegeRenderer/web/TreegeRenderer.d.ts +1 -1
- package/dist/renderer/hooks/useSubmitHandler.d.ts +2 -1
- package/dist/renderer/types/renderer.d.ts +17 -2
- package/dist/renderer/utils/http.d.ts +11 -0
- package/dist/renderer/utils/submit.d.ts +2 -1
- package/dist/renderer-native.js +701 -680
- package/dist/renderer.js +3 -3
- package/dist/shared/locales/ar.json.d.ts +3 -1
- package/dist/shared/locales/de.json.d.ts +3 -1
- package/dist/shared/locales/en.json.d.ts +3 -1
- package/dist/shared/locales/es.json.d.ts +3 -1
- package/dist/shared/locales/fr.json.d.ts +3 -1
- package/dist/shared/locales/it.json.d.ts +3 -1
- package/dist/shared/locales/pt.json.d.ts +3 -1
- package/package.json +1 -1
- package/dist/ThemeContext-BhIeqgqN.js +0 -1398
package/dist/editor.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { t as e } from "./editor-
|
|
2
|
-
import { n as t, t as n } from "./ThemeContext-
|
|
1
|
+
import { t as e } from "./editor-Cd_ifJTX.js";
|
|
2
|
+
import { n as t, t as n } from "./ThemeContext-ClYtPOGK.js";
|
|
3
3
|
export { n as ThemeProvider, e as TreegeEditor, t as useTheme };
|
package/dist/main.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as e } from "./editor-
|
|
2
|
-
import { A as t, B as n,
|
|
3
|
-
import { C as E, E as D, S as O, T as k, _ as A, a as j, b as M, d as N, f as P, i as F, l as I, m as L, n as R, p as z, r as B, s as V, t as H, u as U, v as W, w as G, x as K, y as q } from "./DefaultInputs-
|
|
4
|
-
export { D as DefaultAddressInput, k as DefaultAutocompleteInput, G as DefaultCheckboxInput, E as DefaultDateInput, O as DefaultDateRangeInput, K as DefaultFileInput, M as DefaultHiddenInput, q as DefaultHttpInput, W as DefaultNumberInput, A as DefaultPasswordInput, L as DefaultRadioInput, z as DefaultSelectInput, V as DefaultSwitchInput, j as DefaultTextAreaInput, F as DefaultTextInput, B as DefaultTimeInput, R as DefaultTimeRangeInput, U as Divider, x as ThemeProvider, N as Title, S as TreegeConfigProvider, e as TreegeEditor, I as TreegeRenderer, u as applyReferenceTransformation, y as calculateReferenceFieldUpdates, g as checkFormFieldHasValue, f as convertFormValuesToNamedFormat, H as defaultInputRenderers, P as defaultUI, c as evaluateCondition, h as evaluateConditions, w as fileToSerializable, s as filesToSerializable, o as findStartNode, v as getFlowRenderState,
|
|
1
|
+
import { t as e } from "./editor-Cd_ifJTX.js";
|
|
2
|
+
import { A as t, B as n, H as r, R as i, V as a, a as o, b as s, c, d as l, f as u, g as d, h as f, i as p, j as m, l as h, m as g, n as _, o as v, p as y, s as b, t as x, u as S, x as C, y as w, z as T } from "./ThemeContext-ClYtPOGK.js";
|
|
3
|
+
import { C as E, E as D, S as O, T as k, _ as A, a as j, b as M, d as N, f as P, i as F, l as I, m as L, n as R, p as z, r as B, s as V, t as H, u as U, v as W, w as G, x as K, y as q } from "./DefaultInputs-CoDN_KvC.js";
|
|
4
|
+
export { D as DefaultAddressInput, k as DefaultAutocompleteInput, G as DefaultCheckboxInput, E as DefaultDateInput, O as DefaultDateRangeInput, K as DefaultFileInput, M as DefaultHiddenInput, q as DefaultHttpInput, W as DefaultNumberInput, A as DefaultPasswordInput, L as DefaultRadioInput, z as DefaultSelectInput, V as DefaultSwitchInput, j as DefaultTextAreaInput, F as DefaultTextInput, B as DefaultTimeInput, R as DefaultTimeRangeInput, U as Divider, x as ThemeProvider, N as Title, S as TreegeConfigProvider, e as TreegeEditor, I as TreegeRenderer, u as applyReferenceTransformation, y as calculateReferenceFieldUpdates, g as checkFormFieldHasValue, f as convertFormValuesToNamedFormat, H as defaultInputRenderers, P as defaultUI, c as evaluateCondition, h as evaluateConditions, w as fileToSerializable, s as filesToSerializable, o as findStartNode, v as getFlowRenderState, i as getStaticTranslations, T as getTranslatedText, d as isFieldEmpty, n as isGroupNode, a as isInputNode, b as isStartNode, r as isUINode, t as sanitize, m as sanitizeHttpResponse, C as serializableToFile, _ as useTheme, l as useTreegeConfig, p as useTreegeRenderer };
|
|
@@ -3,11 +3,17 @@ import { PropsWithChildren } from 'react';
|
|
|
3
3
|
import { FormValues } from '../types/renderer';
|
|
4
4
|
import { Flow, HttpHeader, InputNodeData } from '../../shared/types/node';
|
|
5
5
|
export interface TreegeRendererContextValue {
|
|
6
|
+
/**
|
|
7
|
+
* Base URL prepended to every relative HTTP url issued by inputs. Absolute
|
|
8
|
+
* urls are left untouched. Resolved from the renderer config and applied
|
|
9
|
+
* after template-variable substitution.
|
|
10
|
+
*/
|
|
11
|
+
baseUrl?: string;
|
|
6
12
|
/**
|
|
7
13
|
* The flow currently being rendered. `null` when the renderer has no flow
|
|
8
14
|
* to display yet.
|
|
9
15
|
*/
|
|
10
|
-
|
|
16
|
+
flow?: Flow | null;
|
|
11
17
|
/**
|
|
12
18
|
* Validation errors keyed by field id (`node.id`). Empty when the form
|
|
13
19
|
* is valid. Renderers read their own entry to display field-level errors.
|
|
@@ -68,11 +74,17 @@ export declare const TreegeRendererContext: import('react').Context<TreegeRender
|
|
|
68
74
|
export declare const TreegeRendererProvider: ({ children, value }: TreegeRendererProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
69
75
|
export declare const useTreegeRendererContext: () => {
|
|
70
76
|
edges: import('@xyflow/react').Edge[];
|
|
77
|
+
/**
|
|
78
|
+
* Base URL prepended to every relative HTTP url issued by inputs. Absolute
|
|
79
|
+
* urls are left untouched. Resolved from the renderer config and applied
|
|
80
|
+
* after template-variable substitution.
|
|
81
|
+
*/
|
|
82
|
+
baseUrl?: string;
|
|
71
83
|
/**
|
|
72
84
|
* The flow currently being rendered. `null` when the renderer has no flow
|
|
73
85
|
* to display yet.
|
|
74
86
|
*/
|
|
75
|
-
|
|
87
|
+
flow?: Flow | null;
|
|
76
88
|
/**
|
|
77
89
|
* Validation errors keyed by field id (`node.id`). Empty when the form
|
|
78
90
|
* is valid. Renderers read their own entry to display field-level errors.
|
|
@@ -16,14 +16,15 @@ import { GroupNodeData, TreegeNodeData } from '../../../shared/types/node';
|
|
|
16
16
|
* - Submit handling (with HTTP integration support)
|
|
17
17
|
* - Side effects (onChange callbacks, validation modes, reference field sync)
|
|
18
18
|
*
|
|
19
|
-
* @param props - Configuration props (
|
|
19
|
+
* @param props - Configuration props (flow, initialValues, callbacks, etc.)
|
|
20
20
|
* @returns Complete form state and control methods
|
|
21
21
|
*/
|
|
22
|
-
export declare const useTreegeRenderer: ({ components,
|
|
22
|
+
export declare const useTreegeRenderer: ({ baseUrl, components, flow, googleApiKey, headers, language, onChange, onSubmit, theme, validate, validationMode, initialValues, }: Pick<TreegeRendererProps, "baseUrl" | "components" | "flow" | "googleApiKey" | "headers" | "initialValues" | "language" | "onChange" | "onSubmit" | "theme" | "validate" | "validationMode">) => {
|
|
23
23
|
canContinueStep: boolean;
|
|
24
24
|
canSubmit: boolean;
|
|
25
25
|
clearSubmitMessage: () => void;
|
|
26
26
|
config: {
|
|
27
|
+
baseUrl: string | undefined;
|
|
27
28
|
components: {
|
|
28
29
|
form: ((props: {
|
|
29
30
|
children: import('react').ReactNode;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { TreegeRendererProps } from '../../../types/renderer';
|
|
2
|
-
declare const TreegeRenderer: ({ components, className,
|
|
2
|
+
declare const TreegeRenderer: ({ baseUrl, components, className, flow, googleApiKey, headers, language, onChange, onSubmit, theme, validate, validationMode, initialValues, isLoading, }: TreegeRendererProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
export default TreegeRenderer;
|
|
@@ -17,9 +17,10 @@ import { HttpHeader, InputNodeData, TreegeNodeData } from '../../shared/types/no
|
|
|
17
17
|
* @param language - Current language for translations
|
|
18
18
|
* @param inputNodes - All input nodes for form data conversion
|
|
19
19
|
* @param headers
|
|
20
|
+
* @param baseUrl - Base URL prepended to a relative submit url
|
|
20
21
|
* @returns Submit handler state and functions
|
|
21
22
|
*/
|
|
22
|
-
export declare const useSubmitHandler: (visibleNodes: Node<TreegeNodeData>[], formValues: FormValues, language: string, inputNodes: Node<InputNodeData>[], headers?: HttpHeader[]) => {
|
|
23
|
+
export declare const useSubmitHandler: (visibleNodes: Node<TreegeNodeData>[], formValues: FormValues, language: string, inputNodes: Node<InputNodeData>[], headers?: HttpHeader[], baseUrl?: string) => {
|
|
23
24
|
clearSubmitMessage: () => void;
|
|
24
25
|
handleSubmitWithConfig: (onSuccess?: (data: unknown) => void) => Promise<SubmitResult | null>;
|
|
25
26
|
hasSubmitConfig: boolean;
|
|
@@ -296,13 +296,28 @@ export type TreegeRendererConfig = {
|
|
|
296
296
|
* @default "onSubmit"
|
|
297
297
|
*/
|
|
298
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 flow={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;
|
|
299
314
|
};
|
|
300
315
|
/**
|
|
301
316
|
* Props for the TreegeRenderer component
|
|
302
317
|
*
|
|
303
318
|
* Inherits all configuration fields from TreegeRendererConfig (components,
|
|
304
319
|
* headers, googleApiKey, language, theme, validationMode) and adds the
|
|
305
|
-
* instance-specific ones (
|
|
320
|
+
* instance-specific ones (flow, callbacks, initial values, etc.).
|
|
306
321
|
*/
|
|
307
322
|
export interface TreegeRendererProps extends TreegeRendererConfig {
|
|
308
323
|
/**
|
|
@@ -312,7 +327,7 @@ export interface TreegeRendererProps extends TreegeRendererConfig {
|
|
|
312
327
|
/**
|
|
313
328
|
* Flow to render. `null` / `undefined` renders nothing.
|
|
314
329
|
*/
|
|
315
|
-
|
|
330
|
+
flow?: Flow | null;
|
|
316
331
|
/**
|
|
317
332
|
* Initial form values
|
|
318
333
|
*/
|
|
@@ -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
|
*/
|
|
@@ -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
|
*
|