@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.
Files changed (139) hide show
  1. package/lib/arg-types/utils.d.ts +1 -8
  2. package/lib/arg-types/utils.d.ts.map +1 -1
  3. package/lib/arg-types/utils.js +18 -7
  4. package/lib/component-utils/image.d.ts +107 -0
  5. package/lib/component-utils/image.d.ts.map +1 -0
  6. package/lib/component-utils/image.js +198 -0
  7. package/lib/component-utils/image.test.d.ts +2 -0
  8. package/lib/component-utils/image.test.d.ts.map +1 -0
  9. package/lib/component-utils/image.test.js +132 -0
  10. package/lib/components/body.props.json +8 -37
  11. package/lib/components/bold.props.json +8 -37
  12. package/lib/components/box.props.json +9 -40
  13. package/lib/components/button.props.json +10 -45
  14. package/lib/components/component-type.d.ts +1 -1
  15. package/lib/components/component-type.d.ts.map +1 -1
  16. package/lib/components/form.props.json +8 -37
  17. package/lib/components/heading.props.json +10 -48
  18. package/lib/components/image-dev.stories.d.ts +36 -0
  19. package/lib/components/image-dev.stories.d.ts.map +1 -0
  20. package/lib/components/image-dev.stories.js +102 -0
  21. package/lib/components/image.d.ts +10 -2
  22. package/lib/components/image.d.ts.map +1 -1
  23. package/lib/components/image.js +19 -9
  24. package/lib/components/image.props.json +60 -15
  25. package/lib/components/image.stories.d.ts +10 -2
  26. package/lib/components/image.stories.d.ts.map +1 -1
  27. package/lib/components/image.ws.d.ts.map +1 -1
  28. package/lib/components/image.ws.js +15 -0
  29. package/lib/components/index.d.ts +3 -0
  30. package/lib/components/index.d.ts.map +1 -1
  31. package/lib/components/index.js +7 -1
  32. package/lib/components/input.props.json +9 -46
  33. package/lib/components/italic.props.json +8 -37
  34. package/lib/components/link.d.ts +1 -1
  35. package/lib/components/link.props.json +9 -40
  36. package/lib/components/link.stories.d.ts +2 -2
  37. package/lib/components/meta.d.ts +3 -0
  38. package/lib/components/meta.d.ts.map +1 -1
  39. package/lib/components/meta.js +7 -1
  40. package/lib/components/paragraph.props.json +8 -37
  41. package/lib/components/span.d.ts +3 -0
  42. package/lib/components/span.d.ts.map +1 -0
  43. package/lib/components/span.js +8 -0
  44. package/lib/components/span.props.json +2205 -0
  45. package/lib/components/span.stories.d.ts +6 -0
  46. package/lib/components/span.stories.d.ts.map +1 -0
  47. package/lib/components/span.stories.js +19 -0
  48. package/lib/components/span.ws.d.ts +5 -0
  49. package/lib/components/span.ws.d.ts.map +1 -0
  50. package/lib/components/span.ws.js +14 -0
  51. package/lib/components/subscript.d.ts +3 -0
  52. package/lib/components/subscript.d.ts.map +1 -0
  53. package/lib/components/subscript.js +8 -0
  54. package/lib/components/subscript.props.json +2205 -0
  55. package/lib/components/subscript.stories.d.ts +6 -0
  56. package/lib/components/subscript.stories.d.ts.map +1 -0
  57. package/lib/components/subscript.stories.js +19 -0
  58. package/lib/components/subscript.ws.d.ts +5 -0
  59. package/lib/components/subscript.ws.d.ts.map +1 -0
  60. package/lib/components/subscript.ws.js +14 -0
  61. package/lib/components/superscript.d.ts +3 -0
  62. package/lib/components/superscript.d.ts.map +1 -0
  63. package/lib/components/superscript.js +8 -0
  64. package/lib/components/superscript.props.json +2205 -0
  65. package/lib/components/superscript.stories.d.ts +6 -0
  66. package/lib/components/superscript.stories.d.ts.map +1 -0
  67. package/lib/components/superscript.stories.js +19 -0
  68. package/lib/components/superscript.ws.d.ts +5 -0
  69. package/lib/components/superscript.ws.d.ts.map +1 -0
  70. package/lib/components/superscript.ws.js +14 -0
  71. package/lib/components/text-block.props.json +8 -37
  72. package/lib/css/breakpoints.d.ts +1 -1
  73. package/lib/css/breakpoints.d.ts.map +1 -1
  74. package/lib/css/categories.d.ts +2 -2
  75. package/lib/css/get-browser-style.d.ts +1 -1
  76. package/lib/css/get-browser-style.d.ts.map +1 -1
  77. package/lib/css/get-browser-style.js +10 -5
  78. package/lib/css/index.d.ts +0 -5
  79. package/lib/css/index.d.ts.map +1 -1
  80. package/lib/css/index.js +0 -5
  81. package/lib/db/instance.d.ts +1 -1
  82. package/lib/db/instance.d.ts.map +1 -1
  83. package/lib/db/instance.js +2 -2
  84. package/lib/index.d.ts +0 -1
  85. package/lib/index.d.ts.map +1 -1
  86. package/lib/index.js +0 -1
  87. package/lib/pubsub/create.d.ts +1 -0
  88. package/lib/pubsub/create.d.ts.map +1 -1
  89. package/lib/pubsub/create.js +8 -0
  90. package/lib/remix/handle-request.server.d.ts.map +1 -1
  91. package/lib/remix/handle-request.server.js +1 -2
  92. package/lib/remix/root.d.ts.map +1 -1
  93. package/lib/remix/root.js +2 -2
  94. package/lib/tree/create-elements-tree.d.ts +7 -11
  95. package/lib/tree/create-elements-tree.d.ts.map +1 -1
  96. package/lib/tree/create-elements-tree.js +5 -10
  97. package/lib/tree/root.d.ts +4 -6
  98. package/lib/tree/root.d.ts.map +1 -1
  99. package/lib/tree/root.js +1 -23
  100. package/lib/tree/session-storage-polyfill.d.ts +2 -0
  101. package/lib/tree/session-storage-polyfill.d.ts.map +1 -0
  102. package/lib/tree/session-storage-polyfill.js +39 -0
  103. package/lib/tree/wrapper-component.d.ts +4 -4
  104. package/lib/tree/wrapper-component.d.ts.map +1 -1
  105. package/lib/tree/wrapper-component.js +5 -5
  106. package/package.json +20 -13
  107. package/lib/css/keyword-values.d.ts +0 -302
  108. package/lib/css/keyword-values.d.ts.map +0 -1
  109. package/lib/css/keyword-values.js +0 -6619
  110. package/lib/css/properties.d.ts +0 -3199
  111. package/lib/css/properties.d.ts.map +0 -1
  112. package/lib/css/properties.js +0 -3202
  113. package/lib/css/schema.d.ts +0 -283
  114. package/lib/css/schema.d.ts.map +0 -1
  115. package/lib/css/schema.js +0 -48
  116. package/lib/css/types.d.ts +0 -6
  117. package/lib/css/types.d.ts.map +0 -1
  118. package/lib/css/types.js +0 -2
  119. package/lib/css/units.d.ts +0 -2
  120. package/lib/css/units.d.ts.map +0 -1
  121. package/lib/css/units.js +0 -35
  122. package/lib/remix/constants.d.ts +0 -2
  123. package/lib/remix/constants.d.ts.map +0 -1
  124. package/lib/remix/constants.js +0 -4
  125. package/lib/remix/insert-critical-css.d.ts +0 -2
  126. package/lib/remix/insert-critical-css.d.ts.map +0 -1
  127. package/lib/remix/insert-critical-css.js +0 -9
  128. package/lib/stitches/index.d.ts +0 -3
  129. package/lib/stitches/index.d.ts.map +0 -1
  130. package/lib/stitches/index.js +0 -18
  131. package/lib/stitches/stitches.d.ts +0 -8
  132. package/lib/stitches/stitches.d.ts.map +0 -1
  133. package/lib/stitches/stitches.js +0 -38
  134. package/lib/stitches/to-css.d.ts +0 -8
  135. package/lib/stitches/to-css.d.ts.map +0 -1
  136. package/lib/stitches/to-css.js +0 -52
  137. package/lib/stitches/to-css.test.d.ts +0 -2
  138. package/lib/stitches/to-css.test.d.ts.map +0 -1
  139. 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
- export declare type WrapperComponentProps = {
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, css, onChangeChildren, children, ...rest }: WrapperComponentProps) => JSX.Element;
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,EAAE,KAAK,GAAG,EAAoB,MAAM,aAAa,CAAC;AACzD,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,oBAAY,qBAAqB,GAAG;IAClC,QAAQ,EAAE,QAAQ,CAAC;IACnB,GAAG,EAAE,GAAG,CAAC;IACT,QAAQ,EAAE,KAAK,CAAC,GAAG,CAAC,OAAO,GAAG,MAAM,CAAC,CAAC;IACtC,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;CACrC,CAAC;AAEF,eAAO,MAAM,gBAAgB,2DAM1B,qBAAqB,gBASvB,CAAC"}
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, css, onChangeChildren, // prevent it from passing to sdk component
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
- return ((0, jsx_runtime_1.jsx)(Component, { ...userProps, ...rest, id: instance.id, className: className, children: (0, exports.renderWrapperComponentChildren)(children) }));
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.0",
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 src/index.ts --format esm,cjs --watch --out-dir=lib",
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
- "zod": "^3.17.3"
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
  }