@shware/workflow-ui 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (363) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +180 -2
  3. package/dist/assets/iphone-17-pro-DzaacWSl.png +0 -0
  4. package/dist/assets/pixel-10-pro-back-7MDj1_lz.webp +0 -0
  5. package/dist/assets/pixel-10-pro-mask-Bi1deQ9Y.webp +0 -0
  6. package/dist/cli.d.mts +1 -0
  7. package/dist/cli.mjs +673 -0
  8. package/dist/cli.mjs.map +1 -0
  9. package/dist/config.d.mts +247 -0
  10. package/dist/config.d.mts.map +1 -0
  11. package/dist/config.mjs +27 -0
  12. package/dist/config.mjs.map +1 -0
  13. package/dist/index.d.mts +451 -0
  14. package/dist/index.d.mts.map +1 -0
  15. package/dist/index.mjs +2722 -0
  16. package/dist/index.mjs.map +1 -0
  17. package/dist/postgres.d.mts +34 -0
  18. package/dist/postgres.d.mts.map +1 -0
  19. package/dist/postgres.mjs +313 -0
  20. package/dist/postgres.mjs.map +1 -0
  21. package/package.json +93 -3
  22. package/src/app/assets/devices/iphone-17-pro.png +0 -0
  23. package/src/app/assets/devices/pixel-10-pro-back.webp +0 -0
  24. package/src/app/assets/devices/pixel-10-pro-mask.webp +0 -0
  25. package/src/app/assets/flags/AC.svg +1 -0
  26. package/src/app/assets/flags/AD.svg +1 -0
  27. package/src/app/assets/flags/AE.svg +1 -0
  28. package/src/app/assets/flags/AF.svg +1 -0
  29. package/src/app/assets/flags/AG.svg +1 -0
  30. package/src/app/assets/flags/AI.svg +1 -0
  31. package/src/app/assets/flags/AL.svg +1 -0
  32. package/src/app/assets/flags/AM.svg +1 -0
  33. package/src/app/assets/flags/AO.svg +1 -0
  34. package/src/app/assets/flags/AQ.svg +1 -0
  35. package/src/app/assets/flags/AR.svg +1 -0
  36. package/src/app/assets/flags/AS.svg +1 -0
  37. package/src/app/assets/flags/AT.svg +1 -0
  38. package/src/app/assets/flags/AU.svg +1 -0
  39. package/src/app/assets/flags/AW.svg +1 -0
  40. package/src/app/assets/flags/AX.svg +1 -0
  41. package/src/app/assets/flags/AZ.svg +1 -0
  42. package/src/app/assets/flags/BA.svg +1 -0
  43. package/src/app/assets/flags/BB.svg +1 -0
  44. package/src/app/assets/flags/BD.svg +1 -0
  45. package/src/app/assets/flags/BE.svg +1 -0
  46. package/src/app/assets/flags/BF.svg +1 -0
  47. package/src/app/assets/flags/BG.svg +1 -0
  48. package/src/app/assets/flags/BH.svg +1 -0
  49. package/src/app/assets/flags/BI.svg +1 -0
  50. package/src/app/assets/flags/BJ.svg +1 -0
  51. package/src/app/assets/flags/BL.svg +1 -0
  52. package/src/app/assets/flags/BM.svg +1 -0
  53. package/src/app/assets/flags/BN.svg +1 -0
  54. package/src/app/assets/flags/BO.svg +1 -0
  55. package/src/app/assets/flags/BQ-BO.svg +1 -0
  56. package/src/app/assets/flags/BQ-SA.svg +1 -0
  57. package/src/app/assets/flags/BQ-SE.svg +1 -0
  58. package/src/app/assets/flags/BQ.svg +1 -0
  59. package/src/app/assets/flags/BR.svg +1 -0
  60. package/src/app/assets/flags/BS.svg +1 -0
  61. package/src/app/assets/flags/BT.svg +1 -0
  62. package/src/app/assets/flags/BV.svg +1 -0
  63. package/src/app/assets/flags/BW.svg +1 -0
  64. package/src/app/assets/flags/BY.svg +1 -0
  65. package/src/app/assets/flags/BZ.svg +1 -0
  66. package/src/app/assets/flags/CA.svg +1 -0
  67. package/src/app/assets/flags/CC.svg +1 -0
  68. package/src/app/assets/flags/CD.svg +1 -0
  69. package/src/app/assets/flags/CF.svg +1 -0
  70. package/src/app/assets/flags/CG.svg +1 -0
  71. package/src/app/assets/flags/CH.svg +1 -0
  72. package/src/app/assets/flags/CI.svg +1 -0
  73. package/src/app/assets/flags/CK.svg +1 -0
  74. package/src/app/assets/flags/CL.svg +1 -0
  75. package/src/app/assets/flags/CM.svg +1 -0
  76. package/src/app/assets/flags/CN.svg +1 -0
  77. package/src/app/assets/flags/CO.svg +1 -0
  78. package/src/app/assets/flags/CR.svg +1 -0
  79. package/src/app/assets/flags/CU.svg +1 -0
  80. package/src/app/assets/flags/CV.svg +1 -0
  81. package/src/app/assets/flags/CW.svg +1 -0
  82. package/src/app/assets/flags/CX.svg +1 -0
  83. package/src/app/assets/flags/CY.svg +1 -0
  84. package/src/app/assets/flags/CZ.svg +1 -0
  85. package/src/app/assets/flags/DE.svg +1 -0
  86. package/src/app/assets/flags/DJ.svg +1 -0
  87. package/src/app/assets/flags/DK.svg +1 -0
  88. package/src/app/assets/flags/DM.svg +1 -0
  89. package/src/app/assets/flags/DO.svg +1 -0
  90. package/src/app/assets/flags/DZ.svg +1 -0
  91. package/src/app/assets/flags/EC.svg +1 -0
  92. package/src/app/assets/flags/EE.svg +1 -0
  93. package/src/app/assets/flags/EG.svg +1 -0
  94. package/src/app/assets/flags/EH.svg +1 -0
  95. package/src/app/assets/flags/ER.svg +1 -0
  96. package/src/app/assets/flags/ES-CT.svg +1 -0
  97. package/src/app/assets/flags/ES.svg +1 -0
  98. package/src/app/assets/flags/ET.svg +1 -0
  99. package/src/app/assets/flags/EU.svg +1 -0
  100. package/src/app/assets/flags/FI.svg +1 -0
  101. package/src/app/assets/flags/FJ.svg +1 -0
  102. package/src/app/assets/flags/FK.svg +1 -0
  103. package/src/app/assets/flags/FM.svg +1 -0
  104. package/src/app/assets/flags/FO.svg +1 -0
  105. package/src/app/assets/flags/FR.svg +1 -0
  106. package/src/app/assets/flags/GA.svg +1 -0
  107. package/src/app/assets/flags/GB-ENG.svg +1 -0
  108. package/src/app/assets/flags/GB-NIR.svg +1 -0
  109. package/src/app/assets/flags/GB-SCT.svg +1 -0
  110. package/src/app/assets/flags/GB-WLS.svg +1 -0
  111. package/src/app/assets/flags/GB.svg +1 -0
  112. package/src/app/assets/flags/GD.svg +1 -0
  113. package/src/app/assets/flags/GE.svg +1 -0
  114. package/src/app/assets/flags/GF.svg +1 -0
  115. package/src/app/assets/flags/GG.svg +1 -0
  116. package/src/app/assets/flags/GH.svg +1 -0
  117. package/src/app/assets/flags/GI.svg +1 -0
  118. package/src/app/assets/flags/GL.svg +1 -0
  119. package/src/app/assets/flags/GM.svg +1 -0
  120. package/src/app/assets/flags/GN.svg +1 -0
  121. package/src/app/assets/flags/GP.svg +1 -0
  122. package/src/app/assets/flags/GQ.svg +1 -0
  123. package/src/app/assets/flags/GR.svg +1 -0
  124. package/src/app/assets/flags/GS.svg +1 -0
  125. package/src/app/assets/flags/GT.svg +1 -0
  126. package/src/app/assets/flags/GU.svg +1 -0
  127. package/src/app/assets/flags/GW.svg +1 -0
  128. package/src/app/assets/flags/GY.svg +1 -0
  129. package/src/app/assets/flags/HK.svg +1 -0
  130. package/src/app/assets/flags/HM.svg +1 -0
  131. package/src/app/assets/flags/HN.svg +1 -0
  132. package/src/app/assets/flags/HR.svg +1 -0
  133. package/src/app/assets/flags/HT.svg +1 -0
  134. package/src/app/assets/flags/HU.svg +1 -0
  135. package/src/app/assets/flags/IC.svg +1 -0
  136. package/src/app/assets/flags/ID.svg +1 -0
  137. package/src/app/assets/flags/IE.svg +1 -0
  138. package/src/app/assets/flags/IL.svg +1 -0
  139. package/src/app/assets/flags/IM.svg +1 -0
  140. package/src/app/assets/flags/IN.svg +1 -0
  141. package/src/app/assets/flags/IO.svg +1 -0
  142. package/src/app/assets/flags/IQ.svg +1 -0
  143. package/src/app/assets/flags/IR.svg +1 -0
  144. package/src/app/assets/flags/IS.svg +1 -0
  145. package/src/app/assets/flags/IT.svg +1 -0
  146. package/src/app/assets/flags/JE.svg +1 -0
  147. package/src/app/assets/flags/JM.svg +1 -0
  148. package/src/app/assets/flags/JO.svg +1 -0
  149. package/src/app/assets/flags/JP.svg +1 -0
  150. package/src/app/assets/flags/KE.svg +1 -0
  151. package/src/app/assets/flags/KG.svg +1 -0
  152. package/src/app/assets/flags/KH.svg +1 -0
  153. package/src/app/assets/flags/KI.svg +1 -0
  154. package/src/app/assets/flags/KM.svg +1 -0
  155. package/src/app/assets/flags/KN.svg +1 -0
  156. package/src/app/assets/flags/KP.svg +1 -0
  157. package/src/app/assets/flags/KR.svg +1 -0
  158. package/src/app/assets/flags/KW.svg +1 -0
  159. package/src/app/assets/flags/KY.svg +1 -0
  160. package/src/app/assets/flags/KZ.svg +1 -0
  161. package/src/app/assets/flags/LA.svg +1 -0
  162. package/src/app/assets/flags/LB.svg +1 -0
  163. package/src/app/assets/flags/LC.svg +1 -0
  164. package/src/app/assets/flags/LI.svg +1 -0
  165. package/src/app/assets/flags/LK.svg +1 -0
  166. package/src/app/assets/flags/LR.svg +1 -0
  167. package/src/app/assets/flags/LS.svg +1 -0
  168. package/src/app/assets/flags/LT.svg +1 -0
  169. package/src/app/assets/flags/LU.svg +1 -0
  170. package/src/app/assets/flags/LV.svg +1 -0
  171. package/src/app/assets/flags/LY.svg +1 -0
  172. package/src/app/assets/flags/MA.svg +1 -0
  173. package/src/app/assets/flags/MC.svg +1 -0
  174. package/src/app/assets/flags/MD.svg +1 -0
  175. package/src/app/assets/flags/ME.svg +1 -0
  176. package/src/app/assets/flags/MF.svg +1 -0
  177. package/src/app/assets/flags/MG.svg +1 -0
  178. package/src/app/assets/flags/MH.svg +1 -0
  179. package/src/app/assets/flags/MK.svg +1 -0
  180. package/src/app/assets/flags/ML.svg +1 -0
  181. package/src/app/assets/flags/MM.svg +1 -0
  182. package/src/app/assets/flags/MN.svg +1 -0
  183. package/src/app/assets/flags/MO.svg +1 -0
  184. package/src/app/assets/flags/MP.svg +1 -0
  185. package/src/app/assets/flags/MQ.svg +1 -0
  186. package/src/app/assets/flags/MR.svg +1 -0
  187. package/src/app/assets/flags/MS.svg +1 -0
  188. package/src/app/assets/flags/MT.svg +1 -0
  189. package/src/app/assets/flags/MU.svg +1 -0
  190. package/src/app/assets/flags/MV.svg +1 -0
  191. package/src/app/assets/flags/MW.svg +1 -0
  192. package/src/app/assets/flags/MX.svg +1 -0
  193. package/src/app/assets/flags/MY.svg +1 -0
  194. package/src/app/assets/flags/MZ.svg +1 -0
  195. package/src/app/assets/flags/NA.svg +1 -0
  196. package/src/app/assets/flags/NC.svg +1 -0
  197. package/src/app/assets/flags/NE.svg +1 -0
  198. package/src/app/assets/flags/NF.svg +1 -0
  199. package/src/app/assets/flags/NG.svg +1 -0
  200. package/src/app/assets/flags/NI.svg +1 -0
  201. package/src/app/assets/flags/NL.svg +1 -0
  202. package/src/app/assets/flags/NO.svg +1 -0
  203. package/src/app/assets/flags/NP.svg +1 -0
  204. package/src/app/assets/flags/NR.svg +1 -0
  205. package/src/app/assets/flags/NU.svg +1 -0
  206. package/src/app/assets/flags/NZ.svg +1 -0
  207. package/src/app/assets/flags/OM.svg +1 -0
  208. package/src/app/assets/flags/PA.svg +1 -0
  209. package/src/app/assets/flags/PE.svg +1 -0
  210. package/src/app/assets/flags/PF.svg +1 -0
  211. package/src/app/assets/flags/PG.svg +1 -0
  212. package/src/app/assets/flags/PH.svg +1 -0
  213. package/src/app/assets/flags/PK.svg +1 -0
  214. package/src/app/assets/flags/PL.svg +1 -0
  215. package/src/app/assets/flags/PM.svg +1 -0
  216. package/src/app/assets/flags/PN.svg +1 -0
  217. package/src/app/assets/flags/PR.svg +1 -0
  218. package/src/app/assets/flags/PS.svg +1 -0
  219. package/src/app/assets/flags/PT.svg +1 -0
  220. package/src/app/assets/flags/PW.svg +1 -0
  221. package/src/app/assets/flags/PY.svg +1 -0
  222. package/src/app/assets/flags/QA.svg +1 -0
  223. package/src/app/assets/flags/RE.svg +1 -0
  224. package/src/app/assets/flags/README.md +6 -0
  225. package/src/app/assets/flags/RO.svg +1 -0
  226. package/src/app/assets/flags/RS.svg +1 -0
  227. package/src/app/assets/flags/RU.svg +1 -0
  228. package/src/app/assets/flags/RW.svg +1 -0
  229. package/src/app/assets/flags/SA.svg +1 -0
  230. package/src/app/assets/flags/SB.svg +1 -0
  231. package/src/app/assets/flags/SC.svg +1 -0
  232. package/src/app/assets/flags/SD.svg +1 -0
  233. package/src/app/assets/flags/SE.svg +1 -0
  234. package/src/app/assets/flags/SG.svg +1 -0
  235. package/src/app/assets/flags/SH.svg +1 -0
  236. package/src/app/assets/flags/SI.svg +1 -0
  237. package/src/app/assets/flags/SJ.svg +1 -0
  238. package/src/app/assets/flags/SK.svg +1 -0
  239. package/src/app/assets/flags/SL.svg +1 -0
  240. package/src/app/assets/flags/SM.svg +1 -0
  241. package/src/app/assets/flags/SN.svg +1 -0
  242. package/src/app/assets/flags/SO.svg +1 -0
  243. package/src/app/assets/flags/SR.svg +1 -0
  244. package/src/app/assets/flags/SS.svg +1 -0
  245. package/src/app/assets/flags/ST.svg +1 -0
  246. package/src/app/assets/flags/SV.svg +1 -0
  247. package/src/app/assets/flags/SX.svg +1 -0
  248. package/src/app/assets/flags/SY.svg +1 -0
  249. package/src/app/assets/flags/SZ.svg +1 -0
  250. package/src/app/assets/flags/TA.svg +1 -0
  251. package/src/app/assets/flags/TC.svg +1 -0
  252. package/src/app/assets/flags/TD.svg +1 -0
  253. package/src/app/assets/flags/TF.svg +1 -0
  254. package/src/app/assets/flags/TG.svg +1 -0
  255. package/src/app/assets/flags/TH.svg +1 -0
  256. package/src/app/assets/flags/TJ.svg +1 -0
  257. package/src/app/assets/flags/TK.svg +1 -0
  258. package/src/app/assets/flags/TL.svg +1 -0
  259. package/src/app/assets/flags/TM.svg +1 -0
  260. package/src/app/assets/flags/TN.svg +1 -0
  261. package/src/app/assets/flags/TO.svg +1 -0
  262. package/src/app/assets/flags/TR.svg +1 -0
  263. package/src/app/assets/flags/TT.svg +1 -0
  264. package/src/app/assets/flags/TV.svg +1 -0
  265. package/src/app/assets/flags/TW.svg +1 -0
  266. package/src/app/assets/flags/TZ.svg +1 -0
  267. package/src/app/assets/flags/UA.svg +1 -0
  268. package/src/app/assets/flags/UG.svg +1 -0
  269. package/src/app/assets/flags/UM.svg +1 -0
  270. package/src/app/assets/flags/US.svg +1 -0
  271. package/src/app/assets/flags/UY.svg +1 -0
  272. package/src/app/assets/flags/UZ.svg +1 -0
  273. package/src/app/assets/flags/VA.svg +1 -0
  274. package/src/app/assets/flags/VC.svg +1 -0
  275. package/src/app/assets/flags/VE.svg +1 -0
  276. package/src/app/assets/flags/VG.svg +1 -0
  277. package/src/app/assets/flags/VI.svg +1 -0
  278. package/src/app/assets/flags/VN.svg +1 -0
  279. package/src/app/assets/flags/VU.svg +1 -0
  280. package/src/app/assets/flags/WF.svg +1 -0
  281. package/src/app/assets/flags/WS.svg +1 -0
  282. package/src/app/assets/flags/XA.svg +1 -0
  283. package/src/app/assets/flags/XC.svg +1 -0
  284. package/src/app/assets/flags/XK.svg +1 -0
  285. package/src/app/assets/flags/XO.svg +1 -0
  286. package/src/app/assets/flags/YE.svg +1 -0
  287. package/src/app/assets/flags/YT.svg +1 -0
  288. package/src/app/assets/flags/ZA.svg +1 -0
  289. package/src/app/assets/flags/ZM.svg +1 -0
  290. package/src/app/assets/flags/ZW.svg +1 -0
  291. package/src/app/email-preview.ts +46 -0
  292. package/src/app/index.css +203 -0
  293. package/src/app/index.html +12 -0
  294. package/src/app/integrations/i18n/react-i18next.d.ts +11 -0
  295. package/src/app/integrations/i18n/root-provider.tsx +62 -0
  296. package/src/app/integrations/tanstack-query/devtools.tsx +6 -0
  297. package/src/app/integrations/tanstack-query/root-provider.tsx +37 -0
  298. package/src/app/integrations/theme/root-provider.tsx +75 -0
  299. package/src/app/integrations/toast/toast-provider.tsx +46 -0
  300. package/src/app/locales/en-US/common.ts +268 -0
  301. package/src/app/locales/zh-CN/common.ts +263 -0
  302. package/src/app/main.tsx +40 -0
  303. package/src/app/page-chrome.tsx +79 -0
  304. package/src/app/router.tsx +40 -0
  305. package/src/app/routes/__root.tsx +293 -0
  306. package/src/app/routes/emails.tsx +199 -0
  307. package/src/app/routes/home.tsx +87 -0
  308. package/src/app/routes/index.ts +19 -0
  309. package/src/app/routes/metrics.tsx +541 -0
  310. package/src/app/routes/segment-overview.tsx +211 -0
  311. package/src/app/routes/segments.tsx +236 -0
  312. package/src/app/routes/settings.tsx +90 -0
  313. package/src/app/routes/workflows.tsx +348 -0
  314. package/src/app/studio.ts +16 -0
  315. package/src/app/svg.d.ts +17 -0
  316. package/src/app/virtual-config.d.ts +6 -0
  317. package/src/cli.ts +110 -0
  318. package/src/components/avatar.tsx +57 -0
  319. package/src/components/breadcrumb.tsx +49 -0
  320. package/src/components/button/index.tsx +86 -0
  321. package/src/components/channel-icon.ts +39 -0
  322. package/src/components/chat-markup.tsx +109 -0
  323. package/src/components/corner-shape.ts +13 -0
  324. package/src/components/date-range.tsx +181 -0
  325. package/src/components/discord-preview.tsx +165 -0
  326. package/src/components/dropdown/index.tsx +172 -0
  327. package/src/components/email-defaults.tsx +40 -0
  328. package/src/components/email-list.tsx +149 -0
  329. package/src/components/email-thumbnail.tsx +123 -0
  330. package/src/components/flag.tsx +40 -0
  331. package/src/components/input/index.tsx +40 -0
  332. package/src/components/input/search-input.tsx +24 -0
  333. package/src/components/layout.ts +403 -0
  334. package/src/components/menu/index.tsx +118 -0
  335. package/src/components/metric-card.tsx +321 -0
  336. package/src/components/modal/index.tsx +70 -0
  337. package/src/components/nav-drawer.tsx +84 -0
  338. package/src/components/node-inspector.tsx +242 -0
  339. package/src/components/profile-drawer.tsx +331 -0
  340. package/src/components/push-preview.tsx +470 -0
  341. package/src/components/push-thumbnail.tsx +78 -0
  342. package/src/components/segment-list.tsx +184 -0
  343. package/src/components/select/index.tsx +70 -0
  344. package/src/components/series-chart.tsx +120 -0
  345. package/src/components/slack-preview.tsx +223 -0
  346. package/src/components/sparkline.tsx +58 -0
  347. package/src/components/tabs/index.tsx +45 -0
  348. package/src/components/template-refs.ts +110 -0
  349. package/src/components/templates-page.tsx +601 -0
  350. package/src/components/textarea/index.tsx +37 -0
  351. package/src/components/thumbnail-window.tsx +65 -0
  352. package/src/components/workflow-canvas.tsx +503 -0
  353. package/src/components/workflow-list.tsx +231 -0
  354. package/src/config.ts +288 -0
  355. package/src/generate.ts +56 -0
  356. package/src/index.ts +35 -0
  357. package/src/postgres.ts +415 -0
  358. package/src/server/project.ts +290 -0
  359. package/src/server.ts +500 -0
  360. package/src/utils/cn.ts +6 -0
  361. package/src/utils/label.ts +12 -0
  362. package/src/utils/lookup.ts +11 -0
  363. package/src/utils/template-content.ts +213 -0
@@ -0,0 +1,293 @@
1
+ import type { QueryClient } from '@tanstack/react-query';
2
+ import { Link, Outlet, createRootRouteWithContext } from '@tanstack/react-router';
3
+ import { clsx } from 'clsx';
4
+ import type { i18n as I18n } from 'i18next';
5
+ import {
6
+ Home,
7
+ LayoutTemplate,
8
+ Menu,
9
+ PanelLeftClose,
10
+ PanelLeftOpen,
11
+ Settings,
12
+ Users,
13
+ Workflow,
14
+ } from 'lucide-react';
15
+ import { useCallback, useState } from 'react';
16
+ import { useTranslation } from 'react-i18next';
17
+ import { superellipse } from '../../components/corner-shape';
18
+ import { NavDrawer } from '../../components/nav-drawer';
19
+ import type { ResolvedStudioConfig, StudioError } from '../../config';
20
+ import { ToastProvider } from '../integrations/toast/toast-provider';
21
+ import { PageChromeProvider, useChromeSlotRef } from '../page-chrome';
22
+
23
+ /**
24
+ * Shell: one full-height sidebar down the left, carrying the brand at its top,
25
+ * and one header across the top of everything to its right. The header is the
26
+ * only bar: sidebar toggle, then a breadcrumb saying where you are, an optional
27
+ * centred title, and the view's actions on the right. Views fill it through
28
+ * PageChrome rather than drawing bars of their own, so every page reads the
29
+ * same way and the toggle is reachable whether the rail is open or shut.
30
+ *
31
+ * Routes are defined in code rather than by file convention. The studio ships
32
+ * inside a package, so a file-based `routeTree.gen.ts` would have to be written
33
+ * into the consumer's node_modules at dev time — code-based routing keeps the
34
+ * package read-only.
35
+ */
36
+ export interface RouterContext {
37
+ queryClient: QueryClient;
38
+ config: ResolvedStudioConfig;
39
+ i18n: I18n;
40
+ }
41
+
42
+ const NAV = [
43
+ { to: '/', label: 'nav.home', icon: Home, exact: true },
44
+ { to: '/workflows', label: 'nav.workflows', icon: Workflow, exact: false },
45
+ { to: '/segments', label: 'nav.segments', icon: Users, exact: false },
46
+ { to: '/templates', label: 'nav.templates', icon: LayoutTemplate, exact: false },
47
+ { to: '/settings', label: 'nav.settings', icon: Settings, exact: true },
48
+ ] as const;
49
+
50
+ const COLLAPSED_KEY = 'workflow-ui-sidebar-collapsed';
51
+
52
+ /**
53
+ * Read synchronously in the initializer, not in an effect: the sidebar's width
54
+ * is layout, so recovering it a frame late would shove the whole view sideways
55
+ * on every load.
56
+ */
57
+ const readCollapsed = () =>
58
+ typeof localStorage !== 'undefined' && localStorage.getItem(COLLAPSED_KEY) === 'true';
59
+
60
+ function RootLayout() {
61
+ return (
62
+ <PageChromeProvider>
63
+ <Shell />
64
+ </PageChromeProvider>
65
+ );
66
+ }
67
+
68
+ /**
69
+ * The header's three tracks: [toggle + breadcrumb] [title] [actions]. Equal
70
+ * outer tracks keep the title dead-centre while space allows and squeeze the
71
+ * sides — never overlap them — when it does not.
72
+ */
73
+ function Header({
74
+ collapsed,
75
+ onToggle,
76
+ onOpenNav,
77
+ }: {
78
+ collapsed: boolean;
79
+ onToggle: () => void;
80
+ /** Below `md` there is no rail to collapse; the same slot opens the drawer. */
81
+ onOpenNav: () => void;
82
+ }) {
83
+ const { t } = useTranslation();
84
+ const breadcrumbRef = useChromeSlotRef('breadcrumb');
85
+ const titleRef = useChromeSlotRef('title');
86
+ const actionsRef = useChromeSlotRef('actions');
87
+
88
+ /*
89
+ * Sticky rather than a fixed row above the scroller — see Shell for why the
90
+ * whole column scrolls. It is the *only* thing that pins: search rows and
91
+ * table heads used to stack under it and the result read as three bars of
92
+ * chrome, so they scroll away now and the header alone stays. z-20 rather
93
+ * than higher so a drawer's scrim (also z-20, and later in the tree) dims it.
94
+ */
95
+ return (
96
+ <header className="border-border bg-card sticky top-0 z-20 grid h-14 grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] items-center gap-3 border-b px-4">
97
+ <div className="flex min-w-0 items-center gap-3">
98
+ {/*
99
+ Two buttons in one slot rather than one button with two behaviours:
100
+ the icon, the label and the action all differ, and exactly one is
101
+ rendered at any width, so the breadcrumb never shifts. Deciding in JS
102
+ would mean measuring the viewport to draw a button.
103
+ */}
104
+ {/* Its own label rather than the rail's: this opens a drawer over the
105
+ page, it does not widen anything. */}
106
+ <button
107
+ type="button"
108
+ onClick={onOpenNav}
109
+ aria-label={t('nav.menu')}
110
+ title={t('nav.menu')}
111
+ className="text-muted hover:bg-hover hover:text-primary flex size-8 shrink-0 items-center justify-center rounded-lg transition-colors md:hidden"
112
+ style={superellipse}
113
+ >
114
+ <Menu className="size-4" strokeWidth={2} />
115
+ </button>
116
+ <button
117
+ type="button"
118
+ onClick={onToggle}
119
+ aria-label={t(collapsed ? 'nav.expand' : 'nav.collapse')}
120
+ title={t(collapsed ? 'nav.expand' : 'nav.collapse')}
121
+ className="text-muted hover:bg-hover hover:text-primary hidden size-8 shrink-0 items-center justify-center rounded-lg transition-colors md:flex"
122
+ style={superellipse}
123
+ >
124
+ {collapsed ? (
125
+ <PanelLeftOpen className="size-4" strokeWidth={2} />
126
+ ) : (
127
+ <PanelLeftClose className="size-4" strokeWidth={2} />
128
+ )}
129
+ </button>
130
+ <div ref={breadcrumbRef} className="flex min-w-0 items-center" />
131
+ </div>
132
+ {/*
133
+ Never hidden when empty. display:none takes the title out of the grid,
134
+ and the actions div then auto-places into this auto-sized track instead
135
+ of the right-hand one — the actions end up hugging the breadcrumb. Empty,
136
+ the auto track is 0px, which is all "hidden" would have bought.
137
+ */}
138
+ <div ref={titleRef} className="text-sm font-semibold" />
139
+ <div ref={actionsRef} className="flex items-center justify-end gap-2" />
140
+ </header>
141
+ );
142
+ }
143
+
144
+ /**
145
+ * The project failed to load or to compile. Shown in place of every view —
146
+ * a list of nothing would read as "this project has no workflows". The
147
+ * message is compileConfig's own, which names the workflow and the node.
148
+ */
149
+ function ProjectError({ error }: { error: StudioError }) {
150
+ const { t } = useTranslation();
151
+ return (
152
+ <div className="flex flex-1 items-center justify-center p-8">
153
+ <div
154
+ role="alert"
155
+ className="max-w-2xl rounded-2xl border border-red-200 bg-red-50 p-6 text-sm text-red-700 dark:border-red-400/20 dark:bg-red-400/10 dark:text-red-300"
156
+ style={superellipse}
157
+ >
158
+ <p className="font-medium">{t(`project.error.${error.kind}`)}</p>
159
+ <pre className="mt-3 font-mono text-xs break-words whitespace-pre-wrap">
160
+ {error.message}
161
+ </pre>
162
+ <p className="mt-3 text-xs opacity-80">{t('project.errorHint')}</p>
163
+ </div>
164
+ </div>
165
+ );
166
+ }
167
+
168
+ function Shell() {
169
+ const { t } = useTranslation();
170
+ const { config } = Route.useRouteContext();
171
+ const [collapsed, setCollapsed] = useState(readCollapsed);
172
+ /* Narrow viewports only; never persisted — a drawer is a gesture, not a layout. */
173
+ const [navOpen, setNavOpen] = useState(false);
174
+
175
+ const toggle = useCallback(() => {
176
+ setCollapsed((open) => {
177
+ localStorage.setItem(COLLAPSED_KEY, String(!open));
178
+ return !open;
179
+ });
180
+ }, []);
181
+
182
+ const closeNav = useCallback(() => setNavOpen(false), []);
183
+
184
+ /*
185
+ * Identical padding in both states, so the icon sits at the same x whether the
186
+ * rail is open or shut and the collapse animates as pure width. Centring the
187
+ * icon instead would apply the moment the class flips, throwing it to the
188
+ * middle of a still-full-width panel and then dragging it back left as the
189
+ * width caught up — the animation read as a bounce.
190
+ *
191
+ * That fixes the rail's width too: 12px of nav padding + 12px of item padding
192
+ * + a 16px icon + 12px, i.e. 64px, is what leaves the icon centred once shut.
193
+ *
194
+ * The height is pinned for the same reason it is not padded: with `py-2` the
195
+ * box was as tall as its content, so losing the label shrank every item by
196
+ * 4px the instant the state flipped.
197
+ */
198
+ const itemClass = clsx(
199
+ 'flex h-9 items-center gap-2.5 rounded-lg px-3 text-sm font-medium',
200
+ 'text-secondary hover:bg-hover overflow-hidden whitespace-nowrap transition-colors'
201
+ );
202
+
203
+ return (
204
+ <div className="text-primary flex h-full font-sans">
205
+ {/* Gone below `md`, not merely narrowed: 64px of icons is a fifth of a
206
+ phone's width, and the drawer below carries the same items. */}
207
+ <aside
208
+ className={clsx(
209
+ 'border-border bg-card hidden shrink-0 flex-col overflow-hidden border-r md:flex',
210
+ 'transition-[width] duration-200 ease-out',
211
+ collapsed ? 'w-16' : 'w-60'
212
+ )}
213
+ >
214
+ <div className="flex h-14 shrink-0 items-center gap-2.5 px-4">
215
+ <div
216
+ className="bg-primary flex size-7 shrink-0 items-center justify-center rounded-lg"
217
+ style={superellipse}
218
+ >
219
+ <Workflow className="text-card size-4" strokeWidth={2} />
220
+ </div>
221
+ {!collapsed && (
222
+ <strong className="text-sm font-semibold whitespace-nowrap">Workflow Studio</strong>
223
+ )}
224
+ </div>
225
+
226
+ <nav className="flex flex-col gap-1.5 p-3 pt-1">
227
+ {NAV.map((item) => (
228
+ <Link
229
+ key={item.to}
230
+ to={item.to}
231
+ activeOptions={{ exact: item.exact }}
232
+ className={itemClass}
233
+ activeProps={{ className: '!bg-selected !text-primary' }}
234
+ style={superellipse}
235
+ title={collapsed ? t(item.label) : undefined}
236
+ >
237
+ <item.icon className="size-4 shrink-0" strokeWidth={2} />
238
+ {!collapsed && t(item.label)}
239
+ </Link>
240
+ ))}
241
+ </nav>
242
+ </aside>
243
+
244
+ {/*
245
+ One scrollport for everything right of the rail. The column used to be
246
+ a flex stack whose content area scrolled, which drew a short bar inset
247
+ below the header; scrolling the column itself runs the bar the full
248
+ height of the viewport and lets the header ride along as `sticky`.
249
+ Views must therefore not scroll internally — the canvas is the one
250
+ exception, and it says so at its own root.
251
+ */}
252
+ <div className="bg-page min-w-0 flex-1 overflow-y-auto">
253
+ <Header collapsed={collapsed} onToggle={toggle} onOpenNav={() => setNavOpen(true)} />
254
+ {/*
255
+ A short page still has to fill the viewport: empty states centre in
256
+ it and the preview stages paint their dot grid across it. The
257
+ percentage resolves because the scrollport's own height is definite,
258
+ and a long page simply outgrows the minimum.
259
+ */}
260
+ <main className="flex min-h-[calc(100%-3.5rem)] min-w-0 flex-col">
261
+ {config.error !== undefined ? <ProjectError error={config.error} /> : <Outlet />}
262
+ </main>
263
+ </div>
264
+
265
+ {/* After the content column, not before it: the scrim and the header
266
+ are both z-20, so only tree order puts the scrim over the header. */}
267
+ <NavDrawer open={navOpen} onClose={closeNav}>
268
+ {NAV.map((item) => (
269
+ <Link
270
+ key={item.to}
271
+ to={item.to}
272
+ activeOptions={{ exact: item.exact }}
273
+ className={itemClass}
274
+ activeProps={{ className: '!bg-selected !text-primary' }}
275
+ style={superellipse}
276
+ /* Picking a destination is the drawer's whole job; staying open
277
+ after the page behind it changed would only hide the answer. */
278
+ onClick={closeNav}
279
+ >
280
+ <item.icon className="size-4 shrink-0" strokeWidth={2} />
281
+ {t(item.label)}
282
+ </Link>
283
+ ))}
284
+ </NavDrawer>
285
+
286
+ <ToastProvider />
287
+ </div>
288
+ );
289
+ }
290
+
291
+ export const Route = createRootRouteWithContext<RouterContext>()({
292
+ component: RootLayout,
293
+ });
@@ -0,0 +1,199 @@
1
+ import { createRoute, useNavigate } from '@tanstack/react-router';
2
+ import { useMemo, useState } from 'react';
3
+ import { useTranslation } from 'react-i18next';
4
+ import { Breadcrumb } from '../../components/breadcrumb';
5
+ import { EmailList, type EmailListItem } from '../../components/email-list';
6
+ import { SearchInput } from '../../components/input/search-input';
7
+ import { collectTemplates } from '../../components/template-refs';
8
+ import { TemplatesPage } from '../../components/templates-page';
9
+ import { displayName } from '../../utils/label';
10
+ import { type Props, lookupTemplate } from '../../utils/template-content';
11
+ import { useEmailPreview } from '../email-preview';
12
+ import { useTheme } from '../integrations/theme/root-provider';
13
+ import { PageChrome } from '../page-chrome';
14
+ import { Route as rootRoute } from './__root';
15
+
16
+ /* ---------------------------------- List ---------------------------------- */
17
+
18
+ function EmailsIndex() {
19
+ const { config } = emailsIndexRoute.useRouteContext();
20
+ const navigate = useNavigate();
21
+ const { t } = useTranslation();
22
+ const [query, setQuery] = useState('');
23
+
24
+ const items = useMemo(() => {
25
+ const refs = collectTemplates(Object.values(config.workflows), config);
26
+ return refs.map((ref) => {
27
+ // Each channel reads its own registry — a push key is registered in `pushes`,
28
+ // a chat key in the registry named after its client
29
+ const found = lookupTemplate(config, ref.channel, ref.key);
30
+ const labels = { name: found?.entry.title, description: found?.entry.description };
31
+ const item: EmailListItem = {
32
+ key: ref.key,
33
+ channel: ref.channel,
34
+ registered: found !== undefined,
35
+ };
36
+ if (labels.name !== undefined) item.name = labels.name;
37
+ if (labels.description !== undefined) item.description = labels.description;
38
+ return item;
39
+ });
40
+ }, [config]);
41
+
42
+ /* Substring match over everything a template is known by: key, name, description. */
43
+ const filtered = useMemo(() => {
44
+ const needle = query.trim().toLowerCase();
45
+ if (needle === '') return items;
46
+ return items.filter((item) =>
47
+ [item.key, item.name ?? '', item.description ?? ''].some((text) =>
48
+ text.toLowerCase().includes(needle)
49
+ )
50
+ );
51
+ }, [items, query]);
52
+
53
+ if (items.length === 0) {
54
+ return (
55
+ <div className="text-muted flex flex-1 items-center justify-center text-sm">
56
+ {t('emails.empty')}
57
+ </div>
58
+ );
59
+ }
60
+
61
+ return (
62
+ /* Nothing here scrolls: the shell's content column is the one scrollport. */
63
+ <div className="flex-1">
64
+ <PageChrome breadcrumb={<Breadcrumb items={[{ label: t('nav.templates') }]} />} />
65
+ {/*
66
+ The search field belongs with what it filters, not up in the chrome.
67
+ It scrolls away with the list: the app header is the only sticky
68
+ chrome, so nothing here needs an opaque fill or a stacking context.
69
+ */}
70
+ <div className="px-6 pt-4 pb-3">
71
+ <SearchInput
72
+ className="w-72"
73
+ placeholder={t('emails.searchPlaceholder')}
74
+ value={query}
75
+ onChange={(e) => setQuery(e.target.value)}
76
+ />
77
+ </div>
78
+ <div className="px-6 pb-6">
79
+ {filtered.length === 0 ? (
80
+ <div className="text-muted flex items-center justify-center py-24 text-sm">
81
+ {t('emails.noMatches', { query: query.trim() })}
82
+ </div>
83
+ ) : (
84
+ <EmailList
85
+ items={filtered}
86
+ onOpen={(key, channel) =>
87
+ void navigate({ to: '/templates/$key', params: { key }, search: { channel } })
88
+ }
89
+ />
90
+ )}
91
+ </div>
92
+ </div>
93
+ );
94
+ }
95
+
96
+ export const emailsIndexRoute = createRoute({
97
+ getParentRoute: () => rootRoute,
98
+ path: '/templates',
99
+ component: EmailsIndex,
100
+ });
101
+
102
+ function EmailView() {
103
+ const { key } = emailRoute.useParams();
104
+ const { channel } = emailRoute.useSearch();
105
+ const { config } = emailRoute.useRouteContext();
106
+ const { t } = useTranslation();
107
+ const { resolved: studioScheme } = useTheme();
108
+
109
+ const refs = useMemo(() => collectTemplates(Object.values(config.workflows), config), [config]);
110
+ /*
111
+ * The key plus the channel the link carried: one key may be registered as
112
+ * an email and as a push, and those are two templates. Without a channel the
113
+ * first reference wins, as before.
114
+ */
115
+ const ref =
116
+ refs.find(
117
+ (candidate) => candidate.key === key && (channel ?? candidate.channel) === candidate.channel
118
+ ) ?? refs.find((candidate) => candidate.key === key);
119
+ const activeChannel = ref?.channel ?? channel ?? 'email';
120
+
121
+ /*
122
+ * In-memory props for the preview, tied to the template they were typed
123
+ * for: switching template drops them, an HMR edit keeps them and validates
124
+ * them again against the new schema.
125
+ */
126
+ const [override, setOverride] = useState<{ id: string; props: Props } | undefined>();
127
+ const id = `${activeChannel}:${key}`;
128
+ const previewProps = override?.id === id ? override.props : undefined;
129
+
130
+ /* Only email renders a document; every other channel's content is data. */
131
+ const found = lookupTemplate(config, activeChannel, key);
132
+ const selected = found?.channel === 'email' ? found.entry : undefined;
133
+ const { data, error, isPending } = useEmailPreview(selected, key, previewProps);
134
+
135
+ return (
136
+ <div className="flex flex-1 flex-col">
137
+ {/* The header is the root's: breadcrumb with the template switcher as its leaf. */}
138
+ <PageChrome
139
+ breadcrumb={
140
+ <Breadcrumb
141
+ items={[
142
+ { label: t('nav.templates'), to: '/templates' },
143
+ {
144
+ /* The display name of exactly this template: its channel's registry, not the first key match. */
145
+ label: displayName(found?.entry.title, key),
146
+ to: '/templates/$key',
147
+ params: { key },
148
+ search: { channel: activeChannel },
149
+ },
150
+ /*
151
+ The leaf is the page name, still "Preview" now that the
152
+ single-item tab strip is gone: the workflow detail page keeps
153
+ real tabs and ends its breadcrumb on one, so dropping it here
154
+ would leave the three detail pages shaped differently.
155
+ */
156
+ { label: t('emails.tabs.preview') },
157
+ ]}
158
+ />
159
+ }
160
+ />
161
+ <div className="flex flex-1 flex-col">
162
+ <TemplatesPage
163
+ refs={refs}
164
+ emails={config.emails}
165
+ pushes={config.pushes}
166
+ discords={config.discords}
167
+ slacks={config.slacks}
168
+ {...(config.title !== undefined ? { appName: config.title } : {})}
169
+ defaultScheme={studioScheme}
170
+ selected={key}
171
+ selectedChannel={activeChannel}
172
+ emailDefaults={config.emailDefaults}
173
+ previewProps={previewProps}
174
+ onPreviewPropsChange={(props) =>
175
+ setOverride(props === undefined ? undefined : { id, props })
176
+ }
177
+ preview={{
178
+ ...(data?.status === 'ok' ? { html: data.html } : {}),
179
+ ...(data?.status === 'ok' && data.subject !== undefined
180
+ ? { subject: data.subject }
181
+ : {}),
182
+ ...(data?.status === 'invalid' ? { failure: data.failure } : {}),
183
+ ...(error ? { error: error.message } : {}),
184
+ loading: isPending && selected !== undefined,
185
+ }}
186
+ />
187
+ </div>
188
+ </div>
189
+ );
190
+ }
191
+
192
+ export const emailRoute = createRoute({
193
+ getParentRoute: () => rootRoute,
194
+ path: '/templates/$key',
195
+ /* `?channel=push` picks the push when one key is registered in several registries. */
196
+ validateSearch: (search: Record<string, unknown>): { channel?: string } =>
197
+ typeof search.channel === 'string' ? { channel: search.channel } : {},
198
+ component: EmailView,
199
+ });
@@ -0,0 +1,87 @@
1
+ import { useQuery } from '@tanstack/react-query';
2
+ import { createRoute } from '@tanstack/react-router';
3
+ import { useMemo } from 'react';
4
+ import { useTranslation } from 'react-i18next';
5
+ import { Breadcrumb } from '../../components/breadcrumb';
6
+ import { superellipse } from '../../components/corner-shape';
7
+ import { collectTemplateRefs } from '../../components/template-refs';
8
+ import { lookupTemplate } from '../../utils/template-content';
9
+ import { PageChrome } from '../page-chrome';
10
+ import { Route as rootRoute } from './__root';
11
+ import { collectSegments } from './segments';
12
+
13
+ function Stat({ label, value, hint }: { label: string; value: string; hint?: string }) {
14
+ return (
15
+ <div className="border-border bg-card rounded-2xl border px-5 py-4" style={superellipse}>
16
+ <div className="text-muted text-xs">{label}</div>
17
+ <div className="mt-1 text-2xl font-semibold tabular-nums">{value}</div>
18
+ {hint !== undefined && <div className="text-muted mt-1 text-xs">{hint}</div>}
19
+ </div>
20
+ );
21
+ }
22
+
23
+ function Home() {
24
+ const { config } = homeRoute.useRouteContext();
25
+ const { t } = useTranslation();
26
+
27
+ const irs = useMemo(() => Object.values(config.workflows), [config]);
28
+ const templateRefs = useMemo(() => collectTemplateRefs(irs), [irs]);
29
+ /* The same list the Segments page shows: every deployed segment plus any referenced but undeployed. */
30
+ const segmentRefs = useMemo(() => collectSegments(irs, config.segments), [irs, config]);
31
+ /* Each channel reads its own registry, matching the Templates list's badge. */
32
+ const missing = templateRefs.filter(
33
+ (ref) => lookupTemplate(config, ref.channel, ref.key) === undefined
34
+ ).length;
35
+
36
+ const { data: reports } = useQuery({
37
+ queryKey: ['reports'],
38
+ queryFn: async () => (await config.stats?.reports?.()) ?? [],
39
+ enabled: config.stats?.reports !== undefined,
40
+ });
41
+
42
+ const totals = (reports ?? []).reduce(
43
+ (acc, row) => ({
44
+ entered: acc.entered + row.entered,
45
+ converted: acc.converted + row.converted,
46
+ }),
47
+ { entered: 0, converted: 0 }
48
+ );
49
+
50
+ return (
51
+ /* No scroll container of its own: the shell's content column is the only one. */
52
+ <div className="flex-1 p-6">
53
+ <PageChrome breadcrumb={<Breadcrumb items={[{ label: t('nav.home') }]} />} />
54
+ <h1 className="text-lg font-semibold">{t('home.title')}</h1>
55
+ <p className="text-muted mt-1 text-sm">{t('home.subtitle')}</p>
56
+
57
+ <div className="mt-5 grid grid-cols-2 gap-3 lg:grid-cols-3">
58
+ <Stat label={t('home.workflows')} value={String(irs.length)} />
59
+ <Stat
60
+ label={t('home.templates')}
61
+ value={String(templateRefs.length)}
62
+ {...(missing > 0 ? { hint: t('home.missingTemplates', { count: missing }) } : {})}
63
+ />
64
+ <Stat label={t('home.segments')} value={String(segmentRefs.length)} />
65
+ <Stat label={t('home.entered')} value={reports ? totals.entered.toLocaleString() : '—'} />
66
+ <Stat
67
+ label={t('home.converted')}
68
+ value={reports ? totals.converted.toLocaleString() : '—'}
69
+ />
70
+ <Stat
71
+ label={t('home.conversionRate')}
72
+ value={
73
+ reports && totals.entered > 0
74
+ ? `${((totals.converted / totals.entered) * 100).toFixed(1)}%`
75
+ : '—'
76
+ }
77
+ />
78
+ </div>
79
+ </div>
80
+ );
81
+ }
82
+
83
+ export const homeRoute = createRoute({
84
+ getParentRoute: () => rootRoute,
85
+ path: '/',
86
+ component: Home,
87
+ });
@@ -0,0 +1,19 @@
1
+ import { Route as rootRoute } from './__root';
2
+ import { emailRoute, emailsIndexRoute } from './emails';
3
+ import { homeRoute } from './home';
4
+ import { workflowMetricsRoute } from './metrics';
5
+ import { segmentOverviewRoute } from './segment-overview';
6
+ import { segmentDetailRoute, segmentsRoute } from './segments';
7
+ import { settingsRoute } from './settings';
8
+ import { workflowCanvasRoute, workflowDetailRoute, workflowsIndexRoute } from './workflows';
9
+
10
+ export const routeTree = rootRoute.addChildren([
11
+ homeRoute,
12
+ workflowsIndexRoute,
13
+ workflowDetailRoute.addChildren([workflowCanvasRoute, workflowMetricsRoute]),
14
+ segmentsRoute,
15
+ segmentDetailRoute.addChildren([segmentOverviewRoute]),
16
+ emailsIndexRoute,
17
+ emailRoute,
18
+ settingsRoute,
19
+ ]);