@valbuild/react 0.57.0 → 0.59.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/ValProvider-09e313e2.worker.esm.js +87 -0
- package/dist/ValProvider-461fa48b.cjs.js +7 -0
- package/dist/ValProvider-461fa48b.cjs.prod.js +115 -0
- package/dist/ValProvider-a3b1e699.esm.js +92 -0
- package/dist/ValProvider-b34afe68.browser.esm.js +92 -0
- package/dist/ValProvider-d17e4d13.cjs.dev.js +121 -0
- package/dist/{ValUI-891df000.cjs.dev.js → ValUI-1922d8db.cjs.dev.js} +3 -2
- package/dist/ValUI-23e2422b.cjs.js +7 -0
- package/dist/{ValUI-323cc3ff.cjs.prod.js → ValUI-23e2422b.cjs.prod.js} +3 -2
- package/dist/{ValUI-b82ca977.browser.esm.js → ValUI-7d39a3f6.browser.esm.js} +3 -2
- package/dist/{ValUI-29f95099.worker.esm.js → ValUI-84a9cc93.worker.esm.js} +3 -2
- package/dist/{ValUI-04c66635.esm.js → ValUI-8775ef5c.esm.js} +3 -2
- package/dist/declarations/src/internal/ValProvider.d.ts +1 -1
- package/dist/declarations/src/internal/ValRichText.d.ts +67 -14
- package/dist/{slicedToArray-a2a426c7.cjs.prod.js → slicedToArray-11a666de.cjs.dev.js} +3 -17
- package/dist/{slicedToArray-d4c4a4ed.worker.esm.js → slicedToArray-1dc7d2d6.esm.js} +3 -16
- package/dist/{slicedToArray-331bebbb.esm.js → slicedToArray-7b69258f.browser.esm.js} +3 -16
- package/dist/{slicedToArray-a9d0d9cd.cjs.dev.js → slicedToArray-c405fbf0.cjs.prod.js} +3 -17
- package/dist/{slicedToArray-85f6bb43.browser.esm.js → slicedToArray-e7da2c5e.worker.esm.js} +3 -16
- package/dist/toConsumableArray-0a75a603.worker.esm.js +19 -0
- package/dist/toConsumableArray-0ccd58b7.esm.js +19 -0
- package/dist/toConsumableArray-5a71fbb3.browser.esm.js +19 -0
- package/dist/toConsumableArray-b2d28ffa.cjs.dev.js +21 -0
- package/dist/toConsumableArray-b5e3b83f.cjs.prod.js +21 -0
- package/dist/unsupportedIterableToArray-42309462.cjs.prod.js +19 -0
- package/dist/unsupportedIterableToArray-50359a05.worker.esm.js +16 -0
- package/dist/unsupportedIterableToArray-7c30dadf.esm.js +16 -0
- package/dist/unsupportedIterableToArray-ac28611a.cjs.dev.js +19 -0
- package/dist/unsupportedIterableToArray-cce3cb41.browser.esm.js +16 -0
- package/internal/dist/valbuild-react-internal.browser.esm.js +95 -131
- package/internal/dist/valbuild-react-internal.cjs.dev.js +95 -131
- package/internal/dist/valbuild-react-internal.cjs.prod.js +95 -131
- package/internal/dist/valbuild-react-internal.esm.js +95 -131
- package/internal/dist/valbuild-react-internal.worker.esm.js +95 -131
- package/jsx-dev-runtime/dist/valbuild-react-jsx-dev-runtime.browser.esm.js +2 -1
- package/jsx-dev-runtime/dist/valbuild-react-jsx-dev-runtime.cjs.dev.js +2 -1
- package/jsx-dev-runtime/dist/valbuild-react-jsx-dev-runtime.cjs.prod.js +2 -1
- package/jsx-dev-runtime/dist/valbuild-react-jsx-dev-runtime.esm.js +2 -1
- package/jsx-dev-runtime/dist/valbuild-react-jsx-dev-runtime.worker.esm.js +2 -1
- package/jsx-runtime/dist/valbuild-react-jsx-runtime.browser.esm.js +2 -1
- package/jsx-runtime/dist/valbuild-react-jsx-runtime.cjs.dev.js +2 -1
- package/jsx-runtime/dist/valbuild-react-jsx-runtime.cjs.prod.js +2 -1
- package/jsx-runtime/dist/valbuild-react-jsx-runtime.esm.js +2 -1
- package/jsx-runtime/dist/valbuild-react-jsx-runtime.worker.esm.js +2 -1
- package/package.json +4 -4
- package/stega/dist/valbuild-react-stega.browser.esm.js +54 -7
- package/stega/dist/valbuild-react-stega.cjs.dev.js +55 -8
- package/stega/dist/valbuild-react-stega.cjs.prod.js +55 -8
- package/stega/dist/valbuild-react-stega.esm.js +54 -7
- package/stega/dist/valbuild-react-stega.worker.esm.js +54 -7
- package/dist/ValProvider-1009cb51.cjs.dev.js +0 -717
- package/dist/ValProvider-6a12fd8e.browser.esm.js +0 -688
- package/dist/ValProvider-8ec03a73.esm.js +0 -688
- package/dist/ValProvider-c7d7067b.cjs.js +0 -7
- package/dist/ValProvider-c7d7067b.cjs.prod.js +0 -711
- package/dist/ValProvider-ecf57703.worker.esm.js +0 -683
- package/dist/ValUI-323cc3ff.cjs.js +0 -7
- package/dist/declarations/src/internal/ValStore.d.ts +0 -16
- package/dist/defineProperty-6ed7deb7.browser.esm.js +0 -32
- package/dist/defineProperty-82fbeafc.worker.esm.js +0 -32
- package/dist/defineProperty-9bf3d0c0.esm.js +0 -32
- package/dist/defineProperty-c84f9aba.cjs.dev.js +0 -35
- package/dist/defineProperty-f8fe5660.cjs.prod.js +0 -35
|
@@ -2,154 +2,118 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var ValProvider = require('../../dist/ValProvider-
|
|
5
|
+
var ValProvider = require('../../dist/ValProvider-461fa48b.cjs.prod.js');
|
|
6
|
+
var toConsumableArray = require('../../dist/toConsumableArray-b5e3b83f.cjs.prod.js');
|
|
6
7
|
var React = require('react');
|
|
7
8
|
var ReactJSXRuntime = require('react/jsx-runtime');
|
|
9
|
+
require('../../dist/unsupportedIterableToArray-42309462.cjs.prod.js');
|
|
8
10
|
|
|
9
11
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
10
12
|
|
|
11
13
|
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Render RichText as HTML
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* const content = useVal(contentVal);
|
|
20
|
+
* return <ValRichText>{content.myRichText}</ValRichText>
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* const content = useVal(contentVal);
|
|
24
|
+
* return (
|
|
25
|
+
* <ValRichText
|
|
26
|
+
* theme={{
|
|
27
|
+
* h1: 'text-4xl font-bold',
|
|
28
|
+
* }}>
|
|
29
|
+
* {content.myRichText}
|
|
30
|
+
* </ValRichText>
|
|
31
|
+
* );
|
|
32
|
+
*
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* const content = useVal(contentVal);
|
|
36
|
+
* return (
|
|
37
|
+
* <ValRichText
|
|
38
|
+
* theme={{
|
|
39
|
+
* h1: 'text-4xl font-bold',
|
|
40
|
+
* img: 'rounded',
|
|
41
|
+
* }}
|
|
42
|
+
* transform={(node, className) => {
|
|
43
|
+
* if (node.tag === 'img') {
|
|
44
|
+
* return <Image className={className} src={node.src} alt={node.alt || ""} width={node.metadata?.width} height={node.metadata?.height} />
|
|
45
|
+
* }
|
|
46
|
+
* }}>
|
|
47
|
+
* {content.myRichText}
|
|
48
|
+
* </ValRichText>
|
|
49
|
+
* );
|
|
50
|
+
*
|
|
51
|
+
* @param
|
|
52
|
+
* @returns
|
|
53
|
+
*/
|
|
14
54
|
function ValRichText(_ref) {
|
|
15
|
-
var
|
|
55
|
+
var children = _ref.children,
|
|
16
56
|
className = _ref.className,
|
|
17
|
-
|
|
57
|
+
style = _ref.style,
|
|
58
|
+
theme = _ref.theme,
|
|
59
|
+
transform = _ref.transform;
|
|
18
60
|
var root = children;
|
|
19
|
-
function
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if (node.tag === "p") {
|
|
45
|
-
return /*#__PURE__*/ReactJSXRuntime.jsx("p", {
|
|
46
|
-
className: withRenderTag("p"),
|
|
47
|
-
children: node.children.map(toReact)
|
|
48
|
-
}, key);
|
|
49
|
-
}
|
|
50
|
-
if (node.tag === "img") {
|
|
51
|
-
return /*#__PURE__*/ReactJSXRuntime.jsx("img", {
|
|
52
|
-
className: withRenderTag("img"),
|
|
53
|
-
src: node.src
|
|
54
|
-
}, key);
|
|
55
|
-
}
|
|
56
|
-
if (node.tag === "ul") {
|
|
57
|
-
return /*#__PURE__*/ReactJSXRuntime.jsx("ul", {
|
|
58
|
-
className: withRenderTag("ul"),
|
|
59
|
-
children: node.children.map(toReact)
|
|
60
|
-
}, key);
|
|
61
|
-
}
|
|
62
|
-
if (node.tag === "ol") {
|
|
63
|
-
return /*#__PURE__*/ReactJSXRuntime.jsx("ol", {
|
|
64
|
-
className: withRenderTag("ol"),
|
|
65
|
-
children: node.children.map(toReact)
|
|
66
|
-
}, key);
|
|
67
|
-
}
|
|
68
|
-
if (node.tag === "li") {
|
|
69
|
-
return /*#__PURE__*/ReactJSXRuntime.jsx("li", {
|
|
70
|
-
className: withRenderTag("li"),
|
|
71
|
-
children: node.children.map(toReact)
|
|
72
|
-
}, key);
|
|
73
|
-
}
|
|
74
|
-
if (node.tag === "span") {
|
|
75
|
-
return /*#__PURE__*/ReactJSXRuntime.jsx("span", {
|
|
76
|
-
className: node.classes.map(function (nodeClass) {
|
|
77
|
-
switch (nodeClass) {
|
|
78
|
-
case "bold":
|
|
79
|
-
return withRenderClass("bold");
|
|
80
|
-
case "line-through":
|
|
81
|
-
return withRenderClass("lineThrough");
|
|
82
|
-
case "italic":
|
|
83
|
-
return withRenderClass("italic");
|
|
84
|
-
}
|
|
85
|
-
}).join(" "),
|
|
86
|
-
children: node.children.map(toReact)
|
|
87
|
-
}, key);
|
|
88
|
-
}
|
|
89
|
-
if (node.tag === "h1") {
|
|
90
|
-
return /*#__PURE__*/ReactJSXRuntime.jsx("h1", {
|
|
91
|
-
className: withRenderTag("h1"),
|
|
92
|
-
children: node.children.map(toReact)
|
|
93
|
-
}, key);
|
|
94
|
-
}
|
|
95
|
-
if (node.tag === "h2") {
|
|
96
|
-
return /*#__PURE__*/ReactJSXRuntime.jsx("h2", {
|
|
97
|
-
className: withRenderTag("h2"),
|
|
98
|
-
children: node.children.map(toReact)
|
|
99
|
-
}, key);
|
|
100
|
-
}
|
|
101
|
-
if (node.tag === "h3") {
|
|
102
|
-
return /*#__PURE__*/ReactJSXRuntime.jsx("h3", {
|
|
103
|
-
className: withRenderTag("h3"),
|
|
104
|
-
children: node.children.map(toReact)
|
|
105
|
-
}, key);
|
|
106
|
-
}
|
|
107
|
-
if (node.tag === "h4") {
|
|
108
|
-
return /*#__PURE__*/ReactJSXRuntime.jsx("h4", {
|
|
109
|
-
className: withRenderTag("h4"),
|
|
110
|
-
children: node.children.map(toReact)
|
|
111
|
-
}, key);
|
|
112
|
-
}
|
|
113
|
-
if (node.tag === "h5") {
|
|
114
|
-
return /*#__PURE__*/ReactJSXRuntime.jsx("h5", {
|
|
115
|
-
className: withRenderTag("h5"),
|
|
116
|
-
children: node.children.map(toReact)
|
|
117
|
-
}, key);
|
|
118
|
-
}
|
|
119
|
-
if (node.tag === "h6") {
|
|
120
|
-
return /*#__PURE__*/ReactJSXRuntime.jsx("h6", {
|
|
121
|
-
className: withRenderTag("h6"),
|
|
122
|
-
children: node.children.map(toReact)
|
|
123
|
-
}, key);
|
|
124
|
-
}
|
|
125
|
-
if (node.tag === "br") {
|
|
126
|
-
return /*#__PURE__*/ReactJSXRuntime.jsx("br", {}, key);
|
|
127
|
-
}
|
|
128
|
-
if (node.tag === "a") {
|
|
129
|
-
return /*#__PURE__*/ReactJSXRuntime.jsx("a", {
|
|
130
|
-
href: node.href,
|
|
131
|
-
children: node.children.map(toReact)
|
|
132
|
-
}, key);
|
|
133
|
-
}
|
|
134
|
-
console.error("Unknown tag", node.tag);
|
|
135
|
-
var _exhaustiveCheck = node.tag;
|
|
136
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
137
|
-
var anyNode = _exhaustiveCheck;
|
|
138
|
-
if (!(anyNode !== null && anyNode !== void 0 && anyNode.tag)) {
|
|
139
|
-
return null;
|
|
140
|
-
}
|
|
141
|
-
return /*#__PURE__*/React__default["default"].createElement(anyNode.tag, {
|
|
142
|
-
key: key,
|
|
143
|
-
className: (_anyNode$class = anyNode["class"]) === null || _anyNode$class === void 0 ? void 0 : _anyNode$class.join(" "),
|
|
144
|
-
children: (_anyNode$children = anyNode.children) === null || _anyNode$children === void 0 ? void 0 : _anyNode$children.map(toReact)
|
|
61
|
+
function build(child, key) {
|
|
62
|
+
if (typeof child === "string") {
|
|
63
|
+
var transformed = transform && transform(child, []);
|
|
64
|
+
if (transformed !== undefined) {
|
|
65
|
+
return transformed;
|
|
66
|
+
}
|
|
67
|
+
return child;
|
|
68
|
+
}
|
|
69
|
+
var className = classNameOfTag(child.tag, "classes" in child ? child.classes : [], theme);
|
|
70
|
+
var children = "children" in child ?
|
|
71
|
+
// Why do this? We get a very weird error in NextJS 14.0.4 if we do not
|
|
72
|
+
// Error: Cannot access Image.prototype on the server. You cannot dot into a client module from a server component. You can only pass the imported name through.
|
|
73
|
+
// https://github.com/vercel/next.js/issues/52415
|
|
74
|
+
child.children.length === 1 ? build(child.children[0]) : child.children.map(build) : null;
|
|
75
|
+
if (transform) {
|
|
76
|
+
var _transformed = transform(child, children !== null && children !== void 0 ? children : [], className);
|
|
77
|
+
if (_transformed !== undefined) {
|
|
78
|
+
return _transformed;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
var tag = child.tag; // one of: "img" | "a" | "ul" | "ol" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "br" | "p" | "li" | "span"
|
|
82
|
+
return /*#__PURE__*/React__default["default"].createElement(tag, {
|
|
83
|
+
key: key === null || key === void 0 ? void 0 : key.toString(),
|
|
84
|
+
className: className,
|
|
85
|
+
children: children
|
|
145
86
|
});
|
|
146
87
|
}
|
|
147
88
|
return /*#__PURE__*/ReactJSXRuntime.jsx("div", {
|
|
148
89
|
className: className,
|
|
90
|
+
style: style,
|
|
149
91
|
"data-val-path": root.valPath,
|
|
150
|
-
children: root.children.map(
|
|
92
|
+
children: root.children.map(build)
|
|
151
93
|
});
|
|
152
94
|
}
|
|
95
|
+
function classNameOfTag(tag, clazz, theme) {
|
|
96
|
+
var thisTagClassName = null;
|
|
97
|
+
if (theme && tag in theme) {
|
|
98
|
+
var _theme$tag;
|
|
99
|
+
thisTagClassName = (_theme$tag = theme[tag]) !== null && _theme$tag !== void 0 ? _theme$tag : null;
|
|
100
|
+
}
|
|
101
|
+
return [].concat(toConsumableArray._toConsumableArray(thisTagClassName ? [thisTagClassName] : []), toConsumableArray._toConsumableArray(clazz.map(function (style) {
|
|
102
|
+
if (theme &&
|
|
103
|
+
// not need on type-level, but defensive on runtime:
|
|
104
|
+
typeof style === "string") {
|
|
105
|
+
if (style === "line-through") {
|
|
106
|
+
if ("lineThrough" in theme) {
|
|
107
|
+
return theme["lineThrough"];
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
if (style !== "line-through" && style in theme) {
|
|
111
|
+
return theme[style];
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return clazz;
|
|
115
|
+
}))).join(" ");
|
|
116
|
+
}
|
|
153
117
|
|
|
154
118
|
Object.defineProperty(exports, 'ValProvider', {
|
|
155
119
|
enumerable: true,
|
|
@@ -1,146 +1,110 @@
|
|
|
1
|
-
export { ValProvider, useValApi, useValStore } from '../../dist/ValProvider-
|
|
1
|
+
export { ValProvider, useValApi, useValStore } from '../../dist/ValProvider-a3b1e699.esm.js';
|
|
2
|
+
import { _ as _toConsumableArray } from '../../dist/toConsumableArray-0ccd58b7.esm.js';
|
|
2
3
|
import React from 'react';
|
|
3
4
|
import { jsx } from 'react/jsx-runtime';
|
|
5
|
+
import '../../dist/unsupportedIterableToArray-7c30dadf.esm.js';
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Render RichText as HTML
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* const content = useVal(contentVal);
|
|
12
|
+
* return <ValRichText>{content.myRichText}</ValRichText>
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* const content = useVal(contentVal);
|
|
16
|
+
* return (
|
|
17
|
+
* <ValRichText
|
|
18
|
+
* theme={{
|
|
19
|
+
* h1: 'text-4xl font-bold',
|
|
20
|
+
* }}>
|
|
21
|
+
* {content.myRichText}
|
|
22
|
+
* </ValRichText>
|
|
23
|
+
* );
|
|
24
|
+
*
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* const content = useVal(contentVal);
|
|
28
|
+
* return (
|
|
29
|
+
* <ValRichText
|
|
30
|
+
* theme={{
|
|
31
|
+
* h1: 'text-4xl font-bold',
|
|
32
|
+
* img: 'rounded',
|
|
33
|
+
* }}
|
|
34
|
+
* transform={(node, className) => {
|
|
35
|
+
* if (node.tag === 'img') {
|
|
36
|
+
* return <Image className={className} src={node.src} alt={node.alt || ""} width={node.metadata?.width} height={node.metadata?.height} />
|
|
37
|
+
* }
|
|
38
|
+
* }}>
|
|
39
|
+
* {content.myRichText}
|
|
40
|
+
* </ValRichText>
|
|
41
|
+
* );
|
|
42
|
+
*
|
|
43
|
+
* @param
|
|
44
|
+
* @returns
|
|
45
|
+
*/
|
|
6
46
|
function ValRichText(_ref) {
|
|
7
|
-
var
|
|
47
|
+
var children = _ref.children,
|
|
8
48
|
className = _ref.className,
|
|
9
|
-
|
|
49
|
+
style = _ref.style,
|
|
50
|
+
theme = _ref.theme,
|
|
51
|
+
transform = _ref.transform;
|
|
10
52
|
var root = children;
|
|
11
|
-
function
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
if (node.tag === "p") {
|
|
37
|
-
return /*#__PURE__*/jsx("p", {
|
|
38
|
-
className: withRenderTag("p"),
|
|
39
|
-
children: node.children.map(toReact)
|
|
40
|
-
}, key);
|
|
41
|
-
}
|
|
42
|
-
if (node.tag === "img") {
|
|
43
|
-
return /*#__PURE__*/jsx("img", {
|
|
44
|
-
className: withRenderTag("img"),
|
|
45
|
-
src: node.src
|
|
46
|
-
}, key);
|
|
47
|
-
}
|
|
48
|
-
if (node.tag === "ul") {
|
|
49
|
-
return /*#__PURE__*/jsx("ul", {
|
|
50
|
-
className: withRenderTag("ul"),
|
|
51
|
-
children: node.children.map(toReact)
|
|
52
|
-
}, key);
|
|
53
|
-
}
|
|
54
|
-
if (node.tag === "ol") {
|
|
55
|
-
return /*#__PURE__*/jsx("ol", {
|
|
56
|
-
className: withRenderTag("ol"),
|
|
57
|
-
children: node.children.map(toReact)
|
|
58
|
-
}, key);
|
|
59
|
-
}
|
|
60
|
-
if (node.tag === "li") {
|
|
61
|
-
return /*#__PURE__*/jsx("li", {
|
|
62
|
-
className: withRenderTag("li"),
|
|
63
|
-
children: node.children.map(toReact)
|
|
64
|
-
}, key);
|
|
65
|
-
}
|
|
66
|
-
if (node.tag === "span") {
|
|
67
|
-
return /*#__PURE__*/jsx("span", {
|
|
68
|
-
className: node.classes.map(function (nodeClass) {
|
|
69
|
-
switch (nodeClass) {
|
|
70
|
-
case "bold":
|
|
71
|
-
return withRenderClass("bold");
|
|
72
|
-
case "line-through":
|
|
73
|
-
return withRenderClass("lineThrough");
|
|
74
|
-
case "italic":
|
|
75
|
-
return withRenderClass("italic");
|
|
76
|
-
}
|
|
77
|
-
}).join(" "),
|
|
78
|
-
children: node.children.map(toReact)
|
|
79
|
-
}, key);
|
|
80
|
-
}
|
|
81
|
-
if (node.tag === "h1") {
|
|
82
|
-
return /*#__PURE__*/jsx("h1", {
|
|
83
|
-
className: withRenderTag("h1"),
|
|
84
|
-
children: node.children.map(toReact)
|
|
85
|
-
}, key);
|
|
86
|
-
}
|
|
87
|
-
if (node.tag === "h2") {
|
|
88
|
-
return /*#__PURE__*/jsx("h2", {
|
|
89
|
-
className: withRenderTag("h2"),
|
|
90
|
-
children: node.children.map(toReact)
|
|
91
|
-
}, key);
|
|
92
|
-
}
|
|
93
|
-
if (node.tag === "h3") {
|
|
94
|
-
return /*#__PURE__*/jsx("h3", {
|
|
95
|
-
className: withRenderTag("h3"),
|
|
96
|
-
children: node.children.map(toReact)
|
|
97
|
-
}, key);
|
|
98
|
-
}
|
|
99
|
-
if (node.tag === "h4") {
|
|
100
|
-
return /*#__PURE__*/jsx("h4", {
|
|
101
|
-
className: withRenderTag("h4"),
|
|
102
|
-
children: node.children.map(toReact)
|
|
103
|
-
}, key);
|
|
104
|
-
}
|
|
105
|
-
if (node.tag === "h5") {
|
|
106
|
-
return /*#__PURE__*/jsx("h5", {
|
|
107
|
-
className: withRenderTag("h5"),
|
|
108
|
-
children: node.children.map(toReact)
|
|
109
|
-
}, key);
|
|
110
|
-
}
|
|
111
|
-
if (node.tag === "h6") {
|
|
112
|
-
return /*#__PURE__*/jsx("h6", {
|
|
113
|
-
className: withRenderTag("h6"),
|
|
114
|
-
children: node.children.map(toReact)
|
|
115
|
-
}, key);
|
|
116
|
-
}
|
|
117
|
-
if (node.tag === "br") {
|
|
118
|
-
return /*#__PURE__*/jsx("br", {}, key);
|
|
119
|
-
}
|
|
120
|
-
if (node.tag === "a") {
|
|
121
|
-
return /*#__PURE__*/jsx("a", {
|
|
122
|
-
href: node.href,
|
|
123
|
-
children: node.children.map(toReact)
|
|
124
|
-
}, key);
|
|
125
|
-
}
|
|
126
|
-
console.error("Unknown tag", node.tag);
|
|
127
|
-
var _exhaustiveCheck = node.tag;
|
|
128
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
129
|
-
var anyNode = _exhaustiveCheck;
|
|
130
|
-
if (!(anyNode !== null && anyNode !== void 0 && anyNode.tag)) {
|
|
131
|
-
return null;
|
|
132
|
-
}
|
|
133
|
-
return /*#__PURE__*/React.createElement(anyNode.tag, {
|
|
134
|
-
key: key,
|
|
135
|
-
className: (_anyNode$class = anyNode["class"]) === null || _anyNode$class === void 0 ? void 0 : _anyNode$class.join(" "),
|
|
136
|
-
children: (_anyNode$children = anyNode.children) === null || _anyNode$children === void 0 ? void 0 : _anyNode$children.map(toReact)
|
|
53
|
+
function build(child, key) {
|
|
54
|
+
if (typeof child === "string") {
|
|
55
|
+
var transformed = transform && transform(child, []);
|
|
56
|
+
if (transformed !== undefined) {
|
|
57
|
+
return transformed;
|
|
58
|
+
}
|
|
59
|
+
return child;
|
|
60
|
+
}
|
|
61
|
+
var className = classNameOfTag(child.tag, "classes" in child ? child.classes : [], theme);
|
|
62
|
+
var children = "children" in child ?
|
|
63
|
+
// Why do this? We get a very weird error in NextJS 14.0.4 if we do not
|
|
64
|
+
// Error: Cannot access Image.prototype on the server. You cannot dot into a client module from a server component. You can only pass the imported name through.
|
|
65
|
+
// https://github.com/vercel/next.js/issues/52415
|
|
66
|
+
child.children.length === 1 ? build(child.children[0]) : child.children.map(build) : null;
|
|
67
|
+
if (transform) {
|
|
68
|
+
var _transformed = transform(child, children !== null && children !== void 0 ? children : [], className);
|
|
69
|
+
if (_transformed !== undefined) {
|
|
70
|
+
return _transformed;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
var tag = child.tag; // one of: "img" | "a" | "ul" | "ol" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "br" | "p" | "li" | "span"
|
|
74
|
+
return /*#__PURE__*/React.createElement(tag, {
|
|
75
|
+
key: key === null || key === void 0 ? void 0 : key.toString(),
|
|
76
|
+
className: className,
|
|
77
|
+
children: children
|
|
137
78
|
});
|
|
138
79
|
}
|
|
139
80
|
return /*#__PURE__*/jsx("div", {
|
|
140
81
|
className: className,
|
|
82
|
+
style: style,
|
|
141
83
|
"data-val-path": root.valPath,
|
|
142
|
-
children: root.children.map(
|
|
84
|
+
children: root.children.map(build)
|
|
143
85
|
});
|
|
144
86
|
}
|
|
87
|
+
function classNameOfTag(tag, clazz, theme) {
|
|
88
|
+
var thisTagClassName = null;
|
|
89
|
+
if (theme && tag in theme) {
|
|
90
|
+
var _theme$tag;
|
|
91
|
+
thisTagClassName = (_theme$tag = theme[tag]) !== null && _theme$tag !== void 0 ? _theme$tag : null;
|
|
92
|
+
}
|
|
93
|
+
return [].concat(_toConsumableArray(thisTagClassName ? [thisTagClassName] : []), _toConsumableArray(clazz.map(function (style) {
|
|
94
|
+
if (theme &&
|
|
95
|
+
// not need on type-level, but defensive on runtime:
|
|
96
|
+
typeof style === "string") {
|
|
97
|
+
if (style === "line-through") {
|
|
98
|
+
if ("lineThrough" in theme) {
|
|
99
|
+
return theme["lineThrough"];
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (style !== "line-through" && style in theme) {
|
|
103
|
+
return theme[style];
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return clazz;
|
|
107
|
+
}))).join(" ");
|
|
108
|
+
}
|
|
145
109
|
|
|
146
110
|
export { ValRichText };
|