@webstudio-is/react-sdk 0.5.0 → 0.5.1
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/arg-types/utils.d.ts +19 -1
- package/lib/arg-types/utils.d.ts.map +1 -1
- package/lib/arg-types/utils.js +7 -6
- package/lib/components/body.d.ts +3 -0
- package/lib/components/body.d.ts.map +1 -0
- package/lib/components/body.js +8 -0
- package/lib/components/body.props.json +2234 -0
- package/lib/components/body.stories.d.ts +7 -0
- package/lib/components/body.stories.d.ts.map +1 -0
- package/lib/components/body.stories.js +16 -0
- package/lib/components/body.ws.d.ts +5 -0
- package/lib/components/body.ws.d.ts.map +1 -0
- package/lib/components/body.ws.js +64 -0
- package/lib/components/bold.props.json +37 -7
- package/lib/components/bold.ws.d.ts +5 -0
- package/lib/components/bold.ws.d.ts.map +1 -0
- package/lib/components/bold.ws.js +14 -0
- package/lib/components/box.d.ts +7 -2
- package/lib/components/box.d.ts.map +1 -1
- package/lib/components/box.js +3 -2
- package/lib/components/box.props.json +102 -7
- package/lib/components/box.stories.d.ts +6 -2
- package/lib/components/box.stories.d.ts.map +1 -1
- package/lib/components/box.ws.d.ts +5 -0
- package/lib/components/box.ws.d.ts.map +1 -0
- package/lib/components/box.ws.js +21 -0
- package/lib/components/button.d.ts +1 -4
- package/lib/components/button.d.ts.map +1 -1
- package/lib/components/button.props.json +42 -8
- package/lib/components/button.ws.d.ts +5 -0
- package/lib/components/button.ws.d.ts.map +1 -0
- package/lib/components/button.ws.js +15 -0
- package/lib/components/component-type.d.ts +17 -0
- package/lib/components/component-type.d.ts.map +1 -0
- package/lib/components/component-type.js +28 -0
- package/lib/components/form.props.json +37 -7
- package/lib/components/form.ws.d.ts +5 -0
- package/lib/components/form.ws.d.ts.map +1 -0
- package/lib/components/form.ws.js +26 -0
- package/lib/components/heading.d.ts +2 -2
- package/lib/components/heading.d.ts.map +1 -1
- package/lib/components/heading.js +1 -4
- package/lib/components/heading.props.json +45 -8
- package/lib/components/heading.stories.d.ts +2 -2
- package/lib/components/heading.ws.d.ts +5 -0
- package/lib/components/heading.ws.d.ts.map +1 -0
- package/lib/components/heading.ws.js +15 -0
- package/lib/components/index.d.ts +11 -10
- package/lib/components/index.d.ts.map +1 -1
- package/lib/components/index.js +25 -23
- package/lib/components/index.test.d.ts +2 -0
- package/lib/components/index.test.d.ts.map +1 -0
- package/lib/components/index.test.js +33 -0
- package/lib/components/input.props.json +46 -8
- package/lib/components/input.ws.d.ts +5 -0
- package/lib/components/input.ws.d.ts.map +1 -0
- package/lib/components/input.ws.js +14 -0
- package/lib/components/italic.props.json +37 -7
- package/lib/components/italic.ws.d.ts +5 -0
- package/lib/components/italic.ws.d.ts.map +1 -0
- package/lib/components/italic.ws.js +14 -0
- package/lib/components/link.d.ts +2 -2
- package/lib/components/link.d.ts.map +1 -1
- package/lib/components/link.props.json +37 -7
- package/lib/components/link.stories.d.ts +6 -2
- package/lib/components/link.stories.d.ts.map +1 -1
- package/lib/components/link.ws.d.ts +5 -0
- package/lib/components/link.ws.d.ts.map +1 -0
- package/lib/components/link.ws.js +27 -0
- package/lib/components/meta.d.ts +1 -0
- package/lib/components/meta.d.ts.map +1 -1
- package/lib/components/meta.js +3 -1
- package/lib/components/paragraph.props.json +37 -7
- package/lib/components/paragraph.ws.d.ts +5 -0
- package/lib/components/paragraph.ws.d.ts.map +1 -0
- package/lib/components/paragraph.ws.js +15 -0
- package/lib/components/text-block.props.json +37 -7
- package/lib/components/text-block.ws.d.ts +5 -0
- package/lib/components/text-block.ws.d.ts.map +1 -0
- package/lib/components/text-block.ws.js +23 -0
- package/lib/css/get-browser-style.js +1 -1
- package/lib/css/keyword-values.d.ts.map +1 -1
- package/lib/css/keyword-values.js +1149 -396
- package/lib/css/properties.d.ts.map +1 -1
- package/lib/css/properties.js +3194 -3194
- package/lib/css/units.js +1 -1
- package/lib/db/instance.d.ts +5 -2
- package/lib/db/instance.d.ts.map +1 -1
- package/lib/db/instance.js +9 -1
- package/lib/db/types.d.ts +1 -2
- package/lib/db/types.d.ts.map +1 -1
- package/lib/pubsub/publish.js +1 -1
- package/lib/pubsub/subscribe.d.ts.map +1 -1
- package/lib/pubsub/subscribe.js +1 -2
- package/lib/stitches/css.d.ts.map +1 -1
- package/lib/stitches/css.js +1 -0
- package/lib/stitches/to-css.js +2 -3
- package/lib/tree/create-elements-tree.d.ts.map +1 -1
- package/lib/tree/create-elements-tree.js +43 -12
- package/lib/tree/root.js +3 -3
- package/lib/tree/wrapper-component.js +2 -2
- package/lib/user-props/all-user-props.d.ts.map +1 -1
- package/lib/user-props/all-user-props.js +5 -4
- package/lib/user-props/use-user-props.js +1 -1
- package/package.json +7 -9
- package/lib/prisma.server.d.ts +0 -3
- package/lib/prisma.server.d.ts.map +0 -1
- package/lib/prisma.server.js +0 -8
- package/prisma/schema.prisma +0 -71
package/lib/css/units.js
CHANGED
package/lib/db/instance.d.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import * as components from "../components";
|
|
3
3
|
import { type CssRule } from "../css";
|
|
4
|
-
export declare type
|
|
4
|
+
export declare type BaseInstance = {
|
|
5
5
|
id: string;
|
|
6
6
|
component: keyof typeof components;
|
|
7
|
-
children: Array<Instance | string>;
|
|
8
7
|
cssRules: Array<CssRule>;
|
|
9
8
|
};
|
|
9
|
+
export declare type Instance = BaseInstance & {
|
|
10
|
+
children: Array<Instance | string>;
|
|
11
|
+
};
|
|
12
|
+
export declare const toBaseInstance: (instance: Instance) => BaseInstance;
|
|
10
13
|
export declare const InstanceSchema: z.ZodType<Instance, z.ZodTypeDef, Instance>;
|
|
11
14
|
//# sourceMappingURL=instance.d.ts.map
|
package/lib/db/instance.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instance.d.ts","sourceRoot":"","sources":["../../src/db/instance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,UAAU,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,KAAK,OAAO,EAAiB,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"instance.d.ts","sourceRoot":"","sources":["../../src/db/instance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,UAAU,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,KAAK,OAAO,EAAiB,MAAM,QAAQ,CAAC;AAIrD,oBAAY,YAAY,GAAG;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,OAAO,UAAU,CAAC;IACnC,QAAQ,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;CAC1B,CAAC;AAEF,oBAAY,QAAQ,GAAG,YAAY,GAAG;IACpC,QAAQ,EAAE,KAAK,CAAC,QAAQ,GAAG,MAAM,CAAC,CAAC;CACpC,CAAC;AAEF,eAAO,MAAM,cAAc,aAAc,QAAQ,KAAG,YAMnD,CAAC;AAEF,eAAO,MAAM,cAAc,6CASH,CAAC"}
|
package/lib/db/instance.js
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.InstanceSchema = void 0;
|
|
3
|
+
exports.InstanceSchema = exports.toBaseInstance = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const css_1 = require("../css");
|
|
6
|
+
const toBaseInstance = (instance) => {
|
|
7
|
+
return {
|
|
8
|
+
id: instance.id,
|
|
9
|
+
component: instance.component,
|
|
10
|
+
cssRules: instance.cssRules,
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
exports.toBaseInstance = toBaseInstance;
|
|
6
14
|
exports.InstanceSchema = zod_1.z.lazy(() => zod_1.z.object({
|
|
7
15
|
id: zod_1.z.string(),
|
|
8
16
|
component: zod_1.z.string(),
|
package/lib/db/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { InstanceProps as DbInstanceProps
|
|
1
|
+
import type { InstanceProps as DbInstanceProps } from "@webstudio-is/prisma-client";
|
|
2
2
|
import type { UserProp } from "../user-props";
|
|
3
3
|
import type { Instance } from "./instance";
|
|
4
4
|
export declare type Tree = {
|
|
@@ -8,5 +8,4 @@ export declare type Tree = {
|
|
|
8
8
|
export declare type InstanceProps = Omit<DbInstanceProps, "props"> & {
|
|
9
9
|
props: Array<UserProp>;
|
|
10
10
|
};
|
|
11
|
-
export type { DbInstanceProps, Project, User, Breakpoints, Asset };
|
|
12
11
|
//# sourceMappingURL=types.d.ts.map
|
package/lib/db/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/db/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/db/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,IAAI,eAAe,EAAE,MAAM,6BAA6B,CAAC;AACpF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,oBAAY,IAAI,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,QAAQ,CAAC;CAChB,CAAC;AAEF,oBAAY,aAAa,GAAG,IAAI,CAAC,eAAe,EAAE,OAAO,CAAC,GAAG;IAC3D,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;CACxB,CAAC"}
|
package/lib/pubsub/publish.js
CHANGED
|
@@ -9,7 +9,7 @@ const usePublish = () => {
|
|
|
9
9
|
const iframeRef = (0, react_1.useRef)(null);
|
|
10
10
|
const publishCallback = (0, react_1.useCallback)((action) => {
|
|
11
11
|
const element = iframeRef.current;
|
|
12
|
-
if (
|
|
12
|
+
if (element?.contentWindow == null)
|
|
13
13
|
return;
|
|
14
14
|
element.contentWindow.postMessage(action, "*");
|
|
15
15
|
window.postMessage(action, "*");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscribe.d.ts","sourceRoot":"","sources":["../../src/pubsub/subscribe.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"subscribe.d.ts","sourceRoot":"","sources":["../../src/pubsub/subscribe.ts"],"names":[],"mappings":"AAQA,aAAK,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAElC,eAAO,MAAM,OAAO,gCAAiB,CAAC;AAgBtC;;GAEG;AACH,eAAO,MAAM,YAAY,yFAES,IAAI,SAQrC,CAAC"}
|
package/lib/pubsub/subscribe.js
CHANGED
|
@@ -9,10 +9,9 @@ const react_1 = require("react");
|
|
|
9
9
|
exports.emitter = (0, mitt_1.default)();
|
|
10
10
|
if (typeof window === "object") {
|
|
11
11
|
window.addEventListener("message", (event) => {
|
|
12
|
-
var _a;
|
|
13
12
|
// @todo this has no type safety built in, could be anything from any source.
|
|
14
13
|
// we could potentially maintain a list of valid event types, but see prior contra points.
|
|
15
|
-
if (typeof
|
|
14
|
+
if (typeof event.data?.type === "string") {
|
|
16
15
|
exports.emitter.emit(event.data.type, event.data.payload);
|
|
17
16
|
}
|
|
18
17
|
}, false);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"css.d.ts","sourceRoot":"","sources":["../../src/stitches/css.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,SAAS,
|
|
1
|
+
{"version":3,"file":"css.d.ts","sourceRoot":"","sources":["../../src/stitches/css.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,SAAS,EACT,KAAK,GAAG,EACR,GAAG,IAAI,SAAS,EACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAQzC,eAAO,MAAM,eAAe,WAK3B,CAAC;AAEF,eAAO,MAAM,GAAG,EAAE,OAAO,SAExB,CAAC;AAEF,OAAO,EAAE,SAAS,EAAE,CAAC;AACrB,OAAO,EAAE,KAAK,GAAG,EAAE,CAAC;AAEpB,eAAO,MAAM,UAAU,QAAO,MAE7B,CAAC;AAEF,eAAO,MAAM,cAAc,gBAAiB,MAAM,UAAU,CAAC,SAO5D,CAAC"}
|
package/lib/stitches/css.js
CHANGED
|
@@ -5,6 +5,7 @@ const core_1 = require("@stitches/core");
|
|
|
5
5
|
Object.defineProperty(exports, "globalCss", { enumerable: true, get: function () { return core_1.globalCss; } });
|
|
6
6
|
let media = {};
|
|
7
7
|
// @todo needs fixing
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8
9
|
let stitches;
|
|
9
10
|
const getCachedConfig = () => {
|
|
10
11
|
if (stitches === undefined) {
|
package/lib/stitches/to-css.js
CHANGED
|
@@ -18,11 +18,10 @@ const toCss = (cssRules, breakpoints) => {
|
|
|
18
18
|
breakpointsMap[breakpoint.id] = breakpoint.minWidth;
|
|
19
19
|
}
|
|
20
20
|
const sortedCssRules = [...cssRules].sort((ruleA, ruleB) => {
|
|
21
|
-
var _a, _b;
|
|
22
21
|
// If a rule references a breakpoint that was not found in breakpoints,
|
|
23
22
|
// we must have removed the breakpoint and now we fall back to 0.
|
|
24
|
-
const maxWidthA =
|
|
25
|
-
const maxWidthB =
|
|
23
|
+
const maxWidthA = breakpointsMap[ruleA.breakpoint] ?? 0;
|
|
24
|
+
const maxWidthB = breakpointsMap[ruleB.breakpoint] ?? 0;
|
|
26
25
|
return maxWidthA - maxWidthB;
|
|
27
26
|
});
|
|
28
27
|
for (const cssRule of sortedCssRules) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-elements-tree.d.ts","sourceRoot":"","sources":["../../src/tree/create-elements-tree.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"create-elements-tree.d.ts","sourceRoot":"","sources":["../../src/tree/create-elements-tree.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAGjE,oBAAY,eAAe,GAAG,KAAK,CAC/B,MAAM,GAEN;IAAE,EAAE,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAEpC;IACE,EAAE,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC;IACjC,cAAc,EAAE,IAAI,CAAC;CACtB,CACJ,CAAC;AAEF,oBAAY,gBAAgB,GAAG,CAAC,MAAM,EAAE;IACtC,UAAU,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC3B,OAAO,EAAE,eAAe,CAAC;CAC1B,KAAK,IAAI,CAAC;AAEX,eAAO,MAAM,kBAAkB;cAMnB,QAAQ;iBACL,MAAM,UAAU,CAAC;uBACX,qBAAqB,KAAK,WAAW;;iBAsBzD,CAAC"}
|
|
@@ -2,20 +2,52 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createElementsTree = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
5
6
|
const stitches_1 = require("../stitches");
|
|
7
|
+
const react_2 = require("@remix-run/react");
|
|
6
8
|
const createElementsTree = ({ instance, breakpoints, Component, onChangeChildren, }) => {
|
|
7
|
-
const children =
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
const children = createInstanceChildrenElements({
|
|
10
|
+
Component,
|
|
11
|
+
children: instance.children,
|
|
12
|
+
breakpoints,
|
|
13
|
+
onChangeChildren,
|
|
14
|
+
});
|
|
15
|
+
const body = createInstanceElement({
|
|
16
|
+
Component,
|
|
17
|
+
instance,
|
|
18
|
+
children: [
|
|
19
|
+
(0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [children, (0, jsx_runtime_1.jsx)(react_2.ScrollRestoration, {}), (0, jsx_runtime_1.jsx)(react_2.Scripts, {})] }, "children"),
|
|
20
|
+
],
|
|
21
|
+
breakpoints,
|
|
22
|
+
});
|
|
23
|
+
return body;
|
|
24
|
+
};
|
|
25
|
+
exports.createElementsTree = createElementsTree;
|
|
26
|
+
const createInstanceChildrenElements = ({ children, breakpoints, Component, onChangeChildren, }) => {
|
|
27
|
+
const elements = [];
|
|
28
|
+
for (const child of children) {
|
|
29
|
+
if (typeof child === "string") {
|
|
30
|
+
elements.push(child);
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
const children = createInstanceChildrenElements({
|
|
34
|
+
children: child.children,
|
|
35
|
+
breakpoints,
|
|
36
|
+
Component,
|
|
37
|
+
onChangeChildren,
|
|
38
|
+
});
|
|
39
|
+
const element = createInstanceElement({
|
|
40
|
+
instance: child,
|
|
41
|
+
breakpoints,
|
|
42
|
+
Component,
|
|
43
|
+
onChangeChildren,
|
|
44
|
+
children,
|
|
45
|
+
});
|
|
46
|
+
elements.push(element);
|
|
18
47
|
}
|
|
48
|
+
return elements;
|
|
49
|
+
};
|
|
50
|
+
const createInstanceElement = ({ Component, instance, children = [], breakpoints, onChangeChildren, }) => {
|
|
19
51
|
const props = {
|
|
20
52
|
instance,
|
|
21
53
|
children,
|
|
@@ -25,4 +57,3 @@ const createElementsTree = ({ instance, breakpoints, Component, onChangeChildren
|
|
|
25
57
|
};
|
|
26
58
|
return (0, jsx_runtime_1.jsx)(Component, { ...props });
|
|
27
59
|
};
|
|
28
|
-
exports.createElementsTree = createElementsTree;
|
package/lib/tree/root.js
CHANGED
|
@@ -6,8 +6,8 @@ const stitches_1 = require("../stitches");
|
|
|
6
6
|
const create_elements_tree_1 = require("./create-elements-tree");
|
|
7
7
|
const wrapper_component_1 = require("./wrapper-component");
|
|
8
8
|
exports.globalStyles = (0, stitches_1.globalCss)({
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
html: {
|
|
10
|
+
height: "100%",
|
|
11
11
|
},
|
|
12
12
|
});
|
|
13
13
|
const Root = ({ data, Component }) => {
|
|
@@ -20,7 +20,7 @@ const Root = ({ data, Component }) => {
|
|
|
20
20
|
return (0, create_elements_tree_1.createElementsTree)({
|
|
21
21
|
instance: data.tree.root,
|
|
22
22
|
breakpoints: data.breakpoints,
|
|
23
|
-
Component: Component
|
|
23
|
+
Component: Component ?? wrapper_component_1.WrapperComponent,
|
|
24
24
|
});
|
|
25
25
|
};
|
|
26
26
|
exports.Root = Root;
|
|
@@ -43,10 +43,10 @@ const renderWrapperComponentChildren = (children) => {
|
|
|
43
43
|
});
|
|
44
44
|
};
|
|
45
45
|
exports.renderWrapperComponentChildren = renderWrapperComponentChildren;
|
|
46
|
-
const WrapperComponent = ({ instance, css, onChangeChildren, // prevent it from passing to
|
|
46
|
+
const WrapperComponent = ({ instance, css, onChangeChildren, // prevent it from passing to sdk component
|
|
47
47
|
children, ...rest }) => {
|
|
48
48
|
const className = (0, react_1.useMemo)(() => (0, stitches_1.css)(css)(), [css]);
|
|
49
|
-
const Component = components[instance.component];
|
|
49
|
+
const { Component } = components[instance.component];
|
|
50
50
|
const userProps = (0, use_user_props_1.useUserProps)(instance.id);
|
|
51
51
|
return ((0, jsx_runtime_1.jsx)(Component, { ...userProps, ...rest, id: instance.id, className: className, children: (0, exports.renderWrapperComponentChildren)(children) }));
|
|
52
52
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"all-user-props.d.ts","sourceRoot":"","sources":["../../src/user-props/all-user-props.ts"],"names":[],"mappings":";AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAErD,oBAAY,YAAY,GAAG;IAAE,CAAC,EAAE,EAAE,QAAQ,CAAC,IAAI,CAAC,GAAG,aAAa,CAAA;CAAE,CAAC;AAEnE,eAAO,MAAM,qBAAqB,yDAAyC,CAAC;AAE5E,eAAO,MAAM,eAAe,sBAAuB,MAAM,aAAa,CAAC,
|
|
1
|
+
{"version":3,"file":"all-user-props.d.ts","sourceRoot":"","sources":["../../src/user-props/all-user-props.ts"],"names":[],"mappings":";AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAErD,oBAAY,YAAY,GAAG;IAAE,CAAC,EAAE,EAAE,QAAQ,CAAC,IAAI,CAAC,GAAG,aAAa,CAAA;CAAE,CAAC;AAEnE,eAAO,MAAM,qBAAqB,yDAAyC,CAAC;AAE5E,eAAO,MAAM,eAAe,sBAAuB,MAAM,aAAa,CAAC,sEAatE,CAAC"}
|
|
@@ -5,16 +5,17 @@ const react_1 = require("react");
|
|
|
5
5
|
const react_nano_state_1 = require("react-nano-state");
|
|
6
6
|
exports.allUserPropsContainer = (0, react_nano_state_1.createValueContainer)({});
|
|
7
7
|
const useAllUserProps = (initialUserProps) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
// @todo ssr workaround for https://github.com/webstudio-is/webstudio-designer/issues/213
|
|
9
|
+
const ref = (0, react_1.useRef)(false);
|
|
10
|
+
if (ref.current === false && initialUserProps !== undefined) {
|
|
11
11
|
const propsMap = {};
|
|
12
12
|
for (const props of initialUserProps) {
|
|
13
13
|
propsMap[props.instanceId] = props;
|
|
14
14
|
}
|
|
15
15
|
//We don't need to trigger rerender when setting the initial value
|
|
16
16
|
exports.allUserPropsContainer.value = propsMap;
|
|
17
|
-
|
|
17
|
+
ref.current = true;
|
|
18
|
+
}
|
|
18
19
|
return (0, react_nano_state_1.useValue)(exports.allUserPropsContainer);
|
|
19
20
|
};
|
|
20
21
|
exports.useAllUserProps = useAllUserProps;
|
|
@@ -8,7 +8,7 @@ const all_user_props_1 = require("./all-user-props");
|
|
|
8
8
|
* up to date with props panel.
|
|
9
9
|
*/
|
|
10
10
|
const useUserProps = (instanceId) => {
|
|
11
|
-
const [allUserProps
|
|
11
|
+
const [allUserProps] = (0, all_user_props_1.useAllUserProps)();
|
|
12
12
|
const propsData = allUserProps[instanceId];
|
|
13
13
|
const initialUserProps = (0, react_1.useMemo)(() => {
|
|
14
14
|
if (propsData === undefined)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webstudio-is/react-sdk",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Webstudio JavaScript / TypeScript API",
|
|
5
5
|
"author": "Webstudio <github@webstudio.is>",
|
|
6
6
|
"homepage": "https://webstudio.is",
|
|
@@ -8,13 +8,12 @@
|
|
|
8
8
|
"dev": "tsup src/index.ts --format esm,cjs --watch --out-dir=lib",
|
|
9
9
|
"build": "yarn build:mdn-data && yarn build:args && yarn build:lib",
|
|
10
10
|
"build:mdn-data": "node --experimental-loader esbuild-node-loader ./bin/mdn-data.ts ./src/css",
|
|
11
|
-
"build:args": "node --experimental-loader esbuild-node-loader ./bin/generate-arg-types.ts './src/components/*.tsx !./src/**/*.stories.tsx'",
|
|
12
|
-
"build:prisma": "prisma format && prisma generate",
|
|
11
|
+
"build:args": "node --experimental-loader esbuild-node-loader ./bin/generate-arg-types.ts './src/components/*.tsx !./src/**/*.stories.tsx !./src/**/*.ws.tsx'",
|
|
13
12
|
"typecheck": "tsc --noEmit",
|
|
14
13
|
"build:lib": "rm -fr lib && tsc",
|
|
15
|
-
"postinstall": "prisma generate",
|
|
16
14
|
"test": "jest",
|
|
17
|
-
"
|
|
15
|
+
"lint": "eslint ./src --ext .ts,.tsx --max-warnings 0",
|
|
16
|
+
"checks": "yarn typecheck && yarn lint && yarn test",
|
|
18
17
|
"prepublishOnly": "yarn checks && yarn build:lib",
|
|
19
18
|
"storybook:run": "start-storybook -p 6006",
|
|
20
19
|
"storybook:build": "build-storybook"
|
|
@@ -45,6 +44,7 @@
|
|
|
45
44
|
"react": "^17.0.2",
|
|
46
45
|
"react-docgen-typescript": "^2.2.2",
|
|
47
46
|
"react-dom": "^17.0.2",
|
|
47
|
+
"@webstudio-is/prisma-client": "*",
|
|
48
48
|
"tsup": "^6.1.3",
|
|
49
49
|
"typescript": "^4.6.2"
|
|
50
50
|
},
|
|
@@ -56,11 +56,10 @@
|
|
|
56
56
|
"react-dom": "^17.0.2"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@prisma/client": "^3.10.0",
|
|
60
59
|
"@stitches/core": "^1.2.7",
|
|
60
|
+
"@webstudio-is/icons": "*",
|
|
61
61
|
"immer": "^9.0.12",
|
|
62
62
|
"mitt": "^3.0.0",
|
|
63
|
-
"prisma": "^3.10.0",
|
|
64
63
|
"react-nano-state": "^0.4.0",
|
|
65
64
|
"@webstudio-is/jest-config": "*",
|
|
66
65
|
"zod": "^3.17.3"
|
|
@@ -70,8 +69,7 @@
|
|
|
70
69
|
"files": [
|
|
71
70
|
"lib/*",
|
|
72
71
|
"README.md",
|
|
73
|
-
"!*.test.*"
|
|
74
|
-
"prisma/*"
|
|
72
|
+
"!*.test.*"
|
|
75
73
|
],
|
|
76
74
|
"license": "MIT",
|
|
77
75
|
"private": false
|
package/lib/prisma.server.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prisma.server.d.ts","sourceRoot":"","sources":["../src/prisma.server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,6BAA6B,EAAE,MAAM,wBAAwB,CAAC"}
|
package/lib/prisma.server.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PrismaClientKnownRequestError = exports.Prisma = exports.PrismaClient = void 0;
|
|
4
|
-
var client_1 = require("@prisma/client");
|
|
5
|
-
Object.defineProperty(exports, "PrismaClient", { enumerable: true, get: function () { return client_1.PrismaClient; } });
|
|
6
|
-
Object.defineProperty(exports, "Prisma", { enumerable: true, get: function () { return client_1.Prisma; } });
|
|
7
|
-
var runtime_1 = require("@prisma/client/runtime");
|
|
8
|
-
Object.defineProperty(exports, "PrismaClientKnownRequestError", { enumerable: true, get: function () { return runtime_1.PrismaClientKnownRequestError; } });
|
package/prisma/schema.prisma
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
// This is your Prisma schema file,
|
|
2
|
-
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
|
3
|
-
|
|
4
|
-
generator client {
|
|
5
|
-
provider = "prisma-client-js"
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
datasource db {
|
|
9
|
-
provider = "postgres"
|
|
10
|
-
url = env("DATABASE_URL")
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
model Team {
|
|
14
|
-
id String @id @default(uuid())
|
|
15
|
-
users User[]
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
model Asset {
|
|
19
|
-
id String @id @default(uuid())
|
|
20
|
-
project Project @relation(fields: [projectId], references: [id])
|
|
21
|
-
projectId String
|
|
22
|
-
format String?
|
|
23
|
-
size Int
|
|
24
|
-
width Decimal?
|
|
25
|
-
height Decimal?
|
|
26
|
-
name String
|
|
27
|
-
path String
|
|
28
|
-
alt String?
|
|
29
|
-
createdAt DateTime @default(now())
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
model User {
|
|
33
|
-
id String @id @default(uuid())
|
|
34
|
-
email String? @unique
|
|
35
|
-
provider String?
|
|
36
|
-
image String?
|
|
37
|
-
username String?
|
|
38
|
-
createdAt DateTime @default(now())
|
|
39
|
-
Team Team? @relation(fields: [teamId], references: [id])
|
|
40
|
-
teamId String?
|
|
41
|
-
projects Project[]
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
model Project {
|
|
45
|
-
id String @id @default(uuid())
|
|
46
|
-
title String
|
|
47
|
-
domain String @unique
|
|
48
|
-
prodTreeId String? // exists when published
|
|
49
|
-
devTreeId String
|
|
50
|
-
prodTreeIdHistory String @default("[]")
|
|
51
|
-
User User? @relation(fields: [userId], references: [id])
|
|
52
|
-
userId String?
|
|
53
|
-
Asset Asset[]
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
model Tree {
|
|
57
|
-
id String @id @default(uuid())
|
|
58
|
-
root String
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
model InstanceProps {
|
|
62
|
-
id String @id @default(uuid())
|
|
63
|
-
instanceId String
|
|
64
|
-
treeId String
|
|
65
|
-
props String @default("[]")
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
model Breakpoints {
|
|
69
|
-
treeId String @id @default(uuid())
|
|
70
|
-
values String @default("[]")
|
|
71
|
-
}
|