@webstudio-is/react-sdk 0.7.0 → 0.7.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 +1 -8
- package/lib/arg-types/utils.d.ts.map +1 -1
- package/lib/arg-types/utils.js +18 -7
- package/lib/component-utils/image.d.ts +107 -0
- package/lib/component-utils/image.d.ts.map +1 -0
- package/lib/component-utils/image.js +198 -0
- package/lib/component-utils/image.test.d.ts +2 -0
- package/lib/component-utils/image.test.d.ts.map +1 -0
- package/lib/component-utils/image.test.js +132 -0
- package/lib/components/body.props.json +8 -37
- package/lib/components/bold.props.json +8 -37
- package/lib/components/box.props.json +9 -40
- package/lib/components/button.props.json +10 -45
- package/lib/components/component-type.d.ts +1 -1
- package/lib/components/component-type.d.ts.map +1 -1
- package/lib/components/form.props.json +8 -37
- package/lib/components/heading.props.json +10 -48
- package/lib/components/image-dev.stories.d.ts +36 -0
- package/lib/components/image-dev.stories.d.ts.map +1 -0
- package/lib/components/image-dev.stories.js +102 -0
- package/lib/components/image.d.ts +10 -2
- package/lib/components/image.d.ts.map +1 -1
- package/lib/components/image.js +19 -9
- package/lib/components/image.props.json +60 -15
- package/lib/components/image.stories.d.ts +10 -2
- package/lib/components/image.stories.d.ts.map +1 -1
- package/lib/components/image.ws.d.ts.map +1 -1
- package/lib/components/image.ws.js +15 -0
- package/lib/components/index.d.ts +3 -0
- package/lib/components/index.d.ts.map +1 -1
- package/lib/components/index.js +7 -1
- package/lib/components/input.props.json +9 -46
- package/lib/components/italic.props.json +8 -37
- package/lib/components/link.d.ts +1 -1
- package/lib/components/link.props.json +9 -40
- package/lib/components/link.stories.d.ts +2 -2
- package/lib/components/meta.d.ts +3 -0
- package/lib/components/meta.d.ts.map +1 -1
- package/lib/components/meta.js +7 -1
- package/lib/components/paragraph.props.json +8 -37
- package/lib/components/span.d.ts +3 -0
- package/lib/components/span.d.ts.map +1 -0
- package/lib/components/span.js +8 -0
- package/lib/components/span.props.json +2205 -0
- package/lib/components/span.stories.d.ts +6 -0
- package/lib/components/span.stories.d.ts.map +1 -0
- package/lib/components/span.stories.js +19 -0
- package/lib/components/span.ws.d.ts +5 -0
- package/lib/components/span.ws.d.ts.map +1 -0
- package/lib/components/span.ws.js +14 -0
- package/lib/components/subscript.d.ts +3 -0
- package/lib/components/subscript.d.ts.map +1 -0
- package/lib/components/subscript.js +8 -0
- package/lib/components/subscript.props.json +2205 -0
- package/lib/components/subscript.stories.d.ts +6 -0
- package/lib/components/subscript.stories.d.ts.map +1 -0
- package/lib/components/subscript.stories.js +19 -0
- package/lib/components/subscript.ws.d.ts +5 -0
- package/lib/components/subscript.ws.d.ts.map +1 -0
- package/lib/components/subscript.ws.js +14 -0
- package/lib/components/superscript.d.ts +3 -0
- package/lib/components/superscript.d.ts.map +1 -0
- package/lib/components/superscript.js +8 -0
- package/lib/components/superscript.props.json +2205 -0
- package/lib/components/superscript.stories.d.ts +6 -0
- package/lib/components/superscript.stories.d.ts.map +1 -0
- package/lib/components/superscript.stories.js +19 -0
- package/lib/components/superscript.ws.d.ts +5 -0
- package/lib/components/superscript.ws.d.ts.map +1 -0
- package/lib/components/superscript.ws.js +14 -0
- package/lib/components/text-block.props.json +8 -37
- package/lib/css/breakpoints.d.ts +1 -1
- package/lib/css/breakpoints.d.ts.map +1 -1
- package/lib/css/categories.d.ts +2 -2
- package/lib/css/get-browser-style.d.ts +1 -1
- package/lib/css/get-browser-style.d.ts.map +1 -1
- package/lib/css/get-browser-style.js +10 -5
- package/lib/css/index.d.ts +0 -5
- package/lib/css/index.d.ts.map +1 -1
- package/lib/css/index.js +0 -5
- package/lib/db/instance.d.ts +1 -1
- package/lib/db/instance.d.ts.map +1 -1
- package/lib/db/instance.js +2 -2
- package/lib/index.d.ts +0 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +0 -1
- package/lib/pubsub/create.d.ts +1 -0
- package/lib/pubsub/create.d.ts.map +1 -1
- package/lib/pubsub/create.js +8 -0
- package/lib/remix/handle-request.server.d.ts.map +1 -1
- package/lib/remix/handle-request.server.js +1 -2
- package/lib/remix/root.d.ts.map +1 -1
- package/lib/remix/root.js +2 -2
- package/lib/tree/create-elements-tree.d.ts +7 -11
- package/lib/tree/create-elements-tree.d.ts.map +1 -1
- package/lib/tree/create-elements-tree.js +5 -10
- package/lib/tree/root.d.ts +4 -6
- package/lib/tree/root.d.ts.map +1 -1
- package/lib/tree/root.js +1 -23
- package/lib/tree/session-storage-polyfill.d.ts +2 -0
- package/lib/tree/session-storage-polyfill.d.ts.map +1 -0
- package/lib/tree/session-storage-polyfill.js +39 -0
- package/lib/tree/wrapper-component.d.ts +4 -4
- package/lib/tree/wrapper-component.d.ts.map +1 -1
- package/lib/tree/wrapper-component.js +5 -5
- package/package.json +20 -13
- package/lib/css/keyword-values.d.ts +0 -302
- package/lib/css/keyword-values.d.ts.map +0 -1
- package/lib/css/keyword-values.js +0 -6619
- package/lib/css/properties.d.ts +0 -3199
- package/lib/css/properties.d.ts.map +0 -1
- package/lib/css/properties.js +0 -3202
- package/lib/css/schema.d.ts +0 -283
- package/lib/css/schema.d.ts.map +0 -1
- package/lib/css/schema.js +0 -48
- package/lib/css/types.d.ts +0 -6
- package/lib/css/types.d.ts.map +0 -1
- package/lib/css/types.js +0 -2
- package/lib/css/units.d.ts +0 -2
- package/lib/css/units.d.ts.map +0 -1
- package/lib/css/units.js +0 -35
- package/lib/remix/constants.d.ts +0 -2
- package/lib/remix/constants.d.ts.map +0 -1
- package/lib/remix/constants.js +0 -4
- package/lib/remix/insert-critical-css.d.ts +0 -2
- package/lib/remix/insert-critical-css.d.ts.map +0 -1
- package/lib/remix/insert-critical-css.js +0 -9
- package/lib/stitches/index.d.ts +0 -3
- package/lib/stitches/index.d.ts.map +0 -1
- package/lib/stitches/index.js +0 -18
- package/lib/stitches/stitches.d.ts +0 -8
- package/lib/stitches/stitches.d.ts.map +0 -1
- package/lib/stitches/stitches.js +0 -38
- package/lib/stitches/to-css.d.ts +0 -8
- package/lib/stitches/to-css.d.ts.map +0 -1
- package/lib/stitches/to-css.js +0 -52
- package/lib/stitches/to-css.test.d.ts +0 -2
- package/lib/stitches/to-css.test.d.ts.map +0 -1
- package/lib/stitches/to-css.test.js +0 -82
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SessionStoragePolyfill = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
// This is a temporary work around for https://github.com/remix-run/remix/issues/3659
|
|
6
|
+
// The code is based on this discussion https://bugs.chromium.org/p/chromium/issues/detail?id=357625
|
|
7
|
+
const polyfill = function () {
|
|
8
|
+
try {
|
|
9
|
+
const key = "__session_storage_availability_test__";
|
|
10
|
+
sessionStorage.setItem(key, "test"); // test
|
|
11
|
+
sessionStorage.removeItem(key); // cleanup
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
alert('It looks like you have disabled cookies in your browser. Webstudio designer may not work properly.\n\nTo enable cookies, go to "Setting" > "Privacy and security" > "Cookies and other site data", and make sure neither "Block all cookies" nor "Block third-party cookies" are selected.\n\nRead more at https://support.google.com/chrome/answer/95647');
|
|
15
|
+
const data = new Map();
|
|
16
|
+
Object.defineProperty(window, "sessionStorage", {
|
|
17
|
+
value: {
|
|
18
|
+
setItem: (key, val) => {
|
|
19
|
+
// eslint-disable-next-line no-console
|
|
20
|
+
console.warn(`Session storage is unavailable due to Error "${error.message}". A polyfill is used to set value of "${key}". The value will be lost when the page is reloaded.`);
|
|
21
|
+
data.set(key, String(val));
|
|
22
|
+
},
|
|
23
|
+
getItem: (key) => {
|
|
24
|
+
// eslint-disable-next-line no-console
|
|
25
|
+
console.warn(`Session storage is unavailable due to Error "${error.message}". A polyfill is used to get value of "${key}". The value will be undefined if the page was reloaded after it was set.`);
|
|
26
|
+
return data.get(key);
|
|
27
|
+
},
|
|
28
|
+
removeItem: (key) => {
|
|
29
|
+
data.delete(key);
|
|
30
|
+
},
|
|
31
|
+
clear: () => {
|
|
32
|
+
data.clear();
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}.toString();
|
|
38
|
+
const SessionStoragePolyfill = () => ((0, jsx_runtime_1.jsx)("script", { dangerouslySetInnerHTML: { __html: `(${polyfill})()` }, suppressHydrationWarning: true }));
|
|
39
|
+
exports.SessionStoragePolyfill = SessionStoragePolyfill;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { Instance } from "../db";
|
|
2
|
-
import { type CSS } from "../stitches";
|
|
3
2
|
import type { OnChangeChildren } from "./create-elements-tree";
|
|
4
3
|
export declare const renderWrapperComponentChildren: (children: Array<JSX.Element | string> | undefined) => Array<JSX.Element | string | Array<JSX.Element | string>> | undefined;
|
|
5
|
-
|
|
4
|
+
declare type WrapperComponentProps = {
|
|
6
5
|
instance: Instance;
|
|
7
|
-
css: CSS;
|
|
8
6
|
children: Array<JSX.Element | string>;
|
|
9
7
|
onChangeChildren?: OnChangeChildren;
|
|
10
8
|
};
|
|
11
|
-
export declare const WrapperComponent: ({ instance,
|
|
9
|
+
export declare const WrapperComponent: ({ instance, onChangeChildren, children, ...rest }: WrapperComponentProps) => JSX.Element;
|
|
10
|
+
export declare const idAttribute = "data-ws-id";
|
|
11
|
+
export {};
|
|
12
12
|
//# sourceMappingURL=wrapper-component.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrapper-component.d.ts","sourceRoot":"","sources":["../../src/tree/wrapper-component.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGtC,OAAO,
|
|
1
|
+
{"version":3,"file":"wrapper-component.d.ts","sourceRoot":"","sources":["../../src/tree/wrapper-component.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGtC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAY/D,eAAO,MAAM,8BAA8B,aAC/B,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,SAAS,KAChD,MAAM,WAAW,GAAG,MAAM,GAAG,MAAM,WAAW,GAAG,MAAM,CAAC,CAAC,GAAG,SAO9D,CAAC;AAEF,aAAK,qBAAqB,GAAG;IAC3B,QAAQ,EAAE,QAAQ,CAAC;IACnB,QAAQ,EAAE,KAAK,CAAC,GAAG,CAAC,OAAO,GAAG,MAAM,CAAC,CAAC;IACtC,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;CACrC,CAAC;AAEF,eAAO,MAAM,gBAAgB,sDAK1B,qBAAqB,gBAOvB,CAAC;AAEF,eAAO,MAAM,WAAW,eAAe,CAAC"}
|
|
@@ -23,12 +23,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.WrapperComponent = exports.renderWrapperComponentChildren = void 0;
|
|
26
|
+
exports.idAttribute = exports.WrapperComponent = exports.renderWrapperComponentChildren = void 0;
|
|
27
27
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
28
28
|
const react_1 = require("react");
|
|
29
29
|
const components = __importStar(require("../components"));
|
|
30
30
|
const use_user_props_1 = require("../user-props/use-user-props");
|
|
31
|
-
const stitches_1 = require("../stitches");
|
|
32
31
|
const renderText = (text) => {
|
|
33
32
|
const lines = text.split("\n");
|
|
34
33
|
return lines.map((line, index) => ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [line, index < lines.length - 1 ? (0, jsx_runtime_1.jsx)("br", {}) : null] }, index)));
|
|
@@ -43,11 +42,12 @@ const renderWrapperComponentChildren = (children) => {
|
|
|
43
42
|
});
|
|
44
43
|
};
|
|
45
44
|
exports.renderWrapperComponentChildren = renderWrapperComponentChildren;
|
|
46
|
-
const WrapperComponent = ({ instance,
|
|
45
|
+
const WrapperComponent = ({ instance, onChangeChildren, // prevent it from passing to sdk component
|
|
47
46
|
children, ...rest }) => {
|
|
48
|
-
const className = (0, react_1.useMemo)(() => (0, stitches_1.css)(css)(), [css]);
|
|
49
47
|
const { Component } = components[instance.component];
|
|
50
48
|
const userProps = (0, use_user_props_1.useUserProps)(instance.id);
|
|
51
|
-
|
|
49
|
+
const props = { ...userProps, ...rest, [exports.idAttribute]: instance.id };
|
|
50
|
+
return ((0, jsx_runtime_1.jsx)(Component, { ...props, children: (0, exports.renderWrapperComponentChildren)(children) }));
|
|
52
51
|
};
|
|
53
52
|
exports.WrapperComponent = WrapperComponent;
|
|
53
|
+
exports.idAttribute = "data-ws-id";
|
package/package.json
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webstudio-is/react-sdk",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"description": "Webstudio JavaScript / TypeScript API",
|
|
5
5
|
"author": "Webstudio <github@webstudio.is>",
|
|
6
6
|
"homepage": "https://webstudio.is",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"dev": "tsup
|
|
8
|
+
"dev": "tsup --watch",
|
|
9
9
|
"build": "yarn build:lib",
|
|
10
|
-
"build:mdn-data": "tsx ./bin/mdn-data.ts ./src/css",
|
|
11
10
|
"build:args": "tsx ./bin/generate-arg-types.ts './src/components/*.tsx !./src/**/*.stories.tsx !./src/**/*.ws.tsx'",
|
|
12
11
|
"typecheck": "tsc --noEmit",
|
|
13
12
|
"build:lib": "rm -fr lib tsconfig.tsbuildinfo && tsc",
|
|
@@ -23,6 +22,7 @@
|
|
|
23
22
|
"@esbuild-kit/esm-loader": "^2.4.2",
|
|
24
23
|
"@remix-run/react": "^1.2.3",
|
|
25
24
|
"@remix-run/server-runtime": "^1.2.3",
|
|
25
|
+
"remix-utils": "^4.1.0",
|
|
26
26
|
"@storybook/addon-actions": "^6.5.6",
|
|
27
27
|
"@storybook/addon-essentials": "^6.5.6",
|
|
28
28
|
"@storybook/addon-interactions": "^6.5.6",
|
|
@@ -31,41 +31,40 @@
|
|
|
31
31
|
"@storybook/manager-webpack4": "^6.5.6",
|
|
32
32
|
"@storybook/react": "^6.5.6",
|
|
33
33
|
"@storybook/testing-library": "^0.0.11",
|
|
34
|
-
"@types/css-tree": "^1.0.7",
|
|
35
34
|
"@types/fs-extra": "^9.0.13",
|
|
36
35
|
"@types/node": "^17.0.21",
|
|
37
36
|
"@webstudio-is/jest-config": "*",
|
|
38
37
|
"@webstudio-is/prisma-client": "*",
|
|
39
38
|
"babel-loader": "^8.2.5",
|
|
40
|
-
"camelcase": "^6.3.0",
|
|
41
|
-
"css-tree": "^2.1.0",
|
|
42
39
|
"esbuild": "^0.14.25",
|
|
43
40
|
"esbuild-node-externals": "^1.4.1",
|
|
44
|
-
"mdn-data": "2.0.23",
|
|
45
41
|
"react": "^17.0.2",
|
|
46
42
|
"react-docgen-typescript": "^2.2.2",
|
|
47
43
|
"react-dom": "^17.0.2",
|
|
48
44
|
"tsup": "^6.1.3",
|
|
49
45
|
"tsx": "^3.9.0",
|
|
50
|
-
"typescript": "4.7.4"
|
|
46
|
+
"typescript": "4.7.4",
|
|
47
|
+
"zod": "^3.19.1"
|
|
51
48
|
},
|
|
52
49
|
"peerDependencies": {
|
|
53
50
|
"@remix-run/react": "^1.2.3",
|
|
54
51
|
"@remix-run/server-runtime": "^1.2.3",
|
|
52
|
+
"remix-utils": "^4.1.0",
|
|
55
53
|
"@storybook/react": "^6.5.6",
|
|
56
54
|
"react": "^17.0.2",
|
|
57
|
-
"react-dom": "^17.0.2"
|
|
55
|
+
"react-dom": "^17.0.2",
|
|
56
|
+
"zod": "^3.19.1"
|
|
58
57
|
},
|
|
59
58
|
"dependencies": {
|
|
60
|
-
"@stitches/core": "^1.2.7",
|
|
61
59
|
"@webstudio-is/asset-uploader": "^*",
|
|
60
|
+
"@webstudio-is/fonts": "*",
|
|
62
61
|
"@webstudio-is/icons": "*",
|
|
62
|
+
"@webstudio-is/css-data": "*",
|
|
63
63
|
"@webstudio-is/jest-config": "*",
|
|
64
|
-
"@webstudio-is/fonts": "*",
|
|
65
64
|
"immer": "^9.0.12",
|
|
66
65
|
"mitt": "^3.0.0",
|
|
67
66
|
"react-nano-state": "^0.4.0",
|
|
68
|
-
"
|
|
67
|
+
"warn-once": "^0.1.1"
|
|
69
68
|
},
|
|
70
69
|
"main": "lib/index.js",
|
|
71
70
|
"types": "lib/index.d.ts",
|
|
@@ -75,5 +74,13 @@
|
|
|
75
74
|
"!*.test.*"
|
|
76
75
|
],
|
|
77
76
|
"license": "MIT",
|
|
78
|
-
"private": false
|
|
77
|
+
"private": false,
|
|
78
|
+
"sideEffects": false,
|
|
79
|
+
"tsup": {
|
|
80
|
+
"entry": [
|
|
81
|
+
"src/index.ts"
|
|
82
|
+
],
|
|
83
|
+
"format": "cjs",
|
|
84
|
+
"outDir": "lib"
|
|
85
|
+
}
|
|
79
86
|
}
|