treege 3.0.0-beta.86 → 3.0.0-beta.87
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 +51 -20
- package/dist/{editor-BK8Mbi-D.js → editor-B3qu0VAn.js} +2 -2
- package/dist/editor.js +1 -1
- package/dist/main.js +3 -3
- package/dist/renderer/features/TreegeViewer/utils/viewerFields.d.ts +26 -2
- package/dist/renderer/features/TreegeViewer/web/TreegeViewer.d.ts +41 -27
- package/dist/renderer-D2-LozgF.js +445 -0
- package/dist/renderer.js +2 -2
- package/package.json +1 -1
- package/dist/renderer-8xCEZin9.js +0 -424
package/dist/main.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as e } from "./editor-
|
|
1
|
+
import { t as e } from "./editor-B3qu0VAn.js";
|
|
2
2
|
import { G as t, I as n, J as r, K as i, L as a, U as o, W as s, Y as c, _ as l, a as u, b as d, c as f, g as p, h as m, i as h, l as g, m as _, n as v, o as y, q as b, r as x, s as S, t as C, v as w, y as T } from "./ThemeContext-BnPOFQC7.js";
|
|
3
3
|
import { C as E, L as D, S as O, _ as k, a as A, b as j, c as M, d as N, g as P, h as F, i as I, m as L, n as R, o as z, r as B, u as V, v as H, x as U, y as W } from "./DefaultSubmitButton-DpeL3OxC.js";
|
|
4
4
|
import { a as G, c as K, i as q, l as J, n as Y, o as X, r as Z, s as Q } from "./useRenderNode-DQ5lvXuj.js";
|
|
5
|
-
import { a as $, c as ee, i as te,
|
|
6
|
-
export { E as DefaultAddressInput, O as DefaultAutocompleteInput, U as DefaultCheckboxInput, j as DefaultDateInput, W as DefaultDateRangeInput, H as DefaultFileInput, k as DefaultHiddenInput, P as DefaultHttpInput, D as DefaultInputLabel, F as DefaultNumberInput, L as DefaultPasswordInput, N as DefaultRadioInput, V as DefaultSelectInput, M as DefaultSwitchInput, z as DefaultTextAreaInput, A as DefaultTextInput, I as DefaultTimeInput, B as DefaultTimeRangeInput,
|
|
5
|
+
import { a as $, c as ee, i as te, l as ne, n as re, o as ie, r as ae, s as oe, t as se } from "./renderer-D2-LozgF.js";
|
|
6
|
+
export { E as DefaultAddressInput, O as DefaultAutocompleteInput, U as DefaultCheckboxInput, j as DefaultDateInput, W as DefaultDateRangeInput, H as DefaultFileInput, k as DefaultHiddenInput, P as DefaultHttpInput, D as DefaultInputLabel, F as DefaultNumberInput, L as DefaultPasswordInput, N as DefaultRadioInput, V as DefaultSelectInput, M as DefaultSwitchInput, z as DefaultTextAreaInput, A as DefaultTextInput, I as DefaultTimeInput, B as DefaultTimeRangeInput, ie as Divider, C as ThemeProvider, oe as Title, e as TreegeEditor, $ as TreegeRenderer, K as TreegeRendererProvider, se as TreegeViewer, ne as TreegeViewerProvider, x as applyReferenceTransformation, h as buildInitialFormValues, u as calculateReferenceFieldUpdates, y as checkFormFieldHasValue, S as convertFormValuesToNamedFormat, R as defaultInputRenderers, ee as defaultUI, X as evaluateCondition, Q as evaluateConditions, _ as fileNameFromUrl, m as fileToSerializable, p as filesToSerializable, Z as findStartNode, l as formatFileSize, q as getFlowRenderState, o as getStaticTranslations, s as getTranslatableValue, t as getTranslatedText, re as getViewerFields, f as isFieldEmpty, b as isGroupNode, ae as isImageFile, r as isInputNode, w as isRemoteFileData, G as isStartNode, c as isUINode, T as normalizeSerializableFiles, g as resolveNodeDefaultValue, n as sanitize, a as sanitizeHttpResponse, d as serializableToFile, i as setTranslatableValue, v as useTheme, Y as useTreegeRenderer, J as useTreegeRendererConfig, te as viewerFieldsFromResponse };
|
|
@@ -2,6 +2,7 @@ import { Node } from '@xyflow/react';
|
|
|
2
2
|
import { FormValues } from '../../../types/renderer';
|
|
3
3
|
import { SerializableFile } from '../../../../shared/types/file';
|
|
4
4
|
import { Flow, InputNodeData, InputType } from '../../../../shared/types/node';
|
|
5
|
+
import { Translatable } from '../../../../shared/types/translate';
|
|
5
6
|
/**
|
|
6
7
|
* Display-ready representation of a submitted field value, normalized per input
|
|
7
8
|
* type so a viewer can render it without re-deriving formatting rules:
|
|
@@ -40,8 +41,19 @@ export interface ViewerField {
|
|
|
40
41
|
rawValue: unknown;
|
|
41
42
|
/** Normalized, render-ready representation of the value. */
|
|
42
43
|
display: ViewerFieldDisplay;
|
|
43
|
-
/** The originating flow node (escape hatch for custom rendering). */
|
|
44
|
-
node
|
|
44
|
+
/** The originating flow node — present only in flow-based resolution (escape hatch for custom rendering). */
|
|
45
|
+
node?: Node<InputNodeData>;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* A self-describing stored value, used to render a viewer **without** a `flow`
|
|
49
|
+
* (e.g. a persisted `WorkflowValue[]`). Each entry carries its own metadata so
|
|
50
|
+
* the value can be formatted by type and labelled without a flow definition.
|
|
51
|
+
*/
|
|
52
|
+
export interface FlowResponseEntry {
|
|
53
|
+
name?: string;
|
|
54
|
+
type?: string;
|
|
55
|
+
value?: unknown;
|
|
56
|
+
label?: Translatable | string;
|
|
45
57
|
}
|
|
46
58
|
export interface GetViewerFieldsOptions {
|
|
47
59
|
/** Language used to resolve translatable labels/options (defaults to `en`). */
|
|
@@ -76,3 +88,15 @@ export declare const isImageFile: (file: SerializableFile) => boolean;
|
|
|
76
88
|
* @returns The ordered, visible, display-ready fields
|
|
77
89
|
*/
|
|
78
90
|
export declare const getViewerFields: (flow: Flow | null | undefined, values: FormValues | null | undefined, options?: GetViewerFieldsOptions) => ViewerField[];
|
|
91
|
+
/**
|
|
92
|
+
* Build a render-ready field list straight from a self-describing response —
|
|
93
|
+
* each entry supplies its own `name`/`type`/`value`/`label`, so no `flow` is
|
|
94
|
+
* needed. Used by {@link TreegeViewer} in its flow-less mode. Option values are
|
|
95
|
+
* shown as-is (there's no flow to resolve their labels), and `hidden`/`submit`
|
|
96
|
+
* entries are skipped.
|
|
97
|
+
*
|
|
98
|
+
* @param response - The self-describing stored values
|
|
99
|
+
* @param options - Resolution options (language, baseUrl)
|
|
100
|
+
* @returns The ordered, display-ready fields
|
|
101
|
+
*/
|
|
102
|
+
export declare const viewerFieldsFromResponse: (response: readonly FlowResponseEntry[] | null | undefined, options?: GetViewerFieldsOptions) => ViewerField[];
|
|
@@ -1,48 +1,44 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import { ViewerField } from '../utils/viewerFields';
|
|
2
|
+
import { FlowResponseEntry, ViewerField } from '../utils/viewerFields';
|
|
3
3
|
import { FormValues } from '../../../types/renderer';
|
|
4
4
|
import { Flow, InputType } from '../../../../shared/types/node';
|
|
5
5
|
/** Per-type override map: `{ file: (field) => <Thumbnails /> }`. */
|
|
6
6
|
export type ViewerFieldRenderers = Partial<Record<InputType, (field: ViewerField) => ReactNode>>;
|
|
7
|
-
|
|
7
|
+
interface TreegeViewerBaseProps {
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
10
|
-
*/
|
|
11
|
-
flow: Flow;
|
|
12
|
-
/**
|
|
13
|
-
* The submitted values (`name`- or `id`-keyed, e.g. the `onSubmit` payload).
|
|
14
|
-
*/
|
|
15
|
-
values: FormValues;
|
|
16
|
-
/**
|
|
17
|
-
* Language used to resolve translatable labels/options (defaults to `en`).
|
|
9
|
+
* Language used to resolve translatable labels/options (defaults to the provider config, then `en`).
|
|
18
10
|
*/
|
|
19
11
|
language?: string;
|
|
20
12
|
/**
|
|
21
|
-
* Light/dark theme. Falls back to the `TreegeRendererProvider` config, then
|
|
22
|
-
* `"dark"` — same resolution as `TreegeRenderer`.
|
|
13
|
+
* Light/dark theme. Falls back to the `TreegeRendererProvider` config, then `"dark"`.
|
|
23
14
|
*/
|
|
24
15
|
theme?: "light" | "dark";
|
|
25
16
|
/**
|
|
26
|
-
* Base URL
|
|
27
|
-
* as on `TreegeRenderer`/`TreegeEditor`. `data:`/`blob:`/absolute URLs are
|
|
28
|
-
* left untouched.
|
|
17
|
+
* Base URL to resolve relative file paths into absolute URLs. `data:`/`blob:`/absolute URLs are left untouched.
|
|
29
18
|
*/
|
|
30
19
|
baseUrl?: string;
|
|
31
20
|
/**
|
|
32
|
-
*
|
|
21
|
+
* Field names (or ids) to hide from the view.
|
|
33
22
|
*/
|
|
34
23
|
excludedFields?: string[];
|
|
35
24
|
/**
|
|
36
25
|
* Hide fields that have no submitted value (instead of showing `emptyText`).
|
|
37
|
-
* Useful to render a compact recap of only the filled-in fields.
|
|
38
26
|
*/
|
|
39
27
|
excludeEmptyFields?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* When `true`, only the first `collapsedVisibleCount` fields are rendered.
|
|
30
|
+
*/
|
|
31
|
+
collapsed?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Number of fields kept visible while `collapsed` (defaults to all).
|
|
34
|
+
*/
|
|
35
|
+
collapsedVisibleCount?: number;
|
|
40
36
|
/**
|
|
41
37
|
* Text shown when a field has no submitted value (defaults to `"—"`).
|
|
42
38
|
*/
|
|
43
39
|
emptyText?: string;
|
|
44
40
|
/**
|
|
45
|
-
* Extra class names on the root element.
|
|
41
|
+
* Extra class names on the root element.
|
|
46
42
|
*/
|
|
47
43
|
className?: string;
|
|
48
44
|
/**
|
|
@@ -57,6 +53,26 @@ export interface TreegeViewerProps {
|
|
|
57
53
|
*/
|
|
58
54
|
renderRow?: (field: ViewerField, defaultRow: ReactNode) => ReactNode;
|
|
59
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* `flowResponse` is typed conditionally on `flow`:
|
|
58
|
+
* - **with** a `flow` → the renderer's `FormValues` (`name`- or `id`-keyed), resolved against the flow;
|
|
59
|
+
* - **without** a `flow` → a self-describing `FlowResponseEntry[]` (each carries its own
|
|
60
|
+
* `name`/`type`/`value`/`label`), rendered as-is.
|
|
61
|
+
*/
|
|
62
|
+
export type TreegeViewerProps = TreegeViewerBaseProps & ({
|
|
63
|
+
/**
|
|
64
|
+
* The flow the values were submitted against.
|
|
65
|
+
*/
|
|
66
|
+
flow: Flow;
|
|
67
|
+
/** The submitted values as the renderer's `FormValues` (`name`- or `id`-keyed). */
|
|
68
|
+
flowResponse: FormValues;
|
|
69
|
+
} | {
|
|
70
|
+
flow?: undefined;
|
|
71
|
+
/**
|
|
72
|
+
* Self-describing stored values rendered without a flow.
|
|
73
|
+
*/
|
|
74
|
+
flowResponse: FlowResponseEntry[];
|
|
75
|
+
});
|
|
60
76
|
/**
|
|
61
77
|
* Read-only viewer for a submitted Treege form. Given the `flow` and the
|
|
62
78
|
* submitted `values`, it renders every reachable field as a label/value pair —
|
|
@@ -68,13 +84,11 @@ export interface TreegeViewerProps {
|
|
|
68
84
|
* change the whole row layout pass `renderRow`.
|
|
69
85
|
*
|
|
70
86
|
* @example
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
* renderField={{ file: ({ rawValue }) => <Thumbnails files={rawValue} /> }}
|
|
77
|
-
* />
|
|
87
|
+
* // With a flow — `flowResponse` is the renderer's FormValues:
|
|
88
|
+
* <TreegeViewer flow={flow} flowResponse={submitted} language="fr" excludeEmptyFields />
|
|
89
|
+
*
|
|
90
|
+
* // Without a flow — `flowResponse` is a self-describing list:
|
|
91
|
+
* <TreegeViewer flowResponse={[{ name: "city", type: "text", value: "Paris", label: { en: "City" } }]} />
|
|
78
92
|
*/
|
|
79
|
-
declare const TreegeViewer: ({ flow,
|
|
93
|
+
declare const TreegeViewer: ({ flow, flowResponse, baseUrl, theme, excludedFields, excludeEmptyFields, collapsed, collapsedVisibleCount, className, renderField, renderRow, language, emptyText, }: TreegeViewerProps) => import("react/jsx-runtime").JSX.Element;
|
|
80
94
|
export default TreegeViewer;
|