@webstudio-is/sdk-components-react 0.70.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 (460) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +3 -0
  3. package/lib/__generated__/blockquote.props.js +399 -0
  4. package/lib/__generated__/body.props.js +398 -0
  5. package/lib/__generated__/bold.props.js +398 -0
  6. package/lib/__generated__/box.props.js +416 -0
  7. package/lib/__generated__/button.props.js +420 -0
  8. package/lib/__generated__/checkbox-field.props.js +399 -0
  9. package/lib/__generated__/checkbox.props.js +439 -0
  10. package/lib/__generated__/code-text.props.js +405 -0
  11. package/lib/__generated__/error-message.props.js +398 -0
  12. package/lib/__generated__/form.props.js +406 -0
  13. package/lib/__generated__/fragment.props.js +4 -0
  14. package/lib/__generated__/heading.props.js +405 -0
  15. package/lib/__generated__/html-embed.props.js +11 -0
  16. package/lib/__generated__/image.props.js +442 -0
  17. package/lib/__generated__/input.props.js +445 -0
  18. package/lib/__generated__/italic.props.js +398 -0
  19. package/lib/__generated__/label.props.js +400 -0
  20. package/lib/__generated__/link-block.props.js +432 -0
  21. package/lib/__generated__/link.props.js +432 -0
  22. package/lib/__generated__/list-item.props.js +399 -0
  23. package/lib/__generated__/list.props.js +412 -0
  24. package/lib/__generated__/paragraph.props.js +398 -0
  25. package/lib/__generated__/radio-button-field.props.js +399 -0
  26. package/lib/__generated__/radio-button.props.js +439 -0
  27. package/lib/__generated__/rich-text-link.props.js +432 -0
  28. package/lib/__generated__/separator.props.js +398 -0
  29. package/lib/__generated__/slot.props.js +4 -0
  30. package/lib/__generated__/span.props.js +398 -0
  31. package/lib/__generated__/subscript.props.js +398 -0
  32. package/lib/__generated__/success-message.props.js +398 -0
  33. package/lib/__generated__/superscript.props.js +398 -0
  34. package/lib/__generated__/text-block.props.js +405 -0
  35. package/lib/__generated__/textarea.props.js +412 -0
  36. package/lib/blockquote.js +15 -0
  37. package/lib/blockquote.ws.js +76 -0
  38. package/lib/body.js +9 -0
  39. package/lib/body.ws.js +47 -0
  40. package/lib/bold.js +9 -0
  41. package/lib/bold.ws.js +23 -0
  42. package/lib/box.js +14 -0
  43. package/lib/box.ws.js +46 -0
  44. package/lib/button.js +16 -0
  45. package/lib/button.ws.js +31 -0
  46. package/lib/checkbox-field.js +9 -0
  47. package/lib/checkbox-field.ws.js +44 -0
  48. package/lib/checkbox.js +9 -0
  49. package/lib/checkbox.ws.js +40 -0
  50. package/lib/cjs/__generated__/blockquote.props.js +419 -0
  51. package/lib/cjs/__generated__/body.props.js +418 -0
  52. package/lib/cjs/__generated__/bold.props.js +418 -0
  53. package/lib/cjs/__generated__/box.props.js +436 -0
  54. package/lib/cjs/__generated__/button.props.js +440 -0
  55. package/lib/cjs/__generated__/checkbox-field.props.js +419 -0
  56. package/lib/cjs/__generated__/checkbox.props.js +459 -0
  57. package/lib/cjs/__generated__/code-text.props.js +425 -0
  58. package/lib/cjs/__generated__/error-message.props.js +418 -0
  59. package/lib/cjs/__generated__/form.props.js +426 -0
  60. package/lib/cjs/__generated__/fragment.props.js +24 -0
  61. package/lib/cjs/__generated__/heading.props.js +425 -0
  62. package/lib/cjs/__generated__/html-embed.props.js +31 -0
  63. package/lib/cjs/__generated__/image.props.js +462 -0
  64. package/lib/cjs/__generated__/input.props.js +465 -0
  65. package/lib/cjs/__generated__/italic.props.js +418 -0
  66. package/lib/cjs/__generated__/label.props.js +420 -0
  67. package/lib/cjs/__generated__/link-block.props.js +452 -0
  68. package/lib/cjs/__generated__/link.props.js +452 -0
  69. package/lib/cjs/__generated__/list-item.props.js +419 -0
  70. package/lib/cjs/__generated__/list.props.js +432 -0
  71. package/lib/cjs/__generated__/paragraph.props.js +418 -0
  72. package/lib/cjs/__generated__/radio-button-field.props.js +419 -0
  73. package/lib/cjs/__generated__/radio-button.props.js +459 -0
  74. package/lib/cjs/__generated__/rich-text-link.props.js +452 -0
  75. package/lib/cjs/__generated__/separator.props.js +418 -0
  76. package/lib/cjs/__generated__/slot.props.js +24 -0
  77. package/lib/cjs/__generated__/span.props.js +418 -0
  78. package/lib/cjs/__generated__/subscript.props.js +418 -0
  79. package/lib/cjs/__generated__/success-message.props.js +418 -0
  80. package/lib/cjs/__generated__/superscript.props.js +418 -0
  81. package/lib/cjs/__generated__/text-block.props.js +425 -0
  82. package/lib/cjs/__generated__/textarea.props.js +432 -0
  83. package/lib/cjs/blockquote.js +32 -0
  84. package/lib/cjs/blockquote.ws.js +94 -0
  85. package/lib/cjs/body.js +29 -0
  86. package/lib/cjs/body.ws.js +65 -0
  87. package/lib/cjs/bold.js +29 -0
  88. package/lib/cjs/bold.ws.js +41 -0
  89. package/lib/cjs/box.js +31 -0
  90. package/lib/cjs/box.ws.js +53 -0
  91. package/lib/cjs/button.js +36 -0
  92. package/lib/cjs/button.ws.js +49 -0
  93. package/lib/cjs/checkbox-field.js +29 -0
  94. package/lib/cjs/checkbox-field.ws.js +62 -0
  95. package/lib/cjs/checkbox.js +29 -0
  96. package/lib/cjs/checkbox.ws.js +58 -0
  97. package/lib/cjs/code-text.js +39 -0
  98. package/lib/cjs/code-text.ws.js +74 -0
  99. package/lib/cjs/components.js +88 -0
  100. package/lib/cjs/error-message.js +29 -0
  101. package/lib/cjs/error-message.ws.js +40 -0
  102. package/lib/cjs/form.js +29 -0
  103. package/lib/cjs/form.ws.js +82 -0
  104. package/lib/cjs/fragment.js +29 -0
  105. package/lib/cjs/fragment.ws.js +33 -0
  106. package/lib/cjs/heading.js +31 -0
  107. package/lib/cjs/heading.ws.js +56 -0
  108. package/lib/cjs/html-embed.js +80 -0
  109. package/lib/cjs/html-embed.ws.js +45 -0
  110. package/lib/cjs/image.js +76 -0
  111. package/lib/cjs/image.ws.js +66 -0
  112. package/lib/cjs/input.js +29 -0
  113. package/lib/cjs/input.ws.js +55 -0
  114. package/lib/cjs/italic.js +29 -0
  115. package/lib/cjs/italic.ws.js +47 -0
  116. package/lib/cjs/label.js +29 -0
  117. package/lib/cjs/label.ws.js +63 -0
  118. package/lib/cjs/link-block.js +30 -0
  119. package/lib/cjs/link-block.ws.js +53 -0
  120. package/lib/cjs/link.js +48 -0
  121. package/lib/cjs/link.ws.js +79 -0
  122. package/lib/cjs/list-item.js +32 -0
  123. package/lib/cjs/list-item.ws.js +51 -0
  124. package/lib/cjs/list.js +31 -0
  125. package/lib/cjs/list.ws.js +73 -0
  126. package/lib/cjs/metas.js +88 -0
  127. package/lib/cjs/package.json +1 -0
  128. package/lib/cjs/paragraph.js +29 -0
  129. package/lib/cjs/paragraph.ws.js +50 -0
  130. package/lib/cjs/props.js +88 -0
  131. package/lib/cjs/radio-button-field.js +29 -0
  132. package/lib/cjs/radio-button-field.ws.js +62 -0
  133. package/lib/cjs/radio-button.js +29 -0
  134. package/lib/cjs/radio-button.ws.js +58 -0
  135. package/lib/cjs/rich-text-link.js +28 -0
  136. package/lib/cjs/rich-text-link.ws.js +39 -0
  137. package/lib/cjs/separator.js +32 -0
  138. package/lib/cjs/separator.ws.js +70 -0
  139. package/lib/cjs/slot.js +36 -0
  140. package/lib/cjs/slot.ws.js +36 -0
  141. package/lib/cjs/span.js +29 -0
  142. package/lib/cjs/span.ws.js +41 -0
  143. package/lib/cjs/subscript.js +29 -0
  144. package/lib/cjs/subscript.ws.js +41 -0
  145. package/lib/cjs/success-message.js +29 -0
  146. package/lib/cjs/success-message.ws.js +40 -0
  147. package/lib/cjs/superscript.js +29 -0
  148. package/lib/cjs/superscript.ws.js +41 -0
  149. package/lib/cjs/text-block.js +32 -0
  150. package/lib/cjs/text-block.ws.js +57 -0
  151. package/lib/cjs/textarea.js +29 -0
  152. package/lib/cjs/textarea.ws.js +59 -0
  153. package/lib/code-text.js +22 -0
  154. package/lib/code-text.ws.js +56 -0
  155. package/lib/components.js +68 -0
  156. package/lib/error-message.js +9 -0
  157. package/lib/error-message.ws.js +20 -0
  158. package/lib/form.js +9 -0
  159. package/lib/form.ws.js +64 -0
  160. package/lib/fragment.js +9 -0
  161. package/lib/fragment.ws.js +13 -0
  162. package/lib/heading.js +14 -0
  163. package/lib/heading.ws.js +38 -0
  164. package/lib/html-embed.js +65 -0
  165. package/lib/html-embed.ws.js +25 -0
  166. package/lib/image.js +66 -0
  167. package/lib/image.ws.js +48 -0
  168. package/lib/input.js +9 -0
  169. package/lib/input.ws.js +37 -0
  170. package/lib/italic.js +9 -0
  171. package/lib/italic.ws.js +29 -0
  172. package/lib/label.js +9 -0
  173. package/lib/label.ws.js +45 -0
  174. package/lib/link-block.js +10 -0
  175. package/lib/link-block.ws.js +33 -0
  176. package/lib/link.js +32 -0
  177. package/lib/link.ws.js +61 -0
  178. package/lib/list-item.js +15 -0
  179. package/lib/list-item.ws.js +33 -0
  180. package/lib/list.js +14 -0
  181. package/lib/list.ws.js +55 -0
  182. package/lib/metas.js +68 -0
  183. package/lib/paragraph.js +9 -0
  184. package/lib/paragraph.ws.js +32 -0
  185. package/lib/props.js +68 -0
  186. package/lib/radio-button-field.js +9 -0
  187. package/lib/radio-button-field.ws.js +44 -0
  188. package/lib/radio-button.js +9 -0
  189. package/lib/radio-button.ws.js +40 -0
  190. package/lib/rich-text-link.js +8 -0
  191. package/lib/rich-text-link.ws.js +19 -0
  192. package/lib/separator.js +15 -0
  193. package/lib/separator.ws.js +52 -0
  194. package/lib/slot.js +16 -0
  195. package/lib/slot.ws.js +16 -0
  196. package/lib/span.js +9 -0
  197. package/lib/span.ws.js +23 -0
  198. package/lib/subscript.js +9 -0
  199. package/lib/subscript.ws.js +23 -0
  200. package/lib/success-message.js +9 -0
  201. package/lib/success-message.ws.js +20 -0
  202. package/lib/superscript.js +9 -0
  203. package/lib/superscript.ws.js +23 -0
  204. package/lib/text-block.js +15 -0
  205. package/lib/text-block.ws.js +39 -0
  206. package/lib/textarea.js +9 -0
  207. package/lib/textarea.ws.js +41 -0
  208. package/lib/types/__generated__/blockquote.props.d.ts +2 -0
  209. package/lib/types/__generated__/body.props.d.ts +2 -0
  210. package/lib/types/__generated__/bold.props.d.ts +2 -0
  211. package/lib/types/__generated__/box.props.d.ts +2 -0
  212. package/lib/types/__generated__/button.props.d.ts +2 -0
  213. package/lib/types/__generated__/checkbox-field.props.d.ts +2 -0
  214. package/lib/types/__generated__/checkbox.props.d.ts +2 -0
  215. package/lib/types/__generated__/code-text.props.d.ts +2 -0
  216. package/lib/types/__generated__/error-message.props.d.ts +2 -0
  217. package/lib/types/__generated__/form.props.d.ts +2 -0
  218. package/lib/types/__generated__/fragment.props.d.ts +2 -0
  219. package/lib/types/__generated__/heading.props.d.ts +2 -0
  220. package/lib/types/__generated__/html-embed.props.d.ts +2 -0
  221. package/lib/types/__generated__/image.props.d.ts +2 -0
  222. package/lib/types/__generated__/input.props.d.ts +2 -0
  223. package/lib/types/__generated__/italic.props.d.ts +2 -0
  224. package/lib/types/__generated__/label.props.d.ts +2 -0
  225. package/lib/types/__generated__/link-block.props.d.ts +2 -0
  226. package/lib/types/__generated__/link.props.d.ts +2 -0
  227. package/lib/types/__generated__/list-item.props.d.ts +2 -0
  228. package/lib/types/__generated__/list.props.d.ts +2 -0
  229. package/lib/types/__generated__/paragraph.props.d.ts +2 -0
  230. package/lib/types/__generated__/radio-button-field.props.d.ts +2 -0
  231. package/lib/types/__generated__/radio-button.props.d.ts +2 -0
  232. package/lib/types/__generated__/rich-text-link.props.d.ts +2 -0
  233. package/lib/types/__generated__/separator.props.d.ts +2 -0
  234. package/lib/types/__generated__/slot.props.d.ts +2 -0
  235. package/lib/types/__generated__/span.props.d.ts +2 -0
  236. package/lib/types/__generated__/subscript.props.d.ts +2 -0
  237. package/lib/types/__generated__/success-message.props.d.ts +2 -0
  238. package/lib/types/__generated__/superscript.props.d.ts +2 -0
  239. package/lib/types/__generated__/text-block.props.d.ts +2 -0
  240. package/lib/types/__generated__/textarea.props.d.ts +2 -0
  241. package/lib/types/blockquote.d.ts +3 -0
  242. package/lib/types/blockquote.stories.d.ts +5 -0
  243. package/lib/types/blockquote.ws.d.ts +3 -0
  244. package/lib/types/body.d.ts +3 -0
  245. package/lib/types/body.stories.d.ts +6 -0
  246. package/lib/types/body.ws.d.ts +3 -0
  247. package/lib/types/bold.d.ts +3 -0
  248. package/lib/types/bold.stories.d.ts +5 -0
  249. package/lib/types/bold.ws.d.ts +3 -0
  250. package/lib/types/box.d.ts +7 -0
  251. package/lib/types/box.stories.d.ts +9 -0
  252. package/lib/types/box.ws.d.ts +3 -0
  253. package/lib/types/button.d.ts +7 -0
  254. package/lib/types/button.stories.d.ts +9 -0
  255. package/lib/types/button.ws.d.ts +3 -0
  256. package/lib/types/checkbox-field.d.ts +3 -0
  257. package/lib/types/checkbox-field.ws.d.ts +3 -0
  258. package/lib/types/checkbox.d.ts +3 -0
  259. package/lib/types/checkbox.ws.d.ts +3 -0
  260. package/lib/types/code-text.d.ts +9 -0
  261. package/lib/types/code-text.stories.d.ts +11 -0
  262. package/lib/types/code-text.ws.d.ts +3 -0
  263. package/lib/types/components.d.ts +33 -0
  264. package/lib/types/error-message.d.ts +3 -0
  265. package/lib/types/error-message.ws.d.ts +3 -0
  266. package/lib/types/form.d.ts +3 -0
  267. package/lib/types/form.stories.d.ts +5 -0
  268. package/lib/types/form.ws.d.ts +3 -0
  269. package/lib/types/fragment.d.ts +6 -0
  270. package/lib/types/fragment.ws.d.ts +3 -0
  271. package/lib/types/heading.d.ts +7 -0
  272. package/lib/types/heading.stories.d.ts +9 -0
  273. package/lib/types/heading.ws.d.ts +3 -0
  274. package/lib/types/html-embed.d.ts +7 -0
  275. package/lib/types/html-embed.stories.d.ts +11 -0
  276. package/lib/types/html-embed.ws.d.ts +3 -0
  277. package/lib/types/image.d.ts +7 -0
  278. package/lib/types/image.stories.d.ts +13 -0
  279. package/lib/types/image.ws.d.ts +3 -0
  280. package/lib/types/input.d.ts +5 -0
  281. package/lib/types/input.stories.d.ts +9 -0
  282. package/lib/types/input.ws.d.ts +3 -0
  283. package/lib/types/italic.d.ts +3 -0
  284. package/lib/types/italic.stories.d.ts +5 -0
  285. package/lib/types/italic.ws.d.ts +3 -0
  286. package/lib/types/label.d.ts +3 -0
  287. package/lib/types/label.ws.d.ts +3 -0
  288. package/lib/types/link-block.d.ts +3 -0
  289. package/lib/types/link-block.stories.d.ts +13 -0
  290. package/lib/types/link-block.ws.d.ts +3 -0
  291. package/lib/types/link.d.ts +9 -0
  292. package/lib/types/link.stories.d.ts +13 -0
  293. package/lib/types/link.ws.d.ts +3 -0
  294. package/lib/types/list-item.d.ts +3 -0
  295. package/lib/types/list-item.stories.d.ts +5 -0
  296. package/lib/types/list-item.ws.d.ts +3 -0
  297. package/lib/types/list.d.ts +9 -0
  298. package/lib/types/list.stories.d.ts +9 -0
  299. package/lib/types/list.ws.d.ts +3 -0
  300. package/lib/types/metas.d.ts +33 -0
  301. package/lib/types/paragraph.d.ts +3 -0
  302. package/lib/types/paragraph.stories.d.ts +5 -0
  303. package/lib/types/paragraph.ws.d.ts +3 -0
  304. package/lib/types/props.d.ts +33 -0
  305. package/lib/types/radio-button-field.d.ts +3 -0
  306. package/lib/types/radio-button-field.ws.d.ts +3 -0
  307. package/lib/types/radio-button.d.ts +3 -0
  308. package/lib/types/radio-button.ws.d.ts +3 -0
  309. package/lib/types/rich-text-link.d.ts +2 -0
  310. package/lib/types/rich-text-link.stories.d.ts +13 -0
  311. package/lib/types/rich-text-link.ws.d.ts +3 -0
  312. package/lib/types/separator.d.ts +3 -0
  313. package/lib/types/separator.stories.d.ts +5 -0
  314. package/lib/types/separator.ws.d.ts +3 -0
  315. package/lib/types/slot.d.ts +6 -0
  316. package/lib/types/slot.stories.d.ts +9 -0
  317. package/lib/types/slot.ws.d.ts +3 -0
  318. package/lib/types/span.d.ts +3 -0
  319. package/lib/types/span.stories.d.ts +5 -0
  320. package/lib/types/span.ws.d.ts +3 -0
  321. package/lib/types/subscript.d.ts +3 -0
  322. package/lib/types/subscript.stories.d.ts +5 -0
  323. package/lib/types/subscript.ws.d.ts +3 -0
  324. package/lib/types/success-message.d.ts +3 -0
  325. package/lib/types/success-message.ws.d.ts +3 -0
  326. package/lib/types/superscript.d.ts +3 -0
  327. package/lib/types/superscript.stories.d.ts +5 -0
  328. package/lib/types/superscript.ws.d.ts +3 -0
  329. package/lib/types/text-block.d.ts +7 -0
  330. package/lib/types/text-block.stories.d.ts +9 -0
  331. package/lib/types/text-block.ws.d.ts +3 -0
  332. package/lib/types/textarea.d.ts +3 -0
  333. package/lib/types/textarea.ws.d.ts +3 -0
  334. package/package.json +69 -0
  335. package/src/__generated__/blockquote.props.ts +444 -0
  336. package/src/__generated__/body.props.ts +443 -0
  337. package/src/__generated__/bold.props.ts +443 -0
  338. package/src/__generated__/box.props.ts +461 -0
  339. package/src/__generated__/button.props.ts +465 -0
  340. package/src/__generated__/checkbox-field.props.ts +444 -0
  341. package/src/__generated__/checkbox.props.ts +484 -0
  342. package/src/__generated__/code-text.props.ts +450 -0
  343. package/src/__generated__/error-message.props.ts +443 -0
  344. package/src/__generated__/form.props.ts +451 -0
  345. package/src/__generated__/fragment.props.ts +3 -0
  346. package/src/__generated__/heading.props.ts +450 -0
  347. package/src/__generated__/html-embed.props.ts +10 -0
  348. package/src/__generated__/image.props.ts +487 -0
  349. package/src/__generated__/input.props.ts +490 -0
  350. package/src/__generated__/italic.props.ts +443 -0
  351. package/src/__generated__/label.props.ts +445 -0
  352. package/src/__generated__/link-block.props.ts +477 -0
  353. package/src/__generated__/link.props.ts +477 -0
  354. package/src/__generated__/list-item.props.ts +444 -0
  355. package/src/__generated__/list.props.ts +457 -0
  356. package/src/__generated__/paragraph.props.ts +443 -0
  357. package/src/__generated__/radio-button-field.props.ts +444 -0
  358. package/src/__generated__/radio-button.props.ts +484 -0
  359. package/src/__generated__/rich-text-link.props.ts +477 -0
  360. package/src/__generated__/separator.props.ts +443 -0
  361. package/src/__generated__/slot.props.ts +3 -0
  362. package/src/__generated__/span.props.ts +443 -0
  363. package/src/__generated__/subscript.props.ts +443 -0
  364. package/src/__generated__/success-message.props.ts +443 -0
  365. package/src/__generated__/superscript.props.ts +443 -0
  366. package/src/__generated__/text-block.props.ts +450 -0
  367. package/src/__generated__/textarea.props.ts +457 -0
  368. package/src/blockquote.stories.tsx +16 -0
  369. package/src/blockquote.tsx +18 -0
  370. package/src/blockquote.ws.tsx +81 -0
  371. package/src/body.stories.tsx +11 -0
  372. package/src/body.tsx +10 -0
  373. package/src/body.ws.tsx +51 -0
  374. package/src/bold.stories.tsx +16 -0
  375. package/src/bold.tsx +10 -0
  376. package/src/bold.ws.tsx +26 -0
  377. package/src/box.stories.tsx +17 -0
  378. package/src/box.tsx +31 -0
  379. package/src/box.ws.ts +52 -0
  380. package/src/button.stories.tsx +13 -0
  381. package/src/button.tsx +23 -0
  382. package/src/button.ws.tsx +34 -0
  383. package/src/checkbox-field.tsx +10 -0
  384. package/src/checkbox-field.ws.tsx +47 -0
  385. package/src/checkbox.tsx +13 -0
  386. package/src/checkbox.ws.tsx +43 -0
  387. package/src/code-text.stories.tsx +16 -0
  388. package/src/code-text.tsx +31 -0
  389. package/src/code-text.ws.tsx +58 -0
  390. package/src/components.ts +33 -0
  391. package/src/error-message.tsx +10 -0
  392. package/src/error-message.ws.tsx +24 -0
  393. package/src/form.stories.tsx +14 -0
  394. package/src/form.tsx +14 -0
  395. package/src/form.ws.tsx +67 -0
  396. package/src/fragment.tsx +11 -0
  397. package/src/fragment.ws.ts +15 -0
  398. package/src/heading.stories.tsx +16 -0
  399. package/src/heading.tsx +20 -0
  400. package/src/heading.ws.tsx +44 -0
  401. package/src/html-embed.stories.tsx +16 -0
  402. package/src/html-embed.tsx +96 -0
  403. package/src/html-embed.ws.ts +27 -0
  404. package/src/image.stories.tsx +15 -0
  405. package/src/image.tsx +83 -0
  406. package/src/image.ws.tsx +54 -0
  407. package/src/input.stories.tsx +14 -0
  408. package/src/input.tsx +13 -0
  409. package/src/input.ws.tsx +40 -0
  410. package/src/italic.stories.tsx +16 -0
  411. package/src/italic.tsx +10 -0
  412. package/src/italic.ws.tsx +32 -0
  413. package/src/label.tsx +10 -0
  414. package/src/label.ws.tsx +48 -0
  415. package/src/link-block.stories.tsx +16 -0
  416. package/src/link-block.tsx +9 -0
  417. package/src/link-block.ws.tsx +38 -0
  418. package/src/link.stories.tsx +16 -0
  419. package/src/link.tsx +44 -0
  420. package/src/link.ws.tsx +64 -0
  421. package/src/list-item.stories.tsx +16 -0
  422. package/src/list-item.tsx +18 -0
  423. package/src/list-item.ws.tsx +36 -0
  424. package/src/list.stories.tsx +17 -0
  425. package/src/list.tsx +26 -0
  426. package/src/list.ws.tsx +58 -0
  427. package/src/metas.ts +33 -0
  428. package/src/paragraph.stories.tsx +16 -0
  429. package/src/paragraph.tsx +10 -0
  430. package/src/paragraph.ws.tsx +35 -0
  431. package/src/props.ts +33 -0
  432. package/src/radio-button-field.tsx +10 -0
  433. package/src/radio-button-field.ws.tsx +47 -0
  434. package/src/radio-button.tsx +13 -0
  435. package/src/radio-button.ws.tsx +43 -0
  436. package/src/rich-text-link.stories.tsx +16 -0
  437. package/src/rich-text-link.tsx +8 -0
  438. package/src/rich-text-link.ws.tsx +22 -0
  439. package/src/separator.stories.tsx +14 -0
  440. package/src/separator.tsx +18 -0
  441. package/src/separator.ws.tsx +56 -0
  442. package/src/slot.stories.tsx +16 -0
  443. package/src/slot.tsx +17 -0
  444. package/src/slot.ws.ts +18 -0
  445. package/src/span.stories.tsx +16 -0
  446. package/src/span.tsx +10 -0
  447. package/src/span.ws.tsx +26 -0
  448. package/src/subscript.stories.tsx +16 -0
  449. package/src/subscript.tsx +10 -0
  450. package/src/subscript.ws.tsx +26 -0
  451. package/src/success-message.tsx +10 -0
  452. package/src/success-message.ws.tsx +24 -0
  453. package/src/superscript.stories.tsx +16 -0
  454. package/src/superscript.tsx +10 -0
  455. package/src/superscript.ws.tsx +26 -0
  456. package/src/text-block.stories.tsx +16 -0
  457. package/src/text-block.tsx +21 -0
  458. package/src/text-block.ws.tsx +42 -0
  459. package/src/textarea.tsx +13 -0
  460. package/src/textarea.ws.tsx +44 -0
@@ -0,0 +1,44 @@
1
+ import { HeadingIcon } from "@webstudio-is/icons/svg";
2
+ import type { ComponentProps } from "react";
3
+ import {
4
+ defaultStates,
5
+ type PresetStyle,
6
+ type WsComponentMeta,
7
+ type WsComponentPropsMeta,
8
+ } from "@webstudio-is/react-sdk";
9
+ import { h1, h2, h3, h4, h5, h6 } from "@webstudio-is/react-sdk/css-normalize";
10
+ import type { Heading } from "./heading";
11
+ import { props } from "./__generated__/heading.props";
12
+
13
+ type HeadingTags = NonNullable<ComponentProps<typeof Heading>["tag"]>;
14
+
15
+ const presetStyle = {
16
+ h1,
17
+ h2,
18
+ h3,
19
+ h4,
20
+ h5,
21
+ h6,
22
+ } satisfies PresetStyle<HeadingTags>;
23
+
24
+ export const meta: WsComponentMeta = {
25
+ category: "text",
26
+ type: "rich-text",
27
+ label: "Heading",
28
+ icon: HeadingIcon,
29
+ states: defaultStates,
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,
39
+ };
40
+
41
+ export const propsMeta: WsComponentPropsMeta = {
42
+ props,
43
+ initialProps: ["tag"],
44
+ };
@@ -0,0 +1,16 @@
1
+ import type { ComponentStory, ComponentMeta } from "@storybook/react";
2
+ import { HtmlEmbed as HtmlEmbedPrimitive } from "./html-embed";
3
+
4
+ export default {
5
+ title: "Components/HtmlEmbed",
6
+ component: HtmlEmbedPrimitive,
7
+ } as ComponentMeta<typeof HtmlEmbedPrimitive>;
8
+
9
+ const Template: ComponentStory<typeof HtmlEmbedPrimitive> = (args) => (
10
+ <HtmlEmbedPrimitive {...args} />
11
+ );
12
+
13
+ export const HtmlEmbed = Template.bind({});
14
+ HtmlEmbed.args = {
15
+ code: "<strong>custom code</strong>",
16
+ };
@@ -0,0 +1,96 @@
1
+ import {
2
+ forwardRef,
3
+ useContext,
4
+ useEffect,
5
+ useRef,
6
+ type ForwardedRef,
7
+ } from "react";
8
+ import { mergeRefs } from "@react-aria/utils";
9
+ import { ReactSdkContext } from "@webstudio-is/react-sdk";
10
+
11
+ type Props = {
12
+ code: string;
13
+ executeScriptOnCanvas: boolean;
14
+ };
15
+
16
+ type ChildProps = {
17
+ innerRef: ForwardedRef<HTMLDivElement>;
18
+ // code can be actually undefined when prop is not provided
19
+ code?: string;
20
+ };
21
+
22
+ /**
23
+ * Scripts are executed when rendered client side.
24
+ * Necessary on canvas which does not have server rendering.
25
+ */
26
+ const ExecutableHtml = (props: ChildProps) => {
27
+ const { code, innerRef, ...rest } = props;
28
+ const containerRef = useRef<HTMLDivElement>(null);
29
+
30
+ useEffect(() => {
31
+ const container = containerRef.current;
32
+ if (container === null || code === undefined) {
33
+ return;
34
+ }
35
+ // the trick to execute inserted scripts
36
+ // https://ghinda.net/article/script-tags
37
+ const range = document.createRange();
38
+ range.setStart(container, 0);
39
+ const fragment = range.createContextualFragment(code);
40
+ while (container.firstChild) {
41
+ container.removeChild(container.firstChild);
42
+ }
43
+ container.append(fragment);
44
+ }, [code]);
45
+
46
+ return (
47
+ <div
48
+ {...rest}
49
+ ref={mergeRefs(innerRef, containerRef)}
50
+ style={{ display: "contents" }}
51
+ />
52
+ );
53
+ };
54
+
55
+ /**
56
+ * Scripts are executed when rendered server side
57
+ */
58
+ const InnerHtml = (props: ChildProps) => {
59
+ const { code, innerRef, ...rest } = props;
60
+
61
+ return (
62
+ <div
63
+ {...rest}
64
+ ref={innerRef}
65
+ style={{ display: "contents" }}
66
+ dangerouslySetInnerHTML={{ __html: props.code ?? "" }}
67
+ />
68
+ );
69
+ };
70
+
71
+ const Placeholder = (props: ChildProps) => {
72
+ const { code, innerRef, ...rest } = props;
73
+ return (
74
+ <div ref={innerRef} {...rest} style={{ padding: "20px" }}>
75
+ {'Open "Properties" panel to insert HTML code'}
76
+ </div>
77
+ );
78
+ };
79
+
80
+ export const HtmlEmbed = forwardRef<HTMLDivElement, Props>((props, ref) => {
81
+ const { renderer } = useContext(ReactSdkContext);
82
+ const { code, executeScriptOnCanvas, ...rest } = props;
83
+
84
+ // code can be actually undefined when prop is not provided
85
+ if (code === undefined || code.trim().length === 0) {
86
+ return <Placeholder innerRef={ref} {...rest} />;
87
+ }
88
+
89
+ if (renderer === "canvas" && executeScriptOnCanvas === true) {
90
+ return <ExecutableHtml innerRef={ref} code={code} {...rest} />;
91
+ }
92
+
93
+ return <InnerHtml innerRef={ref} code={code} {...rest} />;
94
+ });
95
+
96
+ HtmlEmbed.displayName = "HtmlEmbed";
@@ -0,0 +1,27 @@
1
+ import { EmbedIcon } from "@webstudio-is/icons/svg";
2
+ import type {
3
+ WsComponentMeta,
4
+ WsComponentPropsMeta,
5
+ } from "@webstudio-is/react-sdk";
6
+ import { props } from "./__generated__/html-embed.props";
7
+
8
+ export const meta: WsComponentMeta = {
9
+ category: "general",
10
+ type: "embed",
11
+ label: "HTML Embed",
12
+ icon: EmbedIcon,
13
+ stylable: false,
14
+ order: 7,
15
+ };
16
+
17
+ export const propsMeta: WsComponentPropsMeta = {
18
+ props: {
19
+ ...props,
20
+ code: {
21
+ required: true,
22
+ control: "code",
23
+ type: "string",
24
+ rows: 10,
25
+ },
26
+ },
27
+ };
@@ -0,0 +1,15 @@
1
+ import type { ComponentMeta, ComponentStory } from "@storybook/react";
2
+ import { Image as ImagePrimitive } from "./image";
3
+
4
+ export default {
5
+ title: "Components/Image",
6
+ component: ImagePrimitive,
7
+ } as ComponentMeta<typeof ImagePrimitive>;
8
+
9
+ const Template: ComponentStory<typeof ImagePrimitive> = (args) => (
10
+ <ImagePrimitive {...args} />
11
+ );
12
+
13
+ export const Image = Template.bind({});
14
+
15
+ Image.args = {};
package/src/image.tsx ADDED
@@ -0,0 +1,83 @@
1
+ import {
2
+ type ComponentPropsWithoutRef,
3
+ type ElementRef,
4
+ forwardRef,
5
+ useMemo,
6
+ } from "react";
7
+ import {
8
+ Image as WebstudioImage,
9
+ createImageLoader,
10
+ } from "@webstudio-is/image";
11
+ import {
12
+ usePropAsset,
13
+ getInstanceIdFromComponentProps,
14
+ getParams,
15
+ } from "@webstudio-is/react-sdk";
16
+
17
+ export const defaultTag = "img";
18
+
19
+ const imagePlaceholderSvg = `data:image/svg+xml;base64,${btoa(`<svg
20
+ width="140"
21
+ height="140"
22
+ viewBox="0 0 600 600"
23
+ fill="none"
24
+ xmlns="http://www.w3.org/2000/svg"
25
+ >
26
+ <rect width="600" height="600" fill="#CCCCCC" />
27
+ <path
28
+ fill-rule="evenodd"
29
+ clip-rule="evenodd"
30
+ d="M450 170H150C141.716 170 135 176.716 135 185V415C135 423.284 141.716 430 150 430H450C458.284 430 465 423.284 465 415V185C465 176.716 458.284 170 450 170ZM150 145C127.909 145 110 162.909 110 185V415C110 437.091 127.909 455 150 455H450C472.091 455 490 437.091 490 415V185C490 162.909 472.091 145 450 145H150Z"
31
+ fill="#A2A2A2"
32
+ />
33
+ <path
34
+ d="M237.135 235.012C237.135 255.723 220.345 272.512 199.635 272.512C178.924 272.512 162.135 255.723 162.135 235.012C162.135 214.301 178.924 197.512 199.635 197.512C220.345 197.512 237.135 214.301 237.135 235.012Z"
35
+ fill="#A2A2A2"
36
+ />
37
+ <path
38
+ d="M160 405V367.205L221.609 306.364L256.552 338.628L358.161 234L440 316.043V405H160Z"
39
+ fill="#A2A2A2"
40
+ />
41
+ </svg>`)}`;
42
+
43
+ type Props = ComponentPropsWithoutRef<typeof WebstudioImage>;
44
+
45
+ export const Image = forwardRef<ElementRef<typeof defaultTag>, Props>(
46
+ (props, ref) => {
47
+ const asset = usePropAsset(getInstanceIdFromComponentProps(props), "src");
48
+
49
+ const loader = useMemo(() => {
50
+ const params = getParams();
51
+ return createImageLoader({ imageBaseUrl: params.imageBaseUrl });
52
+ }, []);
53
+
54
+ const src = asset?.name ?? props.src;
55
+
56
+ if (asset == null || loader == null) {
57
+ return (
58
+ <img key={src} {...props} src={src || imagePlaceholderSvg} ref={ref} />
59
+ );
60
+ }
61
+
62
+ return (
63
+ <WebstudioImage
64
+ /**
65
+ * `key` is needed to recreate the image in case of asset change in builder,
66
+ * this gives immediate feedback when an asset is changed.
67
+ * Also, it visually fixes image distortion when another asset has a seriously different aspectRatio
68
+ * (we change aspectRatio CSS prop on asset change)
69
+ *
70
+ * In non-builder mode, key on images are usually also a good idea,
71
+ * prevents showing outdated images on route change.
72
+ **/
73
+ key={src}
74
+ {...props}
75
+ loader={loader}
76
+ src={src}
77
+ ref={ref}
78
+ />
79
+ );
80
+ }
81
+ );
82
+
83
+ Image.displayName = "Image";
@@ -0,0 +1,54 @@
1
+ import { ImageIcon } from "@webstudio-is/icons/svg";
2
+ import {
3
+ defaultStates,
4
+ type PresetStyle,
5
+ type WsComponentMeta,
6
+ type WsComponentPropsMeta,
7
+ } from "@webstudio-is/react-sdk";
8
+ import { img } from "@webstudio-is/react-sdk/css-normalize";
9
+ import type { defaultTag } from "./image";
10
+ import { props } from "./__generated__/image.props";
11
+
12
+ const presetStyle = {
13
+ img: [
14
+ ...img,
15
+
16
+ // Otherwise on new image insert onto canvas it can overfit screen size multiple times
17
+ {
18
+ property: "maxWidth",
19
+ value: { type: "unit", unit: "%", value: 100 },
20
+ },
21
+ // inline | inline-block is not suitable because without line-height: 0 on the parent you get unsuitable spaces/margins
22
+ // see https://stackoverflow.com/questions/24771194/is-the-margin-of-inline-block-4px-is-static-for-all-browsers
23
+ {
24
+ property: "display",
25
+ value: { type: "keyword", value: "block" },
26
+ },
27
+ ],
28
+ } satisfies PresetStyle<typeof defaultTag>;
29
+
30
+ export const meta: WsComponentMeta = {
31
+ category: "media",
32
+ type: "embed",
33
+ label: "Image",
34
+ icon: ImageIcon,
35
+ states: defaultStates,
36
+ presetStyle,
37
+ order: 0,
38
+ };
39
+
40
+ // "loader" is our internal prop not intended to show up in the props panel
41
+ const { loader, ...publicProps } = props;
42
+
43
+ export const propsMeta: WsComponentPropsMeta = {
44
+ props: {
45
+ ...publicProps,
46
+ src: {
47
+ type: "string",
48
+ control: "file",
49
+ label: "Source",
50
+ required: false,
51
+ },
52
+ },
53
+ initialProps: ["src", "width", "height", "alt", "loading"],
54
+ };
@@ -0,0 +1,14 @@
1
+ import type { ComponentStory, ComponentMeta } from "@storybook/react";
2
+ import { Input as InputPrimitive } from "./input";
3
+
4
+ export default {
5
+ title: "Components/Input",
6
+ component: InputPrimitive,
7
+ } as ComponentMeta<typeof InputPrimitive>;
8
+
9
+ const Template: ComponentStory<typeof InputPrimitive> = (args) => (
10
+ <InputPrimitive {...args} />
11
+ );
12
+
13
+ export const Input = Template.bind({});
14
+ Input.args = {};
package/src/input.tsx ADDED
@@ -0,0 +1,13 @@
1
+ import { forwardRef, type ElementRef, type ComponentProps } from "react";
2
+
3
+ export const defaultTag = "input";
4
+
5
+ export const Input = forwardRef<
6
+ ElementRef<typeof defaultTag>,
7
+ ComponentProps<typeof defaultTag> & {
8
+ type?: "text" | "email" | "password" | "number" | "tel" | "url";
9
+ }
10
+ // Make sure children are not passed down to an input, because this will result in error.
11
+ >(({ children: _children, ...props }, ref) => <input {...props} ref={ref} />);
12
+
13
+ Input.displayName = "Input";
@@ -0,0 +1,40 @@
1
+ import { FormTextFieldIcon } from "@webstudio-is/icons/svg";
2
+ import {
3
+ defaultStates,
4
+ type PresetStyle,
5
+ type WsComponentMeta,
6
+ type WsComponentPropsMeta,
7
+ } from "@webstudio-is/react-sdk";
8
+ import { input } from "@webstudio-is/react-sdk/css-normalize";
9
+ import type { defaultTag } from "./input";
10
+ import { props } from "./__generated__/input.props";
11
+
12
+ const presetStyle = {
13
+ input,
14
+ } satisfies PresetStyle<typeof defaultTag>;
15
+
16
+ export const meta: WsComponentMeta = {
17
+ category: "forms",
18
+ type: "control",
19
+ label: "Text Input",
20
+ icon: FormTextFieldIcon,
21
+ presetStyle,
22
+ order: 3,
23
+ states: [
24
+ ...defaultStates,
25
+ { selector: "::placeholder", label: "Placeholder" },
26
+ { selector: ":valid", label: "Valid" },
27
+ { selector: ":invalid", label: "Invalid" },
28
+ { selector: ":required", label: "Required" },
29
+ { selector: ":optional", label: "Optional" },
30
+ { selector: ":disabled", label: "Disabled" },
31
+ { selector: ":enabled", label: "Enabled" },
32
+ { selector: ":read-only", label: "Read Only" },
33
+ { selector: ":read-write", label: "Read Write" },
34
+ ],
35
+ };
36
+
37
+ export const propsMeta: WsComponentPropsMeta = {
38
+ props,
39
+ initialProps: ["name", "type", "placeholder", "required", "autoFocus"],
40
+ };
@@ -0,0 +1,16 @@
1
+ import type { ComponentStory, ComponentMeta } from "@storybook/react";
2
+ import { Italic as ItalicPrimitive } from "./italic";
3
+
4
+ export default {
5
+ title: "Components/Italic",
6
+ component: ItalicPrimitive,
7
+ } as ComponentMeta<typeof ItalicPrimitive>;
8
+
9
+ const Template: ComponentStory<typeof ItalicPrimitive> = (args) => (
10
+ <ItalicPrimitive {...args} />
11
+ );
12
+
13
+ export const Italic = Template.bind({});
14
+ Italic.args = {
15
+ children: "some italic text",
16
+ };
package/src/italic.tsx ADDED
@@ -0,0 +1,10 @@
1
+ import { forwardRef, type ElementRef, type ComponentProps } from "react";
2
+
3
+ export const defaultTag = "i";
4
+
5
+ export const Italic = forwardRef<
6
+ ElementRef<typeof defaultTag>,
7
+ ComponentProps<typeof defaultTag>
8
+ >((props, ref) => <i {...props} ref={ref} />);
9
+
10
+ Italic.displayName = "Italic";
@@ -0,0 +1,32 @@
1
+ import { TextItalicIcon } from "@webstudio-is/icons/svg";
2
+ import type { defaultTag } from "./italic";
3
+ import {
4
+ defaultStates,
5
+ type PresetStyle,
6
+ type WsComponentMeta,
7
+ type WsComponentPropsMeta,
8
+ } from "@webstudio-is/react-sdk";
9
+ import { i } from "@webstudio-is/react-sdk/css-normalize";
10
+ import { props } from "./__generated__/italic.props";
11
+
12
+ const presetStyle = {
13
+ i: [
14
+ ...i,
15
+ {
16
+ property: "fontStyle",
17
+ value: { type: "keyword", value: "italic" },
18
+ },
19
+ ],
20
+ } satisfies PresetStyle<typeof defaultTag>;
21
+
22
+ export const meta: WsComponentMeta = {
23
+ type: "rich-text-child",
24
+ label: "Italic Text",
25
+ icon: TextItalicIcon,
26
+ states: defaultStates,
27
+ presetStyle,
28
+ };
29
+
30
+ export const propsMeta: WsComponentPropsMeta = {
31
+ props,
32
+ };
package/src/label.tsx ADDED
@@ -0,0 +1,10 @@
1
+ import { forwardRef, type ElementRef, type ComponentProps } from "react";
2
+
3
+ export const defaultTag = "label";
4
+
5
+ export const Label = forwardRef<
6
+ ElementRef<typeof defaultTag>,
7
+ ComponentProps<typeof defaultTag>
8
+ >((props, ref) => <label {...props} ref={ref} />);
9
+
10
+ Label.displayName = "Label";
@@ -0,0 +1,48 @@
1
+ import { TextBlockIcon } from "@webstudio-is/icons/svg";
2
+ import {
3
+ type WsComponentMeta,
4
+ type WsComponentPropsMeta,
5
+ type PresetStyle,
6
+ defaultStates,
7
+ } from "@webstudio-is/react-sdk";
8
+ import { label } from "@webstudio-is/react-sdk/css-normalize";
9
+ import { props } from "./__generated__/label.props";
10
+ import type { defaultTag } from "./label";
11
+
12
+ const presetStyle = {
13
+ label: [
14
+ ...label,
15
+ { property: "display", value: { type: "keyword", value: "block" } },
16
+ ],
17
+ } satisfies PresetStyle<typeof defaultTag>;
18
+
19
+ export const meta: WsComponentMeta = {
20
+ category: "forms",
21
+ type: "rich-text",
22
+ label: "Input Label",
23
+ icon: TextBlockIcon,
24
+ states: defaultStates,
25
+ presetStyle,
26
+ order: 2,
27
+ template: [
28
+ {
29
+ type: "instance",
30
+ component: "Label",
31
+ children: [{ type: "text", value: "Form Label" }],
32
+ },
33
+ ],
34
+ };
35
+
36
+ export const propsMeta: WsComponentPropsMeta = {
37
+ props: {
38
+ ...props,
39
+ htmlFor: {
40
+ required: false,
41
+ control: "text",
42
+ type: "string",
43
+ rows: 0,
44
+ label: "For",
45
+ },
46
+ },
47
+ initialProps: ["htmlFor"],
48
+ };
@@ -0,0 +1,16 @@
1
+ import type { ComponentStory, ComponentMeta } from "@storybook/react";
2
+ import { LinkBlock as LinkBlockPrimitive } from "./link-block";
3
+
4
+ export default {
5
+ title: "Components/Link Block",
6
+ component: LinkBlockPrimitive,
7
+ } as ComponentMeta<typeof LinkBlockPrimitive>;
8
+
9
+ const Template: ComponentStory<typeof LinkBlockPrimitive> = (args) => (
10
+ <LinkBlockPrimitive {...args} />
11
+ );
12
+
13
+ export const LinkBlock = Template.bind({});
14
+ LinkBlock.args = {
15
+ children: "Link Block",
16
+ };
@@ -0,0 +1,9 @@
1
+ import { forwardRef } from "react";
2
+ import { Link } from "./link";
3
+ export { defaultTag } from "./link";
4
+
5
+ export const LinkBlock: typeof Link = forwardRef((props, ref) => (
6
+ <Link {...props} ref={ref} />
7
+ ));
8
+
9
+ LinkBlock.displayName = "LinkBlock";
@@ -0,0 +1,38 @@
1
+ import { LinkBlockIcon } from "@webstudio-is/icons/svg";
2
+ import type {
3
+ PresetStyle,
4
+ WsComponentMeta,
5
+ WsComponentPropsMeta,
6
+ } from "@webstudio-is/react-sdk";
7
+ import { a } from "@webstudio-is/react-sdk/css-normalize";
8
+ import { props } from "./__generated__/link-block.props";
9
+ import { meta as linkMeta, propsMeta as linkPropsMeta } from "./link.ws";
10
+ import type { defaultTag } from "./link-block";
11
+
12
+ const presetStyle = {
13
+ a: [
14
+ ...a,
15
+ {
16
+ property: "display",
17
+ value: { type: "keyword", value: "inline-block" },
18
+ },
19
+ ],
20
+ } satisfies PresetStyle<typeof defaultTag>;
21
+
22
+ export const meta: WsComponentMeta = {
23
+ category: "general",
24
+ type: "container",
25
+ label: "Link Block",
26
+ icon: LinkBlockIcon,
27
+ states: linkMeta.states,
28
+ presetStyle,
29
+ order: 2,
30
+ };
31
+
32
+ export const propsMeta: WsComponentPropsMeta = {
33
+ props: {
34
+ ...props,
35
+ href: linkPropsMeta.props.href,
36
+ },
37
+ initialProps: linkPropsMeta.initialProps,
38
+ };
@@ -0,0 +1,16 @@
1
+ import type { ComponentStory, ComponentMeta } from "@storybook/react";
2
+ import { Link as LinkPrimitive } from "./link";
3
+
4
+ export default {
5
+ title: "Components/Link",
6
+ component: LinkPrimitive,
7
+ } as ComponentMeta<typeof LinkPrimitive>;
8
+
9
+ const Template: ComponentStory<typeof LinkPrimitive> = (args) => (
10
+ <LinkPrimitive {...args} />
11
+ );
12
+
13
+ export const Link = Template.bind({});
14
+ Link.args = {
15
+ children: "Link",
16
+ };
package/src/link.tsx ADDED
@@ -0,0 +1,44 @@
1
+ import { forwardRef, type ComponentProps } from "react";
2
+ import {
3
+ usePropUrl,
4
+ getInstanceIdFromComponentProps,
5
+ getParams,
6
+ } from "@webstudio-is/react-sdk";
7
+
8
+ export const defaultTag = "a";
9
+
10
+ // @todo props that come from remix link, shouldn't be here at all
11
+ // - prefetch should be only on remix component and it already is
12
+ // - props meta should be generated from Remix link
13
+ // - changing this requires update in app/canvas/custom-components/link.tsx
14
+ type Props = Omit<ComponentProps<"a">, "href" | "target"> & {
15
+ href?: string;
16
+ target?: "_self" | "_blank" | "_parent" | "_top";
17
+ prefetch?: "none" | "intent" | "render";
18
+ };
19
+
20
+ export const Link = forwardRef<HTMLAnchorElement, Props>((props, ref) => {
21
+ const href = usePropUrl(getInstanceIdFromComponentProps(props), "href");
22
+
23
+ const { assetBaseUrl } = getParams();
24
+
25
+ let url = "#";
26
+
27
+ switch (href?.type) {
28
+ case "page":
29
+ url = href.page.path === "" ? "/" : href.page.path;
30
+ if (href.hash !== undefined) {
31
+ url += `#${href.hash}`;
32
+ }
33
+ break;
34
+ case "asset":
35
+ url = `${assetBaseUrl}${href.asset.name}`;
36
+ break;
37
+ case "string":
38
+ url = href.url;
39
+ }
40
+
41
+ return <a {...props} href={url} ref={ref} />;
42
+ });
43
+
44
+ Link.displayName = "Link";