@valbuild/react 0.17.0 → 0.19.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/{ValUI-d33998d0.esm.js → ValUI-4cf199a2.esm.js} +9 -2
- package/dist/{ValUI-9ac161d2.cjs.dev.js → ValUI-7d465071.cjs.dev.js} +9 -2
- package/dist/{ValUI-64e3e5f2.browser.esm.js → ValUI-b51ca60e.browser.esm.js} +9 -2
- package/dist/{ValUI-3e00aae3.cjs.prod.js → ValUI-b5f81233.cjs.prod.js} +9 -2
- package/dist/declarations/src/ValRichText.d.ts +21 -3
- package/dist/declarations/src/stega/index.d.ts +1 -1
- package/dist/declarations/src/stega/{transform.d.ts → stegaEncode.d.ts} +2 -2
- package/dist/valbuild-react.browser.esm.js +126 -125
- package/dist/valbuild-react.cjs.dev.js +125 -125
- package/dist/valbuild-react.cjs.prod.js +125 -125
- package/dist/valbuild-react.esm.js +126 -125
- package/dist/valbuild-react.worker.esm.js +125 -124
- package/package.json +3 -3
- package/src/ShadowRoot.tsx +9 -3
- package/src/ValRichText.tsx +178 -162
- package/src/ValUI.tsx +8 -1
- package/src/stega/autoTagJSX.ts +4 -3
- package/src/stega/index.ts +2 -2
- package/src/stega/{transform.test.ts → stegaEncode.test.ts} +16 -7
- package/src/stega/{transform.ts → stegaEncode.ts} +44 -21
- package/stega/dist/valbuild-react-stega.browser.esm.js +41 -19
- package/stega/dist/valbuild-react-stega.cjs.dev.js +41 -19
- package/stega/dist/valbuild-react-stega.cjs.prod.js +41 -19
- package/stega/dist/valbuild-react-stega.esm.js +41 -19
- package/stega/dist/valbuild-react-stega.worker.esm.js +41 -19
- package/tsconfig.json +2 -1
@@ -1,10 +1,9 @@
|
|
1
|
-
import React, { useContext, useMemo, lazy
|
1
|
+
import React, { useContext, useMemo, lazy } from 'react';
|
2
2
|
import { _ as _unsupportedIterableToArray, a as _slicedToArray } from './slicedToArray-b4fb91fa.esm.js';
|
3
3
|
import { _ as _toPropertyKey, a as _defineProperty } from './defineProperty-b209a901.esm.js';
|
4
4
|
import { result } from '@valbuild/core/fp';
|
5
5
|
import { ValApi } from '@valbuild/core';
|
6
6
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
7
|
-
import parse from 'style-to-object';
|
8
7
|
|
9
8
|
function _createForOfIteratorHelper(o, allowArrayLike) {
|
10
9
|
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
@@ -599,7 +598,7 @@ var ValContext = /*#__PURE__*/React.createContext({
|
|
599
598
|
}
|
600
599
|
});
|
601
600
|
var ValUI = typeof window !== "undefined" ? /*#__PURE__*/lazy(function () {
|
602
|
-
return import('./ValUI-
|
601
|
+
return import('./ValUI-4cf199a2.esm.js');
|
603
602
|
}) : null;
|
604
603
|
function ValProvider(_ref) {
|
605
604
|
var _ref$host = _ref.host,
|
@@ -620,136 +619,138 @@ function ValProvider(_ref) {
|
|
620
619
|
});
|
621
620
|
}
|
622
621
|
|
622
|
+
/* eslint-disable @typescript-eslint/ban-types */
|
623
623
|
function ValRichText(_ref) {
|
624
|
-
var
|
624
|
+
var theme = _ref.theme,
|
625
|
+
children = _ref.children;
|
625
626
|
var root = children;
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
var childType = child.type;
|
631
|
-
var childPath = "".concat(path, ".").concat(i);
|
632
|
-
switch (childType) {
|
633
|
-
case "heading":
|
634
|
-
return /*#__PURE__*/jsx(HeadingNodeComponent, {
|
635
|
-
path: childPath,
|
636
|
-
node: child
|
637
|
-
}, childPath);
|
638
|
-
case "paragraph":
|
639
|
-
return /*#__PURE__*/jsx(ParagraphNodeComponent, {
|
640
|
-
path: childPath,
|
641
|
-
node: child
|
642
|
-
}, childPath);
|
643
|
-
case "list":
|
644
|
-
return /*#__PURE__*/jsx(ListNodeComponent, {
|
645
|
-
path: childPath,
|
646
|
-
node: child
|
647
|
-
}, childPath);
|
648
|
-
default:
|
649
|
-
throw Error("Unknown root node type: " + childType);
|
650
|
-
}
|
651
|
-
})
|
652
|
-
});
|
653
|
-
}
|
654
|
-
function TextNodeComponent(_ref2) {
|
655
|
-
var _parse, _node$format;
|
656
|
-
var node = _ref2.node;
|
657
|
-
var styleProps = node.style ? (_parse = parse(node.style)) !== null && _parse !== void 0 ? _parse : {} : {};
|
658
|
-
// TODO: Ugly! We should do this before serializing instead
|
659
|
-
if (styleProps["font-family"]) {
|
660
|
-
styleProps["fontFamily"] = styleProps["font-family"];
|
661
|
-
delete styleProps["font-family"];
|
662
|
-
}
|
663
|
-
if (styleProps["font-size"]) {
|
664
|
-
styleProps["fontSize"] = styleProps["font-size"];
|
665
|
-
delete styleProps["font-size"];
|
666
|
-
}
|
667
|
-
var bitmask = (_node$format = node.format) === null || _node$format === void 0 ? void 0 : _node$format.toString(2);
|
668
|
-
var bitmaskOffset = bitmask ? bitmask.length - 1 : 0;
|
669
|
-
function isBitOne(bit) {
|
670
|
-
if (!bitmask) {
|
671
|
-
return false;
|
627
|
+
function withRenderTag(clazz, current) {
|
628
|
+
var renderClass = theme.tags[clazz];
|
629
|
+
if (renderClass && current) {
|
630
|
+
return [current, renderClass].join(" ");
|
672
631
|
}
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
}
|
678
|
-
if (isBitOne(1)) {
|
679
|
-
styleProps["fontStyle"] = "italic";
|
632
|
+
if (renderClass) {
|
633
|
+
return renderClass;
|
634
|
+
}
|
635
|
+
return current;
|
680
636
|
}
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
637
|
+
function withRenderClass(clazz, current) {
|
638
|
+
var renderClass = theme.classes[clazz];
|
639
|
+
if (renderClass && current) {
|
640
|
+
return [current, renderClass].join(" ");
|
641
|
+
}
|
642
|
+
if (renderClass) {
|
643
|
+
return renderClass;
|
686
644
|
}
|
645
|
+
return current;
|
687
646
|
}
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
647
|
+
function toReact(node, key) {
|
648
|
+
var _anyNode$class, _anyNode$children;
|
649
|
+
if (typeof node === "string") {
|
650
|
+
return node;
|
651
|
+
}
|
652
|
+
if (node.tag === "p") {
|
653
|
+
return /*#__PURE__*/jsx("p", {
|
654
|
+
className: withRenderTag("p"),
|
655
|
+
children: node.children.map(toReact)
|
656
|
+
}, key);
|
657
|
+
}
|
658
|
+
if (node.tag === "img") {
|
659
|
+
return /*#__PURE__*/jsx("div", {
|
660
|
+
className: withRenderClass("imgContainer"),
|
661
|
+
children: /*#__PURE__*/jsx("img", {
|
662
|
+
className: withRenderTag("img"),
|
663
|
+
src: node.src
|
664
|
+
})
|
665
|
+
}, key);
|
666
|
+
}
|
667
|
+
// if (node.tag === "blockquote") {
|
668
|
+
// return <blockquote key={key}>{node.children.map(toReact)}</blockquote>;
|
669
|
+
// }
|
670
|
+
if (node.tag === "ul") {
|
671
|
+
return /*#__PURE__*/jsx("ul", {
|
672
|
+
className: withRenderTag("ul"),
|
673
|
+
children: node.children.map(toReact)
|
674
|
+
}, key);
|
675
|
+
}
|
676
|
+
if (node.tag === "ol") {
|
677
|
+
return /*#__PURE__*/jsx("ol", {
|
678
|
+
className: withRenderTag("ol"),
|
679
|
+
children: node.children.map(toReact)
|
680
|
+
}, key);
|
681
|
+
}
|
682
|
+
if (node.tag === "li") {
|
683
|
+
return /*#__PURE__*/jsx("li", {
|
684
|
+
className: withRenderTag("li"),
|
685
|
+
children: node.children.map(toReact)
|
686
|
+
}, key);
|
687
|
+
}
|
688
|
+
if (node.tag === "span") {
|
689
|
+
return /*#__PURE__*/jsx("span", {
|
690
|
+
className: node.classes.map(function (nodeClass) {
|
691
|
+
switch (nodeClass) {
|
692
|
+
case "bold":
|
693
|
+
return withRenderClass("bold");
|
694
|
+
case "line-through":
|
695
|
+
return withRenderClass("lineThrough");
|
696
|
+
case "italic":
|
697
|
+
return withRenderClass("italic");
|
698
|
+
}
|
699
|
+
}).join(" "),
|
700
|
+
children: node.children.map(toReact)
|
701
|
+
}, key);
|
693
702
|
}
|
703
|
+
if (node.tag === "h1") {
|
704
|
+
return /*#__PURE__*/jsx("h1", {
|
705
|
+
className: withRenderTag("h1"),
|
706
|
+
children: node.children.map(toReact)
|
707
|
+
}, key);
|
708
|
+
}
|
709
|
+
if (node.tag === "h2") {
|
710
|
+
return /*#__PURE__*/jsx("h2", {
|
711
|
+
className: withRenderTag("h2"),
|
712
|
+
children: node.children.map(toReact)
|
713
|
+
}, key);
|
714
|
+
}
|
715
|
+
if (node.tag === "h3") {
|
716
|
+
return /*#__PURE__*/jsx("h3", {
|
717
|
+
className: withRenderTag("h3"),
|
718
|
+
children: node.children.map(toReact)
|
719
|
+
}, key);
|
720
|
+
}
|
721
|
+
if (node.tag === "h4") {
|
722
|
+
return /*#__PURE__*/jsx("h4", {
|
723
|
+
className: withRenderTag("h4"),
|
724
|
+
children: node.children.map(toReact)
|
725
|
+
}, key);
|
726
|
+
}
|
727
|
+
if (node.tag === "h5") {
|
728
|
+
return /*#__PURE__*/jsx("h5", {
|
729
|
+
className: withRenderTag("h5"),
|
730
|
+
children: node.children.map(toReact)
|
731
|
+
}, key);
|
732
|
+
}
|
733
|
+
if (node.tag === "h6") {
|
734
|
+
return /*#__PURE__*/jsx("h6", {
|
735
|
+
className: withRenderTag("h6"),
|
736
|
+
children: node.children.map(toReact)
|
737
|
+
}, key);
|
738
|
+
}
|
739
|
+
console.error("Unknown tag", node.tag);
|
740
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
741
|
+
var anyNode = node;
|
742
|
+
if (!(anyNode !== null && anyNode !== void 0 && anyNode.tag)) {
|
743
|
+
return null;
|
744
|
+
}
|
745
|
+
return /*#__PURE__*/React.createElement(anyNode.tag, {
|
746
|
+
key: key,
|
747
|
+
className: (_anyNode$class = anyNode["class"]) === null || _anyNode$class === void 0 ? void 0 : _anyNode$class.join(" "),
|
748
|
+
children: (_anyNode$children = anyNode.children) === null || _anyNode$children === void 0 ? void 0 : _anyNode$children.map(toReact)
|
749
|
+
});
|
694
750
|
}
|
695
|
-
return /*#__PURE__*/jsx("
|
696
|
-
|
697
|
-
children:
|
698
|
-
});
|
699
|
-
}
|
700
|
-
function HeadingNodeComponent(_ref3) {
|
701
|
-
var node = _ref3.node,
|
702
|
-
path = _ref3.path;
|
703
|
-
return /*#__PURE__*/createElement(node.tag, {}, node.children.map(function (child, i) {
|
704
|
-
var childPath = "".concat(path, ".").concat(i);
|
705
|
-
return /*#__PURE__*/jsx(TextNodeComponent, {
|
706
|
-
node: child
|
707
|
-
}, childPath);
|
708
|
-
}));
|
709
|
-
}
|
710
|
-
function ParagraphNodeComponent(_ref4) {
|
711
|
-
var node = _ref4.node,
|
712
|
-
path = _ref4.path;
|
713
|
-
return /*#__PURE__*/jsx("p", {
|
714
|
-
children: node.children.map(function (child, i) {
|
715
|
-
var childPath = "".concat(path, ".").concat(i);
|
716
|
-
switch (child.type) {
|
717
|
-
case "text":
|
718
|
-
return /*#__PURE__*/jsx(TextNodeComponent, {
|
719
|
-
node: child
|
720
|
-
}, childPath);
|
721
|
-
default:
|
722
|
-
throw Error("Unknown paragraph node type: " + (child === null || child === void 0 ? void 0 : child.type));
|
723
|
-
}
|
724
|
-
})
|
725
|
-
});
|
726
|
-
}
|
727
|
-
function ListNodeComponent(_ref5) {
|
728
|
-
var node = _ref5.node,
|
729
|
-
path = _ref5.path;
|
730
|
-
return /*#__PURE__*/createElement(node.tag, {}, node.children.map(function (child, i) {
|
731
|
-
var childPath = "".concat(path, ".").concat(i);
|
732
|
-
return /*#__PURE__*/jsx(ListItemComponent, {
|
733
|
-
path: childPath,
|
734
|
-
node: child
|
735
|
-
}, childPath);
|
736
|
-
}));
|
737
|
-
}
|
738
|
-
function ListItemComponent(_ref6) {
|
739
|
-
var node = _ref6.node,
|
740
|
-
path = _ref6.path;
|
741
|
-
return /*#__PURE__*/jsx("li", {
|
742
|
-
children: node.children.map(function (child, i) {
|
743
|
-
var childPath = "".concat(path, ".").concat(i);
|
744
|
-
switch (child.type) {
|
745
|
-
case "text":
|
746
|
-
return /*#__PURE__*/jsx(TextNodeComponent, {
|
747
|
-
node: child
|
748
|
-
}, childPath);
|
749
|
-
default:
|
750
|
-
throw Error("Unknown list item node type: " + (child === null || child === void 0 ? void 0 : child.type));
|
751
|
-
}
|
752
|
-
})
|
751
|
+
return /*#__PURE__*/jsx("div", {
|
752
|
+
"data-val-path": root.valPath,
|
753
|
+
children: root.children.map(toReact)
|
753
754
|
});
|
754
755
|
}
|
755
756
|
|
@@ -1,10 +1,9 @@
|
|
1
|
-
import React, { useContext, useMemo
|
1
|
+
import React, { useContext, useMemo } from 'react';
|
2
2
|
import { _ as _unsupportedIterableToArray, a as _slicedToArray } from './slicedToArray-5a51fd33.worker.esm.js';
|
3
3
|
import { _ as _toPropertyKey, a as _defineProperty } from './defineProperty-18559492.worker.esm.js';
|
4
4
|
import { result } from '@valbuild/core/fp';
|
5
5
|
import { ValApi } from '@valbuild/core';
|
6
6
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
7
|
-
import parse from 'style-to-object';
|
8
7
|
|
9
8
|
function _createForOfIteratorHelper(o, allowArrayLike) {
|
10
9
|
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
@@ -618,136 +617,138 @@ function ValProvider(_ref) {
|
|
618
617
|
});
|
619
618
|
}
|
620
619
|
|
620
|
+
/* eslint-disable @typescript-eslint/ban-types */
|
621
621
|
function ValRichText(_ref) {
|
622
|
-
var
|
622
|
+
var theme = _ref.theme,
|
623
|
+
children = _ref.children;
|
623
624
|
var root = children;
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
var childType = child.type;
|
629
|
-
var childPath = "".concat(path, ".").concat(i);
|
630
|
-
switch (childType) {
|
631
|
-
case "heading":
|
632
|
-
return /*#__PURE__*/jsx(HeadingNodeComponent, {
|
633
|
-
path: childPath,
|
634
|
-
node: child
|
635
|
-
}, childPath);
|
636
|
-
case "paragraph":
|
637
|
-
return /*#__PURE__*/jsx(ParagraphNodeComponent, {
|
638
|
-
path: childPath,
|
639
|
-
node: child
|
640
|
-
}, childPath);
|
641
|
-
case "list":
|
642
|
-
return /*#__PURE__*/jsx(ListNodeComponent, {
|
643
|
-
path: childPath,
|
644
|
-
node: child
|
645
|
-
}, childPath);
|
646
|
-
default:
|
647
|
-
throw Error("Unknown root node type: " + childType);
|
648
|
-
}
|
649
|
-
})
|
650
|
-
});
|
651
|
-
}
|
652
|
-
function TextNodeComponent(_ref2) {
|
653
|
-
var _parse, _node$format;
|
654
|
-
var node = _ref2.node;
|
655
|
-
var styleProps = node.style ? (_parse = parse(node.style)) !== null && _parse !== void 0 ? _parse : {} : {};
|
656
|
-
// TODO: Ugly! We should do this before serializing instead
|
657
|
-
if (styleProps["font-family"]) {
|
658
|
-
styleProps["fontFamily"] = styleProps["font-family"];
|
659
|
-
delete styleProps["font-family"];
|
660
|
-
}
|
661
|
-
if (styleProps["font-size"]) {
|
662
|
-
styleProps["fontSize"] = styleProps["font-size"];
|
663
|
-
delete styleProps["font-size"];
|
664
|
-
}
|
665
|
-
var bitmask = (_node$format = node.format) === null || _node$format === void 0 ? void 0 : _node$format.toString(2);
|
666
|
-
var bitmaskOffset = bitmask ? bitmask.length - 1 : 0;
|
667
|
-
function isBitOne(bit) {
|
668
|
-
if (!bitmask) {
|
669
|
-
return false;
|
625
|
+
function withRenderTag(clazz, current) {
|
626
|
+
var renderClass = theme.tags[clazz];
|
627
|
+
if (renderClass && current) {
|
628
|
+
return [current, renderClass].join(" ");
|
670
629
|
}
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
}
|
676
|
-
if (isBitOne(1)) {
|
677
|
-
styleProps["fontStyle"] = "italic";
|
630
|
+
if (renderClass) {
|
631
|
+
return renderClass;
|
632
|
+
}
|
633
|
+
return current;
|
678
634
|
}
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
635
|
+
function withRenderClass(clazz, current) {
|
636
|
+
var renderClass = theme.classes[clazz];
|
637
|
+
if (renderClass && current) {
|
638
|
+
return [current, renderClass].join(" ");
|
639
|
+
}
|
640
|
+
if (renderClass) {
|
641
|
+
return renderClass;
|
684
642
|
}
|
643
|
+
return current;
|
685
644
|
}
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
645
|
+
function toReact(node, key) {
|
646
|
+
var _anyNode$class, _anyNode$children;
|
647
|
+
if (typeof node === "string") {
|
648
|
+
return node;
|
649
|
+
}
|
650
|
+
if (node.tag === "p") {
|
651
|
+
return /*#__PURE__*/jsx("p", {
|
652
|
+
className: withRenderTag("p"),
|
653
|
+
children: node.children.map(toReact)
|
654
|
+
}, key);
|
655
|
+
}
|
656
|
+
if (node.tag === "img") {
|
657
|
+
return /*#__PURE__*/jsx("div", {
|
658
|
+
className: withRenderClass("imgContainer"),
|
659
|
+
children: /*#__PURE__*/jsx("img", {
|
660
|
+
className: withRenderTag("img"),
|
661
|
+
src: node.src
|
662
|
+
})
|
663
|
+
}, key);
|
664
|
+
}
|
665
|
+
// if (node.tag === "blockquote") {
|
666
|
+
// return <blockquote key={key}>{node.children.map(toReact)}</blockquote>;
|
667
|
+
// }
|
668
|
+
if (node.tag === "ul") {
|
669
|
+
return /*#__PURE__*/jsx("ul", {
|
670
|
+
className: withRenderTag("ul"),
|
671
|
+
children: node.children.map(toReact)
|
672
|
+
}, key);
|
673
|
+
}
|
674
|
+
if (node.tag === "ol") {
|
675
|
+
return /*#__PURE__*/jsx("ol", {
|
676
|
+
className: withRenderTag("ol"),
|
677
|
+
children: node.children.map(toReact)
|
678
|
+
}, key);
|
679
|
+
}
|
680
|
+
if (node.tag === "li") {
|
681
|
+
return /*#__PURE__*/jsx("li", {
|
682
|
+
className: withRenderTag("li"),
|
683
|
+
children: node.children.map(toReact)
|
684
|
+
}, key);
|
685
|
+
}
|
686
|
+
if (node.tag === "span") {
|
687
|
+
return /*#__PURE__*/jsx("span", {
|
688
|
+
className: node.classes.map(function (nodeClass) {
|
689
|
+
switch (nodeClass) {
|
690
|
+
case "bold":
|
691
|
+
return withRenderClass("bold");
|
692
|
+
case "line-through":
|
693
|
+
return withRenderClass("lineThrough");
|
694
|
+
case "italic":
|
695
|
+
return withRenderClass("italic");
|
696
|
+
}
|
697
|
+
}).join(" "),
|
698
|
+
children: node.children.map(toReact)
|
699
|
+
}, key);
|
691
700
|
}
|
701
|
+
if (node.tag === "h1") {
|
702
|
+
return /*#__PURE__*/jsx("h1", {
|
703
|
+
className: withRenderTag("h1"),
|
704
|
+
children: node.children.map(toReact)
|
705
|
+
}, key);
|
706
|
+
}
|
707
|
+
if (node.tag === "h2") {
|
708
|
+
return /*#__PURE__*/jsx("h2", {
|
709
|
+
className: withRenderTag("h2"),
|
710
|
+
children: node.children.map(toReact)
|
711
|
+
}, key);
|
712
|
+
}
|
713
|
+
if (node.tag === "h3") {
|
714
|
+
return /*#__PURE__*/jsx("h3", {
|
715
|
+
className: withRenderTag("h3"),
|
716
|
+
children: node.children.map(toReact)
|
717
|
+
}, key);
|
718
|
+
}
|
719
|
+
if (node.tag === "h4") {
|
720
|
+
return /*#__PURE__*/jsx("h4", {
|
721
|
+
className: withRenderTag("h4"),
|
722
|
+
children: node.children.map(toReact)
|
723
|
+
}, key);
|
724
|
+
}
|
725
|
+
if (node.tag === "h5") {
|
726
|
+
return /*#__PURE__*/jsx("h5", {
|
727
|
+
className: withRenderTag("h5"),
|
728
|
+
children: node.children.map(toReact)
|
729
|
+
}, key);
|
730
|
+
}
|
731
|
+
if (node.tag === "h6") {
|
732
|
+
return /*#__PURE__*/jsx("h6", {
|
733
|
+
className: withRenderTag("h6"),
|
734
|
+
children: node.children.map(toReact)
|
735
|
+
}, key);
|
736
|
+
}
|
737
|
+
console.error("Unknown tag", node.tag);
|
738
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
739
|
+
var anyNode = node;
|
740
|
+
if (!(anyNode !== null && anyNode !== void 0 && anyNode.tag)) {
|
741
|
+
return null;
|
742
|
+
}
|
743
|
+
return /*#__PURE__*/React.createElement(anyNode.tag, {
|
744
|
+
key: key,
|
745
|
+
className: (_anyNode$class = anyNode["class"]) === null || _anyNode$class === void 0 ? void 0 : _anyNode$class.join(" "),
|
746
|
+
children: (_anyNode$children = anyNode.children) === null || _anyNode$children === void 0 ? void 0 : _anyNode$children.map(toReact)
|
747
|
+
});
|
692
748
|
}
|
693
|
-
return /*#__PURE__*/jsx("
|
694
|
-
|
695
|
-
children:
|
696
|
-
});
|
697
|
-
}
|
698
|
-
function HeadingNodeComponent(_ref3) {
|
699
|
-
var node = _ref3.node,
|
700
|
-
path = _ref3.path;
|
701
|
-
return /*#__PURE__*/createElement(node.tag, {}, node.children.map(function (child, i) {
|
702
|
-
var childPath = "".concat(path, ".").concat(i);
|
703
|
-
return /*#__PURE__*/jsx(TextNodeComponent, {
|
704
|
-
node: child
|
705
|
-
}, childPath);
|
706
|
-
}));
|
707
|
-
}
|
708
|
-
function ParagraphNodeComponent(_ref4) {
|
709
|
-
var node = _ref4.node,
|
710
|
-
path = _ref4.path;
|
711
|
-
return /*#__PURE__*/jsx("p", {
|
712
|
-
children: node.children.map(function (child, i) {
|
713
|
-
var childPath = "".concat(path, ".").concat(i);
|
714
|
-
switch (child.type) {
|
715
|
-
case "text":
|
716
|
-
return /*#__PURE__*/jsx(TextNodeComponent, {
|
717
|
-
node: child
|
718
|
-
}, childPath);
|
719
|
-
default:
|
720
|
-
throw Error("Unknown paragraph node type: " + (child === null || child === void 0 ? void 0 : child.type));
|
721
|
-
}
|
722
|
-
})
|
723
|
-
});
|
724
|
-
}
|
725
|
-
function ListNodeComponent(_ref5) {
|
726
|
-
var node = _ref5.node,
|
727
|
-
path = _ref5.path;
|
728
|
-
return /*#__PURE__*/createElement(node.tag, {}, node.children.map(function (child, i) {
|
729
|
-
var childPath = "".concat(path, ".").concat(i);
|
730
|
-
return /*#__PURE__*/jsx(ListItemComponent, {
|
731
|
-
path: childPath,
|
732
|
-
node: child
|
733
|
-
}, childPath);
|
734
|
-
}));
|
735
|
-
}
|
736
|
-
function ListItemComponent(_ref6) {
|
737
|
-
var node = _ref6.node,
|
738
|
-
path = _ref6.path;
|
739
|
-
return /*#__PURE__*/jsx("li", {
|
740
|
-
children: node.children.map(function (child, i) {
|
741
|
-
var childPath = "".concat(path, ".").concat(i);
|
742
|
-
switch (child.type) {
|
743
|
-
case "text":
|
744
|
-
return /*#__PURE__*/jsx(TextNodeComponent, {
|
745
|
-
node: child
|
746
|
-
}, childPath);
|
747
|
-
default:
|
748
|
-
throw Error("Unknown list item node type: " + (child === null || child === void 0 ? void 0 : child.type));
|
749
|
-
}
|
750
|
-
})
|
749
|
+
return /*#__PURE__*/jsx("div", {
|
750
|
+
"data-val-path": root.valPath,
|
751
|
+
children: root.children.map(toReact)
|
751
752
|
});
|
752
753
|
}
|
753
754
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@valbuild/react",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.19.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.19.0",
|
13
|
+
"@valbuild/ui": "~0.19.0",
|
14
14
|
"@vercel/stega": "^0.1.0",
|
15
15
|
"base64-arraybuffer": "^1.0.2",
|
16
16
|
"style-to-object": "^0.4.1"
|
package/src/ShadowRoot.tsx
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { useState, useLayoutEffect, useRef } from "react";
|
1
|
+
import { useState, useLayoutEffect, useRef, CSSProperties } from "react";
|
2
2
|
import { createPortal } from "react-dom";
|
3
3
|
|
4
4
|
function ShadowContent({
|
@@ -11,7 +11,13 @@ function ShadowContent({
|
|
11
11
|
return createPortal(children, root);
|
12
12
|
}
|
13
13
|
|
14
|
-
export const ShadowRoot = ({
|
14
|
+
export const ShadowRoot = ({
|
15
|
+
children,
|
16
|
+
style,
|
17
|
+
}: {
|
18
|
+
children: React.ReactNode;
|
19
|
+
style?: CSSProperties;
|
20
|
+
}) => {
|
15
21
|
const node = useRef<HTMLDivElement>(null);
|
16
22
|
const [root, setRoot] = useState<ShadowRoot | null>(null);
|
17
23
|
|
@@ -29,7 +35,7 @@ export const ShadowRoot = ({ children }: { children: React.ReactNode }) => {
|
|
29
35
|
}, []);
|
30
36
|
|
31
37
|
return (
|
32
|
-
<div ref={node}>
|
38
|
+
<div ref={node} style={style}>
|
33
39
|
{root && <ShadowContent root={root}>{children}</ShadowContent>}
|
34
40
|
</div>
|
35
41
|
);
|