@webstudio-is/react-sdk 0.48.0 → 0.50.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/lib/app/custom-components/image.js +9 -9
- package/lib/app/custom-components/shared/remix-link.js +9 -10
- package/lib/app/handle-request.server.js +1 -4
- package/lib/app/root.js +11 -29
- package/lib/cjs/app/custom-components/image.cjs +9 -9
- package/lib/cjs/app/custom-components/shared/remix-link.cjs +9 -10
- package/lib/cjs/app/handle-request.server.cjs +1 -4
- package/lib/cjs/app/root.cjs +11 -29
- package/lib/cjs/components/__generated__/fragment.props.cjs +24 -0
- package/lib/cjs/components/__generated__/slot.props.cjs +24 -0
- package/lib/cjs/components/blockquote.ws.cjs +1 -0
- package/lib/cjs/components/body.cjs +1 -4
- package/lib/cjs/components/body.ws.cjs +1 -1
- package/lib/cjs/components/bold.cjs +1 -4
- package/lib/cjs/components/box.ws.cjs +1 -0
- package/lib/cjs/components/button.cjs +1 -6
- package/lib/cjs/components/button.ws.cjs +1 -0
- package/lib/cjs/components/code.ws.cjs +1 -0
- package/lib/cjs/components/{component-type.cjs → component-meta.cjs} +22 -4
- package/lib/cjs/components/components-utils.cjs +6 -0
- package/lib/cjs/components/components.cjs +4 -0
- package/lib/cjs/components/form.cjs +1 -4
- package/lib/cjs/components/form.ws.cjs +1 -0
- package/lib/cjs/components/fragment.cjs +29 -0
- package/lib/cjs/components/fragment.ws.cjs +32 -0
- package/lib/cjs/components/heading.ws.cjs +1 -0
- package/lib/cjs/components/image.cjs +8 -5
- package/lib/cjs/components/image.ws.cjs +4 -0
- package/lib/cjs/components/index.cjs +8 -0
- package/lib/cjs/components/input.cjs +1 -4
- package/lib/cjs/components/input.ws.cjs +1 -0
- package/lib/cjs/components/italic.cjs +1 -4
- package/lib/cjs/components/link-block.cjs +1 -4
- package/lib/cjs/components/link-block.ws.cjs +1 -0
- package/lib/cjs/components/link.cjs +1 -5
- package/lib/cjs/components/link.ws.cjs +1 -0
- package/lib/cjs/components/list-item.ws.cjs +1 -0
- package/lib/cjs/components/list.ws.cjs +1 -0
- package/lib/cjs/components/paragraph.cjs +1 -4
- package/lib/cjs/components/paragraph.ws.cjs +1 -0
- package/lib/cjs/components/rich-text-link.cjs +1 -4
- package/lib/cjs/components/rich-text-link.ws.cjs +2 -1
- package/lib/cjs/components/separator.ws.cjs +1 -0
- package/lib/cjs/components/slot.cjs +36 -0
- package/lib/cjs/components/slot.ws.cjs +34 -0
- package/lib/cjs/components/span.cjs +1 -4
- package/lib/cjs/components/subscript.cjs +1 -4
- package/lib/cjs/components/superscript.cjs +1 -4
- package/lib/cjs/components/text-block.cjs +1 -4
- package/lib/cjs/components/text-block.ws.cjs +1 -0
- package/lib/cjs/css/categories.cjs +6 -0
- package/lib/cjs/index.cjs +2 -0
- package/lib/cjs/pubsub/create.cjs +13 -0
- package/lib/cjs/tree/create-elements-tree.cjs +26 -22
- package/lib/cjs/tree/session-storage-polyfill.cjs +7 -4
- package/lib/cjs/tree/webstudio-component.cjs +5 -10
- package/lib/components/__generated__/fragment.props.js +4 -0
- package/lib/components/__generated__/slot.props.js +4 -0
- package/lib/components/blockquote.ws.js +1 -0
- package/lib/components/body.js +1 -4
- package/lib/components/body.ws.js +1 -1
- package/lib/components/bold.js +1 -4
- package/lib/components/box.ws.js +1 -0
- package/lib/components/button.js +1 -6
- package/lib/components/button.ws.js +1 -0
- package/lib/components/code.ws.js +1 -0
- package/lib/components/component-meta.js +34 -0
- package/lib/components/components-utils.js +2 -0
- package/lib/components/components.js +4 -0
- package/lib/components/form.js +1 -4
- package/lib/components/form.ws.js +1 -0
- package/lib/components/fragment.js +9 -0
- package/lib/components/fragment.ws.js +12 -0
- package/lib/components/heading.ws.js +1 -0
- package/lib/components/image.js +8 -5
- package/lib/components/image.ws.js +4 -0
- package/lib/components/index.js +8 -0
- package/lib/components/input.js +1 -4
- package/lib/components/input.ws.js +1 -0
- package/lib/components/italic.js +1 -4
- package/lib/components/link-block.js +1 -4
- package/lib/components/link-block.ws.js +1 -0
- package/lib/components/link.js +1 -5
- package/lib/components/link.ws.js +1 -0
- package/lib/components/list-item.ws.js +1 -0
- package/lib/components/list.ws.js +1 -0
- package/lib/components/paragraph.js +1 -4
- package/lib/components/paragraph.ws.js +1 -0
- package/lib/components/rich-text-link.js +1 -4
- package/lib/components/rich-text-link.ws.js +2 -1
- package/lib/components/separator.ws.js +1 -0
- package/lib/components/slot.js +16 -0
- package/lib/components/slot.ws.js +14 -0
- package/lib/components/span.js +1 -4
- package/lib/components/subscript.js +1 -4
- package/lib/components/superscript.js +1 -4
- package/lib/components/text-block.js +1 -4
- package/lib/components/text-block.ws.js +1 -0
- package/lib/css/categories.js +6 -0
- package/lib/index.js +4 -0
- package/lib/pubsub/create.js +9 -0
- package/lib/tree/create-elements-tree.js +26 -22
- package/lib/tree/session-storage-polyfill.js +7 -4
- package/lib/tree/webstudio-component.js +5 -10
- package/package.json +12 -16
- package/src/app/custom-components/index.ts +1 -1
- package/src/components/__generated__/fragment.props.ts +3 -0
- package/src/components/__generated__/slot.props.ts +3 -0
- package/src/components/blockquote.ws.tsx +2 -1
- package/src/components/body.ws.tsx +2 -2
- package/src/components/bold.ws.tsx +1 -1
- package/src/components/box.ws.ts +2 -1
- package/src/components/button.ws.tsx +2 -1
- package/src/components/code.ws.tsx +2 -1
- package/src/components/{component-type.ts → component-meta.ts} +21 -23
- package/src/components/components-utils.ts +4 -0
- package/src/components/components.ts +2 -0
- package/src/components/form.ws.tsx +2 -1
- package/src/components/fragment.tsx +11 -0
- package/src/components/fragment.ws.ts +11 -0
- package/src/components/heading.ws.tsx +2 -1
- package/src/components/image.ws.tsx +2 -1
- package/src/components/index.ts +11 -1
- package/src/components/input.ws.tsx +2 -1
- package/src/components/italic.ws.tsx +1 -1
- package/src/components/link-block.ws.tsx +2 -1
- package/src/components/link.ws.tsx +2 -1
- package/src/components/list-item.ws.tsx +2 -1
- package/src/components/list.ws.tsx +2 -1
- package/src/components/paragraph.ws.tsx +2 -1
- package/src/components/rich-text-link.ws.tsx +4 -2
- package/src/components/separator.ws.tsx +2 -1
- package/src/components/slot.stories.tsx +16 -0
- package/src/components/slot.tsx +17 -0
- package/src/components/slot.ws.ts +13 -0
- package/src/components/span.ws.tsx +1 -1
- package/src/components/subscript.ws.tsx +1 -1
- package/src/components/superscript.ws.tsx +1 -1
- package/src/components/text-block.ws.tsx +2 -1
- package/src/index.ts +5 -4
- package/src/tree/create-elements-tree.tsx +24 -10
- package/src/tree/webstudio-component.tsx +1 -0
- package/lib/components/component-type.js +0 -20
package/lib/components/form.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from "react";
|
|
3
3
|
const defaultTag = "form";
|
|
4
|
-
const Form = forwardRef((props, ref) => /* @__PURE__ */ jsx("form", {
|
|
5
|
-
...props,
|
|
6
|
-
ref
|
|
7
|
-
}));
|
|
4
|
+
const Form = forwardRef((props, ref) => /* @__PURE__ */ jsx("form", { ...props, ref }));
|
|
8
5
|
Form.displayName = "Form";
|
|
9
6
|
export {
|
|
10
7
|
Form
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
const Fragment = forwardRef((props, ref) => {
|
|
4
|
+
return /* @__PURE__ */ jsx("div", { ...props, ref, style: { display: "contents" } });
|
|
5
|
+
});
|
|
6
|
+
Fragment.displayName = "Fragment";
|
|
7
|
+
export {
|
|
8
|
+
Fragment
|
|
9
|
+
};
|
package/lib/components/image.js
CHANGED
|
@@ -3,11 +3,14 @@ import { forwardRef } from "react";
|
|
|
3
3
|
const defaultTag = "img";
|
|
4
4
|
const Image = forwardRef(
|
|
5
5
|
(imageProps, ref) => {
|
|
6
|
-
return /* @__PURE__ */ jsx(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
return /* @__PURE__ */ jsx(
|
|
7
|
+
"img",
|
|
8
|
+
{
|
|
9
|
+
...imageProps,
|
|
10
|
+
src: imageProps.src || imagePlaceholderSvg,
|
|
11
|
+
ref
|
|
12
|
+
}
|
|
13
|
+
);
|
|
11
14
|
}
|
|
12
15
|
);
|
|
13
16
|
Image.defaultProps = {
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import { ImageIcon } from "@webstudio-is/icons";
|
|
2
2
|
import { props } from "./__generated__/image.props";
|
|
3
3
|
const presetStyle = {
|
|
4
|
+
// Otherwise on new image insert onto canvas it can overfit screen size multiple times
|
|
4
5
|
maxWidth: {
|
|
5
6
|
type: "unit",
|
|
6
7
|
unit: "%",
|
|
7
8
|
value: 100
|
|
8
9
|
},
|
|
10
|
+
// inline | inline-block is not suitable because without line-height: 0 on the parent you get unsuitable spaces/margins
|
|
11
|
+
// see https://stackoverflow.com/questions/24771194/is-the-margin-of-inline-block-4px-is-static-for-all-browsers
|
|
9
12
|
display: {
|
|
10
13
|
type: "keyword",
|
|
11
14
|
value: "block"
|
|
12
15
|
}
|
|
13
16
|
};
|
|
14
17
|
const meta = {
|
|
18
|
+
category: "media",
|
|
15
19
|
type: "embed",
|
|
16
20
|
label: "Image",
|
|
17
21
|
Icon: ImageIcon,
|
package/lib/components/index.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { PropMeta } from "@webstudio-is/generate-arg-types";
|
|
2
|
+
import { meta as SlotMeta } from "./slot.ws";
|
|
3
|
+
import { meta as FragmentMeta } from "./fragment.ws";
|
|
2
4
|
import { meta as BodyMeta } from "./body.ws";
|
|
3
5
|
import { meta as BoxMeta } from "./box.ws";
|
|
4
6
|
import { meta as TextBlockMeta } from "./text-block.ws";
|
|
@@ -21,6 +23,8 @@ import { meta as ListMeta } from "./list.ws";
|
|
|
21
23
|
import { meta as ListItemMeta } from "./list-item.ws";
|
|
22
24
|
import { meta as SeparatorMeta } from "./separator.ws";
|
|
23
25
|
import { meta as CodeMeta } from "./code.ws";
|
|
26
|
+
import { propsMeta as SlotMetaPropsMeta } from "./slot.ws";
|
|
27
|
+
import { propsMeta as FragmentMetaPropsMeta } from "./fragment.ws";
|
|
24
28
|
import { propsMeta as BodyMetaPropsMeta } from "./body.ws";
|
|
25
29
|
import { propsMeta as BoxMetaPropsMeta } from "./box.ws";
|
|
26
30
|
import { propsMeta as TextBlockMetaPropsMeta } from "./text-block.ws";
|
|
@@ -44,6 +48,8 @@ import { propsMeta as ListItemPropsMeta } from "./list-item.ws";
|
|
|
44
48
|
import { propsMeta as SeparatorPropsMeta } from "./separator.ws";
|
|
45
49
|
import { propsMeta as CodePropsMeta } from "./code.ws";
|
|
46
50
|
const defaultMetas = {
|
|
51
|
+
Slot: SlotMeta,
|
|
52
|
+
Fragment: FragmentMeta,
|
|
47
53
|
Box: BoxMeta,
|
|
48
54
|
Body: BodyMeta,
|
|
49
55
|
TextBlock: TextBlockMeta,
|
|
@@ -79,6 +85,8 @@ const registerComponentMetas = (overrides) => {
|
|
|
79
85
|
currentMetas = result;
|
|
80
86
|
};
|
|
81
87
|
const defaultPropsMetasRaw = {
|
|
88
|
+
Slot: SlotMetaPropsMeta,
|
|
89
|
+
Fragment: FragmentMetaPropsMeta,
|
|
82
90
|
Box: BoxMetaPropsMeta,
|
|
83
91
|
Body: BodyMetaPropsMeta,
|
|
84
92
|
TextBlock: TextBlockMetaPropsMeta,
|
package/lib/components/input.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from "react";
|
|
3
3
|
const defaultTag = "input";
|
|
4
|
-
const Input = forwardRef(({ children: _children, ...props }, ref) => /* @__PURE__ */ jsx("input", {
|
|
5
|
-
...props,
|
|
6
|
-
ref
|
|
7
|
-
}));
|
|
4
|
+
const Input = forwardRef(({ children: _children, ...props }, ref) => /* @__PURE__ */ jsx("input", { ...props, ref }));
|
|
8
5
|
Input.displayName = "Input";
|
|
9
6
|
export {
|
|
10
7
|
Input
|
package/lib/components/italic.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from "react";
|
|
3
3
|
const defaultTag = "i";
|
|
4
|
-
const Italic = forwardRef((props, ref) => /* @__PURE__ */ jsx("i", {
|
|
5
|
-
...props,
|
|
6
|
-
ref
|
|
7
|
-
}));
|
|
4
|
+
const Italic = forwardRef((props, ref) => /* @__PURE__ */ jsx("i", { ...props, ref }));
|
|
8
5
|
Italic.displayName = "Italic";
|
|
9
6
|
export {
|
|
10
7
|
Italic
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from "react";
|
|
3
3
|
import { Link } from "./link";
|
|
4
|
-
const LinkBlock = forwardRef((props, ref) => /* @__PURE__ */ jsx(Link, {
|
|
5
|
-
...props,
|
|
6
|
-
ref
|
|
7
|
-
}));
|
|
4
|
+
const LinkBlock = forwardRef((props, ref) => /* @__PURE__ */ jsx(Link, { ...props, ref }));
|
|
8
5
|
LinkBlock.displayName = "LinkBlock";
|
|
9
6
|
export {
|
|
10
7
|
LinkBlock
|
package/lib/components/link.js
CHANGED
|
@@ -2,11 +2,7 @@ import { jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { forwardRef } from "react";
|
|
3
3
|
const Link = forwardRef(
|
|
4
4
|
({ href = "", ...props }, ref) => {
|
|
5
|
-
return /* @__PURE__ */ jsx("a", {
|
|
6
|
-
...props,
|
|
7
|
-
href,
|
|
8
|
-
ref
|
|
9
|
-
});
|
|
5
|
+
return /* @__PURE__ */ jsx("a", { ...props, href, ref });
|
|
10
6
|
}
|
|
11
7
|
);
|
|
12
8
|
Link.displayName = "Link";
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from "react";
|
|
3
3
|
const defaultTag = "p";
|
|
4
|
-
const Paragraph = forwardRef((props, ref) => /* @__PURE__ */ jsx("p", {
|
|
5
|
-
...props,
|
|
6
|
-
ref
|
|
7
|
-
}));
|
|
4
|
+
const Paragraph = forwardRef((props, ref) => /* @__PURE__ */ jsx("p", { ...props, ref }));
|
|
8
5
|
Paragraph.displayName = "Paragraph";
|
|
9
6
|
export {
|
|
10
7
|
Paragraph
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from "react";
|
|
3
3
|
import { Link } from "./link";
|
|
4
|
-
const RichTextLink = forwardRef((props, ref) => /* @__PURE__ */ jsx(Link, {
|
|
5
|
-
...props,
|
|
6
|
-
ref
|
|
7
|
-
}));
|
|
4
|
+
const RichTextLink = forwardRef((props, ref) => /* @__PURE__ */ jsx(Link, { ...props, ref }));
|
|
8
5
|
RichTextLink.displayName = "RichTextLink";
|
|
9
6
|
export {
|
|
10
7
|
RichTextLink
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { props } from "./__generated__/rich-text-link.props";
|
|
2
2
|
import { meta as linkMeta, propsMeta as propsLinkMeta } from "./link.ws";
|
|
3
|
+
const { category, ...linkMetaRest } = linkMeta;
|
|
3
4
|
const meta = {
|
|
4
|
-
...
|
|
5
|
+
...linkMetaRest,
|
|
5
6
|
type: "rich-text-child",
|
|
6
7
|
children: []
|
|
7
8
|
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
const Slot = forwardRef((props, ref) => {
|
|
4
|
+
return /* @__PURE__ */ jsx(
|
|
5
|
+
"div",
|
|
6
|
+
{
|
|
7
|
+
...props,
|
|
8
|
+
ref,
|
|
9
|
+
style: { display: props.children ? "contents" : "block" }
|
|
10
|
+
}
|
|
11
|
+
);
|
|
12
|
+
});
|
|
13
|
+
Slot.displayName = "Slot";
|
|
14
|
+
export {
|
|
15
|
+
Slot
|
|
16
|
+
};
|
package/lib/components/span.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from "react";
|
|
3
3
|
const defaultTag = "span";
|
|
4
|
-
const Span = forwardRef((props, ref) => /* @__PURE__ */ jsx("span", {
|
|
5
|
-
...props,
|
|
6
|
-
ref
|
|
7
|
-
}));
|
|
4
|
+
const Span = forwardRef((props, ref) => /* @__PURE__ */ jsx("span", { ...props, ref }));
|
|
8
5
|
Span.displayName = "Span";
|
|
9
6
|
export {
|
|
10
7
|
Span
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from "react";
|
|
3
3
|
const defaultTag = "sub";
|
|
4
|
-
const Subscript = forwardRef((props, ref) => /* @__PURE__ */ jsx("sub", {
|
|
5
|
-
...props,
|
|
6
|
-
ref
|
|
7
|
-
}));
|
|
4
|
+
const Subscript = forwardRef((props, ref) => /* @__PURE__ */ jsx("sub", { ...props, ref }));
|
|
8
5
|
Subscript.displayName = "Subscript";
|
|
9
6
|
export {
|
|
10
7
|
Subscript
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from "react";
|
|
3
3
|
const defaultTag = "sup";
|
|
4
|
-
const Superscript = forwardRef((props, ref) => /* @__PURE__ */ jsx("sup", {
|
|
5
|
-
...props,
|
|
6
|
-
ref
|
|
7
|
-
}));
|
|
4
|
+
const Superscript = forwardRef((props, ref) => /* @__PURE__ */ jsx("sup", { ...props, ref }));
|
|
8
5
|
Superscript.displayName = "Bold";
|
|
9
6
|
export {
|
|
10
7
|
Superscript
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from "react";
|
|
3
3
|
const defaultTag = "div";
|
|
4
|
-
const TextBlock = forwardRef((props, ref) => /* @__PURE__ */ jsx("div", {
|
|
5
|
-
...props,
|
|
6
|
-
ref
|
|
7
|
-
}));
|
|
4
|
+
const TextBlock = forwardRef((props, ref) => /* @__PURE__ */ jsx("div", { ...props, ref }));
|
|
8
5
|
TextBlock.displayName = "TextBlock";
|
|
9
6
|
export {
|
|
10
7
|
TextBlock
|
package/lib/css/categories.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
const layout = [
|
|
2
2
|
"display",
|
|
3
|
+
// Flex
|
|
3
4
|
"flexDirection",
|
|
4
5
|
"flexWrap",
|
|
6
|
+
// Flex or grid
|
|
5
7
|
"alignItems",
|
|
6
8
|
"justifyContent",
|
|
7
9
|
"alignContent",
|
|
10
|
+
// Grid
|
|
8
11
|
"justifyItems",
|
|
9
12
|
"rowGap",
|
|
10
13
|
"columnGap",
|
|
@@ -85,6 +88,7 @@ const typography = [
|
|
|
85
88
|
"direction",
|
|
86
89
|
"whiteSpace",
|
|
87
90
|
"textShadow",
|
|
91
|
+
// More
|
|
88
92
|
"fontSizeAdjust",
|
|
89
93
|
"fontStretch",
|
|
90
94
|
"fontVariant",
|
|
@@ -125,6 +129,7 @@ const borders = [
|
|
|
125
129
|
"borderRightWidth",
|
|
126
130
|
"borderBottomWidth",
|
|
127
131
|
"borderLeftWidth",
|
|
132
|
+
// More
|
|
128
133
|
"borderImageSlice",
|
|
129
134
|
"borderImageWidth",
|
|
130
135
|
"borderImageOutset",
|
|
@@ -143,6 +148,7 @@ const effects = [
|
|
|
143
148
|
"filter",
|
|
144
149
|
"backdropFilter",
|
|
145
150
|
"cursor",
|
|
151
|
+
// More
|
|
146
152
|
"animationDelay",
|
|
147
153
|
"animationDirection",
|
|
148
154
|
"animationDuration",
|
package/lib/index.js
CHANGED
|
@@ -10,7 +10,11 @@ import {
|
|
|
10
10
|
customComponentMetas,
|
|
11
11
|
customComponentPropsMetas
|
|
12
12
|
} from "./app/custom-components";
|
|
13
|
+
import {
|
|
14
|
+
componentCategories
|
|
15
|
+
} from "./components/component-meta";
|
|
13
16
|
export {
|
|
17
|
+
componentCategories,
|
|
14
18
|
customComponentMetas,
|
|
15
19
|
customComponentPropsMetas,
|
|
16
20
|
customComponents
|
package/lib/pubsub/create.js
CHANGED
|
@@ -14,10 +14,16 @@ const createPubsub = () => {
|
|
|
14
14
|
);
|
|
15
15
|
}
|
|
16
16
|
return {
|
|
17
|
+
/**
|
|
18
|
+
* To publish a postMessage event on the current window and parent window from the iframe.
|
|
19
|
+
*/
|
|
17
20
|
publish(action) {
|
|
18
21
|
window.parent.postMessage(action, "*");
|
|
19
22
|
window.postMessage(action, "*");
|
|
20
23
|
},
|
|
24
|
+
/**
|
|
25
|
+
* To publish a postMessage event on the iframe and parent window from the parent window.
|
|
26
|
+
*/
|
|
21
27
|
usePublish() {
|
|
22
28
|
const iframeRef = useRef(null);
|
|
23
29
|
const publishCallback = useCallback(
|
|
@@ -33,6 +39,9 @@ const createPubsub = () => {
|
|
|
33
39
|
);
|
|
34
40
|
return [publishCallback, iframeRef];
|
|
35
41
|
},
|
|
42
|
+
/**
|
|
43
|
+
* To subscribe a message event on the current window.
|
|
44
|
+
*/
|
|
36
45
|
useSubscribe(type, onAction) {
|
|
37
46
|
useEffect(() => {
|
|
38
47
|
emitter.on(type, onAction);
|
|
@@ -11,32 +11,31 @@ const createElementsTree = ({
|
|
|
11
11
|
Component,
|
|
12
12
|
getComponent
|
|
13
13
|
}) => {
|
|
14
|
+
const rootInstanceSelector = [instance.id];
|
|
14
15
|
const children = createInstanceChildrenElements({
|
|
16
|
+
instanceSelector: rootInstanceSelector,
|
|
15
17
|
Component,
|
|
16
18
|
children: instance.children,
|
|
17
19
|
getComponent
|
|
18
20
|
});
|
|
19
|
-
const
|
|
21
|
+
const root = createInstanceElement({
|
|
20
22
|
Component,
|
|
21
23
|
instance,
|
|
24
|
+
instanceSelector: rootInstanceSelector,
|
|
22
25
|
children: [
|
|
23
|
-
/* @__PURE__ */ jsxs(Fragment, {
|
|
24
|
-
children
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
]
|
|
30
|
-
}, "children")
|
|
26
|
+
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
27
|
+
children,
|
|
28
|
+
sandbox && /* @__PURE__ */ jsx(SessionStoragePolyfill, {}),
|
|
29
|
+
/* @__PURE__ */ jsx(ScrollRestoration, {}),
|
|
30
|
+
/* @__PURE__ */ jsx(Scripts, {})
|
|
31
|
+
] }, "children")
|
|
31
32
|
],
|
|
32
33
|
getComponent
|
|
33
34
|
});
|
|
34
|
-
return /* @__PURE__ */ jsx(ReactSdkContext.Provider, {
|
|
35
|
-
value: { propsByInstanceIdStore, assetsStore },
|
|
36
|
-
children: body
|
|
37
|
-
});
|
|
35
|
+
return /* @__PURE__ */ jsx(ReactSdkContext.Provider, { value: { propsByInstanceIdStore, assetsStore }, children: root });
|
|
38
36
|
};
|
|
39
37
|
const createInstanceChildrenElements = ({
|
|
38
|
+
instanceSelector,
|
|
40
39
|
children,
|
|
41
40
|
Component,
|
|
42
41
|
getComponent
|
|
@@ -47,13 +46,16 @@ const createInstanceChildrenElements = ({
|
|
|
47
46
|
elements.push(child.value);
|
|
48
47
|
continue;
|
|
49
48
|
}
|
|
49
|
+
const childInstanceSelector = [child.id, ...instanceSelector];
|
|
50
50
|
const children2 = createInstanceChildrenElements({
|
|
51
|
+
instanceSelector: childInstanceSelector,
|
|
51
52
|
children: child.children,
|
|
52
53
|
Component,
|
|
53
54
|
getComponent
|
|
54
55
|
});
|
|
55
56
|
const element = createInstanceElement({
|
|
56
57
|
instance: child,
|
|
58
|
+
instanceSelector: childInstanceSelector,
|
|
57
59
|
Component,
|
|
58
60
|
children: children2,
|
|
59
61
|
getComponent
|
|
@@ -65,18 +67,20 @@ const createInstanceChildrenElements = ({
|
|
|
65
67
|
const createInstanceElement = ({
|
|
66
68
|
Component,
|
|
67
69
|
instance,
|
|
70
|
+
instanceSelector,
|
|
68
71
|
children = [],
|
|
69
72
|
getComponent
|
|
70
73
|
}) => {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
74
|
+
return /* @__PURE__ */ jsx(
|
|
75
|
+
Component,
|
|
76
|
+
{
|
|
77
|
+
instance,
|
|
78
|
+
instanceSelector,
|
|
79
|
+
getComponent,
|
|
80
|
+
children
|
|
81
|
+
},
|
|
82
|
+
instance.id
|
|
83
|
+
);
|
|
80
84
|
};
|
|
81
85
|
export {
|
|
82
86
|
createElementsTree
|
|
@@ -33,10 +33,13 @@ const polyfill = function() {
|
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
35
|
}.toString();
|
|
36
|
-
const SessionStoragePolyfill = () => /* @__PURE__ */ jsx(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
})
|
|
36
|
+
const SessionStoragePolyfill = () => /* @__PURE__ */ jsx(
|
|
37
|
+
"script",
|
|
38
|
+
{
|
|
39
|
+
dangerouslySetInnerHTML: { __html: `(${polyfill})()` },
|
|
40
|
+
suppressHydrationWarning: true
|
|
41
|
+
}
|
|
42
|
+
);
|
|
40
43
|
export {
|
|
41
44
|
SessionStoragePolyfill
|
|
42
45
|
};
|
|
@@ -3,12 +3,10 @@ import { Fragment as Fragment2 } from "react";
|
|
|
3
3
|
import { useInstanceProps } from "../props";
|
|
4
4
|
const renderText = (text) => {
|
|
5
5
|
const lines = text.split("\n");
|
|
6
|
-
return lines.map((line, index) => /* @__PURE__ */ jsxs(Fragment2, {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
]
|
|
11
|
-
}, index));
|
|
6
|
+
return lines.map((line, index) => /* @__PURE__ */ jsxs(Fragment2, { children: [
|
|
7
|
+
line,
|
|
8
|
+
index < lines.length - 1 ? /* @__PURE__ */ jsx("br", {}) : null
|
|
9
|
+
] }, index));
|
|
12
10
|
};
|
|
13
11
|
const renderWebstudioComponentChildren = (children) => {
|
|
14
12
|
if (children === void 0 || children.length === 0) {
|
|
@@ -35,10 +33,7 @@ const WebstudioComponent = ({
|
|
|
35
33
|
if (Component === void 0) {
|
|
36
34
|
return /* @__PURE__ */ jsx(Fragment, {});
|
|
37
35
|
}
|
|
38
|
-
return /* @__PURE__ */ jsx(Component, {
|
|
39
|
-
...props,
|
|
40
|
-
children: renderWebstudioComponentChildren(children)
|
|
41
|
-
});
|
|
36
|
+
return /* @__PURE__ */ jsx(Component, { ...props, children: renderWebstudioComponentChildren(children) });
|
|
42
37
|
};
|
|
43
38
|
const idAttribute = "data-ws-id";
|
|
44
39
|
const componentAttribute = "data-ws-component";
|
package/package.json
CHANGED
|
@@ -1,28 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webstudio-is/react-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.50.0",
|
|
4
4
|
"description": "Webstudio JavaScript / TypeScript API",
|
|
5
5
|
"author": "Webstudio <github@webstudio.is>",
|
|
6
6
|
"homepage": "https://webstudio.is",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"devDependencies": {
|
|
9
9
|
"@babel/core": "^7.21.0",
|
|
10
|
-
"@esbuild-kit/esm-loader": "^2.4.2",
|
|
11
10
|
"@jest/globals": "^29.3.1",
|
|
12
|
-
"@remix-run/node": "1.
|
|
13
|
-
"@remix-run/react": "1.
|
|
14
|
-
"@remix-run/server-runtime": "1.
|
|
11
|
+
"@remix-run/node": "1.14.3",
|
|
12
|
+
"@remix-run/react": "1.14.3",
|
|
13
|
+
"@remix-run/server-runtime": "1.14.3",
|
|
15
14
|
"@storybook/react": "^6.5.16",
|
|
16
15
|
"@types/node": "^18.11.18",
|
|
17
16
|
"@types/react": "^17.0.24",
|
|
18
17
|
"@types/react-dom": "^17.0.9",
|
|
19
|
-
"esbuild": "^0.14.25",
|
|
20
|
-
"esbuild-node-externals": "^1.4.1",
|
|
21
18
|
"jest": "^29.3.1",
|
|
22
19
|
"react": "^17.0.2",
|
|
23
20
|
"react-dom": "^17.0.2",
|
|
24
21
|
"remix-utils": "^4.1.0",
|
|
25
|
-
"tsx": "^3.9.0",
|
|
26
22
|
"typescript": "4.9.5",
|
|
27
23
|
"zod": "^3.19.1",
|
|
28
24
|
"@webstudio-is/jest-config": "^1.0.2",
|
|
@@ -44,14 +40,14 @@
|
|
|
44
40
|
"mitt": "^3.0.0",
|
|
45
41
|
"nanostores": "^0.7.1",
|
|
46
42
|
"warn-once": "^0.1.1",
|
|
47
|
-
"@webstudio-is/asset-uploader": "^0.
|
|
48
|
-
"@webstudio-is/css-data": "^0.
|
|
49
|
-
"@webstudio-is/
|
|
50
|
-
"@webstudio-is/
|
|
51
|
-
"@webstudio-is/icons": "^0.
|
|
52
|
-
"@webstudio-is/image": "^0.
|
|
53
|
-
"@webstudio-is/prisma-client": "^0.
|
|
54
|
-
"@webstudio-is/project-build": "^0.
|
|
43
|
+
"@webstudio-is/asset-uploader": "^0.50.0",
|
|
44
|
+
"@webstudio-is/css-data": "^0.50.0",
|
|
45
|
+
"@webstudio-is/generate-arg-types": "^0.50.0",
|
|
46
|
+
"@webstudio-is/css-vars": "^0.50.0",
|
|
47
|
+
"@webstudio-is/icons": "^0.50.0",
|
|
48
|
+
"@webstudio-is/image": "^0.50.0",
|
|
49
|
+
"@webstudio-is/prisma-client": "^0.50.0",
|
|
50
|
+
"@webstudio-is/project-build": "^0.50.0"
|
|
55
51
|
},
|
|
56
52
|
"exports": {
|
|
57
53
|
".": {
|