@webstudio-is/react-sdk 0.65.0 → 0.67.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.
Files changed (172) hide show
  1. package/lib/app/custom-components/form.ws.js +2 -2
  2. package/lib/app/custom-components/image.js +7 -13
  3. package/lib/app/custom-components/index.js +4 -1
  4. package/lib/app/params.js +1 -0
  5. package/lib/cjs/app/custom-components/form.ws.js +2 -2
  6. package/lib/cjs/app/custom-components/image.js +3 -12
  7. package/lib/cjs/app/custom-components/index.js +4 -1
  8. package/lib/cjs/app/params.js +1 -0
  9. package/lib/cjs/components/__generated__/{code.props.js → code-text.props.js} +3 -3
  10. package/lib/cjs/components/__generated__/html-embed.props.js +31 -0
  11. package/lib/cjs/components/blockquote.ws.js +2 -2
  12. package/lib/cjs/components/body.ws.js +2 -2
  13. package/lib/cjs/components/bold.ws.js +2 -2
  14. package/lib/cjs/components/box.ws.js +2 -2
  15. package/lib/cjs/components/button.ws.js +2 -2
  16. package/lib/cjs/components/checkbox-field.ws.js +2 -2
  17. package/lib/cjs/components/checkbox.ws.js +2 -2
  18. package/lib/cjs/components/{code.js → code-text.js} +6 -6
  19. package/lib/cjs/components/{code.ws.js → code-text.ws.js} +10 -10
  20. package/lib/cjs/components/component-meta.js +2 -2
  21. package/lib/cjs/components/components-utils.js +1 -43
  22. package/lib/cjs/components/components.js +4 -2
  23. package/lib/cjs/components/error-message.ws.js +2 -2
  24. package/lib/cjs/components/form.ws.js +2 -2
  25. package/lib/cjs/components/fragment.ws.js +1 -1
  26. package/lib/cjs/components/heading.ws.js +2 -2
  27. package/lib/cjs/components/html-embed.js +80 -0
  28. package/lib/cjs/components/html-embed.ws.js +43 -0
  29. package/lib/cjs/components/image.ws.js +2 -2
  30. package/lib/cjs/components/index.js +11 -57
  31. package/lib/cjs/components/input.ws.js +2 -2
  32. package/lib/cjs/components/italic.ws.js +2 -2
  33. package/lib/cjs/components/label.ws.js +2 -2
  34. package/lib/cjs/components/link-block.ws.js +2 -2
  35. package/lib/cjs/components/link.ws.js +2 -2
  36. package/lib/cjs/components/list-item.ws.js +2 -2
  37. package/lib/cjs/components/list.ws.js +2 -2
  38. package/lib/cjs/components/paragraph.ws.js +2 -2
  39. package/lib/cjs/components/radio-button-field.ws.js +2 -2
  40. package/lib/cjs/components/radio-button.ws.js +2 -2
  41. package/lib/cjs/components/separator.ws.js +2 -2
  42. package/lib/cjs/components/slot.ws.js +2 -2
  43. package/lib/cjs/components/span.ws.js +2 -2
  44. package/lib/cjs/components/subscript.ws.js +2 -2
  45. package/lib/cjs/components/success-message.ws.js +2 -2
  46. package/lib/cjs/components/superscript.ws.js +2 -2
  47. package/lib/cjs/components/text-block.ws.js +2 -2
  48. package/lib/cjs/components/textarea.ws.js +2 -2
  49. package/lib/cjs/css/css.js +2 -5
  50. package/lib/cjs/css/normalize.js +1 -1
  51. package/lib/cjs/css/presets.js +8 -1
  52. package/lib/cjs/tree/create-elements-tree.js +2 -4
  53. package/lib/components/__generated__/html-embed.props.js +11 -0
  54. package/lib/components/blockquote.ws.js +2 -2
  55. package/lib/components/body.ws.js +2 -2
  56. package/lib/components/bold.ws.js +2 -2
  57. package/lib/components/box.ws.js +2 -2
  58. package/lib/components/button.ws.js +2 -2
  59. package/lib/components/checkbox-field.ws.js +2 -2
  60. package/lib/components/checkbox.ws.js +2 -2
  61. package/lib/components/{code.js → code-text.js} +3 -3
  62. package/lib/components/{code.ws.js → code-text.ws.js} +5 -5
  63. package/lib/components/component-meta.js +3 -3
  64. package/lib/components/components-utils.js +1 -43
  65. package/lib/components/components.js +4 -2
  66. package/lib/components/error-message.ws.js +2 -2
  67. package/lib/components/form.ws.js +2 -2
  68. package/lib/components/fragment.ws.js +1 -1
  69. package/lib/components/heading.ws.js +2 -2
  70. package/lib/components/html-embed.js +65 -0
  71. package/lib/components/html-embed.ws.js +23 -0
  72. package/lib/components/image.ws.js +2 -2
  73. package/lib/components/index.js +11 -57
  74. package/lib/components/input.ws.js +2 -2
  75. package/lib/components/italic.ws.js +2 -2
  76. package/lib/components/label.ws.js +2 -2
  77. package/lib/components/link-block.ws.js +2 -2
  78. package/lib/components/link.ws.js +2 -2
  79. package/lib/components/list-item.ws.js +2 -2
  80. package/lib/components/list.ws.js +2 -2
  81. package/lib/components/paragraph.ws.js +2 -2
  82. package/lib/components/radio-button-field.ws.js +2 -2
  83. package/lib/components/radio-button.ws.js +2 -2
  84. package/lib/components/separator.ws.js +2 -2
  85. package/lib/components/slot.ws.js +2 -2
  86. package/lib/components/span.ws.js +2 -2
  87. package/lib/components/subscript.ws.js +2 -2
  88. package/lib/components/success-message.ws.js +2 -2
  89. package/lib/components/superscript.ws.js +2 -2
  90. package/lib/components/text-block.ws.js +2 -2
  91. package/lib/components/textarea.ws.js +2 -2
  92. package/lib/css/css.js +2 -5
  93. package/lib/css/normalize.js +2 -2
  94. package/lib/css/presets.js +8 -1
  95. package/lib/tree/create-elements-tree.js +2 -4
  96. package/lib/types/app/params.d.ts +22 -1
  97. package/lib/types/components/__generated__/html-embed.props.d.ts +2 -0
  98. package/lib/types/components/{code.d.ts → code-text.d.ts} +1 -1
  99. package/lib/types/components/{code.stories.d.ts → code-text.stories.d.ts} +1 -1
  100. package/lib/types/components/component-meta.d.ts +1785 -10
  101. package/lib/types/components/components-utils.d.ts +6 -3
  102. package/lib/types/components/components.d.ts +2 -1
  103. package/lib/types/components/html-embed.d.ts +7 -0
  104. package/lib/types/components/html-embed.stories.d.ts +11 -0
  105. package/lib/types/components/html-embed.ws.d.ts +3 -0
  106. package/lib/types/components/index.d.ts +2 -2
  107. package/lib/types/context.d.ts +1 -0
  108. package/lib/types/css/css.d.ts +2 -0
  109. package/lib/types/css/presets.d.ts +1 -0
  110. package/lib/types/css/style-rules.d.ts +1 -1
  111. package/lib/types/embed-template.d.ts +1 -1
  112. package/lib/types/tree/create-elements-tree.d.ts +2 -2
  113. package/package.json +14 -13
  114. package/src/app/custom-components/form.ws.tsx +2 -2
  115. package/src/app/custom-components/image.tsx +7 -13
  116. package/src/app/custom-components/index.ts +4 -1
  117. package/src/app/params.ts +23 -1
  118. package/src/components/__generated__/html-embed.props.ts +10 -0
  119. package/src/components/blockquote.ws.tsx +2 -2
  120. package/src/components/body.ws.tsx +2 -2
  121. package/src/components/bold.ws.tsx +2 -2
  122. package/src/components/box.ws.ts +2 -2
  123. package/src/components/button.ws.tsx +2 -2
  124. package/src/components/checkbox-field.ws.tsx +2 -2
  125. package/src/components/checkbox.ws.tsx +2 -2
  126. package/src/components/code-text.stories.tsx +16 -0
  127. package/src/components/{code.tsx → code-text.tsx} +2 -2
  128. package/src/components/{code.ws.tsx → code-text.ws.tsx} +5 -5
  129. package/src/components/component-meta.ts +3 -6
  130. package/src/components/components-utils.ts +14 -58
  131. package/src/components/components.ts +2 -1
  132. package/src/components/error-message.ws.tsx +2 -2
  133. package/src/components/form.ws.tsx +2 -2
  134. package/src/components/fragment.ws.ts +1 -1
  135. package/src/components/heading.ws.tsx +2 -2
  136. package/src/components/html-embed.stories.tsx +16 -0
  137. package/src/components/html-embed.tsx +96 -0
  138. package/src/components/html-embed.ws.ts +22 -0
  139. package/src/components/image.ws.tsx +2 -2
  140. package/src/components/index.ts +10 -87
  141. package/src/components/input.ws.tsx +2 -2
  142. package/src/components/italic.ws.tsx +2 -2
  143. package/src/components/label.ws.tsx +2 -2
  144. package/src/components/link-block.ws.tsx +2 -2
  145. package/src/components/link.ws.tsx +2 -2
  146. package/src/components/list-item.ws.tsx +2 -2
  147. package/src/components/list.ws.tsx +2 -2
  148. package/src/components/paragraph.ws.tsx +2 -2
  149. package/src/components/radio-button-field.ws.tsx +2 -2
  150. package/src/components/radio-button.ws.tsx +2 -2
  151. package/src/components/separator.ws.tsx +2 -2
  152. package/src/components/slot.ws.ts +2 -2
  153. package/src/components/span.ws.tsx +2 -2
  154. package/src/components/subscript.ws.tsx +2 -2
  155. package/src/components/success-message.ws.tsx +2 -2
  156. package/src/components/superscript.ws.tsx +2 -2
  157. package/src/components/text-block.ws.tsx +2 -2
  158. package/src/components/textarea.ws.tsx +2 -2
  159. package/src/context.tsx +1 -0
  160. package/src/css/css.ts +4 -5
  161. package/src/css/normalize.ts +2 -2
  162. package/src/css/presets.ts +7 -0
  163. package/src/tree/create-elements-tree.tsx +3 -5
  164. package/lib/cjs/tree/session-storage-polyfill.js +0 -65
  165. package/lib/tree/session-storage-polyfill.js +0 -45
  166. package/lib/types/tree/session-storage-polyfill.d.ts +0 -2
  167. package/src/components/code.stories.tsx +0 -16
  168. package/src/tree/session-storage-polyfill.tsx +0 -50
  169. /package/lib/components/__generated__/{code.props.js → code-text.props.js} +0 -0
  170. /package/lib/types/components/__generated__/{code.props.d.ts → code-text.props.d.ts} +0 -0
  171. /package/lib/types/components/{code.ws.d.ts → code-text.ws.d.ts} +0 -0
  172. /package/src/components/__generated__/{code.props.ts → code-text.props.ts} +0 -0
@@ -1,4 +1,4 @@
1
- import { RadioCheckedIcon } from "@webstudio-is/icons";
1
+ import { RadioCheckedIcon } from "@webstudio-is/icons/svg";
2
2
  import {
3
3
  defaultStates
4
4
  } from "./component-meta";
@@ -14,7 +14,7 @@ const meta = {
14
14
  category: "forms",
15
15
  type: "container",
16
16
  label: "Radio",
17
- Icon: RadioCheckedIcon,
17
+ icon: RadioCheckedIcon,
18
18
  states: defaultStates,
19
19
  presetStyle,
20
20
  children: [
@@ -1,4 +1,4 @@
1
- import { RadioCheckedIcon } from "@webstudio-is/icons";
1
+ import { RadioCheckedIcon } from "@webstudio-is/icons/svg";
2
2
  import {
3
3
  defaultStates
4
4
  } from "./component-meta";
@@ -16,7 +16,7 @@ const presetStyle = {
16
16
  const meta = {
17
17
  type: "control",
18
18
  label: "Radio Input",
19
- Icon: RadioCheckedIcon,
19
+ icon: RadioCheckedIcon,
20
20
  presetStyle,
21
21
  states: [
22
22
  ...defaultStates,
@@ -1,4 +1,4 @@
1
- import { DashIcon } from "@webstudio-is/icons";
1
+ import { DashIcon } from "@webstudio-is/icons/svg";
2
2
  import {
3
3
  defaultStates
4
4
  } from "./component-meta";
@@ -37,7 +37,7 @@ const meta = {
37
37
  category: "general",
38
38
  type: "embed",
39
39
  label: "Separator",
40
- Icon: DashIcon,
40
+ icon: DashIcon,
41
41
  states: defaultStates,
42
42
  presetStyle,
43
43
  children: []
@@ -1,9 +1,9 @@
1
- import { SlotComponentIcon } from "@webstudio-is/icons";
1
+ import { SlotComponentIcon } from "@webstudio-is/icons/svg";
2
2
  const meta = {
3
3
  category: "general",
4
4
  type: "container",
5
5
  label: "Slot",
6
- Icon: SlotComponentIcon
6
+ icon: SlotComponentIcon
7
7
  };
8
8
  const propsMeta = {
9
9
  props: {}
@@ -1,4 +1,4 @@
1
- import { PaintBrushIcon } from "@webstudio-is/icons";
1
+ import { PaintBrushIcon } from "@webstudio-is/icons/svg";
2
2
  import { span } from "../css/normalize";
3
3
  import {
4
4
  defaultStates
@@ -10,7 +10,7 @@ const presetStyle = {
10
10
  const meta = {
11
11
  type: "rich-text-child",
12
12
  label: "Styled Text",
13
- Icon: PaintBrushIcon,
13
+ icon: PaintBrushIcon,
14
14
  states: defaultStates,
15
15
  presetStyle
16
16
  };
@@ -1,4 +1,4 @@
1
- import { SubscriptIcon } from "@webstudio-is/icons";
1
+ import { SubscriptIcon } from "@webstudio-is/icons/svg";
2
2
  import { sub } from "../css/normalize";
3
3
  import {
4
4
  defaultStates
@@ -10,7 +10,7 @@ const presetStyle = {
10
10
  const meta = {
11
11
  type: "rich-text-child",
12
12
  label: "Subscript Text",
13
- Icon: SubscriptIcon,
13
+ icon: SubscriptIcon,
14
14
  states: defaultStates,
15
15
  presetStyle
16
16
  };
@@ -1,4 +1,4 @@
1
- import { BoxIcon } from "@webstudio-is/icons";
1
+ import { BoxIcon } from "@webstudio-is/icons/svg";
2
2
  import { props } from "./__generated__/success-message.props";
3
3
  import { div } from "../css/normalize";
4
4
  const presetStyle = {
@@ -7,7 +7,7 @@ const presetStyle = {
7
7
  const meta = {
8
8
  type: "container",
9
9
  label: "Success Message",
10
- Icon: BoxIcon,
10
+ icon: BoxIcon,
11
11
  presetStyle
12
12
  };
13
13
  const propsMeta = {
@@ -1,4 +1,4 @@
1
- import { SuperscriptIcon } from "@webstudio-is/icons";
1
+ import { SuperscriptIcon } from "@webstudio-is/icons/svg";
2
2
  import { sup } from "../css/normalize";
3
3
  import {
4
4
  defaultStates
@@ -10,7 +10,7 @@ const presetStyle = {
10
10
  const meta = {
11
11
  type: "rich-text-child",
12
12
  label: "Superscript Text",
13
- Icon: SuperscriptIcon,
13
+ icon: SuperscriptIcon,
14
14
  states: defaultStates,
15
15
  presetStyle
16
16
  };
@@ -1,4 +1,4 @@
1
- import { TextBlockIcon } from "@webstudio-is/icons";
1
+ import { TextBlockIcon } from "@webstudio-is/icons/svg";
2
2
  import {
3
3
  defaultStates
4
4
  } from "./component-meta";
@@ -17,7 +17,7 @@ const meta = {
17
17
  category: "typography",
18
18
  type: "rich-text",
19
19
  label: "Text Block",
20
- Icon: TextBlockIcon,
20
+ icon: TextBlockIcon,
21
21
  states: defaultStates,
22
22
  presetStyle,
23
23
  children: [{ type: "text", value: "Block of text you can edit" }]
@@ -1,4 +1,4 @@
1
- import { FormTextAreaIcon } from "@webstudio-is/icons";
1
+ import { FormTextAreaIcon } from "@webstudio-is/icons/svg";
2
2
  import { textarea } from "../css/normalize";
3
3
  import {
4
4
  defaultStates
@@ -15,7 +15,7 @@ const meta = {
15
15
  category: "forms",
16
16
  type: "control",
17
17
  label: "Text Area",
18
- Icon: FormTextAreaIcon,
18
+ icon: FormTextAreaIcon,
19
19
  presetStyle,
20
20
  states: [
21
21
  ...defaultStates,
package/lib/css/css.js CHANGED
@@ -1,6 +1,4 @@
1
1
  import { createCssEngine } from "@webstudio-is/css-engine";
2
- import { getComponentNames } from "../components/components-utils";
3
- import { getComponentMeta } from "../components";
4
2
  import { idAttribute } from "../tree";
5
3
  import { addGlobalRules } from "./global-rules";
6
4
  import { getPresetStyleRules, getStyleRules } from "./style-rules";
@@ -37,9 +35,8 @@ const generateCssText = (data, options) => {
37
35
  for (const breakpoint of breakpoints.values()) {
38
36
  engine.addMediaRule(breakpoint.id, breakpoint);
39
37
  }
40
- for (const component of getComponentNames()) {
41
- const meta = getComponentMeta(component);
42
- const presetStyle = meta?.presetStyle;
38
+ for (const [component, meta] of data.componentMetas) {
39
+ const presetStyle = meta.presetStyle;
43
40
  if (presetStyle === void 0) {
44
41
  continue;
45
42
  }
@@ -1,9 +1,9 @@
1
- import { borders } from "./presets";
1
+ import { borders, outline } from "./presets";
2
2
  const boxSizing = {
3
3
  property: "boxSizing",
4
4
  value: { type: "keyword", value: "border-box" }
5
5
  };
6
- const baseStyle = [boxSizing, ...borders];
6
+ const baseStyle = [boxSizing, ...borders, ...outline];
7
7
  const div = baseStyle;
8
8
  const address = baseStyle;
9
9
  const article = baseStyle;
@@ -16,6 +16,13 @@ const borders = [
16
16
  value: { type: "unit", value: 1, unit: "px" }
17
17
  }
18
18
  ];
19
+ const outline = [
20
+ {
21
+ property: "outlineWidth",
22
+ value: { type: "unit", value: 1, unit: "px" }
23
+ }
24
+ ];
19
25
  export {
20
- borders
26
+ borders,
27
+ outline
21
28
  };
@@ -2,11 +2,10 @@ import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { Fragment } from "react";
3
3
  import { Scripts, ScrollRestoration } from "@remix-run/react";
4
4
  import { ReactSdkContext } from "../context";
5
- import { SessionStoragePolyfill } from "./session-storage-polyfill";
6
5
  const createElementsTree = ({
6
+ renderer,
7
7
  instances,
8
8
  rootInstanceId,
9
- sandbox,
10
9
  propsByInstanceIdStore,
11
10
  assetsStore,
12
11
  pagesStore,
@@ -32,7 +31,6 @@ const createElementsTree = ({
32
31
  children: [
33
32
  /* @__PURE__ */ jsxs(Fragment, { children: [
34
33
  children,
35
- sandbox && /* @__PURE__ */ jsx(SessionStoragePolyfill, {}),
36
34
  /* @__PURE__ */ jsx(ScrollRestoration, {}),
37
35
  /* @__PURE__ */ jsx(Scripts, {})
38
36
  ] }, "children")
@@ -42,7 +40,7 @@ const createElementsTree = ({
42
40
  return /* @__PURE__ */ jsx(
43
41
  ReactSdkContext.Provider,
44
42
  {
45
- value: { propsByInstanceIdStore, assetsStore, pagesStore },
43
+ value: { propsByInstanceIdStore, assetsStore, pagesStore, renderer },
46
44
  children: root
47
45
  }
48
46
  );
@@ -1,5 +1,26 @@
1
1
  export type Params = {
2
- resizeOrigin?: string;
2
+ /**
3
+ * Base url ir base path for images with ending slash.
4
+ * Used for configuring image with different sizes.
5
+ * Concatinated with "name?width=&quality=&format=".
6
+ *
7
+ * For example
8
+ * /asset/image/ used by default in builder
9
+ * https://image-transform.wstd.io/cdn-cgi/image/
10
+ * https://webstudio.is/cdn-cgi/image/
11
+ */
12
+ imageBaseUrl: string;
13
+ /**
14
+ * Base url or base path for any asset with ending slash.
15
+ * Used to load assets like fonts or images in styles
16
+ * Concatinated with "name".
17
+ *
18
+ * For example
19
+ * /s/uploads/
20
+ * /asset/file/
21
+ * https://assets-dev.webstudio.is/
22
+ * https://assets.webstudio.is/
23
+ */
3
24
  assetBaseUrl: string;
4
25
  };
5
26
  export declare const getParams: () => Params;
@@ -0,0 +1,2 @@
1
+ import type { PropMeta } from "@webstudio-is/generate-arg-types";
2
+ export declare const props: Record<string, PropMeta>;
@@ -5,5 +5,5 @@ type Props = Omit<ComponentProps<typeof defaultTag>, "inline"> & {
5
5
  inline?: boolean;
6
6
  meta?: string;
7
7
  };
8
- export declare const Code: import("react").ForwardRefExoticComponent<Omit<Props, "ref"> & import("react").RefAttributes<HTMLElement>>;
8
+ export declare const CodeText: import("react").ForwardRefExoticComponent<Omit<Props, "ref"> & import("react").RefAttributes<HTMLElement>>;
9
9
  export {};
@@ -5,7 +5,7 @@ declare const _default: ComponentMeta<import("react").ForwardRefExoticComponent<
5
5
  meta?: string | undefined;
6
6
  }, "ref"> & import("react").RefAttributes<HTMLElement>>>;
7
7
  export default _default;
8
- export declare const Code: ComponentStory<import("react").ForwardRefExoticComponent<Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>, "inline"> & {
8
+ export declare const CodeText: ComponentStory<import("react").ForwardRefExoticComponent<Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>, "inline"> & {
9
9
  inline?: boolean | undefined;
10
10
  meta?: string | undefined;
11
11
  }, "ref"> & import("react").RefAttributes<HTMLElement>>>;