@webstudio-is/react-sdk 0.34.0 → 0.36.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 +1 -1
- package/lib/app/custom-components/index.js +1 -6
- package/lib/cjs/app/custom-components/image.cjs +2 -2
- package/lib/cjs/app/custom-components/index.cjs +1 -6
- package/lib/cjs/components/__generated__/blockquote.props.cjs +414 -0
- package/lib/cjs/components/__generated__/body.props.cjs +413 -0
- package/lib/cjs/components/__generated__/bold.props.cjs +413 -0
- package/lib/cjs/components/__generated__/box.props.cjs +431 -0
- package/lib/cjs/components/__generated__/button.props.cjs +430 -0
- package/lib/cjs/components/__generated__/code.props.cjs +420 -0
- package/lib/cjs/components/__generated__/form.props.cjs +421 -0
- package/lib/cjs/components/__generated__/heading.props.cjs +420 -0
- package/lib/cjs/components/__generated__/image.props.cjs +454 -0
- package/lib/cjs/components/__generated__/input.props.cjs +451 -0
- package/lib/cjs/components/__generated__/italic.props.cjs +413 -0
- package/lib/cjs/components/__generated__/link.props.cjs +437 -0
- package/lib/cjs/components/__generated__/list-item.props.cjs +414 -0
- package/lib/cjs/components/__generated__/list.props.cjs +427 -0
- package/lib/cjs/components/__generated__/paragraph.props.cjs +413 -0
- package/lib/cjs/components/__generated__/rich-text-link.props.cjs +437 -0
- package/lib/cjs/components/__generated__/separator.props.cjs +413 -0
- package/lib/cjs/components/__generated__/span.props.cjs +413 -0
- package/lib/cjs/components/__generated__/subscript.props.cjs +413 -0
- package/lib/cjs/components/__generated__/superscript.props.cjs +413 -0
- package/lib/cjs/components/__generated__/text-block.props.cjs +413 -0
- package/lib/cjs/components/blockquote.cjs +31 -0
- package/lib/cjs/components/blockquote.ws.cjs +75 -0
- package/lib/cjs/components/body.ws.cjs +2 -8
- package/lib/cjs/components/bold.ws.cjs +2 -8
- package/lib/cjs/components/box.ws.cjs +2 -8
- package/lib/cjs/components/button.ws.cjs +2 -8
- package/lib/cjs/components/code.cjs +38 -0
- package/lib/cjs/components/code.ws.cjs +66 -0
- package/lib/cjs/components/components-utils.cjs +71 -0
- package/lib/cjs/components/components.cjs +64 -0
- package/lib/cjs/components/form.ws.cjs +2 -8
- package/lib/cjs/components/heading.ws.cjs +2 -8
- package/lib/cjs/components/image.ws.cjs +8 -9
- package/lib/cjs/components/index.cjs +28 -53
- package/lib/cjs/components/input.ws.cjs +2 -8
- package/lib/cjs/components/italic.ws.cjs +2 -8
- package/lib/cjs/components/link.ws.cjs +2 -8
- package/lib/cjs/{css/breakpoints.cjs → components/list-item.cjs} +12 -10
- package/lib/cjs/components/list-item.ws.cjs +35 -0
- package/lib/cjs/components/list.cjs +31 -0
- package/lib/cjs/components/list.ws.cjs +51 -0
- package/lib/cjs/components/paragraph.ws.cjs +2 -8
- package/lib/cjs/components/rich-text-link.ws.cjs +2 -8
- package/lib/cjs/components/separator.cjs +31 -0
- package/lib/cjs/components/separator.ws.cjs +51 -0
- package/lib/cjs/components/span.ws.cjs +2 -8
- package/lib/cjs/components/subscript.ws.cjs +2 -8
- package/lib/cjs/components/superscript.ws.cjs +2 -8
- package/lib/cjs/components/text-block.ws.cjs +2 -8
- package/lib/cjs/css/get-browser-style.cjs +13 -5
- package/lib/cjs/css/index.cjs +0 -1
- package/lib/cjs/index.cjs +2 -0
- package/lib/cjs/tree/create-elements-tree.cjs +10 -9
- package/lib/cjs/tree/index.cjs +1 -1
- package/lib/cjs/tree/root.cjs +28 -4
- package/lib/cjs/tree/{wrapper-component.cjs → webstudio-component.cjs} +12 -11
- package/lib/components/__generated__/blockquote.props.js +394 -0
- package/lib/components/__generated__/body.props.js +393 -0
- package/lib/components/__generated__/bold.props.js +393 -0
- package/lib/components/__generated__/box.props.js +411 -0
- package/lib/components/__generated__/button.props.js +410 -0
- package/lib/components/__generated__/code.props.js +400 -0
- package/lib/components/__generated__/form.props.js +401 -0
- package/lib/components/__generated__/heading.props.js +400 -0
- package/lib/components/__generated__/image.props.js +434 -0
- package/lib/components/__generated__/input.props.js +431 -0
- package/lib/components/__generated__/italic.props.js +393 -0
- package/lib/components/__generated__/link.props.js +417 -0
- package/lib/components/__generated__/list-item.props.js +394 -0
- package/lib/components/__generated__/list.props.js +407 -0
- package/lib/components/__generated__/paragraph.props.js +393 -0
- package/lib/components/__generated__/rich-text-link.props.js +417 -0
- package/lib/components/__generated__/separator.props.js +393 -0
- package/lib/components/__generated__/span.props.js +393 -0
- package/lib/components/__generated__/subscript.props.js +393 -0
- package/lib/components/__generated__/superscript.props.js +393 -0
- package/lib/components/__generated__/text-block.props.js +393 -0
- package/lib/components/blockquote.js +14 -0
- package/lib/components/blockquote.ws.js +55 -0
- package/lib/components/body.ws.js +1 -1
- package/lib/components/bold.ws.js +1 -1
- package/lib/components/box.ws.js +1 -1
- package/lib/components/button.ws.js +1 -1
- package/lib/components/code.js +21 -0
- package/lib/components/code.ws.js +46 -0
- package/lib/components/components-utils.js +45 -0
- package/lib/components/components.js +44 -0
- package/lib/components/form.ws.js +1 -1
- package/lib/components/heading.ws.js +1 -1
- package/lib/components/image.ws.js +7 -2
- package/lib/components/index.js +28 -53
- package/lib/components/input.ws.js +1 -1
- package/lib/components/italic.ws.js +1 -1
- package/lib/components/link.ws.js +1 -1
- package/lib/components/list-item.js +14 -0
- package/lib/components/list-item.ws.js +15 -0
- package/lib/components/list.js +14 -0
- package/lib/components/list.ws.js +31 -0
- package/lib/components/paragraph.ws.js +1 -1
- package/lib/components/rich-text-link.ws.js +1 -1
- package/lib/components/separator.js +14 -0
- package/lib/components/separator.ws.js +31 -0
- package/lib/components/span.ws.js +1 -1
- package/lib/components/subscript.ws.js +1 -1
- package/lib/components/superscript.ws.js +1 -1
- package/lib/components/text-block.ws.js +1 -1
- package/lib/css/get-browser-style.js +9 -1
- package/lib/css/index.js +0 -1
- package/lib/index.js +2 -0
- package/lib/tree/create-elements-tree.js +10 -9
- package/lib/tree/index.js +1 -1
- package/lib/tree/root.js +28 -4
- package/lib/tree/{wrapper-component.js → webstudio-component.js} +8 -7
- package/package.json +14 -11
- package/src/app/custom-components/image.tsx +1 -1
- package/src/app/custom-components/index.ts +2 -7
- package/src/components/__generated__/blockquote.props.ts +439 -0
- package/src/components/__generated__/body.props.ts +438 -0
- package/src/components/__generated__/bold.props.ts +438 -0
- package/src/components/__generated__/box.props.ts +456 -0
- package/src/components/__generated__/button.props.ts +455 -0
- package/src/components/__generated__/code.props.ts +445 -0
- package/src/components/__generated__/form.props.ts +446 -0
- package/src/components/__generated__/heading.props.ts +445 -0
- package/src/components/__generated__/image.props.ts +479 -0
- package/src/components/__generated__/input.props.ts +476 -0
- package/src/components/__generated__/italic.props.ts +438 -0
- package/src/components/__generated__/link.props.ts +462 -0
- package/src/components/__generated__/list-item.props.ts +439 -0
- package/src/components/__generated__/list.props.ts +452 -0
- package/src/components/__generated__/paragraph.props.ts +438 -0
- package/src/components/__generated__/rich-text-link.props.ts +462 -0
- package/src/components/__generated__/separator.props.ts +438 -0
- package/src/components/__generated__/span.props.ts +438 -0
- package/src/components/__generated__/subscript.props.ts +438 -0
- package/src/components/__generated__/superscript.props.ts +438 -0
- package/src/components/__generated__/text-block.props.ts +438 -0
- package/src/components/blockquote.stories.tsx +16 -0
- package/src/components/blockquote.tsx +18 -0
- package/src/components/blockquote.ws.tsx +55 -0
- package/src/components/body.ws.tsx +3 -3
- package/src/components/bold.ws.tsx +3 -3
- package/src/components/box.ws.ts +3 -3
- package/src/components/button.ws.tsx +3 -3
- package/src/components/code.stories.tsx +16 -0
- package/src/components/code.tsx +31 -0
- package/src/components/code.ws.tsx +46 -0
- package/src/components/components-utils.ts +75 -0
- package/src/components/components.ts +28 -0
- package/src/components/form.ws.tsx +3 -3
- package/src/components/heading.ws.tsx +3 -3
- package/src/components/image.ws.tsx +9 -4
- package/src/components/index.ts +28 -63
- package/src/components/input.ws.tsx +3 -3
- package/src/components/italic.ws.tsx +3 -3
- package/src/components/link.ws.tsx +3 -3
- package/src/components/list-item.stories.tsx +16 -0
- package/src/components/list-item.tsx +18 -0
- package/src/components/list-item.ws.tsx +14 -0
- package/src/components/list.stories.tsx +17 -0
- package/src/components/list.tsx +24 -0
- package/src/components/list.ws.tsx +31 -0
- package/src/components/paragraph.ws.tsx +3 -3
- package/src/components/rich-text-link.ws.tsx +3 -3
- package/src/components/separator.stories.tsx +14 -0
- package/src/components/separator.tsx +18 -0
- package/src/components/separator.ws.tsx +31 -0
- package/src/components/span.ws.tsx +3 -3
- package/src/components/subscript.ws.tsx +3 -3
- package/src/components/superscript.ws.tsx +3 -3
- package/src/components/text-block.ws.tsx +3 -3
- package/src/css/get-browser-style.ts +14 -3
- package/src/css/index.ts +0 -1
- package/src/index.ts +2 -0
- package/src/props.ts +1 -1
- package/src/tree/create-elements-tree.tsx +16 -32
- package/src/tree/index.ts +1 -1
- package/src/tree/root.ts +37 -5
- package/src/tree/{wrapper-component.tsx → webstudio-component.tsx} +11 -9
- package/lib/cjs/components/__generated__/body.props.json +0 -743
- package/lib/cjs/components/__generated__/bold.props.json +0 -743
- package/lib/cjs/components/__generated__/box.props.json +0 -765
- package/lib/cjs/components/__generated__/button.props.json +0 -824
- package/lib/cjs/components/__generated__/form.props.json +0 -799
- package/lib/cjs/components/__generated__/heading.props.json +0 -754
- package/lib/cjs/components/__generated__/image.props.json +0 -846
- package/lib/cjs/components/__generated__/input.props.json +0 -977
- package/lib/cjs/components/__generated__/italic.props.json +0 -743
- package/lib/cjs/components/__generated__/link.props.json +0 -820
- package/lib/cjs/components/__generated__/paragraph.props.json +0 -743
- package/lib/cjs/components/__generated__/rich-text-link.props.json +0 -820
- package/lib/cjs/components/__generated__/span.props.json +0 -743
- package/lib/cjs/components/__generated__/subscript.props.json +0 -743
- package/lib/cjs/components/__generated__/superscript.props.json +0 -743
- package/lib/cjs/components/__generated__/text-block.props.json +0 -743
- package/lib/components/__generated__/body.props.json +0 -743
- package/lib/components/__generated__/bold.props.json +0 -743
- package/lib/components/__generated__/box.props.json +0 -765
- package/lib/components/__generated__/button.props.json +0 -824
- package/lib/components/__generated__/form.props.json +0 -799
- package/lib/components/__generated__/heading.props.json +0 -754
- package/lib/components/__generated__/image.props.json +0 -846
- package/lib/components/__generated__/input.props.json +0 -977
- package/lib/components/__generated__/italic.props.json +0 -743
- package/lib/components/__generated__/link.props.json +0 -820
- package/lib/components/__generated__/paragraph.props.json +0 -743
- package/lib/components/__generated__/rich-text-link.props.json +0 -820
- package/lib/components/__generated__/span.props.json +0 -743
- package/lib/components/__generated__/subscript.props.json +0 -743
- package/lib/components/__generated__/superscript.props.json +0 -743
- package/lib/components/__generated__/text-block.props.json +0 -743
- package/lib/css/breakpoints.js +0 -9
- package/src/components/__generated__/body.props.json +0 -743
- package/src/components/__generated__/bold.props.json +0 -743
- package/src/components/__generated__/box.props.json +0 -765
- package/src/components/__generated__/button.props.json +0 -824
- package/src/components/__generated__/form.props.json +0 -799
- package/src/components/__generated__/heading.props.json +0 -754
- package/src/components/__generated__/image.props.json +0 -846
- package/src/components/__generated__/input.props.json +0 -977
- package/src/components/__generated__/italic.props.json +0 -743
- package/src/components/__generated__/link.props.json +0 -820
- package/src/components/__generated__/paragraph.props.json +0 -743
- package/src/components/__generated__/rich-text-link.props.json +0 -820
- package/src/components/__generated__/span.props.json +0 -743
- package/src/components/__generated__/subscript.props.json +0 -743
- package/src/components/__generated__/superscript.props.json +0 -743
- package/src/components/__generated__/text-block.props.json +0 -743
- package/src/css/breakpoints.ts +0 -10
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ImageIcon } from "@webstudio-is/icons";
|
|
2
|
-
import props from "./__generated__/image.props
|
|
2
|
+
import { props } from "./__generated__/image.props";
|
|
3
3
|
const presetStyle = {
|
|
4
4
|
maxWidth: {
|
|
5
5
|
type: "unit",
|
|
@@ -20,7 +20,12 @@ const meta = {
|
|
|
20
20
|
const propsMeta = {
|
|
21
21
|
props: {
|
|
22
22
|
...props,
|
|
23
|
-
src: {
|
|
23
|
+
src: {
|
|
24
|
+
type: "string",
|
|
25
|
+
control: "file-image",
|
|
26
|
+
label: "Source",
|
|
27
|
+
required: false
|
|
28
|
+
}
|
|
24
29
|
},
|
|
25
30
|
initialProps: ["src", "width", "height", "alt", "loading"]
|
|
26
31
|
};
|
package/lib/components/index.js
CHANGED
|
@@ -15,6 +15,11 @@ import { meta as ButtonMeta } from "./button.ws";
|
|
|
15
15
|
import { meta as InputMeta } from "./input.ws";
|
|
16
16
|
import { meta as FormMeta } from "./form.ws";
|
|
17
17
|
import { meta as ImageMeta } from "./image.ws";
|
|
18
|
+
import { meta as BlockquoteMeta } from "./blockquote.ws";
|
|
19
|
+
import { meta as ListMeta } from "./list.ws";
|
|
20
|
+
import { meta as ListItemMeta } from "./list-item.ws";
|
|
21
|
+
import { meta as SeparatorMeta } from "./separator.ws";
|
|
22
|
+
import { meta as CodeMeta } from "./code.ws";
|
|
18
23
|
import { propsMeta as BodyMetaPropsMeta } from "./body.ws";
|
|
19
24
|
import { propsMeta as BoxMetaPropsMeta } from "./box.ws";
|
|
20
25
|
import { propsMeta as TextBlockMetaPropsMeta } from "./text-block.ws";
|
|
@@ -31,22 +36,11 @@ import { propsMeta as ButtonMetaPropsMeta } from "./button.ws";
|
|
|
31
36
|
import { propsMeta as InputMetaPropsMeta } from "./input.ws";
|
|
32
37
|
import { propsMeta as FormMetaPropsMeta } from "./form.ws";
|
|
33
38
|
import { propsMeta as ImageMetaPropsMeta } from "./image.ws";
|
|
34
|
-
import {
|
|
35
|
-
import {
|
|
36
|
-
import {
|
|
37
|
-
import {
|
|
38
|
-
import {
|
|
39
|
-
import { Link } from "./link";
|
|
40
|
-
import { RichTextLink } from "./rich-text-link";
|
|
41
|
-
import { Span } from "./span";
|
|
42
|
-
import { Bold } from "./bold";
|
|
43
|
-
import { Italic } from "./italic";
|
|
44
|
-
import { Superscript } from "./superscript";
|
|
45
|
-
import { Subscript } from "./subscript";
|
|
46
|
-
import { Button } from "./button";
|
|
47
|
-
import { Input } from "./input";
|
|
48
|
-
import { Form } from "./form";
|
|
49
|
-
import { Image } from "./image";
|
|
39
|
+
import { propsMeta as BlockquotePropsMeta } from "./blockquote.ws";
|
|
40
|
+
import { propsMeta as ListPropsMeta } from "./list.ws";
|
|
41
|
+
import { propsMeta as ListItemPropsMeta } from "./list-item.ws";
|
|
42
|
+
import { propsMeta as SeparatorPropsMeta } from "./separator.ws";
|
|
43
|
+
import { propsMeta as CodePropsMeta } from "./code.ws";
|
|
50
44
|
const defaultMetas = {
|
|
51
45
|
Box: BoxMeta,
|
|
52
46
|
Body: BodyMeta,
|
|
@@ -63,7 +57,12 @@ const defaultMetas = {
|
|
|
63
57
|
Button: ButtonMeta,
|
|
64
58
|
Input: InputMeta,
|
|
65
59
|
Form: FormMeta,
|
|
66
|
-
Image: ImageMeta
|
|
60
|
+
Image: ImageMeta,
|
|
61
|
+
Blockquote: BlockquoteMeta,
|
|
62
|
+
List: ListMeta,
|
|
63
|
+
ListItem: ListItemMeta,
|
|
64
|
+
Separator: SeparatorMeta,
|
|
65
|
+
Code: CodeMeta
|
|
67
66
|
};
|
|
68
67
|
let currentMetas = defaultMetas;
|
|
69
68
|
const getComponentMeta = (name) => {
|
|
@@ -76,7 +75,7 @@ const registerComponentMetas = (overrides) => {
|
|
|
76
75
|
}
|
|
77
76
|
currentMetas = result;
|
|
78
77
|
};
|
|
79
|
-
const
|
|
78
|
+
const defaultPropsMetasRaw = {
|
|
80
79
|
Box: BoxMetaPropsMeta,
|
|
81
80
|
Body: BodyMetaPropsMeta,
|
|
82
81
|
TextBlock: TextBlockMetaPropsMeta,
|
|
@@ -92,8 +91,14 @@ const defaultPropsMetas = {
|
|
|
92
91
|
Button: ButtonMetaPropsMeta,
|
|
93
92
|
Input: InputMetaPropsMeta,
|
|
94
93
|
Form: FormMetaPropsMeta,
|
|
95
|
-
Image: ImageMetaPropsMeta
|
|
94
|
+
Image: ImageMetaPropsMeta,
|
|
95
|
+
Blockquote: BlockquotePropsMeta,
|
|
96
|
+
List: ListPropsMeta,
|
|
97
|
+
ListItem: ListItemPropsMeta,
|
|
98
|
+
Separator: SeparatorPropsMeta,
|
|
99
|
+
Code: CodePropsMeta
|
|
96
100
|
};
|
|
101
|
+
const defaultPropsMetas = defaultPropsMetasRaw;
|
|
97
102
|
let registeredPropsMetas = {};
|
|
98
103
|
let currentPropsMetas = void 0;
|
|
99
104
|
const getComponentPropsMeta = (name) => {
|
|
@@ -118,36 +123,7 @@ const registerComponentPropsMetas = (metas) => {
|
|
|
118
123
|
registeredPropsMetas = metas;
|
|
119
124
|
currentPropsMetas = void 0;
|
|
120
125
|
};
|
|
121
|
-
|
|
122
|
-
Box,
|
|
123
|
-
Body,
|
|
124
|
-
TextBlock,
|
|
125
|
-
Heading,
|
|
126
|
-
Paragraph,
|
|
127
|
-
Link,
|
|
128
|
-
RichTextLink,
|
|
129
|
-
Span,
|
|
130
|
-
Bold,
|
|
131
|
-
Italic,
|
|
132
|
-
Superscript,
|
|
133
|
-
Subscript,
|
|
134
|
-
Button,
|
|
135
|
-
Input,
|
|
136
|
-
Form,
|
|
137
|
-
Image
|
|
138
|
-
};
|
|
139
|
-
let registeredComponents = null;
|
|
140
|
-
const componentNames = Object.keys(defaultComponents);
|
|
141
|
-
const getComponentNames = () => {
|
|
142
|
-
const uniqueNames = /* @__PURE__ */ new Set([
|
|
143
|
-
...componentNames,
|
|
144
|
-
...Object.keys(registeredComponents || {})
|
|
145
|
-
]);
|
|
146
|
-
return [...uniqueNames.values()];
|
|
147
|
-
};
|
|
148
|
-
const getComponent = (name) => {
|
|
149
|
-
return registeredComponents != null && name in registeredComponents ? registeredComponents[name] : defaultComponents[name];
|
|
150
|
-
};
|
|
126
|
+
let registeredComponents;
|
|
151
127
|
const registerComponents = (components) => {
|
|
152
128
|
registeredComponents = components;
|
|
153
129
|
};
|
|
@@ -171,16 +147,15 @@ const computeProps = (defaults, overrides) => {
|
|
|
171
147
|
const computeInitialProps = (props, defaults, overrides) => {
|
|
172
148
|
const initialProps = overrides?.initialProps ?? defaults?.initialProps ?? [];
|
|
173
149
|
const requiredProps = props ? Object.entries(props).filter(
|
|
174
|
-
([name, value]) => value?.
|
|
150
|
+
([name, value]) => value?.required && initialProps.includes(name) === false
|
|
175
151
|
).map(([name]) => name) : [];
|
|
176
152
|
return [...initialProps, ...requiredProps];
|
|
177
153
|
};
|
|
178
154
|
export {
|
|
179
|
-
getComponent,
|
|
180
155
|
getComponentMeta,
|
|
181
|
-
getComponentNames,
|
|
182
156
|
getComponentPropsMeta,
|
|
183
157
|
registerComponentMetas,
|
|
184
158
|
registerComponentPropsMetas,
|
|
185
|
-
registerComponents
|
|
159
|
+
registerComponents,
|
|
160
|
+
registeredComponents
|
|
186
161
|
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
forwardRef,
|
|
3
|
+
createElement
|
|
4
|
+
} from "react";
|
|
5
|
+
const defaultTag = "li";
|
|
6
|
+
const ListItem = forwardRef(
|
|
7
|
+
(props, ref) => {
|
|
8
|
+
return createElement(defaultTag, { ...props, ref });
|
|
9
|
+
}
|
|
10
|
+
);
|
|
11
|
+
ListItem.displayName = "ListItem";
|
|
12
|
+
export {
|
|
13
|
+
ListItem
|
|
14
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ListItemIcon } from "@webstudio-is/icons";
|
|
2
|
+
import { props } from "./__generated__/list-item.props";
|
|
3
|
+
const meta = {
|
|
4
|
+
type: "rich-text",
|
|
5
|
+
label: "List Item",
|
|
6
|
+
Icon: ListItemIcon,
|
|
7
|
+
children: ["List Item you can edit"]
|
|
8
|
+
};
|
|
9
|
+
const propsMeta = {
|
|
10
|
+
props
|
|
11
|
+
};
|
|
12
|
+
export {
|
|
13
|
+
meta,
|
|
14
|
+
propsMeta
|
|
15
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
forwardRef,
|
|
3
|
+
createElement
|
|
4
|
+
} from "react";
|
|
5
|
+
const unorderedTag = "ul";
|
|
6
|
+
const orderedTag = "ol";
|
|
7
|
+
const List = forwardRef(({ ordered = false, ...props }, ref) => {
|
|
8
|
+
const tag = ordered ? orderedTag : unorderedTag;
|
|
9
|
+
return createElement(tag, { ...props, ref });
|
|
10
|
+
});
|
|
11
|
+
List.displayName = "List";
|
|
12
|
+
export {
|
|
13
|
+
List
|
|
14
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ListIcon } from "@webstudio-is/icons";
|
|
2
|
+
import { props } from "./__generated__/list.props";
|
|
3
|
+
const presetStyle = {
|
|
4
|
+
marginTop: {
|
|
5
|
+
type: "keyword",
|
|
6
|
+
value: "0"
|
|
7
|
+
},
|
|
8
|
+
marginBottom: {
|
|
9
|
+
type: "keyword",
|
|
10
|
+
value: "10px"
|
|
11
|
+
},
|
|
12
|
+
paddingLeft: {
|
|
13
|
+
type: "keyword",
|
|
14
|
+
value: "40px"
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
const meta = {
|
|
18
|
+
type: "container",
|
|
19
|
+
label: "List",
|
|
20
|
+
Icon: ListIcon,
|
|
21
|
+
presetStyle,
|
|
22
|
+
children: []
|
|
23
|
+
};
|
|
24
|
+
const propsMeta = {
|
|
25
|
+
props,
|
|
26
|
+
initialProps: ["ordered", "type", "starts", "reversed"]
|
|
27
|
+
};
|
|
28
|
+
export {
|
|
29
|
+
meta,
|
|
30
|
+
propsMeta
|
|
31
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
forwardRef,
|
|
3
|
+
createElement
|
|
4
|
+
} from "react";
|
|
5
|
+
const defaultTag = "hr";
|
|
6
|
+
const Separator = forwardRef(
|
|
7
|
+
(props, ref) => {
|
|
8
|
+
return createElement(defaultTag, { ...props, ref });
|
|
9
|
+
}
|
|
10
|
+
);
|
|
11
|
+
Separator.displayName = "Separator";
|
|
12
|
+
export {
|
|
13
|
+
Separator
|
|
14
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { DashIcon } from "@webstudio-is/icons";
|
|
2
|
+
import { props } from "./__generated__/separator.props";
|
|
3
|
+
const presetStyle = {
|
|
4
|
+
height: {
|
|
5
|
+
type: "keyword",
|
|
6
|
+
value: "1px"
|
|
7
|
+
},
|
|
8
|
+
backgroundColor: {
|
|
9
|
+
type: "keyword",
|
|
10
|
+
value: "gray"
|
|
11
|
+
},
|
|
12
|
+
border: {
|
|
13
|
+
type: "keyword",
|
|
14
|
+
value: "none"
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
const meta = {
|
|
18
|
+
type: "embed",
|
|
19
|
+
label: "Separator",
|
|
20
|
+
Icon: DashIcon,
|
|
21
|
+
presetStyle,
|
|
22
|
+
children: []
|
|
23
|
+
};
|
|
24
|
+
const propsMeta = {
|
|
25
|
+
props,
|
|
26
|
+
initialProps: []
|
|
27
|
+
};
|
|
28
|
+
export {
|
|
29
|
+
meta,
|
|
30
|
+
propsMeta
|
|
31
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { detectFont } from "detect-font";
|
|
2
|
+
import { keywordValues } from "@webstudio-is/css-data";
|
|
2
3
|
import { properties, units } from "@webstudio-is/css-data";
|
|
3
4
|
const unitsList = Object.values(units).flat();
|
|
4
5
|
const unitRegex = new RegExp(`${unitsList.join("|")}`);
|
|
@@ -9,8 +10,15 @@ const parseValue = (property, value) => {
|
|
|
9
10
|
value = "transparent";
|
|
10
11
|
}
|
|
11
12
|
if (Number.isNaN(number)) {
|
|
13
|
+
const values = keywordValues[property];
|
|
14
|
+
if (values?.includes(value)) {
|
|
15
|
+
return {
|
|
16
|
+
type: "keyword",
|
|
17
|
+
value
|
|
18
|
+
};
|
|
19
|
+
}
|
|
12
20
|
return {
|
|
13
|
-
type: "
|
|
21
|
+
type: "unparsed",
|
|
14
22
|
value
|
|
15
23
|
};
|
|
16
24
|
}
|
package/lib/css/index.js
CHANGED
package/lib/index.js
CHANGED
|
@@ -9,12 +9,12 @@ const createElementsTree = ({
|
|
|
9
9
|
propsByInstanceIdStore,
|
|
10
10
|
assetsStore,
|
|
11
11
|
Component,
|
|
12
|
-
|
|
12
|
+
getComponent
|
|
13
13
|
}) => {
|
|
14
14
|
const children = createInstanceChildrenElements({
|
|
15
15
|
Component,
|
|
16
16
|
children: instance.children,
|
|
17
|
-
|
|
17
|
+
getComponent
|
|
18
18
|
});
|
|
19
19
|
const body = createInstanceElement({
|
|
20
20
|
Component,
|
|
@@ -28,7 +28,8 @@ const createElementsTree = ({
|
|
|
28
28
|
/* @__PURE__ */ jsx(Scripts, {})
|
|
29
29
|
]
|
|
30
30
|
}, "children")
|
|
31
|
-
]
|
|
31
|
+
],
|
|
32
|
+
getComponent
|
|
32
33
|
});
|
|
33
34
|
return /* @__PURE__ */ jsx(ReactSdkContext.Provider, {
|
|
34
35
|
value: { propsByInstanceIdStore, assetsStore },
|
|
@@ -38,7 +39,7 @@ const createElementsTree = ({
|
|
|
38
39
|
const createInstanceChildrenElements = ({
|
|
39
40
|
children,
|
|
40
41
|
Component,
|
|
41
|
-
|
|
42
|
+
getComponent
|
|
42
43
|
}) => {
|
|
43
44
|
const elements = [];
|
|
44
45
|
for (const child of children) {
|
|
@@ -49,13 +50,13 @@ const createInstanceChildrenElements = ({
|
|
|
49
50
|
const children2 = createInstanceChildrenElements({
|
|
50
51
|
children: child.children,
|
|
51
52
|
Component,
|
|
52
|
-
|
|
53
|
+
getComponent
|
|
53
54
|
});
|
|
54
55
|
const element = createInstanceElement({
|
|
55
56
|
instance: child,
|
|
56
57
|
Component,
|
|
57
|
-
|
|
58
|
-
|
|
58
|
+
children: children2,
|
|
59
|
+
getComponent
|
|
59
60
|
});
|
|
60
61
|
elements.push(element);
|
|
61
62
|
}
|
|
@@ -65,13 +66,13 @@ const createInstanceElement = ({
|
|
|
65
66
|
Component,
|
|
66
67
|
instance,
|
|
67
68
|
children = [],
|
|
68
|
-
|
|
69
|
+
getComponent
|
|
69
70
|
}) => {
|
|
70
71
|
const props = {
|
|
71
72
|
instance,
|
|
72
73
|
children,
|
|
73
74
|
key: instance.id,
|
|
74
|
-
|
|
75
|
+
getComponent
|
|
75
76
|
};
|
|
76
77
|
return /* @__PURE__ */ jsx(Component, {
|
|
77
78
|
...props
|
package/lib/tree/index.js
CHANGED
package/lib/tree/root.js
CHANGED
|
@@ -1,14 +1,37 @@
|
|
|
1
1
|
import { atom } from "nanostores";
|
|
2
2
|
import { createElementsTree } from "./create-elements-tree";
|
|
3
|
-
import {
|
|
3
|
+
import { WebstudioComponent } from "./webstudio-component";
|
|
4
4
|
import { registerComponents } from "../components";
|
|
5
5
|
import { customComponents as defaultCustomComponents } from "../app/custom-components";
|
|
6
6
|
import { setParams } from "../app/params";
|
|
7
7
|
import { getPropsByInstanceId } from "../props";
|
|
8
|
+
const denormalizeTree = (instances) => {
|
|
9
|
+
const convertTree = (instance) => {
|
|
10
|
+
const legacyInstance = {
|
|
11
|
+
type: "instance",
|
|
12
|
+
id: instance.id,
|
|
13
|
+
component: instance.component,
|
|
14
|
+
children: []
|
|
15
|
+
};
|
|
16
|
+
for (const child of instance.children) {
|
|
17
|
+
if (child.type === "id") {
|
|
18
|
+
const childInstance = instances.get(child.value);
|
|
19
|
+
if (childInstance) {
|
|
20
|
+
legacyInstance.children.push(convertTree(childInstance));
|
|
21
|
+
}
|
|
22
|
+
} else {
|
|
23
|
+
legacyInstance.children.push(child);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return legacyInstance;
|
|
27
|
+
};
|
|
28
|
+
return convertTree(Array.from(instances.values())[0]);
|
|
29
|
+
};
|
|
8
30
|
const InstanceRoot = ({
|
|
9
31
|
data,
|
|
10
32
|
Component,
|
|
11
|
-
customComponents = defaultCustomComponents
|
|
33
|
+
customComponents = defaultCustomComponents,
|
|
34
|
+
getComponent
|
|
12
35
|
}) => {
|
|
13
36
|
if (data.tree === null) {
|
|
14
37
|
throw new Error("Tree is null");
|
|
@@ -16,12 +39,13 @@ const InstanceRoot = ({
|
|
|
16
39
|
setParams(data.params ?? null);
|
|
17
40
|
registerComponents(customComponents);
|
|
18
41
|
return createElementsTree({
|
|
19
|
-
instance: data.tree.
|
|
42
|
+
instance: denormalizeTree(new Map(data.tree.instances)),
|
|
20
43
|
propsByInstanceIdStore: atom(
|
|
21
44
|
getPropsByInstanceId(new Map(data.tree.props))
|
|
22
45
|
),
|
|
23
46
|
assetsStore: atom(new Map(data.assets.map((asset) => [asset.id, asset]))),
|
|
24
|
-
Component: Component ??
|
|
47
|
+
Component: Component ?? WebstudioComponent,
|
|
48
|
+
getComponent
|
|
25
49
|
});
|
|
26
50
|
};
|
|
27
51
|
export {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Fragment as Fragment2 } from "react";
|
|
3
|
-
import { getComponent } from "../components";
|
|
4
3
|
import { useInstanceProps } from "../props";
|
|
5
4
|
const renderText = (text) => {
|
|
6
5
|
const lines = text.split("\n");
|
|
@@ -11,7 +10,7 @@ const renderText = (text) => {
|
|
|
11
10
|
]
|
|
12
11
|
}, index));
|
|
13
12
|
};
|
|
14
|
-
const
|
|
13
|
+
const renderWebstudioComponentChildren = (children) => {
|
|
15
14
|
if (children === void 0 || children.length === 0) {
|
|
16
15
|
return;
|
|
17
16
|
}
|
|
@@ -19,10 +18,10 @@ const renderWrapperComponentChildren = (children) => {
|
|
|
19
18
|
return typeof child === "string" ? renderText(child) : child;
|
|
20
19
|
});
|
|
21
20
|
};
|
|
22
|
-
const
|
|
21
|
+
const WebstudioComponent = ({
|
|
23
22
|
instance,
|
|
24
|
-
onChangeChildren,
|
|
25
23
|
children,
|
|
24
|
+
getComponent,
|
|
26
25
|
...rest
|
|
27
26
|
}) => {
|
|
28
27
|
const instanceProps = useInstanceProps(instance.id);
|
|
@@ -38,14 +37,16 @@ const WrapperComponent = ({
|
|
|
38
37
|
}
|
|
39
38
|
return /* @__PURE__ */ jsx(Component, {
|
|
40
39
|
...props,
|
|
41
|
-
children:
|
|
40
|
+
children: renderWebstudioComponentChildren(children)
|
|
42
41
|
});
|
|
43
42
|
};
|
|
44
43
|
const idAttribute = "data-ws-id";
|
|
45
44
|
const componentAttribute = "data-ws-component";
|
|
45
|
+
const collapsedAttribute = "data-ws-collapsed";
|
|
46
46
|
export {
|
|
47
|
-
|
|
47
|
+
WebstudioComponent,
|
|
48
|
+
collapsedAttribute,
|
|
48
49
|
componentAttribute,
|
|
49
50
|
idAttribute,
|
|
50
|
-
|
|
51
|
+
renderWebstudioComponentChildren
|
|
51
52
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webstudio-is/react-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.36.0",
|
|
4
4
|
"description": "Webstudio JavaScript / TypeScript API",
|
|
5
5
|
"author": "Webstudio <github@webstudio.is>",
|
|
6
6
|
"homepage": "https://webstudio.is",
|
|
@@ -46,17 +46,20 @@
|
|
|
46
46
|
"mitt": "^3.0.0",
|
|
47
47
|
"nanostores": "^0.7.1",
|
|
48
48
|
"warn-once": "^0.1.1",
|
|
49
|
-
"@webstudio-is/asset-uploader": "^0.
|
|
50
|
-
"@webstudio-is/css-data": "^0.
|
|
51
|
-
"@webstudio-is/
|
|
52
|
-
"@webstudio-is/
|
|
53
|
-
"@webstudio-is/
|
|
54
|
-
"@webstudio-is/
|
|
55
|
-
"@webstudio-is/
|
|
49
|
+
"@webstudio-is/asset-uploader": "^0.36.0",
|
|
50
|
+
"@webstudio-is/css-data": "^0.36.0",
|
|
51
|
+
"@webstudio-is/css-vars": "^0.36.0",
|
|
52
|
+
"@webstudio-is/generate-arg-types": "^0.36.0",
|
|
53
|
+
"@webstudio-is/icons": "^0.36.0",
|
|
54
|
+
"@webstudio-is/image": "^0.36.0",
|
|
55
|
+
"@webstudio-is/prisma-client": "^0.36.0",
|
|
56
|
+
"@webstudio-is/project-build": "^0.36.0"
|
|
56
57
|
},
|
|
57
58
|
"exports": {
|
|
58
|
-
"
|
|
59
|
-
|
|
59
|
+
".": {
|
|
60
|
+
"import": "./lib/index.js",
|
|
61
|
+
"require": "./lib/cjs/index.cjs"
|
|
62
|
+
}
|
|
60
63
|
},
|
|
61
64
|
"types": "src/index.ts",
|
|
62
65
|
"files": [
|
|
@@ -70,7 +73,7 @@
|
|
|
70
73
|
"scripts": {
|
|
71
74
|
"dev": "build-package --watch",
|
|
72
75
|
"build": "build-package",
|
|
73
|
-
"build:args": "generate-arg-types './src/components/*.tsx !./src/**/*.stories.tsx !./src/**/*.ws.tsx' && prettier --write \"**/*.props.
|
|
76
|
+
"build:args": "generate-arg-types './src/components/*.tsx !./src/**/*.stories.tsx !./src/**/*.ws.tsx' && prettier --write \"**/*.props.ts\"",
|
|
74
77
|
"typecheck": "tsc --noEmit",
|
|
75
78
|
"test": "NODE_OPTIONS=--experimental-vm-modules jest --passWithNoTests",
|
|
76
79
|
"lint": "eslint ./src --ext .ts,.tsx --max-warnings 0",
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
import { Image as WebstudioImage, loaders } from "@webstudio-is/image";
|
|
8
8
|
import { Image as SdkImage } from "../../components/image";
|
|
9
9
|
import { usePropAsset } from "../../props";
|
|
10
|
-
import { idAttribute } from "../../tree/
|
|
10
|
+
import { idAttribute } from "../../tree/webstudio-component";
|
|
11
11
|
import { getParams } from "../params";
|
|
12
12
|
|
|
13
13
|
const defaultTag = "img";
|
|
@@ -10,13 +10,8 @@ export const customComponents = {
|
|
|
10
10
|
RichTextLink,
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
export const customComponentPropsMetas = {
|
|
14
|
-
Image: {
|
|
15
|
-
props: {
|
|
16
|
-
...imageProps,
|
|
17
|
-
src: { ...imageProps.src, control: "file-image", name: "Source" },
|
|
18
|
-
},
|
|
19
|
-
} as WsComponentPropsMeta,
|
|
13
|
+
export const customComponentPropsMetas: Record<string, WsComponentPropsMeta> = {
|
|
14
|
+
Image: { props: imageProps },
|
|
20
15
|
};
|
|
21
16
|
|
|
22
17
|
// just for completeness, maybe we add soemthing here later
|