@webstudio-is/react-sdk 0.68.0 → 0.69.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 (184) hide show
  1. package/lib/cjs/components/__generated__/image.props.js +6 -3
  2. package/lib/cjs/components/__generated__/text-block.props.js +7 -0
  3. package/lib/cjs/components/blockquote.ws.js +9 -2
  4. package/lib/cjs/components/box.ws.js +2 -1
  5. package/lib/cjs/components/button.ws.js +3 -1
  6. package/lib/cjs/components/checkbox-field.ws.js +12 -6
  7. package/lib/cjs/components/checkbox.ws.js +1 -0
  8. package/lib/cjs/components/code-text.ws.js +8 -1
  9. package/lib/cjs/components/component-meta.js +6 -3
  10. package/lib/cjs/components/components-utils.js +0 -28
  11. package/lib/cjs/components/form.ws.js +32 -25
  12. package/lib/cjs/components/fragment.ws.js +2 -1
  13. package/lib/cjs/components/heading.ws.js +10 -3
  14. package/lib/cjs/components/html-embed.ws.js +3 -1
  15. package/lib/cjs/components/image.js +27 -19
  16. package/lib/cjs/components/image.ws.js +4 -2
  17. package/lib/cjs/components/index.js +1 -29
  18. package/lib/cjs/components/input.ws.js +1 -0
  19. package/lib/cjs/components/label.ws.js +8 -1
  20. package/lib/cjs/components/link-block.ws.js +2 -1
  21. package/lib/cjs/components/link.ws.js +8 -1
  22. package/lib/cjs/components/list-item.ws.js +11 -4
  23. package/lib/cjs/components/list.ws.js +2 -2
  24. package/lib/cjs/components/paragraph.ws.js +10 -3
  25. package/lib/cjs/components/radio-button-field.ws.js +12 -6
  26. package/lib/cjs/components/radio-button.ws.js +1 -0
  27. package/lib/cjs/components/rich-text-link.ws.js +1 -1
  28. package/lib/cjs/components/separator.ws.js +1 -1
  29. package/lib/cjs/components/slot.ws.js +3 -1
  30. package/lib/cjs/components/text-block.js +5 -2
  31. package/lib/cjs/components/text-block.ws.js +11 -3
  32. package/lib/cjs/components/textarea.ws.js +1 -0
  33. package/lib/cjs/embed-template.js +2 -1
  34. package/lib/cjs/index.js +4 -5
  35. package/lib/cjs/tree/create-elements-tree.js +8 -8
  36. package/lib/cjs/tree/root.js +2 -6
  37. package/lib/cjs/tree/webstudio-component.js +2 -2
  38. package/lib/components/__generated__/image.props.js +6 -3
  39. package/lib/components/__generated__/text-block.props.js +7 -0
  40. package/lib/components/blockquote.ws.js +9 -2
  41. package/lib/components/box.ws.js +2 -1
  42. package/lib/components/button.ws.js +3 -1
  43. package/lib/components/checkbox-field.ws.js +12 -6
  44. package/lib/components/checkbox.ws.js +1 -0
  45. package/lib/components/code-text.ws.js +8 -1
  46. package/lib/components/component-meta.js +6 -3
  47. package/lib/components/components-utils.js +0 -14
  48. package/lib/components/form.ws.js +32 -25
  49. package/lib/components/fragment.ws.js +2 -1
  50. package/lib/components/heading.ws.js +10 -3
  51. package/lib/components/html-embed.ws.js +3 -1
  52. package/lib/components/image.js +34 -20
  53. package/lib/components/image.ws.js +4 -2
  54. package/lib/components/index.js +1 -29
  55. package/lib/components/input.ws.js +1 -0
  56. package/lib/components/label.ws.js +8 -1
  57. package/lib/components/link-block.ws.js +2 -1
  58. package/lib/components/link.ws.js +8 -1
  59. package/lib/components/list-item.ws.js +11 -4
  60. package/lib/components/list.ws.js +2 -2
  61. package/lib/components/paragraph.ws.js +10 -3
  62. package/lib/components/radio-button-field.ws.js +12 -6
  63. package/lib/components/radio-button.ws.js +1 -0
  64. package/lib/components/rich-text-link.ws.js +1 -1
  65. package/lib/components/separator.ws.js +1 -1
  66. package/lib/components/slot.ws.js +3 -1
  67. package/lib/components/text-block.js +9 -3
  68. package/lib/components/text-block.ws.js +11 -3
  69. package/lib/components/textarea.ws.js +1 -0
  70. package/lib/embed-template.js +2 -1
  71. package/lib/index.js +4 -9
  72. package/lib/tree/create-elements-tree.js +8 -8
  73. package/lib/tree/root.js +2 -6
  74. package/lib/tree/webstudio-component.js +2 -2
  75. package/lib/types/components/component-meta.d.ts +363 -1356
  76. package/lib/types/components/components-utils.d.ts +2 -17
  77. package/lib/types/components/image.d.ts +5 -1
  78. package/lib/types/components/image.stories.d.ts +10 -2
  79. package/lib/types/components/index.d.ts +0 -15
  80. package/lib/types/components/text-block.d.ts +6 -2
  81. package/lib/types/components/text-block.stories.d.ts +6 -2
  82. package/lib/types/css/css.d.ts +14 -4
  83. package/lib/types/css/global-rules.d.ts +14 -4
  84. package/lib/types/css/normalize.d.ts +611 -611
  85. package/lib/types/css/style-rules.d.ts +2 -187
  86. package/lib/types/embed-template.d.ts +543 -167
  87. package/lib/types/index.d.ts +2 -2
  88. package/lib/types/props.d.ts +44 -18
  89. package/lib/types/tree/create-elements-tree.d.ts +4 -4
  90. package/lib/types/tree/root.d.ts +3 -5
  91. package/lib/types/tree/webstudio-component.d.ts +3 -3
  92. package/package.json +24 -13
  93. package/src/components/__generated__/image.props.ts +5 -2
  94. package/src/components/__generated__/text-block.props.ts +7 -0
  95. package/src/components/blockquote.ws.tsx +9 -2
  96. package/src/components/box.tsx +1 -1
  97. package/src/components/box.ws.ts +1 -0
  98. package/src/components/button.ws.tsx +2 -0
  99. package/src/components/checkbox-field.ws.tsx +12 -6
  100. package/src/components/checkbox.ws.tsx +1 -0
  101. package/src/components/code-text.ws.tsx +8 -1
  102. package/src/components/component-meta.ts +6 -3
  103. package/src/components/components-utils.ts +2 -31
  104. package/src/components/form.ws.tsx +32 -25
  105. package/src/components/fragment.ws.ts +1 -0
  106. package/src/components/heading.tsx +1 -1
  107. package/src/components/heading.ws.tsx +9 -2
  108. package/src/components/html-embed.ws.ts +2 -0
  109. package/src/components/image.tsx +54 -26
  110. package/src/components/image.ws.tsx +5 -1
  111. package/src/components/index.ts +0 -48
  112. package/src/components/input.ws.tsx +1 -0
  113. package/src/components/label.ws.tsx +8 -1
  114. package/src/components/link-block.ws.tsx +1 -0
  115. package/src/components/link.ws.tsx +8 -1
  116. package/src/components/list-item.ws.tsx +10 -3
  117. package/src/components/list.ws.tsx +2 -2
  118. package/src/components/paragraph.ws.tsx +9 -2
  119. package/src/components/radio-button-field.ws.tsx +12 -6
  120. package/src/components/radio-button.ws.tsx +1 -0
  121. package/src/components/rich-text-link.ws.tsx +1 -1
  122. package/src/components/separator.ws.tsx +1 -1
  123. package/src/components/slot.ws.ts +2 -0
  124. package/src/components/text-block.tsx +16 -5
  125. package/src/components/text-block.ws.tsx +10 -2
  126. package/src/components/textarea.ws.tsx +1 -0
  127. package/src/embed-template.ts +11 -3
  128. package/src/index.ts +2 -5
  129. package/src/props.test.ts +0 -1
  130. package/src/tree/create-elements-tree.tsx +12 -12
  131. package/src/tree/root.ts +4 -9
  132. package/src/tree/webstudio-component.tsx +4 -4
  133. package/lib/app/custom-components/__generated__/form.props.js +0 -411
  134. package/lib/app/custom-components/__generated__/image.props.js +0 -442
  135. package/lib/app/custom-components/__generated__/link-block.props.js +0 -432
  136. package/lib/app/custom-components/__generated__/link.props.js +0 -432
  137. package/lib/app/custom-components/__generated__/rich-text-link.props.js +0 -432
  138. package/lib/app/custom-components/form.js +0 -65
  139. package/lib/app/custom-components/form.ws.js +0 -81
  140. package/lib/app/custom-components/image.js +0 -40
  141. package/lib/app/custom-components/index.js +0 -29
  142. package/lib/app/custom-components/link-block.js +0 -6
  143. package/lib/app/custom-components/link.js +0 -6
  144. package/lib/app/custom-components/rich-text-link.js +0 -6
  145. package/lib/app/custom-components/shared/remix-link.js +0 -22
  146. package/lib/cjs/app/custom-components/__generated__/form.props.js +0 -431
  147. package/lib/cjs/app/custom-components/__generated__/image.props.js +0 -462
  148. package/lib/cjs/app/custom-components/__generated__/link-block.props.js +0 -452
  149. package/lib/cjs/app/custom-components/__generated__/link.props.js +0 -452
  150. package/lib/cjs/app/custom-components/__generated__/rich-text-link.props.js +0 -452
  151. package/lib/cjs/app/custom-components/form.js +0 -81
  152. package/lib/cjs/app/custom-components/form.ws.js +0 -101
  153. package/lib/cjs/app/custom-components/image.js +0 -54
  154. package/lib/cjs/app/custom-components/index.js +0 -49
  155. package/lib/cjs/app/custom-components/link-block.js +0 -26
  156. package/lib/cjs/app/custom-components/link.js +0 -26
  157. package/lib/cjs/app/custom-components/rich-text-link.js +0 -26
  158. package/lib/cjs/app/custom-components/shared/remix-link.js +0 -42
  159. package/lib/types/app/custom-components/__generated__/form.props.d.ts +0 -2
  160. package/lib/types/app/custom-components/__generated__/image.props.d.ts +0 -2
  161. package/lib/types/app/custom-components/__generated__/link-block.props.d.ts +0 -2
  162. package/lib/types/app/custom-components/__generated__/link.props.d.ts +0 -2
  163. package/lib/types/app/custom-components/__generated__/rich-text-link.props.d.ts +0 -2
  164. package/lib/types/app/custom-components/form.d.ts +0 -5
  165. package/lib/types/app/custom-components/form.ws.d.ts +0 -3
  166. package/lib/types/app/custom-components/image.d.ts +0 -6
  167. package/lib/types/app/custom-components/index.d.ts +0 -31
  168. package/lib/types/app/custom-components/link-block.d.ts +0 -6
  169. package/lib/types/app/custom-components/link.d.ts +0 -6
  170. package/lib/types/app/custom-components/rich-text-link.d.ts +0 -6
  171. package/lib/types/app/custom-components/shared/remix-link.d.ts +0 -10
  172. package/src/app/custom-components/__generated__/form.props.ts +0 -456
  173. package/src/app/custom-components/__generated__/image.props.ts +0 -487
  174. package/src/app/custom-components/__generated__/link-block.props.ts +0 -477
  175. package/src/app/custom-components/__generated__/link.props.ts +0 -477
  176. package/src/app/custom-components/__generated__/rich-text-link.props.ts +0 -477
  177. package/src/app/custom-components/form.tsx +0 -111
  178. package/src/app/custom-components/form.ws.tsx +0 -86
  179. package/src/app/custom-components/image.tsx +0 -55
  180. package/src/app/custom-components/index.ts +0 -28
  181. package/src/app/custom-components/link-block.tsx +0 -4
  182. package/src/app/custom-components/link.tsx +0 -4
  183. package/src/app/custom-components/rich-text-link.tsx +0 -4
  184. package/src/app/custom-components/shared/remix-link.tsx +0 -28
@@ -5,6 +5,6 @@ export * from "./pubsub";
5
5
  export * from "./app";
6
6
  export * from "./components/components";
7
7
  export * from "./components/components-utils";
8
- export { customComponents, customComponentMetas, customComponentPropsMetas, } from "./app/custom-components";
9
- export { type WsComponentPropsMeta, type WsComponentMeta, type ComponentState, componentCategories, stateCategories, } from "./components/component-meta";
8
+ export { type WsComponentPropsMeta, type WsComponentMeta, type ComponentState, type PresetStyle, componentCategories, stateCategories, } from "./components/component-meta";
10
9
  export * from "./embed-template";
10
+ export { usePropUrl, getInstanceIdFromComponentProps } from "./props";
@@ -3,55 +3,61 @@ import type { Asset, Assets } from "@webstudio-is/asset-uploader";
3
3
  export type PropsByInstanceId = Map<Instance["id"], Prop[]>;
4
4
  export type Pages = Map<Page["id"], Page>;
5
5
  export declare const getPropsByInstanceId: (props: Map<string, {
6
- required?: boolean | undefined;
7
6
  name: string;
8
7
  type: "number";
9
8
  value: number;
10
9
  id: string;
11
10
  instanceId: string;
12
- } | {
13
11
  required?: boolean | undefined;
12
+ } | {
14
13
  name: string;
15
14
  type: "string";
16
15
  value: string;
17
16
  id: string;
18
17
  instanceId: string;
19
- } | {
20
18
  required?: boolean | undefined;
19
+ } | {
21
20
  name: string;
22
21
  type: "boolean";
23
22
  value: boolean;
24
23
  id: string;
25
24
  instanceId: string;
26
- } | {
27
25
  required?: boolean | undefined;
26
+ } | {
28
27
  name: string;
29
28
  type: "asset";
30
29
  value: string;
31
30
  id: string;
32
31
  instanceId: string;
33
- } | {
34
32
  required?: boolean | undefined;
33
+ } | {
35
34
  name: string;
36
35
  type: "page";
37
- value: string | {
36
+ value: (string | {
38
37
  instanceId: string;
39
38
  pageId: string;
40
- };
39
+ }) & (string | {
40
+ instanceId: string;
41
+ pageId: string;
42
+ } | undefined);
41
43
  id: string;
42
44
  instanceId: string;
43
- } | {
44
45
  required?: boolean | undefined;
46
+ } | {
45
47
  name: string;
46
48
  type: "string[]";
47
49
  value: string[];
48
50
  id: string;
49
51
  instanceId: string;
52
+ required?: boolean | undefined;
50
53
  }>) => PropsByInstanceId;
51
- export declare const useInstanceProps: (instanceId: Instance["id"]) => Record<string, string | number | boolean | string[] | {
54
+ export declare const useInstanceProps: (instanceId: Instance["id"]) => Record<string, number | boolean | string[] | ((string | {
55
+ instanceId: string;
56
+ pageId: string;
57
+ }) & (string | {
52
58
  instanceId: string;
53
59
  pageId: string;
54
- }>;
60
+ } | undefined))>;
55
61
  export declare const usePropAsset: (instanceId: Instance["id"], name: string) => {
56
62
  name: string;
57
63
  type: "font";
@@ -60,9 +66,8 @@ export declare const usePropAsset: (instanceId: Instance["id"], name: string) =>
60
66
  projectId: string;
61
67
  size: number;
62
68
  description: string | null;
63
- location: "FS" | "REMOTE";
64
69
  createdAt: string;
65
- meta: {
70
+ meta: ({
66
71
  style: "normal" | "italic" | "oblique";
67
72
  weight: number;
68
73
  family: string;
@@ -74,7 +79,19 @@ export declare const usePropAsset: (instanceId: Instance["id"], name: string) =>
74
79
  max: number;
75
80
  }>>;
76
81
  family: string;
77
- };
82
+ }) & ({
83
+ style: "normal" | "italic" | "oblique";
84
+ weight: number;
85
+ family: string;
86
+ } | {
87
+ variationAxes: Partial<Record<"wght" | "wdth" | "slnt" | "opsz" | "ital" | "GRAD" | "XTRA" | "XOPQ" | "YOPQ" | "YTLC" | "YTUC" | "YTAS" | "YTDE" | "YTFI", {
88
+ name: string;
89
+ min: number;
90
+ default: number;
91
+ max: number;
92
+ }>>;
93
+ family: string;
94
+ } | undefined);
78
95
  } | {
79
96
  name: string;
80
97
  type: "image";
@@ -83,7 +100,6 @@ export declare const usePropAsset: (instanceId: Instance["id"], name: string) =>
83
100
  projectId: string;
84
101
  size: number;
85
102
  description: string | null;
86
- location: "FS" | "REMOTE";
87
103
  createdAt: string;
88
104
  meta: {
89
105
  width: number;
@@ -101,9 +117,8 @@ export declare const resolveUrlProp: (instanceId: Instance["id"], name: string,
101
117
  projectId: string;
102
118
  size: number;
103
119
  description: string | null;
104
- location: "FS" | "REMOTE";
105
120
  createdAt: string;
106
- meta: {
121
+ meta: ({
107
122
  style: "normal" | "italic" | "oblique";
108
123
  weight: number;
109
124
  family: string;
@@ -115,7 +130,19 @@ export declare const resolveUrlProp: (instanceId: Instance["id"], name: string,
115
130
  max: number;
116
131
  }>>;
117
132
  family: string;
118
- };
133
+ }) & ({
134
+ style: "normal" | "italic" | "oblique";
135
+ weight: number;
136
+ family: string;
137
+ } | {
138
+ variationAxes: Partial<Record<"wght" | "wdth" | "slnt" | "opsz" | "ital" | "GRAD" | "XTRA" | "XOPQ" | "YOPQ" | "YTLC" | "YTUC" | "YTAS" | "YTDE" | "YTFI", {
139
+ name: string;
140
+ min: number;
141
+ default: number;
142
+ max: number;
143
+ }>>;
144
+ family: string;
145
+ } | undefined);
119
146
  } | {
120
147
  name: string;
121
148
  type: "image";
@@ -124,7 +151,6 @@ export declare const resolveUrlProp: (instanceId: Instance["id"], name: string,
124
151
  projectId: string;
125
152
  size: number;
126
153
  description: string | null;
127
- location: "FS" | "REMOTE";
128
154
  createdAt: string;
129
155
  meta: {
130
156
  width: number;
@@ -2,13 +2,12 @@ import { type ComponentProps } from "react";
2
2
  import type { ReadableAtom } from "nanostores";
3
3
  import type { Assets } from "@webstudio-is/asset-uploader";
4
4
  import type { Instance, Instances } from "@webstudio-is/project-build";
5
- import type { GetComponent } from "../components/components-utils";
5
+ import type { Components } from "../components/components-utils";
6
6
  import type { Pages, PropsByInstanceId } from "../props";
7
7
  import type { WebstudioComponent } from "./webstudio-component";
8
- export declare const createElementsTree: ({ renderer, instances, rootInstanceId, propsByInstanceIdStore, assetsStore, pagesStore, Component, getComponent, }: {
8
+ export declare const createElementsTree: ({ renderer, instances, rootInstanceId, propsByInstanceIdStore, assetsStore, pagesStore, Component, components, }: {
9
9
  renderer?: "canvas" | undefined;
10
10
  instances: Map<string, {
11
- label?: string | undefined;
12
11
  type: "instance";
13
12
  id: string;
14
13
  component: string;
@@ -19,11 +18,12 @@ export declare const createElementsTree: ({ renderer, instances, rootInstanceId,
19
18
  type: "id";
20
19
  value: string;
21
20
  })[];
21
+ label?: string | undefined;
22
22
  }>;
23
23
  rootInstanceId: Instance["id"];
24
24
  propsByInstanceIdStore: ReadableAtom<PropsByInstanceId>;
25
25
  assetsStore: ReadableAtom<Assets>;
26
26
  pagesStore: ReadableAtom<Pages>;
27
27
  Component: (props: ComponentProps<typeof WebstudioComponent>) => JSX.Element;
28
- getComponent: GetComponent;
28
+ components: Components;
29
29
  }) => JSX.Element | null;
@@ -2,9 +2,8 @@ import type { ComponentProps } from "react";
2
2
  import type { Build, Page } from "@webstudio-is/project-build";
3
3
  import type { Asset } from "@webstudio-is/asset-uploader";
4
4
  import { WebstudioComponent } from "./webstudio-component";
5
- import { registerComponents } from "../components";
6
5
  import { type Params } from "../app/params";
7
- import type { GetComponent } from "../components/components-utils";
6
+ import type { Components } from "../components/components-utils";
8
7
  export type Data = {
9
8
  page: Page;
10
9
  pages: Array<Page>;
@@ -18,8 +17,7 @@ export type RootPropsData = Omit<Data, "build"> & {
18
17
  type RootProps = {
19
18
  data: RootPropsData;
20
19
  Component?: (props: ComponentProps<typeof WebstudioComponent>) => JSX.Element;
21
- customComponents?: Parameters<typeof registerComponents>[0];
22
- getComponent: GetComponent;
20
+ components: Components;
23
21
  };
24
- export declare const InstanceRoot: ({ data, Component, customComponents, getComponent, }: RootProps) => JSX.Element | null;
22
+ export declare const InstanceRoot: ({ data, Component, components, }: RootProps) => JSX.Element | null;
25
23
  export {};
@@ -1,14 +1,14 @@
1
1
  /// <reference types="react" />
2
2
  import type { Instance } from "@webstudio-is/project-build";
3
- import type { GetComponent } from "../components/components-utils";
3
+ import type { Components } from "../components/components-utils";
4
4
  export declare const renderWebstudioComponentChildren: (children: Array<JSX.Element | string> | undefined) => Array<JSX.Element | string | Array<JSX.Element | string>> | undefined;
5
5
  type WebstudioComponentProps = {
6
6
  instance: Instance;
7
7
  instanceSelector: Instance["id"][];
8
8
  children: Array<JSX.Element | string>;
9
- getComponent: GetComponent;
9
+ components: Components;
10
10
  };
11
- export declare const WebstudioComponent: ({ instance, instanceSelector, children, getComponent, ...rest }: WebstudioComponentProps) => JSX.Element;
11
+ export declare const WebstudioComponent: ({ instance, instanceSelector, children, components, ...rest }: WebstudioComponentProps) => JSX.Element;
12
12
  export declare const idAttribute = "data-ws-id";
13
13
  export declare const componentAttribute = "data-ws-component";
14
14
  export declare const collapsedAttribute = "data-ws-collapsed";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webstudio-is/react-sdk",
3
- "version": "0.68.0",
3
+ "version": "0.69.0",
4
4
  "description": "Webstudio JavaScript / TypeScript API",
5
5
  "author": "Webstudio <github@webstudio.is>",
6
6
  "homepage": "https://webstudio.is",
@@ -16,7 +16,8 @@
16
16
  "react": "^18.2.0",
17
17
  "react-dom": "^18.2.0",
18
18
  "typescript": "5.0.3",
19
- "zod": "^3.19.1",
19
+ "type-fest": "^3.7.1",
20
+ "zod": "^3.21.4",
20
21
  "@webstudio-is/jest-config": "^1.0.6",
21
22
  "@webstudio-is/scripts": "^0.0.0",
22
23
  "@webstudio-is/storybook-config": "^0.0.0",
@@ -36,23 +37,33 @@
36
37
  "nanoevents": "^7.0.1",
37
38
  "nanoid": "^3.2.0",
38
39
  "nanostores": "^0.7.1",
39
- "@webstudio-is/asset-uploader": "^0.68.0",
40
- "@webstudio-is/css-data": "^0.68.0",
41
- "@webstudio-is/css-engine": "^0.68.0",
42
- "@webstudio-is/css-vars": "^0.68.0",
43
- "@webstudio-is/fonts": "^0.68.0",
44
- "@webstudio-is/form-handlers": "^0.68.0",
45
- "@webstudio-is/generate-arg-types": "^0.68.0",
46
- "@webstudio-is/icons": "^0.68.0",
47
- "@webstudio-is/image": "^0.68.0",
48
- "@webstudio-is/prisma-client": "^0.68.0",
49
- "@webstudio-is/project-build": "^0.68.0"
40
+ "@webstudio-is/asset-uploader": "^0.69.0",
41
+ "@webstudio-is/css-data": "^0.69.0",
42
+ "@webstudio-is/css-engine": "^0.69.0",
43
+ "@webstudio-is/css-vars": "^0.69.0",
44
+ "@webstudio-is/fonts": "^0.69.0",
45
+ "@webstudio-is/form-handlers": "^0.69.0",
46
+ "@webstudio-is/generate-arg-types": "^0.69.0",
47
+ "@webstudio-is/icons": "^0.69.0",
48
+ "@webstudio-is/image": "^0.69.0",
49
+ "@webstudio-is/prisma-client": "^0.69.0",
50
+ "@webstudio-is/project-build": "^0.69.0"
50
51
  },
51
52
  "exports": {
52
53
  ".": {
53
54
  "source": "./src/index.ts",
54
55
  "import": "./lib/index.js",
55
56
  "require": "./lib/cjs/index.js"
57
+ },
58
+ "./components": {
59
+ "source": "./src/components/components.ts",
60
+ "import": "./lib/components/components.js",
61
+ "require": "./lib/cjs/components/components.js"
62
+ },
63
+ "./css-normalize": {
64
+ "source": "./src/css/normalize.ts",
65
+ "import": "./lib/css/normalize.js",
66
+ "require": "./lib/cjs/css/normalize.js"
56
67
  }
57
68
  },
58
69
  "types": "lib/types/index.d.ts",
@@ -4,7 +4,7 @@ export const props: Record<string, PropMeta> = {
4
4
  slot: { required: false, control: "text", type: "string" },
5
5
  style: { required: false, control: "text", type: "string" },
6
6
  title: { required: false, control: "text", type: "string" },
7
- alt: { required: false, control: "text", type: "string", defaultValue: "" },
7
+ alt: { required: false, control: "text", type: "string" },
8
8
  crossOrigin: {
9
9
  required: false,
10
10
  control: "radio",
@@ -41,7 +41,7 @@ export const props: Record<string, PropMeta> = {
41
41
  ],
42
42
  },
43
43
  sizes: { required: false, control: "text", type: "string" },
44
- src: { required: false, control: "text", type: "string", defaultValue: "" },
44
+ src: { required: false, control: "text", type: "string" },
45
45
  srcSet: { required: false, control: "text", type: "string" },
46
46
  useMap: { required: false, control: "text", type: "string" },
47
47
  width: { required: false, control: "number", type: "number" },
@@ -481,4 +481,7 @@ export const props: Record<string, PropMeta> = {
481
481
  control: "text",
482
482
  type: "string",
483
483
  },
484
+ quality: { required: false, control: "number", type: "number" },
485
+ loader: { required: true, control: "text", type: "string" },
486
+ optimize: { required: false, control: "boolean", type: "boolean" },
484
487
  };
@@ -440,4 +440,11 @@ export const props: Record<string, PropMeta> = {
440
440
  control: "text",
441
441
  type: "string",
442
442
  },
443
+ tag: {
444
+ required: false,
445
+ control: "radio",
446
+ type: "string",
447
+ defaultValue: "div",
448
+ options: ["div", "figcaption", "span"],
449
+ },
443
450
  };
@@ -60,13 +60,20 @@ const presetStyle = {
60
60
  } satisfies PresetStyle<typeof defaultTag>;
61
61
 
62
62
  export const meta: WsComponentMeta = {
63
- category: "typography",
63
+ category: "text",
64
64
  type: "rich-text",
65
65
  label: "Blockquote",
66
66
  icon: BlockquoteIcon,
67
67
  states: defaultStates,
68
68
  presetStyle,
69
- children: [{ type: "text", value: "Blockquote you can edit" }],
69
+ template: [
70
+ {
71
+ type: "instance",
72
+ component: "Blockquote",
73
+ children: [{ type: "text", value: "Blockquote you can edit" }],
74
+ },
75
+ ],
76
+ order: 3,
70
77
  };
71
78
 
72
79
  export const propsMeta: WsComponentPropsMeta = {
@@ -24,7 +24,7 @@ type Props = ComponentProps<typeof defaultTag> & {
24
24
 
25
25
  export const Box = forwardRef<ElementRef<typeof defaultTag>, Props>(
26
26
  ({ tag = defaultTag, ...props }, ref) => {
27
- return createElement(tag as string, { ...props, ref });
27
+ return createElement(tag, { ...props, ref });
28
28
  }
29
29
  );
30
30
 
@@ -43,6 +43,7 @@ export const meta: WsComponentMeta = {
43
43
  icon: BoxIcon,
44
44
  states: defaultStates,
45
45
  presetStyle,
46
+ order: 0,
46
47
  };
47
48
 
48
49
  export const propsMeta: WsComponentPropsMeta = {
@@ -16,6 +16,7 @@ const presetStyle = {
16
16
  export const meta: WsComponentMeta = {
17
17
  category: "forms",
18
18
  type: "container",
19
+ invalidAncestors: ["Button"],
19
20
  label: "Button",
20
21
  icon: ButtonElementIcon,
21
22
  presetStyle,
@@ -24,6 +25,7 @@ export const meta: WsComponentMeta = {
24
25
  { selector: ":disabled", label: "Disabled" },
25
26
  { selector: ":enabled", label: "Enabled" },
26
27
  ],
28
+ order: 1,
27
29
  };
28
30
 
29
31
  export const propsMeta: WsComponentPropsMeta = {
@@ -23,14 +23,20 @@ export const meta: WsComponentMeta = {
23
23
  icon: CheckboxCheckedIcon,
24
24
  states: defaultStates,
25
25
  presetStyle,
26
- children: [
27
- { type: "instance", component: "Checkbox", props: [], children: [] },
26
+ template: [
28
27
  {
29
28
  type: "instance",
30
- component: "TextBlock",
31
- label: "Checkbox Label",
32
- props: [],
33
- children: [{ type: "text", value: "Checkbox" }],
29
+ component: "CheckboxField",
30
+ children: [
31
+ { type: "instance", component: "Checkbox", children: [] },
32
+ {
33
+ type: "instance",
34
+ component: "TextBlock",
35
+ label: "Checkbox Label",
36
+ props: [],
37
+ children: [{ type: "text", value: "Checkbox" }],
38
+ },
39
+ ],
34
40
  },
35
41
  ],
36
42
  };
@@ -24,6 +24,7 @@ export const meta: WsComponentMeta = {
24
24
  label: "Checkbox Input",
25
25
  icon: CheckboxCheckedIcon,
26
26
  presetStyle,
27
+ order: 6,
27
28
  states: [
28
29
  ...defaultStates,
29
30
  { selector: ":checked", label: "Checked" },
@@ -42,7 +42,14 @@ export const meta: WsComponentMeta = {
42
42
  icon: CodeTextIcon,
43
43
  states: defaultStates,
44
44
  presetStyle,
45
- children: [{ type: "text", value: "Code you can edit" }],
45
+ template: [
46
+ {
47
+ type: "instance",
48
+ component: "CodeText",
49
+ children: [{ type: "text", value: "Code you can edit" }],
50
+ },
51
+ ],
52
+ order: 8,
46
53
  };
47
54
 
48
55
  export const propsMeta: WsComponentPropsMeta = {
@@ -18,7 +18,7 @@ export type WsComponentPropsMeta = z.infer<typeof WsComponentPropsMeta>;
18
18
 
19
19
  export const componentCategories = [
20
20
  "general",
21
- "typography",
21
+ "text",
22
22
  "media",
23
23
  "forms",
24
24
  ] as const;
@@ -55,12 +55,15 @@ const WsComponentMeta = z.object({
55
55
  "rich-text",
56
56
  "rich-text-child",
57
57
  ]),
58
- acceptedParents: z.optional(z.array(z.string())),
58
+ requiredAncestors: z.optional(z.array(z.string())),
59
+ invalidAncestors: z.optional(z.array(z.string())),
60
+ stylable: z.optional(z.boolean()),
59
61
  label: z.string(),
60
62
  icon: z.string(),
61
63
  presetStyle: z.optional(z.record(z.string(), EmbedTemplateStyleDecl)),
62
64
  states: z.optional(z.array(ComponentState)),
63
- children: z.optional(WsEmbedTemplate),
65
+ template: z.optional(WsEmbedTemplate),
66
+ order: z.number().optional(),
64
67
  });
65
68
 
66
69
  export type WsComponentMeta = Omit<
@@ -1,11 +1,6 @@
1
- import * as components from "./components";
2
- import { registeredComponents } from "./index";
3
1
  import { componentAttribute, idAttribute } from "../tree";
4
2
 
5
- export type ComponentName = keyof typeof components;
6
-
7
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
8
- type AnyComponent = React.ForwardRefExoticComponent<
3
+ export type AnyComponent = React.ForwardRefExoticComponent<
9
4
  Omit<
10
5
  React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>,
11
6
  "ref"
@@ -15,28 +10,4 @@ type AnyComponent = React.ForwardRefExoticComponent<
15
10
  } & React.RefAttributes<HTMLElement>
16
11
  >;
17
12
 
18
- /**
19
- * Now used only in builder app
20
- * @todo Consider using the same approach in the builder app as in the published apps . A dynamic import is needed
21
- */
22
- export const getComponent = (name: string): undefined | AnyComponent => {
23
- return registeredComponents != null && name in registeredComponents
24
- ? (registeredComponents[name as ComponentName] as never)
25
- : (components[name as ComponentName] as never);
26
- };
27
-
28
- /**
29
- * The application imports only the components it uses, then pass them to createGetComponent i.e.
30
- * getComponent = createGetComponent({ Box, BlaBla })
31
- * <RootInstance data={data} getComponent={getComponent} />
32
- * see example /packages/sdk-size-test/app/routes/$.tsx
33
- **/
34
- export const createGetComponent = (comps: Partial<typeof components>) => {
35
- return (name: string): undefined | AnyComponent => {
36
- return registeredComponents != null && name in registeredComponents
37
- ? (registeredComponents[name as ComponentName] as never)
38
- : (comps[name as ComponentName] as never);
39
- };
40
- };
41
-
42
- export type GetComponent = typeof getComponent;
13
+ export type Components = Map<string, AnyComponent>;
@@ -23,33 +23,40 @@ export const meta: WsComponentMeta = {
23
23
  icon: FormIcon,
24
24
  states: defaultStates,
25
25
  presetStyle,
26
- children: [
26
+ order: 0,
27
+ template: [
27
28
  {
28
29
  type: "instance",
29
- component: "Label",
30
- children: [{ type: "text", value: "Name" }],
31
- },
32
- {
33
- type: "instance",
34
- component: "Input",
35
- props: [{ type: "string", name: "name", value: "name" }],
36
- children: [],
37
- },
38
- {
39
- type: "instance",
40
- component: "Label",
41
- children: [{ type: "text", value: "Email" }],
42
- },
43
- {
44
- type: "instance",
45
- component: "Input",
46
- props: [{ type: "string", name: "name", value: "email" }],
47
- children: [],
48
- },
49
- {
50
- type: "instance",
51
- component: "Button",
52
- children: [{ type: "text", value: "Submit" }],
30
+ component: "Form",
31
+ children: [
32
+ {
33
+ type: "instance",
34
+ component: "Label",
35
+ children: [{ type: "text", value: "Name" }],
36
+ },
37
+ {
38
+ type: "instance",
39
+ component: "Input",
40
+ props: [{ type: "string", name: "name", value: "name" }],
41
+ children: [],
42
+ },
43
+ {
44
+ type: "instance",
45
+ component: "Label",
46
+ children: [{ type: "text", value: "Email" }],
47
+ },
48
+ {
49
+ type: "instance",
50
+ component: "Input",
51
+ props: [{ type: "string", name: "name", value: "email" }],
52
+ children: [],
53
+ },
54
+ {
55
+ type: "instance",
56
+ component: "Button",
57
+ children: [{ type: "text", value: "Submit" }],
58
+ },
59
+ ],
53
60
  },
54
61
  ],
55
62
  };
@@ -4,6 +4,7 @@ export const meta: WsComponentMeta = {
4
4
  type: "container",
5
5
  label: "Fragment",
6
6
  icon: "",
7
+ stylable: false,
7
8
  };
8
9
 
9
10
  export const propsMeta: WsComponentPropsMeta = {
@@ -13,7 +13,7 @@ type Props = ComponentProps<typeof defaultTag> & {
13
13
 
14
14
  export const Heading = forwardRef<ElementRef<typeof defaultTag>, Props>(
15
15
  ({ tag = defaultTag, ...props }, ref) => {
16
- return createElement(tag as string, { ...props, ref });
16
+ return createElement(tag, { ...props, ref });
17
17
  }
18
18
  );
19
19
 
@@ -22,13 +22,20 @@ const presetStyle = {
22
22
  } satisfies PresetStyle<HeadingTags>;
23
23
 
24
24
  export const meta: WsComponentMeta = {
25
- category: "typography",
25
+ category: "text",
26
26
  type: "rich-text",
27
27
  label: "Heading",
28
28
  icon: HeadingIcon,
29
- children: [{ type: "text", value: "Heading you can edit" }],
30
29
  states: defaultStates,
31
30
  presetStyle,
31
+ template: [
32
+ {
33
+ type: "instance",
34
+ component: "Heading",
35
+ children: [{ type: "text", value: "Heading you can edit" }],
36
+ },
37
+ ],
38
+ order: 1,
32
39
  };
33
40
 
34
41
  export const propsMeta: WsComponentPropsMeta = {
@@ -7,6 +7,8 @@ export const meta: WsComponentMeta = {
7
7
  type: "embed",
8
8
  label: "HTML Embed",
9
9
  icon: EmbedIcon,
10
+ stylable: false,
11
+ order: 7,
10
12
  };
11
13
 
12
14
  export const propsMeta: WsComponentPropsMeta = {