@valbuild/react 0.13.3 → 0.14.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/README.md +11 -0
- package/dist/{ValProvider-52f2fa13.esm.js → ValProvider-2eb6c2f2.esm.js} +4 -34
- package/dist/ValProvider-74eef393.cjs.js +7 -0
- package/dist/{ValProvider-e1d5ffbe.cjs.prod.js → ValProvider-74eef393.cjs.prod.js} +7 -38
- package/dist/{ValProvider-c7a8476b.browser.esm.js → ValProvider-c677e164.browser.esm.js} +4 -34
- package/dist/{ValProvider-a45a47b9.worker.esm.js → ValProvider-cb5a2161.worker.esm.js} +3 -33
- package/dist/{ValProvider-7364ec46.cjs.dev.js → ValProvider-f647e355.cjs.dev.js} +7 -38
- package/dist/{ValUI-0fbdafd4.cjs.prod.js → ValUI-0c2671a7.cjs.prod.js} +12 -28
- package/dist/{ValUI-371e9bf4.cjs.dev.js → ValUI-334ef1d0.cjs.dev.js} +12 -28
- package/dist/{ValUI-51404232.browser.esm.js → ValUI-bb1d1ed6.browser.esm.js} +11 -27
- package/dist/{ValUI-9a3eb570.esm.js → ValUI-bf82178a.esm.js} +11 -27
- package/dist/declarations/src/ValProvider.d.ts +3 -3
- package/dist/declarations/src/ValRichText.d.ts +2 -2
- package/dist/declarations/src/ValStore.d.ts +1 -1
- package/dist/declarations/src/index.d.ts +3 -3
- package/dist/declarations/src/jsx-runtime.d.ts +1 -1
- package/dist/declarations/src/stega/autoTagJSX.d.ts +1 -0
- package/dist/declarations/src/stega/fetchVal.d.ts +3 -0
- package/dist/declarations/src/stega/hooks/useVal.d.ts +3 -0
- package/dist/declarations/src/stega/index.d.ts +4 -0
- package/dist/declarations/src/stega/stegaEncode.d.ts +24 -0
- package/dist/defineProperty-12b5bd29.esm.js +32 -0
- package/dist/defineProperty-36ed93cd.cjs.prod.js +35 -0
- package/dist/defineProperty-a4bf59bc.worker.esm.js +32 -0
- package/dist/defineProperty-c82a49b0.cjs.dev.js +35 -0
- package/dist/defineProperty-f319cb47.browser.esm.js +32 -0
- package/dist/objectSpread2-30cc2856.browser.esm.js +25 -0
- package/dist/objectSpread2-61fbd9a9.cjs.dev.js +27 -0
- package/dist/objectSpread2-7b752a35.cjs.prod.js +27 -0
- package/dist/objectSpread2-d5a1fe1c.esm.js +25 -0
- package/dist/valbuild-react.browser.esm.js +50 -41
- package/dist/valbuild-react.cjs.dev.js +53 -67
- package/dist/valbuild-react.cjs.prod.js +53 -67
- package/dist/valbuild-react.esm.js +50 -49
- package/dist/valbuild-react.worker.esm.js +50 -49
- package/jsx-dev-runtime/dist/valbuild-react-jsx-dev-runtime.browser.esm.js +2 -2
- package/jsx-dev-runtime/dist/valbuild-react-jsx-dev-runtime.cjs.dev.js +5 -5
- package/jsx-dev-runtime/dist/valbuild-react-jsx-dev-runtime.cjs.prod.js +5 -5
- package/jsx-dev-runtime/dist/valbuild-react-jsx-dev-runtime.esm.js +2 -2
- package/jsx-dev-runtime/dist/valbuild-react-jsx-dev-runtime.worker.esm.js +2 -2
- package/package.json +20 -7
- package/src/ShadowRoot.tsx +8 -4
- package/src/ValProvider.tsx +1 -4
- package/src/ValRichText.tsx +76 -40
- package/src/index.ts +2 -4
- package/src/stega/autoTagJSX.ts +80 -0
- package/src/stega/fetchVal.ts +16 -0
- package/src/stega/hooks/useVal.ts +14 -0
- package/src/stega/index.ts +5 -0
- package/src/stega/stegaEncode.ts +84 -0
- package/stega/README.md +3 -0
- package/stega/dist/valbuild-react-stega.browser.esm.js +126 -0
- package/stega/dist/valbuild-react-stega.cjs.d.ts +2 -0
- package/stega/dist/valbuild-react-stega.cjs.d.ts.map +1 -0
- package/stega/dist/valbuild-react-stega.cjs.dev.js +138 -0
- package/stega/dist/valbuild-react-stega.cjs.js +7 -0
- package/stega/dist/valbuild-react-stega.cjs.prod.js +138 -0
- package/stega/dist/valbuild-react-stega.esm.js +126 -0
- package/stega/dist/valbuild-react-stega.worker.esm.js +147 -0
- package/stega/package.json +7 -0
- package/dist/ValProvider-e1d5ffbe.cjs.js +0 -7
- package/dist/declarations/src/AuthStatus.d.ts +0 -6
- package/dist/declarations/src/ShadowRoot.d.ts +0 -4
- package/dist/declarations/src/ValProviderWrapper.d.ts +0 -3
- package/dist/declarations/src/ValUI.d.ts +0 -8
- package/src/ValProviderWrapper.tsx +0 -15
@@ -2,49 +2,16 @@
|
|
2
2
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
|
-
var
|
6
|
-
var ReactJSXRuntime = require('react/jsx-runtime');
|
5
|
+
var ValProvider = require('./ValProvider-f647e355.cjs.dev.js');
|
7
6
|
var core = require('@valbuild/core');
|
7
|
+
var React = require('react');
|
8
8
|
var parse = require('style-to-object');
|
9
|
+
var ReactJSXRuntime = require('react/jsx-runtime');
|
9
10
|
|
10
11
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
11
12
|
|
12
|
-
function _interopNamespace(e) {
|
13
|
-
if (e && e.__esModule) return e;
|
14
|
-
var n = Object.create(null);
|
15
|
-
if (e) {
|
16
|
-
Object.keys(e).forEach(function (k) {
|
17
|
-
if (k !== 'default') {
|
18
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
19
|
-
Object.defineProperty(n, k, d.get ? d : {
|
20
|
-
enumerable: true,
|
21
|
-
get: function () { return e[k]; }
|
22
|
-
});
|
23
|
-
}
|
24
|
-
});
|
25
|
-
}
|
26
|
-
n["default"] = e;
|
27
|
-
return Object.freeze(n);
|
28
|
-
}
|
29
|
-
|
30
13
|
var parse__default = /*#__PURE__*/_interopDefault(parse);
|
31
14
|
|
32
|
-
var ValProvider = typeof window === "undefined" && /*#__PURE__*/React.lazy(function () {
|
33
|
-
return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('./ValProvider-7364ec46.cjs.dev.js')); });
|
34
|
-
});
|
35
|
-
function ValProviderWrapper(_ref) {
|
36
|
-
var _ref$host = _ref.host,
|
37
|
-
host = _ref$host === void 0 ? "/api/val" : _ref$host,
|
38
|
-
children = _ref.children;
|
39
|
-
if (!ValProvider) {
|
40
|
-
return null;
|
41
|
-
}
|
42
|
-
return /*#__PURE__*/ReactJSXRuntime.jsx(ValProvider, {
|
43
|
-
host: host,
|
44
|
-
children: children
|
45
|
-
});
|
46
|
-
}
|
47
|
-
|
48
15
|
function useVal(selector, locale) {
|
49
16
|
// const mod = selectable.getModule();
|
50
17
|
// const valStore = useValStore();
|
@@ -67,37 +34,41 @@ function useVal(selector, locale) {
|
|
67
34
|
return core.Internal.getVal(selector, locale);
|
68
35
|
}
|
69
36
|
|
70
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
71
|
-
var getValPath = core.Internal.getValPath;
|
72
37
|
function ValRichText(_ref) {
|
73
38
|
var children = _ref.children;
|
39
|
+
var root = children;
|
40
|
+
var path = root.valPath;
|
74
41
|
return /*#__PURE__*/ReactJSXRuntime.jsx("div", {
|
75
|
-
"data-val-path":
|
76
|
-
children:
|
77
|
-
|
42
|
+
"data-val-path": path,
|
43
|
+
children: root.children.map(function (child, i) {
|
44
|
+
var childType = child.type;
|
45
|
+
var childPath = "".concat(path, ".").concat(i);
|
46
|
+
switch (childType) {
|
78
47
|
case "heading":
|
79
48
|
return /*#__PURE__*/ReactJSXRuntime.jsx(HeadingNodeComponent, {
|
49
|
+
path: childPath,
|
80
50
|
node: child
|
81
|
-
},
|
51
|
+
}, childPath);
|
82
52
|
case "paragraph":
|
83
53
|
return /*#__PURE__*/ReactJSXRuntime.jsx(ParagraphNodeComponent, {
|
54
|
+
path: childPath,
|
84
55
|
node: child
|
85
|
-
},
|
56
|
+
}, childPath);
|
86
57
|
case "list":
|
87
58
|
return /*#__PURE__*/ReactJSXRuntime.jsx(ListNodeComponent, {
|
59
|
+
path: childPath,
|
88
60
|
node: child
|
89
|
-
},
|
61
|
+
}, childPath);
|
90
62
|
default:
|
91
|
-
throw Error("Unknown node type: " +
|
63
|
+
throw Error("Unknown root node type: " + childType);
|
92
64
|
}
|
93
65
|
})
|
94
66
|
});
|
95
67
|
}
|
96
68
|
function TextNodeComponent(_ref2) {
|
97
|
-
var _parse;
|
69
|
+
var _parse, _node$format;
|
98
70
|
var node = _ref2.node;
|
99
|
-
var
|
100
|
-
var styleProps = actualVal.style ? (_parse = parse__default["default"](actualVal.style)) !== null && _parse !== void 0 ? _parse : {} : {};
|
71
|
+
var styleProps = node.style ? (_parse = parse__default["default"](node.style)) !== null && _parse !== void 0 ? _parse : {} : {};
|
101
72
|
// TODO: Ugly! We should do this before serializing instead
|
102
73
|
if (styleProps["font-family"]) {
|
103
74
|
styleProps["fontFamily"] = styleProps["font-family"];
|
@@ -107,9 +78,12 @@ function TextNodeComponent(_ref2) {
|
|
107
78
|
styleProps["fontSize"] = styleProps["font-size"];
|
108
79
|
delete styleProps["font-size"];
|
109
80
|
}
|
110
|
-
var bitmask =
|
111
|
-
var bitmaskOffset = bitmask.length - 1;
|
81
|
+
var bitmask = (_node$format = node.format) === null || _node$format === void 0 ? void 0 : _node$format.toString(2);
|
82
|
+
var bitmaskOffset = bitmask ? bitmask.length - 1 : 0;
|
112
83
|
function isBitOne(bit) {
|
84
|
+
if (!bitmask) {
|
85
|
+
return false;
|
86
|
+
}
|
113
87
|
return bitmask.length >= bitmaskOffset - bit && bitmask[bitmaskOffset - bit] === "1";
|
114
88
|
}
|
115
89
|
if (isBitOne(0)) {
|
@@ -134,56 +108,68 @@ function TextNodeComponent(_ref2) {
|
|
134
108
|
}
|
135
109
|
return /*#__PURE__*/ReactJSXRuntime.jsx("span", {
|
136
110
|
style: styleProps,
|
137
|
-
children:
|
111
|
+
children: node.text
|
138
112
|
});
|
139
113
|
}
|
140
114
|
function HeadingNodeComponent(_ref3) {
|
141
|
-
var node = _ref3.node
|
142
|
-
|
115
|
+
var node = _ref3.node,
|
116
|
+
path = _ref3.path;
|
117
|
+
return /*#__PURE__*/React.createElement(node.tag, {}, node.children.map(function (child, i) {
|
118
|
+
var childPath = "".concat(path, ".").concat(i);
|
143
119
|
return /*#__PURE__*/ReactJSXRuntime.jsx(TextNodeComponent, {
|
144
120
|
node: child
|
145
|
-
},
|
121
|
+
}, childPath);
|
146
122
|
}));
|
147
123
|
}
|
148
124
|
function ParagraphNodeComponent(_ref4) {
|
149
|
-
var node = _ref4.node
|
125
|
+
var node = _ref4.node,
|
126
|
+
path = _ref4.path;
|
150
127
|
return /*#__PURE__*/ReactJSXRuntime.jsx("p", {
|
151
|
-
children: node.children.map(function (child) {
|
152
|
-
|
128
|
+
children: node.children.map(function (child, i) {
|
129
|
+
var childPath = "".concat(path, ".").concat(i);
|
130
|
+
switch (child.type) {
|
153
131
|
case "text":
|
154
132
|
return /*#__PURE__*/ReactJSXRuntime.jsx(TextNodeComponent, {
|
155
133
|
node: child
|
156
|
-
},
|
134
|
+
}, childPath);
|
157
135
|
default:
|
158
|
-
throw Error("Unknown node type: " + (child === null || child === void 0 ? void 0 : child.type));
|
136
|
+
throw Error("Unknown paragraph node type: " + (child === null || child === void 0 ? void 0 : child.type));
|
159
137
|
}
|
160
138
|
})
|
161
139
|
});
|
162
140
|
}
|
163
141
|
function ListNodeComponent(_ref5) {
|
164
|
-
var node = _ref5.node
|
165
|
-
|
142
|
+
var node = _ref5.node,
|
143
|
+
path = _ref5.path;
|
144
|
+
return /*#__PURE__*/React.createElement(node.tag, {}, node.children.map(function (child, i) {
|
145
|
+
var childPath = "".concat(path, ".").concat(i);
|
166
146
|
return /*#__PURE__*/ReactJSXRuntime.jsx(ListItemComponent, {
|
147
|
+
path: childPath,
|
167
148
|
node: child
|
168
|
-
},
|
149
|
+
}, childPath);
|
169
150
|
}));
|
170
151
|
}
|
171
152
|
function ListItemComponent(_ref6) {
|
172
|
-
var node = _ref6.node
|
153
|
+
var node = _ref6.node,
|
154
|
+
path = _ref6.path;
|
173
155
|
return /*#__PURE__*/ReactJSXRuntime.jsx("li", {
|
174
156
|
children: node.children.map(function (child, i) {
|
175
|
-
|
157
|
+
var childPath = "".concat(path, ".").concat(i);
|
158
|
+
switch (child.type) {
|
176
159
|
case "text":
|
177
160
|
return /*#__PURE__*/ReactJSXRuntime.jsx(TextNodeComponent, {
|
178
161
|
node: child
|
179
|
-
},
|
162
|
+
}, childPath);
|
180
163
|
default:
|
181
|
-
throw Error("Unknown node type: " + (child === null || child === void 0 ? void 0 : child.type));
|
164
|
+
throw Error("Unknown list item node type: " + (child === null || child === void 0 ? void 0 : child.type));
|
182
165
|
}
|
183
166
|
})
|
184
167
|
});
|
185
168
|
}
|
186
169
|
|
187
|
-
exports
|
170
|
+
Object.defineProperty(exports, 'ValProvider', {
|
171
|
+
enumerable: true,
|
172
|
+
get: function () { return ValProvider.ValProvider; }
|
173
|
+
});
|
188
174
|
exports.ValRichText = ValRichText;
|
189
175
|
exports.useVal = useVal;
|
@@ -2,49 +2,16 @@
|
|
2
2
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
|
-
var
|
6
|
-
var ReactJSXRuntime = require('react/jsx-runtime');
|
5
|
+
var ValProvider = require('./ValProvider-74eef393.cjs.prod.js');
|
7
6
|
var core = require('@valbuild/core');
|
7
|
+
var React = require('react');
|
8
8
|
var parse = require('style-to-object');
|
9
|
+
var ReactJSXRuntime = require('react/jsx-runtime');
|
9
10
|
|
10
11
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
11
12
|
|
12
|
-
function _interopNamespace(e) {
|
13
|
-
if (e && e.__esModule) return e;
|
14
|
-
var n = Object.create(null);
|
15
|
-
if (e) {
|
16
|
-
Object.keys(e).forEach(function (k) {
|
17
|
-
if (k !== 'default') {
|
18
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
19
|
-
Object.defineProperty(n, k, d.get ? d : {
|
20
|
-
enumerable: true,
|
21
|
-
get: function () { return e[k]; }
|
22
|
-
});
|
23
|
-
}
|
24
|
-
});
|
25
|
-
}
|
26
|
-
n["default"] = e;
|
27
|
-
return Object.freeze(n);
|
28
|
-
}
|
29
|
-
|
30
13
|
var parse__default = /*#__PURE__*/_interopDefault(parse);
|
31
14
|
|
32
|
-
var ValProvider = typeof window === "undefined" && /*#__PURE__*/React.lazy(function () {
|
33
|
-
return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('./ValProvider-e1d5ffbe.cjs.prod.js')); });
|
34
|
-
});
|
35
|
-
function ValProviderWrapper(_ref) {
|
36
|
-
var _ref$host = _ref.host,
|
37
|
-
host = _ref$host === void 0 ? "/api/val" : _ref$host,
|
38
|
-
children = _ref.children;
|
39
|
-
if (!ValProvider) {
|
40
|
-
return null;
|
41
|
-
}
|
42
|
-
return /*#__PURE__*/ReactJSXRuntime.jsx(ValProvider, {
|
43
|
-
host: host,
|
44
|
-
children: children
|
45
|
-
});
|
46
|
-
}
|
47
|
-
|
48
15
|
function useVal(selector, locale) {
|
49
16
|
// const mod = selectable.getModule();
|
50
17
|
// const valStore = useValStore();
|
@@ -67,37 +34,41 @@ function useVal(selector, locale) {
|
|
67
34
|
return core.Internal.getVal(selector, locale);
|
68
35
|
}
|
69
36
|
|
70
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
71
|
-
var getValPath = core.Internal.getValPath;
|
72
37
|
function ValRichText(_ref) {
|
73
38
|
var children = _ref.children;
|
39
|
+
var root = children;
|
40
|
+
var path = root.valPath;
|
74
41
|
return /*#__PURE__*/ReactJSXRuntime.jsx("div", {
|
75
|
-
"data-val-path":
|
76
|
-
children:
|
77
|
-
|
42
|
+
"data-val-path": path,
|
43
|
+
children: root.children.map(function (child, i) {
|
44
|
+
var childType = child.type;
|
45
|
+
var childPath = "".concat(path, ".").concat(i);
|
46
|
+
switch (childType) {
|
78
47
|
case "heading":
|
79
48
|
return /*#__PURE__*/ReactJSXRuntime.jsx(HeadingNodeComponent, {
|
49
|
+
path: childPath,
|
80
50
|
node: child
|
81
|
-
},
|
51
|
+
}, childPath);
|
82
52
|
case "paragraph":
|
83
53
|
return /*#__PURE__*/ReactJSXRuntime.jsx(ParagraphNodeComponent, {
|
54
|
+
path: childPath,
|
84
55
|
node: child
|
85
|
-
},
|
56
|
+
}, childPath);
|
86
57
|
case "list":
|
87
58
|
return /*#__PURE__*/ReactJSXRuntime.jsx(ListNodeComponent, {
|
59
|
+
path: childPath,
|
88
60
|
node: child
|
89
|
-
},
|
61
|
+
}, childPath);
|
90
62
|
default:
|
91
|
-
throw Error("Unknown node type: " +
|
63
|
+
throw Error("Unknown root node type: " + childType);
|
92
64
|
}
|
93
65
|
})
|
94
66
|
});
|
95
67
|
}
|
96
68
|
function TextNodeComponent(_ref2) {
|
97
|
-
var _parse;
|
69
|
+
var _parse, _node$format;
|
98
70
|
var node = _ref2.node;
|
99
|
-
var
|
100
|
-
var styleProps = actualVal.style ? (_parse = parse__default["default"](actualVal.style)) !== null && _parse !== void 0 ? _parse : {} : {};
|
71
|
+
var styleProps = node.style ? (_parse = parse__default["default"](node.style)) !== null && _parse !== void 0 ? _parse : {} : {};
|
101
72
|
// TODO: Ugly! We should do this before serializing instead
|
102
73
|
if (styleProps["font-family"]) {
|
103
74
|
styleProps["fontFamily"] = styleProps["font-family"];
|
@@ -107,9 +78,12 @@ function TextNodeComponent(_ref2) {
|
|
107
78
|
styleProps["fontSize"] = styleProps["font-size"];
|
108
79
|
delete styleProps["font-size"];
|
109
80
|
}
|
110
|
-
var bitmask =
|
111
|
-
var bitmaskOffset = bitmask.length - 1;
|
81
|
+
var bitmask = (_node$format = node.format) === null || _node$format === void 0 ? void 0 : _node$format.toString(2);
|
82
|
+
var bitmaskOffset = bitmask ? bitmask.length - 1 : 0;
|
112
83
|
function isBitOne(bit) {
|
84
|
+
if (!bitmask) {
|
85
|
+
return false;
|
86
|
+
}
|
113
87
|
return bitmask.length >= bitmaskOffset - bit && bitmask[bitmaskOffset - bit] === "1";
|
114
88
|
}
|
115
89
|
if (isBitOne(0)) {
|
@@ -134,56 +108,68 @@ function TextNodeComponent(_ref2) {
|
|
134
108
|
}
|
135
109
|
return /*#__PURE__*/ReactJSXRuntime.jsx("span", {
|
136
110
|
style: styleProps,
|
137
|
-
children:
|
111
|
+
children: node.text
|
138
112
|
});
|
139
113
|
}
|
140
114
|
function HeadingNodeComponent(_ref3) {
|
141
|
-
var node = _ref3.node
|
142
|
-
|
115
|
+
var node = _ref3.node,
|
116
|
+
path = _ref3.path;
|
117
|
+
return /*#__PURE__*/React.createElement(node.tag, {}, node.children.map(function (child, i) {
|
118
|
+
var childPath = "".concat(path, ".").concat(i);
|
143
119
|
return /*#__PURE__*/ReactJSXRuntime.jsx(TextNodeComponent, {
|
144
120
|
node: child
|
145
|
-
},
|
121
|
+
}, childPath);
|
146
122
|
}));
|
147
123
|
}
|
148
124
|
function ParagraphNodeComponent(_ref4) {
|
149
|
-
var node = _ref4.node
|
125
|
+
var node = _ref4.node,
|
126
|
+
path = _ref4.path;
|
150
127
|
return /*#__PURE__*/ReactJSXRuntime.jsx("p", {
|
151
|
-
children: node.children.map(function (child) {
|
152
|
-
|
128
|
+
children: node.children.map(function (child, i) {
|
129
|
+
var childPath = "".concat(path, ".").concat(i);
|
130
|
+
switch (child.type) {
|
153
131
|
case "text":
|
154
132
|
return /*#__PURE__*/ReactJSXRuntime.jsx(TextNodeComponent, {
|
155
133
|
node: child
|
156
|
-
},
|
134
|
+
}, childPath);
|
157
135
|
default:
|
158
|
-
throw Error("Unknown node type: " + (child === null || child === void 0 ? void 0 : child.type));
|
136
|
+
throw Error("Unknown paragraph node type: " + (child === null || child === void 0 ? void 0 : child.type));
|
159
137
|
}
|
160
138
|
})
|
161
139
|
});
|
162
140
|
}
|
163
141
|
function ListNodeComponent(_ref5) {
|
164
|
-
var node = _ref5.node
|
165
|
-
|
142
|
+
var node = _ref5.node,
|
143
|
+
path = _ref5.path;
|
144
|
+
return /*#__PURE__*/React.createElement(node.tag, {}, node.children.map(function (child, i) {
|
145
|
+
var childPath = "".concat(path, ".").concat(i);
|
166
146
|
return /*#__PURE__*/ReactJSXRuntime.jsx(ListItemComponent, {
|
147
|
+
path: childPath,
|
167
148
|
node: child
|
168
|
-
},
|
149
|
+
}, childPath);
|
169
150
|
}));
|
170
151
|
}
|
171
152
|
function ListItemComponent(_ref6) {
|
172
|
-
var node = _ref6.node
|
153
|
+
var node = _ref6.node,
|
154
|
+
path = _ref6.path;
|
173
155
|
return /*#__PURE__*/ReactJSXRuntime.jsx("li", {
|
174
156
|
children: node.children.map(function (child, i) {
|
175
|
-
|
157
|
+
var childPath = "".concat(path, ".").concat(i);
|
158
|
+
switch (child.type) {
|
176
159
|
case "text":
|
177
160
|
return /*#__PURE__*/ReactJSXRuntime.jsx(TextNodeComponent, {
|
178
161
|
node: child
|
179
|
-
},
|
162
|
+
}, childPath);
|
180
163
|
default:
|
181
|
-
throw Error("Unknown node type: " + (child === null || child === void 0 ? void 0 : child.type));
|
164
|
+
throw Error("Unknown list item node type: " + (child === null || child === void 0 ? void 0 : child.type));
|
182
165
|
}
|
183
166
|
})
|
184
167
|
});
|
185
168
|
}
|
186
169
|
|
187
|
-
exports
|
170
|
+
Object.defineProperty(exports, 'ValProvider', {
|
171
|
+
enumerable: true,
|
172
|
+
get: function () { return ValProvider.ValProvider; }
|
173
|
+
});
|
188
174
|
exports.ValRichText = ValRichText;
|
189
175
|
exports.useVal = useVal;
|
@@ -1,23 +1,8 @@
|
|
1
|
-
|
2
|
-
import { jsx } from 'react/jsx-runtime';
|
1
|
+
export { ValProvider } from './ValProvider-2eb6c2f2.esm.js';
|
3
2
|
import { Internal } from '@valbuild/core';
|
3
|
+
import { createElement } from 'react';
|
4
4
|
import parse from 'style-to-object';
|
5
|
-
|
6
|
-
var ValProvider = typeof window === "undefined" && /*#__PURE__*/lazy(function () {
|
7
|
-
return import('./ValProvider-52f2fa13.esm.js');
|
8
|
-
});
|
9
|
-
function ValProviderWrapper(_ref) {
|
10
|
-
var _ref$host = _ref.host,
|
11
|
-
host = _ref$host === void 0 ? "/api/val" : _ref$host,
|
12
|
-
children = _ref.children;
|
13
|
-
if (!ValProvider) {
|
14
|
-
return null;
|
15
|
-
}
|
16
|
-
return /*#__PURE__*/jsx(ValProvider, {
|
17
|
-
host: host,
|
18
|
-
children: children
|
19
|
-
});
|
20
|
-
}
|
5
|
+
import { jsx } from 'react/jsx-runtime';
|
21
6
|
|
22
7
|
function useVal(selector, locale) {
|
23
8
|
// const mod = selectable.getModule();
|
@@ -41,37 +26,41 @@ function useVal(selector, locale) {
|
|
41
26
|
return Internal.getVal(selector, locale);
|
42
27
|
}
|
43
28
|
|
44
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
45
|
-
var getValPath = Internal.getValPath;
|
46
29
|
function ValRichText(_ref) {
|
47
30
|
var children = _ref.children;
|
31
|
+
var root = children;
|
32
|
+
var path = root.valPath;
|
48
33
|
return /*#__PURE__*/jsx("div", {
|
49
|
-
"data-val-path":
|
50
|
-
children:
|
51
|
-
|
34
|
+
"data-val-path": path,
|
35
|
+
children: root.children.map(function (child, i) {
|
36
|
+
var childType = child.type;
|
37
|
+
var childPath = "".concat(path, ".").concat(i);
|
38
|
+
switch (childType) {
|
52
39
|
case "heading":
|
53
40
|
return /*#__PURE__*/jsx(HeadingNodeComponent, {
|
41
|
+
path: childPath,
|
54
42
|
node: child
|
55
|
-
},
|
43
|
+
}, childPath);
|
56
44
|
case "paragraph":
|
57
45
|
return /*#__PURE__*/jsx(ParagraphNodeComponent, {
|
46
|
+
path: childPath,
|
58
47
|
node: child
|
59
|
-
},
|
48
|
+
}, childPath);
|
60
49
|
case "list":
|
61
50
|
return /*#__PURE__*/jsx(ListNodeComponent, {
|
51
|
+
path: childPath,
|
62
52
|
node: child
|
63
|
-
},
|
53
|
+
}, childPath);
|
64
54
|
default:
|
65
|
-
throw Error("Unknown node type: " +
|
55
|
+
throw Error("Unknown root node type: " + childType);
|
66
56
|
}
|
67
57
|
})
|
68
58
|
});
|
69
59
|
}
|
70
60
|
function TextNodeComponent(_ref2) {
|
71
|
-
var _parse;
|
61
|
+
var _parse, _node$format;
|
72
62
|
var node = _ref2.node;
|
73
|
-
var
|
74
|
-
var styleProps = actualVal.style ? (_parse = parse(actualVal.style)) !== null && _parse !== void 0 ? _parse : {} : {};
|
63
|
+
var styleProps = node.style ? (_parse = parse(node.style)) !== null && _parse !== void 0 ? _parse : {} : {};
|
75
64
|
// TODO: Ugly! We should do this before serializing instead
|
76
65
|
if (styleProps["font-family"]) {
|
77
66
|
styleProps["fontFamily"] = styleProps["font-family"];
|
@@ -81,9 +70,12 @@ function TextNodeComponent(_ref2) {
|
|
81
70
|
styleProps["fontSize"] = styleProps["font-size"];
|
82
71
|
delete styleProps["font-size"];
|
83
72
|
}
|
84
|
-
var bitmask =
|
85
|
-
var bitmaskOffset = bitmask.length - 1;
|
73
|
+
var bitmask = (_node$format = node.format) === null || _node$format === void 0 ? void 0 : _node$format.toString(2);
|
74
|
+
var bitmaskOffset = bitmask ? bitmask.length - 1 : 0;
|
86
75
|
function isBitOne(bit) {
|
76
|
+
if (!bitmask) {
|
77
|
+
return false;
|
78
|
+
}
|
87
79
|
return bitmask.length >= bitmaskOffset - bit && bitmask[bitmaskOffset - bit] === "1";
|
88
80
|
}
|
89
81
|
if (isBitOne(0)) {
|
@@ -108,54 +100,63 @@ function TextNodeComponent(_ref2) {
|
|
108
100
|
}
|
109
101
|
return /*#__PURE__*/jsx("span", {
|
110
102
|
style: styleProps,
|
111
|
-
children:
|
103
|
+
children: node.text
|
112
104
|
});
|
113
105
|
}
|
114
106
|
function HeadingNodeComponent(_ref3) {
|
115
|
-
var node = _ref3.node
|
116
|
-
|
107
|
+
var node = _ref3.node,
|
108
|
+
path = _ref3.path;
|
109
|
+
return /*#__PURE__*/createElement(node.tag, {}, node.children.map(function (child, i) {
|
110
|
+
var childPath = "".concat(path, ".").concat(i);
|
117
111
|
return /*#__PURE__*/jsx(TextNodeComponent, {
|
118
112
|
node: child
|
119
|
-
},
|
113
|
+
}, childPath);
|
120
114
|
}));
|
121
115
|
}
|
122
116
|
function ParagraphNodeComponent(_ref4) {
|
123
|
-
var node = _ref4.node
|
117
|
+
var node = _ref4.node,
|
118
|
+
path = _ref4.path;
|
124
119
|
return /*#__PURE__*/jsx("p", {
|
125
|
-
children: node.children.map(function (child) {
|
126
|
-
|
120
|
+
children: node.children.map(function (child, i) {
|
121
|
+
var childPath = "".concat(path, ".").concat(i);
|
122
|
+
switch (child.type) {
|
127
123
|
case "text":
|
128
124
|
return /*#__PURE__*/jsx(TextNodeComponent, {
|
129
125
|
node: child
|
130
|
-
},
|
126
|
+
}, childPath);
|
131
127
|
default:
|
132
|
-
throw Error("Unknown node type: " + (child === null || child === void 0 ? void 0 : child.type));
|
128
|
+
throw Error("Unknown paragraph node type: " + (child === null || child === void 0 ? void 0 : child.type));
|
133
129
|
}
|
134
130
|
})
|
135
131
|
});
|
136
132
|
}
|
137
133
|
function ListNodeComponent(_ref5) {
|
138
|
-
var node = _ref5.node
|
139
|
-
|
134
|
+
var node = _ref5.node,
|
135
|
+
path = _ref5.path;
|
136
|
+
return /*#__PURE__*/createElement(node.tag, {}, node.children.map(function (child, i) {
|
137
|
+
var childPath = "".concat(path, ".").concat(i);
|
140
138
|
return /*#__PURE__*/jsx(ListItemComponent, {
|
139
|
+
path: childPath,
|
141
140
|
node: child
|
142
|
-
},
|
141
|
+
}, childPath);
|
143
142
|
}));
|
144
143
|
}
|
145
144
|
function ListItemComponent(_ref6) {
|
146
|
-
var node = _ref6.node
|
145
|
+
var node = _ref6.node,
|
146
|
+
path = _ref6.path;
|
147
147
|
return /*#__PURE__*/jsx("li", {
|
148
148
|
children: node.children.map(function (child, i) {
|
149
|
-
|
149
|
+
var childPath = "".concat(path, ".").concat(i);
|
150
|
+
switch (child.type) {
|
150
151
|
case "text":
|
151
152
|
return /*#__PURE__*/jsx(TextNodeComponent, {
|
152
153
|
node: child
|
153
|
-
},
|
154
|
+
}, childPath);
|
154
155
|
default:
|
155
|
-
throw Error("Unknown node type: " + (child === null || child === void 0 ? void 0 : child.type));
|
156
|
+
throw Error("Unknown list item node type: " + (child === null || child === void 0 ? void 0 : child.type));
|
156
157
|
}
|
157
158
|
})
|
158
159
|
});
|
159
160
|
}
|
160
161
|
|
161
|
-
export {
|
162
|
+
export { ValRichText, useVal };
|