treege 3.0.0-beta.62 → 3.0.0-beta.63
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 +88 -37
- package/dist/{DefaultInputs-DamDWb5R.js → DefaultInputs-nX-CVK2i.js} +415 -390
- package/dist/{ThemeContext-cGSTk24y.js → ThemeContext-nopV_oRU.js} +184 -168
- package/dist/{editor-K1jjfc5n.js → editor-Bag5U_S5.js} +237 -237
- package/dist/editor.js +2 -2
- package/dist/main.js +4 -4
- package/dist/renderer/features/TreegeRenderer/native/TreegeRenderer.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/native/components/DefaultStep.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/useTreegeRenderer.d.ts +2 -0
- package/dist/renderer/features/TreegeRenderer/web/TreegeRenderer.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/DefaultFormWrapper.d.ts +2 -1
- package/dist/renderer/features/TreegeRenderer/web/components/DefaultStep.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/DefaultSubmitButton.d.ts +4 -0
- package/dist/renderer/hooks/useRenderNode.d.ts +4 -1
- package/dist/renderer/types/renderer.d.ts +50 -4
- package/dist/renderer/utils/form.d.ts +16 -0
- package/dist/renderer-native.js +1014 -1002
- package/dist/renderer.js +3 -3
- package/package.json +1 -1
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-Bag5U_S5.js";
|
|
2
|
+
import { n as t, t as n } from "./ThemeContext-nopV_oRU.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 { B as t, H as n, M as r,
|
|
3
|
-
import { C as
|
|
4
|
-
export {
|
|
1
|
+
import { t as e } from "./editor-Bag5U_S5.js";
|
|
2
|
+
import { B as t, H as n, M as r, N as i, S as a, U as o, V as s, W as c, _ as l, a as u, b as d, c as f, d as p, f as m, g as h, h as g, i as _, l as v, m as y, n as b, o as x, p as S, s as C, t as w, u as T, x as E } from "./ThemeContext-nopV_oRU.js";
|
|
3
|
+
import { C as D, E as O, S as k, T as A, _ as j, a as M, b as N, d as P, f as F, i as I, l as L, m as R, n as z, p as B, r as V, s as H, t as U, u as W, v as G, w as K, x as q, y as J } from "./DefaultInputs-nX-CVK2i.js";
|
|
4
|
+
export { O as DefaultAddressInput, A as DefaultAutocompleteInput, K as DefaultCheckboxInput, D as DefaultDateInput, k as DefaultDateRangeInput, q as DefaultFileInput, N as DefaultHiddenInput, J as DefaultHttpInput, G as DefaultNumberInput, j as DefaultPasswordInput, R as DefaultRadioInput, B as DefaultSelectInput, H as DefaultSwitchInput, M as DefaultTextAreaInput, I as DefaultTextInput, V as DefaultTimeInput, z as DefaultTimeRangeInput, W as Divider, w as ThemeProvider, P as Title, e as TreegeEditor, L as TreegeRenderer, T as TreegeRendererProvider, m as applyReferenceTransformation, S as buildInitialFormValues, y as calculateReferenceFieldUpdates, g as checkFormFieldHasValue, h as convertFormValuesToNamedFormat, U as defaultInputRenderers, F as defaultUI, f as evaluateCondition, v as evaluateConditions, d as fileToSerializable, E as filesToSerializable, u as findStartNode, x as getFlowRenderState, t as getStaticTranslations, s as getTranslatedText, l as isFieldEmpty, n as isGroupNode, o as isInputNode, C as isStartNode, c as isUINode, r as sanitize, i as sanitizeHttpResponse, a as serializableToFile, b as useTheme, _ as useTreegeRenderer, p as useTreegeRendererConfig };
|
|
@@ -6,7 +6,7 @@ import { TreegeRendererProps } from '../../../types/renderer';
|
|
|
6
6
|
* - Omits className (not used in React Native)
|
|
7
7
|
* - Adds style and contentContainerStyle (React Native specific)
|
|
8
8
|
*/
|
|
9
|
-
export type TreegeRendererNativeProps = Omit<TreegeRendererProps, "className"> & {
|
|
9
|
+
export type TreegeRendererNativeProps = Omit<TreegeRendererProps, "className" | "formId"> & {
|
|
10
10
|
/**
|
|
11
11
|
* Style for the ScrollView container
|
|
12
12
|
*/
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { StepRenderProps } from '../../../../types/renderer';
|
|
2
|
-
declare const DefaultStep: ({ label, children,
|
|
2
|
+
declare const DefaultStep: ({ label, children, canGoBack, isLastStep, canContinue, isSubmitting, onBack, onContinue }: StepRenderProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
export default DefaultStep;
|
|
@@ -28,6 +28,7 @@ export declare const useTreegeRenderer: ({ baseUrl, components, flow, googleApiK
|
|
|
28
28
|
components: {
|
|
29
29
|
form: ((props: {
|
|
30
30
|
children: import('react').ReactNode;
|
|
31
|
+
id?: string;
|
|
31
32
|
onSubmit: (e: import('react').FormEvent<HTMLFormElement>) => void;
|
|
32
33
|
}) => import('react').ReactNode) | undefined;
|
|
33
34
|
inputs: {
|
|
@@ -55,6 +56,7 @@ export declare const useTreegeRenderer: ({ baseUrl, components, flow, googleApiK
|
|
|
55
56
|
submitButton: ((props: {
|
|
56
57
|
label?: string;
|
|
57
58
|
disabled?: boolean;
|
|
59
|
+
isSubmitting?: boolean;
|
|
58
60
|
[key: string]: unknown;
|
|
59
61
|
} | {
|
|
60
62
|
children?: import('react').ReactNode;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { TreegeRendererProps } from '../../../types/renderer';
|
|
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;
|
|
2
|
+
declare const TreegeRenderer: ({ baseUrl, components, className, flow, formId, googleApiKey, headers, language, onBack, onChange, onSubmit, theme, validate, validationMode, initialValues, isLoading, isSubmitting: isSubmittingProp, }: TreegeRendererProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
export default TreegeRenderer;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { FormEvent, ReactNode } from 'react';
|
|
2
|
-
declare const DefaultFormWrapper: ({ children, onSubmit }: {
|
|
2
|
+
declare const DefaultFormWrapper: ({ children, id, onSubmit, }: {
|
|
3
3
|
children: ReactNode;
|
|
4
|
+
id?: string;
|
|
4
5
|
onSubmit: (e: FormEvent<HTMLFormElement>) => void;
|
|
5
6
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
6
7
|
export default DefaultFormWrapper;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { StepRenderProps } from '../../../../types/renderer';
|
|
2
|
-
declare const DefaultStep: ({ label, children,
|
|
2
|
+
declare const DefaultStep: ({ label, children, canGoBack, isLastStep, canContinue, isSubmitting, onBack, onContinue, missingFields, }: StepRenderProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
export default DefaultStep;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { ButtonHTMLAttributes } from 'react';
|
|
2
2
|
export interface SubmitButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
3
3
|
label?: string;
|
|
4
|
+
/**
|
|
5
|
+
* When true, shows a spinner inside the button (and keeps it disabled).
|
|
6
|
+
*/
|
|
7
|
+
isSubmitting?: boolean;
|
|
4
8
|
}
|
|
5
9
|
/**
|
|
6
10
|
* Default submit button
|
|
@@ -20,6 +20,7 @@ type UseRenderNodeParams = {
|
|
|
20
20
|
formErrors: Record<string, string>;
|
|
21
21
|
formValues: FormValues;
|
|
22
22
|
inputNodes: Node<InputNodeData>[];
|
|
23
|
+
isSubmitting?: boolean;
|
|
23
24
|
missingRequiredFields: string[];
|
|
24
25
|
setFieldValue: (fieldId: string, value: unknown) => void;
|
|
25
26
|
};
|
|
@@ -33,15 +34,17 @@ type UseRenderNodeParams = {
|
|
|
33
34
|
* - SubmitButton: Submit button component with fallback
|
|
34
35
|
* - SubmitButtonWrapper: Submit button wrapper component with fallback (web only, undefined for native)
|
|
35
36
|
*/
|
|
36
|
-
export declare const useRenderNode: ({ DefaultFormWrapper, DefaultInputWrapper, DefaultSubmitButton, DefaultSubmitButtonWrapper, config, defaultInputRenderers, defaultUI, formErrors, formValues, inputNodes, missingRequiredFields, setFieldValue, }: UseRenderNodeParams) => {
|
|
37
|
+
export declare const useRenderNode: ({ DefaultFormWrapper, DefaultInputWrapper, DefaultSubmitButton, DefaultSubmitButtonWrapper, config, defaultInputRenderers, defaultUI, formErrors, formValues, inputNodes, isSubmitting, missingRequiredFields, setFieldValue, }: UseRenderNodeParams) => {
|
|
37
38
|
FormWrapper: ((props: {
|
|
38
39
|
children: ReactNode;
|
|
40
|
+
id?: string;
|
|
39
41
|
onSubmit: (e: import('react').FormEvent<HTMLFormElement>) => void;
|
|
40
42
|
}) => ReactNode) | AnyComponent;
|
|
41
43
|
renderNode: (node: Node<TreegeNodeData>) => ReactNode;
|
|
42
44
|
SubmitButton: ((props: {
|
|
43
45
|
label?: string;
|
|
44
46
|
disabled?: boolean;
|
|
47
|
+
isSubmitting?: boolean;
|
|
45
48
|
[key: string]: unknown;
|
|
46
49
|
} | {
|
|
47
50
|
children?: ReactNode;
|
|
@@ -180,6 +180,13 @@ export type StepRenderProps = {
|
|
|
180
180
|
totalSteps: number;
|
|
181
181
|
/** True when this is the first step (Back should be hidden/disabled). */
|
|
182
182
|
isFirstStep: boolean;
|
|
183
|
+
/**
|
|
184
|
+
* Whether a Back button should be shown. True on any step past the first, and
|
|
185
|
+
* also on the first step when the consumer passes an `onBack` prop (to bridge
|
|
186
|
+
* back-navigation to an outer flow, e.g. a parent modal's steps). Prefer this
|
|
187
|
+
* over `isFirstStep` to decide whether to render the Back control.
|
|
188
|
+
*/
|
|
189
|
+
canGoBack: boolean;
|
|
183
190
|
/**
|
|
184
191
|
* True when this is the last visible step. The renderer turns Continue
|
|
185
192
|
* into a submit action on the last step.
|
|
@@ -194,7 +201,11 @@ export type StepRenderProps = {
|
|
|
194
201
|
missingFields?: string[];
|
|
195
202
|
/** Submission in progress (passed through from `useTreegeRenderer`). */
|
|
196
203
|
isSubmitting?: boolean;
|
|
197
|
-
/**
|
|
204
|
+
/**
|
|
205
|
+
* Go back: advances to the previous step, or — on the first step, when the
|
|
206
|
+
* consumer passed an `onBack` prop — invokes that callback instead. No-op on
|
|
207
|
+
* the first step when no `onBack` prop was provided.
|
|
208
|
+
*/
|
|
198
209
|
onBack: () => void;
|
|
199
210
|
/**
|
|
200
211
|
* Advance to the next step (or trigger submit on the last step). The wrapper
|
|
@@ -226,20 +237,24 @@ export type TreegeRendererComponents = {
|
|
|
226
237
|
*/
|
|
227
238
|
step?: (props: StepRenderProps) => ReactNode;
|
|
228
239
|
/**
|
|
229
|
-
* Custom form wrapper
|
|
240
|
+
* Custom form wrapper. `id` (when provided via the `formId` prop) should be
|
|
241
|
+
* forwarded to the underlying `<form>` element to keep external submit
|
|
242
|
+
* buttons working.
|
|
230
243
|
*/
|
|
231
244
|
form?: (props: {
|
|
232
245
|
children: ReactNode;
|
|
246
|
+
id?: string;
|
|
233
247
|
onSubmit: (e: FormEvent<HTMLFormElement>) => void;
|
|
234
248
|
}) => ReactNode;
|
|
235
249
|
/**
|
|
236
250
|
* Custom submit button (supports both web and native variants)
|
|
237
|
-
* Web variant: { label?: string; disabled?: boolean; ...otherHTMLAttributes }
|
|
251
|
+
* Web variant: { label?: string; disabled?: boolean; isSubmitting?: boolean; ...otherHTMLAttributes }
|
|
238
252
|
* Native variant: { children?: ReactNode; disabled?: boolean; isSubmitting?: boolean; onPress?: () => void }
|
|
239
253
|
*/
|
|
240
254
|
submitButton?: (props: {
|
|
241
255
|
label?: string;
|
|
242
256
|
disabled?: boolean;
|
|
257
|
+
isSubmitting?: boolean;
|
|
243
258
|
[key: string]: unknown;
|
|
244
259
|
} | {
|
|
245
260
|
children?: ReactNode;
|
|
@@ -332,7 +347,23 @@ export interface TreegeRendererProps extends TreegeRendererConfig {
|
|
|
332
347
|
*/
|
|
333
348
|
flow?: Flow | null;
|
|
334
349
|
/**
|
|
335
|
-
*
|
|
350
|
+
* Sets the `id` attribute on the underlying `<form>` element, so a submit
|
|
351
|
+
* button rendered outside the renderer can target it via the native HTML
|
|
352
|
+
* `form` attribute: `<button type="submit" form={formId}>`. Web only.
|
|
353
|
+
*/
|
|
354
|
+
formId?: string;
|
|
355
|
+
/**
|
|
356
|
+
* Initial form values — use this to pre-fill the form when editing a record
|
|
357
|
+
* that was already submitted.
|
|
358
|
+
*
|
|
359
|
+
* Keys can be either `node.id` OR the same name-based keys you receive back in
|
|
360
|
+
* `onChange` / `onSubmit`, so the previously-submitted object can be fed
|
|
361
|
+
* straight back in without any remapping.
|
|
362
|
+
*
|
|
363
|
+
* Reactive: if this changes after mount (e.g. an async-fetched record resolves
|
|
364
|
+
* later), the form is re-seeded automatically. A new object literal of
|
|
365
|
+
* identical content does NOT reset the form, so in-progress user edits are
|
|
366
|
+
* preserved.
|
|
336
367
|
*/
|
|
337
368
|
initialValues?: FormValues;
|
|
338
369
|
/**
|
|
@@ -340,6 +371,21 @@ export interface TreegeRendererProps extends TreegeRendererConfig {
|
|
|
340
371
|
* the flow is being fetched. Customizable via `components.loadingSkeleton`.
|
|
341
372
|
*/
|
|
342
373
|
isLoading?: boolean;
|
|
374
|
+
/**
|
|
375
|
+
* When true, forces the submit/continue button into its loading state
|
|
376
|
+
* (spinner + disabled). Use this to keep the button busy while an async
|
|
377
|
+
* `onSubmit` is still resolving on the consumer side. It is OR-ed with the
|
|
378
|
+
* renderer's own internal submitting state, so it only ever adds to it.
|
|
379
|
+
*/
|
|
380
|
+
isSubmitting?: boolean;
|
|
381
|
+
/**
|
|
382
|
+
* Called when the user clicks Back on the FIRST step. Provide this to bridge
|
|
383
|
+
* back-navigation to an outer flow (e.g. a parent modal's steps): when set, a
|
|
384
|
+
* Back button is shown on the first step and triggers this callback instead
|
|
385
|
+
* of being a no-op. Has no effect on later steps, which always navigate back
|
|
386
|
+
* internally.
|
|
387
|
+
*/
|
|
388
|
+
onBack?: () => void;
|
|
343
389
|
/**
|
|
344
390
|
* Callback when form values change
|
|
345
391
|
*/
|
|
@@ -17,6 +17,22 @@ 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
|
+
* Build the initial (nodeId-keyed) form state from consumer-provided values.
|
|
22
|
+
*
|
|
23
|
+
* Consumers can pass `initialValues` keyed either by `node.id` OR by the same
|
|
24
|
+
* key shape they receive back in `onChange`/`onSubmit` (resolved via
|
|
25
|
+
* `resolveNodeKey`: name > label > node.id). This lets an edit screen feed the
|
|
26
|
+
* previously-submitted object straight back in without any remapping.
|
|
27
|
+
*
|
|
28
|
+
* After normalizing provided values, node `defaultValue`s (static / reference)
|
|
29
|
+
* are applied to any field still left unset — matching a fresh mount.
|
|
30
|
+
*
|
|
31
|
+
* @param initialValues - Values provided by the consumer (id- or name-keyed)
|
|
32
|
+
* @param inputNodes - All input nodes of the flow
|
|
33
|
+
* @returns Form values keyed strictly by node id
|
|
34
|
+
*/
|
|
35
|
+
export declare const buildInitialFormValues: (initialValues: FormValues, inputNodes: Node<InputNodeData>[]) => FormValues;
|
|
20
36
|
/**
|
|
21
37
|
* Convert internal form values (keyed by nodeId) to external format (keyed by name)
|
|
22
38
|
* When multiple nodes share the same name, later values overwrite earlier ones
|