treege 3.0.0-beta.57 → 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/dist/editor.js CHANGED
@@ -1,3 +1,3 @@
1
- import { t as e } from "./editor-D3cbfAxI.js";
2
- import { n as t, t as n } from "./ThemeContext-BhIeqgqN.js";
1
+ import { t as e } from "./editor-BhL3w_KP.js";
2
+ import { n as t, t as n } from "./ThemeContext-DrI5HTYl.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-D3cbfAxI.js";
2
- import { A as t, B as n, L 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, k 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-BhIeqgqN.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-CoJrOYMe.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, r as getStaticTranslations, i as getTranslatedText, d as isFieldEmpty, T as isGroupNode, n as isInputNode, b as isStartNode, a as isUINode, m as sanitize, t as sanitizeHttpResponse, C as serializableToFile, _ as useTheme, l as useTreegeConfig, p as useTreegeRenderer };
1
+ import { t as e } from "./editor-BhL3w_KP.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-DrI5HTYl.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-Dr3R5r53.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,6 +3,12 @@ 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.
@@ -68,6 +74,12 @@ 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.
@@ -19,11 +19,12 @@ import { GroupNodeData, TreegeNodeData } from '../../../shared/types/node';
19
19
  * @param props - Configuration props (flows, initialValues, callbacks, etc.)
20
20
  * @returns Complete form state and control methods
21
21
  */
22
- export declare const useTreegeRenderer: ({ components, flows, googleApiKey, headers, initialValues, language, onChange, onSubmit, theme, validate, validationMode, }: Pick<TreegeRendererProps, "components" | "flows" | "googleApiKey" | "headers" | "initialValues" | "language" | "onChange" | "onSubmit" | "theme" | "validate" | "validationMode">) => {
22
+ export declare const useTreegeRenderer: ({ baseUrl, components, flows, googleApiKey, headers, initialValues, language, onChange, onSubmit, theme, validate, validationMode, }: Pick<TreegeRendererProps, "baseUrl" | "components" | "flows" | "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, flows, googleApiKey, headers, language, onChange, onSubmit, theme, validate, validationMode, initialValues, isLoading, }: TreegeRendererProps) => import("react/jsx-runtime").JSX.Element;
2
+ declare const TreegeRenderer: ({ baseUrl, components, className, flows, 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,6 +296,21 @@ 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 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;
299
314
  };
300
315
  /**
301
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
  */
@@ -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
  *