@krak-stack/registry 0.10.19 → 0.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (472) hide show
  1. package/CHANGELOG.md +105 -0
  2. package/README.md +28 -7
  3. package/dist/components/agent/index.d.ts +454 -0
  4. package/dist/components/agent/react.d.ts +55 -0
  5. package/dist/components/agent/react.js +2594 -0
  6. package/dist/components/agent/schema.d.ts +55 -0
  7. package/dist/components/animated-list/classes.d.ts +9 -0
  8. package/dist/components/animated-list/html.d.ts +11 -0
  9. package/dist/components/animated-list/html.js +533 -0
  10. package/dist/components/animated-list/index.d.ts +205 -0
  11. package/dist/components/animated-list/react.d.ts +11 -0
  12. package/dist/components/animated-list/react.js +711 -0
  13. package/dist/components/animated-list/schema.d.ts +44 -0
  14. package/dist/components/animated-number/html.d.ts +19 -0
  15. package/dist/components/animated-number/html.js +101 -0
  16. package/dist/components/animated-number/index.d.ts +80 -0
  17. package/dist/components/{ui/animated-number.d.ts → animated-number/react.d.ts} +2 -7
  18. package/dist/components/animated-number/react.js +278 -0
  19. package/dist/components/animated-number/schema.d.ts +9 -0
  20. package/dist/components/app-brand/classes.d.ts +11 -0
  21. package/dist/components/app-brand/html.d.ts +26 -0
  22. package/dist/components/app-brand/html.js +78 -0
  23. package/dist/components/app-brand/react.d.ts +12 -0
  24. package/dist/components/app-brand/react.js +86 -0
  25. package/dist/components/app-brand/schema.d.ts +36 -0
  26. package/dist/components/app-switcher/classes.d.ts +15 -0
  27. package/dist/components/app-switcher/html.d.ts +72 -0
  28. package/dist/components/app-switcher/html.js +327 -0
  29. package/dist/components/app-switcher/index.d.ts +47 -0
  30. package/dist/components/app-switcher/react.d.ts +12 -0
  31. package/dist/components/{ui/app-switcher.js → app-switcher/react.js} +84 -15
  32. package/dist/components/app-switcher/schema.d.ts +39 -0
  33. package/dist/components/async-action-button/classes.d.ts +11 -0
  34. package/dist/components/async-action-button/html.d.ts +46 -0
  35. package/dist/components/async-action-button/html.js +266 -0
  36. package/dist/components/async-action-button/index.d.ts +73 -0
  37. package/dist/components/async-action-button/react.d.ts +10 -0
  38. package/dist/components/async-action-button/react.js +378 -0
  39. package/dist/components/async-action-button/schema.d.ts +28 -0
  40. package/dist/{services/events/client/audit-log-table.d.ts → components/audit-log-table/react.d.ts} +2 -2
  41. package/dist/{services/events/client/audit-log-table.js → components/audit-log-table/react.js} +2195 -918
  42. package/dist/components/auto-height/html.d.ts +8 -0
  43. package/dist/components/auto-height/html.js +81 -0
  44. package/dist/components/auto-height/index.d.ts +2 -0
  45. package/dist/components/{ui/auto-height.d.ts → auto-height/react.d.ts} +2 -4
  46. package/dist/components/auto-height/react.js +75 -0
  47. package/dist/components/auto-height/schema.d.ts +7 -0
  48. package/dist/components/bulk-list-input/classes.d.ts +7 -0
  49. package/dist/components/bulk-list-input/html.d.ts +41 -0
  50. package/dist/components/bulk-list-input/html.js +265 -0
  51. package/dist/components/bulk-list-input/index.d.ts +76 -0
  52. package/dist/components/bulk-list-input/react.d.ts +12 -0
  53. package/dist/components/{ui/bulk-list-input.js → bulk-list-input/react.js} +71 -4
  54. package/dist/components/bulk-list-input/schema.d.ts +33 -0
  55. package/dist/components/choice-cards/classes.d.ts +19 -0
  56. package/dist/components/choice-cards/html.d.ts +76 -0
  57. package/dist/components/choice-cards/html.js +237 -0
  58. package/dist/components/choice-cards/index.d.ts +1 -0
  59. package/dist/components/choice-cards/react.d.ts +21 -0
  60. package/dist/components/{ui/choice-cards.js → choice-cards/react.js} +29 -10
  61. package/dist/components/choice-cards/schema.d.ts +100 -0
  62. package/dist/components/code-block/classes.d.ts +13 -0
  63. package/dist/components/code-block/html.d.ts +21 -0
  64. package/dist/components/code-block/html.js +381 -0
  65. package/dist/components/code-block/index.d.ts +4 -0
  66. package/dist/components/code-block/react.d.ts +4 -0
  67. package/dist/components/code-block/react.js +493 -0
  68. package/dist/components/code-block/schema.d.ts +29 -0
  69. package/dist/components/color-input/classes.d.ts +9 -0
  70. package/dist/components/color-input/html.d.ts +48 -0
  71. package/dist/components/color-input/html.js +187 -0
  72. package/dist/components/color-input/index.d.ts +88 -0
  73. package/dist/components/color-input/react.d.ts +7 -0
  74. package/dist/components/{ui/color-picker.js → color-input/react.js} +165 -233
  75. package/dist/components/color-input/schema.d.ts +40 -0
  76. package/dist/components/copy-button/html.d.ts +48 -0
  77. package/dist/components/copy-button/html.js +266 -0
  78. package/dist/components/copy-button/index.d.ts +73 -0
  79. package/dist/components/copy-button/react.d.ts +12 -0
  80. package/dist/components/copy-button/react.js +388 -0
  81. package/dist/components/copy-button/schema.d.ts +37 -0
  82. package/dist/components/copy-value/html.d.ts +37 -0
  83. package/dist/components/copy-value/html.js +426 -0
  84. package/dist/components/copy-value/index.d.ts +57 -0
  85. package/dist/components/copy-value/react.d.ts +9 -0
  86. package/dist/components/copy-value/react.js +682 -0
  87. package/dist/components/copy-value/schema.d.ts +45 -0
  88. package/dist/components/cron-input/classes.d.ts +25 -0
  89. package/dist/components/cron-input/html.d.ts +36 -0
  90. package/dist/components/cron-input/html.js +204 -0
  91. package/dist/components/cron-input/index.d.ts +59 -0
  92. package/dist/components/cron-input/react.d.ts +7 -0
  93. package/dist/components/{ui/cron-expression-editor.js → cron-input/react.js} +126 -54
  94. package/dist/components/cron-input/schema.d.ts +24 -0
  95. package/dist/components/danger-confirmation/classes.d.ts +7 -0
  96. package/dist/components/danger-confirmation/html.d.ts +39 -0
  97. package/dist/components/danger-confirmation/html.js +227 -0
  98. package/dist/components/danger-confirmation/index.d.ts +113 -0
  99. package/dist/components/{ui/danger-confirmation.d.ts → danger-confirmation/react.d.ts} +3 -12
  100. package/dist/components/danger-confirmation/react.js +550 -0
  101. package/dist/components/danger-confirmation/schema.d.ts +34 -0
  102. package/dist/components/data-table/classes.d.ts +63 -0
  103. package/dist/components/data-table/html.d.ts +1938 -0
  104. package/dist/components/data-table/html.js +2682 -0
  105. package/dist/components/data-table/index.d.ts +2686 -0
  106. package/dist/components/data-table/react.d.ts +578 -0
  107. package/dist/components/{ui/data-table.js → data-table/react.js} +2189 -906
  108. package/dist/components/data-table/schema.d.ts +3012 -0
  109. package/dist/components/date-input/classes.d.ts +17 -0
  110. package/dist/components/date-input/html.d.ts +60 -0
  111. package/dist/components/date-input/html.js +418 -0
  112. package/dist/components/date-input/index.d.ts +91 -0
  113. package/dist/components/date-input/react.d.ts +10 -0
  114. package/dist/components/{ui/date-picker.js → date-input/react.js} +233 -79
  115. package/dist/components/date-input/schema.d.ts +41 -0
  116. package/dist/components/editable-text/classes.d.ts +17 -0
  117. package/dist/components/editable-text/html.d.ts +51 -0
  118. package/dist/components/editable-text/html.js +370 -0
  119. package/dist/components/editable-text/index.d.ts +143 -0
  120. package/dist/components/editable-text/react.d.ts +6 -0
  121. package/dist/components/editable-text/react.js +499 -0
  122. package/dist/components/editable-text/schema.d.ts +31 -0
  123. package/dist/components/editing-locale-switcher/classes.d.ts +7 -0
  124. package/dist/components/editing-locale-switcher/html.d.ts +27 -0
  125. package/dist/components/editing-locale-switcher/html.js +250 -0
  126. package/dist/components/editing-locale-switcher/index.d.ts +52 -0
  127. package/dist/components/editing-locale-switcher/react.d.ts +7 -0
  128. package/dist/components/{ui/editing-locale-switcher.js → editing-locale-switcher/react.js} +70 -17
  129. package/dist/components/editing-locale-switcher/schema.d.ts +16 -0
  130. package/dist/components/{ui/effect-form.d.ts → effect-form/react.d.ts} +2 -2
  131. package/dist/components/{ui/effect-form.js → effect-form/react.js} +309 -83
  132. package/dist/components/effectcn/alert-dialog.d.ts +13 -0
  133. package/dist/components/effectcn/button.d.ts +31 -0
  134. package/dist/components/effectcn/calendar.d.ts +12 -0
  135. package/dist/components/effectcn/checkbox.d.ts +10 -0
  136. package/dist/components/effectcn/combobox.d.ts +25 -0
  137. package/dist/components/effectcn/dialog.d.ts +19 -0
  138. package/dist/components/effectcn/field.d.ts +11 -0
  139. package/dist/components/effectcn/file-drop.d.ts +8 -0
  140. package/dist/components/effectcn/input.d.ts +26 -0
  141. package/dist/components/effectcn/menu.d.ts +85 -0
  142. package/dist/components/effectcn/menubar.d.ts +8 -0
  143. package/dist/components/effectcn/popover.d.ts +18 -0
  144. package/dist/components/effectcn/scroll-area.d.ts +12 -0
  145. package/dist/components/effectcn/select.d.ts +68 -0
  146. package/dist/components/effectcn/toast.d.ts +29 -0
  147. package/dist/components/email-composer/index.d.ts +229 -0
  148. package/dist/components/email-composer/labels.d.ts +12 -0
  149. package/dist/components/email-composer/react.d.ts +5 -0
  150. package/dist/components/email-composer/react.js +1354 -0
  151. package/dist/components/email-composer/schema.d.ts +42 -0
  152. package/dist/components/email-editor/classes.d.ts +21 -0
  153. package/dist/components/email-editor/html.d.ts +360 -0
  154. package/dist/components/email-editor/html.js +1706 -0
  155. package/dist/components/email-editor/index.d.ts +693 -0
  156. package/dist/components/{ui/email-editor.d.ts → email-editor/labels.d.ts} +1 -19
  157. package/dist/components/email-editor/legacy-editor.html.d.ts +160 -0
  158. package/dist/components/email-editor/react.d.ts +11 -0
  159. package/dist/components/{ui/email-editor.js → email-editor/react.js} +1057 -712
  160. package/dist/components/email-editor/schema.d.ts +162 -0
  161. package/dist/components/error-component/classes.d.ts +7 -0
  162. package/dist/components/error-component/html.d.ts +120 -0
  163. package/dist/components/error-component/html.js +346 -0
  164. package/dist/components/error-component/index.d.ts +69 -0
  165. package/dist/components/error-component/react.d.ts +8 -0
  166. package/dist/components/error-component/react.js +744 -0
  167. package/dist/components/error-component/schema.d.ts +56 -0
  168. package/dist/components/file-input/classes.d.ts +7 -0
  169. package/dist/components/file-input/html.d.ts +95 -0
  170. package/dist/components/file-input/html.js +368 -0
  171. package/dist/components/file-input/index.d.ts +99 -0
  172. package/dist/components/file-input/react.d.ts +11 -0
  173. package/dist/components/{ui/file-picker.js → file-input/react.js} +122 -19
  174. package/dist/components/file-input/schema.d.ts +37 -0
  175. package/dist/components/{ui/form.d.ts → form/react.d.ts} +4 -4
  176. package/dist/components/{ui/form.js → form/react.js} +314 -84
  177. package/dist/components/icon-input/html.d.ts +55 -0
  178. package/dist/components/icon-input/html.js +538 -0
  179. package/dist/components/icon-input/index.d.ts +143 -0
  180. package/dist/components/icon-input/react.d.ts +6 -0
  181. package/dist/components/{ui/icon-input.js → icon-input/react.js} +459 -89
  182. package/dist/components/icon-input/schema.d.ts +23 -0
  183. package/dist/components/image-crop-editor/classes.d.ts +19 -0
  184. package/dist/components/image-crop-editor/html.d.ts +66 -0
  185. package/dist/components/image-crop-editor/html.js +561 -0
  186. package/dist/components/image-crop-editor/index.d.ts +183 -0
  187. package/dist/components/image-crop-editor/react.d.ts +8 -0
  188. package/dist/components/image-crop-editor/react.js +802 -0
  189. package/dist/components/image-crop-editor/schema.d.ts +54 -0
  190. package/dist/components/krakstack-provider/html.d.ts +17 -0
  191. package/dist/components/krakstack-provider/html.js +37 -0
  192. package/dist/components/krakstack-provider/index.d.ts +7 -0
  193. package/dist/components/krakstack-provider/react.d.ts +8 -0
  194. package/dist/components/{ui/krakstack-provider.js → krakstack-provider/react.js} +14 -5
  195. package/dist/components/krakstack-provider/schema.d.ts +6 -0
  196. package/dist/components/loading/classes.d.ts +5 -0
  197. package/dist/components/loading/html.d.ts +18 -0
  198. package/dist/components/loading/html.js +166 -0
  199. package/dist/components/loading/index.d.ts +6 -0
  200. package/dist/components/loading/react.d.ts +4 -0
  201. package/dist/components/loading/react.js +51 -0
  202. package/dist/components/loading/schema.d.ts +23 -0
  203. package/dist/components/locale-switcher/html.d.ts +22 -0
  204. package/dist/components/locale-switcher/html.js +264 -0
  205. package/dist/components/locale-switcher/index.d.ts +50 -0
  206. package/dist/components/locale-switcher/react.d.ts +7 -0
  207. package/dist/components/{ui/locale-switcher.js → locale-switcher/react.js} +55 -22
  208. package/dist/components/locale-switcher/schema.d.ts +12 -0
  209. package/dist/components/map-menu/classes.d.ts +13 -0
  210. package/dist/components/map-menu/google-maps.d.ts +80 -0
  211. package/dist/components/map-menu/google-viewport.d.ts +7 -0
  212. package/dist/components/map-menu/html.d.ts +274 -0
  213. package/dist/components/map-menu/html.js +934 -0
  214. package/dist/components/map-menu/index.d.ts +246 -0
  215. package/dist/components/map-menu/map.d.ts +47 -0
  216. package/dist/components/map-menu/react.d.ts +40 -0
  217. package/dist/components/{ui/map-menu.js → map-menu/react.js} +502 -141
  218. package/dist/components/map-menu/schema.d.ts +132 -0
  219. package/dist/components/markdown/classes.d.ts +1 -0
  220. package/dist/components/markdown/html.d.ts +23 -0
  221. package/dist/components/markdown/html.js +510 -0
  222. package/dist/components/markdown/index.d.ts +6 -0
  223. package/dist/components/markdown/react.d.ts +3 -0
  224. package/dist/components/markdown/react.js +546 -0
  225. package/dist/components/markdown/schema.d.ts +20 -0
  226. package/dist/components/notification-menu/classes.d.ts +11 -0
  227. package/dist/components/notification-menu/html.d.ts +67 -0
  228. package/dist/components/notification-menu/html.js +425 -0
  229. package/dist/components/notification-menu/index.d.ts +132 -0
  230. package/dist/components/notification-menu/react.d.ts +57 -0
  231. package/dist/components/notification-menu/react.js +829 -0
  232. package/dist/components/notification-menu/schema.d.ts +59 -0
  233. package/dist/components/pagination/classes.d.ts +19 -0
  234. package/dist/components/pagination/html.d.ts +49 -0
  235. package/dist/components/pagination/html.js +387 -0
  236. package/dist/components/pagination/index.d.ts +109 -0
  237. package/dist/components/pagination/react.d.ts +9 -0
  238. package/dist/components/{ui/pagination.js → pagination/react.js} +130 -30
  239. package/dist/components/pagination/schema.d.ts +36 -0
  240. package/dist/components/phone-number-input/classes.d.ts +17 -0
  241. package/dist/components/phone-number-input/html.d.ts +52 -0
  242. package/dist/components/phone-number-input/html.js +655 -0
  243. package/dist/components/phone-number-input/index.d.ts +59 -0
  244. package/dist/components/phone-number-input/react.d.ts +11 -0
  245. package/dist/components/{ui/phone-number-input.js → phone-number-input/react.js} +368 -138
  246. package/dist/components/phone-number-input/schema.d.ts +31 -0
  247. package/dist/components/presence-transition/html.d.ts +13 -0
  248. package/dist/components/presence-transition/html.js +128 -0
  249. package/dist/components/presence-transition/index.d.ts +57 -0
  250. package/dist/components/{ui/presence-transition.d.ts → presence-transition/react.d.ts} +3 -5
  251. package/dist/components/presence-transition/react.js +293 -0
  252. package/dist/components/presence-transition/schema.d.ts +7 -0
  253. package/dist/components/registry-previews/component-example.d.ts +31 -0
  254. package/dist/components/registry-previews/component-example.js +679 -0
  255. package/dist/components/registry-previews/html-preview.d.ts +17 -0
  256. package/dist/components/registry-previews/html-preview.js +83 -0
  257. package/dist/components/rich-text-editor/classes.d.ts +15 -0
  258. package/dist/components/rich-text-editor/engine.d.ts +9 -0
  259. package/dist/components/rich-text-editor/html.d.ts +246 -0
  260. package/dist/components/rich-text-editor/html.js +830 -0
  261. package/dist/components/rich-text-editor/index.d.ts +453 -0
  262. package/dist/components/rich-text-editor/labels.d.ts +42 -0
  263. package/dist/components/rich-text-editor/react.d.ts +19 -0
  264. package/dist/components/rich-text-editor/react.js +1175 -0
  265. package/dist/components/rich-text-editor/schema.d.ts +116 -0
  266. package/dist/components/search-menu/classes.d.ts +9 -0
  267. package/dist/components/search-menu/html.d.ts +127 -0
  268. package/dist/components/search-menu/html.js +432 -0
  269. package/dist/components/search-menu/index.d.ts +85 -0
  270. package/dist/components/search-menu/react.d.ts +18 -0
  271. package/dist/components/{ui/search-menu.js → search-menu/react.js} +290 -31
  272. package/dist/components/search-menu/schema.d.ts +78 -0
  273. package/dist/components/select-with-custom-input/classes.d.ts +17 -0
  274. package/dist/components/select-with-custom-input/html.d.ts +60 -0
  275. package/dist/components/select-with-custom-input/html.js +238 -0
  276. package/dist/components/select-with-custom-input/index.d.ts +114 -0
  277. package/dist/components/select-with-custom-input/react.d.ts +7 -0
  278. package/dist/components/{ui/select-with-custom-input.js → select-with-custom-input/react.js} +134 -29
  279. package/dist/components/select-with-custom-input/schema.d.ts +54 -0
  280. package/dist/components/sidebar-layout/classes.d.ts +21 -0
  281. package/dist/components/sidebar-layout/html.d.ts +97 -0
  282. package/dist/components/sidebar-layout/html.js +361 -0
  283. package/dist/components/sidebar-layout/index.d.ts +57 -0
  284. package/dist/components/sidebar-layout/react.d.ts +30 -0
  285. package/dist/components/{ui/sidebar-layout.js → sidebar-layout/react.js} +353 -39
  286. package/dist/components/sidebar-layout/schema.d.ts +54 -0
  287. package/dist/components/stats-card/classes.d.ts +11 -0
  288. package/dist/components/stats-card/html.d.ts +15 -0
  289. package/dist/components/stats-card/html.js +55 -0
  290. package/dist/components/stats-card/react.d.ts +7 -0
  291. package/dist/components/{ui/stats-card.js → stats-card/react.js} +19 -15
  292. package/dist/components/stats-card/schema.d.ts +14 -0
  293. package/dist/components/stepper/classes.d.ts +39 -0
  294. package/dist/components/stepper/html.d.ts +107 -0
  295. package/dist/components/stepper/html.js +397 -0
  296. package/dist/components/stepper/index.d.ts +83 -0
  297. package/dist/components/stepper/react.d.ts +17 -0
  298. package/dist/components/{ui/stepper.js → stepper/react.js} +120 -21
  299. package/dist/components/stepper/schema.d.ts +52 -0
  300. package/dist/components/support/classes.d.ts +55 -0
  301. package/dist/components/support/form.d.ts +19 -0
  302. package/dist/components/support/html.d.ts +266 -0
  303. package/dist/components/support/html.js +604 -0
  304. package/dist/components/support/index.d.ts +226 -0
  305. package/dist/components/support/multipart.d.ts +21 -0
  306. package/dist/components/support/react.d.ts +54 -0
  307. package/dist/components/support/react.js +1252 -0
  308. package/dist/components/support/schema.d.ts +69 -0
  309. package/dist/components/support.d.ts +1 -66
  310. package/dist/components/theme-switcher/html.d.ts +28 -0
  311. package/dist/components/theme-switcher/html.js +288 -0
  312. package/dist/components/theme-switcher/index.d.ts +59 -0
  313. package/dist/components/{ui/theme-switcher.d.ts → theme-switcher/react.d.ts} +4 -12
  314. package/dist/components/{ui/theme-switcher.js → theme-switcher/react.js} +69 -35
  315. package/dist/components/theme-switcher/schema.d.ts +33 -0
  316. package/dist/components/time-input/classes.d.ts +23 -0
  317. package/dist/components/time-input/html.d.ts +75 -0
  318. package/dist/components/time-input/html.js +571 -0
  319. package/dist/components/time-input/index.d.ts +164 -0
  320. package/dist/components/time-input/react.d.ts +7 -0
  321. package/dist/components/{ui/time-picker.js → time-input/react.js} +286 -114
  322. package/dist/components/time-input/schema.d.ts +96 -0
  323. package/dist/components/timezone-input/classes.d.ts +13 -0
  324. package/dist/components/timezone-input/html.d.ts +58 -0
  325. package/dist/components/timezone-input/html.js +804 -0
  326. package/dist/components/timezone-input/index.d.ts +170 -0
  327. package/dist/components/timezone-input/react.d.ts +9 -0
  328. package/dist/components/{ui/timezone-select.js → timezone-input/react.js} +493 -106
  329. package/dist/components/timezone-input/schema.d.ts +43 -0
  330. package/dist/components/toast/classes.d.ts +7 -0
  331. package/dist/components/toast/html.d.ts +34 -0
  332. package/dist/components/toast/html.js +280 -0
  333. package/dist/components/toast/index.d.ts +10 -0
  334. package/dist/components/toast/react.d.ts +9 -0
  335. package/dist/components/{ui/toast.js → toast/react.js} +35 -15
  336. package/dist/components/toast/schema.d.ts +24 -0
  337. package/dist/{services/events/client/tracking-notice.d.ts → components/tracking-notice/react.d.ts} +7 -1
  338. package/dist/{services/events/client/tracking-notice.js → components/tracking-notice/react.js} +13 -7
  339. package/dist/components/ui/animated-list.d.ts +1 -21
  340. package/dist/components/ui/app-brand.d.ts +1 -33
  341. package/dist/components/ui/async-action-button.d.ts +1 -17
  342. package/dist/components/ui/code-block.d.ts +1 -14
  343. package/dist/components/ui/copy-button.d.ts +1 -21
  344. package/dist/components/ui/data-table.d.ts +1 -584
  345. package/dist/components/ui/krakstack-provider.d.ts +1 -9
  346. package/dist/components/ui/loading.d.ts +1 -13
  347. package/dist/components/ui/pagination.d.ts +1 -47
  348. package/dist/components/ui/rich-text-editor.d.ts +1 -70
  349. package/dist/components/ui/search-menu.d.ts +1 -36
  350. package/dist/components/ui/select.js +159 -0
  351. package/dist/components/ui/sidebar-layout.d.ts +1 -40
  352. package/dist/components/ui/virtualized-combobox.d.ts +1 -59
  353. package/dist/components/unsaved-changes-guard/html.d.ts +34 -0
  354. package/dist/components/unsaved-changes-guard/html.js +172 -0
  355. package/dist/components/unsaved-changes-guard/index.d.ts +56 -0
  356. package/dist/components/unsaved-changes-guard/react.d.ts +4 -0
  357. package/dist/components/{ui/unsaved-changes-guard.js → unsaved-changes-guard/react.js} +74 -11
  358. package/dist/components/unsaved-changes-guard/schema.d.ts +37 -0
  359. package/dist/components/upload-attachment/classes.d.ts +11 -0
  360. package/dist/components/upload-attachment/html.d.ts +84 -0
  361. package/dist/components/upload-attachment/html.js +312 -0
  362. package/dist/components/upload-attachment/index.d.ts +72 -0
  363. package/dist/components/upload-attachment/react.d.ts +9 -0
  364. package/dist/components/{ui/upload-attachment.js → upload-attachment/react.js} +114 -17
  365. package/dist/components/upload-attachment/schema.d.ts +53 -0
  366. package/dist/components/virtualized-combobox/classes.d.ts +7 -0
  367. package/dist/components/virtualized-combobox/html.d.ts +97 -0
  368. package/dist/components/virtualized-combobox/html.js +310 -0
  369. package/dist/components/virtualized-combobox/index.d.ts +182 -0
  370. package/dist/components/virtualized-combobox/react.d.ts +31 -0
  371. package/dist/components/{ui/virtualized-combobox.js → virtualized-combobox/react.js} +160 -40
  372. package/dist/components/virtualized-combobox/schema.d.ts +92 -0
  373. package/dist/components/webhook-delivery-table/html.d.ts +216 -0
  374. package/dist/components/webhook-delivery-table/html.js +3008 -0
  375. package/dist/components/webhook-delivery-table/index.d.ts +405 -0
  376. package/dist/components/webhook-delivery-table/react.d.ts +13 -0
  377. package/dist/{services/webhooks/client/delivery-table.js → components/webhook-delivery-table/react.js} +2475 -956
  378. package/dist/components/webhook-delivery-table/schema.d.ts +134 -0
  379. package/dist/lib/docs.d.ts +17 -1
  380. package/dist/lib/docs.integrations.server.js +358 -73
  381. package/dist/lib/docs.js +861 -293
  382. package/dist/lib/docs.server.js +342 -57
  383. package/dist/lib/documentation-toolkit.d.ts +4 -4
  384. package/dist/lib/documentation-toolkit.js +354 -69
  385. package/dist/lib/effect-ui-adapter/model-runtime.d.ts +17 -0
  386. package/dist/lib/effect-ui-adapter/use-model.d.ts +9 -0
  387. package/dist/lib/effectcn-form.d.ts +3 -0
  388. package/dist/lib/effectcn-form.js +54 -0
  389. package/dist/lib/email-composer/index.d.ts +12 -0
  390. package/dist/lib/email-composer/index.js +110 -0
  391. package/dist/lib/email-composer/schema.d.ts +14 -0
  392. package/dist/lib/email-composer/schema.js +13 -0
  393. package/dist/lib/email-document/legacy-rich-text/editor.d.ts +70 -0
  394. package/dist/lib/email-document/legacy-rich-text/model.d.ts +19 -0
  395. package/dist/lib/email-document/legacy-rich-text/schema.d.ts +65 -0
  396. package/dist/lib/email-document/legacy-rich-text/tiptap.d.ts +39 -0
  397. package/dist/lib/email-document/model.d.ts +1 -1
  398. package/dist/lib/email-document/model.js +2 -2
  399. package/dist/lib/email-document/render.js +2 -2
  400. package/dist/lib/email-document/schema.js +1 -1
  401. package/dist/lib/httpapi-toolkit.d.ts +1 -1
  402. package/dist/lib/lucide-effect.d.ts +39 -0
  403. package/dist/lib/markdown/content.d.ts +1 -12
  404. package/dist/lib/rich-text/model.d.ts +5 -19
  405. package/dist/lib/rich-text/model.js +79 -111
  406. package/dist/lib/rich-text/schema.d.ts +5 -55
  407. package/dist/lib/rich-text/schema.js +17 -36
  408. package/dist/lib/rich-text/tiptap.d.ts +12 -0
  409. package/dist/lib/webfetch-toolkit.d.ts +1 -1
  410. package/dist/services/agent/client/index.js +695 -179
  411. package/dist/services/agent/client/widget.d.ts +1 -55
  412. package/dist/services/notification/client/index.js +138 -27
  413. package/dist/services/notification/client/notification-menu.d.ts +1 -85
  414. package/dist/services/notification/public.js +138 -27
  415. package/dist/services/opentelemetry/browser.js +15 -9
  416. package/dist/services/webhooks/index.d.ts +4 -3
  417. package/package.json +199 -137
  418. package/dist/components/support-dialog.js +0 -881
  419. package/dist/components/support.js +0 -881
  420. package/dist/components/ui/animated-list.js +0 -414
  421. package/dist/components/ui/animated-number.js +0 -75
  422. package/dist/components/ui/app-brand.js +0 -126
  423. package/dist/components/ui/app-switcher.d.ts +0 -26
  424. package/dist/components/ui/async-action-button.js +0 -149
  425. package/dist/components/ui/auto-height.js +0 -86
  426. package/dist/components/ui/bulk-list-input.d.ts +0 -25
  427. package/dist/components/ui/choice-cards.d.ts +0 -33
  428. package/dist/components/ui/code-block.js +0 -221
  429. package/dist/components/ui/color-picker.d.ts +0 -31
  430. package/dist/components/ui/copy-button.js +0 -138
  431. package/dist/components/ui/copy-value.d.ts +0 -24
  432. package/dist/components/ui/copy-value.js +0 -352
  433. package/dist/components/ui/cron-expression-editor.d.ts +0 -16
  434. package/dist/components/ui/cron-expression-editor.schema.d.ts +0 -7
  435. package/dist/components/ui/danger-confirmation.js +0 -398
  436. package/dist/components/ui/date-picker.d.ts +0 -33
  437. package/dist/components/ui/date-picker.schema.d.ts +0 -9
  438. package/dist/components/ui/editable-text.d.ts +0 -19
  439. package/dist/components/ui/editable-text.js +0 -341
  440. package/dist/components/ui/editing-locale-switcher.d.ts +0 -11
  441. package/dist/components/ui/error-component.d.ts +0 -34
  442. package/dist/components/ui/error-component.js +0 -387
  443. package/dist/components/ui/file-picker.d.ts +0 -37
  444. package/dist/components/ui/icon-input.d.ts +0 -58
  445. package/dist/components/ui/image-crop-editor.d.ts +0 -41
  446. package/dist/components/ui/image-crop-editor.js +0 -417
  447. package/dist/components/ui/loading.js +0 -39
  448. package/dist/components/ui/locale-switcher.d.ts +0 -11
  449. package/dist/components/ui/map-menu-map.d.ts +0 -115
  450. package/dist/components/ui/map-menu.d.ts +0 -87
  451. package/dist/components/ui/phone-number-input.d.ts +0 -22
  452. package/dist/components/ui/phone-number-input.schema.d.ts +0 -7
  453. package/dist/components/ui/presence-transition.js +0 -94
  454. package/dist/components/ui/rich-text-editor.js +0 -1135
  455. package/dist/components/ui/select-with-custom-input.d.ts +0 -36
  456. package/dist/components/ui/stats-card.d.ts +0 -12
  457. package/dist/components/ui/stepper.d.ts +0 -37
  458. package/dist/components/ui/time-picker.d.ts +0 -50
  459. package/dist/components/ui/time-picker.schema.d.ts +0 -28
  460. package/dist/components/ui/timezone-select.d.ts +0 -57
  461. package/dist/components/ui/timezone-select.schema.d.ts +0 -9
  462. package/dist/components/ui/toast.d.ts +0 -18
  463. package/dist/components/ui/unsaved-changes-guard.d.ts +0 -16
  464. package/dist/components/ui/upload-attachment.d.ts +0 -39
  465. package/dist/lib/rich-text/dom.d.ts +0 -40
  466. package/dist/services/notification/persistence/drizzle.d.ts +0 -868
  467. package/dist/services/notification/persistence/drizzle.js +0 -214
  468. package/dist/services/notification/persistence/index.d.ts +0 -2
  469. package/dist/services/notification/persistence/index.js +0 -227
  470. package/dist/services/notification/persistence/schema.d.ts +0 -143
  471. package/dist/services/notification/persistence/schema.js +0 -118
  472. package/dist/services/webhooks/client/delivery-table.d.ts +0 -62
@@ -1,11 +1,11 @@
1
- // ../../src/components/ui/email-editor.tsx
2
- import { Schema as Schema7 } from "effect";
1
+ // ../../src/components/email-editor/react.tsx
2
+ import { Schema as Schema11 } from "effect";
3
3
  import { Popover } from "@base-ui/react/popover";
4
4
  import {
5
5
  useId as useId3,
6
6
  useMemo,
7
7
  useRef as useRef4,
8
- useState as useState4
8
+ useState as useState5
9
9
  } from "react";
10
10
  import {
11
11
  Type,
@@ -106,7 +106,7 @@ function SelectTrigger({
106
106
  return /* @__PURE__ */ jsxs(SelectPrimitive.Trigger, {
107
107
  "data-slot": "select-trigger",
108
108
  "data-size": size,
109
- className: cn("flex w-fit items-center justify-between gap-1.5 rounded-md border border-input bg-transparent py-2 pr-2 pl-2.5 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", className),
109
+ className: cn("border-input focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 flex w-fit items-center justify-between gap-1.5 rounded-md border bg-transparent py-2 pr-2 pl-2.5 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-3 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:ring-3 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", className),
110
110
  ...props,
111
111
  children: [
112
112
  children,
@@ -123,9 +123,9 @@ function SelectContent({
123
123
  children,
124
124
  side = "bottom",
125
125
  sideOffset = 4,
126
- align = "center",
126
+ align = "start",
127
127
  alignOffset = 0,
128
- alignItemWithTrigger = true,
128
+ alignItemWithTrigger = false,
129
129
  ...props
130
130
  }) {
131
131
  return /* @__PURE__ */ jsx3(SelectPrimitive.Portal, {
@@ -139,7 +139,7 @@ function SelectContent({
139
139
  children: /* @__PURE__ */ jsxs(SelectPrimitive.Popup, {
140
140
  "data-slot": "select-content",
141
141
  "data-align-trigger": alignItemWithTrigger,
142
- className: cn("relative isolate z-50 max-h-(--available-height) w-(--anchor-width) min-w-36 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-md bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[align-trigger=true]:animate-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95", className),
142
+ className: cn("bg-popover text-popover-foreground ring-foreground/10 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 relative isolate z-50 max-h-(--available-height) w-(--anchor-width) max-w-(--available-width) min-w-0 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-md shadow-md ring-1 duration-100 data-[align-trigger=true]:animate-none", className),
143
143
  ...props,
144
144
  children: [
145
145
  /* @__PURE__ */ jsx3(SelectScrollUpButton, {}),
@@ -159,7 +159,7 @@ function SelectItem({
159
159
  }) {
160
160
  return /* @__PURE__ */ jsxs(SelectPrimitive.Item, {
161
161
  "data-slot": "select-item",
162
- className: cn("relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2", className),
162
+ className: cn("focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2", className),
163
163
  ...props,
164
164
  children: [
165
165
  /* @__PURE__ */ jsx3(SelectPrimitive.ItemText, {
@@ -183,7 +183,7 @@ function SelectScrollUpButton({
183
183
  }) {
184
184
  return /* @__PURE__ */ jsx3(SelectPrimitive.ScrollUpArrow, {
185
185
  "data-slot": "select-scroll-up-button",
186
- className: cn("top-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4", className),
186
+ className: cn("bg-popover top-0 z-10 flex w-full cursor-default items-center justify-center py-1 [&_svg:not([class*='size-'])]:size-4", className),
187
187
  ...props,
188
188
  children: /* @__PURE__ */ jsx3(ChevronUpIcon, {})
189
189
  });
@@ -194,7 +194,7 @@ function SelectScrollDownButton({
194
194
  }) {
195
195
  return /* @__PURE__ */ jsx3(SelectPrimitive.ScrollDownArrow, {
196
196
  "data-slot": "select-scroll-down-button",
197
- className: cn("bottom-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4", className),
197
+ className: cn("bg-popover bottom-0 z-10 flex w-full cursor-default items-center justify-center py-1 [&_svg:not([class*='size-'])]:size-4", className),
198
198
  ...props,
199
199
  children: /* @__PURE__ */ jsx3(ChevronDownIcon, {})
200
200
  });
@@ -240,17 +240,18 @@ function PopoverTitle({ className, ...props }) {
240
240
  });
241
241
  }
242
242
 
243
- // ../../src/components/ui/animated-list.tsx
243
+ // ../../src/components/animated-list/react.tsx
244
244
  import {
245
- useEffect as useEffect2,
245
+ useEffect as useEffect3,
246
246
  useEffectEvent as useEffectEvent2,
247
247
  useId,
248
- useRef as useRef2,
249
- useState as useState2
248
+ useRef as useRef3,
249
+ useState as useState3
250
250
  } from "react";
251
251
  import { GripVertical } from "lucide-react";
252
+ import { Component as Component2, View as View2 } from "effect/ui";
252
253
  import { cn as cn2 } from "cn";
253
- import { useKrakstackLocale } from "@krak-stack/registry/krakstack-provider";
254
+ import { useKrakstackLocale } from "@krak-stack/registry/krakstack-provider/react";
254
255
 
255
256
  // ../../src/lib/krakmotion.ts
256
257
  import {
@@ -284,26 +285,6 @@ var animateElement = (element, frames, duration, complete) => {
284
285
  animation.cancel();
285
286
  };
286
287
  };
287
- var useKeyedPresence = (items, getKey) => {
288
- const [previous, setPrevious] = useState(items);
289
- const [retained, setRetained] = useState(items);
290
- if (previous !== items) {
291
- const keys = new Set(items.map(getKey));
292
- const next = [...items];
293
- retained.forEach((item, index) => {
294
- if (!keys.has(getKey(item)))
295
- next.splice(Math.min(index, next.length), 0, item);
296
- });
297
- setPrevious(items);
298
- setRetained(next);
299
- }
300
- const present = new Set(items.map(getKey));
301
- return {
302
- items: retained,
303
- present,
304
- remove: (key) => setRetained((current) => current.filter((item) => getKey(item) !== key))
305
- };
306
- };
307
288
  var useListLayout = (ref, duration) => {
308
289
  const previous = useRef(new Map);
309
290
  const animations = useRef(new Map);
@@ -469,8 +450,205 @@ var useVerticalDrag = ({
469
450
  };
470
451
  };
471
452
 
472
- // ../../src/components/ui/animated-list.tsx
473
- import { jsx as jsx5, jsxs as jsxs2, Fragment } from "react/jsx-runtime";
453
+ // ../../src/lib/effect-ui-adapter/use-model.ts
454
+ import { MessageLog as MessageLog2 } from "effect/ui";
455
+ import {
456
+ createContext,
457
+ useCallback,
458
+ useContext,
459
+ useEffect as useEffect2,
460
+ useLayoutEffect as useLayoutEffect2,
461
+ useRef as useRef2,
462
+ useState as useState2,
463
+ useSyncExternalStore as useSyncExternalStore2
464
+ } from "react";
465
+
466
+ // ../../src/lib/effect-ui-adapter/model-runtime.ts
467
+ import { MessageLog, Renderer, View } from "effect/ui";
468
+ import { BrowserHost, Html } from "effect/ui/html";
469
+ import { Cause, Effect, Fiber } from "effect";
470
+ var node = () => ({ children: [] });
471
+ var modelHost = (commit) => {
472
+ const remove = (child) => {
473
+ if (!child.parent)
474
+ return;
475
+ child.parent.children.splice(child.parent.children.indexOf(child), 1);
476
+ delete child.parent;
477
+ };
478
+ return {
479
+ createElement: node,
480
+ createText: node,
481
+ setText: () => {},
482
+ setAttr: () => {},
483
+ setProp: () => {},
484
+ setEvents: () => {},
485
+ insertBefore: (parent, child, before) => {
486
+ if (child === before)
487
+ return;
488
+ remove(child);
489
+ const index = before ? parent.children.indexOf(before) : parent.children.length;
490
+ parent.children.splice(index, 0, child);
491
+ child.parent = parent;
492
+ },
493
+ remove,
494
+ parentOf: (child) => child.parent,
495
+ nextOf: (child) => child.parent?.children[child.parent.children.indexOf(child) + 1],
496
+ elements: ["html"],
497
+ controlled: new Set,
498
+ runsMounts: false,
499
+ commit
500
+ };
501
+ };
502
+ var mountModel = (component, props, publishSnapshot, messageLog, onEmit) => {
503
+ let currentProps = props;
504
+ let root;
505
+ let active = true;
506
+ let failure;
507
+ const publish = () => {
508
+ if (!active)
509
+ return;
510
+ if (failure) {
511
+ publishSnapshot({ error: failure });
512
+ return;
513
+ }
514
+ const current = root?.model();
515
+ if (current !== undefined)
516
+ publishSnapshot({ model: current });
517
+ };
518
+ const fiber = Effect.runFork(Effect.scoped(Effect.gen(function* () {
519
+ const mounted = yield* Renderer.mount(component, Effect.succeed(props), node(), {
520
+ head: false,
521
+ onEmit,
522
+ fallback: ({ cause }) => {
523
+ failure = new Error("Effect UI root failed", {
524
+ cause: Cause.squash(cause)
525
+ });
526
+ return View.text("");
527
+ }
528
+ });
529
+ if (!active)
530
+ return;
531
+ root = mounted;
532
+ if (props !== currentProps)
533
+ mounted.setProps(currentProps);
534
+ publish();
535
+ return yield* Effect.never;
536
+ }).pipe(Effect.provide(Renderer.layer(modelHost(publish))), Effect.provideService(Html.Host, BrowserHost.htmlHost), Effect.provideService(MessageLog.MessageLog, messageLog))));
537
+ return {
538
+ send: (message) => {
539
+ root?.send(message);
540
+ publish();
541
+ },
542
+ setProps: (next) => {
543
+ currentProps = next;
544
+ root?.setProps(next);
545
+ },
546
+ dispose: () => {
547
+ active = false;
548
+ root = undefined;
549
+ Effect.runFork(Fiber.interrupt(fiber));
550
+ }
551
+ };
552
+ };
553
+
554
+ // ../../src/lib/effect-ui-adapter/use-model.ts
555
+ "use client";
556
+ var ModelMessageLogContext = createContext(undefined);
557
+ var useModel = (component, props, options = {}) => {
558
+ const contextLog = useContext(ModelMessageLogContext);
559
+ const messageLog = options.messageLog ?? (contextLog === undefined ? MessageLog2.noop : contextLog);
560
+ const [store] = useState2(() => {
561
+ const initial = { model: component.init(props).model };
562
+ let snapshot = initial;
563
+ const listeners = new Set;
564
+ return {
565
+ subscribe: (listener) => {
566
+ listeners.add(listener);
567
+ return () => {
568
+ listeners.delete(listener);
569
+ };
570
+ },
571
+ getSnapshot: () => snapshot,
572
+ getServerSnapshot: () => initial,
573
+ publish: (next) => {
574
+ if ("model" in snapshot && "model" in next && Object.is(snapshot.model, next.model))
575
+ return;
576
+ if ("error" in snapshot && "error" in next && snapshot.error === next.error)
577
+ return;
578
+ snapshot = next;
579
+ listeners.forEach((listener) => listener());
580
+ }
581
+ };
582
+ });
583
+ const snapshot = useSyncExternalStore2(store.subscribe, store.getSnapshot, store.getServerSnapshot);
584
+ const committed = useRef2(props);
585
+ const onEmit = useRef2(options.onEmit);
586
+ const runtime = useRef2(undefined);
587
+ const send = useCallback((message) => runtime.current?.send(message), []);
588
+ useLayoutEffect2(() => {
589
+ onEmit.current = options.onEmit;
590
+ committed.current = props;
591
+ runtime.current?.setProps(props);
592
+ }, [props, options.onEmit]);
593
+ useEffect2(() => {
594
+ if (messageLog === null)
595
+ return;
596
+ const mounted = mountModel(component, committed.current, store.publish, messageLog, (event) => onEmit.current?.(event));
597
+ runtime.current = mounted;
598
+ return () => {
599
+ runtime.current = undefined;
600
+ mounted.dispose();
601
+ };
602
+ }, [component, messageLog, store]);
603
+ if ("error" in snapshot)
604
+ throw snapshot.error;
605
+ return { model: snapshot.model, send };
606
+ };
607
+
608
+ // ../../src/components/animated-list/classes.ts
609
+ var animatedListClasses = {
610
+ list: "relative grid gap-3",
611
+ dragHandle: "text-muted-foreground focus-visible:ring-ring inline-flex size-8 shrink-0 cursor-grab touch-none items-center justify-center rounded-md outline-none select-none focus-visible:ring-2 active:cursor-grabbing disabled:cursor-default disabled:opacity-50"
612
+ };
613
+ var resolveAnimatedListClasses = (overrides) => ({
614
+ ...animatedListClasses,
615
+ ...overrides
616
+ });
617
+
618
+ // ../../src/components/animated-list/index.ts
619
+ import { Schema as Schema2, Stream } from "effect";
620
+ import { Component, Subscription, UiSchema } from "effect/ui";
621
+
622
+ // ../../src/components/animated-list/schema.ts
623
+ import { Predicate, Schema, Struct } from "effect";
624
+ var Position = Schema.declare((value) => Predicate.isFunction(value));
625
+ var MessageOverrides = Schema.Struct({
626
+ reorder: Schema.optional(Schema.String),
627
+ instructions: Schema.optional(Schema.String),
628
+ position: Schema.optional(Position)
629
+ });
630
+ var AnimatedListClassesOverridesSchema = Schema.Record(Schema.Literals(Struct.keys(animatedListClasses)), Schema.optionalKey(Schema.String)).annotate({ identifier: "AnimatedListClassesOverrides" });
631
+ var AnimatedListPropsSchema = Schema.Struct({
632
+ classes: Schema.optional(AnimatedListClassesOverridesSchema),
633
+ duration: Schema.optional(Schema.Number),
634
+ className: Schema.optional(Schema.String),
635
+ itemClassName: Schema.optional(Schema.String),
636
+ label: Schema.optional(Schema.String),
637
+ dragOverflow: Schema.optional(Schema.Number),
638
+ locale: Schema.optional(Schema.String),
639
+ messages: Schema.optional(Schema.Record(Schema.String, Schema.UndefinedOr(MessageOverrides)))
640
+ }).annotate({ identifier: "AnimatedListProps" });
641
+ var AnimatedListRow = Schema.Struct({
642
+ key: Schema.String,
643
+ label: Schema.optional(Schema.String)
644
+ }).annotate({ identifier: "AnimatedListRow" });
645
+ var AnimatedListModelProps = Schema.Struct({
646
+ ...AnimatedListPropsSchema.fields,
647
+ items: Schema.Array(AnimatedListRow),
648
+ reorderable: Schema.optional(Schema.Boolean)
649
+ }).annotate({ identifier: "AnimatedListModelProps" });
650
+
651
+ // ../../src/components/animated-list/index.ts
474
652
  var labels = {
475
653
  en: {
476
654
  reorder: "Reorder",
@@ -483,7 +661,107 @@ var labels = {
483
661
  position: (label, position, total) => `${label}, position ${position} sur ${total}.`
484
662
  }
485
663
  };
664
+ var animatedListCopy = (locale, messages) => ({
665
+ ...locale.startsWith("fr") ? labels.fr : labels.en,
666
+ ...messages?.[locale.split("-")[0] ?? locale],
667
+ ...messages?.[locale]
668
+ });
669
+ var reorderTarget = (key, index, total) => key === "Home" ? 0 : key === "End" ? total - 1 : key === "ArrowUp" ? Math.max(0, index - 1) : key === "ArrowDown" ? Math.min(total - 1, index + 1) : undefined;
670
+ var moveItem = (items, from, to) => {
671
+ if (from < 0 || from >= items.length || to < 0 || to >= items.length || from === to)
672
+ return;
673
+ const next = [...items];
674
+ next.splice(to, 0, ...next.splice(from, 1));
675
+ return next;
676
+ };
677
+ var retainedRows = (items, previous) => {
678
+ const keys = new Set(items.map((row) => row.key));
679
+ const next = [...items];
680
+ previous.forEach((row, index) => {
681
+ if (!keys.has(row.key))
682
+ next.splice(Math.min(index, next.length), 0, row);
683
+ });
684
+ return next;
685
+ };
686
+ var listAnnouncement = (items, key, copy) => {
687
+ const index = items.findIndex((row) => row.key === key);
688
+ const row = items[index];
689
+ return row ? copy.position(row.label ?? row.key, index + 1, items.length) : "";
690
+ };
691
+ var AnimatedListMessage = UiSchema.TaggedEnum({
692
+ Synced: {},
693
+ Exited: { key: Schema2.String },
694
+ Announced: { key: Schema2.String },
695
+ Moved: { key: Schema2.String, to: Schema2.Number }
696
+ });
697
+ var AnimatedListEvent = UiSchema.TaggedEnum({
698
+ Reordered: {
699
+ from: Schema2.Number,
700
+ to: Schema2.Number,
701
+ items: Schema2.Array(AnimatedListRow)
702
+ }
703
+ });
704
+ var animatedListOptions = {
705
+ name: "AnimatedList",
706
+ props: AnimatedListModelProps,
707
+ model: Schema2.Struct({
708
+ lastItems: Schema2.Array(AnimatedListRow),
709
+ rows: Schema2.Array(AnimatedListRow),
710
+ announcedKey: Schema2.NullOr(Schema2.String)
711
+ }).annotate({ identifier: "AnimatedListModel" }),
712
+ message: AnimatedListMessage,
713
+ restore: false
714
+ };
715
+ var Definition = Component.define(animatedListOptions);
716
+ var changed = Subscription.make("animated-list/changed", Stream.succeed(AnimatedListMessage.Synced()));
717
+ var listMove = (props, key, to) => {
718
+ const from = props.items.findIndex((row) => row.key === key);
719
+ const items = props.reorderable && moveItem(props.items, from, to);
720
+ return items ? { from, to, items } : undefined;
721
+ };
722
+ var updateAnimatedList = ({
723
+ model,
724
+ props
725
+ }, message) => {
726
+ switch (message._tag) {
727
+ case "Synced":
728
+ return {
729
+ ...model,
730
+ lastItems: props.items,
731
+ rows: retainedRows(props.items, model.rows)
732
+ };
733
+ case "Exited":
734
+ return props.items.some((row) => row.key === message.key) ? model : {
735
+ ...model,
736
+ rows: model.rows.filter((row) => row.key !== message.key)
737
+ };
738
+ case "Announced":
739
+ return { ...model, announcedKey: message.key };
740
+ case "Moved":
741
+ return listMove(props, message.key, message.to) ? { ...model, announcedKey: message.key } : model;
742
+ }
743
+ };
744
+ var update = Definition.update(updateAnimatedList);
745
+ var animatedListBehaviours = {
746
+ init: Definition.init(({ props }) => ({
747
+ lastItems: props.items,
748
+ rows: props.items,
749
+ announcedKey: null
750
+ })),
751
+ update,
752
+ subscriptions: Definition.subscriptions(({ model, props }) => [
753
+ (props.items.length !== model.lastItems.length || props.items.some(({ key, label }, index) => model.lastItems[index]?.key !== key || model.lastItems[index]?.label !== label)) && changed
754
+ ])
755
+ };
756
+
757
+ // ../../src/components/animated-list/react.tsx
758
+ import { jsx as jsx5, jsxs as jsxs2, Fragment } from "react/jsx-runtime";
759
+ var Model = Component2.define(animatedListOptions).make({
760
+ ...animatedListBehaviours,
761
+ view: () => View2.text("")
762
+ });
486
763
  var AnimatedList = ({
764
+ classes: classOverrides,
487
765
  items,
488
766
  getKey,
489
767
  children,
@@ -497,30 +775,45 @@ var AnimatedList = ({
497
775
  locale: override,
498
776
  messages
499
777
  }) => {
778
+ const animatedListClasses = resolveAnimatedListClasses(classOverrides);
500
779
  const locale = useKrakstackLocale(override);
501
- const copy = {
502
- ...locale.startsWith("fr") ? labels.fr : labels.en,
503
- ...messages?.[locale.split("-")[0] ?? locale],
504
- ...messages?.[locale]
505
- };
780
+ const copy = animatedListCopy(locale, messages);
506
781
  const instructions = useId();
507
- const container = useRef2(null);
508
- const [announcedKey, setAnnouncedKey] = useState2(null);
509
- const retained = useKeyedPresence(items, getKey);
510
- const [initial, setInitial] = useState2(true);
511
- useEffect2(() => setInitial(false), []);
782
+ const container = useRef3(null);
783
+ const descriptors = items.map((item) => ({
784
+ key: getKey(item),
785
+ label: getItemLabel?.(item)
786
+ }));
787
+ const { model, send } = useModel(Model, {
788
+ items: descriptors,
789
+ reorderable: !!onReorder
790
+ });
791
+ const retained = retainedRows(descriptors, model.rows);
792
+ const current = new Map(items.map((item) => [getKey(item), { item }]));
793
+ const [previous, setPrevious] = useState3(() => ({
794
+ items,
795
+ rows: model.rows,
796
+ rendered: current
797
+ }));
798
+ const rendered = new Map(retained.flatMap(({ key }) => {
799
+ const value = current.get(key) ?? previous.rendered.get(key);
800
+ return value ? [[key, value]] : [];
801
+ }));
802
+ if (previous.items !== items || previous.rows !== model.rows) {
803
+ setPrevious({ items, rows: model.rows, rendered });
804
+ }
805
+ const committed = useRef3(false);
806
+ useEffect3(() => {
807
+ committed.current = true;
808
+ }, []);
512
809
  useListLayout(container, duration);
513
- const announcement = items.map((item, index) => getKey(item) === announcedKey ? copy.position(getItemLabel?.(item) ?? getKey(item), index + 1, items.length) : "").join("");
810
+ const announcement = listAnnouncement(descriptors, model.announcedKey, copy);
514
811
  const move = (key, target) => {
515
812
  const index = items.findIndex((item) => getKey(item) === key);
516
- if (index < 0 || index === target || !onReorder)
517
- return;
518
- const next = [...items];
519
- const [item] = next.splice(index, 1);
520
- if (item === undefined)
813
+ const next = onReorder && moveItem(items, index, target);
814
+ if (!next || !onReorder)
521
815
  return;
522
- next.splice(target, 0, item);
523
- setAnnouncedKey(key);
816
+ send(AnimatedListMessage.Announced({ key }));
524
817
  onReorder(next);
525
818
  };
526
819
  return /* @__PURE__ */ jsxs2(Fragment, {
@@ -528,27 +821,30 @@ var AnimatedList = ({
528
821
  /* @__PURE__ */ jsx5("ul", {
529
822
  ref: container,
530
823
  "data-slot": "animated-list",
531
- className: cn2("relative grid gap-3", className),
824
+ className: cn2(animatedListClasses.list, className),
532
825
  "aria-label": label,
533
- children: retained.items.map((item) => {
534
- const key = getKey(item);
826
+ children: retained.map(({ key, label }) => {
827
+ const value = rendered.get(key);
828
+ if (!value)
829
+ return null;
535
830
  const index = items.findIndex((candidate) => getKey(candidate) === key);
536
831
  return /* @__PURE__ */ jsx5(ListItem, {
537
832
  itemKey: key,
538
- present: retained.present.has(key),
539
- initial,
833
+ present: current.has(key),
834
+ committed,
540
835
  duration,
541
836
  className: itemClassName,
837
+ handleClassName: animatedListClasses.dragHandle,
542
838
  instructions,
543
- handleLabel: `${copy.reorder}: ${getItemLabel?.(item) ?? key}`,
839
+ handleLabel: `${copy.reorder}: ${label ?? key}`,
544
840
  reorderable: !!onReorder,
545
841
  disabled: items.length < 2,
546
842
  container,
547
843
  dragOverflow,
548
- onExit: () => retained.remove(key),
844
+ onExit: () => send(AnimatedListMessage.Exited({ key })),
549
845
  onMove: (target) => move(key, target),
550
- onKeyMove: (direction) => move(key, direction === "Home" ? 0 : direction === "End" ? items.length - 1 : Math.max(0, Math.min(items.length - 1, index + (direction === "ArrowUp" ? -1 : 1)))),
551
- children: children(item)
846
+ onKeyMove: (direction) => move(key, reorderTarget(direction, index, items.length) ?? index),
847
+ children: children(value.item)
552
848
  }, key);
553
849
  })
554
850
  }),
@@ -574,11 +870,12 @@ var AnimatedList = ({
574
870
  var ListItem = ({
575
871
  itemKey,
576
872
  present,
577
- initial,
873
+ committed,
578
874
  duration,
579
875
  className,
580
876
  instructions,
581
877
  handleLabel,
878
+ handleClassName,
582
879
  reorderable,
583
880
  disabled,
584
881
  container,
@@ -588,10 +885,10 @@ var ListItem = ({
588
885
  onKeyMove,
589
886
  children
590
887
  }) => {
591
- const ref = useRef2(null);
592
- const mounted = useRef2(false);
593
- const lastPresent = useRef2(present);
594
- const transitioning = useRef2(false);
888
+ const ref = useRef3(null);
889
+ const mounted = useRef3(false);
890
+ const lastPresent = useRef3(present);
891
+ const transitioning = useRef3(false);
595
892
  const exit = useEffectEvent2(onExit);
596
893
  const reduced = useReducedMotion();
597
894
  const drag = useVerticalDrag({
@@ -601,11 +898,11 @@ var ListItem = ({
601
898
  overflow: dragOverflow,
602
899
  onMove
603
900
  });
604
- useEffect2(() => {
901
+ useEffect3(() => {
605
902
  const element = ref.current;
606
903
  const first = !mounted.current;
607
904
  mounted.current = true;
608
- if (!element || first && initial && present)
905
+ if (!element || first && !committed.current && present)
609
906
  return;
610
907
  if (!first && lastPresent.current === present && !transitioning.current)
611
908
  return;
@@ -616,7 +913,7 @@ var ListItem = ({
616
913
  if (!present)
617
914
  exit();
618
915
  });
619
- }, [present, initial, duration, reduced]);
916
+ }, [present, committed, duration, reduced]);
620
917
  return /* @__PURE__ */ jsxs2("li", {
621
918
  ref,
622
919
  "data-slot": "animated-list-item",
@@ -631,7 +928,7 @@ var ListItem = ({
631
928
  disabled: disabled || !present,
632
929
  "aria-label": handleLabel,
633
930
  "aria-describedby": instructions,
634
- className: "text-muted-foreground focus-visible:ring-ring inline-flex size-8 shrink-0 cursor-grab touch-none items-center justify-center rounded-md outline-none select-none focus-visible:ring-2 active:cursor-grabbing disabled:cursor-default disabled:opacity-50",
931
+ className: handleClassName,
635
932
  ...drag,
636
933
  onKeyDown: (event) => {
637
934
  if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey)
@@ -651,15 +948,16 @@ var ListItem = ({
651
948
  ]
652
949
  });
653
950
  };
654
-
655
- // ../../src/components/ui/rich-text-editor.tsx
656
- import { Schema as Schema4 } from "effect";
951
+ // ../../src/lib/email-document/legacy-rich-text/editor.tsx
952
+ import { Option as Option2, Schema as Schema6 } from "effect";
953
+ import { EditorContent, useEditor } from "@tiptap/react";
954
+ import { EditorState } from "@tiptap/pm/state";
955
+ import { closeHistory } from "@tiptap/pm/history";
657
956
  import {
658
- useEffect as useEffect3,
957
+ useEffect as useEffect4,
659
958
  useEffectEvent as useEffectEvent3,
660
959
  useId as useId2,
661
- useRef as useRef3,
662
- useState as useState3
960
+ useState as useState4
663
961
  } from "react";
664
962
  import {
665
963
  Bold,
@@ -727,62 +1025,64 @@ function DropdownMenuItem({
727
1025
  });
728
1026
  }
729
1027
 
730
- // ../../src/components/ui/rich-text-editor.tsx
731
- import { useKrakstackLocale as useKrakstackLocale2 } from "@krak-stack/registry/krakstack-provider";
1028
+ // ../../src/lib/email-document/legacy-rich-text/editor.tsx
1029
+ import { useKrakstackLocale as useKrakstackLocale2 } from "@krak-stack/registry/krakstack-provider/react";
732
1030
 
733
- // ../../src/lib/rich-text/schema.ts
734
- import { Schema } from "effect";
735
- var RichTextLink = Schema.String.check(Schema.isMaxLength(2000), Schema.makeFilter((value) => {
1031
+ // ../../src/lib/email-document/legacy-rich-text/schema.ts
1032
+ import { Schema as Schema3 } from "effect";
1033
+ var RichTextLink = Schema3.String.check(Schema3.isMaxLength(2000), Schema3.makeFilter((value) => {
736
1034
  if (/[\s\p{Cc}\\{}]/u.test(value))
737
1035
  return false;
738
1036
  const url = URL.parse(value);
739
1037
  return url !== null && ["https:", "mailto:"].includes(url.protocol) && !url.username && !url.password;
740
1038
  })).annotate({ identifier: "RichTextLink" });
741
- var RichTextMarks = Schema.Struct({
742
- bold: Schema.optional(Schema.Boolean),
743
- italic: Schema.optional(Schema.Boolean),
744
- underline: Schema.optional(Schema.Boolean),
745
- href: Schema.optional(RichTextLink)
1039
+ var RichTextMarks = Schema3.Struct({
1040
+ bold: Schema3.optional(Schema3.Boolean),
1041
+ italic: Schema3.optional(Schema3.Boolean),
1042
+ underline: Schema3.optional(Schema3.Boolean),
1043
+ href: Schema3.optional(RichTextLink)
746
1044
  }).annotate({ identifier: "RichTextMarks" });
747
- var RichTextInline = Schema.Union([
748
- Schema.Struct({
749
- type: Schema.Literal("text"),
750
- text: Schema.String.check(Schema.isMaxLength(20000)),
751
- marks: Schema.optional(RichTextMarks)
1045
+ var RichTextInline = Schema3.Union([
1046
+ Schema3.Struct({
1047
+ type: Schema3.Literal("text"),
1048
+ text: Schema3.String.check(Schema3.isMaxLength(20000)),
1049
+ marks: Schema3.optional(RichTextMarks)
752
1050
  }),
753
- Schema.Struct({
754
- type: Schema.Literal("variable"),
755
- key: Schema.String.check(Schema.isPattern(/^[a-zA-Z][a-zA-Z0-9_.]{0,79}$/)),
756
- marks: Schema.optional(RichTextMarks)
1051
+ Schema3.Struct({
1052
+ type: Schema3.Literal("variable"),
1053
+ key: Schema3.String.check(Schema3.isPattern(/^[a-zA-Z][a-zA-Z0-9_.]{0,79}$/)),
1054
+ marks: Schema3.optional(RichTextMarks)
757
1055
  })
758
1056
  ]).annotate({ identifier: "RichTextInline" });
759
- var RichTextBlockKind = Schema.Literals([
1057
+ var RichTextBlockKind = Schema3.Literals([
760
1058
  "paragraph",
761
1059
  "heading",
762
1060
  "bullet",
763
1061
  "numbered"
764
1062
  ]).annotate({ identifier: "RichTextBlockKind" });
765
- var RichTextDocument = Schema.Struct({
766
- version: Schema.Literal(1),
767
- blocks: Schema.Array(Schema.Struct({
1063
+ var RichTextDocument = Schema3.Struct({
1064
+ version: Schema3.Literal(1),
1065
+ blocks: Schema3.Array(Schema3.Struct({
768
1066
  type: RichTextBlockKind,
769
- content: Schema.Array(RichTextInline).check(Schema.isMaxLength(2000))
770
- })).check(Schema.isMinLength(1), Schema.isMaxLength(100))
771
- }).check(Schema.makeFilter((value) => value.blocks.reduce((size, block) => size + block.content.reduce((count, inline) => count + (inline.type === "text" ? inline.text.length : 1), 0), 0) <= 20000)).annotate({ identifier: "RichTextDocument" });
772
- var RichTextVariable = Schema.Struct({
773
- key: Schema.String.check(Schema.isPattern(/^[a-zA-Z][a-zA-Z0-9_.]{0,79}$/)),
774
- label: Schema.String,
775
- type: Schema.Literals(["text", "url"]),
776
- sample: Schema.String
1067
+ content: Schema3.Array(RichTextInline).check(Schema3.isMaxLength(2000))
1068
+ })).check(Schema3.isMinLength(1), Schema3.isMaxLength(100))
1069
+ }).check(Schema3.makeFilter((value) => value.blocks.reduce((size, block) => size + block.content.reduce((count, inline) => count + (inline.type === "text" ? inline.text.length : 1), 0), 0) <= 20000)).annotate({ identifier: "RichTextDocument" });
1070
+ var RichTextVariable = Schema3.Struct({
1071
+ key: Schema3.String.check(Schema3.isPattern(/^[a-zA-Z][a-zA-Z0-9_.]{0,79}$/)),
1072
+ label: Schema3.String,
1073
+ type: Schema3.Literals(["text", "url"]),
1074
+ sample: Schema3.String
777
1075
  }).annotate({ identifier: "RichTextVariable" });
778
1076
 
779
- // ../../src/lib/rich-text/model.ts
780
- import { Schema as Schema2 } from "effect";
781
- var sameMarks = Schema2.toEquivalence(RichTextMarks);
782
- var emptyRichText = () => ({
783
- version: 1,
784
- blocks: [{ type: "paragraph", content: [] }]
785
- });
1077
+ // ../../src/lib/email-document/legacy-rich-text/tiptap.ts
1078
+ import { Extension, Node } from "@tiptap/core";
1079
+ import { Plugin } from "@tiptap/pm/state";
1080
+ import StarterKit from "@tiptap/starter-kit";
1081
+ import { Option, Schema as Schema5 } from "effect";
1082
+
1083
+ // ../../src/lib/email-document/legacy-rich-text/model.ts
1084
+ import { Schema as Schema4 } from "effect";
1085
+ var sameMarks = Schema4.toEquivalence(RichTextMarks);
786
1086
  var richTextFromString = (text) => ({
787
1087
  version: 1,
788
1088
  blocks: text.split(/\r\n?|\n/).map((line) => ({
@@ -792,223 +1092,174 @@ var richTextFromString = (text) => ({
792
1092
  });
793
1093
  var richTextPlainText = (value, variables) => value.blocks.map((block) => block.content.map((inline) => inline.type === "text" ? inline.text : variables?.[inline.key] ?? `{{${inline.key}}}`).join("")).join(`
794
1094
  `);
795
- var units = (value) => value.blocks.flatMap((block, index) => [
796
- ...index ? [{ type: "break", next: block.type }] : [],
797
- ...block.content.flatMap((inline) => inline.type === "text" ? inline.text.split("").map((text) => ({ ...inline, text })) : [inline])
798
- ]);
799
- var fromUnits = (content, first) => {
800
- const blocks = [{ type: first, content: [] }];
801
- for (const unit of content) {
802
- if (unit.type === "break") {
803
- blocks.push({ type: unit.next, content: [] });
804
- continue;
805
- }
806
- const target = blocks.at(-1);
807
- if (!target)
808
- continue;
809
- const previous = target.content.at(-1);
810
- if (unit.type === "text" && previous?.type === "text" && sameMarks(previous.marks ?? {}, unit.marks ?? {})) {
811
- target.content[target.content.length - 1] = {
812
- ...previous,
813
- text: previous.text + unit.text
814
- };
815
- } else
816
- target.content.push(unit);
817
- }
818
- return { version: 1, blocks };
819
- };
820
- var replaceRichText = (value, selection, inserted) => {
821
- const content = units(value);
822
- const from = Math.max(0, Math.min(selection.from, content.length));
823
- const to = Math.max(from, Math.min(selection.to, content.length));
824
- const additions = inserted.type === "text" ? inserted.text.replace(/\r\n?/g, `
825
- `).split("").map((text) => text === `
826
- ` ? { type: "break", next: "paragraph" } : { type: "text", text, marks: inserted.marks }) : [inserted];
827
- const next = fromUnits([...content.slice(0, from), ...additions, ...content.slice(to)], value.blocks[0]?.type ?? "paragraph");
828
- const position = from + additions.length;
829
- return { value: next, selection: { from: position, to: position } };
830
- };
831
- var formatRichText = (value, selection, mark, setting) => fromUnits(units(value).map((unit, index) => {
832
- if (unit.type === "break" || index < selection.from || index >= selection.to)
833
- return unit;
834
- const marks = { ...unit.marks, [mark]: setting };
835
- return { ...unit, marks };
836
- }), value.blocks[0]?.type ?? "paragraph");
837
- var setRichTextBlock = (value, selection, type) => {
838
- let offset = 0;
839
- return {
840
- ...value,
841
- blocks: value.blocks.map((block) => {
842
- const start = offset;
843
- offset += block.content.reduce((size, inline) => size + (inline.type === "text" ? inline.text.length : 1), 0) + 1;
844
- return selection.from < offset && selection.to >= start ? { ...block, type } : block;
845
- })
846
- };
847
- };
848
- var richTextMarksAt = (value, position) => {
849
- const content = units(value);
850
- const unit = content[Math.max(0, position - 1)];
851
- return unit && unit.type !== "break" ? unit.marks ?? {} : {};
852
- };
853
1095
 
854
- // ../../src/lib/rich-text/dom.ts
855
- import { Option, Schema as Schema3 } from "effect";
856
- var blocks = new Set(["P", "DIV", "H1", "H2", "H3", "LI"]);
857
- var sameMarks2 = Schema3.toEquivalence(RichTextMarks);
858
- var pointAfter = (node) => ({
859
- node: node.parentNode ?? node,
860
- offset: Array.from(node.parentNode?.childNodes ?? []).indexOf(node) + 1
861
- });
862
- var readRichTextDOM = (root) => {
863
- const result = [];
864
- const points = [{ node: root, offset: 0 }];
865
- let current;
866
- const begin = (type, point) => {
867
- if (current)
868
- result.push(current);
869
- if (result.length)
870
- points.push(point);
871
- else
872
- points[0] = point;
873
- current = { type, content: [] };
874
- };
875
- const append = (inline, point) => {
876
- if (!current)
877
- begin("paragraph", point);
878
- const previous = current?.content.at(-1);
879
- if (inline.type === "text" && previous?.type === "text" && sameMarks2(inline.marks ?? {}, previous.marks ?? {})) {
880
- if (current)
881
- current.content[current.content.length - 1] = {
882
- ...previous,
883
- text: previous.text + inline.text
884
- };
885
- } else
886
- current?.content.push(inline);
887
- points.push(point);
888
- };
889
- const visit = (node, inherited = {}, kind = "paragraph") => {
890
- if (node instanceof Text) {
891
- if (!current)
892
- begin(kind, { node, offset: 0 });
893
- for (let index = 0;index < node.data.length; index++)
894
- append({ type: "text", text: node.data[index] ?? "", marks: inherited }, { node, offset: index + 1 });
895
- return;
896
- }
897
- if (!(node instanceof HTMLElement) || ["SCRIPT", "STYLE", "IFRAME"].includes(node.tagName))
898
- return;
899
- const key = node.dataset.richVariable;
900
- if (key) {
901
- const variable = { type: "variable", key, marks: inherited };
902
- append(variable, pointAfter(node));
903
- return;
904
- }
905
- const href = node.getAttribute("href");
906
- const marks = {
907
- bold: inherited.bold,
908
- italic: inherited.italic,
909
- underline: inherited.underline,
910
- href: inherited.href
911
- };
912
- if (["B", "STRONG"].includes(node.tagName) || node.style.fontWeight === "700")
913
- marks.bold = true;
914
- if (["I", "EM"].includes(node.tagName) || node.style.fontStyle === "italic")
915
- marks.italic = true;
916
- if (node.tagName === "U" || node.style.textDecoration.includes("underline"))
917
- marks.underline = true;
918
- if (href && Schema3.is(RichTextLink)(href))
919
- marks.href = href;
920
- const type = node.dataset.richKind === "bullet" ? "bullet" : node.dataset.richKind === "numbered" ? "numbered" : /^H[123]$/.test(node.tagName) ? "heading" : node.tagName === "LI" ? node.parentElement?.tagName === "OL" ? "numbered" : "bullet" : kind;
921
- const isBlock = blocks.has(node.tagName);
922
- const container = isBlock && [...node.children].some((child) => blocks.has(child.tagName));
923
- if (isBlock && !container)
924
- begin(type, { node, offset: 0 });
925
- if (node.tagName === "BR") {
926
- if (node.nextSibling)
927
- begin(kind, pointAfter(node));
928
- return;
1096
+ // ../../src/lib/email-document/legacy-rich-text/tiptap.ts
1097
+ var toTiptapDocument = (value, singleLine = false) => {
1098
+ const blocks = singleLine ? [
1099
+ {
1100
+ type: "paragraph",
1101
+ content: value.blocks.flatMap((block, index) => [
1102
+ ...index ? [{ type: "text", text: " " }] : [],
1103
+ ...block.content.map((inline) => inline.type === "text" ? { type: "text", text: inline.text.replace(/[\r\n]+/g, " ") } : { type: "variable", key: inline.key })
1104
+ ])
929
1105
  }
930
- for (const child of node.childNodes)
931
- visit(child, marks, type);
1106
+ ] : value.blocks;
1107
+ return {
1108
+ type: "doc",
1109
+ content: blocks.map((block) => ({
1110
+ type: "paragraph",
1111
+ attrs: { kind: block.type },
1112
+ content: block.content.filter((inline) => inline.type !== "text" || inline.text.length > 0).map((inline) => {
1113
+ const marks = [];
1114
+ if (inline.marks?.bold)
1115
+ marks.push({ type: "bold" });
1116
+ if (inline.marks?.italic)
1117
+ marks.push({ type: "italic" });
1118
+ if (inline.marks?.underline)
1119
+ marks.push({ type: "underline" });
1120
+ if (inline.marks?.href)
1121
+ marks.push({ type: "link", attrs: { href: inline.marks.href } });
1122
+ return inline.type === "text" ? { type: "text", text: inline.text, marks } : { type: "variable", attrs: { key: inline.key }, marks };
1123
+ })
1124
+ }))
932
1125
  };
933
- for (const child of root.childNodes)
934
- visit(child);
935
- if (current)
936
- result.push(current);
937
- const value = Option.getOrUndefined(Schema3.decodeOption(RichTextDocument)({
938
- version: 1,
939
- blocks: result.length ? result : emptyRichText().blocks
940
- }));
941
- return { value, points };
942
1126
  };
943
- var readEditorSelection = (root, points) => {
944
- const selection = root.ownerDocument.getSelection();
945
- if (!selection?.anchorNode || !selection.focusNode || !root.contains(selection.anchorNode) || !root.contains(selection.focusNode))
946
- return;
947
- const position = (node, offset) => {
948
- const range = root.ownerDocument.createRange();
949
- range.setStart(node, offset);
950
- range.collapse(true);
951
- let result = 0;
952
- points.forEach((point, index) => {
953
- if (root.contains(point.node) && range.comparePoint(point.node, point.offset) <= 0)
954
- result = index;
1127
+ var fromTiptapDocument = (doc) => {
1128
+ const blocks = [];
1129
+ doc.forEach((block) => {
1130
+ const content = [];
1131
+ block.forEach((inline) => {
1132
+ let marks = {};
1133
+ for (const mark of inline.marks) {
1134
+ if (mark.type.name === "bold")
1135
+ marks = { ...marks, bold: true };
1136
+ if (mark.type.name === "italic")
1137
+ marks = { ...marks, italic: true };
1138
+ if (mark.type.name === "underline")
1139
+ marks = { ...marks, underline: true };
1140
+ if (mark.type.name === "link")
1141
+ marks = { ...marks, href: mark.attrs.href };
1142
+ }
1143
+ const value = inline.isText ? { type: "text", text: inline.text } : { type: inline.type.name, key: inline.attrs.key };
1144
+ content.push(Object.keys(marks).length ? { ...value, marks } : value);
955
1145
  });
956
- return result;
957
- };
958
- const anchor = position(selection.anchorNode, selection.anchorOffset);
959
- const focus = position(selection.focusNode, selection.focusOffset);
960
- return { from: Math.min(anchor, focus), to: Math.max(anchor, focus) };
1146
+ blocks.push({ type: block.attrs.kind, content });
1147
+ });
1148
+ return Schema5.decodeUnknownOption(RichTextDocument)({ version: 1, blocks });
961
1149
  };
962
- var restoreRichTextSelection = (root, selection) => {
963
- const { points } = readRichTextDOM(root);
964
- const start = points[Math.min(selection.from, points.length - 1)];
965
- const end = points[Math.min(selection.to, points.length - 1)];
966
- if (!start || !end)
1150
+ var SingleLineDocument = RichTextDocument.check(Schema5.makeFilter((value) => value.blocks.length === 1 && value.blocks.every((block) => block.type === "paragraph" && block.content.every((inline) => !inline.marks && (inline.type !== "text" || !/[\r\n]/.test(inline.text)))))).annotate({ identifier: "SingleLineRichTextDocument" });
1151
+ var richTextExtensions = ({
1152
+ singleLine = false,
1153
+ maxLength = () => {
967
1154
  return;
968
- const range = root.ownerDocument.createRange();
969
- range.setStart(start.node, start.offset);
970
- range.setEnd(end.node, end.offset);
971
- root.ownerDocument.getSelection()?.removeAllRanges();
972
- root.ownerDocument.getSelection()?.addRange(range);
973
- };
974
- var writeRichTextDOM = (root, value, variables) => {
975
- const children = value.blocks.map((block) => {
976
- const paragraph = root.ownerDocument.createElement(block.type === "heading" ? "h2" : "div");
977
- if (block.type === "heading")
978
- paragraph.style.cssText = "font-size:1.4em;font-weight:700";
979
- if (block.type === "bullet" || block.type === "numbered") {
980
- paragraph.dataset.richKind = block.type;
981
- paragraph.style.cssText = `display:list-item;margin-left:1.5em;list-style-type:${block.type === "bullet" ? "disc" : "decimal"}`;
1155
+ },
1156
+ variables = () => [],
1157
+ onInvalid = () => {}
1158
+ } = {}) => [
1159
+ StarterKit.configure({
1160
+ blockquote: false,
1161
+ bulletList: false,
1162
+ code: false,
1163
+ codeBlock: false,
1164
+ dropcursor: false,
1165
+ gapcursor: false,
1166
+ hardBreak: false,
1167
+ heading: false,
1168
+ horizontalRule: false,
1169
+ listItem: false,
1170
+ listKeymap: false,
1171
+ orderedList: false,
1172
+ paragraph: false,
1173
+ strike: false,
1174
+ trailingNode: false,
1175
+ bold: singleLine ? false : {},
1176
+ italic: singleLine ? false : {},
1177
+ underline: singleLine ? false : {},
1178
+ link: singleLine ? false : {
1179
+ openOnClick: false,
1180
+ autolink: false,
1181
+ linkOnPaste: false,
1182
+ isAllowedUri: (url) => Schema5.is(RichTextLink)(url),
1183
+ HTMLAttributes: { class: "underline" }
1184
+ },
1185
+ undoRedo: { depth: 100 }
1186
+ }),
1187
+ Node.create({
1188
+ name: "paragraph",
1189
+ group: "block",
1190
+ content: "inline*",
1191
+ marks: singleLine ? "" : "_",
1192
+ addAttributes: () => ({ kind: { default: "paragraph" } }),
1193
+ parseHTML: () => [{ tag: "p" }],
1194
+ renderHTML: ({ node }) => {
1195
+ const kind = Schema5.decodeUnknownSync(RichTextBlockKind)(node.attrs.kind);
1196
+ if (kind === "heading")
1197
+ return ["h2", { class: "text-xl font-semibold" }, 0];
1198
+ return [
1199
+ "div",
1200
+ {
1201
+ "data-rich-kind": kind,
1202
+ style: kind === "bullet" || kind === "numbered" ? `display:list-item;margin-left:1.5em;list-style-type:${kind === "bullet" ? "disc" : "decimal"}` : null
1203
+ },
1204
+ 0
1205
+ ];
1206
+ },
1207
+ addKeyboardShortcuts() {
1208
+ return {
1209
+ Enter: () => {
1210
+ if (singleLine)
1211
+ return true;
1212
+ const { $from } = this.editor.state.selection;
1213
+ if (!$from.parent.content.size && $from.parent.attrs.kind !== "paragraph")
1214
+ return this.editor.commands.updateAttributes("paragraph", {
1215
+ kind: "paragraph"
1216
+ });
1217
+ return this.editor.commands.splitBlock();
1218
+ },
1219
+ "Shift-Enter": () => singleLine || this.editor.commands.splitBlock()
1220
+ };
982
1221
  }
983
- for (const inline of block.content) {
984
- const span = root.ownerDocument.createElement(inline.marks?.href ? "a" : "span");
985
- if (inline.type === "variable") {
986
- span.dataset.richVariable = inline.key;
987
- span.contentEditable = "false";
988
- span.textContent = `{{${variables.find((item) => item.key === inline.key)?.label ?? inline.key}}}`;
989
- span.className = "mx-0.5 inline-block rounded bg-indigo-50 px-1 font-mono text-[0.85em] text-indigo-800";
990
- } else
991
- span.textContent = inline.text;
992
- if (inline.marks?.bold)
993
- span.style.fontWeight = "700";
994
- if (inline.marks?.italic)
995
- span.style.fontStyle = "italic";
996
- if (inline.marks?.underline)
997
- span.style.textDecoration = "underline";
998
- if (inline.marks?.href) {
999
- span.setAttribute("href", inline.marks.href);
1000
- span.style.textDecoration = "underline";
1001
- }
1002
- paragraph.append(span);
1222
+ }),
1223
+ Node.create({
1224
+ name: "variable",
1225
+ group: "inline",
1226
+ inline: true,
1227
+ atom: true,
1228
+ selectable: true,
1229
+ addAttributes: () => ({ key: { default: null } }),
1230
+ renderText: ({ node }) => `{{${node.attrs.key}}}`,
1231
+ renderHTML: ({ node }) => {
1232
+ const key = Schema5.decodeUnknownSync(Schema5.String)(node.attrs.key);
1233
+ return [
1234
+ "span",
1235
+ {
1236
+ "data-rich-variable": key,
1237
+ contenteditable: "false",
1238
+ class: "inline-block rounded bg-indigo-50 px-1.5 font-mono text-[0.85em] text-indigo-800 select-all"
1239
+ },
1240
+ `{{${variables().find((variable) => variable.key === key)?.label ?? key}}}`
1241
+ ];
1003
1242
  }
1004
- if (!block.content.length)
1005
- paragraph.append(root.ownerDocument.createElement("br"));
1006
- return paragraph;
1007
- });
1008
- root.replaceChildren(...children);
1009
- };
1243
+ }),
1244
+ Extension.create({
1245
+ name: "richTextValidation",
1246
+ addProseMirrorPlugins: () => [
1247
+ new Plugin({
1248
+ filterTransaction: (transaction) => {
1249
+ if (!transaction.docChanged)
1250
+ return true;
1251
+ const decoded = fromTiptapDocument(transaction.doc);
1252
+ const limit = maxLength();
1253
+ const valid = Option.isSome(decoded) && (!singleLine || Schema5.is(SingleLineDocument)(decoded.value)) && (limit === undefined || richTextPlainText(decoded.value).length <= limit);
1254
+ onInvalid?.(!valid);
1255
+ return valid;
1256
+ }
1257
+ })
1258
+ ]
1259
+ })
1260
+ ];
1010
1261
 
1011
- // ../../src/components/ui/rich-text-editor.tsx
1262
+ // ../../src/lib/email-document/legacy-rich-text/editor.tsx
1012
1263
  import { jsx as jsx7, jsxs as jsxs4, Fragment as Fragment2 } from "react/jsx-runtime";
1013
1264
  var labels2 = {
1014
1265
  en: {
@@ -1052,7 +1303,7 @@ var labels2 = {
1052
1303
  cancel: "Annuler"
1053
1304
  }
1054
1305
  };
1055
- var equivalent = Schema4.toEquivalence(RichTextDocument);
1306
+ var externalReplacementMeta = "krakstackExternalReplacement";
1056
1307
  var ToolButton = ({
1057
1308
  label,
1058
1309
  children,
@@ -1142,203 +1393,132 @@ var RichTextEditor = ({
1142
1393
  ...messages?.[locale.split("-")[0] ?? locale],
1143
1394
  ...messages?.[locale]
1144
1395
  };
1145
- const root = useRef3(null);
1146
- const model = useRef3(value);
1147
- const composing = useRef3(false);
1148
- const selected = useRef3({ from: 0, to: 0 });
1149
- const history = useRef3([
1150
- { value, selection: { from: 0, to: 0 } }
1151
- ]);
1152
- const cursor = useRef3(0);
1153
- const [marks, setMarks] = useState3({});
1154
- const pendingMarks = useRef3(null);
1155
- const [error, setError] = useState3(false);
1156
- const [linkOpen, setLinkOpen] = useState3(false);
1157
- const [link, setLink] = useState3("");
1158
- const [linkError, setLinkError] = useState3(false);
1159
- const [revision, setRevision] = useState3(0);
1160
- const [historyState, setHistoryState] = useState3({
1161
- undo: false,
1162
- redo: false
1163
- });
1396
+ const [error, setError] = useState4(false);
1397
+ const [linkOpen, setLinkOpen] = useState4(false);
1398
+ const [link, setLink] = useState4("");
1399
+ const [linkError, setLinkError] = useState4(false);
1400
+ const [revision, setRevision] = useState4(0);
1164
1401
  const id = useId2();
1165
- const [initial] = useState3(() => /* @__PURE__ */ jsx7(RichTextContent, {
1166
- value,
1167
- variables
1168
- }));
1169
- const selection = () => {
1170
- const element = root.current;
1171
- if (!element)
1172
- return selected.current;
1173
- const next = readEditorSelection(element, readRichTextDOM(element).points);
1174
- if (next)
1175
- selected.current = next;
1176
- return selected.current;
1402
+ const getMaxLength = useEffectEvent3(() => maxLength);
1403
+ const getVariables = useEffectEvent3(() => variables);
1404
+ const editor = useEditor({
1405
+ immediatelyRender: false,
1406
+ extensions: richTextExtensions({
1407
+ singleLine,
1408
+ maxLength: () => getMaxLength(),
1409
+ variables: () => getVariables(),
1410
+ onInvalid: setError
1411
+ }),
1412
+ content: toTiptapDocument(value, singleLine),
1413
+ editable: !disabled,
1414
+ onTransaction: ({ transaction }) => {
1415
+ const replacement = transaction.getMeta(externalReplacementMeta) === true;
1416
+ if (replacement) {
1417
+ setError(false);
1418
+ setLinkOpen(false);
1419
+ }
1420
+ if (replacement || transaction.docChanged || transaction.selectionSet || transaction.storedMarksSet)
1421
+ setRevision((current) => current + 1);
1422
+ },
1423
+ onUpdate: ({ editor }) => {
1424
+ const next = fromTiptapDocument(editor.state.doc);
1425
+ if (Option2.isSome(next)) {
1426
+ onChange(next.value);
1427
+ }
1428
+ },
1429
+ editorProps: {
1430
+ attributes: {
1431
+ role: "textbox",
1432
+ "aria-label": label,
1433
+ "aria-multiline": String(!singleLine),
1434
+ "aria-disabled": String(!!disabled),
1435
+ "aria-describedby": error ? `${id}-error` : "",
1436
+ class: `focus-visible:ring-ring ${singleLine ? "min-h-10" : "min-h-32"} px-4 py-3 ${contentStyle?.fontSize === undefined ? "text-sm" : ""} ${contentStyle?.lineHeight === undefined ? "leading-relaxed" : ""} outline-none focus-visible:ring-2 focus-visible:ring-inset [&>div]:min-h-[1.5em]`
1437
+ },
1438
+ handlePaste: (view, event) => {
1439
+ event.preventDefault();
1440
+ if (disabled)
1441
+ return true;
1442
+ const text = event.clipboardData?.getData("text/plain") ?? "";
1443
+ const lines = (singleLine ? text.replace(/[\r\n]+/g, " ") : text.replace(/\r\n?/g, `
1444
+ `)).split(`
1445
+ `);
1446
+ const nodes = lines.map((line) => view.state.schema.nodes.paragraph.create({ kind: "paragraph" }, line ? view.state.schema.text(line) : undefined));
1447
+ const doc = view.state.schema.topNodeType.create(null, nodes);
1448
+ view.dispatch(view.state.tr.replaceSelection(doc.slice(1, doc.content.size - 1)));
1449
+ return true;
1450
+ },
1451
+ handleDrop: () => true,
1452
+ handleClick: (_view, _position, event) => {
1453
+ if (event.target instanceof HTMLElement && event.target.closest("a")) {
1454
+ event.preventDefault();
1455
+ return true;
1456
+ }
1457
+ return false;
1458
+ }
1459
+ }
1460
+ }, [singleLine]);
1461
+ const marks = {
1462
+ bold: editor?.isActive("bold"),
1463
+ italic: editor?.isActive("italic"),
1464
+ underline: editor?.isActive("underline"),
1465
+ href: editor?.getAttributes("link").href
1466
+ };
1467
+ const historyState = {
1468
+ undo: editor?.can().undo() ?? false,
1469
+ redo: editor?.can().redo() ?? false
1177
1470
  };
1178
1471
  const focusEditor = () => {
1179
- const element = root.current;
1180
- if (element) {
1181
- element.focus();
1182
- restoreRichTextSelection(element, selected.current);
1183
- }
1472
+ editor?.view.focus();
1184
1473
  return false;
1185
1474
  };
1186
- const commit = (next, range, write = true, record = true) => {
1187
- const element = root.current;
1188
- if (!element || disabled)
1189
- return;
1190
- const original = next;
1191
- if (singleLine) {
1192
- next = {
1193
- version: 1,
1194
- blocks: [
1195
- {
1196
- type: "paragraph",
1197
- content: next.blocks.flatMap((block, index) => [
1198
- ...index ? [{ type: "text", text: " " }] : [],
1199
- ...block.content.map((inline) => inline.type === "variable" ? { type: "variable", key: inline.key } : {
1200
- type: "text",
1201
- text: inline.text.replace(/[\r\n]+/g, " ")
1202
- })
1203
- ])
1204
- }
1205
- ]
1206
- };
1207
- if (!equivalent(original, next))
1208
- write = true;
1209
- }
1210
- if (!Schema4.is(RichTextDocument)(next) || maxLength !== undefined && richTextPlainText(next).length > maxLength) {
1211
- setError(true);
1212
- writeRichTextDOM(element, model.current, variables);
1213
- element.focus();
1214
- restoreRichTextSelection(element, selected.current);
1215
- return;
1216
- }
1217
- setError(false);
1218
- if (record && !equivalent(model.current, next)) {
1219
- history.current[cursor.current] = {
1220
- value: model.current,
1221
- selection: selected.current
1222
- };
1223
- history.current = [
1224
- ...history.current.slice(0, cursor.current + 1),
1225
- { value: next, selection: range }
1226
- ].slice(-100);
1227
- cursor.current = history.current.length - 1;
1228
- }
1229
- model.current = next;
1230
- selected.current = range;
1231
- if (write) {
1232
- writeRichTextDOM(element, next, variables);
1233
- element.focus();
1234
- restoreRichTextSelection(element, range);
1235
- }
1236
- setRevision((current) => current + 1);
1237
- setHistoryState({
1238
- undo: cursor.current > 0,
1239
- redo: cursor.current < history.current.length - 1
1240
- });
1241
- onChange(next);
1242
- };
1243
1475
  const travel = (direction) => {
1244
- const index = Math.max(0, Math.min(history.current.length - 1, cursor.current + direction));
1245
- const snapshot = history.current[index];
1246
- if (!snapshot || index === cursor.current)
1476
+ if (disabled)
1247
1477
  return;
1248
- cursor.current = index;
1249
- pendingMarks.current = null;
1250
- commit(snapshot.value, snapshot.selection, true, false);
1251
- };
1252
- const insert = (inline) => {
1253
- const result = replaceRichText(model.current, selection(), inline);
1254
- commit(result.value, result.selection);
1478
+ if (direction < 0)
1479
+ editor?.chain().focus().undo().run();
1480
+ else
1481
+ editor?.chain().focus().redo().run();
1255
1482
  };
1256
1483
  const format = (mark) => {
1257
- const range = selection();
1258
- const next = {
1259
- ...pendingMarks.current ?? richTextMarksAt(model.current, range.to),
1260
- [mark]: !marks[mark]
1261
- };
1262
- setMarks(next);
1263
- if (range.from === range.to) {
1264
- pendingMarks.current = next;
1265
- root.current?.focus();
1266
- } else
1267
- commit(formatRichText(model.current, range, mark, next[mark]), range);
1484
+ if (!disabled)
1485
+ editor?.chain().focus().toggleMark(mark).run();
1268
1486
  };
1269
- const syncInput = () => {
1270
- const element = root.current;
1271
- if (!element || composing.current)
1487
+ const insertVariable = (key) => {
1488
+ if (disabled || !editor)
1272
1489
  return;
1273
- const parsed = readRichTextDOM(element);
1274
- const range = readEditorSelection(element, parsed.points) ?? selected.current;
1275
- if (parsed.value)
1276
- commit(parsed.value, range, false);
1277
- else {
1278
- setError(true);
1279
- writeRichTextDOM(element, model.current, variables);
1280
- restoreRichTextSelection(element, selected.current);
1281
- }
1490
+ editor.view.dispatch(closeHistory(editor.state.tr));
1491
+ editor.chain().insertContent({ type: "variable", attrs: { key } }).run();
1492
+ editor.view.dispatch(closeHistory(editor.state.tr));
1282
1493
  };
1283
- const beforeInput = useEffectEvent3((event) => {
1284
- if (disabled || composing.current || event.isComposing)
1494
+ useEffect4(() => {
1495
+ if (!editor)
1285
1496
  return;
1286
- if (event.inputType === "historyUndo" || event.inputType === "historyRedo") {
1287
- event.preventDefault();
1288
- travel(event.inputType === "historyUndo" ? -1 : 1);
1289
- } else if (["insertText", "insertParagraph", "insertLineBreak"].includes(event.inputType)) {
1290
- event.preventDefault();
1291
- if (singleLine && event.inputType !== "insertText")
1292
- return;
1293
- const range = selection();
1294
- insert({
1295
- type: "text",
1296
- text: event.inputType === "insertText" ? event.data ?? "" : `
1297
- `,
1298
- marks: pendingMarks.current ?? richTextMarksAt(model.current, range.to)
1299
- });
1300
- } else if (event.inputType === "formatBold" || event.inputType === "formatItalic" || event.inputType === "formatUnderline") {
1301
- event.preventDefault();
1302
- if (!singleLine)
1303
- format(event.inputType === "formatBold" ? "bold" : event.inputType === "formatItalic" ? "italic" : "underline");
1497
+ const incoming = editor.schema.nodeFromJSON(toTiptapDocument(value, singleLine));
1498
+ if (!editor.state.doc.eq(incoming)) {
1499
+ editor.view.updateState(EditorState.create({
1500
+ schema: editor.schema,
1501
+ doc: incoming,
1502
+ plugins: editor.state.plugins
1503
+ }));
1504
+ editor.view.dispatch(editor.state.tr.setMeta(externalReplacementMeta, true));
1304
1505
  }
1305
- });
1306
- useEffect3(() => {
1307
- const element = root.current;
1308
- if (!element)
1309
- return;
1310
- const listener = (event) => beforeInput(event);
1311
- element.addEventListener("beforeinput", listener);
1312
- return () => element.removeEventListener("beforeinput", listener);
1313
- }, []);
1314
- const remember = useEffectEvent3(() => {
1315
- const element = root.current;
1316
- if (!element || document.activeElement !== element || composing.current)
1506
+ }, [editor, value, singleLine]);
1507
+ useEffect4(() => {
1508
+ if (!editor)
1317
1509
  return;
1318
- const previous = selected.current;
1319
- const range = selection();
1320
- if (previous.from !== range.from || previous.to !== range.to)
1321
- pendingMarks.current = null;
1322
- setMarks(pendingMarks.current ?? richTextMarksAt(model.current, range.to));
1323
- });
1324
- useEffect3(() => {
1325
- document.addEventListener("selectionchange", remember);
1326
- return () => document.removeEventListener("selectionchange", remember);
1327
- }, []);
1328
- useEffect3(() => {
1329
- const element = root.current;
1330
- if (!element || composing.current)
1510
+ editor.setEditable(!disabled, false);
1511
+ }, [editor, disabled]);
1512
+ useEffect4(() => {
1513
+ if (!editor)
1331
1514
  return;
1332
- if (!equivalent(model.current, value)) {
1333
- model.current = value;
1334
- history.current = [{ value, selection: { from: 0, to: 0 } }];
1335
- cursor.current = 0;
1336
- selected.current = { from: 0, to: 0 };
1337
- writeRichTextDOM(element, value, variables);
1338
- setRevision((current) => current + 1);
1339
- setHistoryState({ undo: false, redo: false });
1515
+ for (const chip of editor.view.dom.querySelectorAll("[data-rich-variable]")) {
1516
+ const key = chip.getAttribute("data-rich-variable");
1517
+ const text = `{{${variables.find((variable) => variable.key === key)?.label ?? key}}}`;
1518
+ if (chip.textContent !== text)
1519
+ chip.textContent = text;
1340
1520
  }
1341
- }, [value, variables]);
1521
+ }, [editor, variables]);
1342
1522
  return /* @__PURE__ */ jsxs4("div", {
1343
1523
  "data-slot": "rich-text-editor",
1344
1524
  className: `bg-background text-foreground overflow-hidden rounded-xl border ${className ?? ""}`,
@@ -1369,29 +1549,22 @@ var RichTextEditor = ({
1369
1549
  }),
1370
1550
  /* @__PURE__ */ jsxs4(Select, {
1371
1551
  disabled,
1372
- defaultValue: "paragraph",
1552
+ value: editor?.getAttributes("paragraph").kind ?? "paragraph",
1373
1553
  items: [
1374
1554
  { value: "paragraph", label: copy.paragraph },
1375
1555
  { value: "heading", label: copy.heading },
1376
1556
  { value: "bullet", label: copy.bullet },
1377
1557
  { value: "numbered", label: copy.numbered }
1378
1558
  ],
1379
- onOpenChange: (open) => {
1380
- if (open)
1381
- selection();
1382
- },
1383
1559
  onValueChange: (value) => {
1384
- const type = Schema4.decodeUnknownSync(RichTextBlockKind)(value);
1385
- const range = selection();
1386
- commit(setRichTextBlock(model.current, range, type), range);
1560
+ if (!disabled && value)
1561
+ editor?.chain().focus().updateAttributes("paragraph", { kind: value }).run();
1387
1562
  },
1388
1563
  children: [
1389
1564
  /* @__PURE__ */ jsx7(SelectTrigger, {
1390
1565
  size: "sm",
1391
1566
  "aria-label": copy.paragraph,
1392
1567
  className: "max-w-40 text-xs",
1393
- onPointerDown: selection,
1394
- onFocus: selection,
1395
1568
  children: /* @__PURE__ */ jsx7(SelectValue, {})
1396
1569
  }),
1397
1570
  /* @__PURE__ */ jsxs4(SelectContent, {
@@ -1445,7 +1618,6 @@ var RichTextEditor = ({
1445
1618
  disabled,
1446
1619
  pressed: linkOpen || !!marks.href,
1447
1620
  onClick: () => {
1448
- selection();
1449
1621
  setLink(marks.href ?? "");
1450
1622
  setLinkError(false);
1451
1623
  setLinkOpen(!linkOpen);
@@ -1455,15 +1627,9 @@ var RichTextEditor = ({
1455
1627
  ]
1456
1628
  }) : null,
1457
1629
  variables.length ? /* @__PURE__ */ jsxs4(DropdownMenu, {
1458
- onOpenChange: (open) => {
1459
- if (open)
1460
- selection();
1461
- },
1462
1630
  children: [
1463
1631
  /* @__PURE__ */ jsxs4(DropdownMenuTrigger, {
1464
1632
  disabled,
1465
- onPointerDown: selection,
1466
- onFocus: selection,
1467
1633
  render: /* @__PURE__ */ jsx7(Button, {
1468
1634
  type: "button",
1469
1635
  variant: "outline",
@@ -1486,7 +1652,7 @@ var RichTextEditor = ({
1486
1652
  align: "end",
1487
1653
  finalFocus: focusEditor,
1488
1654
  children: variables.map((variable) => /* @__PURE__ */ jsx7(DropdownMenuItem, {
1489
- onClick: () => insert({ type: "variable", key: variable.key }),
1655
+ onClick: () => insertVariable(variable.key),
1490
1656
  children: variable.label
1491
1657
  }, variable.key))
1492
1658
  })
@@ -1514,11 +1680,11 @@ var RichTextEditor = ({
1514
1680
  size: "sm",
1515
1681
  disabled,
1516
1682
  onClick: () => {
1517
- if (!Schema4.is(RichTextLink)(link)) {
1683
+ if (!Schema6.is(RichTextLink)(link)) {
1518
1684
  setLinkError(true);
1519
1685
  return;
1520
1686
  }
1521
- commit(formatRichText(model.current, selected.current, "href", link), selected.current);
1687
+ editor?.chain().focus().setLink({ href: link }).run();
1522
1688
  setLinkOpen(false);
1523
1689
  },
1524
1690
  children: copy.apply
@@ -1529,7 +1695,7 @@ var RichTextEditor = ({
1529
1695
  variant: "outline",
1530
1696
  disabled,
1531
1697
  onClick: () => {
1532
- commit(formatRichText(model.current, selected.current, "href", undefined), selected.current);
1698
+ editor?.chain().focus().unsetLink().run();
1533
1699
  setLinkOpen(false);
1534
1700
  setLinkError(false);
1535
1701
  },
@@ -1554,56 +1720,9 @@ var RichTextEditor = ({
1554
1720
  }) : null
1555
1721
  ]
1556
1722
  }) : null,
1557
- /* @__PURE__ */ jsx7("div", {
1558
- ref: root,
1559
- style: contentStyle,
1560
- role: "textbox",
1561
- "aria-label": label,
1562
- "aria-multiline": !singleLine,
1563
- "aria-disabled": disabled,
1564
- "aria-describedby": error ? `${id}-error` : undefined,
1565
- contentEditable: !disabled,
1566
- suppressContentEditableWarning: true,
1567
- className: `focus-visible:ring-ring ${singleLine ? "min-h-10" : "min-h-32"} px-4 py-3 text-sm leading-relaxed outline-none focus-visible:ring-2 focus-visible:ring-inset [&>div]:min-h-[1.5em]`,
1568
- onInput: syncInput,
1569
- onKeyUp: selection,
1570
- onPointerUp: selection,
1571
- onBlur: selection,
1572
- onCompositionStart: () => {
1573
- composing.current = true;
1574
- },
1575
- onCompositionEnd: () => {
1576
- composing.current = false;
1577
- syncInput();
1578
- },
1579
- onPaste: (event) => {
1580
- event.preventDefault();
1581
- const text = event.clipboardData.getData("text/plain");
1582
- insert({
1583
- type: "text",
1584
- text: singleLine ? text.replace(/[\r\n]+/g, " ") : text
1585
- });
1586
- },
1587
- onDrop: (event) => event.preventDefault(),
1588
- onClick: (event) => {
1589
- if (event.target instanceof HTMLElement && event.target.closest("a"))
1590
- event.preventDefault();
1591
- },
1592
- onKeyDown: (event) => {
1593
- if (event.nativeEvent.isComposing)
1594
- return;
1595
- if ((event.ctrlKey || event.metaKey) && !event.altKey) {
1596
- const key = event.key.toLowerCase();
1597
- if (["b", "i", "u", "z", "y"].includes(key)) {
1598
- event.preventDefault();
1599
- if (key === "z" || key === "y")
1600
- travel(key === "y" || event.shiftKey ? 1 : -1);
1601
- else if (!singleLine)
1602
- format(key === "b" ? "bold" : key === "i" ? "italic" : "underline");
1603
- }
1604
- }
1605
- },
1606
- children: initial
1723
+ /* @__PURE__ */ jsx7(EditorContent, {
1724
+ editor,
1725
+ style: contentStyle
1607
1726
  }),
1608
1727
  error ? /* @__PURE__ */ jsx7("p", {
1609
1728
  id: `${id}-error`,
@@ -1669,92 +1788,92 @@ function TabsContent({ className, ...props }) {
1669
1788
  });
1670
1789
  }
1671
1790
 
1672
- // ../../src/components/ui/email-editor.tsx
1673
- import { useKrakstackLocale as useKrakstackLocale3 } from "@krak-stack/registry/krakstack-provider";
1791
+ // ../../src/components/email-editor/react.tsx
1792
+ import { useKrakstackLocale as useKrakstackLocale3 } from "@krak-stack/registry/krakstack-provider/react";
1674
1793
 
1675
1794
  // ../../src/lib/email-document/schema.ts
1676
- import { Schema as Schema5 } from "effect";
1677
- var EmailImageUrl = RichTextLink.check(Schema5.isPattern(/^https:\/\//)).annotate({ identifier: "EmailImageUrl" });
1678
- var EmailColor = Schema5.String.check(Schema5.isPattern(/^#[0-9a-fA-F]{6}$/)).annotate({ identifier: "EmailColor" });
1679
- var EmailAlignment = Schema5.Literals([
1795
+ import { Schema as Schema7 } from "effect";
1796
+ var EmailImageUrl = RichTextLink.check(Schema7.isPattern(/^https:\/\//)).annotate({ identifier: "EmailImageUrl" });
1797
+ var EmailColor = Schema7.String.check(Schema7.isPattern(/^#[0-9a-fA-F]{6}$/)).annotate({ identifier: "EmailColor" });
1798
+ var EmailAlignment = Schema7.Literals([
1680
1799
  "left",
1681
1800
  "center",
1682
1801
  "right"
1683
1802
  ]).annotate({ identifier: "EmailAlignment" });
1684
- var EmailFont = Schema5.Literals(["sans", "serif", "mono"]).annotate({
1803
+ var EmailFont = Schema7.Literals(["sans", "serif", "mono"]).annotate({
1685
1804
  identifier: "EmailFont"
1686
1805
  });
1687
- var spacing = Schema5.Int.check(Schema5.isBetween({ minimum: 0, maximum: 96 }));
1806
+ var spacing = Schema7.Int.check(Schema7.isBetween({ minimum: 0, maximum: 96 }));
1688
1807
  var common = {
1689
- id: Schema5.NonEmptyString.check(Schema5.isMaxLength(80)),
1808
+ id: Schema7.NonEmptyString.check(Schema7.isMaxLength(80)),
1690
1809
  alignment: EmailAlignment,
1691
1810
  paddingTop: spacing,
1692
1811
  paddingBottom: spacing
1693
1812
  };
1694
- var EmailDestination = Schema5.Union([
1695
- Schema5.Struct({ type: Schema5.Literal("url"), url: RichTextLink }),
1696
- Schema5.Struct({
1697
- type: Schema5.Literal("variable"),
1813
+ var EmailDestination = Schema7.Union([
1814
+ Schema7.Struct({ type: Schema7.Literal("url"), url: RichTextLink }),
1815
+ Schema7.Struct({
1816
+ type: Schema7.Literal("variable"),
1698
1817
  key: RichTextVariable.fields.key
1699
1818
  })
1700
1819
  ]).annotate({ identifier: "EmailDestination" });
1701
- var EmailElement = Schema5.Union([
1702
- Schema5.Struct({
1820
+ var EmailElement = Schema7.Union([
1821
+ Schema7.Struct({
1703
1822
  ...common,
1704
- type: Schema5.Literal("text"),
1823
+ type: Schema7.Literal("text"),
1705
1824
  content: RichTextDocument
1706
1825
  }),
1707
- Schema5.Struct({
1826
+ Schema7.Struct({
1708
1827
  ...common,
1709
- type: Schema5.Literal("button"),
1710
- label: Schema5.String.check(Schema5.isMaxLength(200)),
1828
+ type: Schema7.Literal("button"),
1829
+ label: Schema7.String.check(Schema7.isMaxLength(200)),
1711
1830
  destination: EmailDestination
1712
1831
  }),
1713
- Schema5.Struct({
1832
+ Schema7.Struct({
1714
1833
  ...common,
1715
- type: Schema5.Literal("code"),
1834
+ type: Schema7.Literal("code"),
1716
1835
  variable: RichTextVariable.fields.key
1717
1836
  }),
1718
- Schema5.Struct({
1837
+ Schema7.Struct({
1719
1838
  ...common,
1720
- type: Schema5.Literals(["logo", "image"]),
1839
+ type: Schema7.Literals(["logo", "image"]),
1721
1840
  src: EmailImageUrl,
1722
- alt: Schema5.String.check(Schema5.isMaxLength(200)),
1723
- width: Schema5.Int.check(Schema5.isBetween({ minimum: 32, maximum: 560 }))
1841
+ alt: Schema7.String.check(Schema7.isMaxLength(200)),
1842
+ width: Schema7.Int.check(Schema7.isBetween({ minimum: 32, maximum: 560 }))
1724
1843
  }),
1725
- Schema5.Struct({ ...common, type: Schema5.Literal("divider") }),
1726
- Schema5.Struct({ ...common, type: Schema5.Literal("spacer"), height: spacing })
1844
+ Schema7.Struct({ ...common, type: Schema7.Literal("divider") }),
1845
+ Schema7.Struct({ ...common, type: Schema7.Literal("spacer"), height: spacing })
1727
1846
  ]).annotate({ identifier: "EmailElement" });
1728
- var subject = Schema5.String.check(Schema5.isMaxLength(200), Schema5.isPattern(/^[^\r\n]*$/));
1729
- var EmailDocument = Schema5.Struct({
1730
- version: Schema5.Literal(1),
1847
+ var subject = Schema7.String.check(Schema7.isMaxLength(200), Schema7.isPattern(/^[^\r\n]*$/));
1848
+ var EmailDocument = Schema7.Struct({
1849
+ version: Schema7.Literal(1),
1731
1850
  subject,
1732
1851
  preview: subject,
1733
- appearance: Schema5.Struct({
1852
+ appearance: Schema7.Struct({
1734
1853
  background: EmailColor,
1735
1854
  surface: EmailColor,
1736
1855
  text: EmailColor,
1737
1856
  primary: EmailColor,
1738
1857
  primaryText: EmailColor,
1739
1858
  font: EmailFont,
1740
- radius: Schema5.Int.check(Schema5.isBetween({ minimum: 0, maximum: 32 }))
1859
+ radius: Schema7.Int.check(Schema7.isBetween({ minimum: 0, maximum: 32 }))
1741
1860
  }),
1742
- elements: Schema5.Array(EmailElement).check(Schema5.isMaxLength(40))
1743
- }).check(Schema5.makeFilter((document2) => new Set(document2.elements.map((element) => element.id)).size === document2.elements.length)).annotate({ identifier: "EmailDocument" });
1744
- var EmailRenderInput = Schema5.Struct({
1861
+ elements: Schema7.Array(EmailElement).check(Schema7.isMaxLength(40))
1862
+ }).check(Schema7.makeFilter((document2) => new Set(document2.elements.map((element) => element.id)).size === document2.elements.length)).annotate({ identifier: "EmailDocument" });
1863
+ var EmailRenderInput = Schema7.Struct({
1745
1864
  document: EmailDocument,
1746
- variables: Schema5.Array(RichTextVariable),
1747
- values: Schema5.Record(Schema5.String, Schema5.String),
1748
- requiredVariables: Schema5.optional(Schema5.Array(Schema5.String))
1865
+ variables: Schema7.Array(RichTextVariable),
1866
+ values: Schema7.Record(Schema7.String, Schema7.String),
1867
+ requiredVariables: Schema7.optional(Schema7.Array(Schema7.String))
1749
1868
  }).annotate({ identifier: "EmailRenderInput" });
1750
- var EmailRenderResult = Schema5.Struct({
1751
- subject: Schema5.String,
1752
- html: Schema5.String,
1753
- text: Schema5.String
1869
+ var EmailRenderResult = Schema7.Struct({
1870
+ subject: Schema7.String,
1871
+ html: Schema7.String,
1872
+ text: Schema7.String
1754
1873
  }).annotate({ identifier: "EmailRenderResult" });
1755
1874
 
1756
1875
  // ../../src/lib/email-document/model.ts
1757
- import { Schema as Schema6 } from "effect";
1876
+ import { Schema as Schema8 } from "effect";
1758
1877
  var emailElementTypes = [
1759
1878
  "text",
1760
1879
  "button",
@@ -1835,7 +1954,7 @@ var validateEmailDocument = ({
1835
1954
  values,
1836
1955
  requiredVariables = []
1837
1956
  }) => {
1838
- if (!Schema6.is(EmailDocument)(document2))
1957
+ if (!Schema8.is(EmailDocument)(document2))
1839
1958
  return [{ code: "invalid-document" }];
1840
1959
  const references = emailDocumentReferences(document2);
1841
1960
  const issues = [];
@@ -1848,7 +1967,7 @@ var validateEmailDocument = ({
1848
1967
  for (const element of document2.elements) {
1849
1968
  if (element.type === "button" && element.destination.type === "variable") {
1850
1969
  const key = element.destination.key;
1851
- if (variables.find((variable) => variable.key === key)?.type !== "url" || values && !Schema6.is(RichTextLink)(values[key]))
1970
+ if (variables.find((variable) => variable.key === key)?.type !== "url" || values && !Schema8.is(RichTextLink)(values[key]))
1852
1971
  issues.push({ code: "invalid-url", key });
1853
1972
  }
1854
1973
  }
@@ -1858,39 +1977,28 @@ var validateEmailDocument = ({
1858
1977
  return issues;
1859
1978
  };
1860
1979
 
1861
- // ../../src/components/ui/email-editor.tsx
1862
- import { jsx as jsx9, jsxs as jsxs5, Fragment as Fragment3 } from "react/jsx-runtime";
1863
- var EmailEditorSelect = ({
1864
- label,
1865
- value,
1866
- options,
1867
- disabled,
1868
- onValueChange
1869
- }) => /* @__PURE__ */ jsxs5(Select, {
1870
- items: options,
1871
- value,
1872
- disabled,
1873
- onValueChange: (value) => {
1874
- if (value !== null)
1875
- onValueChange(value);
1876
- },
1877
- children: [
1878
- /* @__PURE__ */ jsx9(SelectTrigger, {
1879
- "aria-label": label,
1880
- className: "w-full min-w-0 text-xs",
1881
- children: /* @__PURE__ */ jsx9(SelectValue, {})
1882
- }),
1883
- /* @__PURE__ */ jsx9(SelectContent, {
1884
- align: "start",
1885
- alignItemWithTrigger: false,
1886
- children: options.map((option) => /* @__PURE__ */ jsx9(SelectItem, {
1887
- value: option.value,
1888
- children: option.label
1889
- }, option.value))
1890
- })
1891
- ]
1980
+ // ../../src/components/email-editor/classes.ts
1981
+ var emailEditorClasses = {
1982
+ inspectorField: "grid min-w-0 gap-1.5 text-xs font-medium",
1983
+ inspector: "min-w-0 space-y-4",
1984
+ sectionHeading: "text-xs font-medium",
1985
+ previewPlaceholder: "p-8 text-center text-sm",
1986
+ image: "inline-block max-w-full",
1987
+ metadata: "text-muted-foreground text-xs",
1988
+ actionGrid: "grid grid-cols-2 gap-2",
1989
+ error: "text-destructive text-xs"
1990
+ };
1991
+ var resolveEmailEditorClasses = (overrides) => ({
1992
+ ...emailEditorClasses,
1993
+ ...overrides
1892
1994
  });
1893
- var labels3 = {
1995
+
1996
+ // ../../src/components/email-editor/index.ts
1997
+ import { Schema as Schema10 } from "effect";
1998
+ import { Component as Component3, UiSchema as UiSchema2 } from "effect/ui";
1999
+
2000
+ // ../../src/components/email-editor/labels.ts
2001
+ var defaultMessages = {
1894
2002
  en: {
1895
2003
  edit: "Design",
1896
2004
  preview: "Preview",
@@ -1996,6 +2104,274 @@ var labels3 = {
1996
2104
  local: "Glissez avec la poignée ou utilisez ses touches fléchées. Vos modifications restent dans cet éditeur."
1997
2105
  }
1998
2106
  };
2107
+
2108
+ // ../../src/components/email-editor/schema.ts
2109
+ import { Schema as Schema9, Struct as Struct2 } from "effect";
2110
+ var Overrides = Schema9.Struct({
2111
+ edit: Schema9.optional(Schema9.String),
2112
+ preview: Schema9.optional(Schema9.String),
2113
+ subject: Schema9.optional(Schema9.String),
2114
+ preheader: Schema9.optional(Schema9.String),
2115
+ add: Schema9.optional(Schema9.String),
2116
+ text: Schema9.optional(Schema9.String),
2117
+ button: Schema9.optional(Schema9.String),
2118
+ code: Schema9.optional(Schema9.String),
2119
+ logo: Schema9.optional(Schema9.String),
2120
+ image: Schema9.optional(Schema9.String),
2121
+ divider: Schema9.optional(Schema9.String),
2122
+ spacer: Schema9.optional(Schema9.String),
2123
+ content: Schema9.optional(Schema9.String),
2124
+ properties: Schema9.optional(Schema9.String),
2125
+ select: Schema9.optional(Schema9.String),
2126
+ alignment: Schema9.optional(Schema9.String),
2127
+ left: Schema9.optional(Schema9.String),
2128
+ center: Schema9.optional(Schema9.String),
2129
+ right: Schema9.optional(Schema9.String),
2130
+ paddingTop: Schema9.optional(Schema9.String),
2131
+ paddingBottom: Schema9.optional(Schema9.String),
2132
+ width: Schema9.optional(Schema9.String),
2133
+ height: Schema9.optional(Schema9.String),
2134
+ src: Schema9.optional(Schema9.String),
2135
+ alt: Schema9.optional(Schema9.String),
2136
+ label: Schema9.optional(Schema9.String),
2137
+ destination: Schema9.optional(Schema9.String),
2138
+ url: Schema9.optional(Schema9.String),
2139
+ variable: Schema9.optional(Schema9.String),
2140
+ insertVariable: Schema9.optional(Schema9.String),
2141
+ close: Schema9.optional(Schema9.String),
2142
+ duplicate: Schema9.optional(Schema9.String),
2143
+ remove: Schema9.optional(Schema9.String),
2144
+ background: Schema9.optional(Schema9.String),
2145
+ surface: Schema9.optional(Schema9.String),
2146
+ primary: Schema9.optional(Schema9.String),
2147
+ primaryText: Schema9.optional(Schema9.String),
2148
+ foreground: Schema9.optional(Schema9.String),
2149
+ font: Schema9.optional(Schema9.String),
2150
+ sans: Schema9.optional(Schema9.String),
2151
+ serif: Schema9.optional(Schema9.String),
2152
+ mono: Schema9.optional(Schema9.String),
2153
+ branding: Schema9.optional(Schema9.String),
2154
+ invalid: Schema9.optional(Schema9.String),
2155
+ newText: Schema9.optional(Schema9.String),
2156
+ newButton: Schema9.optional(Schema9.String),
2157
+ newImage: Schema9.optional(Schema9.String),
2158
+ empty: Schema9.optional(Schema9.String),
2159
+ editElement: Schema9.optional(Schema9.String),
2160
+ local: Schema9.optional(Schema9.String)
2161
+ });
2162
+ var EmailEditorClassesOverridesSchema = Schema9.Record(Schema9.Literals(Struct2.keys(emailEditorClasses)), Schema9.optionalKey(Schema9.String)).annotate({ identifier: "EmailEditorClassesOverrides" });
2163
+ var EmailEditorPropsSchema = Schema9.Struct({
2164
+ classes: Schema9.optional(EmailEditorClassesOverridesSchema),
2165
+ value: EmailDocument,
2166
+ variables: Schema9.optional(Schema9.Array(RichTextVariable)),
2167
+ requiredVariables: Schema9.optional(Schema9.Array(Schema9.String)),
2168
+ disabled: Schema9.optional(Schema9.Boolean),
2169
+ locale: Schema9.optional(Schema9.String),
2170
+ messages: Schema9.optional(Schema9.Record(Schema9.String, Schema9.UndefinedOr(Overrides)))
2171
+ }).annotate({ identifier: "EmailEditorProps" });
2172
+
2173
+ // ../../src/components/email-editor/index.ts
2174
+ var emailEditorMessages = (locale, messages) => ({
2175
+ ...locale.startsWith("fr") ? defaultMessages.fr : defaultMessages.en,
2176
+ ...messages?.[locale.split("-")[0] ?? locale],
2177
+ ...messages?.[locale]
2178
+ });
2179
+ var fonts = {
2180
+ sans: "Arial, sans-serif",
2181
+ serif: "Georgia, serif",
2182
+ mono: "'Courier New', monospace"
2183
+ };
2184
+ var createElement = (type, id, copy, variables) => newEmailElement(type, {
2185
+ id,
2186
+ text: copy.newText,
2187
+ button: copy.newButton,
2188
+ imageAlt: copy.newImage,
2189
+ codeVariable: variables.find(({ key }) => key === "code")?.key ?? variables.find(({ type }) => type === "text")?.key,
2190
+ urlVariable: variables.find(({ type }) => type === "url")?.key
2191
+ });
2192
+ var replaceElement = (value, element) => ({
2193
+ ...value,
2194
+ elements: value.elements.map((item) => item.id === element.id ? element : item)
2195
+ });
2196
+ var duplicateElement = (value, target, id) => ({
2197
+ ...value,
2198
+ elements: value.elements.flatMap((item) => item.id === target ? [item, { ...item, id }] : [item])
2199
+ });
2200
+ var removeElement = (value, target) => ({
2201
+ ...value,
2202
+ elements: value.elements.filter(({ id }) => id !== target)
2203
+ });
2204
+ var moveElement = (value, source, target) => {
2205
+ const from = value.elements.findIndex(({ id }) => id === source);
2206
+ const to = value.elements.findIndex(({ id }) => id === target);
2207
+ if (from < 0 || to < 0 || from === to)
2208
+ return value;
2209
+ const elements = [...value.elements];
2210
+ const [element] = elements.splice(from, 1);
2211
+ if (!element)
2212
+ return value;
2213
+ elements.splice(to, 0, element);
2214
+ return { ...value, elements };
2215
+ };
2216
+ var initialActive = (value) => value.elements.find(({ type }) => type === "text")?.id ?? null;
2217
+ var EmailEditorEvents = UiSchema2.TaggedEnum({
2218
+ Changed: { value: EmailDocument }
2219
+ }).annotate({ identifier: "EmailEditorEvents" });
2220
+ var EmailEditorMessage = UiSchema2.TaggedEnum({
2221
+ Mode: { mode: Schema10.Literals(["design", "preview"]) },
2222
+ SetDesignPopover: {
2223
+ popover: Schema10.Literals(["add", "branding"]),
2224
+ open: Schema10.Boolean
2225
+ },
2226
+ Select: { id: Schema10.String },
2227
+ Close: {},
2228
+ Add: {
2229
+ id: Schema10.String,
2230
+ kind: Schema10.Literals(emailElementTypes),
2231
+ text: Schema10.String,
2232
+ button: Schema10.String,
2233
+ image: Schema10.String
2234
+ },
2235
+ Duplicate: { id: Schema10.String, target: Schema10.String },
2236
+ Remove: { id: Schema10.String },
2237
+ Move: { source: Schema10.String, target: Schema10.String },
2238
+ Content: { id: Schema10.String, content: RichTextDocument },
2239
+ Header: {
2240
+ key: Schema10.Literals(["subject", "preview"]),
2241
+ content: RichTextDocument
2242
+ },
2243
+ Appearance: {
2244
+ key: Schema10.Literals([
2245
+ "background",
2246
+ "surface",
2247
+ "primary",
2248
+ "primaryText",
2249
+ "text",
2250
+ "font"
2251
+ ]),
2252
+ value: Schema10.String
2253
+ },
2254
+ Setting: {
2255
+ id: Schema10.String,
2256
+ key: Schema10.Literals([
2257
+ "alignment",
2258
+ "paddingTop",
2259
+ "paddingBottom",
2260
+ "label",
2261
+ "destination",
2262
+ "url",
2263
+ "variable",
2264
+ "src",
2265
+ "alt",
2266
+ "width",
2267
+ "height"
2268
+ ]),
2269
+ value: Schema10.String
2270
+ }
2271
+ }).annotate({ identifier: "EmailEditorMessage" });
2272
+ var emailEditorOptions = {
2273
+ name: "EmailEditor",
2274
+ props: EmailEditorPropsSchema,
2275
+ model: Schema10.Struct({
2276
+ active: Schema10.NullOr(Schema10.String),
2277
+ settingsOpen: Schema10.Boolean,
2278
+ mode: Schema10.Literals(["design", "preview"]),
2279
+ designPopover: Schema10.NullOr(Schema10.Literals(["add", "branding"]))
2280
+ }).annotate({ identifier: "EmailEditorModel" }),
2281
+ message: EmailEditorMessage,
2282
+ events: EmailEditorEvents,
2283
+ restore: false
2284
+ };
2285
+ var update2 = Component3.define(emailEditorOptions).update({
2286
+ Mode: ($, { mode }) => $.evolve({ mode, designPopover: null }),
2287
+ SetDesignPopover: ($, { popover, open }) => $.evolve({
2288
+ designPopover: open ? popover : $.model.designPopover === popover ? null : $.model.designPopover
2289
+ }),
2290
+ Select: ($, { id }) => $.props.disabled ? $.model : $.evolve({ active: id, settingsOpen: true }),
2291
+ Close: ($) => $.evolve({ settingsOpen: false }),
2292
+ Add: ($, { kind, id, text, button, image }) => $.props.disabled || $.props.value.elements.length >= 40 ? $.model : $.evolve({ active: id, designPopover: null }).emit(EmailEditorEvents.Changed({
2293
+ value: {
2294
+ ...$.props.value,
2295
+ elements: [
2296
+ ...$.props.value.elements,
2297
+ createElement(kind, id, { newText: text, newButton: button, newImage: image }, $.props.variables ?? [])
2298
+ ]
2299
+ }
2300
+ })),
2301
+ Duplicate: ($, { id, target }) => $.props.disabled || $.props.value.elements.length >= 40 ? $.model : $.evolve({ active: id }).emit(EmailEditorEvents.Changed({
2302
+ value: duplicateElement($.props.value, target, id)
2303
+ })),
2304
+ Remove: ($, { id }) => $.props.disabled ? $.model : $.evolve({ active: null, settingsOpen: false }).emit(EmailEditorEvents.Changed({
2305
+ value: removeElement($.props.value, id)
2306
+ })),
2307
+ Move: ($, { source, target }) => {
2308
+ const value = moveElement($.props.value, source, target);
2309
+ return $.props.disabled || value === $.props.value ? $.model : $.set($.model).emit(EmailEditorEvents.Changed({ value }));
2310
+ },
2311
+ Content: ($, { id, content }) => {
2312
+ const element = $.props.value.elements.find((item) => item.id === id);
2313
+ return $.props.disabled || element?.type !== "text" ? $.model : $.set($.model).emit(EmailEditorEvents.Changed({
2314
+ value: replaceElement($.props.value, { ...element, content })
2315
+ }));
2316
+ },
2317
+ Header: ($, { key, content }) => $.props.disabled ? $.model : $.set($.model).emit(EmailEditorEvents.Changed({
2318
+ value: { ...$.props.value, [key]: richTextPlainText(content) }
2319
+ })),
2320
+ Appearance: ($, { key, value }) => $.props.disabled ? $.model : $.set($.model).emit(EmailEditorEvents.Changed({
2321
+ value: {
2322
+ ...$.props.value,
2323
+ appearance: { ...$.props.value.appearance, [key]: value }
2324
+ }
2325
+ })),
2326
+ Setting: ($, { id, key, value }) => {
2327
+ const element = $.props.value.elements.find((item) => item.id === id);
2328
+ if ($.props.disabled || !element)
2329
+ return $.model;
2330
+ const updated = key === "destination" && element.type === "button" ? {
2331
+ ...element,
2332
+ destination: value === "__url" ? { type: "url", url: "https://example.com" } : { type: "variable", key: value }
2333
+ } : key === "url" && element.type === "button" ? { ...element, destination: { type: "url", url: value } } : {
2334
+ ...element,
2335
+ [key]: key === "width" || key === "height" || key === "paddingTop" || key === "paddingBottom" ? value === "" ? 0 : Number(value) : value
2336
+ };
2337
+ return $.set($.model).emit(EmailEditorEvents.Changed({
2338
+ value: replaceElement($.props.value, updated)
2339
+ }));
2340
+ }
2341
+ });
2342
+
2343
+ // ../../src/components/email-editor/react.tsx
2344
+ import { jsx as jsx9, jsxs as jsxs5, Fragment as Fragment3 } from "react/jsx-runtime";
2345
+ var EmailEditorSelect = ({
2346
+ label,
2347
+ value,
2348
+ options,
2349
+ disabled,
2350
+ onValueChange
2351
+ }) => /* @__PURE__ */ jsxs5(Select, {
2352
+ items: options,
2353
+ value,
2354
+ disabled,
2355
+ onValueChange: (value) => {
2356
+ if (value !== null)
2357
+ onValueChange(value);
2358
+ },
2359
+ children: [
2360
+ /* @__PURE__ */ jsx9(SelectTrigger, {
2361
+ "aria-label": label,
2362
+ className: "w-full min-w-0 text-xs",
2363
+ children: /* @__PURE__ */ jsx9(SelectValue, {})
2364
+ }),
2365
+ /* @__PURE__ */ jsx9(SelectContent, {
2366
+ align: "start",
2367
+ alignItemWithTrigger: false,
2368
+ children: options.map((option) => /* @__PURE__ */ jsx9(SelectItem, {
2369
+ value: option.value,
2370
+ children: option.label
2371
+ }, option.value))
2372
+ })
2373
+ ]
2374
+ });
1999
2375
  var icons = {
2000
2376
  text: Type,
2001
2377
  button: MousePointer2,
@@ -2005,12 +2381,8 @@ var icons = {
2005
2381
  divider: Minus,
2006
2382
  spacer: Space
2007
2383
  };
2008
- var fonts = {
2009
- sans: "Arial, sans-serif",
2010
- serif: "Georgia, serif",
2011
- mono: "'Courier New', monospace"
2012
- };
2013
2384
  var EmailEditor = ({
2385
+ classes: classOverrides,
2014
2386
  value,
2015
2387
  onChange,
2016
2388
  variables = [],
@@ -2020,18 +2392,15 @@ var EmailEditor = ({
2020
2392
  locale: override,
2021
2393
  messages
2022
2394
  }) => {
2395
+ const emailEditorClasses = resolveEmailEditorClasses(classOverrides);
2023
2396
  const locale = useKrakstackLocale3(override);
2024
- const copy = {
2025
- ...locale.startsWith("fr") ? labels3.fr : labels3.en,
2026
- ...messages?.[locale.split("-")[0] ?? locale],
2027
- ...messages?.[locale]
2028
- };
2029
- const [active, setActive] = useState4(value.elements.find((element) => element.type === "text")?.id ?? null);
2397
+ const copy = emailEditorMessages(locale, messages);
2398
+ const [active, setActive] = useState5(() => initialActive(value));
2030
2399
  const selected = value.elements.find((element) => element.id === active);
2031
- const [view, setView] = useState4("design");
2400
+ const [view, setView] = useState5("design");
2032
2401
  const canvas = useRef4(null);
2033
2402
  const elementSurfaces = useRef4(new Map);
2034
- const [settingsOpen, setSettingsOpen] = useState4(false);
2403
+ const [settingsOpen, setSettingsOpen] = useState5(false);
2035
2404
  const settingsAnchor = useMemo(() => settingsOpen ? {
2036
2405
  get contextElement() {
2037
2406
  return canvas.current ?? undefined;
@@ -2043,28 +2412,18 @@ var EmailEditor = ({
2043
2412
  }
2044
2413
  } : null, [active, settingsOpen]);
2045
2414
  const id = useId3();
2046
- const [insertOpen, setInsertOpen] = useState4(false);
2415
+ const [insertOpen, setInsertOpen] = useState5(false);
2047
2416
  const update = (element) => {
2048
2417
  if (!disabled)
2049
- onChange({
2050
- ...value,
2051
- elements: value.elements.map((item) => item.id === element.id ? element : item)
2052
- });
2418
+ onChange(replaceElement(value, element));
2053
2419
  };
2054
2420
  const add = (type) => {
2055
- const element = newEmailElement(type, {
2056
- id: crypto.randomUUID(),
2057
- text: copy.newText,
2058
- button: copy.newButton,
2059
- imageAlt: copy.newImage,
2060
- codeVariable: variables.find((variable) => variable.key === "code")?.key ?? variables.find((variable) => variable.type === "text")?.key,
2061
- urlVariable: variables.find((variable) => variable.type === "url")?.key
2062
- });
2421
+ const element = createElement(type, crypto.randomUUID(), copy, variables);
2063
2422
  onChange({ ...value, elements: [...value.elements, element] });
2064
2423
  setActive(element.id);
2065
2424
  };
2066
2425
  const field = (label, control) => /* @__PURE__ */ jsxs5("label", {
2067
- className: "grid min-w-0 gap-1.5 text-xs font-medium",
2426
+ className: emailEditorClasses.inspectorField,
2068
2427
  children: [
2069
2428
  label,
2070
2429
  control
@@ -2077,7 +2436,7 @@ var EmailEditor = ({
2077
2436
  };
2078
2437
  return /* @__PURE__ */ jsxs5("div", {
2079
2438
  "data-slot": "email-editor",
2080
- className: "min-w-0 space-y-4",
2439
+ className: emailEditorClasses.inspector,
2081
2440
  children: [
2082
2441
  /* @__PURE__ */ jsxs5(Tabs, {
2083
2442
  value: view,
@@ -2115,7 +2474,7 @@ var EmailEditor = ({
2115
2474
  className: "min-w-0 space-y-1.5",
2116
2475
  children: [
2117
2476
  /* @__PURE__ */ jsx9("p", {
2118
- className: "text-xs font-medium",
2477
+ className: emailEditorClasses.sectionHeading,
2119
2478
  children: label
2120
2479
  }),
2121
2480
  /* @__PURE__ */ jsx9(RichTextEditor, {
@@ -2258,7 +2617,7 @@ var EmailEditor = ({
2258
2617
  ...value,
2259
2618
  appearance: {
2260
2619
  ...value.appearance,
2261
- font: Schema7.decodeUnknownSync(EmailFont)(font)
2620
+ font: Schema11.decodeUnknownSync(EmailFont)(font)
2262
2621
  }
2263
2622
  })
2264
2623
  }))
@@ -2278,19 +2637,19 @@ var EmailEditor = ({
2278
2637
  "data-slot": "email-editor-canvas",
2279
2638
  className: "min-w-0 rounded-xl border p-3 sm:p-4",
2280
2639
  style: {
2281
- backgroundColor: Schema7.is(EmailColor)(value.appearance.background) ? value.appearance.background : "#f4f4f5"
2640
+ backgroundColor: Schema11.is(EmailColor)(value.appearance.background) ? value.appearance.background : "#f4f4f5"
2282
2641
  },
2283
2642
  children: /* @__PURE__ */ jsxs5("div", {
2284
2643
  className: "min-w-0 rounded-lg p-2 shadow-sm sm:p-3",
2285
2644
  style: {
2286
2645
  ...canvasVariables,
2287
- backgroundColor: Schema7.is(EmailColor)(value.appearance.surface) ? value.appearance.surface : "#ffffff",
2288
- color: Schema7.is(EmailColor)(value.appearance.text) ? value.appearance.text : "#18181b",
2646
+ backgroundColor: Schema11.is(EmailColor)(value.appearance.surface) ? value.appearance.surface : "#ffffff",
2647
+ color: Schema11.is(EmailColor)(value.appearance.text) ? value.appearance.text : "#18181b",
2289
2648
  fontFamily: fonts[value.appearance.font]
2290
2649
  },
2291
2650
  children: [
2292
2651
  !value.elements.length ? /* @__PURE__ */ jsx9("p", {
2293
- className: "p-8 text-center text-sm",
2652
+ className: emailEditorClasses.previewPlaceholder,
2294
2653
  children: copy.empty
2295
2654
  }) : null,
2296
2655
  /* @__PURE__ */ jsx9(AnimatedList, {
@@ -2396,11 +2755,11 @@ var EmailEditor = ({
2396
2755
  onClick: () => setActive(element.id),
2397
2756
  className: "w-full rounded-lg border border-[#e5e7eb] p-4 font-mono text-xl tracking-[0.2em]",
2398
2757
  children: `{{${element.variable}}}`
2399
- }) : element.type === "image" || element.type === "logo" ? Schema7.is(RichTextLink)(element.src) ? /* @__PURE__ */ jsx9("img", {
2758
+ }) : element.type === "image" || element.type === "logo" ? Schema11.is(RichTextLink)(element.src) ? /* @__PURE__ */ jsx9("img", {
2400
2759
  src: element.src,
2401
2760
  alt: element.alt,
2402
2761
  width: element.width,
2403
- className: "inline-block max-w-full"
2762
+ className: emailEditorClasses.image
2404
2763
  }) : /* @__PURE__ */ jsx9(Image, {
2405
2764
  className: "mx-auto size-8"
2406
2765
  }) : element.type === "divider" ? /* @__PURE__ */ jsx9("hr", {
@@ -2452,7 +2811,7 @@ var EmailEditor = ({
2452
2811
  ]
2453
2812
  }),
2454
2813
  !selected ? /* @__PURE__ */ jsx9("p", {
2455
- className: "text-muted-foreground text-xs",
2814
+ className: emailEditorClasses.metadata,
2456
2815
  children: copy.select
2457
2816
  }) : /* @__PURE__ */ jsxs5("div", {
2458
2817
  className: "grid min-w-0 items-end gap-3 sm:grid-cols-2 [&>label]:min-w-0",
@@ -2467,11 +2826,11 @@ var EmailEditor = ({
2467
2826
  })),
2468
2827
  onValueChange: (alignment) => update({
2469
2828
  ...selected,
2470
- alignment: Schema7.decodeUnknownSync(EmailAlignment)(alignment)
2829
+ alignment: Schema11.decodeUnknownSync(EmailAlignment)(alignment)
2471
2830
  })
2472
2831
  })),
2473
2832
  /* @__PURE__ */ jsx9("div", {
2474
- className: "grid grid-cols-2 gap-2",
2833
+ className: emailEditorClasses.actionGrid,
2475
2834
  children: ["paddingTop", "paddingBottom"].map((key) => /* @__PURE__ */ jsxs5("label", {
2476
2835
  className: "grid gap-1.5 text-[11px]",
2477
2836
  children: [
@@ -2601,20 +2960,9 @@ var EmailEditor = ({
2601
2960
  variant: "outline",
2602
2961
  disabled: disabled || value.elements.length >= 40,
2603
2962
  onClick: () => {
2604
- const duplicate = {
2605
- ...selected,
2606
- id: crypto.randomUUID()
2607
- };
2608
- const index = value.elements.findIndex((element) => element.id === selected.id);
2609
- onChange({
2610
- ...value,
2611
- elements: [
2612
- ...value.elements.slice(0, index + 1),
2613
- duplicate,
2614
- ...value.elements.slice(index + 1)
2615
- ]
2616
- });
2617
- setActive(duplicate.id);
2963
+ const id = crypto.randomUUID();
2964
+ onChange(duplicateElement(value, selected.id, id));
2965
+ setActive(id);
2618
2966
  },
2619
2967
  children: [
2620
2968
  /* @__PURE__ */ jsx9(Copy, {
@@ -2631,10 +2979,7 @@ var EmailEditor = ({
2631
2979
  disabled,
2632
2980
  onClick: () => {
2633
2981
  document.getElementById(`${id}-add`)?.focus();
2634
- onChange({
2635
- ...value,
2636
- elements: value.elements.filter((element) => element.id !== selected.id)
2637
- });
2982
+ onChange(removeElement(value, selected.id));
2638
2983
  setActive(null);
2639
2984
  setSettingsOpen(false);
2640
2985
  },
@@ -2657,7 +3002,7 @@ var EmailEditor = ({
2657
3002
  ]
2658
3003
  }),
2659
3004
  /* @__PURE__ */ jsx9("p", {
2660
- className: "text-muted-foreground text-xs",
3005
+ className: emailEditorClasses.metadata,
2661
3006
  children: copy.local
2662
3007
  })
2663
3008
  ]
@@ -2666,7 +3011,7 @@ var EmailEditor = ({
2666
3011
  }),
2667
3012
  invalid ? /* @__PURE__ */ jsx9("p", {
2668
3013
  role: "alert",
2669
- className: "text-destructive text-xs",
3014
+ className: emailEditorClasses.error,
2670
3015
  children: copy.invalid
2671
3016
  }) : null
2672
3017
  ]