@valbuild/react 0.13.3 → 0.13.4

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.
Files changed (25) hide show
  1. package/dist/{ValProvider-52f2fa13.esm.js → ValProvider-07551558.esm.js} +3 -3
  2. package/dist/{ValProvider-c7a8476b.browser.esm.js → ValProvider-11be7088.browser.esm.js} +3 -3
  3. package/dist/{ValProvider-a45a47b9.worker.esm.js → ValProvider-50aa4ba8.worker.esm.js} +2 -2
  4. package/dist/{ValProvider-7364ec46.cjs.dev.js → ValProvider-7b9d888e.cjs.dev.js} +2 -2
  5. package/dist/ValProvider-d8fe7dc4.cjs.js +7 -0
  6. package/dist/{ValProvider-e1d5ffbe.cjs.prod.js → ValProvider-d8fe7dc4.cjs.prod.js} +2 -2
  7. package/dist/{ValUI-51404232.browser.esm.js → ValUI-4844450a.browser.esm.js} +1 -1
  8. package/dist/{ValUI-9a3eb570.esm.js → ValUI-599818da.esm.js} +1 -1
  9. package/dist/{ValUI-0fbdafd4.cjs.prod.js → ValUI-5e993a19.cjs.prod.js} +1 -1
  10. package/dist/{ValUI-371e9bf4.cjs.dev.js → ValUI-ac6ae690.cjs.dev.js} +1 -1
  11. package/dist/declarations/src/ValProvider.d.ts +1 -1
  12. package/dist/declarations/src/index.d.ts +1 -2
  13. package/dist/valbuild-react.browser.esm.js +2 -129
  14. package/dist/valbuild-react.cjs.dev.js +5 -160
  15. package/dist/valbuild-react.cjs.prod.js +5 -160
  16. package/dist/valbuild-react.esm.js +2 -137
  17. package/dist/valbuild-react.worker.esm.js +2 -137
  18. package/package.json +8 -5
  19. package/src/ValProvider.tsx +1 -4
  20. package/src/index.ts +1 -2
  21. package/dist/ValProvider-e1d5ffbe.cjs.js +0 -7
  22. package/dist/declarations/src/ValProviderWrapper.d.ts +0 -3
  23. package/dist/declarations/src/ValRichText.d.ts +0 -5
  24. package/src/ValProviderWrapper.tsx +0 -15
  25. package/src/ValRichText.tsx +0 -141
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- import React, { useMemo, useContext, lazy } from 'react';
2
+ import React, { useContext, useMemo, lazy } from 'react';
3
3
  import { _ as _unsupportedIterableToArray } from './unsupportedIterableToArray-51bb61c2.esm.js';
4
4
  import { jsxs, jsx } from 'react/jsx-runtime';
5
5
 
@@ -704,7 +704,7 @@ var ValContext = /*#__PURE__*/React.createContext({
704
704
  }
705
705
  });
706
706
  var ValUI = typeof window !== "undefined" ? /*#__PURE__*/lazy(function () {
707
- return import('./ValUI-9a3eb570.esm.js');
707
+ return import('./ValUI-599818da.esm.js');
708
708
  }) : null;
709
709
  function ValProvider(_ref) {
710
710
  var _ref$host = _ref.host,
@@ -728,4 +728,4 @@ function ValProvider(_ref) {
728
728
  });
729
729
  }
730
730
 
731
- export { ValContext, _defineProperty as _, _createForOfIteratorHelper as a, _asyncToGenerator as b, _regeneratorRuntime as c, ValProvider as default, useValApi, useValStore };
731
+ export { ValContext, ValProvider, _defineProperty as _, _createForOfIteratorHelper as a, _asyncToGenerator as b, _regeneratorRuntime as c, useValApi, useValStore };
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- import React, { useMemo, useContext, lazy } from 'react';
2
+ import React, { useContext, useMemo, lazy } from 'react';
3
3
  import { _ as _unsupportedIterableToArray } from './unsupportedIterableToArray-d3087ed5.browser.esm.js';
4
4
  import { jsxs, jsx } from 'react/jsx-runtime';
5
5
 
@@ -704,7 +704,7 @@ var ValContext = /*#__PURE__*/React.createContext({
704
704
  }
705
705
  });
706
706
  var ValUI = /*#__PURE__*/lazy(function () {
707
- return import('./ValUI-51404232.browser.esm.js');
707
+ return import('./ValUI-4844450a.browser.esm.js');
708
708
  }) ;
709
709
  function ValProvider(_ref) {
710
710
  var _ref$host = _ref.host,
@@ -728,4 +728,4 @@ function ValProvider(_ref) {
728
728
  });
729
729
  }
730
730
 
731
- export { ValContext, _defineProperty as _, _createForOfIteratorHelper as a, _asyncToGenerator as b, _regeneratorRuntime as c, ValProvider as default, useValApi, useValStore };
731
+ export { ValContext, ValProvider, _defineProperty as _, _createForOfIteratorHelper as a, _asyncToGenerator as b, _regeneratorRuntime as c, useValApi, useValStore };
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- import React, { useMemo, useContext } from 'react';
2
+ import React, { useContext, useMemo } from 'react';
3
3
  import { _ as _unsupportedIterableToArray } from './unsupportedIterableToArray-738344ef.worker.esm.js';
4
4
  import { jsxs } from 'react/jsx-runtime';
5
5
 
@@ -723,4 +723,4 @@ function ValProvider(_ref) {
723
723
  });
724
724
  }
725
725
 
726
- export { ValContext, ValProvider as default, useValApi, useValStore };
726
+ export { ValContext, ValProvider, useValApi, useValStore };
@@ -712,7 +712,7 @@ var ValContext = /*#__PURE__*/React__default["default"].createContext({
712
712
  }
713
713
  });
714
714
  var ValUI = typeof window !== "undefined" ? /*#__PURE__*/React.lazy(function () {
715
- return Promise.resolve().then(function () { return require('./ValUI-371e9bf4.cjs.dev.js'); });
715
+ return Promise.resolve().then(function () { return require('./ValUI-ac6ae690.cjs.dev.js'); });
716
716
  }) : null;
717
717
  function ValProvider(_ref) {
718
718
  var _ref$host = _ref.host,
@@ -737,10 +737,10 @@ function ValProvider(_ref) {
737
737
  }
738
738
 
739
739
  exports.ValContext = ValContext;
740
+ exports.ValProvider = ValProvider;
740
741
  exports._asyncToGenerator = _asyncToGenerator;
741
742
  exports._createForOfIteratorHelper = _createForOfIteratorHelper;
742
743
  exports._defineProperty = _defineProperty;
743
744
  exports._regeneratorRuntime = _regeneratorRuntime;
744
- exports["default"] = ValProvider;
745
745
  exports.useValApi = useValApi;
746
746
  exports.useValStore = useValStore;
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ if (process.env.NODE_ENV === "production") {
4
+ module.exports = require("./ValProvider-d8fe7dc4.cjs.prod.js");
5
+ } else {
6
+ module.exports = require("./ValProvider-d8fe7dc4.cjs.dev.js");
7
+ }
@@ -712,7 +712,7 @@ var ValContext = /*#__PURE__*/React__default["default"].createContext({
712
712
  }
713
713
  });
714
714
  var ValUI = typeof window !== "undefined" ? /*#__PURE__*/React.lazy(function () {
715
- return Promise.resolve().then(function () { return require('./ValUI-0fbdafd4.cjs.prod.js'); });
715
+ return Promise.resolve().then(function () { return require('./ValUI-5e993a19.cjs.prod.js'); });
716
716
  }) : null;
717
717
  function ValProvider(_ref) {
718
718
  var _ref$host = _ref.host,
@@ -737,10 +737,10 @@ function ValProvider(_ref) {
737
737
  }
738
738
 
739
739
  exports.ValContext = ValContext;
740
+ exports.ValProvider = ValProvider;
740
741
  exports._asyncToGenerator = _asyncToGenerator;
741
742
  exports._createForOfIteratorHelper = _createForOfIteratorHelper;
742
743
  exports._defineProperty = _defineProperty;
743
744
  exports._regeneratorRuntime = _regeneratorRuntime;
744
- exports["default"] = ValProvider;
745
745
  exports.useValApi = useValApi;
746
746
  exports.useValStore = useValStore;
@@ -1,4 +1,4 @@
1
- import { _ as _defineProperty, a as _createForOfIteratorHelper, b as _asyncToGenerator, c as _regeneratorRuntime } from './ValProvider-c7a8476b.browser.esm.js';
1
+ import { _ as _defineProperty, a as _createForOfIteratorHelper, b as _asyncToGenerator, c as _regeneratorRuntime } from './ValProvider-11be7088.browser.esm.js';
2
2
  import { _ as _slicedToArray, a as _typeof } from './slicedToArray-1a246338.browser.esm.js';
3
3
  import { useRef, useState, useLayoutEffect, useEffect } from 'react';
4
4
  import { Style, ValOverlay } from '@valbuild/ui';
@@ -1,4 +1,4 @@
1
- import { _ as _defineProperty, a as _createForOfIteratorHelper, b as _asyncToGenerator, c as _regeneratorRuntime } from './ValProvider-52f2fa13.esm.js';
1
+ import { _ as _defineProperty, a as _createForOfIteratorHelper, b as _asyncToGenerator, c as _regeneratorRuntime } from './ValProvider-07551558.esm.js';
2
2
  import { _ as _slicedToArray, a as _typeof } from './slicedToArray-d846e1d2.esm.js';
3
3
  import { useRef, useState, useLayoutEffect, useEffect } from 'react';
4
4
  import { Style, ValOverlay } from '@valbuild/ui';
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var ValProvider = require('./ValProvider-e1d5ffbe.cjs.prod.js');
3
+ var ValProvider = require('./ValProvider-d8fe7dc4.cjs.prod.js');
4
4
  var slicedToArray = require('./slicedToArray-0eb0bcdb.cjs.prod.js');
5
5
  var React = require('react');
6
6
  var ui = require('@valbuild/ui');
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var ValProvider = require('./ValProvider-7364ec46.cjs.dev.js');
3
+ var ValProvider = require('./ValProvider-7b9d888e.cjs.dev.js');
4
4
  var slicedToArray = require('./slicedToArray-b7cf26e0.cjs.dev.js');
5
5
  var React = require('react');
6
6
  var ui = require('@valbuild/ui');
@@ -12,4 +12,4 @@ export type ValProviderProps = {
12
12
  host?: string;
13
13
  children?: React.ReactNode;
14
14
  };
15
- export default function ValProvider({ host, children, }: ValProviderProps): JSX.Element;
15
+ export declare function ValProvider({ host, children }: ValProviderProps): JSX.Element;
@@ -1,3 +1,2 @@
1
- export { ValProviderWrapper as ValProvider } from "./ValProviderWrapper";
1
+ export { ValProvider } from "./ValProvider";
2
2
  export { useVal } from "./hooks/useVal";
3
- export { ValRichText } from "./ValRichText";
@@ -1,15 +1,5 @@
1
- import { createElement } from 'react';
2
- import { jsx } from 'react/jsx-runtime';
1
+ export { ValProvider } from './ValProvider-11be7088.browser.esm.js';
3
2
  import { Internal } from '@valbuild/core';
4
- import parse from 'style-to-object';
5
-
6
- function ValProviderWrapper(_ref) {
7
- _ref.host;
8
- _ref.children;
9
- {
10
- return null;
11
- }
12
- }
13
3
 
14
4
  function useVal(selector, locale) {
15
5
  // const mod = selectable.getModule();
@@ -33,121 +23,4 @@ function useVal(selector, locale) {
33
23
  return Internal.getVal(selector, locale);
34
24
  }
35
25
 
36
- /* eslint-disable @typescript-eslint/no-explicit-any */
37
- var getValPath = Internal.getValPath;
38
- function ValRichText(_ref) {
39
- var children = _ref.children;
40
- return /*#__PURE__*/jsx("div", {
41
- "data-val-path": getValPath(children),
42
- children: children.children.map(function (child) {
43
- switch (child.type.val) {
44
- case "heading":
45
- return /*#__PURE__*/jsx(HeadingNodeComponent, {
46
- node: child
47
- }, getValPath(child));
48
- case "paragraph":
49
- return /*#__PURE__*/jsx(ParagraphNodeComponent, {
50
- node: child
51
- }, getValPath(child));
52
- case "list":
53
- return /*#__PURE__*/jsx(ListNodeComponent, {
54
- node: child
55
- }, getValPath(child));
56
- default:
57
- throw Error("Unknown node type: " + (child === null || child === void 0 ? void 0 : child.type));
58
- }
59
- })
60
- });
61
- }
62
- function TextNodeComponent(_ref2) {
63
- var _parse;
64
- var node = _ref2.node;
65
- var actualVal = node.val;
66
- var styleProps = actualVal.style ? (_parse = parse(actualVal.style)) !== null && _parse !== void 0 ? _parse : {} : {};
67
- // TODO: Ugly! We should do this before serializing instead
68
- if (styleProps["font-family"]) {
69
- styleProps["fontFamily"] = styleProps["font-family"];
70
- delete styleProps["font-family"];
71
- }
72
- if (styleProps["font-size"]) {
73
- styleProps["fontSize"] = styleProps["font-size"];
74
- delete styleProps["font-size"];
75
- }
76
- var bitmask = actualVal.format.toString(2);
77
- var bitmaskOffset = bitmask.length - 1;
78
- function isBitOne(bit) {
79
- return bitmask.length >= bitmaskOffset - bit && bitmask[bitmaskOffset - bit] === "1";
80
- }
81
- if (isBitOne(0)) {
82
- styleProps["fontWeight"] = "bold";
83
- }
84
- if (isBitOne(1)) {
85
- styleProps["fontStyle"] = "italic";
86
- }
87
- if (isBitOne(2)) {
88
- if (!styleProps["textDecoration"]) {
89
- styleProps["textDecoration"] = "line-through";
90
- } else {
91
- styleProps["textDecoration"] += " line-through";
92
- }
93
- }
94
- if (isBitOne(3)) {
95
- if (!styleProps["textDecoration"]) {
96
- styleProps["textDecoration"] = "underline";
97
- } else {
98
- styleProps["textDecoration"] += " underline";
99
- }
100
- }
101
- return /*#__PURE__*/jsx("span", {
102
- style: styleProps,
103
- children: actualVal.text
104
- });
105
- }
106
- function HeadingNodeComponent(_ref3) {
107
- var node = _ref3.node;
108
- return /*#__PURE__*/createElement(node.tag.val, {}, node.children.map(function (child) {
109
- return /*#__PURE__*/jsx(TextNodeComponent, {
110
- node: child
111
- }, getValPath(child));
112
- }));
113
- }
114
- function ParagraphNodeComponent(_ref4) {
115
- var node = _ref4.node;
116
- return /*#__PURE__*/jsx("p", {
117
- children: node.children.map(function (child) {
118
- switch (child.type.val) {
119
- case "text":
120
- return /*#__PURE__*/jsx(TextNodeComponent, {
121
- node: child
122
- }, getValPath(child));
123
- default:
124
- throw Error("Unknown node type: " + (child === null || child === void 0 ? void 0 : child.type));
125
- }
126
- })
127
- });
128
- }
129
- function ListNodeComponent(_ref5) {
130
- var node = _ref5.node;
131
- return /*#__PURE__*/createElement(node.val.tag, {}, node.children.map(function (child) {
132
- return /*#__PURE__*/jsx(ListItemComponent, {
133
- node: child
134
- }, getValPath(child));
135
- }));
136
- }
137
- function ListItemComponent(_ref6) {
138
- var node = _ref6.node;
139
- return /*#__PURE__*/jsx("li", {
140
- children: node.children.map(function (child, i) {
141
- switch (child.val.type) {
142
- case "text":
143
- return /*#__PURE__*/jsx(TextNodeComponent, {
144
- node: child
145
- }, i);
146
- default:
147
- throw Error("Unknown node type: " + (child === null || child === void 0 ? void 0 : child.type));
148
- }
149
- })
150
- });
151
- }
152
-
153
- export { ValProviderWrapper as ValProvider, ValRichText, useVal };
26
+ export { useVal };
@@ -2,48 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var React = require('react');
6
- var ReactJSXRuntime = require('react/jsx-runtime');
5
+ var ValProvider = require('./ValProvider-7b9d888e.cjs.dev.js');
7
6
  var core = require('@valbuild/core');
8
- var parse = require('style-to-object');
9
-
10
- function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
11
-
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
- var parse__default = /*#__PURE__*/_interopDefault(parse);
31
-
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
7
 
48
8
  function useVal(selector, locale) {
49
9
  // const mod = selectable.getModule();
@@ -67,123 +27,8 @@ function useVal(selector, locale) {
67
27
  return core.Internal.getVal(selector, locale);
68
28
  }
69
29
 
70
- /* eslint-disable @typescript-eslint/no-explicit-any */
71
- var getValPath = core.Internal.getValPath;
72
- function ValRichText(_ref) {
73
- var children = _ref.children;
74
- return /*#__PURE__*/ReactJSXRuntime.jsx("div", {
75
- "data-val-path": getValPath(children),
76
- children: children.children.map(function (child) {
77
- switch (child.type.val) {
78
- case "heading":
79
- return /*#__PURE__*/ReactJSXRuntime.jsx(HeadingNodeComponent, {
80
- node: child
81
- }, getValPath(child));
82
- case "paragraph":
83
- return /*#__PURE__*/ReactJSXRuntime.jsx(ParagraphNodeComponent, {
84
- node: child
85
- }, getValPath(child));
86
- case "list":
87
- return /*#__PURE__*/ReactJSXRuntime.jsx(ListNodeComponent, {
88
- node: child
89
- }, getValPath(child));
90
- default:
91
- throw Error("Unknown node type: " + (child === null || child === void 0 ? void 0 : child.type));
92
- }
93
- })
94
- });
95
- }
96
- function TextNodeComponent(_ref2) {
97
- var _parse;
98
- var node = _ref2.node;
99
- var actualVal = node.val;
100
- var styleProps = actualVal.style ? (_parse = parse__default["default"](actualVal.style)) !== null && _parse !== void 0 ? _parse : {} : {};
101
- // TODO: Ugly! We should do this before serializing instead
102
- if (styleProps["font-family"]) {
103
- styleProps["fontFamily"] = styleProps["font-family"];
104
- delete styleProps["font-family"];
105
- }
106
- if (styleProps["font-size"]) {
107
- styleProps["fontSize"] = styleProps["font-size"];
108
- delete styleProps["font-size"];
109
- }
110
- var bitmask = actualVal.format.toString(2);
111
- var bitmaskOffset = bitmask.length - 1;
112
- function isBitOne(bit) {
113
- return bitmask.length >= bitmaskOffset - bit && bitmask[bitmaskOffset - bit] === "1";
114
- }
115
- if (isBitOne(0)) {
116
- styleProps["fontWeight"] = "bold";
117
- }
118
- if (isBitOne(1)) {
119
- styleProps["fontStyle"] = "italic";
120
- }
121
- if (isBitOne(2)) {
122
- if (!styleProps["textDecoration"]) {
123
- styleProps["textDecoration"] = "line-through";
124
- } else {
125
- styleProps["textDecoration"] += " line-through";
126
- }
127
- }
128
- if (isBitOne(3)) {
129
- if (!styleProps["textDecoration"]) {
130
- styleProps["textDecoration"] = "underline";
131
- } else {
132
- styleProps["textDecoration"] += " underline";
133
- }
134
- }
135
- return /*#__PURE__*/ReactJSXRuntime.jsx("span", {
136
- style: styleProps,
137
- children: actualVal.text
138
- });
139
- }
140
- function HeadingNodeComponent(_ref3) {
141
- var node = _ref3.node;
142
- return /*#__PURE__*/React.createElement(node.tag.val, {}, node.children.map(function (child) {
143
- return /*#__PURE__*/ReactJSXRuntime.jsx(TextNodeComponent, {
144
- node: child
145
- }, getValPath(child));
146
- }));
147
- }
148
- function ParagraphNodeComponent(_ref4) {
149
- var node = _ref4.node;
150
- return /*#__PURE__*/ReactJSXRuntime.jsx("p", {
151
- children: node.children.map(function (child) {
152
- switch (child.type.val) {
153
- case "text":
154
- return /*#__PURE__*/ReactJSXRuntime.jsx(TextNodeComponent, {
155
- node: child
156
- }, getValPath(child));
157
- default:
158
- throw Error("Unknown node type: " + (child === null || child === void 0 ? void 0 : child.type));
159
- }
160
- })
161
- });
162
- }
163
- function ListNodeComponent(_ref5) {
164
- var node = _ref5.node;
165
- return /*#__PURE__*/React.createElement(node.val.tag, {}, node.children.map(function (child) {
166
- return /*#__PURE__*/ReactJSXRuntime.jsx(ListItemComponent, {
167
- node: child
168
- }, getValPath(child));
169
- }));
170
- }
171
- function ListItemComponent(_ref6) {
172
- var node = _ref6.node;
173
- return /*#__PURE__*/ReactJSXRuntime.jsx("li", {
174
- children: node.children.map(function (child, i) {
175
- switch (child.val.type) {
176
- case "text":
177
- return /*#__PURE__*/ReactJSXRuntime.jsx(TextNodeComponent, {
178
- node: child
179
- }, i);
180
- default:
181
- throw Error("Unknown node type: " + (child === null || child === void 0 ? void 0 : child.type));
182
- }
183
- })
184
- });
185
- }
186
-
187
- exports.ValProvider = ValProviderWrapper;
188
- exports.ValRichText = ValRichText;
30
+ Object.defineProperty(exports, 'ValProvider', {
31
+ enumerable: true,
32
+ get: function () { return ValProvider.ValProvider; }
33
+ });
189
34
  exports.useVal = useVal;
@@ -2,48 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var React = require('react');
6
- var ReactJSXRuntime = require('react/jsx-runtime');
5
+ var ValProvider = require('./ValProvider-d8fe7dc4.cjs.prod.js');
7
6
  var core = require('@valbuild/core');
8
- var parse = require('style-to-object');
9
-
10
- function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
11
-
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
- var parse__default = /*#__PURE__*/_interopDefault(parse);
31
-
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
7
 
48
8
  function useVal(selector, locale) {
49
9
  // const mod = selectable.getModule();
@@ -67,123 +27,8 @@ function useVal(selector, locale) {
67
27
  return core.Internal.getVal(selector, locale);
68
28
  }
69
29
 
70
- /* eslint-disable @typescript-eslint/no-explicit-any */
71
- var getValPath = core.Internal.getValPath;
72
- function ValRichText(_ref) {
73
- var children = _ref.children;
74
- return /*#__PURE__*/ReactJSXRuntime.jsx("div", {
75
- "data-val-path": getValPath(children),
76
- children: children.children.map(function (child) {
77
- switch (child.type.val) {
78
- case "heading":
79
- return /*#__PURE__*/ReactJSXRuntime.jsx(HeadingNodeComponent, {
80
- node: child
81
- }, getValPath(child));
82
- case "paragraph":
83
- return /*#__PURE__*/ReactJSXRuntime.jsx(ParagraphNodeComponent, {
84
- node: child
85
- }, getValPath(child));
86
- case "list":
87
- return /*#__PURE__*/ReactJSXRuntime.jsx(ListNodeComponent, {
88
- node: child
89
- }, getValPath(child));
90
- default:
91
- throw Error("Unknown node type: " + (child === null || child === void 0 ? void 0 : child.type));
92
- }
93
- })
94
- });
95
- }
96
- function TextNodeComponent(_ref2) {
97
- var _parse;
98
- var node = _ref2.node;
99
- var actualVal = node.val;
100
- var styleProps = actualVal.style ? (_parse = parse__default["default"](actualVal.style)) !== null && _parse !== void 0 ? _parse : {} : {};
101
- // TODO: Ugly! We should do this before serializing instead
102
- if (styleProps["font-family"]) {
103
- styleProps["fontFamily"] = styleProps["font-family"];
104
- delete styleProps["font-family"];
105
- }
106
- if (styleProps["font-size"]) {
107
- styleProps["fontSize"] = styleProps["font-size"];
108
- delete styleProps["font-size"];
109
- }
110
- var bitmask = actualVal.format.toString(2);
111
- var bitmaskOffset = bitmask.length - 1;
112
- function isBitOne(bit) {
113
- return bitmask.length >= bitmaskOffset - bit && bitmask[bitmaskOffset - bit] === "1";
114
- }
115
- if (isBitOne(0)) {
116
- styleProps["fontWeight"] = "bold";
117
- }
118
- if (isBitOne(1)) {
119
- styleProps["fontStyle"] = "italic";
120
- }
121
- if (isBitOne(2)) {
122
- if (!styleProps["textDecoration"]) {
123
- styleProps["textDecoration"] = "line-through";
124
- } else {
125
- styleProps["textDecoration"] += " line-through";
126
- }
127
- }
128
- if (isBitOne(3)) {
129
- if (!styleProps["textDecoration"]) {
130
- styleProps["textDecoration"] = "underline";
131
- } else {
132
- styleProps["textDecoration"] += " underline";
133
- }
134
- }
135
- return /*#__PURE__*/ReactJSXRuntime.jsx("span", {
136
- style: styleProps,
137
- children: actualVal.text
138
- });
139
- }
140
- function HeadingNodeComponent(_ref3) {
141
- var node = _ref3.node;
142
- return /*#__PURE__*/React.createElement(node.tag.val, {}, node.children.map(function (child) {
143
- return /*#__PURE__*/ReactJSXRuntime.jsx(TextNodeComponent, {
144
- node: child
145
- }, getValPath(child));
146
- }));
147
- }
148
- function ParagraphNodeComponent(_ref4) {
149
- var node = _ref4.node;
150
- return /*#__PURE__*/ReactJSXRuntime.jsx("p", {
151
- children: node.children.map(function (child) {
152
- switch (child.type.val) {
153
- case "text":
154
- return /*#__PURE__*/ReactJSXRuntime.jsx(TextNodeComponent, {
155
- node: child
156
- }, getValPath(child));
157
- default:
158
- throw Error("Unknown node type: " + (child === null || child === void 0 ? void 0 : child.type));
159
- }
160
- })
161
- });
162
- }
163
- function ListNodeComponent(_ref5) {
164
- var node = _ref5.node;
165
- return /*#__PURE__*/React.createElement(node.val.tag, {}, node.children.map(function (child) {
166
- return /*#__PURE__*/ReactJSXRuntime.jsx(ListItemComponent, {
167
- node: child
168
- }, getValPath(child));
169
- }));
170
- }
171
- function ListItemComponent(_ref6) {
172
- var node = _ref6.node;
173
- return /*#__PURE__*/ReactJSXRuntime.jsx("li", {
174
- children: node.children.map(function (child, i) {
175
- switch (child.val.type) {
176
- case "text":
177
- return /*#__PURE__*/ReactJSXRuntime.jsx(TextNodeComponent, {
178
- node: child
179
- }, i);
180
- default:
181
- throw Error("Unknown node type: " + (child === null || child === void 0 ? void 0 : child.type));
182
- }
183
- })
184
- });
185
- }
186
-
187
- exports.ValProvider = ValProviderWrapper;
188
- exports.ValRichText = ValRichText;
30
+ Object.defineProperty(exports, 'ValProvider', {
31
+ enumerable: true,
32
+ get: function () { return ValProvider.ValProvider; }
33
+ });
189
34
  exports.useVal = useVal;
@@ -1,23 +1,5 @@
1
- import { lazy, createElement } from 'react';
2
- import { jsx } from 'react/jsx-runtime';
1
+ export { ValProvider } from './ValProvider-07551558.esm.js';
3
2
  import { Internal } from '@valbuild/core';
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
- }
21
3
 
22
4
  function useVal(selector, locale) {
23
5
  // const mod = selectable.getModule();
@@ -41,121 +23,4 @@ function useVal(selector, locale) {
41
23
  return Internal.getVal(selector, locale);
42
24
  }
43
25
 
44
- /* eslint-disable @typescript-eslint/no-explicit-any */
45
- var getValPath = Internal.getValPath;
46
- function ValRichText(_ref) {
47
- var children = _ref.children;
48
- return /*#__PURE__*/jsx("div", {
49
- "data-val-path": getValPath(children),
50
- children: children.children.map(function (child) {
51
- switch (child.type.val) {
52
- case "heading":
53
- return /*#__PURE__*/jsx(HeadingNodeComponent, {
54
- node: child
55
- }, getValPath(child));
56
- case "paragraph":
57
- return /*#__PURE__*/jsx(ParagraphNodeComponent, {
58
- node: child
59
- }, getValPath(child));
60
- case "list":
61
- return /*#__PURE__*/jsx(ListNodeComponent, {
62
- node: child
63
- }, getValPath(child));
64
- default:
65
- throw Error("Unknown node type: " + (child === null || child === void 0 ? void 0 : child.type));
66
- }
67
- })
68
- });
69
- }
70
- function TextNodeComponent(_ref2) {
71
- var _parse;
72
- var node = _ref2.node;
73
- var actualVal = node.val;
74
- var styleProps = actualVal.style ? (_parse = parse(actualVal.style)) !== null && _parse !== void 0 ? _parse : {} : {};
75
- // TODO: Ugly! We should do this before serializing instead
76
- if (styleProps["font-family"]) {
77
- styleProps["fontFamily"] = styleProps["font-family"];
78
- delete styleProps["font-family"];
79
- }
80
- if (styleProps["font-size"]) {
81
- styleProps["fontSize"] = styleProps["font-size"];
82
- delete styleProps["font-size"];
83
- }
84
- var bitmask = actualVal.format.toString(2);
85
- var bitmaskOffset = bitmask.length - 1;
86
- function isBitOne(bit) {
87
- return bitmask.length >= bitmaskOffset - bit && bitmask[bitmaskOffset - bit] === "1";
88
- }
89
- if (isBitOne(0)) {
90
- styleProps["fontWeight"] = "bold";
91
- }
92
- if (isBitOne(1)) {
93
- styleProps["fontStyle"] = "italic";
94
- }
95
- if (isBitOne(2)) {
96
- if (!styleProps["textDecoration"]) {
97
- styleProps["textDecoration"] = "line-through";
98
- } else {
99
- styleProps["textDecoration"] += " line-through";
100
- }
101
- }
102
- if (isBitOne(3)) {
103
- if (!styleProps["textDecoration"]) {
104
- styleProps["textDecoration"] = "underline";
105
- } else {
106
- styleProps["textDecoration"] += " underline";
107
- }
108
- }
109
- return /*#__PURE__*/jsx("span", {
110
- style: styleProps,
111
- children: actualVal.text
112
- });
113
- }
114
- function HeadingNodeComponent(_ref3) {
115
- var node = _ref3.node;
116
- return /*#__PURE__*/createElement(node.tag.val, {}, node.children.map(function (child) {
117
- return /*#__PURE__*/jsx(TextNodeComponent, {
118
- node: child
119
- }, getValPath(child));
120
- }));
121
- }
122
- function ParagraphNodeComponent(_ref4) {
123
- var node = _ref4.node;
124
- return /*#__PURE__*/jsx("p", {
125
- children: node.children.map(function (child) {
126
- switch (child.type.val) {
127
- case "text":
128
- return /*#__PURE__*/jsx(TextNodeComponent, {
129
- node: child
130
- }, getValPath(child));
131
- default:
132
- throw Error("Unknown node type: " + (child === null || child === void 0 ? void 0 : child.type));
133
- }
134
- })
135
- });
136
- }
137
- function ListNodeComponent(_ref5) {
138
- var node = _ref5.node;
139
- return /*#__PURE__*/createElement(node.val.tag, {}, node.children.map(function (child) {
140
- return /*#__PURE__*/jsx(ListItemComponent, {
141
- node: child
142
- }, getValPath(child));
143
- }));
144
- }
145
- function ListItemComponent(_ref6) {
146
- var node = _ref6.node;
147
- return /*#__PURE__*/jsx("li", {
148
- children: node.children.map(function (child, i) {
149
- switch (child.val.type) {
150
- case "text":
151
- return /*#__PURE__*/jsx(TextNodeComponent, {
152
- node: child
153
- }, i);
154
- default:
155
- throw Error("Unknown node type: " + (child === null || child === void 0 ? void 0 : child.type));
156
- }
157
- })
158
- });
159
- }
160
-
161
- export { ValProviderWrapper as ValProvider, ValRichText, useVal };
26
+ export { useVal };
@@ -1,23 +1,5 @@
1
- import { lazy, createElement } from 'react';
2
- import { jsx } from 'react/jsx-runtime';
1
+ export { ValProvider } from './ValProvider-50aa4ba8.worker.esm.js';
3
2
  import { Internal } from '@valbuild/core';
4
- import parse from 'style-to-object';
5
-
6
- var ValProvider = /*#__PURE__*/lazy(function () {
7
- return import('./ValProvider-a45a47b9.worker.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
- }
21
3
 
22
4
  function useVal(selector, locale) {
23
5
  // const mod = selectable.getModule();
@@ -41,121 +23,4 @@ function useVal(selector, locale) {
41
23
  return Internal.getVal(selector, locale);
42
24
  }
43
25
 
44
- /* eslint-disable @typescript-eslint/no-explicit-any */
45
- var getValPath = Internal.getValPath;
46
- function ValRichText(_ref) {
47
- var children = _ref.children;
48
- return /*#__PURE__*/jsx("div", {
49
- "data-val-path": getValPath(children),
50
- children: children.children.map(function (child) {
51
- switch (child.type.val) {
52
- case "heading":
53
- return /*#__PURE__*/jsx(HeadingNodeComponent, {
54
- node: child
55
- }, getValPath(child));
56
- case "paragraph":
57
- return /*#__PURE__*/jsx(ParagraphNodeComponent, {
58
- node: child
59
- }, getValPath(child));
60
- case "list":
61
- return /*#__PURE__*/jsx(ListNodeComponent, {
62
- node: child
63
- }, getValPath(child));
64
- default:
65
- throw Error("Unknown node type: " + (child === null || child === void 0 ? void 0 : child.type));
66
- }
67
- })
68
- });
69
- }
70
- function TextNodeComponent(_ref2) {
71
- var _parse;
72
- var node = _ref2.node;
73
- var actualVal = node.val;
74
- var styleProps = actualVal.style ? (_parse = parse(actualVal.style)) !== null && _parse !== void 0 ? _parse : {} : {};
75
- // TODO: Ugly! We should do this before serializing instead
76
- if (styleProps["font-family"]) {
77
- styleProps["fontFamily"] = styleProps["font-family"];
78
- delete styleProps["font-family"];
79
- }
80
- if (styleProps["font-size"]) {
81
- styleProps["fontSize"] = styleProps["font-size"];
82
- delete styleProps["font-size"];
83
- }
84
- var bitmask = actualVal.format.toString(2);
85
- var bitmaskOffset = bitmask.length - 1;
86
- function isBitOne(bit) {
87
- return bitmask.length >= bitmaskOffset - bit && bitmask[bitmaskOffset - bit] === "1";
88
- }
89
- if (isBitOne(0)) {
90
- styleProps["fontWeight"] = "bold";
91
- }
92
- if (isBitOne(1)) {
93
- styleProps["fontStyle"] = "italic";
94
- }
95
- if (isBitOne(2)) {
96
- if (!styleProps["textDecoration"]) {
97
- styleProps["textDecoration"] = "line-through";
98
- } else {
99
- styleProps["textDecoration"] += " line-through";
100
- }
101
- }
102
- if (isBitOne(3)) {
103
- if (!styleProps["textDecoration"]) {
104
- styleProps["textDecoration"] = "underline";
105
- } else {
106
- styleProps["textDecoration"] += " underline";
107
- }
108
- }
109
- return /*#__PURE__*/jsx("span", {
110
- style: styleProps,
111
- children: actualVal.text
112
- });
113
- }
114
- function HeadingNodeComponent(_ref3) {
115
- var node = _ref3.node;
116
- return /*#__PURE__*/createElement(node.tag.val, {}, node.children.map(function (child) {
117
- return /*#__PURE__*/jsx(TextNodeComponent, {
118
- node: child
119
- }, getValPath(child));
120
- }));
121
- }
122
- function ParagraphNodeComponent(_ref4) {
123
- var node = _ref4.node;
124
- return /*#__PURE__*/jsx("p", {
125
- children: node.children.map(function (child) {
126
- switch (child.type.val) {
127
- case "text":
128
- return /*#__PURE__*/jsx(TextNodeComponent, {
129
- node: child
130
- }, getValPath(child));
131
- default:
132
- throw Error("Unknown node type: " + (child === null || child === void 0 ? void 0 : child.type));
133
- }
134
- })
135
- });
136
- }
137
- function ListNodeComponent(_ref5) {
138
- var node = _ref5.node;
139
- return /*#__PURE__*/createElement(node.val.tag, {}, node.children.map(function (child) {
140
- return /*#__PURE__*/jsx(ListItemComponent, {
141
- node: child
142
- }, getValPath(child));
143
- }));
144
- }
145
- function ListItemComponent(_ref6) {
146
- var node = _ref6.node;
147
- return /*#__PURE__*/jsx("li", {
148
- children: node.children.map(function (child, i) {
149
- switch (child.val.type) {
150
- case "text":
151
- return /*#__PURE__*/jsx(TextNodeComponent, {
152
- node: child
153
- }, i);
154
- default:
155
- throw Error("Unknown node type: " + (child === null || child === void 0 ? void 0 : child.type));
156
- }
157
- })
158
- });
159
- }
160
-
161
- export { ValProviderWrapper as ValProvider, ValRichText, useVal };
26
+ export { useVal };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@valbuild/react",
3
- "version": "0.13.3",
3
+ "version": "0.13.4",
4
4
  "private": false,
5
5
  "description": "Val - React",
6
6
  "sideEffects": false,
@@ -9,8 +9,8 @@
9
9
  "test": "jest"
10
10
  },
11
11
  "dependencies": {
12
- "@valbuild/core": "~0.13.3",
13
- "@valbuild/ui": "~0.13.3",
12
+ "@valbuild/core": "~0.13.4",
13
+ "@valbuild/ui": "~0.13.4",
14
14
  "base64-arraybuffer": "^1.0.2",
15
15
  "style-to-object": "^0.4.1"
16
16
  },
@@ -22,8 +22,8 @@
22
22
  "react-dom": "^18.2.0"
23
23
  },
24
24
  "peerDependencies": {
25
- "react": ">=16.8.0",
26
- "react-dom": ">=16.8.0"
25
+ "react": ">=18.2.0",
26
+ "react-dom": ">=18.2.0"
27
27
  },
28
28
  "peerDependenciesMeta": {
29
29
  "@types/react": {
@@ -43,6 +43,9 @@
43
43
  ]
44
44
  }
45
45
  },
46
+ "externals": [
47
+ "react"
48
+ ],
46
49
  "main": "dist/valbuild-react.cjs.js",
47
50
  "module": "dist/valbuild-react.esm.js",
48
51
  "browser": {
@@ -36,10 +36,7 @@ export type ValProviderProps = {
36
36
  const ValUI =
37
37
  typeof window !== "undefined" ? lazy(() => import("./ValUI")) : null;
38
38
 
39
- export default function ValProvider({
40
- host = "/api/val",
41
- children,
42
- }: ValProviderProps) {
39
+ export function ValProvider({ host = "/api/val", children }: ValProviderProps) {
43
40
  const valApi = useMemo(() => new ValApi(host), [host]);
44
41
  const valStore = useMemo(() => new ValStore(valApi), [valApi]);
45
42
  return (
package/src/index.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  /* export { useContent } from "./useContent";
2
2
  export { useText } from "./useText";
3
3
  export { WithVal } from "./WithVal"; */
4
- export { ValProviderWrapper as ValProvider } from "./ValProviderWrapper";
4
+ export { ValProvider } from "./ValProvider";
5
5
  export { useVal } from "./hooks/useVal";
6
- export { ValRichText } from "./ValRichText";
@@ -1,7 +0,0 @@
1
- 'use strict';
2
-
3
- if (process.env.NODE_ENV === "production") {
4
- module.exports = require("./ValProvider-e1d5ffbe.cjs.prod.js");
5
- } else {
6
- module.exports = require("./ValProvider-e1d5ffbe.cjs.dev.js");
7
- }
@@ -1,3 +0,0 @@
1
- /// <reference types="react" />
2
- import { ValProviderProps } from "./ValProvider";
3
- export declare function ValProviderWrapper({ host, children, }: ValProviderProps): JSX.Element | null;
@@ -1,5 +0,0 @@
1
- /// <reference types="react" />
2
- import { RichText, Val } from "@valbuild/core";
3
- export declare function ValRichText({ children }: {
4
- children: Val<RichText>;
5
- }): JSX.Element;
@@ -1,15 +0,0 @@
1
- import { lazy } from "react";
2
- import { ValProviderProps } from "./ValProvider";
3
-
4
- const ValProvider =
5
- typeof window === "undefined" && lazy(() => import("./ValProvider"));
6
-
7
- export function ValProviderWrapper({
8
- host = "/api/val",
9
- children,
10
- }: ValProviderProps) {
11
- if (!ValProvider) {
12
- return null;
13
- }
14
- return <ValProvider host={host}>{children}</ValProvider>;
15
- }
@@ -1,141 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
- import {
3
- HeadingNode,
4
- ListItemNode,
5
- ListNode,
6
- ParagraphNode,
7
- RichText,
8
- TextNode,
9
- Val,
10
- } from "@valbuild/core";
11
- import { Internal } from "@valbuild/core";
12
- import { createElement } from "react";
13
- import parse from "style-to-object";
14
-
15
- const getValPath = Internal.getValPath;
16
- export function ValRichText({ children }: { children: Val<RichText> }) {
17
- return (
18
- <div data-val-path={getValPath(children)}>
19
- {children.children.map((child) => {
20
- switch (child.type.val) {
21
- case "heading":
22
- return (
23
- <HeadingNodeComponent
24
- key={getValPath(child)}
25
- node={child as Val<HeadingNode>}
26
- />
27
- );
28
- case "paragraph":
29
- return (
30
- <ParagraphNodeComponent
31
- key={getValPath(child)}
32
- node={child as Val<ParagraphNode>}
33
- />
34
- );
35
- case "list":
36
- return (
37
- <ListNodeComponent
38
- key={getValPath(child)}
39
- node={child as Val<ListNode>}
40
- />
41
- );
42
- default:
43
- throw Error("Unknown node type: " + (child as any)?.type);
44
- }
45
- })}
46
- </div>
47
- );
48
- }
49
-
50
- function TextNodeComponent({ node }: { node: Val<TextNode> }) {
51
- const actualVal = node.val;
52
- const styleProps = actualVal.style ? parse(actualVal.style) ?? {} : {};
53
- // TODO: Ugly! We should do this before serializing instead
54
- if (styleProps["font-family"]) {
55
- styleProps["fontFamily"] = styleProps["font-family"];
56
- delete styleProps["font-family"];
57
- }
58
- if (styleProps["font-size"]) {
59
- styleProps["fontSize"] = styleProps["font-size"];
60
- delete styleProps["font-size"];
61
- }
62
- const bitmask = actualVal.format.toString(2);
63
- const bitmaskOffset = bitmask.length - 1;
64
- function isBitOne(bit: number) {
65
- return (
66
- bitmask.length >= bitmaskOffset - bit &&
67
- bitmask[bitmaskOffset - bit] === "1"
68
- );
69
- }
70
- if (isBitOne(0)) {
71
- styleProps["fontWeight"] = "bold";
72
- }
73
- if (isBitOne(1)) {
74
- styleProps["fontStyle"] = "italic";
75
- }
76
- if (isBitOne(2)) {
77
- if (!styleProps["textDecoration"]) {
78
- styleProps["textDecoration"] = "line-through";
79
- } else {
80
- styleProps["textDecoration"] += " line-through";
81
- }
82
- }
83
- if (isBitOne(3)) {
84
- if (!styleProps["textDecoration"]) {
85
- styleProps["textDecoration"] = "underline";
86
- } else {
87
- styleProps["textDecoration"] += " underline";
88
- }
89
- }
90
- return <span style={styleProps}>{actualVal.text}</span>;
91
- }
92
-
93
- function HeadingNodeComponent({ node }: { node: Val<HeadingNode> }) {
94
- return createElement(
95
- node.tag.val,
96
- {},
97
- node.children.map((child) => (
98
- <TextNodeComponent key={getValPath(child)} node={child} />
99
- ))
100
- );
101
- }
102
-
103
- function ParagraphNodeComponent({ node }: { node: Val<ParagraphNode> }) {
104
- return (
105
- <p>
106
- {node.children.map((child) => {
107
- switch (child.type.val) {
108
- case "text":
109
- return <TextNodeComponent key={getValPath(child)} node={child} />;
110
- default:
111
- throw Error("Unknown node type: " + (child as any)?.type);
112
- }
113
- })}
114
- </p>
115
- );
116
- }
117
-
118
- function ListNodeComponent({ node }: { node: Val<ListNode> }) {
119
- return createElement(
120
- node.val.tag,
121
- {},
122
- node.children.map((child) => (
123
- <ListItemComponent key={getValPath(child)} node={child} />
124
- ))
125
- );
126
- }
127
-
128
- function ListItemComponent({ node }: { node: Val<ListItemNode> }) {
129
- return (
130
- <li>
131
- {node.children.map((child, i) => {
132
- switch (child.val.type) {
133
- case "text":
134
- return <TextNodeComponent key={i} node={child} />;
135
- default:
136
- throw Error("Unknown node type: " + (child as any)?.type);
137
- }
138
- })}
139
- </li>
140
- );
141
- }