@contractspec/lib.contracts-runtime-client-react 3.7.10 → 3.8.0
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/browser/drivers/rn-reusables.js +8 -0
- package/dist/browser/drivers/shadcn.js +8 -0
- package/dist/browser/feature-render.js +62 -6
- package/dist/browser/form-render.impl.js +8 -0
- package/dist/browser/form-render.js +8 -0
- package/dist/browser/index.js +65 -9
- package/dist/browser/transform-engine.js +66 -0
- package/dist/drivers/rn-reusables.js +2 -0
- package/dist/drivers/shadcn.js +2 -0
- package/dist/feature-render.d.ts +2 -3
- package/dist/feature-render.js +56 -6
- package/dist/form-render.impl.js +2 -0
- package/dist/form-render.js +2 -0
- package/dist/index.js +59 -9
- package/dist/node/drivers/rn-reusables.js +3 -0
- package/dist/node/drivers/shadcn.js +3 -0
- package/dist/node/feature-render.js +57 -6
- package/dist/node/form-render.impl.js +3 -0
- package/dist/node/form-render.js +3 -0
- package/dist/node/index.js +60 -9
- package/dist/node/transform-engine.js +61 -0
- package/dist/transform-engine.d.ts +17 -0
- package/dist/transform-engine.js +61 -0
- package/dist/transform-engine.test.d.ts +1 -0
- package/package.json +20 -6
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
+
}) : x)(function(x) {
|
|
4
|
+
if (typeof require !== "undefined")
|
|
5
|
+
return require.apply(this, arguments);
|
|
6
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
|
+
});
|
|
8
|
+
|
|
1
9
|
// src/drivers/rn-reusables.ts
|
|
2
10
|
function rnReusablesDriver(slots) {
|
|
3
11
|
return slots;
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
+
}) : x)(function(x) {
|
|
4
|
+
if (typeof require !== "undefined")
|
|
5
|
+
return require.apply(this, arguments);
|
|
6
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
|
+
});
|
|
8
|
+
|
|
1
9
|
// src/drivers/shadcn.ts
|
|
2
10
|
function shadcnDriver(slots) {
|
|
3
11
|
return slots;
|
|
@@ -1,10 +1,66 @@
|
|
|
1
|
-
|
|
1
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
+
}) : x)(function(x) {
|
|
4
|
+
if (typeof require !== "undefined")
|
|
5
|
+
return require.apply(this, arguments);
|
|
6
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
// src/transform-engine.ts
|
|
2
10
|
import {
|
|
3
11
|
createDefaultTransformEngine,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
} from "@contractspec/lib.
|
|
12
|
+
htmlToMarkdown,
|
|
13
|
+
registerBasicValidation
|
|
14
|
+
} from "@contractspec/lib.presentation-runtime-core/transform-engine";
|
|
7
15
|
import React from "react";
|
|
16
|
+
|
|
17
|
+
export * from "@contractspec/lib.presentation-runtime-core/transform-engine";
|
|
18
|
+
function registerDefaultReactRenderer(engine) {
|
|
19
|
+
engine.register({
|
|
20
|
+
target: "react",
|
|
21
|
+
async render(desc) {
|
|
22
|
+
if (desc.source.type === "component") {
|
|
23
|
+
const props = desc.source.props ? desc.source.props.getZod().safeParse({}).success ? {} : undefined : undefined;
|
|
24
|
+
return {
|
|
25
|
+
kind: "react_component",
|
|
26
|
+
componentKey: desc.source.componentKey,
|
|
27
|
+
props
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
kind: "blocknotejs",
|
|
32
|
+
docJson: desc.source.docJson,
|
|
33
|
+
blockConfig: desc.source.blockConfig
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
return engine;
|
|
38
|
+
}
|
|
39
|
+
function registerReactToMarkdownRenderer(engine, componentMap) {
|
|
40
|
+
engine.prependRegister({
|
|
41
|
+
target: "markdown",
|
|
42
|
+
async render(desc) {
|
|
43
|
+
if (desc.source.type !== "component") {
|
|
44
|
+
throw new Error("React-to-markdown renderer only handles component presentations");
|
|
45
|
+
}
|
|
46
|
+
const Component = componentMap[desc.source.componentKey];
|
|
47
|
+
if (!Component) {
|
|
48
|
+
throw new Error(`Component ${desc.source.componentKey} not found in componentMap`);
|
|
49
|
+
}
|
|
50
|
+
const { renderToStaticMarkup } = await import("react-dom/server");
|
|
51
|
+
const element = React.createElement(Component, desc.source.props ? {} : undefined);
|
|
52
|
+
const markdown = htmlToMarkdown(renderToStaticMarkup(element));
|
|
53
|
+
return {
|
|
54
|
+
mimeType: "text/markdown",
|
|
55
|
+
body: desc.policy?.pii?.length ? markdown.replace(/\[REDACTED\]/g, "[REDACTED]") : markdown
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
return engine;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// src/feature-render.ts
|
|
63
|
+
import React2 from "react";
|
|
8
64
|
function createEngineWithDefaults() {
|
|
9
65
|
return registerBasicValidation(registerDefaultReactRenderer(createDefaultTransformEngine()));
|
|
10
66
|
}
|
|
@@ -20,12 +76,12 @@ async function renderFeaturePresentation(engine, target, desc, options) {
|
|
|
20
76
|
...rd.props ?? {},
|
|
21
77
|
...options?.reactProps ?? {}
|
|
22
78
|
};
|
|
23
|
-
return
|
|
79
|
+
return React2.createElement(C, merged);
|
|
24
80
|
}
|
|
25
81
|
if (rd.kind === "blocknotejs") {
|
|
26
82
|
if (options?.renderBlockNote)
|
|
27
83
|
return options.renderBlockNote(rd.docJson, rd.blockConfig);
|
|
28
|
-
return
|
|
84
|
+
return React2.createElement("div", {}, "[BlockNote renderer not configured]");
|
|
29
85
|
}
|
|
30
86
|
return null;
|
|
31
87
|
}
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
+
}) : x)(function(x) {
|
|
4
|
+
if (typeof require !== "undefined")
|
|
5
|
+
return require.apply(this, arguments);
|
|
6
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
|
+
});
|
|
8
|
+
|
|
1
9
|
// src/form-render.impl.tsx
|
|
2
10
|
import {
|
|
3
11
|
buildZodWithRelations,
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
+
}) : x)(function(x) {
|
|
4
|
+
if (typeof require !== "undefined")
|
|
5
|
+
return require.apply(this, arguments);
|
|
6
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
|
+
});
|
|
8
|
+
|
|
1
9
|
// src/form-render.impl.tsx
|
|
2
10
|
import {
|
|
3
11
|
buildZodWithRelations,
|
package/dist/browser/index.js
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
+
}) : x)(function(x) {
|
|
4
|
+
if (typeof require !== "undefined")
|
|
5
|
+
return require.apply(this, arguments);
|
|
6
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
|
+
});
|
|
8
|
+
|
|
1
9
|
// src/drivers/rn-reusables.ts
|
|
2
10
|
function rnReusablesDriver(slots) {
|
|
3
11
|
return slots;
|
|
@@ -8,13 +16,61 @@ function shadcnDriver(slots) {
|
|
|
8
16
|
return slots;
|
|
9
17
|
}
|
|
10
18
|
|
|
11
|
-
// src/
|
|
19
|
+
// src/transform-engine.ts
|
|
12
20
|
import {
|
|
13
21
|
createDefaultTransformEngine,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
} from "@contractspec/lib.
|
|
22
|
+
htmlToMarkdown,
|
|
23
|
+
registerBasicValidation
|
|
24
|
+
} from "@contractspec/lib.presentation-runtime-core/transform-engine";
|
|
17
25
|
import React from "react";
|
|
26
|
+
|
|
27
|
+
export * from "@contractspec/lib.presentation-runtime-core/transform-engine";
|
|
28
|
+
function registerDefaultReactRenderer(engine) {
|
|
29
|
+
engine.register({
|
|
30
|
+
target: "react",
|
|
31
|
+
async render(desc) {
|
|
32
|
+
if (desc.source.type === "component") {
|
|
33
|
+
const props = desc.source.props ? desc.source.props.getZod().safeParse({}).success ? {} : undefined : undefined;
|
|
34
|
+
return {
|
|
35
|
+
kind: "react_component",
|
|
36
|
+
componentKey: desc.source.componentKey,
|
|
37
|
+
props
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
kind: "blocknotejs",
|
|
42
|
+
docJson: desc.source.docJson,
|
|
43
|
+
blockConfig: desc.source.blockConfig
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
return engine;
|
|
48
|
+
}
|
|
49
|
+
function registerReactToMarkdownRenderer(engine, componentMap) {
|
|
50
|
+
engine.prependRegister({
|
|
51
|
+
target: "markdown",
|
|
52
|
+
async render(desc) {
|
|
53
|
+
if (desc.source.type !== "component") {
|
|
54
|
+
throw new Error("React-to-markdown renderer only handles component presentations");
|
|
55
|
+
}
|
|
56
|
+
const Component = componentMap[desc.source.componentKey];
|
|
57
|
+
if (!Component) {
|
|
58
|
+
throw new Error(`Component ${desc.source.componentKey} not found in componentMap`);
|
|
59
|
+
}
|
|
60
|
+
const { renderToStaticMarkup } = await import("react-dom/server");
|
|
61
|
+
const element = React.createElement(Component, desc.source.props ? {} : undefined);
|
|
62
|
+
const markdown = htmlToMarkdown(renderToStaticMarkup(element));
|
|
63
|
+
return {
|
|
64
|
+
mimeType: "text/markdown",
|
|
65
|
+
body: desc.policy?.pii?.length ? markdown.replace(/\[REDACTED\]/g, "[REDACTED]") : markdown
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
return engine;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// src/feature-render.ts
|
|
73
|
+
import React2 from "react";
|
|
18
74
|
function createEngineWithDefaults() {
|
|
19
75
|
return registerBasicValidation(registerDefaultReactRenderer(createDefaultTransformEngine()));
|
|
20
76
|
}
|
|
@@ -30,12 +86,12 @@ async function renderFeaturePresentation(engine, target, desc, options) {
|
|
|
30
86
|
...rd.props ?? {},
|
|
31
87
|
...options?.reactProps ?? {}
|
|
32
88
|
};
|
|
33
|
-
return
|
|
89
|
+
return React2.createElement(C, merged);
|
|
34
90
|
}
|
|
35
91
|
if (rd.kind === "blocknotejs") {
|
|
36
92
|
if (options?.renderBlockNote)
|
|
37
93
|
return options.renderBlockNote(rd.docJson, rd.blockConfig);
|
|
38
|
-
return
|
|
94
|
+
return React2.createElement("div", {}, "[BlockNote renderer not configured]");
|
|
39
95
|
}
|
|
40
96
|
return null;
|
|
41
97
|
}
|
|
@@ -61,7 +117,7 @@ import {
|
|
|
61
117
|
evalPredicate
|
|
62
118
|
} from "@contractspec/lib.contracts-spec/forms";
|
|
63
119
|
import { zodResolver } from "@hookform/resolvers/zod";
|
|
64
|
-
import
|
|
120
|
+
import React3, { useEffect, useMemo, useState } from "react";
|
|
65
121
|
import {
|
|
66
122
|
Controller,
|
|
67
123
|
useFieldArray,
|
|
@@ -173,7 +229,7 @@ function createFormRenderer(base) {
|
|
|
173
229
|
children: f.descriptionI18n
|
|
174
230
|
}, undefined, false, undefined, this) : null;
|
|
175
231
|
if (f.kind === "group") {
|
|
176
|
-
const children = f.fields.map((c, i) => /* @__PURE__ */ jsxDEV(
|
|
232
|
+
const children = f.fields.map((c, i) => /* @__PURE__ */ jsxDEV(React3.Fragment, {
|
|
177
233
|
children: renderOne(c, name, arrayIndex)
|
|
178
234
|
}, `${name}-${i}`, false, undefined, this));
|
|
179
235
|
return /* @__PURE__ */ jsxDEV(DriverField, {
|
|
@@ -388,7 +444,7 @@ function createFormRenderer(base) {
|
|
|
388
444
|
return /* @__PURE__ */ jsxDEV("form", {
|
|
389
445
|
onSubmit: form.handleSubmit(onSubmit),
|
|
390
446
|
children: [
|
|
391
|
-
(spec.fields || []).map((f, i) => /* @__PURE__ */ jsxDEV(
|
|
447
|
+
(spec.fields || []).map((f, i) => /* @__PURE__ */ jsxDEV(React3.Fragment, {
|
|
392
448
|
children: renderOne(f)
|
|
393
449
|
}, i, false, undefined, this)),
|
|
394
450
|
spec.actions && spec.actions.length ? /* @__PURE__ */ jsxDEV("div", {
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
+
}) : x)(function(x) {
|
|
4
|
+
if (typeof require !== "undefined")
|
|
5
|
+
return require.apply(this, arguments);
|
|
6
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
// src/transform-engine.ts
|
|
10
|
+
import {
|
|
11
|
+
createDefaultTransformEngine,
|
|
12
|
+
htmlToMarkdown,
|
|
13
|
+
registerBasicValidation
|
|
14
|
+
} from "@contractspec/lib.presentation-runtime-core/transform-engine";
|
|
15
|
+
import React from "react";
|
|
16
|
+
|
|
17
|
+
export * from "@contractspec/lib.presentation-runtime-core/transform-engine";
|
|
18
|
+
function registerDefaultReactRenderer(engine) {
|
|
19
|
+
engine.register({
|
|
20
|
+
target: "react",
|
|
21
|
+
async render(desc) {
|
|
22
|
+
if (desc.source.type === "component") {
|
|
23
|
+
const props = desc.source.props ? desc.source.props.getZod().safeParse({}).success ? {} : undefined : undefined;
|
|
24
|
+
return {
|
|
25
|
+
kind: "react_component",
|
|
26
|
+
componentKey: desc.source.componentKey,
|
|
27
|
+
props
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
kind: "blocknotejs",
|
|
32
|
+
docJson: desc.source.docJson,
|
|
33
|
+
blockConfig: desc.source.blockConfig
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
return engine;
|
|
38
|
+
}
|
|
39
|
+
function registerReactToMarkdownRenderer(engine, componentMap) {
|
|
40
|
+
engine.prependRegister({
|
|
41
|
+
target: "markdown",
|
|
42
|
+
async render(desc) {
|
|
43
|
+
if (desc.source.type !== "component") {
|
|
44
|
+
throw new Error("React-to-markdown renderer only handles component presentations");
|
|
45
|
+
}
|
|
46
|
+
const Component = componentMap[desc.source.componentKey];
|
|
47
|
+
if (!Component) {
|
|
48
|
+
throw new Error(`Component ${desc.source.componentKey} not found in componentMap`);
|
|
49
|
+
}
|
|
50
|
+
const { renderToStaticMarkup } = await import("react-dom/server");
|
|
51
|
+
const element = React.createElement(Component, desc.source.props ? {} : undefined);
|
|
52
|
+
const markdown = htmlToMarkdown(renderToStaticMarkup(element));
|
|
53
|
+
return {
|
|
54
|
+
mimeType: "text/markdown",
|
|
55
|
+
body: desc.policy?.pii?.length ? markdown.replace(/\[REDACTED\]/g, "[REDACTED]") : markdown
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
return engine;
|
|
60
|
+
}
|
|
61
|
+
export {
|
|
62
|
+
registerReactToMarkdownRenderer,
|
|
63
|
+
registerDefaultReactRenderer,
|
|
64
|
+
registerBasicValidation,
|
|
65
|
+
createDefaultTransformEngine
|
|
66
|
+
};
|
package/dist/drivers/shadcn.js
CHANGED
package/dist/feature-render.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import type { BlockConfig } from '@blocknote/core';
|
|
2
1
|
import { type FeatureModuleSpec, FeatureRegistry } from '@contractspec/lib.contracts-spec/features';
|
|
3
|
-
import type { PresentationSpec, PresentationTarget } from '@contractspec/lib.contracts-spec/presentations';
|
|
4
|
-
import { type ComponentMap, TransformEngine } from '@contractspec/lib.contracts-spec/presentations/transform-engine';
|
|
2
|
+
import type { BlockConfig, PresentationSpec, PresentationTarget } from '@contractspec/lib.contracts-spec/presentations';
|
|
5
3
|
import React from 'react';
|
|
4
|
+
import { type ComponentMap, TransformEngine } from './transform-engine';
|
|
6
5
|
export declare function createEngineWithDefaults(): TransformEngine;
|
|
7
6
|
export declare function renderFeaturePresentation(engine: TransformEngine, target: PresentationTarget, desc: PresentationSpec, options?: {
|
|
8
7
|
componentMap?: ComponentMap;
|
package/dist/feature-render.js
CHANGED
|
@@ -1,11 +1,61 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
|
|
2
|
+
var __require = import.meta.require;
|
|
3
|
+
|
|
4
|
+
// src/transform-engine.ts
|
|
3
5
|
import {
|
|
4
6
|
createDefaultTransformEngine,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from "@contractspec/lib.
|
|
7
|
+
htmlToMarkdown,
|
|
8
|
+
registerBasicValidation
|
|
9
|
+
} from "@contractspec/lib.presentation-runtime-core/transform-engine";
|
|
8
10
|
import React from "react";
|
|
11
|
+
|
|
12
|
+
export * from "@contractspec/lib.presentation-runtime-core/transform-engine";
|
|
13
|
+
function registerDefaultReactRenderer(engine) {
|
|
14
|
+
engine.register({
|
|
15
|
+
target: "react",
|
|
16
|
+
async render(desc) {
|
|
17
|
+
if (desc.source.type === "component") {
|
|
18
|
+
const props = desc.source.props ? desc.source.props.getZod().safeParse({}).success ? {} : undefined : undefined;
|
|
19
|
+
return {
|
|
20
|
+
kind: "react_component",
|
|
21
|
+
componentKey: desc.source.componentKey,
|
|
22
|
+
props
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
kind: "blocknotejs",
|
|
27
|
+
docJson: desc.source.docJson,
|
|
28
|
+
blockConfig: desc.source.blockConfig
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
return engine;
|
|
33
|
+
}
|
|
34
|
+
function registerReactToMarkdownRenderer(engine, componentMap) {
|
|
35
|
+
engine.prependRegister({
|
|
36
|
+
target: "markdown",
|
|
37
|
+
async render(desc) {
|
|
38
|
+
if (desc.source.type !== "component") {
|
|
39
|
+
throw new Error("React-to-markdown renderer only handles component presentations");
|
|
40
|
+
}
|
|
41
|
+
const Component = componentMap[desc.source.componentKey];
|
|
42
|
+
if (!Component) {
|
|
43
|
+
throw new Error(`Component ${desc.source.componentKey} not found in componentMap`);
|
|
44
|
+
}
|
|
45
|
+
const { renderToStaticMarkup } = await import("react-dom/server");
|
|
46
|
+
const element = React.createElement(Component, desc.source.props ? {} : undefined);
|
|
47
|
+
const markdown = htmlToMarkdown(renderToStaticMarkup(element));
|
|
48
|
+
return {
|
|
49
|
+
mimeType: "text/markdown",
|
|
50
|
+
body: desc.policy?.pii?.length ? markdown.replace(/\[REDACTED\]/g, "[REDACTED]") : markdown
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
return engine;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// src/feature-render.ts
|
|
58
|
+
import React2 from "react";
|
|
9
59
|
function createEngineWithDefaults() {
|
|
10
60
|
return registerBasicValidation(registerDefaultReactRenderer(createDefaultTransformEngine()));
|
|
11
61
|
}
|
|
@@ -21,12 +71,12 @@ async function renderFeaturePresentation(engine, target, desc, options) {
|
|
|
21
71
|
...rd.props ?? {},
|
|
22
72
|
...options?.reactProps ?? {}
|
|
23
73
|
};
|
|
24
|
-
return
|
|
74
|
+
return React2.createElement(C, merged);
|
|
25
75
|
}
|
|
26
76
|
if (rd.kind === "blocknotejs") {
|
|
27
77
|
if (options?.renderBlockNote)
|
|
28
78
|
return options.renderBlockNote(rd.docJson, rd.blockConfig);
|
|
29
|
-
return
|
|
79
|
+
return React2.createElement("div", {}, "[BlockNote renderer not configured]");
|
|
30
80
|
}
|
|
31
81
|
return null;
|
|
32
82
|
}
|
package/dist/form-render.impl.js
CHANGED
package/dist/form-render.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
|
+
var __require = import.meta.require;
|
|
3
|
+
|
|
2
4
|
// src/drivers/rn-reusables.ts
|
|
3
5
|
function rnReusablesDriver(slots) {
|
|
4
6
|
return slots;
|
|
@@ -9,13 +11,61 @@ function shadcnDriver(slots) {
|
|
|
9
11
|
return slots;
|
|
10
12
|
}
|
|
11
13
|
|
|
12
|
-
// src/
|
|
14
|
+
// src/transform-engine.ts
|
|
13
15
|
import {
|
|
14
16
|
createDefaultTransformEngine,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
} from "@contractspec/lib.
|
|
17
|
+
htmlToMarkdown,
|
|
18
|
+
registerBasicValidation
|
|
19
|
+
} from "@contractspec/lib.presentation-runtime-core/transform-engine";
|
|
18
20
|
import React from "react";
|
|
21
|
+
|
|
22
|
+
export * from "@contractspec/lib.presentation-runtime-core/transform-engine";
|
|
23
|
+
function registerDefaultReactRenderer(engine) {
|
|
24
|
+
engine.register({
|
|
25
|
+
target: "react",
|
|
26
|
+
async render(desc) {
|
|
27
|
+
if (desc.source.type === "component") {
|
|
28
|
+
const props = desc.source.props ? desc.source.props.getZod().safeParse({}).success ? {} : undefined : undefined;
|
|
29
|
+
return {
|
|
30
|
+
kind: "react_component",
|
|
31
|
+
componentKey: desc.source.componentKey,
|
|
32
|
+
props
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
kind: "blocknotejs",
|
|
37
|
+
docJson: desc.source.docJson,
|
|
38
|
+
blockConfig: desc.source.blockConfig
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
return engine;
|
|
43
|
+
}
|
|
44
|
+
function registerReactToMarkdownRenderer(engine, componentMap) {
|
|
45
|
+
engine.prependRegister({
|
|
46
|
+
target: "markdown",
|
|
47
|
+
async render(desc) {
|
|
48
|
+
if (desc.source.type !== "component") {
|
|
49
|
+
throw new Error("React-to-markdown renderer only handles component presentations");
|
|
50
|
+
}
|
|
51
|
+
const Component = componentMap[desc.source.componentKey];
|
|
52
|
+
if (!Component) {
|
|
53
|
+
throw new Error(`Component ${desc.source.componentKey} not found in componentMap`);
|
|
54
|
+
}
|
|
55
|
+
const { renderToStaticMarkup } = await import("react-dom/server");
|
|
56
|
+
const element = React.createElement(Component, desc.source.props ? {} : undefined);
|
|
57
|
+
const markdown = htmlToMarkdown(renderToStaticMarkup(element));
|
|
58
|
+
return {
|
|
59
|
+
mimeType: "text/markdown",
|
|
60
|
+
body: desc.policy?.pii?.length ? markdown.replace(/\[REDACTED\]/g, "[REDACTED]") : markdown
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
return engine;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// src/feature-render.ts
|
|
68
|
+
import React2 from "react";
|
|
19
69
|
function createEngineWithDefaults() {
|
|
20
70
|
return registerBasicValidation(registerDefaultReactRenderer(createDefaultTransformEngine()));
|
|
21
71
|
}
|
|
@@ -31,12 +81,12 @@ async function renderFeaturePresentation(engine, target, desc, options) {
|
|
|
31
81
|
...rd.props ?? {},
|
|
32
82
|
...options?.reactProps ?? {}
|
|
33
83
|
};
|
|
34
|
-
return
|
|
84
|
+
return React2.createElement(C, merged);
|
|
35
85
|
}
|
|
36
86
|
if (rd.kind === "blocknotejs") {
|
|
37
87
|
if (options?.renderBlockNote)
|
|
38
88
|
return options.renderBlockNote(rd.docJson, rd.blockConfig);
|
|
39
|
-
return
|
|
89
|
+
return React2.createElement("div", {}, "[BlockNote renderer not configured]");
|
|
40
90
|
}
|
|
41
91
|
return null;
|
|
42
92
|
}
|
|
@@ -62,7 +112,7 @@ import {
|
|
|
62
112
|
evalPredicate
|
|
63
113
|
} from "@contractspec/lib.contracts-spec/forms";
|
|
64
114
|
import { zodResolver } from "@hookform/resolvers/zod";
|
|
65
|
-
import
|
|
115
|
+
import React3, { useEffect, useMemo, useState } from "react";
|
|
66
116
|
import {
|
|
67
117
|
Controller,
|
|
68
118
|
useFieldArray,
|
|
@@ -174,7 +224,7 @@ function createFormRenderer(base) {
|
|
|
174
224
|
children: f.descriptionI18n
|
|
175
225
|
}, undefined, false, undefined, this) : null;
|
|
176
226
|
if (f.kind === "group") {
|
|
177
|
-
const children = f.fields.map((c, i) => /* @__PURE__ */ jsxDEV(
|
|
227
|
+
const children = f.fields.map((c, i) => /* @__PURE__ */ jsxDEV(React3.Fragment, {
|
|
178
228
|
children: renderOne(c, name, arrayIndex)
|
|
179
229
|
}, `${name}-${i}`, false, undefined, this));
|
|
180
230
|
return /* @__PURE__ */ jsxDEV(DriverField, {
|
|
@@ -389,7 +439,7 @@ function createFormRenderer(base) {
|
|
|
389
439
|
return /* @__PURE__ */ jsxDEV("form", {
|
|
390
440
|
onSubmit: form.handleSubmit(onSubmit),
|
|
391
441
|
children: [
|
|
392
|
-
(spec.fields || []).map((f, i) => /* @__PURE__ */ jsxDEV(
|
|
442
|
+
(spec.fields || []).map((f, i) => /* @__PURE__ */ jsxDEV(React3.Fragment, {
|
|
393
443
|
children: renderOne(f)
|
|
394
444
|
}, i, false, undefined, this)),
|
|
395
445
|
spec.actions && spec.actions.length ? /* @__PURE__ */ jsxDEV("div", {
|
|
@@ -1,10 +1,61 @@
|
|
|
1
|
-
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
3
|
+
|
|
4
|
+
// src/transform-engine.ts
|
|
2
5
|
import {
|
|
3
6
|
createDefaultTransformEngine,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
} from "@contractspec/lib.
|
|
7
|
+
htmlToMarkdown,
|
|
8
|
+
registerBasicValidation
|
|
9
|
+
} from "@contractspec/lib.presentation-runtime-core/transform-engine";
|
|
7
10
|
import React from "react";
|
|
11
|
+
|
|
12
|
+
export * from "@contractspec/lib.presentation-runtime-core/transform-engine";
|
|
13
|
+
function registerDefaultReactRenderer(engine) {
|
|
14
|
+
engine.register({
|
|
15
|
+
target: "react",
|
|
16
|
+
async render(desc) {
|
|
17
|
+
if (desc.source.type === "component") {
|
|
18
|
+
const props = desc.source.props ? desc.source.props.getZod().safeParse({}).success ? {} : undefined : undefined;
|
|
19
|
+
return {
|
|
20
|
+
kind: "react_component",
|
|
21
|
+
componentKey: desc.source.componentKey,
|
|
22
|
+
props
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
kind: "blocknotejs",
|
|
27
|
+
docJson: desc.source.docJson,
|
|
28
|
+
blockConfig: desc.source.blockConfig
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
return engine;
|
|
33
|
+
}
|
|
34
|
+
function registerReactToMarkdownRenderer(engine, componentMap) {
|
|
35
|
+
engine.prependRegister({
|
|
36
|
+
target: "markdown",
|
|
37
|
+
async render(desc) {
|
|
38
|
+
if (desc.source.type !== "component") {
|
|
39
|
+
throw new Error("React-to-markdown renderer only handles component presentations");
|
|
40
|
+
}
|
|
41
|
+
const Component = componentMap[desc.source.componentKey];
|
|
42
|
+
if (!Component) {
|
|
43
|
+
throw new Error(`Component ${desc.source.componentKey} not found in componentMap`);
|
|
44
|
+
}
|
|
45
|
+
const { renderToStaticMarkup } = await import("react-dom/server");
|
|
46
|
+
const element = React.createElement(Component, desc.source.props ? {} : undefined);
|
|
47
|
+
const markdown = htmlToMarkdown(renderToStaticMarkup(element));
|
|
48
|
+
return {
|
|
49
|
+
mimeType: "text/markdown",
|
|
50
|
+
body: desc.policy?.pii?.length ? markdown.replace(/\[REDACTED\]/g, "[REDACTED]") : markdown
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
return engine;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// src/feature-render.ts
|
|
58
|
+
import React2 from "react";
|
|
8
59
|
function createEngineWithDefaults() {
|
|
9
60
|
return registerBasicValidation(registerDefaultReactRenderer(createDefaultTransformEngine()));
|
|
10
61
|
}
|
|
@@ -20,12 +71,12 @@ async function renderFeaturePresentation(engine, target, desc, options) {
|
|
|
20
71
|
...rd.props ?? {},
|
|
21
72
|
...options?.reactProps ?? {}
|
|
22
73
|
};
|
|
23
|
-
return
|
|
74
|
+
return React2.createElement(C, merged);
|
|
24
75
|
}
|
|
25
76
|
if (rd.kind === "blocknotejs") {
|
|
26
77
|
if (options?.renderBlockNote)
|
|
27
78
|
return options.renderBlockNote(rd.docJson, rd.blockConfig);
|
|
28
|
-
return
|
|
79
|
+
return React2.createElement("div", {}, "[BlockNote renderer not configured]");
|
|
29
80
|
}
|
|
30
81
|
return null;
|
|
31
82
|
}
|
package/dist/node/form-render.js
CHANGED
package/dist/node/index.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
3
|
+
|
|
1
4
|
// src/drivers/rn-reusables.ts
|
|
2
5
|
function rnReusablesDriver(slots) {
|
|
3
6
|
return slots;
|
|
@@ -8,13 +11,61 @@ function shadcnDriver(slots) {
|
|
|
8
11
|
return slots;
|
|
9
12
|
}
|
|
10
13
|
|
|
11
|
-
// src/
|
|
14
|
+
// src/transform-engine.ts
|
|
12
15
|
import {
|
|
13
16
|
createDefaultTransformEngine,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
} from "@contractspec/lib.
|
|
17
|
+
htmlToMarkdown,
|
|
18
|
+
registerBasicValidation
|
|
19
|
+
} from "@contractspec/lib.presentation-runtime-core/transform-engine";
|
|
17
20
|
import React from "react";
|
|
21
|
+
|
|
22
|
+
export * from "@contractspec/lib.presentation-runtime-core/transform-engine";
|
|
23
|
+
function registerDefaultReactRenderer(engine) {
|
|
24
|
+
engine.register({
|
|
25
|
+
target: "react",
|
|
26
|
+
async render(desc) {
|
|
27
|
+
if (desc.source.type === "component") {
|
|
28
|
+
const props = desc.source.props ? desc.source.props.getZod().safeParse({}).success ? {} : undefined : undefined;
|
|
29
|
+
return {
|
|
30
|
+
kind: "react_component",
|
|
31
|
+
componentKey: desc.source.componentKey,
|
|
32
|
+
props
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
kind: "blocknotejs",
|
|
37
|
+
docJson: desc.source.docJson,
|
|
38
|
+
blockConfig: desc.source.blockConfig
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
return engine;
|
|
43
|
+
}
|
|
44
|
+
function registerReactToMarkdownRenderer(engine, componentMap) {
|
|
45
|
+
engine.prependRegister({
|
|
46
|
+
target: "markdown",
|
|
47
|
+
async render(desc) {
|
|
48
|
+
if (desc.source.type !== "component") {
|
|
49
|
+
throw new Error("React-to-markdown renderer only handles component presentations");
|
|
50
|
+
}
|
|
51
|
+
const Component = componentMap[desc.source.componentKey];
|
|
52
|
+
if (!Component) {
|
|
53
|
+
throw new Error(`Component ${desc.source.componentKey} not found in componentMap`);
|
|
54
|
+
}
|
|
55
|
+
const { renderToStaticMarkup } = await import("react-dom/server");
|
|
56
|
+
const element = React.createElement(Component, desc.source.props ? {} : undefined);
|
|
57
|
+
const markdown = htmlToMarkdown(renderToStaticMarkup(element));
|
|
58
|
+
return {
|
|
59
|
+
mimeType: "text/markdown",
|
|
60
|
+
body: desc.policy?.pii?.length ? markdown.replace(/\[REDACTED\]/g, "[REDACTED]") : markdown
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
return engine;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// src/feature-render.ts
|
|
68
|
+
import React2 from "react";
|
|
18
69
|
function createEngineWithDefaults() {
|
|
19
70
|
return registerBasicValidation(registerDefaultReactRenderer(createDefaultTransformEngine()));
|
|
20
71
|
}
|
|
@@ -30,12 +81,12 @@ async function renderFeaturePresentation(engine, target, desc, options) {
|
|
|
30
81
|
...rd.props ?? {},
|
|
31
82
|
...options?.reactProps ?? {}
|
|
32
83
|
};
|
|
33
|
-
return
|
|
84
|
+
return React2.createElement(C, merged);
|
|
34
85
|
}
|
|
35
86
|
if (rd.kind === "blocknotejs") {
|
|
36
87
|
if (options?.renderBlockNote)
|
|
37
88
|
return options.renderBlockNote(rd.docJson, rd.blockConfig);
|
|
38
|
-
return
|
|
89
|
+
return React2.createElement("div", {}, "[BlockNote renderer not configured]");
|
|
39
90
|
}
|
|
40
91
|
return null;
|
|
41
92
|
}
|
|
@@ -61,7 +112,7 @@ import {
|
|
|
61
112
|
evalPredicate
|
|
62
113
|
} from "@contractspec/lib.contracts-spec/forms";
|
|
63
114
|
import { zodResolver } from "@hookform/resolvers/zod";
|
|
64
|
-
import
|
|
115
|
+
import React3, { useEffect, useMemo, useState } from "react";
|
|
65
116
|
import {
|
|
66
117
|
Controller,
|
|
67
118
|
useFieldArray,
|
|
@@ -173,7 +224,7 @@ function createFormRenderer(base) {
|
|
|
173
224
|
children: f.descriptionI18n
|
|
174
225
|
}, undefined, false, undefined, this) : null;
|
|
175
226
|
if (f.kind === "group") {
|
|
176
|
-
const children = f.fields.map((c, i) => /* @__PURE__ */ jsxDEV(
|
|
227
|
+
const children = f.fields.map((c, i) => /* @__PURE__ */ jsxDEV(React3.Fragment, {
|
|
177
228
|
children: renderOne(c, name, arrayIndex)
|
|
178
229
|
}, `${name}-${i}`, false, undefined, this));
|
|
179
230
|
return /* @__PURE__ */ jsxDEV(DriverField, {
|
|
@@ -388,7 +439,7 @@ function createFormRenderer(base) {
|
|
|
388
439
|
return /* @__PURE__ */ jsxDEV("form", {
|
|
389
440
|
onSubmit: form.handleSubmit(onSubmit),
|
|
390
441
|
children: [
|
|
391
|
-
(spec.fields || []).map((f, i) => /* @__PURE__ */ jsxDEV(
|
|
442
|
+
(spec.fields || []).map((f, i) => /* @__PURE__ */ jsxDEV(React3.Fragment, {
|
|
392
443
|
children: renderOne(f)
|
|
393
444
|
}, i, false, undefined, this)),
|
|
394
445
|
spec.actions && spec.actions.length ? /* @__PURE__ */ jsxDEV("div", {
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
3
|
+
|
|
4
|
+
// src/transform-engine.ts
|
|
5
|
+
import {
|
|
6
|
+
createDefaultTransformEngine,
|
|
7
|
+
htmlToMarkdown,
|
|
8
|
+
registerBasicValidation
|
|
9
|
+
} from "@contractspec/lib.presentation-runtime-core/transform-engine";
|
|
10
|
+
import React from "react";
|
|
11
|
+
|
|
12
|
+
export * from "@contractspec/lib.presentation-runtime-core/transform-engine";
|
|
13
|
+
function registerDefaultReactRenderer(engine) {
|
|
14
|
+
engine.register({
|
|
15
|
+
target: "react",
|
|
16
|
+
async render(desc) {
|
|
17
|
+
if (desc.source.type === "component") {
|
|
18
|
+
const props = desc.source.props ? desc.source.props.getZod().safeParse({}).success ? {} : undefined : undefined;
|
|
19
|
+
return {
|
|
20
|
+
kind: "react_component",
|
|
21
|
+
componentKey: desc.source.componentKey,
|
|
22
|
+
props
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
kind: "blocknotejs",
|
|
27
|
+
docJson: desc.source.docJson,
|
|
28
|
+
blockConfig: desc.source.blockConfig
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
return engine;
|
|
33
|
+
}
|
|
34
|
+
function registerReactToMarkdownRenderer(engine, componentMap) {
|
|
35
|
+
engine.prependRegister({
|
|
36
|
+
target: "markdown",
|
|
37
|
+
async render(desc) {
|
|
38
|
+
if (desc.source.type !== "component") {
|
|
39
|
+
throw new Error("React-to-markdown renderer only handles component presentations");
|
|
40
|
+
}
|
|
41
|
+
const Component = componentMap[desc.source.componentKey];
|
|
42
|
+
if (!Component) {
|
|
43
|
+
throw new Error(`Component ${desc.source.componentKey} not found in componentMap`);
|
|
44
|
+
}
|
|
45
|
+
const { renderToStaticMarkup } = await import("react-dom/server");
|
|
46
|
+
const element = React.createElement(Component, desc.source.props ? {} : undefined);
|
|
47
|
+
const markdown = htmlToMarkdown(renderToStaticMarkup(element));
|
|
48
|
+
return {
|
|
49
|
+
mimeType: "text/markdown",
|
|
50
|
+
body: desc.policy?.pii?.length ? markdown.replace(/\[REDACTED\]/g, "[REDACTED]") : markdown
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
return engine;
|
|
55
|
+
}
|
|
56
|
+
export {
|
|
57
|
+
registerReactToMarkdownRenderer,
|
|
58
|
+
registerDefaultReactRenderer,
|
|
59
|
+
registerBasicValidation,
|
|
60
|
+
createDefaultTransformEngine
|
|
61
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { BlockConfig } from '@contractspec/lib.contracts-spec/presentations';
|
|
2
|
+
import { createDefaultTransformEngine, registerBasicValidation, type TransformEngine } from '@contractspec/lib.presentation-runtime-core/transform-engine';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
export * from '@contractspec/lib.presentation-runtime-core/transform-engine';
|
|
5
|
+
export { createDefaultTransformEngine, registerBasicValidation };
|
|
6
|
+
export type ReactRenderDescriptor = {
|
|
7
|
+
kind: 'react_component';
|
|
8
|
+
componentKey: string;
|
|
9
|
+
props?: Record<string, unknown>;
|
|
10
|
+
} | {
|
|
11
|
+
kind: 'blocknotejs';
|
|
12
|
+
docJson: unknown;
|
|
13
|
+
blockConfig?: BlockConfig;
|
|
14
|
+
};
|
|
15
|
+
export type ComponentMap = Record<string, React.ComponentType<Record<string, unknown>>>;
|
|
16
|
+
export declare function registerDefaultReactRenderer(engine: TransformEngine): TransformEngine;
|
|
17
|
+
export declare function registerReactToMarkdownRenderer(engine: TransformEngine, componentMap: ComponentMap): TransformEngine;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
var __require = import.meta.require;
|
|
3
|
+
|
|
4
|
+
// src/transform-engine.ts
|
|
5
|
+
import {
|
|
6
|
+
createDefaultTransformEngine,
|
|
7
|
+
htmlToMarkdown,
|
|
8
|
+
registerBasicValidation
|
|
9
|
+
} from "@contractspec/lib.presentation-runtime-core/transform-engine";
|
|
10
|
+
import React from "react";
|
|
11
|
+
|
|
12
|
+
export * from "@contractspec/lib.presentation-runtime-core/transform-engine";
|
|
13
|
+
function registerDefaultReactRenderer(engine) {
|
|
14
|
+
engine.register({
|
|
15
|
+
target: "react",
|
|
16
|
+
async render(desc) {
|
|
17
|
+
if (desc.source.type === "component") {
|
|
18
|
+
const props = desc.source.props ? desc.source.props.getZod().safeParse({}).success ? {} : undefined : undefined;
|
|
19
|
+
return {
|
|
20
|
+
kind: "react_component",
|
|
21
|
+
componentKey: desc.source.componentKey,
|
|
22
|
+
props
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
kind: "blocknotejs",
|
|
27
|
+
docJson: desc.source.docJson,
|
|
28
|
+
blockConfig: desc.source.blockConfig
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
return engine;
|
|
33
|
+
}
|
|
34
|
+
function registerReactToMarkdownRenderer(engine, componentMap) {
|
|
35
|
+
engine.prependRegister({
|
|
36
|
+
target: "markdown",
|
|
37
|
+
async render(desc) {
|
|
38
|
+
if (desc.source.type !== "component") {
|
|
39
|
+
throw new Error("React-to-markdown renderer only handles component presentations");
|
|
40
|
+
}
|
|
41
|
+
const Component = componentMap[desc.source.componentKey];
|
|
42
|
+
if (!Component) {
|
|
43
|
+
throw new Error(`Component ${desc.source.componentKey} not found in componentMap`);
|
|
44
|
+
}
|
|
45
|
+
const { renderToStaticMarkup } = await import("react-dom/server");
|
|
46
|
+
const element = React.createElement(Component, desc.source.props ? {} : undefined);
|
|
47
|
+
const markdown = htmlToMarkdown(renderToStaticMarkup(element));
|
|
48
|
+
return {
|
|
49
|
+
mimeType: "text/markdown",
|
|
50
|
+
body: desc.policy?.pii?.length ? markdown.replace(/\[REDACTED\]/g, "[REDACTED]") : markdown
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
return engine;
|
|
55
|
+
}
|
|
56
|
+
export {
|
|
57
|
+
registerReactToMarkdownRenderer,
|
|
58
|
+
registerDefaultReactRenderer,
|
|
59
|
+
registerBasicValidation,
|
|
60
|
+
createDefaultTransformEngine
|
|
61
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contractspec/lib.contracts-runtime-client-react",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.8.0",
|
|
4
4
|
"description": "React runtime adapters for ContractSpec contracts",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -24,20 +24,20 @@
|
|
|
24
24
|
"directory": "packages/libs/contract-runtime-client-react"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
|
-
"@blocknote/core": "^0.47.1",
|
|
28
27
|
"@hookform/resolvers": "^5.2.2",
|
|
29
28
|
"react": "^19.2.0",
|
|
30
29
|
"react-dom": "^19.2.0",
|
|
31
30
|
"react-hook-form": "^7.70.0"
|
|
32
31
|
},
|
|
33
32
|
"dependencies": {
|
|
34
|
-
"@contractspec/lib.contracts-spec": "
|
|
35
|
-
"@contractspec/lib.schema": "3.7.
|
|
33
|
+
"@contractspec/lib.contracts-spec": "5.0.0",
|
|
34
|
+
"@contractspec/lib.schema": "3.7.10",
|
|
35
|
+
"@contractspec/lib.presentation-runtime-core": "3.9.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@contractspec/tool.typescript": "3.7.
|
|
38
|
+
"@contractspec/tool.typescript": "3.7.9",
|
|
39
39
|
"typescript": "^5.9.3",
|
|
40
|
-
"@contractspec/tool.bun": "3.7.
|
|
40
|
+
"@contractspec/tool.bun": "3.7.9"
|
|
41
41
|
},
|
|
42
42
|
"files": [
|
|
43
43
|
"dist",
|
|
@@ -85,6 +85,13 @@
|
|
|
85
85
|
"bun": "./dist/form-render.impl.js",
|
|
86
86
|
"node": "./dist/node/form-render.impl.js",
|
|
87
87
|
"default": "./dist/form-render.impl.js"
|
|
88
|
+
},
|
|
89
|
+
"./transform-engine": {
|
|
90
|
+
"types": "./dist/transform-engine.d.ts",
|
|
91
|
+
"browser": "./dist/browser/transform-engine.js",
|
|
92
|
+
"bun": "./dist/transform-engine.js",
|
|
93
|
+
"node": "./dist/node/transform-engine.js",
|
|
94
|
+
"default": "./dist/transform-engine.js"
|
|
88
95
|
}
|
|
89
96
|
},
|
|
90
97
|
"publishConfig": {
|
|
@@ -132,6 +139,13 @@
|
|
|
132
139
|
"bun": "./dist/form-render.impl.js",
|
|
133
140
|
"node": "./dist/node/form-render.impl.js",
|
|
134
141
|
"default": "./dist/form-render.impl.js"
|
|
142
|
+
},
|
|
143
|
+
"./transform-engine": {
|
|
144
|
+
"types": "./dist/transform-engine.d.ts",
|
|
145
|
+
"browser": "./dist/browser/transform-engine.js",
|
|
146
|
+
"bun": "./dist/transform-engine.js",
|
|
147
|
+
"node": "./dist/node/transform-engine.js",
|
|
148
|
+
"default": "./dist/transform-engine.js"
|
|
135
149
|
}
|
|
136
150
|
}
|
|
137
151
|
}
|