@valbuild/react 0.30.0 → 0.32.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/{ValProviderInternal-06aa7448.esm.js → ValProvider-0620664e.esm.js} +68 -17
- package/dist/{ValProviderInternal-4c19d576.browser.esm.js → ValProvider-14179159.browser.esm.js} +67 -16
- package/dist/{ValProviderInternal-2faf106c.cjs.dev.js → ValProvider-7513c6ec.cjs.dev.js} +85 -17
- package/dist/ValProvider-b2e83d12.cjs.js +7 -0
- package/dist/{ValProviderInternal-172144ad.cjs.prod.js → ValProvider-b2e83d12.cjs.prod.js} +85 -17
- package/dist/{ValProviderInternal-5a5100ab.worker.esm.js → ValProvider-d46ec16a.worker.esm.js} +67 -21
- package/dist/{ValUI-ab7ef83f.cjs.dev.js → ValUI-33562b10.cjs.dev.js} +5 -43
- package/dist/{ValUI-b8544437.worker.esm.js → ValUI-3b9f6c17.worker.esm.js} +4 -42
- package/dist/{ValUI-9a231a97.esm.js → ValUI-4ba5efea.esm.js} +4 -42
- package/dist/{ValUI-697700f4.browser.esm.js → ValUI-75338157.browser.esm.js} +4 -42
- package/dist/ValUI-8ea90ec3.cjs.js +7 -0
- package/dist/{ValUI-46395962.cjs.prod.js → ValUI-8ea90ec3.cjs.prod.js} +5 -43
- package/dist/declarations/src/index.d.ts +11 -3
- package/dist/declarations/src/internal/ValProvider.d.ts +16 -0
- package/dist/declarations/src/internal/index.d.ts +2 -0
- package/dist/declarations/src/stega/stegaEncode.d.ts +1 -1
- package/dist/valbuild-react.browser.esm.js +11 -160
- package/dist/valbuild-react.cjs.d.ts +1 -0
- package/dist/valbuild-react.cjs.dev.js +12 -192
- package/dist/valbuild-react.cjs.prod.js +12 -192
- package/dist/valbuild-react.esm.js +11 -160
- package/dist/valbuild-react.worker.esm.js +11 -152
- package/internal/dist/valbuild-react-internal.browser.esm.js +146 -0
- package/internal/dist/valbuild-react-internal.cjs.d.ts +2 -0
- package/internal/dist/valbuild-react-internal.cjs.d.ts.map +1 -0
- package/internal/dist/valbuild-react-internal.cjs.dev.js +166 -0
- package/internal/dist/valbuild-react-internal.cjs.js +7 -0
- package/internal/dist/valbuild-react-internal.cjs.prod.js +166 -0
- package/internal/dist/valbuild-react-internal.esm.js +146 -0
- package/internal/dist/valbuild-react-internal.worker.esm.js +146 -0
- package/internal/package.json +7 -0
- package/package.json +15 -5
- package/dist/ValProviderInternal-172144ad.cjs.js +0 -7
- package/dist/ValUI-46395962.cjs.js +0 -7
- package/dist/declarations/src/ValProvider.d.ts +0 -3
- package/dist/declarations/src/ValProviderInternal.d.ts +0 -15
- /package/dist/declarations/src/{ValRichText.d.ts → internal/ValRichText.d.ts} +0 -0
- /package/dist/declarations/src/{ValStore.d.ts → internal/ValStore.d.ts} +0 -0
@@ -0,0 +1,146 @@
|
|
1
|
+
export { ValProvider, useValApi, useValStore } from '../../dist/ValProvider-0620664e.esm.js';
|
2
|
+
import React from 'react';
|
3
|
+
import { jsx } from 'react/jsx-runtime';
|
4
|
+
|
5
|
+
/* eslint-disable @typescript-eslint/ban-types */
|
6
|
+
function ValRichText(_ref) {
|
7
|
+
var theme = _ref.theme,
|
8
|
+
className = _ref.className,
|
9
|
+
children = _ref.children;
|
10
|
+
var root = children;
|
11
|
+
function withRenderTag(clazz, current) {
|
12
|
+
var renderClass = theme.tags[clazz];
|
13
|
+
if (renderClass && current) {
|
14
|
+
return [current, renderClass].join(" ");
|
15
|
+
}
|
16
|
+
if (renderClass) {
|
17
|
+
return renderClass;
|
18
|
+
}
|
19
|
+
return current;
|
20
|
+
}
|
21
|
+
function withRenderClass(clazz, current) {
|
22
|
+
var renderClass = theme.classes[clazz];
|
23
|
+
if (renderClass && current) {
|
24
|
+
return [current, renderClass].join(" ");
|
25
|
+
}
|
26
|
+
if (renderClass) {
|
27
|
+
return renderClass;
|
28
|
+
}
|
29
|
+
return current;
|
30
|
+
}
|
31
|
+
function toReact(node, key) {
|
32
|
+
var _anyNode$class, _anyNode$children;
|
33
|
+
if (typeof node === "string") {
|
34
|
+
return node;
|
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)
|
137
|
+
});
|
138
|
+
}
|
139
|
+
return /*#__PURE__*/jsx("div", {
|
140
|
+
className: className,
|
141
|
+
"data-val-path": root.valPath,
|
142
|
+
children: root.children.map(toReact)
|
143
|
+
});
|
144
|
+
}
|
145
|
+
|
146
|
+
export { ValRichText };
|
@@ -0,0 +1,146 @@
|
|
1
|
+
export { ValProvider, useValApi, useValStore } from '../../dist/ValProvider-d46ec16a.worker.esm.js';
|
2
|
+
import React from 'react';
|
3
|
+
import { jsx } from 'react/jsx-runtime';
|
4
|
+
|
5
|
+
/* eslint-disable @typescript-eslint/ban-types */
|
6
|
+
function ValRichText(_ref) {
|
7
|
+
var theme = _ref.theme,
|
8
|
+
className = _ref.className,
|
9
|
+
children = _ref.children;
|
10
|
+
var root = children;
|
11
|
+
function withRenderTag(clazz, current) {
|
12
|
+
var renderClass = theme.tags[clazz];
|
13
|
+
if (renderClass && current) {
|
14
|
+
return [current, renderClass].join(" ");
|
15
|
+
}
|
16
|
+
if (renderClass) {
|
17
|
+
return renderClass;
|
18
|
+
}
|
19
|
+
return current;
|
20
|
+
}
|
21
|
+
function withRenderClass(clazz, current) {
|
22
|
+
var renderClass = theme.classes[clazz];
|
23
|
+
if (renderClass && current) {
|
24
|
+
return [current, renderClass].join(" ");
|
25
|
+
}
|
26
|
+
if (renderClass) {
|
27
|
+
return renderClass;
|
28
|
+
}
|
29
|
+
return current;
|
30
|
+
}
|
31
|
+
function toReact(node, key) {
|
32
|
+
var _anyNode$class, _anyNode$children;
|
33
|
+
if (typeof node === "string") {
|
34
|
+
return node;
|
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)
|
137
|
+
});
|
138
|
+
}
|
139
|
+
return /*#__PURE__*/jsx("div", {
|
140
|
+
className: className,
|
141
|
+
"data-val-path": root.valPath,
|
142
|
+
children: root.children.map(toReact)
|
143
|
+
});
|
144
|
+
}
|
145
|
+
|
146
|
+
export { ValRichText };
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@valbuild/react",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.32.0",
|
4
4
|
"private": false,
|
5
5
|
"description": "Val - React internal helpers",
|
6
6
|
"sideEffects": false,
|
@@ -9,8 +9,8 @@
|
|
9
9
|
"test": "jest"
|
10
10
|
},
|
11
11
|
"dependencies": {
|
12
|
-
"@valbuild/core": "~0.
|
13
|
-
"@valbuild/ui": "~0.
|
12
|
+
"@valbuild/core": "~0.32.0",
|
13
|
+
"@valbuild/ui": "~0.32.0",
|
14
14
|
"@vercel/stega": "^0.1.0",
|
15
15
|
"base64-arraybuffer": "^1.0.2",
|
16
16
|
"style-to-object": "^0.4.1"
|
@@ -36,7 +36,8 @@
|
|
36
36
|
"./index.ts",
|
37
37
|
"./jsx-runtime.js",
|
38
38
|
"./jsx-dev-runtime.js",
|
39
|
-
"./stega/index.ts"
|
39
|
+
"./stega/index.ts",
|
40
|
+
"./internal/index.ts"
|
40
41
|
],
|
41
42
|
"exports": {
|
42
43
|
"envConditions": [
|
@@ -78,6 +79,14 @@
|
|
78
79
|
},
|
79
80
|
"default": "./stega/dist/valbuild-react-stega.cjs.js"
|
80
81
|
},
|
82
|
+
"./internal": {
|
83
|
+
"module": {
|
84
|
+
"worker": "./internal/dist/valbuild-react-internal.worker.esm.js",
|
85
|
+
"browser": "./internal/dist/valbuild-react-internal.browser.esm.js",
|
86
|
+
"default": "./internal/dist/valbuild-react-internal.esm.js"
|
87
|
+
},
|
88
|
+
"default": "./internal/dist/valbuild-react-internal.cjs.js"
|
89
|
+
},
|
81
90
|
"./jsx-dev-runtime": {
|
82
91
|
"module": {
|
83
92
|
"worker": "./jsx-dev-runtime/dist/valbuild-react-jsx-dev-runtime.worker.esm.js",
|
@@ -93,6 +102,7 @@
|
|
93
102
|
"dist",
|
94
103
|
"jsx-runtime",
|
95
104
|
"jsx-dev-runtime",
|
96
|
-
"stega"
|
105
|
+
"stega",
|
106
|
+
"internal"
|
97
107
|
]
|
98
108
|
}
|
@@ -1,15 +0,0 @@
|
|
1
|
-
import React from "react";
|
2
|
-
import { ValStore } from "./ValStore.js";
|
3
|
-
import { ValApi } from "@valbuild/core";
|
4
|
-
export declare function useValStore(): ValStore | undefined;
|
5
|
-
export declare function useValApi(): ValApi | undefined;
|
6
|
-
export type ValContext = {
|
7
|
-
readonly valStore?: ValStore;
|
8
|
-
readonly valApi?: ValApi;
|
9
|
-
};
|
10
|
-
export declare const ValContext: React.Context<ValContext>;
|
11
|
-
export type ValProviderProps = {
|
12
|
-
children?: React.ReactNode;
|
13
|
-
};
|
14
|
-
declare function ValProviderInternal({ children }: ValProviderProps): JSX.Element;
|
15
|
-
export default ValProviderInternal;
|
File without changes
|
File without changes
|