@webstudio-is/react-sdk 0.67.0 → 0.69.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/cjs/components/__generated__/image.props.js +6 -3
- package/lib/cjs/components/__generated__/text-block.props.js +7 -0
- package/lib/cjs/components/blockquote.ws.js +9 -2
- package/lib/cjs/components/box.ws.js +2 -1
- package/lib/cjs/components/button.ws.js +3 -1
- package/lib/cjs/components/checkbox-field.ws.js +12 -6
- package/lib/cjs/components/checkbox.ws.js +1 -0
- package/lib/cjs/components/code-text.ws.js +8 -1
- package/lib/cjs/components/component-meta.js +6 -3
- package/lib/cjs/components/components-utils.js +0 -28
- package/lib/cjs/components/form.ws.js +32 -25
- package/lib/cjs/components/fragment.ws.js +2 -1
- package/lib/cjs/components/heading.ws.js +10 -3
- package/lib/cjs/components/html-embed.ws.js +3 -1
- package/lib/cjs/components/image.js +27 -19
- package/lib/cjs/components/image.ws.js +4 -2
- package/lib/cjs/components/index.js +1 -29
- package/lib/cjs/components/input.ws.js +1 -0
- package/lib/cjs/components/label.ws.js +8 -1
- package/lib/cjs/components/link-block.ws.js +2 -1
- package/lib/cjs/components/link.ws.js +8 -1
- package/lib/cjs/components/list-item.ws.js +11 -4
- package/lib/cjs/components/list.ws.js +2 -2
- package/lib/cjs/components/paragraph.ws.js +10 -3
- package/lib/cjs/components/radio-button-field.ws.js +12 -6
- package/lib/cjs/components/radio-button.ws.js +1 -0
- package/lib/cjs/components/rich-text-link.ws.js +1 -1
- package/lib/cjs/components/separator.ws.js +1 -1
- package/lib/cjs/components/slot.ws.js +3 -1
- package/lib/cjs/components/text-block.js +5 -2
- package/lib/cjs/components/text-block.ws.js +11 -3
- package/lib/cjs/components/textarea.ws.js +1 -0
- package/lib/cjs/embed-template.js +2 -1
- package/lib/cjs/index.js +4 -5
- package/lib/cjs/tree/create-elements-tree.js +8 -8
- package/lib/cjs/tree/root.js +2 -6
- package/lib/cjs/tree/webstudio-component.js +2 -2
- package/lib/components/__generated__/image.props.js +6 -3
- package/lib/components/__generated__/text-block.props.js +7 -0
- package/lib/components/blockquote.ws.js +9 -2
- package/lib/components/box.ws.js +2 -1
- package/lib/components/button.ws.js +3 -1
- package/lib/components/checkbox-field.ws.js +12 -6
- package/lib/components/checkbox.ws.js +1 -0
- package/lib/components/code-text.ws.js +8 -1
- package/lib/components/component-meta.js +6 -3
- package/lib/components/components-utils.js +0 -14
- package/lib/components/form.ws.js +32 -25
- package/lib/components/fragment.ws.js +2 -1
- package/lib/components/heading.ws.js +10 -3
- package/lib/components/html-embed.ws.js +3 -1
- package/lib/components/image.js +34 -20
- package/lib/components/image.ws.js +4 -2
- package/lib/components/index.js +1 -29
- package/lib/components/input.ws.js +1 -0
- package/lib/components/label.ws.js +8 -1
- package/lib/components/link-block.ws.js +2 -1
- package/lib/components/link.ws.js +8 -1
- package/lib/components/list-item.ws.js +11 -4
- package/lib/components/list.ws.js +2 -2
- package/lib/components/paragraph.ws.js +10 -3
- package/lib/components/radio-button-field.ws.js +12 -6
- package/lib/components/radio-button.ws.js +1 -0
- package/lib/components/rich-text-link.ws.js +1 -1
- package/lib/components/separator.ws.js +1 -1
- package/lib/components/slot.ws.js +3 -1
- package/lib/components/text-block.js +9 -3
- package/lib/components/text-block.ws.js +11 -3
- package/lib/components/textarea.ws.js +1 -0
- package/lib/embed-template.js +2 -1
- package/lib/index.js +4 -9
- package/lib/tree/create-elements-tree.js +8 -8
- package/lib/tree/root.js +2 -6
- package/lib/tree/webstudio-component.js +2 -2
- package/lib/types/components/component-meta.d.ts +363 -1356
- package/lib/types/components/components-utils.d.ts +2 -17
- package/lib/types/components/image.d.ts +5 -1
- package/lib/types/components/image.stories.d.ts +10 -2
- package/lib/types/components/index.d.ts +0 -15
- package/lib/types/components/text-block.d.ts +6 -2
- package/lib/types/components/text-block.stories.d.ts +6 -2
- package/lib/types/css/css.d.ts +14 -4
- package/lib/types/css/global-rules.d.ts +14 -4
- package/lib/types/css/normalize.d.ts +611 -611
- package/lib/types/css/style-rules.d.ts +2 -187
- package/lib/types/embed-template.d.ts +543 -167
- package/lib/types/index.d.ts +2 -2
- package/lib/types/props.d.ts +44 -18
- package/lib/types/tree/create-elements-tree.d.ts +4 -4
- package/lib/types/tree/root.d.ts +3 -5
- package/lib/types/tree/webstudio-component.d.ts +3 -3
- package/package.json +25 -14
- package/src/components/__generated__/image.props.ts +5 -2
- package/src/components/__generated__/text-block.props.ts +7 -0
- package/src/components/blockquote.ws.tsx +9 -2
- package/src/components/box.tsx +1 -1
- package/src/components/box.ws.ts +1 -0
- package/src/components/button.ws.tsx +2 -0
- package/src/components/checkbox-field.ws.tsx +12 -6
- package/src/components/checkbox.ws.tsx +1 -0
- package/src/components/code-text.ws.tsx +8 -1
- package/src/components/component-meta.ts +6 -3
- package/src/components/components-utils.ts +2 -31
- package/src/components/form.ws.tsx +32 -25
- package/src/components/fragment.ws.ts +1 -0
- package/src/components/heading.tsx +1 -1
- package/src/components/heading.ws.tsx +9 -2
- package/src/components/html-embed.ws.ts +2 -0
- package/src/components/image.tsx +54 -26
- package/src/components/image.ws.tsx +5 -1
- package/src/components/index.ts +0 -48
- package/src/components/input.ws.tsx +1 -0
- package/src/components/label.ws.tsx +8 -1
- package/src/components/link-block.ws.tsx +1 -0
- package/src/components/link.ws.tsx +8 -1
- package/src/components/list-item.ws.tsx +10 -3
- package/src/components/list.ws.tsx +2 -2
- package/src/components/paragraph.ws.tsx +9 -2
- package/src/components/radio-button-field.ws.tsx +12 -6
- package/src/components/radio-button.ws.tsx +1 -0
- package/src/components/rich-text-link.ws.tsx +1 -1
- package/src/components/separator.ws.tsx +1 -1
- package/src/components/slot.ws.ts +2 -0
- package/src/components/text-block.tsx +16 -5
- package/src/components/text-block.ws.tsx +10 -2
- package/src/components/textarea.ws.tsx +1 -0
- package/src/embed-template.ts +11 -3
- package/src/index.ts +2 -5
- package/src/props.test.ts +0 -1
- package/src/tree/create-elements-tree.tsx +12 -12
- package/src/tree/root.ts +4 -9
- package/src/tree/webstudio-component.tsx +4 -4
- package/lib/app/custom-components/__generated__/form.props.js +0 -411
- package/lib/app/custom-components/__generated__/image.props.js +0 -442
- package/lib/app/custom-components/__generated__/link-block.props.js +0 -432
- package/lib/app/custom-components/__generated__/link.props.js +0 -432
- package/lib/app/custom-components/__generated__/rich-text-link.props.js +0 -432
- package/lib/app/custom-components/form.js +0 -65
- package/lib/app/custom-components/form.ws.js +0 -81
- package/lib/app/custom-components/image.js +0 -40
- package/lib/app/custom-components/index.js +0 -29
- package/lib/app/custom-components/link-block.js +0 -6
- package/lib/app/custom-components/link.js +0 -6
- package/lib/app/custom-components/rich-text-link.js +0 -6
- package/lib/app/custom-components/shared/remix-link.js +0 -22
- package/lib/cjs/app/custom-components/__generated__/form.props.js +0 -431
- package/lib/cjs/app/custom-components/__generated__/image.props.js +0 -462
- package/lib/cjs/app/custom-components/__generated__/link-block.props.js +0 -452
- package/lib/cjs/app/custom-components/__generated__/link.props.js +0 -452
- package/lib/cjs/app/custom-components/__generated__/rich-text-link.props.js +0 -452
- package/lib/cjs/app/custom-components/form.js +0 -81
- package/lib/cjs/app/custom-components/form.ws.js +0 -101
- package/lib/cjs/app/custom-components/image.js +0 -54
- package/lib/cjs/app/custom-components/index.js +0 -49
- package/lib/cjs/app/custom-components/link-block.js +0 -26
- package/lib/cjs/app/custom-components/link.js +0 -26
- package/lib/cjs/app/custom-components/rich-text-link.js +0 -26
- package/lib/cjs/app/custom-components/shared/remix-link.js +0 -42
- package/lib/types/app/custom-components/__generated__/form.props.d.ts +0 -2
- package/lib/types/app/custom-components/__generated__/image.props.d.ts +0 -2
- package/lib/types/app/custom-components/__generated__/link-block.props.d.ts +0 -2
- package/lib/types/app/custom-components/__generated__/link.props.d.ts +0 -2
- package/lib/types/app/custom-components/__generated__/rich-text-link.props.d.ts +0 -2
- package/lib/types/app/custom-components/form.d.ts +0 -5
- package/lib/types/app/custom-components/form.ws.d.ts +0 -3
- package/lib/types/app/custom-components/image.d.ts +0 -6
- package/lib/types/app/custom-components/index.d.ts +0 -31
- package/lib/types/app/custom-components/link-block.d.ts +0 -6
- package/lib/types/app/custom-components/link.d.ts +0 -6
- package/lib/types/app/custom-components/rich-text-link.d.ts +0 -6
- package/lib/types/app/custom-components/shared/remix-link.d.ts +0 -10
- package/src/app/custom-components/__generated__/form.props.ts +0 -456
- package/src/app/custom-components/__generated__/image.props.ts +0 -487
- package/src/app/custom-components/__generated__/link-block.props.ts +0 -477
- package/src/app/custom-components/__generated__/link.props.ts +0 -477
- package/src/app/custom-components/__generated__/rich-text-link.props.ts +0 -477
- package/src/app/custom-components/form.tsx +0 -111
- package/src/app/custom-components/form.ws.tsx +0 -86
- package/src/app/custom-components/image.tsx +0 -55
- package/src/app/custom-components/index.ts +0 -28
- package/src/app/custom-components/link-block.tsx +0 -4
- package/src/app/custom-components/link.tsx +0 -4
- package/src/app/custom-components/rich-text-link.tsx +0 -4
- package/src/app/custom-components/shared/remix-link.tsx +0 -28
|
@@ -22,8 +22,11 @@ __export(text_block_exports, {
|
|
|
22
22
|
defaultTag: () => defaultTag
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(text_block_exports);
|
|
25
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
26
25
|
var import_react = require("react");
|
|
27
26
|
const defaultTag = "div";
|
|
28
|
-
const TextBlock = (0, import_react.forwardRef)(
|
|
27
|
+
const TextBlock = (0, import_react.forwardRef)(
|
|
28
|
+
({ tag = defaultTag, ...props }, ref) => {
|
|
29
|
+
return (0, import_react.createElement)(tag, { ...props, ref });
|
|
30
|
+
}
|
|
31
|
+
);
|
|
29
32
|
TextBlock.displayName = "TextBlock";
|
|
@@ -36,14 +36,22 @@ const presetStyle = {
|
|
|
36
36
|
]
|
|
37
37
|
};
|
|
38
38
|
const meta = {
|
|
39
|
-
category: "
|
|
39
|
+
category: "text",
|
|
40
40
|
type: "rich-text",
|
|
41
41
|
label: "Text Block",
|
|
42
42
|
icon: import_svg.TextBlockIcon,
|
|
43
43
|
states: import_component_meta.defaultStates,
|
|
44
44
|
presetStyle,
|
|
45
|
-
|
|
45
|
+
template: [
|
|
46
|
+
{
|
|
47
|
+
type: "instance",
|
|
48
|
+
component: "TextBlock",
|
|
49
|
+
children: [{ type: "text", value: "Block of text you can edit" }]
|
|
50
|
+
}
|
|
51
|
+
],
|
|
52
|
+
order: 0
|
|
46
53
|
};
|
|
47
54
|
const propsMeta = {
|
|
48
|
-
props: import_text_block.props
|
|
55
|
+
props: import_text_block.props,
|
|
56
|
+
initialProps: ["tag"]
|
|
49
57
|
};
|
|
@@ -53,11 +53,12 @@ const EmbedTemplateProp = import_zod.z.union([
|
|
|
53
53
|
value: import_zod.z.array(import_zod.z.string())
|
|
54
54
|
})
|
|
55
55
|
]);
|
|
56
|
-
const
|
|
56
|
+
const EmbedTemplateStyleDeclRaw = import_zod.z.object({
|
|
57
57
|
state: import_zod.z.optional(import_zod.z.string()),
|
|
58
58
|
property: import_zod.z.string(),
|
|
59
59
|
value: import_css_data.StyleValue
|
|
60
60
|
});
|
|
61
|
+
const EmbedTemplateStyleDecl = EmbedTemplateStyleDeclRaw;
|
|
61
62
|
const EmbedTemplateInstance = import_zod.z.lazy(
|
|
62
63
|
() => import_zod.z.object({
|
|
63
64
|
type: import_zod.z.literal("instance"),
|
package/lib/cjs/index.js
CHANGED
|
@@ -20,10 +20,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
var src_exports = {};
|
|
21
21
|
__export(src_exports, {
|
|
22
22
|
componentCategories: () => import_component_meta.componentCategories,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
stateCategories: () => import_component_meta.stateCategories
|
|
23
|
+
getInstanceIdFromComponentProps: () => import_props.getInstanceIdFromComponentProps,
|
|
24
|
+
stateCategories: () => import_component_meta.stateCategories,
|
|
25
|
+
usePropUrl: () => import_props.usePropUrl
|
|
27
26
|
});
|
|
28
27
|
module.exports = __toCommonJS(src_exports);
|
|
29
28
|
__reExport(src_exports, require("./css"), module.exports);
|
|
@@ -33,6 +32,6 @@ __reExport(src_exports, require("./pubsub"), module.exports);
|
|
|
33
32
|
__reExport(src_exports, require("./app"), module.exports);
|
|
34
33
|
__reExport(src_exports, require("./components/components"), module.exports);
|
|
35
34
|
__reExport(src_exports, require("./components/components-utils"), module.exports);
|
|
36
|
-
var import_custom_components = require("./app/custom-components");
|
|
37
35
|
var import_component_meta = require("./components/component-meta");
|
|
38
36
|
__reExport(src_exports, require("./embed-template"), module.exports);
|
|
37
|
+
var import_props = require("./props");
|
|
@@ -33,7 +33,7 @@ const createElementsTree = ({
|
|
|
33
33
|
assetsStore,
|
|
34
34
|
pagesStore,
|
|
35
35
|
Component,
|
|
36
|
-
|
|
36
|
+
components
|
|
37
37
|
}) => {
|
|
38
38
|
const rootInstance = instances.get(rootInstanceId);
|
|
39
39
|
if (rootInstance === void 0) {
|
|
@@ -45,7 +45,7 @@ const createElementsTree = ({
|
|
|
45
45
|
instanceSelector: rootInstanceSelector,
|
|
46
46
|
Component,
|
|
47
47
|
children: rootInstance.children,
|
|
48
|
-
|
|
48
|
+
components
|
|
49
49
|
});
|
|
50
50
|
const root = createInstanceElement({
|
|
51
51
|
Component,
|
|
@@ -58,7 +58,7 @@ const createElementsTree = ({
|
|
|
58
58
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react2.Scripts, {})
|
|
59
59
|
] }, "children")
|
|
60
60
|
],
|
|
61
|
-
|
|
61
|
+
components
|
|
62
62
|
});
|
|
63
63
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
64
64
|
import_context.ReactSdkContext.Provider,
|
|
@@ -73,7 +73,7 @@ const createInstanceChildrenElements = ({
|
|
|
73
73
|
instanceSelector,
|
|
74
74
|
children,
|
|
75
75
|
Component,
|
|
76
|
-
|
|
76
|
+
components
|
|
77
77
|
}) => {
|
|
78
78
|
const elements = [];
|
|
79
79
|
for (const child of children) {
|
|
@@ -91,14 +91,14 @@ const createInstanceChildrenElements = ({
|
|
|
91
91
|
instanceSelector: childInstanceSelector,
|
|
92
92
|
children: childInstance.children,
|
|
93
93
|
Component,
|
|
94
|
-
|
|
94
|
+
components
|
|
95
95
|
});
|
|
96
96
|
const element = createInstanceElement({
|
|
97
97
|
instance: childInstance,
|
|
98
98
|
instanceSelector: childInstanceSelector,
|
|
99
99
|
Component,
|
|
100
100
|
children: children2,
|
|
101
|
-
|
|
101
|
+
components
|
|
102
102
|
});
|
|
103
103
|
elements.push(element);
|
|
104
104
|
}
|
|
@@ -109,14 +109,14 @@ const createInstanceElement = ({
|
|
|
109
109
|
instance,
|
|
110
110
|
instanceSelector,
|
|
111
111
|
children = [],
|
|
112
|
-
|
|
112
|
+
components
|
|
113
113
|
}) => {
|
|
114
114
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
115
115
|
Component,
|
|
116
116
|
{
|
|
117
117
|
instance,
|
|
118
118
|
instanceSelector,
|
|
119
|
-
|
|
119
|
+
components,
|
|
120
120
|
children
|
|
121
121
|
},
|
|
122
122
|
instance.id
|
package/lib/cjs/tree/root.js
CHANGED
|
@@ -24,18 +24,14 @@ module.exports = __toCommonJS(root_exports);
|
|
|
24
24
|
var import_nanostores = require("nanostores");
|
|
25
25
|
var import_create_elements_tree = require("./create-elements-tree");
|
|
26
26
|
var import_webstudio_component = require("./webstudio-component");
|
|
27
|
-
var import_components = require("../components");
|
|
28
|
-
var import_custom_components = require("../app/custom-components");
|
|
29
27
|
var import_params = require("../app/params");
|
|
30
28
|
var import_props = require("../props");
|
|
31
29
|
const InstanceRoot = ({
|
|
32
30
|
data,
|
|
33
31
|
Component,
|
|
34
|
-
|
|
35
|
-
getComponent
|
|
32
|
+
components
|
|
36
33
|
}) => {
|
|
37
34
|
(0, import_params.setParams)(data.params);
|
|
38
|
-
(0, import_components.registerComponents)(customComponents);
|
|
39
35
|
return (0, import_create_elements_tree.createElementsTree)({
|
|
40
36
|
instances: new Map(data.build.instances),
|
|
41
37
|
rootInstanceId: data.page.rootInstanceId,
|
|
@@ -45,6 +41,6 @@ const InstanceRoot = ({
|
|
|
45
41
|
assetsStore: (0, import_nanostores.atom)(new Map(data.assets.map((asset) => [asset.id, asset]))),
|
|
46
42
|
pagesStore: (0, import_nanostores.atom)(new Map(data.pages.map((page) => [page.id, page]))),
|
|
47
43
|
Component: Component ?? import_webstudio_component.WebstudioComponent,
|
|
48
|
-
|
|
44
|
+
components
|
|
49
45
|
});
|
|
50
46
|
};
|
|
@@ -47,7 +47,7 @@ const WebstudioComponent = ({
|
|
|
47
47
|
instance,
|
|
48
48
|
instanceSelector,
|
|
49
49
|
children,
|
|
50
|
-
|
|
50
|
+
components,
|
|
51
51
|
...rest
|
|
52
52
|
}) => {
|
|
53
53
|
const instanceProps = (0, import_props.useInstanceProps)(instance.id);
|
|
@@ -57,7 +57,7 @@ const WebstudioComponent = ({
|
|
|
57
57
|
[idAttribute]: instance.id,
|
|
58
58
|
[componentAttribute]: instance.component
|
|
59
59
|
};
|
|
60
|
-
const Component =
|
|
60
|
+
const Component = components.get(instance.component);
|
|
61
61
|
if (Component === void 0) {
|
|
62
62
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {});
|
|
63
63
|
}
|
|
@@ -2,7 +2,7 @@ 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
|
-
alt: { required: false, control: "text", type: "string"
|
|
5
|
+
alt: { required: false, control: "text", type: "string" },
|
|
6
6
|
crossOrigin: {
|
|
7
7
|
required: false,
|
|
8
8
|
control: "radio",
|
|
@@ -39,7 +39,7 @@ const props = {
|
|
|
39
39
|
]
|
|
40
40
|
},
|
|
41
41
|
sizes: { required: false, control: "text", type: "string" },
|
|
42
|
-
src: { required: false, control: "text", type: "string"
|
|
42
|
+
src: { required: false, control: "text", type: "string" },
|
|
43
43
|
srcSet: { required: false, control: "text", type: "string" },
|
|
44
44
|
useMap: { required: false, control: "text", type: "string" },
|
|
45
45
|
width: { required: false, control: "number", type: "number" },
|
|
@@ -432,7 +432,10 @@ const props = {
|
|
|
432
432
|
required: false,
|
|
433
433
|
control: "text",
|
|
434
434
|
type: "string"
|
|
435
|
-
}
|
|
435
|
+
},
|
|
436
|
+
quality: { required: false, control: "number", type: "number" },
|
|
437
|
+
loader: { required: true, control: "text", type: "string" },
|
|
438
|
+
optimize: { required: false, control: "boolean", type: "boolean" }
|
|
436
439
|
};
|
|
437
440
|
export {
|
|
438
441
|
props
|
|
@@ -391,6 +391,13 @@ const props = {
|
|
|
391
391
|
required: false,
|
|
392
392
|
control: "text",
|
|
393
393
|
type: "string"
|
|
394
|
+
},
|
|
395
|
+
tag: {
|
|
396
|
+
required: false,
|
|
397
|
+
control: "radio",
|
|
398
|
+
type: "string",
|
|
399
|
+
defaultValue: "div",
|
|
400
|
+
options: ["div", "figcaption", "span"]
|
|
394
401
|
}
|
|
395
402
|
};
|
|
396
403
|
export {
|
|
@@ -52,13 +52,20 @@ const presetStyle = {
|
|
|
52
52
|
]
|
|
53
53
|
};
|
|
54
54
|
const meta = {
|
|
55
|
-
category: "
|
|
55
|
+
category: "text",
|
|
56
56
|
type: "rich-text",
|
|
57
57
|
label: "Blockquote",
|
|
58
58
|
icon: BlockquoteIcon,
|
|
59
59
|
states: defaultStates,
|
|
60
60
|
presetStyle,
|
|
61
|
-
|
|
61
|
+
template: [
|
|
62
|
+
{
|
|
63
|
+
type: "instance",
|
|
64
|
+
component: "Blockquote",
|
|
65
|
+
children: [{ type: "text", value: "Blockquote you can edit" }]
|
|
66
|
+
}
|
|
67
|
+
],
|
|
68
|
+
order: 3
|
|
62
69
|
};
|
|
63
70
|
const propsMeta = {
|
|
64
71
|
props
|
package/lib/components/box.ws.js
CHANGED
|
@@ -10,6 +10,7 @@ const presetStyle = {
|
|
|
10
10
|
const meta = {
|
|
11
11
|
category: "forms",
|
|
12
12
|
type: "container",
|
|
13
|
+
invalidAncestors: ["Button"],
|
|
13
14
|
label: "Button",
|
|
14
15
|
icon: ButtonElementIcon,
|
|
15
16
|
presetStyle,
|
|
@@ -17,7 +18,8 @@ const meta = {
|
|
|
17
18
|
...defaultStates,
|
|
18
19
|
{ selector: ":disabled", label: "Disabled" },
|
|
19
20
|
{ selector: ":enabled", label: "Enabled" }
|
|
20
|
-
]
|
|
21
|
+
],
|
|
22
|
+
order: 1
|
|
21
23
|
};
|
|
22
24
|
const propsMeta = {
|
|
23
25
|
props,
|
|
@@ -17,14 +17,20 @@ const meta = {
|
|
|
17
17
|
icon: CheckboxCheckedIcon,
|
|
18
18
|
states: defaultStates,
|
|
19
19
|
presetStyle,
|
|
20
|
-
|
|
21
|
-
{ type: "instance", component: "Checkbox", props: [], children: [] },
|
|
20
|
+
template: [
|
|
22
21
|
{
|
|
23
22
|
type: "instance",
|
|
24
|
-
component: "
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
component: "CheckboxField",
|
|
24
|
+
children: [
|
|
25
|
+
{ type: "instance", component: "Checkbox", children: [] },
|
|
26
|
+
{
|
|
27
|
+
type: "instance",
|
|
28
|
+
component: "TextBlock",
|
|
29
|
+
label: "Checkbox Label",
|
|
30
|
+
props: [],
|
|
31
|
+
children: [{ type: "text", value: "Checkbox" }]
|
|
32
|
+
}
|
|
33
|
+
]
|
|
28
34
|
}
|
|
29
35
|
]
|
|
30
36
|
};
|
|
@@ -37,7 +37,14 @@ const meta = {
|
|
|
37
37
|
icon: CodeTextIcon,
|
|
38
38
|
states: defaultStates,
|
|
39
39
|
presetStyle,
|
|
40
|
-
|
|
40
|
+
template: [
|
|
41
|
+
{
|
|
42
|
+
type: "instance",
|
|
43
|
+
component: "CodeText",
|
|
44
|
+
children: [{ type: "text", value: "Code you can edit" }]
|
|
45
|
+
}
|
|
46
|
+
],
|
|
47
|
+
order: 8
|
|
41
48
|
};
|
|
42
49
|
const propsMeta = {
|
|
43
50
|
props,
|
|
@@ -7,7 +7,7 @@ const WsComponentPropsMeta = z.object({
|
|
|
7
7
|
});
|
|
8
8
|
const componentCategories = [
|
|
9
9
|
"general",
|
|
10
|
-
"
|
|
10
|
+
"text",
|
|
11
11
|
"media",
|
|
12
12
|
"forms"
|
|
13
13
|
];
|
|
@@ -38,12 +38,15 @@ const WsComponentMeta = z.object({
|
|
|
38
38
|
"rich-text",
|
|
39
39
|
"rich-text-child"
|
|
40
40
|
]),
|
|
41
|
-
|
|
41
|
+
requiredAncestors: z.optional(z.array(z.string())),
|
|
42
|
+
invalidAncestors: z.optional(z.array(z.string())),
|
|
43
|
+
stylable: z.optional(z.boolean()),
|
|
42
44
|
label: z.string(),
|
|
43
45
|
icon: z.string(),
|
|
44
46
|
presetStyle: z.optional(z.record(z.string(), EmbedTemplateStyleDecl)),
|
|
45
47
|
states: z.optional(z.array(ComponentState)),
|
|
46
|
-
|
|
48
|
+
template: z.optional(WsEmbedTemplate),
|
|
49
|
+
order: z.number().optional()
|
|
47
50
|
});
|
|
48
51
|
export {
|
|
49
52
|
ComponentState,
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import * as components from "./components";
|
|
2
|
-
import { registeredComponents } from "./index";
|
|
3
|
-
const getComponent = (name) => {
|
|
4
|
-
return registeredComponents != null && name in registeredComponents ? registeredComponents[name] : components[name];
|
|
5
|
-
};
|
|
6
|
-
const createGetComponent = (comps) => {
|
|
7
|
-
return (name) => {
|
|
8
|
-
return registeredComponents != null && name in registeredComponents ? registeredComponents[name] : comps[name];
|
|
9
|
-
};
|
|
10
|
-
};
|
|
11
|
-
export {
|
|
12
|
-
createGetComponent,
|
|
13
|
-
getComponent
|
|
14
|
-
};
|
|
@@ -17,33 +17,40 @@ const meta = {
|
|
|
17
17
|
icon: FormIcon,
|
|
18
18
|
states: defaultStates,
|
|
19
19
|
presetStyle,
|
|
20
|
-
|
|
20
|
+
order: 0,
|
|
21
|
+
template: [
|
|
21
22
|
{
|
|
22
23
|
type: "instance",
|
|
23
|
-
component: "
|
|
24
|
-
children: [
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
24
|
+
component: "Form",
|
|
25
|
+
children: [
|
|
26
|
+
{
|
|
27
|
+
type: "instance",
|
|
28
|
+
component: "Label",
|
|
29
|
+
children: [{ type: "text", value: "Name" }]
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
type: "instance",
|
|
33
|
+
component: "Input",
|
|
34
|
+
props: [{ type: "string", name: "name", value: "name" }],
|
|
35
|
+
children: []
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
type: "instance",
|
|
39
|
+
component: "Label",
|
|
40
|
+
children: [{ type: "text", value: "Email" }]
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
type: "instance",
|
|
44
|
+
component: "Input",
|
|
45
|
+
props: [{ type: "string", name: "name", value: "email" }],
|
|
46
|
+
children: []
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
type: "instance",
|
|
50
|
+
component: "Button",
|
|
51
|
+
children: [{ type: "text", value: "Submit" }]
|
|
52
|
+
}
|
|
53
|
+
]
|
|
47
54
|
}
|
|
48
55
|
]
|
|
49
56
|
};
|
|
@@ -13,13 +13,20 @@ const presetStyle = {
|
|
|
13
13
|
h6
|
|
14
14
|
};
|
|
15
15
|
const meta = {
|
|
16
|
-
category: "
|
|
16
|
+
category: "text",
|
|
17
17
|
type: "rich-text",
|
|
18
18
|
label: "Heading",
|
|
19
19
|
icon: HeadingIcon,
|
|
20
|
-
children: [{ type: "text", value: "Heading you can edit" }],
|
|
21
20
|
states: defaultStates,
|
|
22
|
-
presetStyle
|
|
21
|
+
presetStyle,
|
|
22
|
+
template: [
|
|
23
|
+
{
|
|
24
|
+
type: "instance",
|
|
25
|
+
component: "Heading",
|
|
26
|
+
children: [{ type: "text", value: "Heading you can edit" }]
|
|
27
|
+
}
|
|
28
|
+
],
|
|
29
|
+
order: 1
|
|
23
30
|
};
|
|
24
31
|
const propsMeta = {
|
|
25
32
|
props,
|
package/lib/components/image.js
CHANGED
|
@@ -1,25 +1,15 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
forwardRef,
|
|
4
|
+
useMemo
|
|
5
|
+
} from "react";
|
|
6
|
+
import {
|
|
7
|
+
Image as WebstudioImage,
|
|
8
|
+
createImageLoader
|
|
9
|
+
} from "@webstudio-is/image";
|
|
10
|
+
import { usePropAsset, getInstanceIdFromComponentProps } from "../props";
|
|
11
|
+
import { getParams } from "../app/params";
|
|
3
12
|
const defaultTag = "img";
|
|
4
|
-
const Image = forwardRef(
|
|
5
|
-
(imageProps, ref) => {
|
|
6
|
-
return /* @__PURE__ */ jsx(
|
|
7
|
-
"img",
|
|
8
|
-
{
|
|
9
|
-
...imageProps,
|
|
10
|
-
src: imageProps.src || imagePlaceholderSvg,
|
|
11
|
-
ref
|
|
12
|
-
}
|
|
13
|
-
);
|
|
14
|
-
}
|
|
15
|
-
);
|
|
16
|
-
Image.defaultProps = {
|
|
17
|
-
src: "",
|
|
18
|
-
width: "",
|
|
19
|
-
height: "",
|
|
20
|
-
alt: ""
|
|
21
|
-
};
|
|
22
|
-
Image.displayName = "Image";
|
|
23
13
|
const imagePlaceholderSvg = `data:image/svg+xml;base64,${btoa(`<svg
|
|
24
14
|
width="140"
|
|
25
15
|
height="140"
|
|
@@ -43,6 +33,30 @@ const imagePlaceholderSvg = `data:image/svg+xml;base64,${btoa(`<svg
|
|
|
43
33
|
fill="#A2A2A2"
|
|
44
34
|
/>
|
|
45
35
|
</svg>`)}`;
|
|
36
|
+
const Image = forwardRef(
|
|
37
|
+
(props, ref) => {
|
|
38
|
+
const asset = usePropAsset(getInstanceIdFromComponentProps(props), "src");
|
|
39
|
+
const loader = useMemo(() => {
|
|
40
|
+
const params = getParams();
|
|
41
|
+
return createImageLoader({ imageBaseUrl: params.imageBaseUrl });
|
|
42
|
+
}, []);
|
|
43
|
+
const src = asset?.name ?? props.src;
|
|
44
|
+
if (asset == null || loader == null) {
|
|
45
|
+
return /* @__PURE__ */ jsx("img", { ...props, src: src || imagePlaceholderSvg, ref }, src);
|
|
46
|
+
}
|
|
47
|
+
return /* @__PURE__ */ jsx(
|
|
48
|
+
WebstudioImage,
|
|
49
|
+
{
|
|
50
|
+
...props,
|
|
51
|
+
loader,
|
|
52
|
+
src,
|
|
53
|
+
ref
|
|
54
|
+
},
|
|
55
|
+
src
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
);
|
|
59
|
+
Image.displayName = "Image";
|
|
46
60
|
export {
|
|
47
61
|
Image,
|
|
48
62
|
defaultTag
|
|
@@ -26,11 +26,13 @@ const meta = {
|
|
|
26
26
|
label: "Image",
|
|
27
27
|
icon: ImageIcon,
|
|
28
28
|
states: defaultStates,
|
|
29
|
-
presetStyle
|
|
29
|
+
presetStyle,
|
|
30
|
+
order: 0
|
|
30
31
|
};
|
|
32
|
+
const { loader, ...publicProps } = props;
|
|
31
33
|
const propsMeta = {
|
|
32
34
|
props: {
|
|
33
|
-
...
|
|
35
|
+
...publicProps,
|
|
34
36
|
src: {
|
|
35
37
|
type: "string",
|
|
36
38
|
control: "file",
|
package/lib/components/index.js
CHANGED
|
@@ -99,17 +99,6 @@ const defaultMetas = {
|
|
|
99
99
|
CheckboxField: CheckboxFieldMeta,
|
|
100
100
|
Checkbox: CheckboxMeta
|
|
101
101
|
};
|
|
102
|
-
let currentMetas = defaultMetas;
|
|
103
|
-
const getComponentMeta = (name) => {
|
|
104
|
-
return currentMetas[name];
|
|
105
|
-
};
|
|
106
|
-
const registerComponentMetas = (overrides) => {
|
|
107
|
-
const result = {};
|
|
108
|
-
for (const name of Object.keys(defaultMetas)) {
|
|
109
|
-
result[name] = { ...defaultMetas[name], ...overrides[name] };
|
|
110
|
-
}
|
|
111
|
-
currentMetas = result;
|
|
112
|
-
};
|
|
113
102
|
const defaultPropsMetas = {
|
|
114
103
|
Slot: SlotMetaPropsMeta,
|
|
115
104
|
Fragment: FragmentMetaPropsMeta,
|
|
@@ -145,24 +134,7 @@ const defaultPropsMetas = {
|
|
|
145
134
|
CheckboxField: CheckboxFieldPropsMeta,
|
|
146
135
|
Checkbox: CheckboxPropsMeta
|
|
147
136
|
};
|
|
148
|
-
let registeredComponents;
|
|
149
|
-
const registerComponents = (components) => {
|
|
150
|
-
registeredComponents = components;
|
|
151
|
-
};
|
|
152
|
-
const canAcceptComponent = (parentComponent, childComponent) => {
|
|
153
|
-
const parentMeta = getComponentMeta(parentComponent);
|
|
154
|
-
const childMeta = getComponentMeta(childComponent);
|
|
155
|
-
if (parentMeta?.type !== "container" || childMeta === void 0) {
|
|
156
|
-
return false;
|
|
157
|
-
}
|
|
158
|
-
return childMeta.acceptedParents === void 0 || childMeta.acceptedParents.includes(parentComponent);
|
|
159
|
-
};
|
|
160
137
|
export {
|
|
161
|
-
canAcceptComponent,
|
|
162
138
|
defaultMetas,
|
|
163
|
-
defaultPropsMetas
|
|
164
|
-
getComponentMeta,
|
|
165
|
-
registerComponentMetas,
|
|
166
|
-
registerComponents,
|
|
167
|
-
registeredComponents
|
|
139
|
+
defaultPropsMetas
|
|
168
140
|
};
|
|
@@ -17,7 +17,14 @@ const meta = {
|
|
|
17
17
|
icon: TextBlockIcon,
|
|
18
18
|
states: defaultStates,
|
|
19
19
|
presetStyle,
|
|
20
|
-
|
|
20
|
+
order: 2,
|
|
21
|
+
template: [
|
|
22
|
+
{
|
|
23
|
+
type: "instance",
|
|
24
|
+
component: "Label",
|
|
25
|
+
children: [{ type: "text", value: "Form Label" }]
|
|
26
|
+
}
|
|
27
|
+
]
|
|
21
28
|
};
|
|
22
29
|
const propsMeta = {
|
|
23
30
|
props: {
|