@webstudio-is/react-sdk 0.8.0 → 0.10.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 (612) hide show
  1. package/lib/app/custom-components/image.js +46 -0
  2. package/lib/app/custom-components/index.js +18 -0
  3. package/lib/app/custom-components/link.js +6 -0
  4. package/lib/app/custom-components/rich-text-link.js +6 -0
  5. package/lib/app/custom-components/shared/remix-link.js +29 -0
  6. package/lib/app/handle-request.server.js +19 -0
  7. package/lib/{remix → app}/index.js +1 -0
  8. package/lib/app/params.js +10 -0
  9. package/lib/app/root.js +40 -0
  10. package/lib/cjs/app/custom-components/image.cjs +63 -0
  11. package/lib/cjs/app/custom-components/index.cjs +38 -0
  12. package/lib/cjs/app/custom-components/link.cjs +26 -0
  13. package/lib/cjs/app/custom-components/rich-text-link.cjs +26 -0
  14. package/lib/cjs/app/custom-components/shared/remix-link.cjs +49 -0
  15. package/lib/cjs/app/handle-request.server.cjs +39 -0
  16. package/lib/cjs/app/index.cjs +20 -0
  17. package/lib/cjs/app/params.cjs +30 -0
  18. package/lib/cjs/app/root.cjs +60 -0
  19. package/lib/cjs/components/__generated__/body.props.json +491 -0
  20. package/lib/cjs/components/__generated__/bold.props.json +491 -0
  21. package/lib/cjs/components/__generated__/box.props.json +508 -0
  22. package/lib/cjs/components/__generated__/button.props.json +547 -0
  23. package/lib/cjs/components/__generated__/form.props.json +531 -0
  24. package/lib/cjs/components/__generated__/heading.props.json +497 -0
  25. package/lib/cjs/components/__generated__/image.props.json +560 -0
  26. package/lib/cjs/components/__generated__/input.props.json +657 -0
  27. package/lib/cjs/components/__generated__/italic.props.json +491 -0
  28. package/lib/cjs/components/__generated__/link.props.json +547 -0
  29. package/lib/cjs/components/__generated__/paragraph.props.json +491 -0
  30. package/lib/cjs/components/__generated__/rich-text-link.props.json +547 -0
  31. package/lib/cjs/components/__generated__/span.props.json +491 -0
  32. package/lib/cjs/components/__generated__/subscript.props.json +491 -0
  33. package/lib/cjs/components/__generated__/superscript.props.json +491 -0
  34. package/lib/cjs/components/__generated__/text-block.props.json +491 -0
  35. package/lib/cjs/components/body.cjs +29 -6
  36. package/lib/cjs/components/body.ws.cjs +83 -59
  37. package/lib/cjs/components/bold.cjs +29 -6
  38. package/lib/cjs/components/bold.ws.cjs +35 -11
  39. package/lib/cjs/components/box.cjs +29 -7
  40. package/lib/cjs/components/box.ws.cjs +40 -16
  41. package/lib/cjs/components/button.cjs +33 -8
  42. package/lib/cjs/components/button.ws.cjs +36 -12
  43. package/lib/cjs/components/component-type.cjs +77 -27
  44. package/lib/cjs/components/form.cjs +29 -6
  45. package/lib/cjs/components/form.ws.cjs +45 -21
  46. package/lib/cjs/components/heading.cjs +29 -7
  47. package/lib/cjs/components/heading.ws.cjs +36 -12
  48. package/lib/cjs/components/image.cjs +39 -14
  49. package/lib/cjs/components/image.ws.cjs +45 -24
  50. package/lib/cjs/components/index.cjs +145 -35
  51. package/lib/cjs/components/input.cjs +29 -6
  52. package/lib/cjs/components/input.ws.cjs +35 -11
  53. package/lib/cjs/components/italic.cjs +29 -6
  54. package/lib/cjs/components/italic.ws.cjs +40 -16
  55. package/lib/cjs/components/link.cjs +32 -7
  56. package/lib/cjs/components/link.ws.cjs +46 -22
  57. package/lib/cjs/components/paragraph.cjs +29 -6
  58. package/lib/cjs/components/paragraph.ws.cjs +36 -12
  59. package/lib/cjs/components/rich-text-link.cjs +33 -0
  60. package/lib/cjs/components/rich-text-link.ws.cjs +38 -0
  61. package/lib/cjs/components/span.cjs +29 -6
  62. package/lib/cjs/components/span.ws.cjs +35 -11
  63. package/lib/cjs/components/subscript.cjs +29 -6
  64. package/lib/cjs/components/subscript.ws.cjs +35 -11
  65. package/lib/cjs/components/superscript.cjs +29 -6
  66. package/lib/cjs/components/superscript.ws.cjs +35 -11
  67. package/lib/cjs/components/text-block.cjs +29 -6
  68. package/lib/cjs/components/text-block.ws.cjs +42 -18
  69. package/lib/cjs/css/breakpoints.cjs +27 -7
  70. package/lib/cjs/css/categories.cjs +218 -203
  71. package/lib/cjs/css/get-browser-style.cjs +56 -40
  72. package/lib/cjs/css/index.cjs +18 -17
  73. package/lib/cjs/db/index.cjs +17 -16
  74. package/lib/cjs/db/instance.cjs +37 -17
  75. package/lib/cjs/db/types.cjs +15 -1
  76. package/lib/cjs/index.cjs +30 -34
  77. package/lib/cjs/pubsub/create.cjs +76 -61
  78. package/lib/cjs/pubsub/index.cjs +16 -15
  79. package/lib/cjs/tree/create-elements-tree.cjs +90 -48
  80. package/lib/cjs/tree/index.cjs +18 -17
  81. package/lib/cjs/tree/root.cjs +43 -15
  82. package/lib/cjs/tree/session-storage-polyfill.cjs +60 -37
  83. package/lib/cjs/tree/wrapper-component.cjs +53 -46
  84. package/lib/cjs/user-props/all-user-props.cjs +35 -17
  85. package/lib/cjs/user-props/index.cjs +19 -18
  86. package/lib/cjs/user-props/schema.cjs +52 -31
  87. package/lib/cjs/user-props/types.cjs +15 -1
  88. package/lib/cjs/user-props/use-user-props-asset.cjs +41 -0
  89. package/lib/cjs/user-props/use-user-props.cjs +38 -30
  90. package/lib/components/__generated__/body.props.json +491 -0
  91. package/lib/components/__generated__/bold.props.json +491 -0
  92. package/lib/components/__generated__/box.props.json +508 -0
  93. package/lib/components/__generated__/button.props.json +547 -0
  94. package/lib/components/__generated__/form.props.json +531 -0
  95. package/lib/components/__generated__/heading.props.json +497 -0
  96. package/lib/components/__generated__/image.props.json +560 -0
  97. package/lib/components/__generated__/input.props.json +657 -0
  98. package/lib/components/__generated__/italic.props.json +491 -0
  99. package/lib/components/__generated__/link.props.json +547 -0
  100. package/lib/components/__generated__/paragraph.props.json +491 -0
  101. package/lib/components/__generated__/rich-text-link.props.json +547 -0
  102. package/lib/components/__generated__/span.props.json +491 -0
  103. package/lib/components/__generated__/subscript.props.json +491 -0
  104. package/lib/components/__generated__/superscript.props.json +491 -0
  105. package/lib/components/__generated__/text-block.props.json +491 -0
  106. package/lib/components/body.js +8 -2
  107. package/lib/components/body.ws.js +57 -57
  108. package/lib/components/bold.js +8 -2
  109. package/lib/components/bold.ws.js +9 -9
  110. package/lib/components/box.js +11 -3
  111. package/lib/components/box.ws.js +14 -14
  112. package/lib/components/button.js +11 -3
  113. package/lib/components/button.ws.js +10 -10
  114. package/lib/components/component-type.js +54 -21
  115. package/lib/components/form.js +8 -2
  116. package/lib/components/form.ws.js +19 -19
  117. package/lib/components/heading.js +11 -3
  118. package/lib/components/heading.ws.js +10 -10
  119. package/lib/components/image.js +17 -9
  120. package/lib/components/image.ws.js +19 -22
  121. package/lib/components/index.js +120 -15
  122. package/lib/components/input.js +8 -2
  123. package/lib/components/input.ws.js +9 -9
  124. package/lib/components/italic.js +8 -2
  125. package/lib/components/italic.ws.js +14 -14
  126. package/lib/components/link.js +11 -3
  127. package/lib/components/link.ws.js +20 -20
  128. package/lib/components/paragraph.js +8 -2
  129. package/lib/components/paragraph.ws.js +10 -10
  130. package/lib/components/rich-text-link.js +13 -0
  131. package/lib/components/rich-text-link.ws.js +12 -0
  132. package/lib/components/span.js +8 -2
  133. package/lib/components/span.ws.js +9 -9
  134. package/lib/components/subscript.js +8 -2
  135. package/lib/components/subscript.ws.js +9 -9
  136. package/lib/components/superscript.js +8 -2
  137. package/lib/components/superscript.ws.js +9 -9
  138. package/lib/components/text-block.js +8 -2
  139. package/lib/components/text-block.ws.js +16 -16
  140. package/lib/css/breakpoints.js +8 -5
  141. package/lib/css/categories.js +198 -200
  142. package/lib/css/get-browser-style.js +35 -35
  143. package/lib/db/instance.js +14 -10
  144. package/lib/db/types.js +0 -1
  145. package/lib/index.js +10 -3
  146. package/lib/pubsub/create.js +51 -55
  147. package/lib/tree/create-elements-tree.js +68 -42
  148. package/lib/tree/root.js +21 -9
  149. package/lib/tree/session-storage-polyfill.js +41 -34
  150. package/lib/tree/wrapper-component.js +34 -19
  151. package/lib/user-props/all-user-props.js +15 -13
  152. package/lib/user-props/schema.js +33 -29
  153. package/lib/user-props/types.js +0 -1
  154. package/lib/user-props/use-user-props-asset.js +21 -0
  155. package/lib/user-props/use-user-props.js +19 -27
  156. package/package.json +14 -24
  157. package/src/app/custom-components/image.tsx +62 -0
  158. package/src/app/custom-components/index.ts +17 -0
  159. package/src/app/custom-components/link.tsx +4 -0
  160. package/src/app/custom-components/rich-text-link.tsx +4 -0
  161. package/src/app/custom-components/shared/remix-link.tsx +40 -0
  162. package/src/app/handle-request.server.tsx +21 -0
  163. package/{lib/cjs/remix/index.d.ts → src/app/index.ts} +1 -1
  164. package/src/app/params.ts +13 -0
  165. package/src/app/root.tsx +27 -0
  166. package/src/components/__generated__/body.props.json +491 -0
  167. package/src/components/__generated__/bold.props.json +491 -0
  168. package/src/components/__generated__/box.props.json +508 -0
  169. package/src/components/__generated__/button.props.json +547 -0
  170. package/src/components/__generated__/form.props.json +531 -0
  171. package/src/components/__generated__/heading.props.json +497 -0
  172. package/src/components/__generated__/image.props.json +560 -0
  173. package/src/components/__generated__/input.props.json +657 -0
  174. package/src/components/__generated__/italic.props.json +491 -0
  175. package/src/components/__generated__/link.props.json +547 -0
  176. package/src/components/__generated__/paragraph.props.json +491 -0
  177. package/src/components/__generated__/rich-text-link.props.json +547 -0
  178. package/src/components/__generated__/span.props.json +491 -0
  179. package/src/components/__generated__/subscript.props.json +491 -0
  180. package/src/components/__generated__/superscript.props.json +491 -0
  181. package/src/components/__generated__/text-block.props.json +491 -0
  182. package/src/components/body.stories.tsx +11 -0
  183. package/src/components/body.tsx +10 -0
  184. package/src/components/body.ws.tsx +63 -0
  185. package/src/components/bold.stories.tsx +16 -0
  186. package/src/components/bold.tsx +10 -0
  187. package/src/components/bold.ws.tsx +12 -0
  188. package/src/components/box.stories.tsx +17 -0
  189. package/src/components/box.tsx +31 -0
  190. package/src/components/box.ws.ts +20 -0
  191. package/src/components/button.stories.tsx +17 -0
  192. package/src/components/button.tsx +14 -0
  193. package/src/components/button.ws.tsx +13 -0
  194. package/src/components/component-type.ts +89 -0
  195. package/src/components/form.stories.tsx +14 -0
  196. package/src/components/form.tsx +10 -0
  197. package/src/components/form.ws.tsx +25 -0
  198. package/src/components/heading.stories.tsx +16 -0
  199. package/src/components/heading.tsx +20 -0
  200. package/src/components/heading.ws.tsx +13 -0
  201. package/src/components/image.stories.tsx +15 -0
  202. package/src/components/image.tsx +52 -0
  203. package/src/components/image.ws.tsx +28 -0
  204. package/src/components/index.test.ts +28 -0
  205. package/src/components/index.ts +159 -0
  206. package/src/components/input.stories.tsx +14 -0
  207. package/src/components/input.tsx +11 -0
  208. package/src/components/input.ws.tsx +12 -0
  209. package/src/components/italic.stories.tsx +16 -0
  210. package/src/components/italic.tsx +10 -0
  211. package/src/components/italic.ws.tsx +20 -0
  212. package/src/components/link.stories.tsx +16 -0
  213. package/src/components/link.tsx +9 -0
  214. package/src/components/link.ws.tsx +26 -0
  215. package/src/components/paragraph.stories.tsx +16 -0
  216. package/src/components/paragraph.tsx +10 -0
  217. package/src/components/paragraph.ws.tsx +13 -0
  218. package/src/components/rich-text-link.stories.tsx +16 -0
  219. package/src/components/rich-text-link.tsx +9 -0
  220. package/src/components/rich-text-link.ws.tsx +12 -0
  221. package/src/components/span.stories.tsx +16 -0
  222. package/src/components/span.tsx +10 -0
  223. package/src/components/span.ws.tsx +12 -0
  224. package/src/components/subscript.stories.tsx +16 -0
  225. package/src/components/subscript.tsx +10 -0
  226. package/src/components/subscript.ws.tsx +12 -0
  227. package/src/components/superscript.stories.tsx +16 -0
  228. package/src/components/superscript.tsx +10 -0
  229. package/src/components/superscript.ws.tsx +12 -0
  230. package/src/components/text-block.stories.tsx +16 -0
  231. package/src/components/text-block.tsx +10 -0
  232. package/src/components/text-block.ws.tsx +22 -0
  233. package/src/css/breakpoints.ts +10 -0
  234. package/src/css/categories.ts +254 -0
  235. package/src/css/get-browser-style.ts +50 -0
  236. package/{lib/cjs/css/index.d.ts → src/css/index.ts} +0 -1
  237. package/{lib/cjs/db/index.d.ts → src/db/index.ts} +0 -1
  238. package/src/db/instance.ts +34 -0
  239. package/src/db/types.ts +18 -0
  240. package/src/index.ts +12 -0
  241. package/src/pubsub/create.ts +84 -0
  242. package/src/pubsub/index.ts +1 -0
  243. package/src/tree/create-elements-tree.tsx +102 -0
  244. package/{lib/tree/index.d.ts → src/tree/index.ts} +0 -1
  245. package/src/tree/root.ts +45 -0
  246. package/src/tree/session-storage-polyfill.tsx +50 -0
  247. package/src/tree/wrapper-component.tsx +48 -0
  248. package/src/user-props/all-user-props.ts +22 -0
  249. package/{lib/cjs/user-props/index.d.ts → src/user-props/index.ts} +0 -1
  250. package/src/user-props/schema.ts +35 -0
  251. package/src/user-props/types.ts +14 -0
  252. package/src/user-props/use-user-props-asset.ts +31 -0
  253. package/src/user-props/use-user-props.ts +30 -0
  254. package/lib/arg-types/utils.d.ts +0 -10
  255. package/lib/arg-types/utils.d.ts.map +0 -1
  256. package/lib/arg-types/utils.js +0 -83
  257. package/lib/cjs/arg-types/utils.cjs +0 -88
  258. package/lib/cjs/arg-types/utils.d.ts +0 -10
  259. package/lib/cjs/arg-types/utils.d.ts.map +0 -1
  260. package/lib/cjs/components/body.d.ts +0 -3
  261. package/lib/cjs/components/body.d.ts.map +0 -1
  262. package/lib/cjs/components/body.props.json +0 -491
  263. package/lib/cjs/components/body.stories.cjs +0 -11
  264. package/lib/cjs/components/body.stories.d.ts +0 -7
  265. package/lib/cjs/components/body.stories.d.ts.map +0 -1
  266. package/lib/cjs/components/body.ws.d.ts +0 -5
  267. package/lib/cjs/components/body.ws.d.ts.map +0 -1
  268. package/lib/cjs/components/bold.d.ts +0 -3
  269. package/lib/cjs/components/bold.d.ts.map +0 -1
  270. package/lib/cjs/components/bold.props.json +0 -491
  271. package/lib/cjs/components/bold.stories.cjs +0 -14
  272. package/lib/cjs/components/bold.stories.d.ts +0 -6
  273. package/lib/cjs/components/bold.stories.d.ts.map +0 -1
  274. package/lib/cjs/components/bold.ws.d.ts +0 -5
  275. package/lib/cjs/components/bold.ws.d.ts.map +0 -1
  276. package/lib/cjs/components/box.d.ts +0 -8
  277. package/lib/cjs/components/box.d.ts.map +0 -1
  278. package/lib/cjs/components/box.props.json +0 -508
  279. package/lib/cjs/components/box.stories.cjs +0 -12
  280. package/lib/cjs/components/box.stories.d.ts +0 -10
  281. package/lib/cjs/components/box.stories.d.ts.map +0 -1
  282. package/lib/cjs/components/box.ws.d.ts +0 -5
  283. package/lib/cjs/components/box.ws.d.ts.map +0 -1
  284. package/lib/cjs/components/button.d.ts +0 -3
  285. package/lib/cjs/components/button.d.ts.map +0 -1
  286. package/lib/cjs/components/button.props.json +0 -547
  287. package/lib/cjs/components/button.stories.cjs +0 -14
  288. package/lib/cjs/components/button.stories.d.ts +0 -6
  289. package/lib/cjs/components/button.stories.d.ts.map +0 -1
  290. package/lib/cjs/components/button.ws.d.ts +0 -5
  291. package/lib/cjs/components/button.ws.d.ts.map +0 -1
  292. package/lib/cjs/components/component-type.d.ts +0 -17
  293. package/lib/cjs/components/component-type.d.ts.map +0 -1
  294. package/lib/cjs/components/form.d.ts +0 -3
  295. package/lib/cjs/components/form.d.ts.map +0 -1
  296. package/lib/cjs/components/form.props.json +0 -531
  297. package/lib/cjs/components/form.stories.cjs +0 -12
  298. package/lib/cjs/components/form.stories.d.ts +0 -6
  299. package/lib/cjs/components/form.stories.d.ts.map +0 -1
  300. package/lib/cjs/components/form.ws.d.ts +0 -5
  301. package/lib/cjs/components/form.ws.d.ts.map +0 -1
  302. package/lib/cjs/components/heading.d.ts +0 -8
  303. package/lib/cjs/components/heading.d.ts.map +0 -1
  304. package/lib/cjs/components/heading.props.json +0 -497
  305. package/lib/cjs/components/heading.stories.cjs +0 -14
  306. package/lib/cjs/components/heading.stories.d.ts +0 -10
  307. package/lib/cjs/components/heading.stories.d.ts.map +0 -1
  308. package/lib/cjs/components/heading.ws.d.ts +0 -5
  309. package/lib/cjs/components/heading.ws.d.ts.map +0 -1
  310. package/lib/cjs/components/image.d.ts +0 -3
  311. package/lib/cjs/components/image.d.ts.map +0 -1
  312. package/lib/cjs/components/image.props.json +0 -575
  313. package/lib/cjs/components/image.stories.cjs +0 -12
  314. package/lib/cjs/components/image.stories.d.ts +0 -6
  315. package/lib/cjs/components/image.stories.d.ts.map +0 -1
  316. package/lib/cjs/components/image.ws.d.ts +0 -5
  317. package/lib/cjs/components/image.ws.d.ts.map +0 -1
  318. package/lib/cjs/components/index.d.ts +0 -16
  319. package/lib/cjs/components/index.d.ts.map +0 -1
  320. package/lib/cjs/components/index.test.cjs +0 -33
  321. package/lib/cjs/components/index.test.d.ts +0 -2
  322. package/lib/cjs/components/index.test.d.ts.map +0 -1
  323. package/lib/cjs/components/input.d.ts +0 -3
  324. package/lib/cjs/components/input.d.ts.map +0 -1
  325. package/lib/cjs/components/input.props.json +0 -657
  326. package/lib/cjs/components/input.stories.cjs +0 -12
  327. package/lib/cjs/components/input.stories.d.ts +0 -6
  328. package/lib/cjs/components/input.stories.d.ts.map +0 -1
  329. package/lib/cjs/components/input.ws.d.ts +0 -5
  330. package/lib/cjs/components/input.ws.d.ts.map +0 -1
  331. package/lib/cjs/components/italic.d.ts +0 -3
  332. package/lib/cjs/components/italic.d.ts.map +0 -1
  333. package/lib/cjs/components/italic.props.json +0 -491
  334. package/lib/cjs/components/italic.stories.cjs +0 -14
  335. package/lib/cjs/components/italic.stories.d.ts +0 -6
  336. package/lib/cjs/components/italic.stories.d.ts.map +0 -1
  337. package/lib/cjs/components/italic.ws.d.ts +0 -5
  338. package/lib/cjs/components/italic.ws.d.ts.map +0 -1
  339. package/lib/cjs/components/link.d.ts +0 -8
  340. package/lib/cjs/components/link.d.ts.map +0 -1
  341. package/lib/cjs/components/link.props.json +0 -547
  342. package/lib/cjs/components/link.stories.cjs +0 -14
  343. package/lib/cjs/components/link.stories.d.ts +0 -10
  344. package/lib/cjs/components/link.stories.d.ts.map +0 -1
  345. package/lib/cjs/components/link.ws.d.ts +0 -5
  346. package/lib/cjs/components/link.ws.d.ts.map +0 -1
  347. package/lib/cjs/components/meta.cjs +0 -40
  348. package/lib/cjs/components/meta.d.ts +0 -7479
  349. package/lib/cjs/components/meta.d.ts.map +0 -1
  350. package/lib/cjs/components/paragraph.d.ts +0 -3
  351. package/lib/cjs/components/paragraph.d.ts.map +0 -1
  352. package/lib/cjs/components/paragraph.props.json +0 -491
  353. package/lib/cjs/components/paragraph.stories.cjs +0 -14
  354. package/lib/cjs/components/paragraph.stories.d.ts +0 -6
  355. package/lib/cjs/components/paragraph.stories.d.ts.map +0 -1
  356. package/lib/cjs/components/paragraph.ws.d.ts +0 -5
  357. package/lib/cjs/components/paragraph.ws.d.ts.map +0 -1
  358. package/lib/cjs/components/span.d.ts +0 -3
  359. package/lib/cjs/components/span.d.ts.map +0 -1
  360. package/lib/cjs/components/span.props.json +0 -491
  361. package/lib/cjs/components/span.stories.cjs +0 -14
  362. package/lib/cjs/components/span.stories.d.ts +0 -6
  363. package/lib/cjs/components/span.stories.d.ts.map +0 -1
  364. package/lib/cjs/components/span.ws.d.ts +0 -5
  365. package/lib/cjs/components/span.ws.d.ts.map +0 -1
  366. package/lib/cjs/components/subscript.d.ts +0 -3
  367. package/lib/cjs/components/subscript.d.ts.map +0 -1
  368. package/lib/cjs/components/subscript.props.json +0 -491
  369. package/lib/cjs/components/subscript.stories.cjs +0 -14
  370. package/lib/cjs/components/subscript.stories.d.ts +0 -6
  371. package/lib/cjs/components/subscript.stories.d.ts.map +0 -1
  372. package/lib/cjs/components/subscript.ws.d.ts +0 -5
  373. package/lib/cjs/components/subscript.ws.d.ts.map +0 -1
  374. package/lib/cjs/components/superscript.d.ts +0 -3
  375. package/lib/cjs/components/superscript.d.ts.map +0 -1
  376. package/lib/cjs/components/superscript.props.json +0 -491
  377. package/lib/cjs/components/superscript.stories.cjs +0 -14
  378. package/lib/cjs/components/superscript.stories.d.ts +0 -6
  379. package/lib/cjs/components/superscript.stories.d.ts.map +0 -1
  380. package/lib/cjs/components/superscript.ws.d.ts +0 -5
  381. package/lib/cjs/components/superscript.ws.d.ts.map +0 -1
  382. package/lib/cjs/components/text-block.d.ts +0 -3
  383. package/lib/cjs/components/text-block.d.ts.map +0 -1
  384. package/lib/cjs/components/text-block.props.json +0 -491
  385. package/lib/cjs/components/text-block.stories.cjs +0 -14
  386. package/lib/cjs/components/text-block.stories.d.ts +0 -6
  387. package/lib/cjs/components/text-block.stories.d.ts.map +0 -1
  388. package/lib/cjs/components/text-block.ws.d.ts +0 -5
  389. package/lib/cjs/components/text-block.ws.d.ts.map +0 -1
  390. package/lib/cjs/css/breakpoints.d.ts +0 -4
  391. package/lib/cjs/css/breakpoints.d.ts.map +0 -1
  392. package/lib/cjs/css/categories.d.ts +0 -408
  393. package/lib/cjs/css/categories.d.ts.map +0 -1
  394. package/lib/cjs/css/get-browser-style.d.ts +0 -3
  395. package/lib/cjs/css/get-browser-style.d.ts.map +0 -1
  396. package/lib/cjs/css/index.d.ts.map +0 -1
  397. package/lib/cjs/db/index.d.ts.map +0 -1
  398. package/lib/cjs/db/instance.d.ts +0 -14
  399. package/lib/cjs/db/instance.d.ts.map +0 -1
  400. package/lib/cjs/db/types.d.ts +0 -17
  401. package/lib/cjs/db/types.d.ts.map +0 -1
  402. package/lib/cjs/index.d.ts +0 -9
  403. package/lib/cjs/index.d.ts.map +0 -1
  404. package/lib/cjs/pubsub/create.d.ts +0 -29
  405. package/lib/cjs/pubsub/create.d.ts.map +0 -1
  406. package/lib/cjs/pubsub/index.d.ts +0 -2
  407. package/lib/cjs/pubsub/index.d.ts.map +0 -1
  408. package/lib/cjs/remix/handle-request.server.cjs +0 -15
  409. package/lib/cjs/remix/handle-request.server.d.ts +0 -3
  410. package/lib/cjs/remix/handle-request.server.d.ts.map +0 -1
  411. package/lib/cjs/remix/index.cjs +0 -18
  412. package/lib/cjs/remix/index.d.ts.map +0 -1
  413. package/lib/cjs/remix/root.cjs +0 -13
  414. package/lib/cjs/remix/root.d.ts +0 -8
  415. package/lib/cjs/remix/root.d.ts.map +0 -1
  416. package/lib/cjs/tree/create-elements-tree.d.ts +0 -19
  417. package/lib/cjs/tree/create-elements-tree.d.ts.map +0 -1
  418. package/lib/cjs/tree/index.d.ts +0 -4
  419. package/lib/cjs/tree/index.d.ts.map +0 -1
  420. package/lib/cjs/tree/root.d.ts +0 -18
  421. package/lib/cjs/tree/root.d.ts.map +0 -1
  422. package/lib/cjs/tree/session-storage-polyfill.d.ts +0 -2
  423. package/lib/cjs/tree/session-storage-polyfill.d.ts.map +0 -1
  424. package/lib/cjs/tree/wrapper-component.d.ts +0 -12
  425. package/lib/cjs/tree/wrapper-component.d.ts.map +0 -1
  426. package/lib/cjs/user-props/all-user-props.d.ts +0 -8
  427. package/lib/cjs/user-props/all-user-props.d.ts.map +0 -1
  428. package/lib/cjs/user-props/index.d.ts.map +0 -1
  429. package/lib/cjs/user-props/schema.d.ts +0 -72
  430. package/lib/cjs/user-props/schema.d.ts.map +0 -1
  431. package/lib/cjs/user-props/types.d.ts +0 -13
  432. package/lib/cjs/user-props/types.d.ts.map +0 -1
  433. package/lib/cjs/user-props/use-user-props.d.ts +0 -12
  434. package/lib/cjs/user-props/use-user-props.d.ts.map +0 -1
  435. package/lib/components/body.d.ts +0 -3
  436. package/lib/components/body.d.ts.map +0 -1
  437. package/lib/components/body.props.json +0 -491
  438. package/lib/components/body.stories.d.ts +0 -7
  439. package/lib/components/body.stories.d.ts.map +0 -1
  440. package/lib/components/body.stories.js +0 -7
  441. package/lib/components/body.ws.d.ts +0 -5
  442. package/lib/components/body.ws.d.ts.map +0 -1
  443. package/lib/components/bold.d.ts +0 -3
  444. package/lib/components/bold.d.ts.map +0 -1
  445. package/lib/components/bold.props.json +0 -491
  446. package/lib/components/bold.stories.d.ts +0 -6
  447. package/lib/components/bold.stories.d.ts.map +0 -1
  448. package/lib/components/bold.stories.js +0 -11
  449. package/lib/components/bold.ws.d.ts +0 -5
  450. package/lib/components/bold.ws.d.ts.map +0 -1
  451. package/lib/components/box.d.ts +0 -8
  452. package/lib/components/box.d.ts.map +0 -1
  453. package/lib/components/box.props.json +0 -508
  454. package/lib/components/box.stories.d.ts +0 -10
  455. package/lib/components/box.stories.d.ts.map +0 -1
  456. package/lib/components/box.stories.js +0 -9
  457. package/lib/components/box.ws.d.ts +0 -5
  458. package/lib/components/box.ws.d.ts.map +0 -1
  459. package/lib/components/button.d.ts +0 -3
  460. package/lib/components/button.d.ts.map +0 -1
  461. package/lib/components/button.props.json +0 -547
  462. package/lib/components/button.stories.d.ts +0 -6
  463. package/lib/components/button.stories.d.ts.map +0 -1
  464. package/lib/components/button.stories.js +0 -11
  465. package/lib/components/button.ws.d.ts +0 -5
  466. package/lib/components/button.ws.d.ts.map +0 -1
  467. package/lib/components/component-type.d.ts +0 -17
  468. package/lib/components/component-type.d.ts.map +0 -1
  469. package/lib/components/form.d.ts +0 -3
  470. package/lib/components/form.d.ts.map +0 -1
  471. package/lib/components/form.props.json +0 -531
  472. package/lib/components/form.stories.d.ts +0 -6
  473. package/lib/components/form.stories.d.ts.map +0 -1
  474. package/lib/components/form.stories.js +0 -9
  475. package/lib/components/form.ws.d.ts +0 -5
  476. package/lib/components/form.ws.d.ts.map +0 -1
  477. package/lib/components/heading.d.ts +0 -8
  478. package/lib/components/heading.d.ts.map +0 -1
  479. package/lib/components/heading.props.json +0 -497
  480. package/lib/components/heading.stories.d.ts +0 -10
  481. package/lib/components/heading.stories.d.ts.map +0 -1
  482. package/lib/components/heading.stories.js +0 -11
  483. package/lib/components/heading.ws.d.ts +0 -5
  484. package/lib/components/heading.ws.d.ts.map +0 -1
  485. package/lib/components/image.d.ts +0 -3
  486. package/lib/components/image.d.ts.map +0 -1
  487. package/lib/components/image.props.json +0 -575
  488. package/lib/components/image.stories.d.ts +0 -6
  489. package/lib/components/image.stories.d.ts.map +0 -1
  490. package/lib/components/image.stories.js +0 -9
  491. package/lib/components/image.ws.d.ts +0 -5
  492. package/lib/components/image.ws.d.ts.map +0 -1
  493. package/lib/components/index.d.ts +0 -16
  494. package/lib/components/index.d.ts.map +0 -1
  495. package/lib/components/index.test.d.ts +0 -2
  496. package/lib/components/index.test.d.ts.map +0 -1
  497. package/lib/components/index.test.js +0 -8
  498. package/lib/components/input.d.ts +0 -3
  499. package/lib/components/input.d.ts.map +0 -1
  500. package/lib/components/input.props.json +0 -657
  501. package/lib/components/input.stories.d.ts +0 -6
  502. package/lib/components/input.stories.d.ts.map +0 -1
  503. package/lib/components/input.stories.js +0 -9
  504. package/lib/components/input.ws.d.ts +0 -5
  505. package/lib/components/input.ws.d.ts.map +0 -1
  506. package/lib/components/italic.d.ts +0 -3
  507. package/lib/components/italic.d.ts.map +0 -1
  508. package/lib/components/italic.props.json +0 -491
  509. package/lib/components/italic.stories.d.ts +0 -6
  510. package/lib/components/italic.stories.d.ts.map +0 -1
  511. package/lib/components/italic.stories.js +0 -11
  512. package/lib/components/italic.ws.d.ts +0 -5
  513. package/lib/components/italic.ws.d.ts.map +0 -1
  514. package/lib/components/link.d.ts +0 -8
  515. package/lib/components/link.d.ts.map +0 -1
  516. package/lib/components/link.props.json +0 -547
  517. package/lib/components/link.stories.d.ts +0 -10
  518. package/lib/components/link.stories.d.ts.map +0 -1
  519. package/lib/components/link.stories.js +0 -11
  520. package/lib/components/link.ws.d.ts +0 -5
  521. package/lib/components/link.ws.d.ts.map +0 -1
  522. package/lib/components/meta.d.ts +0 -7479
  523. package/lib/components/meta.d.ts.map +0 -1
  524. package/lib/components/meta.js +0 -34
  525. package/lib/components/paragraph.d.ts +0 -3
  526. package/lib/components/paragraph.d.ts.map +0 -1
  527. package/lib/components/paragraph.props.json +0 -491
  528. package/lib/components/paragraph.stories.d.ts +0 -6
  529. package/lib/components/paragraph.stories.d.ts.map +0 -1
  530. package/lib/components/paragraph.stories.js +0 -11
  531. package/lib/components/paragraph.ws.d.ts +0 -5
  532. package/lib/components/paragraph.ws.d.ts.map +0 -1
  533. package/lib/components/span.d.ts +0 -3
  534. package/lib/components/span.d.ts.map +0 -1
  535. package/lib/components/span.props.json +0 -491
  536. package/lib/components/span.stories.d.ts +0 -6
  537. package/lib/components/span.stories.d.ts.map +0 -1
  538. package/lib/components/span.stories.js +0 -11
  539. package/lib/components/span.ws.d.ts +0 -5
  540. package/lib/components/span.ws.d.ts.map +0 -1
  541. package/lib/components/subscript.d.ts +0 -3
  542. package/lib/components/subscript.d.ts.map +0 -1
  543. package/lib/components/subscript.props.json +0 -491
  544. package/lib/components/subscript.stories.d.ts +0 -6
  545. package/lib/components/subscript.stories.d.ts.map +0 -1
  546. package/lib/components/subscript.stories.js +0 -11
  547. package/lib/components/subscript.ws.d.ts +0 -5
  548. package/lib/components/subscript.ws.d.ts.map +0 -1
  549. package/lib/components/superscript.d.ts +0 -3
  550. package/lib/components/superscript.d.ts.map +0 -1
  551. package/lib/components/superscript.props.json +0 -491
  552. package/lib/components/superscript.stories.d.ts +0 -6
  553. package/lib/components/superscript.stories.d.ts.map +0 -1
  554. package/lib/components/superscript.stories.js +0 -11
  555. package/lib/components/superscript.ws.d.ts +0 -5
  556. package/lib/components/superscript.ws.d.ts.map +0 -1
  557. package/lib/components/text-block.d.ts +0 -3
  558. package/lib/components/text-block.d.ts.map +0 -1
  559. package/lib/components/text-block.props.json +0 -491
  560. package/lib/components/text-block.stories.d.ts +0 -6
  561. package/lib/components/text-block.stories.d.ts.map +0 -1
  562. package/lib/components/text-block.stories.js +0 -11
  563. package/lib/components/text-block.ws.d.ts +0 -5
  564. package/lib/components/text-block.ws.d.ts.map +0 -1
  565. package/lib/css/breakpoints.d.ts +0 -4
  566. package/lib/css/breakpoints.d.ts.map +0 -1
  567. package/lib/css/categories.d.ts +0 -408
  568. package/lib/css/categories.d.ts.map +0 -1
  569. package/lib/css/get-browser-style.d.ts +0 -3
  570. package/lib/css/get-browser-style.d.ts.map +0 -1
  571. package/lib/css/index.d.ts +0 -4
  572. package/lib/css/index.d.ts.map +0 -1
  573. package/lib/db/index.d.ts +0 -3
  574. package/lib/db/index.d.ts.map +0 -1
  575. package/lib/db/instance.d.ts +0 -14
  576. package/lib/db/instance.d.ts.map +0 -1
  577. package/lib/db/types.d.ts +0 -17
  578. package/lib/db/types.d.ts.map +0 -1
  579. package/lib/index.d.ts +0 -9
  580. package/lib/index.d.ts.map +0 -1
  581. package/lib/pubsub/create.d.ts +0 -29
  582. package/lib/pubsub/create.d.ts.map +0 -1
  583. package/lib/pubsub/index.d.ts +0 -2
  584. package/lib/pubsub/index.d.ts.map +0 -1
  585. package/lib/remix/handle-request.server.d.ts +0 -3
  586. package/lib/remix/handle-request.server.d.ts.map +0 -1
  587. package/lib/remix/handle-request.server.js +0 -11
  588. package/lib/remix/index.d.ts +0 -3
  589. package/lib/remix/index.d.ts.map +0 -1
  590. package/lib/remix/root.d.ts +0 -8
  591. package/lib/remix/root.d.ts.map +0 -1
  592. package/lib/remix/root.js +0 -9
  593. package/lib/tree/create-elements-tree.d.ts +0 -19
  594. package/lib/tree/create-elements-tree.d.ts.map +0 -1
  595. package/lib/tree/index.d.ts.map +0 -1
  596. package/lib/tree/root.d.ts +0 -18
  597. package/lib/tree/root.d.ts.map +0 -1
  598. package/lib/tree/session-storage-polyfill.d.ts +0 -2
  599. package/lib/tree/session-storage-polyfill.d.ts.map +0 -1
  600. package/lib/tree/wrapper-component.d.ts +0 -12
  601. package/lib/tree/wrapper-component.d.ts.map +0 -1
  602. package/lib/tsconfig.tsbuildinfo +0 -1
  603. package/lib/user-props/all-user-props.d.ts +0 -8
  604. package/lib/user-props/all-user-props.d.ts.map +0 -1
  605. package/lib/user-props/index.d.ts +0 -5
  606. package/lib/user-props/index.d.ts.map +0 -1
  607. package/lib/user-props/schema.d.ts +0 -72
  608. package/lib/user-props/schema.d.ts.map +0 -1
  609. package/lib/user-props/types.d.ts +0 -13
  610. package/lib/user-props/types.d.ts.map +0 -1
  611. package/lib/user-props/use-user-props.d.ts +0 -12
  612. package/lib/user-props/use-user-props.d.ts.map +0 -1
@@ -1,44 +1,44 @@
1
1
  import { detectFont } from "detect-font";
2
2
  import { properties, units } from "@webstudio-is/css-data";
3
3
  const unitRegex = new RegExp(`${units.join("|")}`);
4
- // @todo use a parser
5
4
  const parseValue = (property, value) => {
6
- const number = parseFloat(value);
7
- const parsedUnit = unitRegex.exec(value);
8
- if (value === "rgba(0, 0, 0, 0)")
9
- value = "transparent";
10
- if (isNaN(number) || parsedUnit === null) {
11
- return {
12
- type: "keyword",
13
- value,
14
- };
15
- }
16
- if (number === 0) {
17
- return properties[property].initial;
18
- }
5
+ const number = parseFloat(value);
6
+ const parsedUnit = unitRegex.exec(value);
7
+ if (value === "rgba(0, 0, 0, 0)")
8
+ value = "transparent";
9
+ if (isNaN(number) || parsedUnit === null) {
19
10
  return {
20
- type: "unit",
21
- unit: parsedUnit[0],
22
- value: number,
11
+ type: "keyword",
12
+ value
23
13
  };
14
+ }
15
+ if (number === 0 && property in properties) {
16
+ return properties[property].initial;
17
+ }
18
+ return {
19
+ type: "unit",
20
+ unit: parsedUnit[0],
21
+ value: number
22
+ };
24
23
  };
25
- export const getBrowserStyle = (element) => {
26
- const browserStyle = {};
27
- if (element === undefined)
28
- return browserStyle;
29
- let knownProperty;
30
- const computedStyle = getComputedStyle(element);
31
- for (knownProperty in properties) {
32
- if (knownProperty in computedStyle === false)
33
- continue;
34
- // Typescript doesn't know we can access CSSStyleDeclaration properties by keys
35
- const computedValue = computedStyle[knownProperty];
36
- browserStyle[knownProperty] = parseValue(knownProperty, computedValue);
37
- }
38
- // We need a single font-family that is actually rendered. Computed style will return a list of potential fonts.
39
- browserStyle.fontFamily = {
40
- type: "fontFamily",
41
- value: [detectFont(element)],
42
- };
24
+ const getBrowserStyle = (element) => {
25
+ const browserStyle = {};
26
+ if (element === void 0)
43
27
  return browserStyle;
28
+ let knownProperty;
29
+ const computedStyle = getComputedStyle(element);
30
+ for (knownProperty in properties) {
31
+ if (knownProperty in computedStyle === false)
32
+ continue;
33
+ const computedValue = computedStyle[knownProperty];
34
+ browserStyle[knownProperty] = parseValue(knownProperty, computedValue);
35
+ }
36
+ browserStyle.fontFamily = {
37
+ type: "fontFamily",
38
+ value: [detectFont(element)]
39
+ };
40
+ return browserStyle;
41
+ };
42
+ export {
43
+ getBrowserStyle
44
44
  };
@@ -1,17 +1,21 @@
1
1
  import { CssRule } from "@webstudio-is/css-data";
2
2
  import { z } from "zod";
3
- export const toBaseInstance = (instance) => {
4
- return {
5
- id: instance.id,
6
- component: instance.component,
7
- cssRules: instance.cssRules,
8
- };
3
+ const toBaseInstance = (instance) => {
4
+ return {
5
+ id: instance.id,
6
+ component: instance.component,
7
+ cssRules: instance.cssRules
8
+ };
9
9
  };
10
- export const Instance = z.lazy(() => z.object({
10
+ const Instance = z.lazy(
11
+ () => z.object({
11
12
  id: z.string(),
12
13
  component: z.string(),
13
14
  children: z.array(z.union([Instance, z.string()])),
14
- cssRules: z.array(CssRule),
15
- })
16
- // @todo can't figure out how to make component to be z.enum(Object.keys(components))
15
+ cssRules: z.array(CssRule)
16
+ })
17
17
  );
18
+ export {
19
+ Instance,
20
+ toBaseInstance
21
+ };
package/lib/db/types.js CHANGED
@@ -1 +0,0 @@
1
- export {};
package/lib/index.js CHANGED
@@ -1,8 +1,15 @@
1
1
  export * from "./css";
2
2
  export * from "./tree";
3
- export * as components from "./components";
4
- export * from "./components/meta";
3
+ export * from "./components";
5
4
  export * from "./user-props";
6
5
  export * from "./pubsub";
7
6
  export * from "./db";
8
- export * from "./remix";
7
+ export * from "./app";
8
+ import {
9
+ customComponents,
10
+ customComponentsMeta
11
+ } from "./app/custom-components";
12
+ export {
13
+ customComponents,
14
+ customComponentsMeta
15
+ };
@@ -1,59 +1,55 @@
1
1
  import mitt from "mitt";
2
2
  import { useCallback, useEffect, useRef } from "react";
3
- export const createPubsub = () => {
4
- // `mitt` has a somewhat annoying overload for `*` type that makes it hard to wrap in a generic context
5
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
6
- const emitter = mitt();
7
- if (typeof window === "object") {
8
- window.addEventListener("message", (event) => {
9
- // @todo this has no type safety built in, could be anything from any source.
10
- // we could potentially maintain a list of valid event types at runtime
11
- // at the very least we could add a brand property or something to our events
12
- if (typeof event.data?.type === "string") {
13
- emitter.emit(event.data.type, event.data.payload);
14
- }
15
- }, false);
16
- }
17
- return {
18
- /**
19
- * To publish a postMessage event on the current window and parent window from the iframe.
20
- */
21
- publish(action) {
22
- window.parent.postMessage(action, "*");
23
- window.postMessage(action, "*");
24
- },
25
- /**
26
- * To publish a postMessage event on the iframe and parent window from the parent window.
27
- */
28
- usePublish() {
29
- const iframeRef = useRef(null);
30
- const publishCallback = useCallback((action) => {
31
- const element = iframeRef.current;
32
- if (element?.contentWindow == null)
33
- return;
34
- element.contentWindow.postMessage(action, "*");
35
- window.postMessage(action, "*");
36
- }, [iframeRef]);
37
- return [publishCallback, iframeRef];
38
- },
39
- /**
40
- * To subscribe a message event on the current window.
41
- */
42
- useSubscribe(type, onAction) {
43
- useEffect(() => {
44
- emitter.on(type, onAction);
45
- return () => {
46
- emitter.off(type, onAction);
47
- };
48
- }, [type, onAction]);
3
+ const createPubsub = () => {
4
+ const emitter = mitt();
5
+ if (typeof window === "object") {
6
+ window.addEventListener(
7
+ "message",
8
+ (event) => {
9
+ if (typeof event.data?.type === "string") {
10
+ emitter.emit(event.data.type, event.data.payload);
11
+ }
12
+ },
13
+ false
14
+ );
15
+ }
16
+ return {
17
+ publish(action) {
18
+ window.parent.postMessage(action, "*");
19
+ window.postMessage(action, "*");
20
+ },
21
+ usePublish() {
22
+ const iframeRef = useRef(null);
23
+ const publishCallback = useCallback(
24
+ (action) => {
25
+ const element = iframeRef.current;
26
+ if (element?.contentWindow == null)
27
+ return;
28
+ element.contentWindow.postMessage(action, "*");
29
+ window.postMessage(action, "*");
49
30
  },
50
- useSubscribeAll(onAction) {
51
- useEffect(() => {
52
- emitter.on("*", onAction);
53
- return () => {
54
- emitter.off("*", onAction);
55
- };
56
- }, [onAction]);
57
- },
58
- };
31
+ [iframeRef]
32
+ );
33
+ return [publishCallback, iframeRef];
34
+ },
35
+ useSubscribe(type, onAction) {
36
+ useEffect(() => {
37
+ emitter.on(type, onAction);
38
+ return () => {
39
+ emitter.off(type, onAction);
40
+ };
41
+ }, [type, onAction]);
42
+ },
43
+ useSubscribeAll(onAction) {
44
+ useEffect(() => {
45
+ emitter.on("*", onAction);
46
+ return () => {
47
+ emitter.off("*", onAction);
48
+ };
49
+ }, [onAction]);
50
+ }
51
+ };
52
+ };
53
+ export {
54
+ createPubsub
59
55
  };
@@ -1,50 +1,76 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ 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 { SessionStoragePolyfill } from "./session-storage-polyfill";
5
- export const createElementsTree = ({ sandbox, instance, Component, onChangeChildren, }) => {
6
- const children = createInstanceChildrenElements({
7
- Component,
8
- children: instance.children,
9
- onChangeChildren,
10
- });
11
- const body = createInstanceElement({
12
- Component,
13
- instance,
5
+ const createElementsTree = ({
6
+ sandbox,
7
+ instance,
8
+ Component,
9
+ onChangeChildren
10
+ }) => {
11
+ const children = createInstanceChildrenElements({
12
+ Component,
13
+ children: instance.children,
14
+ onChangeChildren
15
+ });
16
+ const body = createInstanceElement({
17
+ Component,
18
+ instance,
19
+ children: [
20
+ /* @__PURE__ */ jsxs(Fragment, {
14
21
  children: [
15
- _jsxs(Fragment, { children: [children, sandbox && _jsx(SessionStoragePolyfill, {}), _jsx(ScrollRestoration, {}), _jsx(Scripts, {})] }, "children"),
16
- ],
17
- });
18
- return body;
22
+ children,
23
+ sandbox && /* @__PURE__ */ jsx(SessionStoragePolyfill, {}),
24
+ /* @__PURE__ */ jsx(ScrollRestoration, {}),
25
+ /* @__PURE__ */ jsx(Scripts, {})
26
+ ]
27
+ }, "children")
28
+ ]
29
+ });
30
+ return body;
19
31
  };
20
- const createInstanceChildrenElements = ({ children, Component, onChangeChildren, }) => {
21
- const elements = [];
22
- for (const child of children) {
23
- if (typeof child === "string") {
24
- elements.push(child);
25
- continue;
26
- }
27
- const children = createInstanceChildrenElements({
28
- children: child.children,
29
- Component,
30
- onChangeChildren,
31
- });
32
- const element = createInstanceElement({
33
- instance: child,
34
- Component,
35
- onChangeChildren,
36
- children,
37
- });
38
- elements.push(element);
32
+ const createInstanceChildrenElements = ({
33
+ children,
34
+ Component,
35
+ onChangeChildren
36
+ }) => {
37
+ const elements = [];
38
+ for (const child of children) {
39
+ if (typeof child === "string") {
40
+ elements.push(child);
41
+ continue;
39
42
  }
40
- return elements;
43
+ const children2 = createInstanceChildrenElements({
44
+ children: child.children,
45
+ Component,
46
+ onChangeChildren
47
+ });
48
+ const element = createInstanceElement({
49
+ instance: child,
50
+ Component,
51
+ onChangeChildren,
52
+ children: children2
53
+ });
54
+ elements.push(element);
55
+ }
56
+ return elements;
57
+ };
58
+ const createInstanceElement = ({
59
+ Component,
60
+ instance,
61
+ children = [],
62
+ onChangeChildren
63
+ }) => {
64
+ const props = {
65
+ instance,
66
+ children,
67
+ key: instance.id,
68
+ onChangeChildren
69
+ };
70
+ return /* @__PURE__ */ jsx(Component, {
71
+ ...props
72
+ });
41
73
  };
42
- const createInstanceElement = ({ Component, instance, children = [], onChangeChildren, }) => {
43
- const props = {
44
- instance,
45
- children,
46
- key: instance.id,
47
- onChangeChildren,
48
- };
49
- return _jsx(Component, { ...props });
74
+ export {
75
+ createElementsTree
50
76
  };
package/lib/tree/root.js CHANGED
@@ -1,13 +1,25 @@
1
1
  import { useAllUserProps } from "../user-props/";
2
2
  import { createElementsTree } from "./create-elements-tree";
3
3
  import { WrapperComponent } from "./wrapper-component";
4
- export const InstanceRoot = ({ data, Component, }) => {
5
- if (data.tree === null) {
6
- throw new Error("Tree is null");
7
- }
8
- useAllUserProps(data.props);
9
- return createElementsTree({
10
- instance: data.tree.root,
11
- Component: Component ?? WrapperComponent,
12
- });
4
+ import { registerComponents } from "../components";
5
+ import { customComponents as defaultCustomComponents } from "../app/custom-components";
6
+ import { setParams } from "../app/params";
7
+ const InstanceRoot = ({
8
+ data,
9
+ Component,
10
+ customComponents = defaultCustomComponents
11
+ }) => {
12
+ if (data.tree === null) {
13
+ throw new Error("Tree is null");
14
+ }
15
+ useAllUserProps(data.props);
16
+ setParams(data.params ?? null);
17
+ registerComponents(customComponents);
18
+ return createElementsTree({
19
+ instance: data.tree.root,
20
+ Component: Component ?? WrapperComponent
21
+ });
22
+ };
23
+ export {
24
+ InstanceRoot
13
25
  };
@@ -1,35 +1,42 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- // This is a temporary work around for https://github.com/remix-run/remix/issues/3659
3
- // The code is based on this discussion https://bugs.chromium.org/p/chromium/issues/detail?id=357625
4
- const polyfill = function () {
5
- try {
6
- const key = "__session_storage_availability_test__";
7
- sessionStorage.setItem(key, "test"); // test
8
- sessionStorage.removeItem(key); // cleanup
9
- }
10
- catch (error) {
11
- 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');
12
- const data = new Map();
13
- Object.defineProperty(window, "sessionStorage", {
14
- value: {
15
- setItem: (key, val) => {
16
- // eslint-disable-next-line no-console
17
- 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.`);
18
- data.set(key, String(val));
19
- },
20
- getItem: (key) => {
21
- // eslint-disable-next-line no-console
22
- 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.`);
23
- return data.get(key);
24
- },
25
- removeItem: (key) => {
26
- data.delete(key);
27
- },
28
- clear: () => {
29
- data.clear();
30
- },
31
- },
32
- });
33
- }
1
+ import { jsx } from "react/jsx-runtime";
2
+ const polyfill = function() {
3
+ try {
4
+ const key = "__session_storage_availability_test__";
5
+ sessionStorage.setItem(key, "test");
6
+ sessionStorage.removeItem(key);
7
+ } catch (error) {
8
+ alert(
9
+ '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'
10
+ );
11
+ const data = /* @__PURE__ */ new Map();
12
+ Object.defineProperty(window, "sessionStorage", {
13
+ value: {
14
+ setItem: (key, val) => {
15
+ console.warn(
16
+ `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.`
17
+ );
18
+ data.set(key, String(val));
19
+ },
20
+ getItem: (key) => {
21
+ console.warn(
22
+ `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.`
23
+ );
24
+ return data.get(key);
25
+ },
26
+ removeItem: (key) => {
27
+ data.delete(key);
28
+ },
29
+ clear: () => {
30
+ data.clear();
31
+ }
32
+ }
33
+ });
34
+ }
34
35
  }.toString();
35
- export const SessionStoragePolyfill = () => (_jsx("script", { dangerouslySetInnerHTML: { __html: `(${polyfill})()` }, suppressHydrationWarning: true }));
36
+ const SessionStoragePolyfill = () => /* @__PURE__ */ jsx("script", {
37
+ dangerouslySetInnerHTML: { __html: `(${polyfill})()` },
38
+ suppressHydrationWarning: true
39
+ });
40
+ export {
41
+ SessionStoragePolyfill
42
+ };
@@ -1,25 +1,40 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { Fragment } from "react";
3
- import * as components from "../components";
3
+ import { getComponent } from "../components";
4
4
  import { useUserProps } from "../user-props/use-user-props";
5
5
  const renderText = (text) => {
6
- const lines = text.split("\n");
7
- return lines.map((line, index) => (_jsxs(Fragment, { children: [line, index < lines.length - 1 ? _jsx("br", {}) : null] }, index)));
6
+ const lines = text.split("\n");
7
+ return lines.map((line, index) => /* @__PURE__ */ jsxs(Fragment, {
8
+ children: [
9
+ line,
10
+ index < lines.length - 1 ? /* @__PURE__ */ jsx("br", {}) : null
11
+ ]
12
+ }, index));
8
13
  };
9
- export const renderWrapperComponentChildren = (children) => {
10
- // Some elements like input can't have children
11
- // @todo needs to be made impossible to drag element into input
12
- if (children === undefined || children.length === 0)
13
- return;
14
- return children.map((child) => {
15
- return typeof child === "string" ? renderText(child) : child;
16
- });
14
+ const renderWrapperComponentChildren = (children) => {
15
+ if (children === void 0 || children.length === 0)
16
+ return;
17
+ return children.map((child) => {
18
+ return typeof child === "string" ? renderText(child) : child;
19
+ });
17
20
  };
18
- export const WrapperComponent = ({ instance, onChangeChildren, // prevent it from passing to sdk component
19
- children, ...rest }) => {
20
- const { Component } = components[instance.component];
21
- const userProps = useUserProps(instance.id);
22
- const props = { ...userProps, ...rest, [idAttribute]: instance.id };
23
- return (_jsx(Component, { ...props, children: renderWrapperComponentChildren(children) }));
21
+ const WrapperComponent = ({
22
+ instance,
23
+ onChangeChildren,
24
+ children,
25
+ ...rest
26
+ }) => {
27
+ const Component = getComponent(instance.component);
28
+ const userProps = useUserProps(instance.id);
29
+ const props = { ...userProps, ...rest, [idAttribute]: instance.id };
30
+ return /* @__PURE__ */ jsx(Component, {
31
+ ...props,
32
+ children: renderWrapperComponentChildren(children)
33
+ });
34
+ };
35
+ const idAttribute = "data-ws-id";
36
+ export {
37
+ WrapperComponent,
38
+ idAttribute,
39
+ renderWrapperComponentChildren
24
40
  };
25
- export const idAttribute = "data-ws-id";
@@ -1,17 +1,19 @@
1
1
  import { useRef } from "react";
2
2
  import { createValueContainer, useValue } from "react-nano-state";
3
- export const allUserPropsContainer = createValueContainer({});
4
- export const useAllUserProps = (initialUserProps) => {
5
- // @todo ssr workaround for https://github.com/webstudio-is/webstudio-designer/issues/213
6
- const ref = useRef(false);
7
- if (ref.current === false && initialUserProps !== undefined) {
8
- const propsMap = {};
9
- for (const props of initialUserProps) {
10
- propsMap[props.instanceId] = props;
11
- }
12
- //We don't need to trigger rerender when setting the initial value
13
- allUserPropsContainer.value = propsMap;
14
- ref.current = true;
3
+ const allUserPropsContainer = createValueContainer({});
4
+ const useAllUserProps = (initialUserProps) => {
5
+ const ref = useRef(false);
6
+ if (ref.current === false && initialUserProps !== void 0) {
7
+ const propsMap = {};
8
+ for (const props of initialUserProps) {
9
+ propsMap[props.instanceId] = props;
15
10
  }
16
- return useValue(allUserPropsContainer);
11
+ allUserPropsContainer.value = propsMap;
12
+ ref.current = true;
13
+ }
14
+ return useValue(allUserPropsContainer);
15
+ };
16
+ export {
17
+ allUserPropsContainer,
18
+ useAllUserProps
17
19
  };
@@ -1,30 +1,34 @@
1
1
  import { z } from "zod";
2
- const UserPropDb = z.object({
3
- id: z.string(),
4
- prop: z.string(),
5
- value: z.union([z.string(), z.boolean()]),
6
- assetId: z.optional(z.string()),
7
- required: z.optional(z.boolean()),
8
- });
9
- export const UserDbProps = z.array(UserPropDb);
10
- const UserUserProp = z
11
- .object({
12
- id: z.string(),
13
- prop: z.string(),
14
- value: z.union([z.string(), z.boolean()]),
15
- // We are not interested in Props data does any other props on asset exists
16
- asset: z.optional(z.object({ id: z.string() })),
17
- required: z.optional(z.boolean()),
18
- })
19
- .transform(({ id, prop, value, asset, required }) => {
20
- // Check with infer that we are transforming to UserPropDb
21
- const res = {
22
- id,
23
- prop,
24
- value,
25
- assetId: asset?.id,
26
- required,
27
- };
28
- return res;
29
- });
30
- export const UserUserProps = z.array(UserUserProp);
2
+ import { Asset } from "@webstudio-is/asset-uploader";
3
+ const baseUserProps = {
4
+ id: z.string(),
5
+ prop: z.string(),
6
+ required: z.optional(z.boolean())
7
+ };
8
+ const UserProp = z.discriminatedUnion("type", [
9
+ z.object({
10
+ ...baseUserProps,
11
+ type: z.literal("number"),
12
+ value: z.number()
13
+ }),
14
+ z.object({
15
+ ...baseUserProps,
16
+ type: z.literal("string"),
17
+ value: z.string()
18
+ }),
19
+ z.object({
20
+ ...baseUserProps,
21
+ type: z.literal("boolean"),
22
+ value: z.boolean()
23
+ }),
24
+ z.object({
25
+ ...baseUserProps,
26
+ type: z.literal("asset"),
27
+ value: Asset
28
+ })
29
+ ]);
30
+ const UserProps = z.array(UserProp);
31
+ export {
32
+ UserProp,
33
+ UserProps
34
+ };
@@ -1 +0,0 @@
1
- export {};