treege 3.0.0-beta.81 → 3.0.0-beta.83
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/{DefaultSubmitButton-Dg9GPvh-.js → DefaultSubmitButton-DpeL3OxC.js} +758 -702
- package/dist/{ThemeContext-BgTIhoK6.js → ThemeContext-BnPOFQC7.js} +82 -74
- package/dist/editor/features/TreegeEditor/inputs/TranslatableInput.d.ts +20 -0
- package/dist/{editor-h20-TVM8.js → editor-CbcW0OVV.js} +1340 -1430
- package/dist/editor.js +2 -2
- package/dist/main.js +6 -6
- package/dist/renderer/features/TreegeViewer/utils/viewerFields.d.ts +78 -0
- package/dist/renderer/features/TreegeViewer/web/TreegeViewer.d.ts +70 -0
- package/dist/renderer/index.d.ts +3 -0
- package/dist/renderer/utils/file.d.ts +15 -2
- package/dist/renderer-KRzuU6OD.js +411 -0
- package/dist/renderer-native.js +946 -946
- package/dist/renderer.js +5 -5
- package/dist/shared/utils/normalizeLabel.d.ts +2 -1
- package/dist/shared/utils/translations.d.ts +21 -1
- package/dist/useRenderNode-DQ5lvXuj.js +527 -0
- package/package.json +1 -1
- package/dist/renderer-DI6nF4St.js +0 -256
- package/dist/useRenderNode-B1sfwbia.js +0 -527
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-CbcW0OVV.js";
|
|
2
|
+
import { n as t, t as n } from "./ThemeContext-BnPOFQC7.js";
|
|
3
3
|
export { n as ThemeProvider, e as TreegeEditor, t as useTheme };
|
package/dist/main.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as e } from "./editor-
|
|
2
|
-
import {
|
|
3
|
-
import { C as
|
|
4
|
-
import { a as
|
|
5
|
-
import { i as
|
|
6
|
-
export {
|
|
1
|
+
import { t as e } from "./editor-CbcW0OVV.js";
|
|
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
|
+
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
|
+
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 $, i as ee, n as te, o as ne, r as re, s as ie, t as ae } from "./renderer-KRzuU6OD.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, $ as Divider, C as ThemeProvider, ne as Title, e as TreegeEditor, ee as TreegeRenderer, K as TreegeRendererProvider, ae as TreegeViewer, x as applyReferenceTransformation, h as buildInitialFormValues, u as calculateReferenceFieldUpdates, y as checkFormFieldHasValue, S as convertFormValuesToNamedFormat, R as defaultInputRenderers, ie 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, te as getViewerFields, f as isFieldEmpty, b as isGroupNode, re 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 };
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { Node } from '@xyflow/react';
|
|
2
|
+
import { FormValues } from '../../../types/renderer';
|
|
3
|
+
import { SerializableFile } from '../../../../shared/types/file';
|
|
4
|
+
import { Flow, InputNodeData, InputType } from '../../../../shared/types/node';
|
|
5
|
+
/**
|
|
6
|
+
* Display-ready representation of a submitted field value, normalized per input
|
|
7
|
+
* type so a viewer can render it without re-deriving formatting rules:
|
|
8
|
+
* - `text` free-form string (text, number, date, ranges, resolved option label…)
|
|
9
|
+
* - `boolean` a yes/no value (switch) — render as a read-only toggle/checkbox
|
|
10
|
+
* - `tags` a list of labels (multi-select checkbox) — render as chips
|
|
11
|
+
* - `files` uploaded documents — render names or thumbnails (often overridden)
|
|
12
|
+
* - `empty` no value was submitted for this field
|
|
13
|
+
*/
|
|
14
|
+
export type ViewerFieldDisplay = {
|
|
15
|
+
kind: "text";
|
|
16
|
+
text: string;
|
|
17
|
+
} | {
|
|
18
|
+
kind: "boolean";
|
|
19
|
+
checked: boolean;
|
|
20
|
+
} | {
|
|
21
|
+
kind: "tags";
|
|
22
|
+
tags: string[];
|
|
23
|
+
} | {
|
|
24
|
+
kind: "files";
|
|
25
|
+
files: SerializableFile[];
|
|
26
|
+
} | {
|
|
27
|
+
kind: "empty";
|
|
28
|
+
};
|
|
29
|
+
/** A single resolved field of a submitted form, ready for read-only rendering. */
|
|
30
|
+
export interface ViewerField {
|
|
31
|
+
/** The flow node id. */
|
|
32
|
+
id: string;
|
|
33
|
+
/** The submission key (name > translated label > id), as used in `onSubmit`. */
|
|
34
|
+
name: string;
|
|
35
|
+
/** The input type (`text`, `select`, `daterange`, `file`, …). */
|
|
36
|
+
type: InputType;
|
|
37
|
+
/** The translated field label (falls back to `name`, then node id). */
|
|
38
|
+
label: string;
|
|
39
|
+
/** The raw submitted value, untouched. */
|
|
40
|
+
rawValue: unknown;
|
|
41
|
+
/** Normalized, render-ready representation of the value. */
|
|
42
|
+
display: ViewerFieldDisplay;
|
|
43
|
+
/** The originating flow node (escape hatch for custom rendering). */
|
|
44
|
+
node: Node<InputNodeData>;
|
|
45
|
+
}
|
|
46
|
+
export interface GetViewerFieldsOptions {
|
|
47
|
+
/** Language used to resolve translatable labels/options (defaults to `en`). */
|
|
48
|
+
language?: string;
|
|
49
|
+
/**
|
|
50
|
+
* Base URL used to resolve relative file paths (e.g. `uploads/x.png`) into
|
|
51
|
+
* absolute URLs — same role as on `TreegeRenderer`/`TreegeEditor`. Absolute,
|
|
52
|
+
* `data:` and `blob:` URLs are left untouched.
|
|
53
|
+
*/
|
|
54
|
+
baseUrl?: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Whether a file should be previewed inline as an image — detected by MIME type
|
|
58
|
+
* (`image/*`), a `data:image/` data-URL, or a recognized image URL extension.
|
|
59
|
+
*/
|
|
60
|
+
export declare const isImageFile: (file: SerializableFile) => boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Resolve a submitted form into a flat, render-ready list of fields.
|
|
63
|
+
*
|
|
64
|
+
* Mirrors what the renderer would show for the same values: the submission is
|
|
65
|
+
* normalized to node-id keys (accepting both `name`- and `id`-keyed input, like
|
|
66
|
+
* `initialValues`), then run through the same branch-visibility logic so only
|
|
67
|
+
* the fields that were actually reachable for these values are returned —
|
|
68
|
+
* inactive branches and `hidden`/`submit` nodes are excluded.
|
|
69
|
+
*
|
|
70
|
+
* This is the headless core behind {@link TreegeViewer}: consumers wanting a
|
|
71
|
+
* custom layout can render straight from this list.
|
|
72
|
+
*
|
|
73
|
+
* @param flow - The flow definition the values were submitted against
|
|
74
|
+
* @param values - The submitted values (`name`- or `id`-keyed)
|
|
75
|
+
* @param options - Resolution options (language, baseUrl)
|
|
76
|
+
* @returns The ordered, visible, display-ready fields
|
|
77
|
+
*/
|
|
78
|
+
export declare const getViewerFields: (flow: Flow | null | undefined, values: FormValues | null | undefined, options?: GetViewerFieldsOptions) => ViewerField[];
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { ViewerField } from '../utils/viewerFields';
|
|
3
|
+
import { FormValues } from '../../../types/renderer';
|
|
4
|
+
import { Flow, InputType } from '../../../../shared/types/node';
|
|
5
|
+
/** Per-type override map: `{ file: (field) => <Thumbnails /> }`. */
|
|
6
|
+
export type ViewerFieldRenderers = Partial<Record<InputType, (field: ViewerField) => ReactNode>>;
|
|
7
|
+
export interface TreegeViewerProps {
|
|
8
|
+
/**
|
|
9
|
+
* The flow the values were submitted against
|
|
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`).
|
|
18
|
+
*/
|
|
19
|
+
language?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Base URL used to resolve relative file paths into absolute URLs — same role
|
|
22
|
+
* as on `TreegeRenderer`/`TreegeEditor`. `data:`/`blob:`/absolute URLs are
|
|
23
|
+
* left untouched.
|
|
24
|
+
*/
|
|
25
|
+
baseUrl?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Field names (or ids) to hide from the view.
|
|
28
|
+
*/
|
|
29
|
+
excludedFields?: string[];
|
|
30
|
+
/**
|
|
31
|
+
* Text shown when a field has no submitted value (defaults to `"—"`).
|
|
32
|
+
*/
|
|
33
|
+
emptyText?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Extra class names on the root element. *
|
|
36
|
+
*/
|
|
37
|
+
className?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Per-type rendering overrides for the value cell. Use this for app-specific
|
|
40
|
+
* cases — typically `file` (e.g. render thumbnails from your own storage)
|
|
41
|
+
* while every other type keeps its built-in rendering.
|
|
42
|
+
*/
|
|
43
|
+
renderField?: ViewerFieldRenderers;
|
|
44
|
+
/**
|
|
45
|
+
* Wrap or replace a whole field row (label + value). Receives the resolved
|
|
46
|
+
* field and the default row node; return your own layout or the default.
|
|
47
|
+
*/
|
|
48
|
+
renderRow?: (field: ViewerField, defaultRow: ReactNode) => ReactNode;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Read-only viewer for a submitted Treege form. Given the `flow` and the
|
|
52
|
+
* submitted `values`, it renders every reachable field as a label/value pair —
|
|
53
|
+
* resolving option labels, formatting dates/ranges and i18n labels the same way
|
|
54
|
+
* the renderer does, scoped to the active branch.
|
|
55
|
+
*
|
|
56
|
+
* Styling matches the renderer (shadcn/Tailwind, `tg:` prefix). For values that
|
|
57
|
+
* need app-specific rendering (chiefly uploaded `file`s) pass `renderField`; to
|
|
58
|
+
* change the whole row layout pass `renderRow`.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* <TreegeViewer
|
|
62
|
+
* flow={flow}
|
|
63
|
+
* values={submitted}
|
|
64
|
+
* language="fr"
|
|
65
|
+
* excludedFields={["internalNote"]}
|
|
66
|
+
* renderField={{ file: ({ rawValue }) => <Thumbnails files={rawValue} /> }}
|
|
67
|
+
* />
|
|
68
|
+
*/
|
|
69
|
+
declare const TreegeViewer: ({ flow, values, baseUrl, excludedFields, className, renderField, renderRow, emptyText, language, }: TreegeViewerProps) => import("react/jsx-runtime").JSX.Element;
|
|
70
|
+
export default TreegeViewer;
|
package/dist/renderer/index.d.ts
CHANGED
|
@@ -9,6 +9,9 @@ export * from './features/TreegeRenderer/web/components/DefaultSubmitButton';
|
|
|
9
9
|
export * from './features/TreegeRenderer/web/components/DefaultUI';
|
|
10
10
|
export * from './features/TreegeRenderer/web/TreegeRenderer';
|
|
11
11
|
export { default as TreegeRenderer } from './features/TreegeRenderer/web/TreegeRenderer';
|
|
12
|
+
export * from './features/TreegeViewer/utils/viewerFields';
|
|
13
|
+
export * from './features/TreegeViewer/web/TreegeViewer';
|
|
14
|
+
export { default as TreegeViewer } from './features/TreegeViewer/web/TreegeViewer';
|
|
12
15
|
export type { TreegeRendererConfig } from './types/renderer';
|
|
13
16
|
export * from './types/renderer';
|
|
14
17
|
export * from './utils/conditions';
|
|
@@ -12,11 +12,24 @@ export declare const serializableToFile: (serializable: SerializableFile) => Fil
|
|
|
12
12
|
* Converts multiple File objects to serializable format
|
|
13
13
|
*/
|
|
14
14
|
export declare const filesToSerializable: (files: File[]) => Promise<SerializableFile[]>;
|
|
15
|
+
/**
|
|
16
|
+
* Derive a readable file name from a URL's last path segment (query/hash stripped).
|
|
17
|
+
*/
|
|
18
|
+
export declare const fileNameFromUrl: (url: string) => string;
|
|
19
|
+
/**
|
|
20
|
+
* Whether a file's `data` is a URL to fetch/link to (an http(s) or relative
|
|
21
|
+
* path) rather than inline base64/blob content. Useful to decide whether to
|
|
22
|
+
* render the file as a clickable link or resolve it against a base URL.
|
|
23
|
+
*/
|
|
24
|
+
export declare const isRemoteFileData: (data: string | null | undefined) => boolean;
|
|
15
25
|
/**
|
|
16
26
|
* Normalizes a file field value into an array of `SerializableFile`.
|
|
17
|
-
* Handles single file, array
|
|
27
|
+
* Handles a single file, an array, and empty (`null`/`undefined`) values. A
|
|
28
|
+
* stored document may also be referenced by a bare URL string (or an array
|
|
29
|
+
* containing some) — those are coerced into a `SerializableFile` whose `data`
|
|
30
|
+
* holds the URL and whose `name` is derived from it.
|
|
18
31
|
*/
|
|
19
|
-
export declare const normalizeSerializableFiles: (value: SerializableFile | SerializableFile
|
|
32
|
+
export declare const normalizeSerializableFiles: (value: SerializableFile | string | Array<SerializableFile | string> | null | undefined) => SerializableFile[];
|
|
20
33
|
/**
|
|
21
34
|
* Formats a byte size into a human-readable string (B / KB / MB)
|
|
22
35
|
*/
|