@webstudio-is/react-sdk 0.34.0 → 0.35.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/css/index.cjs +0 -1
- package/lib/cjs/tree/create-elements-tree.cjs +6 -13
- package/lib/cjs/tree/wrapper-component.cjs +2 -1
- package/lib/css/index.js +0 -1
- package/lib/tree/create-elements-tree.js +6 -13
- package/lib/tree/wrapper-component.js +2 -1
- package/package.json +8 -8
- package/src/css/index.ts +0 -1
- package/src/tree/create-elements-tree.tsx +0 -28
- package/src/tree/wrapper-component.tsx +1 -3
- package/lib/cjs/css/breakpoints.cjs +0 -29
- package/lib/css/breakpoints.js +0 -9
- package/src/css/breakpoints.ts +0 -10
package/lib/cjs/css/index.cjs
CHANGED
|
@@ -17,4 +17,3 @@ var css_exports = {};
|
|
|
17
17
|
module.exports = __toCommonJS(css_exports);
|
|
18
18
|
__reExport(css_exports, require("./get-browser-style"), module.exports);
|
|
19
19
|
__reExport(css_exports, require("./categories"), module.exports);
|
|
20
|
-
__reExport(css_exports, require("./breakpoints"), module.exports);
|
|
@@ -31,13 +31,11 @@ const createElementsTree = ({
|
|
|
31
31
|
instance,
|
|
32
32
|
propsByInstanceIdStore,
|
|
33
33
|
assetsStore,
|
|
34
|
-
Component
|
|
35
|
-
onChangeChildren
|
|
34
|
+
Component
|
|
36
35
|
}) => {
|
|
37
36
|
const children = createInstanceChildrenElements({
|
|
38
37
|
Component,
|
|
39
|
-
children: instance.children
|
|
40
|
-
onChangeChildren
|
|
38
|
+
children: instance.children
|
|
41
39
|
});
|
|
42
40
|
const body = createInstanceElement({
|
|
43
41
|
Component,
|
|
@@ -60,8 +58,7 @@ const createElementsTree = ({
|
|
|
60
58
|
};
|
|
61
59
|
const createInstanceChildrenElements = ({
|
|
62
60
|
children,
|
|
63
|
-
Component
|
|
64
|
-
onChangeChildren
|
|
61
|
+
Component
|
|
65
62
|
}) => {
|
|
66
63
|
const elements = [];
|
|
67
64
|
for (const child of children) {
|
|
@@ -71,13 +68,11 @@ const createInstanceChildrenElements = ({
|
|
|
71
68
|
}
|
|
72
69
|
const children2 = createInstanceChildrenElements({
|
|
73
70
|
children: child.children,
|
|
74
|
-
Component
|
|
75
|
-
onChangeChildren
|
|
71
|
+
Component
|
|
76
72
|
});
|
|
77
73
|
const element = createInstanceElement({
|
|
78
74
|
instance: child,
|
|
79
75
|
Component,
|
|
80
|
-
onChangeChildren,
|
|
81
76
|
children: children2
|
|
82
77
|
});
|
|
83
78
|
elements.push(element);
|
|
@@ -87,14 +82,12 @@ const createInstanceChildrenElements = ({
|
|
|
87
82
|
const createInstanceElement = ({
|
|
88
83
|
Component,
|
|
89
84
|
instance,
|
|
90
|
-
children = []
|
|
91
|
-
onChangeChildren
|
|
85
|
+
children = []
|
|
92
86
|
}) => {
|
|
93
87
|
const props = {
|
|
94
88
|
instance,
|
|
95
89
|
children,
|
|
96
|
-
key: instance.id
|
|
97
|
-
onChangeChildren
|
|
90
|
+
key: instance.id
|
|
98
91
|
};
|
|
99
92
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {
|
|
100
93
|
...props
|
|
@@ -19,6 +19,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
var wrapper_component_exports = {};
|
|
20
20
|
__export(wrapper_component_exports, {
|
|
21
21
|
WrapperComponent: () => WrapperComponent,
|
|
22
|
+
collapsedAttribute: () => collapsedAttribute,
|
|
22
23
|
componentAttribute: () => componentAttribute,
|
|
23
24
|
idAttribute: () => idAttribute,
|
|
24
25
|
renderWrapperComponentChildren: () => renderWrapperComponentChildren
|
|
@@ -47,7 +48,6 @@ const renderWrapperComponentChildren = (children) => {
|
|
|
47
48
|
};
|
|
48
49
|
const WrapperComponent = ({
|
|
49
50
|
instance,
|
|
50
|
-
onChangeChildren,
|
|
51
51
|
children,
|
|
52
52
|
...rest
|
|
53
53
|
}) => {
|
|
@@ -69,3 +69,4 @@ const WrapperComponent = ({
|
|
|
69
69
|
};
|
|
70
70
|
const idAttribute = "data-ws-id";
|
|
71
71
|
const componentAttribute = "data-ws-component";
|
|
72
|
+
const collapsedAttribute = "data-ws-collapsed";
|
package/lib/css/index.js
CHANGED
|
@@ -8,13 +8,11 @@ const createElementsTree = ({
|
|
|
8
8
|
instance,
|
|
9
9
|
propsByInstanceIdStore,
|
|
10
10
|
assetsStore,
|
|
11
|
-
Component
|
|
12
|
-
onChangeChildren
|
|
11
|
+
Component
|
|
13
12
|
}) => {
|
|
14
13
|
const children = createInstanceChildrenElements({
|
|
15
14
|
Component,
|
|
16
|
-
children: instance.children
|
|
17
|
-
onChangeChildren
|
|
15
|
+
children: instance.children
|
|
18
16
|
});
|
|
19
17
|
const body = createInstanceElement({
|
|
20
18
|
Component,
|
|
@@ -37,8 +35,7 @@ const createElementsTree = ({
|
|
|
37
35
|
};
|
|
38
36
|
const createInstanceChildrenElements = ({
|
|
39
37
|
children,
|
|
40
|
-
Component
|
|
41
|
-
onChangeChildren
|
|
38
|
+
Component
|
|
42
39
|
}) => {
|
|
43
40
|
const elements = [];
|
|
44
41
|
for (const child of children) {
|
|
@@ -48,13 +45,11 @@ const createInstanceChildrenElements = ({
|
|
|
48
45
|
}
|
|
49
46
|
const children2 = createInstanceChildrenElements({
|
|
50
47
|
children: child.children,
|
|
51
|
-
Component
|
|
52
|
-
onChangeChildren
|
|
48
|
+
Component
|
|
53
49
|
});
|
|
54
50
|
const element = createInstanceElement({
|
|
55
51
|
instance: child,
|
|
56
52
|
Component,
|
|
57
|
-
onChangeChildren,
|
|
58
53
|
children: children2
|
|
59
54
|
});
|
|
60
55
|
elements.push(element);
|
|
@@ -64,14 +59,12 @@ const createInstanceChildrenElements = ({
|
|
|
64
59
|
const createInstanceElement = ({
|
|
65
60
|
Component,
|
|
66
61
|
instance,
|
|
67
|
-
children = []
|
|
68
|
-
onChangeChildren
|
|
62
|
+
children = []
|
|
69
63
|
}) => {
|
|
70
64
|
const props = {
|
|
71
65
|
instance,
|
|
72
66
|
children,
|
|
73
|
-
key: instance.id
|
|
74
|
-
onChangeChildren
|
|
67
|
+
key: instance.id
|
|
75
68
|
};
|
|
76
69
|
return /* @__PURE__ */ jsx(Component, {
|
|
77
70
|
...props
|
|
@@ -21,7 +21,6 @@ const renderWrapperComponentChildren = (children) => {
|
|
|
21
21
|
};
|
|
22
22
|
const WrapperComponent = ({
|
|
23
23
|
instance,
|
|
24
|
-
onChangeChildren,
|
|
25
24
|
children,
|
|
26
25
|
...rest
|
|
27
26
|
}) => {
|
|
@@ -43,8 +42,10 @@ const WrapperComponent = ({
|
|
|
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
|
WrapperComponent,
|
|
48
|
+
collapsedAttribute,
|
|
48
49
|
componentAttribute,
|
|
49
50
|
idAttribute,
|
|
50
51
|
renderWrapperComponentChildren
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webstudio-is/react-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.35.0",
|
|
4
4
|
"description": "Webstudio JavaScript / TypeScript API",
|
|
5
5
|
"author": "Webstudio <github@webstudio.is>",
|
|
6
6
|
"homepage": "https://webstudio.is",
|
|
@@ -46,13 +46,13 @@
|
|
|
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/generate-arg-types": "^0.
|
|
52
|
-
"@webstudio-is/icons": "^0.
|
|
53
|
-
"@webstudio-is/image": "^0.
|
|
54
|
-
"@webstudio-is/prisma-client": "^0.
|
|
55
|
-
"@webstudio-is/project-build": "^0.
|
|
49
|
+
"@webstudio-is/asset-uploader": "^0.35.0",
|
|
50
|
+
"@webstudio-is/css-data": "^0.35.0",
|
|
51
|
+
"@webstudio-is/generate-arg-types": "^0.35.0",
|
|
52
|
+
"@webstudio-is/icons": "^0.35.0",
|
|
53
|
+
"@webstudio-is/image": "^0.35.0",
|
|
54
|
+
"@webstudio-is/prisma-client": "^0.35.0",
|
|
55
|
+
"@webstudio-is/project-build": "^0.35.0"
|
|
56
56
|
},
|
|
57
57
|
"exports": {
|
|
58
58
|
"import": "./lib/index.js",
|
package/src/css/index.ts
CHANGED
|
@@ -7,43 +7,22 @@ import type { Assets, PropsByInstanceId } from "../props";
|
|
|
7
7
|
import type { WrapperComponent } from "./wrapper-component";
|
|
8
8
|
import { SessionStoragePolyfill } from "./session-storage-polyfill";
|
|
9
9
|
|
|
10
|
-
export type ChildrenUpdates = Array<
|
|
11
|
-
| {
|
|
12
|
-
type: "text";
|
|
13
|
-
value: string;
|
|
14
|
-
}
|
|
15
|
-
| {
|
|
16
|
-
type: "instance";
|
|
17
|
-
id: undefined | Instance["id"];
|
|
18
|
-
component: Instance["component"];
|
|
19
|
-
children: ChildrenUpdates;
|
|
20
|
-
}
|
|
21
|
-
>;
|
|
22
|
-
|
|
23
|
-
export type OnChangeChildren = (change: {
|
|
24
|
-
instanceId: Instance["id"];
|
|
25
|
-
updates: ChildrenUpdates;
|
|
26
|
-
}) => void;
|
|
27
|
-
|
|
28
10
|
export const createElementsTree = ({
|
|
29
11
|
sandbox,
|
|
30
12
|
instance,
|
|
31
13
|
propsByInstanceIdStore,
|
|
32
14
|
assetsStore,
|
|
33
15
|
Component,
|
|
34
|
-
onChangeChildren,
|
|
35
16
|
}: {
|
|
36
17
|
sandbox?: boolean;
|
|
37
18
|
instance: Instance;
|
|
38
19
|
propsByInstanceIdStore: ReadableAtom<PropsByInstanceId>;
|
|
39
20
|
assetsStore: ReadableAtom<Assets>;
|
|
40
21
|
Component: (props: ComponentProps<typeof WrapperComponent>) => JSX.Element;
|
|
41
|
-
onChangeChildren?: OnChangeChildren;
|
|
42
22
|
}) => {
|
|
43
23
|
const children = createInstanceChildrenElements({
|
|
44
24
|
Component,
|
|
45
25
|
children: instance.children,
|
|
46
|
-
onChangeChildren,
|
|
47
26
|
});
|
|
48
27
|
const body = createInstanceElement({
|
|
49
28
|
Component,
|
|
@@ -67,11 +46,9 @@ export const createElementsTree = ({
|
|
|
67
46
|
const createInstanceChildrenElements = ({
|
|
68
47
|
children,
|
|
69
48
|
Component,
|
|
70
|
-
onChangeChildren,
|
|
71
49
|
}: {
|
|
72
50
|
children: Instance["children"];
|
|
73
51
|
Component: (props: ComponentProps<typeof WrapperComponent>) => JSX.Element;
|
|
74
|
-
onChangeChildren?: OnChangeChildren;
|
|
75
52
|
}) => {
|
|
76
53
|
const elements = [];
|
|
77
54
|
for (const child of children) {
|
|
@@ -82,12 +59,10 @@ const createInstanceChildrenElements = ({
|
|
|
82
59
|
const children = createInstanceChildrenElements({
|
|
83
60
|
children: child.children,
|
|
84
61
|
Component,
|
|
85
|
-
onChangeChildren,
|
|
86
62
|
});
|
|
87
63
|
const element = createInstanceElement({
|
|
88
64
|
instance: child,
|
|
89
65
|
Component,
|
|
90
|
-
onChangeChildren,
|
|
91
66
|
children,
|
|
92
67
|
});
|
|
93
68
|
elements.push(element);
|
|
@@ -99,18 +74,15 @@ const createInstanceElement = ({
|
|
|
99
74
|
Component,
|
|
100
75
|
instance,
|
|
101
76
|
children = [],
|
|
102
|
-
onChangeChildren,
|
|
103
77
|
}: {
|
|
104
78
|
instance: Instance;
|
|
105
79
|
Component: (props: ComponentProps<typeof WrapperComponent>) => JSX.Element;
|
|
106
|
-
onChangeChildren?: OnChangeChildren;
|
|
107
80
|
children?: Array<JSX.Element | string>;
|
|
108
81
|
}) => {
|
|
109
82
|
const props = {
|
|
110
83
|
instance,
|
|
111
84
|
children,
|
|
112
85
|
key: instance.id,
|
|
113
|
-
onChangeChildren,
|
|
114
86
|
};
|
|
115
87
|
|
|
116
88
|
return <Component {...props} />;
|
|
@@ -2,7 +2,6 @@ import { Fragment } from "react";
|
|
|
2
2
|
import type { Instance } from "@webstudio-is/project-build";
|
|
3
3
|
import { getComponent } from "../components";
|
|
4
4
|
import { useInstanceProps } from "../props";
|
|
5
|
-
import type { OnChangeChildren } from "./create-elements-tree";
|
|
6
5
|
|
|
7
6
|
const renderText = (text: string): Array<JSX.Element> => {
|
|
8
7
|
const lines = text.split("\n");
|
|
@@ -30,12 +29,10 @@ export const renderWrapperComponentChildren = (
|
|
|
30
29
|
type WrapperComponentProps = {
|
|
31
30
|
instance: Instance;
|
|
32
31
|
children: Array<JSX.Element | string>;
|
|
33
|
-
onChangeChildren?: OnChangeChildren;
|
|
34
32
|
};
|
|
35
33
|
|
|
36
34
|
export const WrapperComponent = ({
|
|
37
35
|
instance,
|
|
38
|
-
onChangeChildren, // prevent it from passing to sdk component
|
|
39
36
|
children,
|
|
40
37
|
...rest
|
|
41
38
|
}: WrapperComponentProps) => {
|
|
@@ -57,3 +54,4 @@ export const WrapperComponent = ({
|
|
|
57
54
|
|
|
58
55
|
export const idAttribute = "data-ws-id";
|
|
59
56
|
export const componentAttribute = "data-ws-component";
|
|
57
|
+
export const collapsedAttribute = "data-ws-collapsed";
|
|
@@ -1,29 +0,0 @@
|
|
|
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 breakpoints_exports = {};
|
|
20
|
-
__export(breakpoints_exports, {
|
|
21
|
-
initialBreakpoints: () => initialBreakpoints
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(breakpoints_exports);
|
|
24
|
-
const initialBreakpoints = [
|
|
25
|
-
{ label: "Mobile", minWidth: 0 },
|
|
26
|
-
{ label: "Tablet", minWidth: 768 },
|
|
27
|
-
{ label: "Laptop", minWidth: 1024 },
|
|
28
|
-
{ label: "Desktop", minWidth: 1280 }
|
|
29
|
-
];
|
package/lib/css/breakpoints.js
DELETED
package/src/css/breakpoints.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { Breakpoint } from "@webstudio-is/project-build";
|
|
2
|
-
|
|
3
|
-
export type BaseBreakpoint = Pick<Breakpoint, "label" | "minWidth">;
|
|
4
|
-
|
|
5
|
-
export const initialBreakpoints: Array<BaseBreakpoint> = [
|
|
6
|
-
{ label: "Mobile", minWidth: 0 },
|
|
7
|
-
{ label: "Tablet", minWidth: 768 },
|
|
8
|
-
{ label: "Laptop", minWidth: 1024 },
|
|
9
|
-
{ label: "Desktop", minWidth: 1280 },
|
|
10
|
-
];
|