@webstudio-is/react-sdk 0.65.0 → 0.67.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/form.ws.js +2 -2
- package/lib/app/custom-components/image.js +7 -13
- package/lib/app/custom-components/index.js +4 -1
- package/lib/app/params.js +1 -0
- package/lib/cjs/app/custom-components/form.ws.js +2 -2
- package/lib/cjs/app/custom-components/image.js +3 -12
- package/lib/cjs/app/custom-components/index.js +4 -1
- package/lib/cjs/app/params.js +1 -0
- package/lib/cjs/components/__generated__/{code.props.js → code-text.props.js} +3 -3
- package/lib/cjs/components/__generated__/html-embed.props.js +31 -0
- package/lib/cjs/components/blockquote.ws.js +2 -2
- package/lib/cjs/components/body.ws.js +2 -2
- package/lib/cjs/components/bold.ws.js +2 -2
- package/lib/cjs/components/box.ws.js +2 -2
- package/lib/cjs/components/button.ws.js +2 -2
- package/lib/cjs/components/checkbox-field.ws.js +2 -2
- package/lib/cjs/components/checkbox.ws.js +2 -2
- package/lib/cjs/components/{code.js → code-text.js} +6 -6
- package/lib/cjs/components/{code.ws.js → code-text.ws.js} +10 -10
- package/lib/cjs/components/component-meta.js +2 -2
- package/lib/cjs/components/components-utils.js +1 -43
- package/lib/cjs/components/components.js +4 -2
- package/lib/cjs/components/error-message.ws.js +2 -2
- package/lib/cjs/components/form.ws.js +2 -2
- package/lib/cjs/components/fragment.ws.js +1 -1
- package/lib/cjs/components/heading.ws.js +2 -2
- package/lib/cjs/components/html-embed.js +80 -0
- package/lib/cjs/components/html-embed.ws.js +43 -0
- package/lib/cjs/components/image.ws.js +2 -2
- package/lib/cjs/components/index.js +11 -57
- package/lib/cjs/components/input.ws.js +2 -2
- package/lib/cjs/components/italic.ws.js +2 -2
- package/lib/cjs/components/label.ws.js +2 -2
- package/lib/cjs/components/link-block.ws.js +2 -2
- package/lib/cjs/components/link.ws.js +2 -2
- package/lib/cjs/components/list-item.ws.js +2 -2
- package/lib/cjs/components/list.ws.js +2 -2
- package/lib/cjs/components/paragraph.ws.js +2 -2
- package/lib/cjs/components/radio-button-field.ws.js +2 -2
- package/lib/cjs/components/radio-button.ws.js +2 -2
- package/lib/cjs/components/separator.ws.js +2 -2
- package/lib/cjs/components/slot.ws.js +2 -2
- package/lib/cjs/components/span.ws.js +2 -2
- package/lib/cjs/components/subscript.ws.js +2 -2
- package/lib/cjs/components/success-message.ws.js +2 -2
- package/lib/cjs/components/superscript.ws.js +2 -2
- package/lib/cjs/components/text-block.ws.js +2 -2
- package/lib/cjs/components/textarea.ws.js +2 -2
- package/lib/cjs/css/css.js +2 -5
- package/lib/cjs/css/normalize.js +1 -1
- package/lib/cjs/css/presets.js +8 -1
- package/lib/cjs/tree/create-elements-tree.js +2 -4
- package/lib/components/__generated__/html-embed.props.js +11 -0
- package/lib/components/blockquote.ws.js +2 -2
- package/lib/components/body.ws.js +2 -2
- package/lib/components/bold.ws.js +2 -2
- package/lib/components/box.ws.js +2 -2
- package/lib/components/button.ws.js +2 -2
- package/lib/components/checkbox-field.ws.js +2 -2
- package/lib/components/checkbox.ws.js +2 -2
- package/lib/components/{code.js → code-text.js} +3 -3
- package/lib/components/{code.ws.js → code-text.ws.js} +5 -5
- package/lib/components/component-meta.js +3 -3
- package/lib/components/components-utils.js +1 -43
- package/lib/components/components.js +4 -2
- package/lib/components/error-message.ws.js +2 -2
- package/lib/components/form.ws.js +2 -2
- package/lib/components/fragment.ws.js +1 -1
- package/lib/components/heading.ws.js +2 -2
- package/lib/components/html-embed.js +65 -0
- package/lib/components/html-embed.ws.js +23 -0
- package/lib/components/image.ws.js +2 -2
- package/lib/components/index.js +11 -57
- package/lib/components/input.ws.js +2 -2
- package/lib/components/italic.ws.js +2 -2
- package/lib/components/label.ws.js +2 -2
- package/lib/components/link-block.ws.js +2 -2
- package/lib/components/link.ws.js +2 -2
- package/lib/components/list-item.ws.js +2 -2
- package/lib/components/list.ws.js +2 -2
- package/lib/components/paragraph.ws.js +2 -2
- package/lib/components/radio-button-field.ws.js +2 -2
- package/lib/components/radio-button.ws.js +2 -2
- package/lib/components/separator.ws.js +2 -2
- package/lib/components/slot.ws.js +2 -2
- package/lib/components/span.ws.js +2 -2
- package/lib/components/subscript.ws.js +2 -2
- package/lib/components/success-message.ws.js +2 -2
- package/lib/components/superscript.ws.js +2 -2
- package/lib/components/text-block.ws.js +2 -2
- package/lib/components/textarea.ws.js +2 -2
- package/lib/css/css.js +2 -5
- package/lib/css/normalize.js +2 -2
- package/lib/css/presets.js +8 -1
- package/lib/tree/create-elements-tree.js +2 -4
- package/lib/types/app/params.d.ts +22 -1
- package/lib/types/components/__generated__/html-embed.props.d.ts +2 -0
- package/lib/types/components/{code.d.ts → code-text.d.ts} +1 -1
- package/lib/types/components/{code.stories.d.ts → code-text.stories.d.ts} +1 -1
- package/lib/types/components/component-meta.d.ts +1785 -10
- package/lib/types/components/components-utils.d.ts +6 -3
- package/lib/types/components/components.d.ts +2 -1
- package/lib/types/components/html-embed.d.ts +7 -0
- package/lib/types/components/html-embed.stories.d.ts +11 -0
- package/lib/types/components/html-embed.ws.d.ts +3 -0
- package/lib/types/components/index.d.ts +2 -2
- package/lib/types/context.d.ts +1 -0
- package/lib/types/css/css.d.ts +2 -0
- package/lib/types/css/presets.d.ts +1 -0
- package/lib/types/css/style-rules.d.ts +1 -1
- package/lib/types/embed-template.d.ts +1 -1
- package/lib/types/tree/create-elements-tree.d.ts +2 -2
- package/package.json +14 -13
- package/src/app/custom-components/form.ws.tsx +2 -2
- package/src/app/custom-components/image.tsx +7 -13
- package/src/app/custom-components/index.ts +4 -1
- package/src/app/params.ts +23 -1
- package/src/components/__generated__/html-embed.props.ts +10 -0
- package/src/components/blockquote.ws.tsx +2 -2
- package/src/components/body.ws.tsx +2 -2
- package/src/components/bold.ws.tsx +2 -2
- package/src/components/box.ws.ts +2 -2
- package/src/components/button.ws.tsx +2 -2
- package/src/components/checkbox-field.ws.tsx +2 -2
- package/src/components/checkbox.ws.tsx +2 -2
- package/src/components/code-text.stories.tsx +16 -0
- package/src/components/{code.tsx → code-text.tsx} +2 -2
- package/src/components/{code.ws.tsx → code-text.ws.tsx} +5 -5
- package/src/components/component-meta.ts +3 -6
- package/src/components/components-utils.ts +14 -58
- package/src/components/components.ts +2 -1
- package/src/components/error-message.ws.tsx +2 -2
- package/src/components/form.ws.tsx +2 -2
- package/src/components/fragment.ws.ts +1 -1
- package/src/components/heading.ws.tsx +2 -2
- package/src/components/html-embed.stories.tsx +16 -0
- package/src/components/html-embed.tsx +96 -0
- package/src/components/html-embed.ws.ts +22 -0
- package/src/components/image.ws.tsx +2 -2
- package/src/components/index.ts +10 -87
- package/src/components/input.ws.tsx +2 -2
- package/src/components/italic.ws.tsx +2 -2
- package/src/components/label.ws.tsx +2 -2
- package/src/components/link-block.ws.tsx +2 -2
- package/src/components/link.ws.tsx +2 -2
- package/src/components/list-item.ws.tsx +2 -2
- package/src/components/list.ws.tsx +2 -2
- package/src/components/paragraph.ws.tsx +2 -2
- package/src/components/radio-button-field.ws.tsx +2 -2
- package/src/components/radio-button.ws.tsx +2 -2
- package/src/components/separator.ws.tsx +2 -2
- package/src/components/slot.ws.ts +2 -2
- package/src/components/span.ws.tsx +2 -2
- package/src/components/subscript.ws.tsx +2 -2
- package/src/components/success-message.ws.tsx +2 -2
- package/src/components/superscript.ws.tsx +2 -2
- package/src/components/text-block.ws.tsx +2 -2
- package/src/components/textarea.ws.tsx +2 -2
- package/src/context.tsx +1 -0
- package/src/css/css.ts +4 -5
- package/src/css/normalize.ts +2 -2
- package/src/css/presets.ts +7 -0
- package/src/tree/create-elements-tree.tsx +3 -5
- package/lib/cjs/tree/session-storage-polyfill.js +0 -65
- package/lib/tree/session-storage-polyfill.js +0 -45
- package/lib/types/tree/session-storage-polyfill.d.ts +0 -2
- package/src/components/code.stories.tsx +0 -16
- package/src/tree/session-storage-polyfill.tsx +0 -50
- /package/lib/components/__generated__/{code.props.js → code-text.props.js} +0 -0
- /package/lib/types/components/__generated__/{code.props.d.ts → code-text.props.d.ts} +0 -0
- /package/lib/types/components/{code.ws.d.ts → code-text.ws.d.ts} +0 -0
- /package/src/components/__generated__/{code.props.ts → code-text.props.ts} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FormIcon } from "@webstudio-is/icons";
|
|
1
|
+
import { FormIcon } from "@webstudio-is/icons/svg";
|
|
2
2
|
import { form } from "../../css/normalize";
|
|
3
3
|
import { props } from "./__generated__/form.props";
|
|
4
4
|
const presetStyle = {
|
|
@@ -11,7 +11,7 @@ const meta = {
|
|
|
11
11
|
category: "forms",
|
|
12
12
|
type: "container",
|
|
13
13
|
label: "Form",
|
|
14
|
-
|
|
14
|
+
icon: FormIcon,
|
|
15
15
|
presetStyle,
|
|
16
16
|
states: [
|
|
17
17
|
{ selector: "[data-state=error]", label: "Error" },
|
|
@@ -3,7 +3,10 @@ import {
|
|
|
3
3
|
forwardRef,
|
|
4
4
|
useMemo
|
|
5
5
|
} from "react";
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
Image as WebstudioImage,
|
|
8
|
+
createImageLoader
|
|
9
|
+
} from "@webstudio-is/image";
|
|
7
10
|
import { Image as SdkImage } from "../../components/image";
|
|
8
11
|
import { usePropAsset, getInstanceIdFromComponentProps } from "../../props";
|
|
9
12
|
import { getParams } from "../params";
|
|
@@ -11,19 +14,10 @@ const defaultTag = "img";
|
|
|
11
14
|
const Image = forwardRef(
|
|
12
15
|
(props, ref) => {
|
|
13
16
|
const asset = usePropAsset(getInstanceIdFromComponentProps(props), "src");
|
|
14
|
-
const params = getParams();
|
|
15
17
|
const loader = useMemo(() => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if (asset.location === "REMOTE") {
|
|
20
|
-
return loaders.cloudflareImageLoader({
|
|
21
|
-
resizeOrigin: params.resizeOrigin,
|
|
22
|
-
cdnUrl: params.assetBaseUrl
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
return loaders.localImageLoader({ publicPath: params.assetBaseUrl });
|
|
26
|
-
}, [asset, params]);
|
|
18
|
+
const params = getParams();
|
|
19
|
+
return createImageLoader({ imageBaseUrl: params.imageBaseUrl });
|
|
20
|
+
}, []);
|
|
27
21
|
const src = asset?.name ?? props.src;
|
|
28
22
|
if (asset == null || loader == null) {
|
|
29
23
|
return /* @__PURE__ */ jsx(SdkImage, { ...props, src, ref }, src);
|
|
@@ -13,7 +13,10 @@ const customComponents = {
|
|
|
13
13
|
Form
|
|
14
14
|
};
|
|
15
15
|
const customComponentPropsMetas = {
|
|
16
|
-
Image: {
|
|
16
|
+
Image: {
|
|
17
|
+
props: imageProps,
|
|
18
|
+
initialProps: ["src", "width", "height", "alt", "loading"]
|
|
19
|
+
},
|
|
17
20
|
Form: formPropsMeta
|
|
18
21
|
};
|
|
19
22
|
const customComponentMetas = {
|
package/lib/app/params.js
CHANGED
|
@@ -22,7 +22,7 @@ __export(form_ws_exports, {
|
|
|
22
22
|
propsMeta: () => propsMeta
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(form_ws_exports);
|
|
25
|
-
var
|
|
25
|
+
var import_svg = require("@webstudio-is/icons/svg");
|
|
26
26
|
var import_normalize = require("../../css/normalize");
|
|
27
27
|
var import_form = require("./__generated__/form.props");
|
|
28
28
|
const presetStyle = {
|
|
@@ -35,7 +35,7 @@ const meta = {
|
|
|
35
35
|
category: "forms",
|
|
36
36
|
type: "container",
|
|
37
37
|
label: "Form",
|
|
38
|
-
|
|
38
|
+
icon: import_svg.FormIcon,
|
|
39
39
|
presetStyle,
|
|
40
40
|
states: [
|
|
41
41
|
{ selector: "[data-state=error]", label: "Error" },
|
|
@@ -31,19 +31,10 @@ const defaultTag = "img";
|
|
|
31
31
|
const Image = (0, import_react.forwardRef)(
|
|
32
32
|
(props, ref) => {
|
|
33
33
|
const asset = (0, import_props.usePropAsset)((0, import_props.getInstanceIdFromComponentProps)(props), "src");
|
|
34
|
-
const params = (0, import_params.getParams)();
|
|
35
34
|
const loader = (0, import_react.useMemo)(() => {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (asset.location === "REMOTE") {
|
|
40
|
-
return import_image.loaders.cloudflareImageLoader({
|
|
41
|
-
resizeOrigin: params.resizeOrigin,
|
|
42
|
-
cdnUrl: params.assetBaseUrl
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
return import_image.loaders.localImageLoader({ publicPath: params.assetBaseUrl });
|
|
46
|
-
}, [asset, params]);
|
|
35
|
+
const params = (0, import_params.getParams)();
|
|
36
|
+
return (0, import_image.createImageLoader)({ imageBaseUrl: params.imageBaseUrl });
|
|
37
|
+
}, []);
|
|
47
38
|
const src = asset?.name ?? props.src;
|
|
48
39
|
if (asset == null || loader == null) {
|
|
49
40
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_image2.Image, { ...props, src, ref }, src);
|
|
@@ -38,7 +38,10 @@ const customComponents = {
|
|
|
38
38
|
Form: import_form.Form
|
|
39
39
|
};
|
|
40
40
|
const customComponentPropsMetas = {
|
|
41
|
-
Image: {
|
|
41
|
+
Image: {
|
|
42
|
+
props: import_image.imageProps,
|
|
43
|
+
initialProps: ["src", "width", "height", "alt", "loading"]
|
|
44
|
+
},
|
|
42
45
|
Form: import_form2.propsMeta
|
|
43
46
|
};
|
|
44
47
|
const customComponentMetas = {
|
package/lib/cjs/app/params.js
CHANGED
|
@@ -16,11 +16,11 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var
|
|
20
|
-
__export(
|
|
19
|
+
var code_text_props_exports = {};
|
|
20
|
+
__export(code_text_props_exports, {
|
|
21
21
|
props: () => props
|
|
22
22
|
});
|
|
23
|
-
module.exports = __toCommonJS(
|
|
23
|
+
module.exports = __toCommonJS(code_text_props_exports);
|
|
24
24
|
const props = {
|
|
25
25
|
meta: { required: false, control: "text", type: "string" },
|
|
26
26
|
slot: { required: false, control: "text", type: "string" },
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var html_embed_props_exports = {};
|
|
20
|
+
__export(html_embed_props_exports, {
|
|
21
|
+
props: () => props
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(html_embed_props_exports);
|
|
24
|
+
const props = {
|
|
25
|
+
code: { required: true, control: "text", type: "string" },
|
|
26
|
+
executeScriptOnCanvas: {
|
|
27
|
+
required: true,
|
|
28
|
+
control: "boolean",
|
|
29
|
+
type: "boolean"
|
|
30
|
+
}
|
|
31
|
+
};
|
|
@@ -22,7 +22,7 @@ __export(blockquote_ws_exports, {
|
|
|
22
22
|
propsMeta: () => propsMeta
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(blockquote_ws_exports);
|
|
25
|
-
var
|
|
25
|
+
var import_svg = require("@webstudio-is/icons/svg");
|
|
26
26
|
var import_component_meta = require("./component-meta");
|
|
27
27
|
var import_blockquote = require("./__generated__/blockquote.props");
|
|
28
28
|
const presetStyle = {
|
|
@@ -77,7 +77,7 @@ const meta = {
|
|
|
77
77
|
category: "typography",
|
|
78
78
|
type: "rich-text",
|
|
79
79
|
label: "Blockquote",
|
|
80
|
-
|
|
80
|
+
icon: import_svg.BlockquoteIcon,
|
|
81
81
|
states: import_component_meta.defaultStates,
|
|
82
82
|
presetStyle,
|
|
83
83
|
children: [{ type: "text", value: "Blockquote you can edit" }]
|
|
@@ -22,7 +22,7 @@ __export(body_ws_exports, {
|
|
|
22
22
|
propsMeta: () => propsMeta
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(body_ws_exports);
|
|
25
|
-
var
|
|
25
|
+
var import_svg = require("@webstudio-is/icons/svg");
|
|
26
26
|
var import_normalize = require("../css/normalize");
|
|
27
27
|
var import_component_meta = require("./component-meta");
|
|
28
28
|
var import_body = require("./__generated__/body.props");
|
|
@@ -56,7 +56,7 @@ const presetStyle = {
|
|
|
56
56
|
const meta = {
|
|
57
57
|
type: "container",
|
|
58
58
|
label: "Body",
|
|
59
|
-
|
|
59
|
+
icon: import_svg.BodyIcon,
|
|
60
60
|
states: import_component_meta.defaultStates,
|
|
61
61
|
presetStyle
|
|
62
62
|
};
|
|
@@ -22,7 +22,7 @@ __export(bold_ws_exports, {
|
|
|
22
22
|
propsMeta: () => propsMeta
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(bold_ws_exports);
|
|
25
|
-
var
|
|
25
|
+
var import_svg = require("@webstudio-is/icons/svg");
|
|
26
26
|
var import_component_meta = require("./component-meta");
|
|
27
27
|
var import_bold = require("./__generated__/bold.props");
|
|
28
28
|
var import_normalize = require("../css/normalize");
|
|
@@ -32,7 +32,7 @@ const presetStyle = {
|
|
|
32
32
|
const meta = {
|
|
33
33
|
type: "rich-text-child",
|
|
34
34
|
label: "Bold Text",
|
|
35
|
-
|
|
35
|
+
icon: import_svg.BoldIcon,
|
|
36
36
|
states: import_component_meta.defaultStates,
|
|
37
37
|
presetStyle
|
|
38
38
|
};
|
|
@@ -22,7 +22,7 @@ __export(box_ws_exports, {
|
|
|
22
22
|
propsMeta: () => propsMeta
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(box_ws_exports);
|
|
25
|
-
var
|
|
25
|
+
var import_svg = require("@webstudio-is/icons/svg");
|
|
26
26
|
var import_component_meta = require("./component-meta");
|
|
27
27
|
var import_box = require("./__generated__/box.props");
|
|
28
28
|
var import_normalize = require("../css/normalize");
|
|
@@ -42,7 +42,7 @@ const meta = {
|
|
|
42
42
|
category: "general",
|
|
43
43
|
type: "container",
|
|
44
44
|
label: "Box",
|
|
45
|
-
|
|
45
|
+
icon: import_svg.BoxIcon,
|
|
46
46
|
states: import_component_meta.defaultStates,
|
|
47
47
|
presetStyle
|
|
48
48
|
};
|
|
@@ -22,7 +22,7 @@ __export(button_ws_exports, {
|
|
|
22
22
|
propsMeta: () => propsMeta
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(button_ws_exports);
|
|
25
|
-
var
|
|
25
|
+
var import_svg = require("@webstudio-is/icons/svg");
|
|
26
26
|
var import_normalize = require("../css/normalize");
|
|
27
27
|
var import_component_meta = require("./component-meta");
|
|
28
28
|
var import_button = require("./__generated__/button.props");
|
|
@@ -33,7 +33,7 @@ const meta = {
|
|
|
33
33
|
category: "forms",
|
|
34
34
|
type: "container",
|
|
35
35
|
label: "Button",
|
|
36
|
-
|
|
36
|
+
icon: import_svg.ButtonElementIcon,
|
|
37
37
|
presetStyle,
|
|
38
38
|
states: [
|
|
39
39
|
...import_component_meta.defaultStates,
|
|
@@ -22,7 +22,7 @@ __export(checkbox_field_ws_exports, {
|
|
|
22
22
|
propsMeta: () => propsMeta
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(checkbox_field_ws_exports);
|
|
25
|
-
var
|
|
25
|
+
var import_svg = require("@webstudio-is/icons/svg");
|
|
26
26
|
var import_component_meta = require("./component-meta");
|
|
27
27
|
var import_checkbox_field = require("./__generated__/checkbox-field.props");
|
|
28
28
|
var import_normalize = require("../css/normalize");
|
|
@@ -36,7 +36,7 @@ const meta = {
|
|
|
36
36
|
category: "forms",
|
|
37
37
|
type: "container",
|
|
38
38
|
label: "Checkbox",
|
|
39
|
-
|
|
39
|
+
icon: import_svg.CheckboxCheckedIcon,
|
|
40
40
|
states: import_component_meta.defaultStates,
|
|
41
41
|
presetStyle,
|
|
42
42
|
children: [
|
|
@@ -22,7 +22,7 @@ __export(checkbox_ws_exports, {
|
|
|
22
22
|
propsMeta: () => propsMeta
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(checkbox_ws_exports);
|
|
25
|
-
var
|
|
25
|
+
var import_svg = require("@webstudio-is/icons/svg");
|
|
26
26
|
var import_component_meta = require("./component-meta");
|
|
27
27
|
var import_normalize = require("../css/normalize");
|
|
28
28
|
var import_checkbox = require("./__generated__/checkbox.props");
|
|
@@ -38,7 +38,7 @@ const presetStyle = {
|
|
|
38
38
|
const meta = {
|
|
39
39
|
type: "control",
|
|
40
40
|
label: "Checkbox Input",
|
|
41
|
-
|
|
41
|
+
icon: import_svg.CheckboxCheckedIcon,
|
|
42
42
|
presetStyle,
|
|
43
43
|
states: [
|
|
44
44
|
...import_component_meta.defaultStates,
|
|
@@ -16,13 +16,13 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var
|
|
20
|
-
__export(
|
|
21
|
-
|
|
19
|
+
var code_text_exports = {};
|
|
20
|
+
__export(code_text_exports, {
|
|
21
|
+
CodeText: () => CodeText,
|
|
22
22
|
defaultTag: () => defaultTag,
|
|
23
23
|
displayVarNamespace: () => displayVarNamespace
|
|
24
24
|
});
|
|
25
|
-
module.exports = __toCommonJS(
|
|
25
|
+
module.exports = __toCommonJS(code_text_exports);
|
|
26
26
|
var import_react = require("react");
|
|
27
27
|
var import_css_vars = require("@webstudio-is/css-vars");
|
|
28
28
|
const defaultTag = "code";
|
|
@@ -30,10 +30,10 @@ const displayVarNamespace = import_css_vars.cssVars.unique("code-display");
|
|
|
30
30
|
const blockStyle = {
|
|
31
31
|
[import_css_vars.cssVars.define(displayVarNamespace, true)]: "block"
|
|
32
32
|
};
|
|
33
|
-
const
|
|
33
|
+
const CodeText = (0, import_react.forwardRef)(
|
|
34
34
|
({ inline = false, ...props }, ref) => {
|
|
35
35
|
const style = inline ? void 0 : blockStyle;
|
|
36
36
|
return (0, import_react.createElement)(defaultTag, { ...props, style, ref });
|
|
37
37
|
}
|
|
38
38
|
);
|
|
39
|
-
|
|
39
|
+
CodeText.displayName = "CodeText";
|
|
@@ -16,16 +16,16 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var
|
|
20
|
-
__export(
|
|
19
|
+
var code_text_ws_exports = {};
|
|
20
|
+
__export(code_text_ws_exports, {
|
|
21
21
|
meta: () => meta,
|
|
22
22
|
propsMeta: () => propsMeta
|
|
23
23
|
});
|
|
24
|
-
module.exports = __toCommonJS(
|
|
25
|
-
var
|
|
24
|
+
module.exports = __toCommonJS(code_text_ws_exports);
|
|
25
|
+
var import_svg = require("@webstudio-is/icons/svg");
|
|
26
26
|
var import_component_meta = require("./component-meta");
|
|
27
|
-
var
|
|
28
|
-
var
|
|
27
|
+
var import_code_text = require("./code-text");
|
|
28
|
+
var import_code_text2 = require("./__generated__/code-text.props");
|
|
29
29
|
var import_normalize = require("../css/normalize");
|
|
30
30
|
const presetStyle = {
|
|
31
31
|
code: [
|
|
@@ -34,7 +34,7 @@ const presetStyle = {
|
|
|
34
34
|
property: "display",
|
|
35
35
|
value: {
|
|
36
36
|
type: "var",
|
|
37
|
-
value:
|
|
37
|
+
value: import_code_text.displayVarNamespace,
|
|
38
38
|
fallbacks: [{ type: "keyword", value: "inline-block" }]
|
|
39
39
|
}
|
|
40
40
|
},
|
|
@@ -55,13 +55,13 @@ const presetStyle = {
|
|
|
55
55
|
const meta = {
|
|
56
56
|
category: "general",
|
|
57
57
|
type: "rich-text",
|
|
58
|
-
label: "Code",
|
|
59
|
-
|
|
58
|
+
label: "Code Text",
|
|
59
|
+
icon: import_svg.CodeTextIcon,
|
|
60
60
|
states: import_component_meta.defaultStates,
|
|
61
61
|
presetStyle,
|
|
62
62
|
children: [{ type: "text", value: "Code you can edit" }]
|
|
63
63
|
};
|
|
64
64
|
const propsMeta = {
|
|
65
|
-
props:
|
|
65
|
+
props: import_code_text2.props,
|
|
66
66
|
initialProps: ["inline", "lang", "meta"]
|
|
67
67
|
};
|
|
@@ -66,8 +66,8 @@ const WsComponentMeta = import_zod.z.object({
|
|
|
66
66
|
]),
|
|
67
67
|
acceptedParents: import_zod.z.optional(import_zod.z.array(import_zod.z.string())),
|
|
68
68
|
label: import_zod.z.string(),
|
|
69
|
-
|
|
70
|
-
presetStyle: import_zod.z.optional(import_zod.z.
|
|
69
|
+
icon: import_zod.z.string(),
|
|
70
|
+
presetStyle: import_zod.z.optional(import_zod.z.record(import_zod.z.string(), import_embed_template.EmbedTemplateStyleDecl)),
|
|
71
71
|
states: import_zod.z.optional(import_zod.z.array(ComponentState)),
|
|
72
72
|
children: import_zod.z.optional(import_embed_template.WsEmbedTemplate)
|
|
73
73
|
});
|
|
@@ -29,53 +29,11 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
29
29
|
var components_utils_exports = {};
|
|
30
30
|
__export(components_utils_exports, {
|
|
31
31
|
createGetComponent: () => createGetComponent,
|
|
32
|
-
getComponent: () => getComponent
|
|
33
|
-
getComponentNames: () => getComponentNames
|
|
32
|
+
getComponent: () => getComponent
|
|
34
33
|
});
|
|
35
34
|
module.exports = __toCommonJS(components_utils_exports);
|
|
36
35
|
var components = __toESM(require("./components"), 1);
|
|
37
36
|
var import_index = require("./index");
|
|
38
|
-
const componentNames = Object.keys({
|
|
39
|
-
Slot: 1,
|
|
40
|
-
Fragment: 1,
|
|
41
|
-
Box: 1,
|
|
42
|
-
Body: 1,
|
|
43
|
-
TextBlock: 1,
|
|
44
|
-
Heading: 1,
|
|
45
|
-
Paragraph: 1,
|
|
46
|
-
Link: 1,
|
|
47
|
-
LinkBlock: 1,
|
|
48
|
-
RichTextLink: 1,
|
|
49
|
-
Span: 1,
|
|
50
|
-
Bold: 1,
|
|
51
|
-
Italic: 1,
|
|
52
|
-
Superscript: 1,
|
|
53
|
-
Subscript: 1,
|
|
54
|
-
Button: 1,
|
|
55
|
-
Input: 1,
|
|
56
|
-
Form: 1,
|
|
57
|
-
Image: 1,
|
|
58
|
-
Blockquote: 1,
|
|
59
|
-
List: 1,
|
|
60
|
-
ListItem: 1,
|
|
61
|
-
Separator: 1,
|
|
62
|
-
Code: 1,
|
|
63
|
-
Label: 1,
|
|
64
|
-
SuccessMessage: 1,
|
|
65
|
-
ErrorMessage: 1,
|
|
66
|
-
Textarea: 1,
|
|
67
|
-
RadioButtonField: 1,
|
|
68
|
-
RadioButton: 1,
|
|
69
|
-
CheckboxField: 1,
|
|
70
|
-
Checkbox: 1
|
|
71
|
-
});
|
|
72
|
-
const getComponentNames = () => {
|
|
73
|
-
const uniqueNames = /* @__PURE__ */ new Set([
|
|
74
|
-
...componentNames,
|
|
75
|
-
...Object.keys(import_index.registeredComponents || {})
|
|
76
|
-
]);
|
|
77
|
-
return Array.from(uniqueNames);
|
|
78
|
-
};
|
|
79
37
|
const getComponent = (name) => {
|
|
80
38
|
return import_index.registeredComponents != null && name in import_index.registeredComponents ? import_index.registeredComponents[name] : components[name];
|
|
81
39
|
};
|
|
@@ -25,11 +25,12 @@ __export(components_exports, {
|
|
|
25
25
|
Button: () => import_button.Button,
|
|
26
26
|
Checkbox: () => import_checkbox.Checkbox,
|
|
27
27
|
CheckboxField: () => import_checkbox_field.CheckboxField,
|
|
28
|
-
|
|
28
|
+
CodeText: () => import_code_text.CodeText,
|
|
29
29
|
ErrorMessage: () => import_error_message.ErrorMessage,
|
|
30
30
|
Form: () => import_form.Form,
|
|
31
31
|
Fragment: () => import_fragment.Fragment,
|
|
32
32
|
Heading: () => import_heading.Heading,
|
|
33
|
+
HtmlEmbed: () => import_html_embed.HtmlEmbed,
|
|
33
34
|
Image: () => import_image.Image,
|
|
34
35
|
Input: () => import_input.Input,
|
|
35
36
|
Italic: () => import_italic.Italic,
|
|
@@ -54,6 +55,7 @@ __export(components_exports, {
|
|
|
54
55
|
module.exports = __toCommonJS(components_exports);
|
|
55
56
|
var import_slot = require("./slot");
|
|
56
57
|
var import_fragment = require("./fragment");
|
|
58
|
+
var import_html_embed = require("./html-embed");
|
|
57
59
|
var import_body = require("./body");
|
|
58
60
|
var import_box = require("./box");
|
|
59
61
|
var import_text_block = require("./text-block");
|
|
@@ -75,7 +77,7 @@ var import_blockquote = require("./blockquote");
|
|
|
75
77
|
var import_list = require("./list");
|
|
76
78
|
var import_list_item = require("./list-item");
|
|
77
79
|
var import_separator = require("./separator");
|
|
78
|
-
var
|
|
80
|
+
var import_code_text = require("./code-text");
|
|
79
81
|
var import_label = require("./label");
|
|
80
82
|
var import_success_message = require("./success-message");
|
|
81
83
|
var import_error_message = require("./error-message");
|
|
@@ -22,7 +22,7 @@ __export(error_message_ws_exports, {
|
|
|
22
22
|
propsMeta: () => propsMeta
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(error_message_ws_exports);
|
|
25
|
-
var
|
|
25
|
+
var import_svg = require("@webstudio-is/icons/svg");
|
|
26
26
|
var import_error_message = require("./__generated__/error-message.props");
|
|
27
27
|
var import_normalize = require("../css/normalize");
|
|
28
28
|
const presetStyle = {
|
|
@@ -31,7 +31,7 @@ const presetStyle = {
|
|
|
31
31
|
const meta = {
|
|
32
32
|
type: "container",
|
|
33
33
|
label: "Error Message",
|
|
34
|
-
|
|
34
|
+
icon: import_svg.BoxIcon,
|
|
35
35
|
presetStyle
|
|
36
36
|
};
|
|
37
37
|
const propsMeta = {
|
|
@@ -22,7 +22,7 @@ __export(form_ws_exports, {
|
|
|
22
22
|
propsMeta: () => propsMeta
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(form_ws_exports);
|
|
25
|
-
var
|
|
25
|
+
var import_svg = require("@webstudio-is/icons/svg");
|
|
26
26
|
var import_normalize = require("../css/normalize");
|
|
27
27
|
var import_component_meta = require("./component-meta");
|
|
28
28
|
var import_form = require("./__generated__/form.props");
|
|
@@ -36,7 +36,7 @@ const meta = {
|
|
|
36
36
|
category: "forms",
|
|
37
37
|
type: "container",
|
|
38
38
|
label: "Form",
|
|
39
|
-
|
|
39
|
+
icon: import_svg.FormIcon,
|
|
40
40
|
states: import_component_meta.defaultStates,
|
|
41
41
|
presetStyle,
|
|
42
42
|
children: [
|
|
@@ -22,7 +22,7 @@ __export(heading_ws_exports, {
|
|
|
22
22
|
propsMeta: () => propsMeta
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(heading_ws_exports);
|
|
25
|
-
var
|
|
25
|
+
var import_svg = require("@webstudio-is/icons/svg");
|
|
26
26
|
var import_normalize = require("../css/normalize");
|
|
27
27
|
var import_component_meta = require("./component-meta");
|
|
28
28
|
var import_heading = require("./__generated__/heading.props");
|
|
@@ -38,7 +38,7 @@ const meta = {
|
|
|
38
38
|
category: "typography",
|
|
39
39
|
type: "rich-text",
|
|
40
40
|
label: "Heading",
|
|
41
|
-
|
|
41
|
+
icon: import_svg.HeadingIcon,
|
|
42
42
|
children: [{ type: "text", value: "Heading you can edit" }],
|
|
43
43
|
states: import_component_meta.defaultStates,
|
|
44
44
|
presetStyle
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var html_embed_exports = {};
|
|
20
|
+
__export(html_embed_exports, {
|
|
21
|
+
HtmlEmbed: () => HtmlEmbed
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(html_embed_exports);
|
|
24
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
25
|
+
var import_react = require("react");
|
|
26
|
+
var import_utils = require("@react-aria/utils");
|
|
27
|
+
var import_context = require("../context");
|
|
28
|
+
const ExecutableHtml = (props) => {
|
|
29
|
+
const { code, innerRef, ...rest } = props;
|
|
30
|
+
const containerRef = (0, import_react.useRef)(null);
|
|
31
|
+
(0, import_react.useEffect)(() => {
|
|
32
|
+
const container = containerRef.current;
|
|
33
|
+
if (container === null || code === void 0) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const range = document.createRange();
|
|
37
|
+
range.setStart(container, 0);
|
|
38
|
+
const fragment = range.createContextualFragment(code);
|
|
39
|
+
while (container.firstChild) {
|
|
40
|
+
container.removeChild(container.firstChild);
|
|
41
|
+
}
|
|
42
|
+
container.append(fragment);
|
|
43
|
+
}, [code]);
|
|
44
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
45
|
+
"div",
|
|
46
|
+
{
|
|
47
|
+
...rest,
|
|
48
|
+
ref: (0, import_utils.mergeRefs)(innerRef, containerRef),
|
|
49
|
+
style: { display: "contents" }
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
};
|
|
53
|
+
const InnerHtml = (props) => {
|
|
54
|
+
const { code, innerRef, ...rest } = props;
|
|
55
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
56
|
+
"div",
|
|
57
|
+
{
|
|
58
|
+
...rest,
|
|
59
|
+
ref: innerRef,
|
|
60
|
+
style: { display: "contents" },
|
|
61
|
+
dangerouslySetInnerHTML: { __html: props.code ?? "" }
|
|
62
|
+
}
|
|
63
|
+
);
|
|
64
|
+
};
|
|
65
|
+
const Placeholder = (props) => {
|
|
66
|
+
const { code, innerRef, ...rest } = props;
|
|
67
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref: innerRef, ...rest, style: { padding: "20px" }, children: 'Open "Properties" panel to insert HTML code' });
|
|
68
|
+
};
|
|
69
|
+
const HtmlEmbed = (0, import_react.forwardRef)((props, ref) => {
|
|
70
|
+
const { renderer } = (0, import_react.useContext)(import_context.ReactSdkContext);
|
|
71
|
+
const { code, executeScriptOnCanvas, ...rest } = props;
|
|
72
|
+
if (code === void 0 || code.trim().length === 0) {
|
|
73
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Placeholder, { innerRef: ref, ...rest });
|
|
74
|
+
}
|
|
75
|
+
if (renderer === "canvas" && executeScriptOnCanvas === true) {
|
|
76
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ExecutableHtml, { innerRef: ref, code, ...rest });
|
|
77
|
+
}
|
|
78
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(InnerHtml, { innerRef: ref, code, ...rest });
|
|
79
|
+
});
|
|
80
|
+
HtmlEmbed.displayName = "HtmlEmbed";
|