@webstudio-is/react-sdk 0.49.0 → 0.51.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 +11 -13
- package/lib/app/custom-components/shared/remix-link.js +7 -24
- package/lib/app/handle-request.server.js +1 -4
- package/lib/app/root.js +11 -29
- package/lib/cjs/app/custom-components/image.cjs +10 -12
- package/lib/cjs/app/custom-components/shared/remix-link.cjs +6 -23
- 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__/link-block.props.cjs +5 -5
- package/lib/cjs/components/__generated__/link.props.cjs +6 -6
- package/lib/cjs/components/__generated__/rich-text-link.props.cjs +5 -5
- 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 +7 -2
- package/lib/cjs/components/link.cjs +10 -7
- package/lib/cjs/components/link.ws.cjs +9 -1
- 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 +7 -3
- 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/context.cjs +2 -1
- package/lib/cjs/css/categories.cjs +6 -0
- package/lib/cjs/index.cjs +2 -0
- package/lib/cjs/props.cjs +43 -2
- package/lib/cjs/pubsub/create.cjs +13 -0
- package/lib/cjs/tree/create-elements-tree.cjs +33 -22
- package/lib/cjs/tree/root.cjs +1 -0
- 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__/link-block.props.js +5 -5
- package/lib/components/__generated__/link.props.js +6 -6
- package/lib/components/__generated__/rich-text-link.props.js +5 -5
- 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 +7 -2
- package/lib/components/link.js +10 -7
- package/lib/components/link.ws.js +9 -1
- 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 +8 -4
- 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/context.js +2 -1
- package/lib/css/categories.js +6 -0
- package/lib/index.js +4 -0
- package/lib/props.js +43 -2
- package/lib/pubsub/create.js +9 -0
- package/lib/tree/create-elements-tree.js +33 -22
- package/lib/tree/root.js +1 -0
- 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/image.tsx +4 -7
- package/src/app/custom-components/index.ts +1 -1
- package/src/app/custom-components/shared/remix-link.tsx +12 -48
- package/src/components/__generated__/fragment.props.ts +3 -0
- package/src/components/__generated__/link-block.props.ts +5 -5
- package/src/components/__generated__/link.props.ts +6 -6
- package/src/components/__generated__/rich-text-link.props.ts +5 -5
- 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 +8 -3
- package/src/components/link.tsx +12 -6
- package/src/components/link.ws.tsx +10 -2
- 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 +10 -5
- 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/context.tsx +3 -1
- package/src/index.ts +5 -4
- package/src/props.test.ts +95 -0
- package/src/props.ts +59 -3
- package/src/tree/create-elements-tree.tsx +30 -12
- package/src/tree/root.ts +2 -0
- package/src/tree/webstudio-component.tsx +1 -0
- package/lib/components/component-type.js +0 -20
|
@@ -31,35 +31,41 @@ const createElementsTree = ({
|
|
|
31
31
|
instance,
|
|
32
32
|
propsByInstanceIdStore,
|
|
33
33
|
assetsStore,
|
|
34
|
+
pagesStore,
|
|
34
35
|
Component,
|
|
35
36
|
getComponent
|
|
36
37
|
}) => {
|
|
38
|
+
const rootInstanceSelector = [instance.id];
|
|
37
39
|
const children = createInstanceChildrenElements({
|
|
40
|
+
instanceSelector: rootInstanceSelector,
|
|
38
41
|
Component,
|
|
39
42
|
children: instance.children,
|
|
40
43
|
getComponent
|
|
41
44
|
});
|
|
42
|
-
const
|
|
45
|
+
const root = createInstanceElement({
|
|
43
46
|
Component,
|
|
44
47
|
instance,
|
|
48
|
+
instanceSelector: rootInstanceSelector,
|
|
45
49
|
children: [
|
|
46
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.Fragment, {
|
|
47
|
-
children
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
]
|
|
53
|
-
}, "children")
|
|
50
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.Fragment, { children: [
|
|
51
|
+
children,
|
|
52
|
+
sandbox && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_session_storage_polyfill.SessionStoragePolyfill, {}),
|
|
53
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react2.ScrollRestoration, {}),
|
|
54
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react2.Scripts, {})
|
|
55
|
+
] }, "children")
|
|
54
56
|
],
|
|
55
57
|
getComponent
|
|
56
58
|
});
|
|
57
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
60
|
+
import_context.ReactSdkContext.Provider,
|
|
61
|
+
{
|
|
62
|
+
value: { propsByInstanceIdStore, assetsStore, pagesStore },
|
|
63
|
+
children: root
|
|
64
|
+
}
|
|
65
|
+
);
|
|
61
66
|
};
|
|
62
67
|
const createInstanceChildrenElements = ({
|
|
68
|
+
instanceSelector,
|
|
63
69
|
children,
|
|
64
70
|
Component,
|
|
65
71
|
getComponent
|
|
@@ -70,13 +76,16 @@ const createInstanceChildrenElements = ({
|
|
|
70
76
|
elements.push(child.value);
|
|
71
77
|
continue;
|
|
72
78
|
}
|
|
79
|
+
const childInstanceSelector = [child.id, ...instanceSelector];
|
|
73
80
|
const children2 = createInstanceChildrenElements({
|
|
81
|
+
instanceSelector: childInstanceSelector,
|
|
74
82
|
children: child.children,
|
|
75
83
|
Component,
|
|
76
84
|
getComponent
|
|
77
85
|
});
|
|
78
86
|
const element = createInstanceElement({
|
|
79
87
|
instance: child,
|
|
88
|
+
instanceSelector: childInstanceSelector,
|
|
80
89
|
Component,
|
|
81
90
|
children: children2,
|
|
82
91
|
getComponent
|
|
@@ -88,16 +97,18 @@ const createInstanceChildrenElements = ({
|
|
|
88
97
|
const createInstanceElement = ({
|
|
89
98
|
Component,
|
|
90
99
|
instance,
|
|
100
|
+
instanceSelector,
|
|
91
101
|
children = [],
|
|
92
102
|
getComponent
|
|
93
103
|
}) => {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
104
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
105
|
+
Component,
|
|
106
|
+
{
|
|
107
|
+
instance,
|
|
108
|
+
instanceSelector,
|
|
109
|
+
getComponent,
|
|
110
|
+
children
|
|
111
|
+
},
|
|
112
|
+
instance.id
|
|
113
|
+
);
|
|
103
114
|
};
|
package/lib/cjs/tree/root.cjs
CHANGED
|
@@ -75,6 +75,7 @@ const InstanceRoot = ({
|
|
|
75
75
|
(0, import_props.getPropsByInstanceId)(new Map(data.build.props))
|
|
76
76
|
),
|
|
77
77
|
assetsStore: (0, import_nanostores.atom)(new Map(data.assets.map((asset) => [asset.id, asset]))),
|
|
78
|
+
pagesStore: (0, import_nanostores.atom)(new Map(data.pages.map((page) => [page.id, page]))),
|
|
78
79
|
Component: Component ?? import_webstudio_component.WebstudioComponent,
|
|
79
80
|
getComponent
|
|
80
81
|
});
|
|
@@ -56,7 +56,10 @@ const polyfill = function() {
|
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
58
|
}.toString();
|
|
59
|
-
const SessionStoragePolyfill = () => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
})
|
|
59
|
+
const SessionStoragePolyfill = () => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
60
|
+
"script",
|
|
61
|
+
{
|
|
62
|
+
dangerouslySetInnerHTML: { __html: `(${polyfill})()` },
|
|
63
|
+
suppressHydrationWarning: true
|
|
64
|
+
}
|
|
65
|
+
);
|
|
@@ -30,12 +30,10 @@ var import_react = require("react");
|
|
|
30
30
|
var import_props = require("../props");
|
|
31
31
|
const renderText = (text) => {
|
|
32
32
|
const lines = text.split("\n");
|
|
33
|
-
return lines.map((line, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.Fragment, {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
]
|
|
38
|
-
}, index));
|
|
33
|
+
return lines.map((line, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.Fragment, { children: [
|
|
34
|
+
line,
|
|
35
|
+
index < lines.length - 1 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}) : null
|
|
36
|
+
] }, index));
|
|
39
37
|
};
|
|
40
38
|
const renderWebstudioComponentChildren = (children) => {
|
|
41
39
|
if (children === void 0 || children.length === 0) {
|
|
@@ -62,10 +60,7 @@ const WebstudioComponent = ({
|
|
|
62
60
|
if (Component === void 0) {
|
|
63
61
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {});
|
|
64
62
|
}
|
|
65
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {
|
|
66
|
-
...props,
|
|
67
|
-
children: renderWebstudioComponentChildren(children)
|
|
68
|
-
});
|
|
63
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, { ...props, children: renderWebstudioComponentChildren(children) });
|
|
69
64
|
};
|
|
70
65
|
const idAttribute = "data-ws-id";
|
|
71
66
|
const componentAttribute = "data-ws-component";
|
|
@@ -2,18 +2,18 @@ const props = {
|
|
|
2
2
|
slot: { required: false, control: "text", type: "string" },
|
|
3
3
|
style: { required: false, control: "text", type: "string" },
|
|
4
4
|
title: { required: false, control: "text", type: "string" },
|
|
5
|
-
download: { required: false, control: "text", type: "string" },
|
|
6
5
|
href: { required: false, control: "text", type: "string" },
|
|
7
|
-
hrefLang: { required: false, control: "text", type: "string" },
|
|
8
|
-
media: { required: false, control: "text", type: "string" },
|
|
9
|
-
ping: { required: false, control: "text", type: "string" },
|
|
10
|
-
rel: { required: false, control: "text", type: "string" },
|
|
11
6
|
target: {
|
|
12
7
|
required: false,
|
|
13
8
|
control: "select",
|
|
14
9
|
type: "string",
|
|
15
10
|
options: ["_self", "_blank", "_parent", "_top"]
|
|
16
11
|
},
|
|
12
|
+
download: { required: false, control: "text", type: "string" },
|
|
13
|
+
hrefLang: { required: false, control: "text", type: "string" },
|
|
14
|
+
media: { required: false, control: "text", type: "string" },
|
|
15
|
+
ping: { required: false, control: "text", type: "string" },
|
|
16
|
+
rel: { required: false, control: "text", type: "string" },
|
|
17
17
|
type: { required: false, control: "text", type: "string" },
|
|
18
18
|
referrerPolicy: {
|
|
19
19
|
required: false,
|
|
@@ -2,18 +2,18 @@ const props = {
|
|
|
2
2
|
slot: { required: false, control: "text", type: "string" },
|
|
3
3
|
style: { required: false, control: "text", type: "string" },
|
|
4
4
|
title: { required: false, control: "text", type: "string" },
|
|
5
|
-
|
|
6
|
-
href: { required: false, control: "text", type: "string", defaultValue: "" },
|
|
7
|
-
hrefLang: { required: false, control: "text", type: "string" },
|
|
8
|
-
media: { required: false, control: "text", type: "string" },
|
|
9
|
-
ping: { required: false, control: "text", type: "string" },
|
|
10
|
-
rel: { required: false, control: "text", type: "string" },
|
|
5
|
+
href: { required: false, control: "text", type: "string" },
|
|
11
6
|
target: {
|
|
12
7
|
required: false,
|
|
13
8
|
control: "select",
|
|
14
9
|
type: "string",
|
|
15
10
|
options: ["_self", "_blank", "_parent", "_top"]
|
|
16
11
|
},
|
|
12
|
+
download: { required: false, control: "text", type: "string" },
|
|
13
|
+
hrefLang: { required: false, control: "text", type: "string" },
|
|
14
|
+
media: { required: false, control: "text", type: "string" },
|
|
15
|
+
ping: { required: false, control: "text", type: "string" },
|
|
16
|
+
rel: { required: false, control: "text", type: "string" },
|
|
17
17
|
type: { required: false, control: "text", type: "string" },
|
|
18
18
|
referrerPolicy: {
|
|
19
19
|
required: false,
|
|
@@ -2,18 +2,18 @@ const props = {
|
|
|
2
2
|
slot: { required: false, control: "text", type: "string" },
|
|
3
3
|
style: { required: false, control: "text", type: "string" },
|
|
4
4
|
title: { required: false, control: "text", type: "string" },
|
|
5
|
-
download: { required: false, control: "text", type: "string" },
|
|
6
5
|
href: { required: false, control: "text", type: "string" },
|
|
7
|
-
hrefLang: { required: false, control: "text", type: "string" },
|
|
8
|
-
media: { required: false, control: "text", type: "string" },
|
|
9
|
-
ping: { required: false, control: "text", type: "string" },
|
|
10
|
-
rel: { required: false, control: "text", type: "string" },
|
|
11
6
|
target: {
|
|
12
7
|
required: false,
|
|
13
8
|
control: "select",
|
|
14
9
|
type: "string",
|
|
15
10
|
options: ["_self", "_blank", "_parent", "_top"]
|
|
16
11
|
},
|
|
12
|
+
download: { required: false, control: "text", type: "string" },
|
|
13
|
+
hrefLang: { required: false, control: "text", type: "string" },
|
|
14
|
+
media: { required: false, control: "text", type: "string" },
|
|
15
|
+
ping: { required: false, control: "text", type: "string" },
|
|
16
|
+
rel: { required: false, control: "text", type: "string" },
|
|
17
17
|
type: { required: false, control: "text", type: "string" },
|
|
18
18
|
referrerPolicy: {
|
|
19
19
|
required: false,
|
package/lib/components/body.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from "react";
|
|
3
3
|
const defaultTag = "body";
|
|
4
|
-
const Body = forwardRef((props, ref) => /* @__PURE__ */ jsx("body", {
|
|
5
|
-
...props,
|
|
6
|
-
ref
|
|
7
|
-
}));
|
|
4
|
+
const Body = forwardRef((props, ref) => /* @__PURE__ */ jsx("body", { ...props, ref }));
|
|
8
5
|
Body.displayName = "Body";
|
|
9
6
|
export {
|
|
10
7
|
Body
|
package/lib/components/bold.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from "react";
|
|
3
3
|
const defaultTag = "b";
|
|
4
|
-
const Bold = forwardRef((props, ref) => /* @__PURE__ */ jsx("b", {
|
|
5
|
-
...props,
|
|
6
|
-
ref
|
|
7
|
-
}));
|
|
4
|
+
const Bold = forwardRef((props, ref) => /* @__PURE__ */ jsx("b", { ...props, ref }));
|
|
8
5
|
Bold.displayName = "Bold";
|
|
9
6
|
export {
|
|
10
7
|
Bold
|
package/lib/components/box.ws.js
CHANGED
package/lib/components/button.js
CHANGED
|
@@ -7,12 +7,7 @@ const Button = forwardRef(
|
|
|
7
7
|
innerText = "Edit Inner Text in Properties",
|
|
8
8
|
children,
|
|
9
9
|
...props
|
|
10
|
-
}, ref) => /* @__PURE__ */ jsx("button", {
|
|
11
|
-
type,
|
|
12
|
-
...props,
|
|
13
|
-
ref,
|
|
14
|
-
children: children ? children : innerText
|
|
15
|
-
})
|
|
10
|
+
}, ref) => /* @__PURE__ */ jsx("button", { type, ...props, ref, children: children ? children : innerText })
|
|
16
11
|
);
|
|
17
12
|
Button.displayName = "Button";
|
|
18
13
|
export {
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { PropMeta } from "@webstudio-is/generate-arg-types";
|
|
3
|
+
const WsComponentPropsMeta = z.object({
|
|
4
|
+
props: z.record(PropMeta),
|
|
5
|
+
initialProps: z.array(z.string()).optional()
|
|
6
|
+
});
|
|
7
|
+
const componentCategories = [
|
|
8
|
+
"general",
|
|
9
|
+
"typography",
|
|
10
|
+
"media",
|
|
11
|
+
"forms"
|
|
12
|
+
];
|
|
13
|
+
const WsComponentMeta = z.object({
|
|
14
|
+
category: z.enum(componentCategories).optional(),
|
|
15
|
+
// container - can accept other components with dnd
|
|
16
|
+
// control - usually form controls like inputs, without children
|
|
17
|
+
// embed - images, videos or other embeddable components, without children
|
|
18
|
+
// rich-text - editable text component
|
|
19
|
+
// rich-text-child - formatted text fragment, not listed in components list
|
|
20
|
+
type: z.enum([
|
|
21
|
+
"container",
|
|
22
|
+
"control",
|
|
23
|
+
"embed",
|
|
24
|
+
"rich-text",
|
|
25
|
+
"rich-text-child"
|
|
26
|
+
]),
|
|
27
|
+
label: z.string(),
|
|
28
|
+
Icon: z.function(),
|
|
29
|
+
presetStyle: z.optional(z.any()),
|
|
30
|
+
children: z.optional(z.array(z.string()))
|
|
31
|
+
});
|
|
32
|
+
export {
|
|
33
|
+
componentCategories
|
|
34
|
+
};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Slot } from "./slot";
|
|
2
|
+
import { Fragment } from "./fragment";
|
|
1
3
|
import { Body } from "./body";
|
|
2
4
|
import { Box } from "./box";
|
|
3
5
|
import { TextBlock } from "./text-block";
|
|
@@ -28,6 +30,7 @@ export {
|
|
|
28
30
|
Button,
|
|
29
31
|
Code,
|
|
30
32
|
Form,
|
|
33
|
+
Fragment,
|
|
31
34
|
Heading,
|
|
32
35
|
Image,
|
|
33
36
|
Input,
|
|
@@ -39,6 +42,7 @@ export {
|
|
|
39
42
|
Paragraph,
|
|
40
43
|
RichTextLink,
|
|
41
44
|
Separator,
|
|
45
|
+
Slot,
|
|
42
46
|
Span,
|
|
43
47
|
Subscript,
|
|
44
48
|
Superscript,
|
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
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BoxLinkIcon } from "@webstudio-is/icons";
|
|
2
2
|
import { props } from "./__generated__/link-block.props";
|
|
3
|
+
import { propsMeta as linkPropsMeta } from "./link.ws";
|
|
3
4
|
const presetStyle = {
|
|
4
5
|
boxSizing: {
|
|
5
6
|
type: "keyword",
|
|
@@ -11,14 +12,18 @@ const presetStyle = {
|
|
|
11
12
|
}
|
|
12
13
|
};
|
|
13
14
|
const meta = {
|
|
15
|
+
category: "general",
|
|
14
16
|
type: "container",
|
|
15
17
|
label: "Link Block",
|
|
16
18
|
Icon: BoxLinkIcon,
|
|
17
19
|
presetStyle
|
|
18
20
|
};
|
|
19
21
|
const propsMeta = {
|
|
20
|
-
props
|
|
21
|
-
|
|
22
|
+
props: {
|
|
23
|
+
...props,
|
|
24
|
+
href: linkPropsMeta.props.href
|
|
25
|
+
},
|
|
26
|
+
initialProps: linkPropsMeta.initialProps
|
|
22
27
|
};
|
|
23
28
|
export {
|
|
24
29
|
meta,
|
package/lib/components/link.js
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from "react";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import { usePropUrl, getInstanceIdFromComponentProps } from "../props";
|
|
4
|
+
const Link = forwardRef((props, ref) => {
|
|
5
|
+
const href = usePropUrl(getInstanceIdFromComponentProps(props), "href");
|
|
6
|
+
return /* @__PURE__ */ jsx(
|
|
7
|
+
"a",
|
|
8
|
+
{
|
|
6
9
|
...props,
|
|
7
|
-
href,
|
|
10
|
+
href: typeof href === "string" ? href : href?.path,
|
|
8
11
|
ref
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
);
|
|
12
|
+
}
|
|
13
|
+
);
|
|
14
|
+
});
|
|
12
15
|
Link.displayName = "Link";
|
|
13
16
|
export {
|
|
14
17
|
Link
|
|
@@ -12,6 +12,7 @@ const presetStyle = {
|
|
|
12
12
|
}
|
|
13
13
|
};
|
|
14
14
|
const meta = {
|
|
15
|
+
category: "general",
|
|
15
16
|
type: "rich-text",
|
|
16
17
|
label: "Link Text",
|
|
17
18
|
Icon: Link2Icon,
|
|
@@ -19,7 +20,14 @@ const meta = {
|
|
|
19
20
|
children: ["Link text you can edit"]
|
|
20
21
|
};
|
|
21
22
|
const propsMeta = {
|
|
22
|
-
props
|
|
23
|
+
props: {
|
|
24
|
+
...props,
|
|
25
|
+
href: {
|
|
26
|
+
type: "string",
|
|
27
|
+
control: "url",
|
|
28
|
+
required: false
|
|
29
|
+
}
|
|
30
|
+
},
|
|
23
31
|
initialProps: ["href", "target", "prefetch"]
|
|
24
32
|
};
|
|
25
33
|
export {
|