@jackuait/blok 0.10.3 → 0.10.4

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 (284) hide show
  1. package/dist/blok.mjs +2 -2
  2. package/dist/chunks/{blok-3wc3aInM.mjs → blok-NcdNQ0I6.mjs} +2364 -2178
  3. package/dist/chunks/{constants-Bp622jic.mjs → constants-DtfShkXT.mjs} +318 -227
  4. package/dist/chunks/{i18next-loader-CDnSPae_.mjs → i18next-loader-D32EUWLr.mjs} +1 -1
  5. package/dist/chunks/{lightweight-i18n-DZmo8dAI.mjs → lightweight-i18n-DpkvRXEd.mjs} +19 -0
  6. package/dist/{messages-Ddq3Ce3E2.mjs → chunks/messages-AD17iDBx.mjs} +18 -0
  7. package/dist/{messages-neGD3WGq.mjs → chunks/messages-B03yUEra2.mjs} +18 -0
  8. package/dist/chunks/{messages-CIfUm1Oa.mjs → messages-B2dU00Z3.mjs} +18 -0
  9. package/dist/chunks/{messages-BKN3YVIj.mjs → messages-B8hICx3L.mjs} +18 -0
  10. package/dist/{messages-Dnd5YSWv.mjs → chunks/messages-BBe45sPH.mjs} +18 -0
  11. package/dist/{messages-C7lJg8fy2.mjs → chunks/messages-BCifzMVO2.mjs} +18 -0
  12. package/dist/chunks/{messages-D7dx_6k8.mjs → messages-BGmvvtg_.mjs} +18 -0
  13. package/dist/{messages-Q5sQeVap2.mjs → chunks/messages-BJNFCDv42.mjs} +18 -0
  14. package/dist/chunks/{messages-BlxwW7M6.mjs → messages-BNy4e7Xl.mjs} +18 -0
  15. package/dist/chunks/{messages-C15z2r5U.mjs → messages-BcHZf9o-.mjs} +18 -0
  16. package/dist/{messages-A96tMxeU.mjs → chunks/messages-BjyYZeBm2.mjs} +18 -0
  17. package/dist/{messages-BbJ7ZXY8.mjs → chunks/messages-Bop7vrhU.mjs} +18 -0
  18. package/dist/{messages-BiTMwiKH.mjs → chunks/messages-BouFtpfO.mjs} +18 -0
  19. package/dist/chunks/{messages-ElIGUi0O2.mjs → messages-Br6bE1FD2.mjs} +18 -0
  20. package/dist/chunks/{messages-BHMiK51R.mjs → messages-C-EBhOHE.mjs} +18 -0
  21. package/dist/chunks/{messages-kGmxkeFH.mjs → messages-C3X7dv3f.mjs} +18 -0
  22. package/dist/chunks/{messages-4Ck88DYZ2.mjs → messages-C7Pjof0d2.mjs} +18 -0
  23. package/dist/{messages-D0lLw9KM.mjs → chunks/messages-C7sBaZOO2.mjs} +18 -0
  24. package/dist/chunks/{messages-QMOmwcZb.mjs → messages-C85zv_7x.mjs} +18 -0
  25. package/dist/chunks/{messages-DSrdy9Nw2.mjs → messages-CCEgR9GN2.mjs} +18 -0
  26. package/dist/chunks/{messages-DUr9WAkD.mjs → messages-CDSyoUft.mjs} +18 -0
  27. package/dist/{messages-bkGniiaz.mjs → chunks/messages-CGFlOwst.mjs} +18 -0
  28. package/dist/chunks/{messages-DBMaLL8b2.mjs → messages-CGLTjtRv2.mjs} +18 -0
  29. package/dist/{messages-2ZWBTerL.mjs → chunks/messages-CGPxUESo.mjs} +18 -0
  30. package/dist/chunks/{messages-BfAcUavP.mjs → messages-CNaaqQVz.mjs} +18 -0
  31. package/dist/{messages-DBhvm8NK.mjs → chunks/messages-CPFB2_m-2.mjs} +18 -0
  32. package/dist/chunks/{messages-zt6zdYWh.mjs → messages-CTdSIOAc.mjs} +18 -0
  33. package/dist/chunks/{messages-1_6UkKLS.mjs → messages-CXVWb9js.mjs} +18 -0
  34. package/dist/{messages-CdEASHDp2.mjs → chunks/messages-Cfbmwdep2.mjs} +18 -0
  35. package/dist/chunks/{messages-DxHh0O8j2.mjs → messages-ChayV9WY2.mjs} +18 -0
  36. package/dist/chunks/{messages-BgM91Lxm2.mjs → messages-Ci7UXRVI2.mjs} +18 -0
  37. package/dist/chunks/{messages-Clku7Cf-2.mjs → messages-CpXvyGWv2.mjs} +18 -0
  38. package/dist/chunks/{messages-DjvaiALg2.mjs → messages-Cql2ozf_2.mjs} +18 -0
  39. package/dist/{messages-DODrhcop.mjs → chunks/messages-Cxy_E2IS.mjs} +18 -0
  40. package/dist/chunks/{messages-CZSlfnkO2.mjs → messages-D9syZVGi2.mjs} +18 -0
  41. package/dist/chunks/{messages-BRAoJpOu.mjs → messages-D9uWAWjW.mjs} +18 -0
  42. package/dist/chunks/{messages-BK8Cp2d0.mjs → messages-DRJxSTqs.mjs} +18 -0
  43. package/dist/{messages-C_Qn9SbQ.mjs → chunks/messages-DSbI0vJf.mjs} +18 -0
  44. package/dist/chunks/{messages-CD_MnBln.mjs → messages-DVvrZRyZ.mjs} +18 -0
  45. package/dist/{messages-BE_z-zrb.mjs → chunks/messages-DY8zPIZW.mjs} +18 -0
  46. package/dist/chunks/{messages-Bz0-KNEB.mjs → messages-D_kZN9rB.mjs} +18 -0
  47. package/dist/{messages-C1vc5584.mjs → chunks/messages-DjSuq0-y2.mjs} +18 -0
  48. package/dist/chunks/{messages-DPzHD51Y.mjs → messages-DkP3Jf4F.mjs} +18 -0
  49. package/dist/{messages-_PLyRfVw.mjs → chunks/messages-DoPdy75l.mjs} +18 -0
  50. package/dist/chunks/{messages-JSQjKQ8I.mjs → messages-DpydMd36.mjs} +18 -0
  51. package/dist/{messages-BckDk9aq2.mjs → chunks/messages-DtZ9U9g72.mjs} +18 -0
  52. package/dist/{messages-JNrYldAa2.mjs → chunks/messages-H6vLy8wJ.mjs} +18 -0
  53. package/dist/chunks/{messages-DTN1XGll.mjs → messages-HzH9_QH8.mjs} +18 -0
  54. package/dist/chunks/{messages-C0IFfhnp.mjs → messages-O6FOfUgF.mjs} +18 -0
  55. package/dist/{messages-Be_2RHZD.mjs → chunks/messages-OSP4Hj5o.mjs} +18 -0
  56. package/dist/chunks/{messages-DMoERagV2.mjs → messages-RiqdVwuN2.mjs} +18 -0
  57. package/dist/chunks/{messages-BJ-vT1SU2.mjs → messages-SP659Sal2.mjs} +18 -0
  58. package/dist/{messages-Che99vKP.mjs → chunks/messages-THR8q8bJ.mjs} +18 -0
  59. package/dist/chunks/{messages-CvANwuht2.mjs → messages-VlEyFUxF2.mjs} +18 -0
  60. package/dist/{messages-apA6BStA.mjs → chunks/messages-VtfKWZ2S.mjs} +18 -0
  61. package/dist/{messages-DpJGbx3q.mjs → chunks/messages-YbckahVx2.mjs} +18 -0
  62. package/dist/{messages-DYuD5-rO.mjs → chunks/messages-ZhHLC6dk.mjs} +18 -0
  63. package/dist/{messages-C0GSBBCo2.mjs → chunks/messages-bFEdH3lv.mjs} +18 -0
  64. package/dist/chunks/{messages-euM2m3wQ.mjs → messages-dpXwA3Sz.mjs} +18 -0
  65. package/dist/chunks/{messages-CQBo3lmL2.mjs → messages-fbL5y58u2.mjs} +18 -0
  66. package/dist/chunks/{messages-CxiURE2X.mjs → messages-oPV2oMxM.mjs} +18 -0
  67. package/dist/{messages-DM4Gjc9h.mjs → chunks/messages-oXBbHW9A.mjs} +18 -0
  68. package/dist/chunks/{messages-QilfinOn2.mjs → messages-vDgsEqQW2.mjs} +18 -0
  69. package/dist/{messages-ClGvlFcH2.mjs → chunks/messages-wYQksm10.mjs} +18 -0
  70. package/dist/{messages-CnuH-BZK2.mjs → chunks/messages-yGedmr61.mjs} +18 -0
  71. package/dist/chunks/{messages-sDdNf8O9.mjs → messages-zQOpKjl3.mjs} +18 -0
  72. package/dist/chunks/{messages-eFd4YYzt.mjs → messages-zWqsggJh.mjs} +18 -0
  73. package/dist/chunks/{tools-BC1jRfoS.mjs → tools-DMSi-3RW.mjs} +3445 -1302
  74. package/dist/full.mjs +10 -10
  75. package/dist/locales.mjs +86 -67
  76. package/dist/{messages-BK_LsgY4.mjs → messages-0lOPMv8u.mjs} +18 -0
  77. package/dist/{messages-LYJbLq_F.mjs → messages-5wuR90qS.mjs} +18 -0
  78. package/dist/{messages-98nQiC7t2.mjs → messages-6eX0fWGR2.mjs} +18 -0
  79. package/dist/{chunks/messages-DUeiPraX.mjs → messages-9L4qqCKh2.mjs} +18 -0
  80. package/dist/{chunks/messages-Q7-4ZJLB2.mjs → messages-B4zPxKl62.mjs} +18 -0
  81. package/dist/{messages-D0005ti32.mjs → messages-BCMFYqKc2.mjs} +18 -0
  82. package/dist/{chunks/messages-CC_noR8y.mjs → messages-BKXjO3NH.mjs} +18 -0
  83. package/dist/{messages-CRNogopy2.mjs → messages-BLW2GX7J2.mjs} +18 -0
  84. package/dist/{messages-D81w6AmW.mjs → messages-BLfK27kX.mjs} +18 -0
  85. package/dist/{chunks/messages-CPBN4zWc.mjs → messages-BM2kx9Td.mjs} +18 -0
  86. package/dist/{messages-E8NjqzWq2.mjs → messages-BORkMoil2.mjs} +18 -0
  87. package/dist/{messages-Dqu4aX9s.mjs → messages-BPw_x-6H.mjs} +18 -0
  88. package/dist/{messages-DSmxJWju2.mjs → messages-BRY51SEw2.mjs} +18 -0
  89. package/dist/{chunks/messages-BONyZroH.mjs → messages-BSNsrZVN.mjs} +18 -0
  90. package/dist/{chunks/messages-BAlZjPcl.mjs → messages-B_UKuqrH.mjs} +18 -0
  91. package/dist/{chunks/messages-DB_-5Xln.mjs → messages-BrYeJsSE2.mjs} +18 -0
  92. package/dist/{messages-Brd5R-da2.mjs → messages-BwttyHDI2.mjs} +18 -0
  93. package/dist/{messages-qfvXgPpu2.mjs → messages-C-8qb9sf2.mjs} +18 -0
  94. package/dist/{chunks/messages-BbEW9bQz.mjs → messages-C34dTwF72.mjs} +18 -0
  95. package/dist/{messages-BmH2cQHQ.mjs → messages-C67YUZ9-.mjs} +18 -0
  96. package/dist/{messages-DpwMKDV0.mjs → messages-C6yKu_PJ.mjs} +18 -0
  97. package/dist/{messages-Do7Xjy0n.mjs → messages-CA6J_QoC.mjs} +18 -0
  98. package/dist/{messages-DVL0KZE5.mjs → messages-CFUBJfnf.mjs} +18 -0
  99. package/dist/{chunks/messages-DVr1sqfI2.mjs → messages-CLUBh7O_.mjs} +18 -0
  100. package/dist/{chunks/messages-wl8YrvGG.mjs → messages-CLZoy5fQ.mjs} +18 -0
  101. package/dist/{messages-CisR4PNV.mjs → messages-CNGwdIEz.mjs} +18 -0
  102. package/dist/{messages-DopaMHC42.mjs → messages-CR4gHjd82.mjs} +18 -0
  103. package/dist/{messages-DK6dA0O2.mjs → messages-CVMngZNA.mjs} +18 -0
  104. package/dist/{messages-Xc0KUbYl.mjs → messages-Cd5CW5Tt.mjs} +18 -0
  105. package/dist/{chunks/messages-ChK7v1PV.mjs → messages-CrjQ2Op0.mjs} +18 -0
  106. package/dist/{chunks/messages-CRF7nNrO.mjs → messages-Cv1PSaNk.mjs} +18 -0
  107. package/dist/{messages-DOGbHYv-2.mjs → messages-CxZarWTm2.mjs} +18 -0
  108. package/dist/{messages-D3rwCtKn.mjs → messages-D0eT_eWA.mjs} +18 -0
  109. package/dist/{messages-C6ONf71u2.mjs → messages-D6RYu9JW2.mjs} +18 -0
  110. package/dist/{messages-DQORja0D.mjs → messages-D8U5D391.mjs} +18 -0
  111. package/dist/{chunks/messages-EDMC5ukV.mjs → messages-D8dO6OMN.mjs} +18 -0
  112. package/dist/{messages-DfFZ6Yj5.mjs → messages-DA4T9WBe.mjs} +18 -0
  113. package/dist/{chunks/messages-D22e9h7V2.mjs → messages-DB4UKN8D.mjs} +18 -0
  114. package/dist/{chunks/messages-DEBy3nuJ2.mjs → messages-DCdP2ujL.mjs} +18 -0
  115. package/dist/{messages-D05jqBIa2.mjs → messages-DPFuzIdF2.mjs} +18 -0
  116. package/dist/{chunks/messages-DrfRYiM32.mjs → messages-DQ1icG7L.mjs} +18 -0
  117. package/dist/{chunks/messages-a07QVz8U.mjs → messages-DT7dwzEe.mjs} +18 -0
  118. package/dist/{chunks/messages-CszmHAvQ.mjs → messages-DUYxMxrQ2.mjs} +18 -0
  119. package/dist/{chunks/messages-DtoId_bw2.mjs → messages-D_V0kHD7.mjs} +18 -0
  120. package/dist/{messages-BesJaI6A.mjs → messages-DfqM_XvD.mjs} +18 -0
  121. package/dist/{messages-CT-Kdas6.mjs → messages-Di3-WVzq.mjs} +18 -0
  122. package/dist/{messages-BcVB3osF.mjs → messages-Dl0bfeA-.mjs} +18 -0
  123. package/dist/{chunks/messages-C1S9ztpF.mjs → messages-Do3mHd9U.mjs} +18 -0
  124. package/dist/{chunks/messages-BeGZqQwz.mjs → messages-DqDlcEPn.mjs} +18 -0
  125. package/dist/{chunks/messages-CTCe595D2.mjs → messages-DwiykEgr2.mjs} +18 -0
  126. package/dist/{chunks/messages-8Ld7P_9j2.mjs → messages-Dx5n6MLQ2.mjs} +18 -0
  127. package/dist/{messages-LMaR2_bE.mjs → messages-DxEiqa-B.mjs} +18 -0
  128. package/dist/{chunks/messages-CxxyR4vY.mjs → messages-Dxr1BBvo.mjs} +18 -0
  129. package/dist/{messages-D6VIFnSW.mjs → messages-DzknMM7W.mjs} +18 -0
  130. package/dist/{chunks/messages-oMc7qugU2.mjs → messages-ELvF3qMl2.mjs} +18 -0
  131. package/dist/{messages-53w0fPZS2.mjs → messages-JVJdC0Er2.mjs} +18 -0
  132. package/dist/{chunks/messages-BMD37y3q2.mjs → messages-KVerxvZC.mjs} +18 -0
  133. package/dist/{chunks/messages-Du2BffA7.mjs → messages-OOiDDmVw.mjs} +18 -0
  134. package/dist/{messages-uwK7ktqk.mjs → messages-PyOr_YgV.mjs} +18 -0
  135. package/dist/{messages-qbKjjvgd2.mjs → messages-VrQw3tQ62.mjs} +18 -0
  136. package/dist/{messages-CTTmWn4Y2.mjs → messages-WsUHzXMu2.mjs} +18 -0
  137. package/dist/{messages-CZbcxlZt2.mjs → messages-ZHgPRUj02.mjs} +18 -0
  138. package/dist/{messages-DKHbt-7l2.mjs → messages-aoO_TtoE2.mjs} +18 -0
  139. package/dist/{chunks/messages-CW35K1pq.mjs → messages-bh8BiOee2.mjs} +18 -0
  140. package/dist/{messages-BrOWqNCu2.mjs → messages-gZEhkRrR2.mjs} +18 -0
  141. package/dist/{chunks/messages-BRoa9tGl.mjs → messages-hya8YLMj.mjs} +18 -0
  142. package/dist/{messages-CdduYw-q.mjs → messages-tb1FD_ge.mjs} +18 -0
  143. package/dist/react.mjs +2 -2
  144. package/dist/tools.mjs +3 -3
  145. package/dist/vendor.LICENSE.txt +135 -0
  146. package/package.json +2 -1
  147. package/src/blok.ts +48 -0
  148. package/src/components/block/index.ts +21 -2
  149. package/src/components/block-tunes/block-tune-copy-link.ts +82 -0
  150. package/src/components/i18n/locales/am/messages.json +18 -0
  151. package/src/components/i18n/locales/ar/messages.json +18 -0
  152. package/src/components/i18n/locales/az/messages.json +18 -0
  153. package/src/components/i18n/locales/bg/messages.json +18 -0
  154. package/src/components/i18n/locales/bn/messages.json +18 -0
  155. package/src/components/i18n/locales/bs/messages.json +18 -0
  156. package/src/components/i18n/locales/cs/messages.json +18 -0
  157. package/src/components/i18n/locales/da/messages.json +18 -0
  158. package/src/components/i18n/locales/de/messages.json +18 -0
  159. package/src/components/i18n/locales/dv/messages.json +18 -0
  160. package/src/components/i18n/locales/el/messages.json +18 -0
  161. package/src/components/i18n/locales/en/messages.json +19 -0
  162. package/src/components/i18n/locales/es/messages.json +18 -0
  163. package/src/components/i18n/locales/et/messages.json +18 -0
  164. package/src/components/i18n/locales/fa/messages.json +18 -0
  165. package/src/components/i18n/locales/fi/messages.json +18 -0
  166. package/src/components/i18n/locales/fil/messages.json +18 -0
  167. package/src/components/i18n/locales/fr/messages.json +18 -0
  168. package/src/components/i18n/locales/gu/messages.json +18 -0
  169. package/src/components/i18n/locales/he/messages.json +18 -0
  170. package/src/components/i18n/locales/hi/messages.json +18 -0
  171. package/src/components/i18n/locales/hr/messages.json +18 -0
  172. package/src/components/i18n/locales/hu/messages.json +18 -0
  173. package/src/components/i18n/locales/hy/messages.json +18 -0
  174. package/src/components/i18n/locales/id/messages.json +18 -0
  175. package/src/components/i18n/locales/it/messages.json +18 -0
  176. package/src/components/i18n/locales/ja/messages.json +18 -0
  177. package/src/components/i18n/locales/ka/messages.json +18 -0
  178. package/src/components/i18n/locales/km/messages.json +18 -0
  179. package/src/components/i18n/locales/kn/messages.json +18 -0
  180. package/src/components/i18n/locales/ko/messages.json +18 -0
  181. package/src/components/i18n/locales/ku/messages.json +18 -0
  182. package/src/components/i18n/locales/lo/messages.json +18 -0
  183. package/src/components/i18n/locales/lt/messages.json +18 -0
  184. package/src/components/i18n/locales/lv/messages.json +18 -0
  185. package/src/components/i18n/locales/mk/messages.json +18 -0
  186. package/src/components/i18n/locales/ml/messages.json +18 -0
  187. package/src/components/i18n/locales/mn/messages.json +18 -0
  188. package/src/components/i18n/locales/mr/messages.json +18 -0
  189. package/src/components/i18n/locales/ms/messages.json +18 -0
  190. package/src/components/i18n/locales/my/messages.json +18 -0
  191. package/src/components/i18n/locales/ne/messages.json +18 -0
  192. package/src/components/i18n/locales/nl/messages.json +18 -0
  193. package/src/components/i18n/locales/no/messages.json +18 -0
  194. package/src/components/i18n/locales/pa/messages.json +18 -0
  195. package/src/components/i18n/locales/pl/messages.json +18 -0
  196. package/src/components/i18n/locales/ps/messages.json +18 -0
  197. package/src/components/i18n/locales/pt/messages.json +18 -0
  198. package/src/components/i18n/locales/ro/messages.json +18 -0
  199. package/src/components/i18n/locales/ru/messages.json +18 -0
  200. package/src/components/i18n/locales/sd/messages.json +18 -0
  201. package/src/components/i18n/locales/si/messages.json +18 -0
  202. package/src/components/i18n/locales/sk/messages.json +18 -0
  203. package/src/components/i18n/locales/sl/messages.json +18 -0
  204. package/src/components/i18n/locales/sq/messages.json +18 -0
  205. package/src/components/i18n/locales/sr/messages.json +18 -0
  206. package/src/components/i18n/locales/sv/messages.json +18 -0
  207. package/src/components/i18n/locales/sw/messages.json +18 -0
  208. package/src/components/i18n/locales/ta/messages.json +18 -0
  209. package/src/components/i18n/locales/te/messages.json +18 -0
  210. package/src/components/i18n/locales/th/messages.json +18 -0
  211. package/src/components/i18n/locales/tr/messages.json +18 -0
  212. package/src/components/i18n/locales/ug/messages.json +18 -0
  213. package/src/components/i18n/locales/uk/messages.json +18 -0
  214. package/src/components/i18n/locales/ur/messages.json +18 -0
  215. package/src/components/i18n/locales/vi/messages.json +18 -0
  216. package/src/components/i18n/locales/yi/messages.json +18 -0
  217. package/src/components/i18n/locales/zh/messages.json +18 -0
  218. package/src/components/icons/index.ts +65 -0
  219. package/src/components/inline-tools/inline-tool-bold.ts +10 -0
  220. package/src/components/inline-tools/inline-tool-code.ts +54 -1
  221. package/src/components/inline-tools/inline-tool-italic.ts +54 -1
  222. package/src/components/inline-tools/inline-tool-strikethrough.ts +54 -1
  223. package/src/components/inline-tools/inline-tool-underline.ts +54 -1
  224. package/src/components/inline-tools/services/bold-normalization-pass.ts +29 -3
  225. package/src/components/inline-tools/utils/formatting-range-utils.ts +83 -0
  226. package/src/components/modules/api/tools.ts +19 -0
  227. package/src/components/modules/blockEvents/composers/keyboardNavigation.ts +5 -5
  228. package/src/components/modules/blockManager/blockManager.ts +22 -0
  229. package/src/components/modules/blockManager/event-binder.ts +12 -1
  230. package/src/components/modules/blockManager/factory.ts +4 -0
  231. package/src/components/modules/blockManager/types.ts +4 -0
  232. package/src/components/modules/blockManager/yjs-sync.ts +16 -2
  233. package/src/components/modules/paste/google-docs-preprocessor.ts +49 -3
  234. package/src/components/modules/paste/handlers/table-cells-handler.ts +12 -2
  235. package/src/components/modules/paste/index.ts +8 -4
  236. package/src/components/modules/paste/types.ts +2 -0
  237. package/src/components/modules/renderer.ts +22 -2
  238. package/src/components/modules/saver.ts +19 -1
  239. package/src/components/modules/themeManager.ts +3 -1
  240. package/src/components/modules/toolbar/blockSettings.ts +51 -1
  241. package/src/components/modules/toolbar/inline/index.ts +0 -3
  242. package/src/components/modules/tools.ts +5 -0
  243. package/src/components/modules/uiControllers/controllers/keyboard.ts +29 -0
  244. package/src/components/modules/uiControllers/controllers/selection.ts +14 -2
  245. package/src/components/modules/yjs/document-store.ts +22 -0
  246. package/src/components/modules/yjs/index.ts +10 -0
  247. package/src/components/modules/yjs/serializer.ts +20 -0
  248. package/src/components/ui/toolbox.ts +0 -1
  249. package/src/components/utils/id-generator.ts +11 -0
  250. package/src/components/utils/key-icon.ts +187 -0
  251. package/src/components/utils/popover/components/hint/hint.ts +3 -1
  252. package/src/components/utils/popover/components/popover-item/popover-item-default/popover-item-default.ts +18 -5
  253. package/src/components/utils/popover/popover-abstract.ts +45 -0
  254. package/src/components/utils/popover/popover-desktop.ts +1 -0
  255. package/src/components/utils/popover/popover-position.ts +4 -2
  256. package/src/components/utils/popover/popover.const.ts +2 -0
  257. package/src/components/utils.ts +1 -0
  258. package/src/styles/main.css +1269 -0
  259. package/src/tools/code/index.ts +4 -0
  260. package/src/tools/database/database-backend-sync.ts +132 -0
  261. package/src/tools/database/database-board-view.ts +410 -0
  262. package/src/tools/database/database-card-drag.ts +306 -0
  263. package/src/tools/database/database-card-drawer.ts +546 -0
  264. package/src/tools/database/database-column-controls.ts +141 -0
  265. package/src/tools/database/database-column-drag.ts +262 -0
  266. package/src/tools/database/database-keyboard.ts +35 -0
  267. package/src/tools/database/database-list-row-drag.ts +245 -0
  268. package/src/tools/database/database-list-view.ts +333 -0
  269. package/src/tools/database/database-model.ts +214 -0
  270. package/src/tools/database/database-property-type-popover.ts +108 -0
  271. package/src/tools/database/database-tab-bar.ts +558 -0
  272. package/src/tools/database/database-view-popover.ts +129 -0
  273. package/src/tools/database/database-view-renderer.ts +25 -0
  274. package/src/tools/database/index.ts +1223 -0
  275. package/src/tools/database/types.ts +152 -0
  276. package/src/tools/database-row/index.ts +74 -0
  277. package/src/tools/index.ts +4 -0
  278. package/types/api/tools.d.ts +18 -0
  279. package/types/configs/blok-config.d.ts +27 -0
  280. package/types/data-formats/output-data.d.ts +13 -0
  281. package/types/index.d.ts +17 -0
  282. package/types/tools/database.d.ts +152 -0
  283. package/types/tools-entry.d.ts +7 -4
  284. package/types/utils/popover/popover.d.ts +6 -0
@@ -0,0 +1,558 @@
1
+ import { generateKeyBetween } from 'fractional-indexing';
2
+ import { IconBoard, IconList, IconPencil, IconCopy, IconTrash, IconPlus } from '../../components/icons';
3
+ import { DatabaseViewPopover } from './database-view-popover';
4
+ import { PopoverDesktop } from '../../components/utils/popover';
5
+ import { PopoverItemType } from '../../components/utils/popover/components/popover-item';
6
+ import { PopoverEvent } from '@/types/utils/popover/popover-event';
7
+ import type { DatabaseViewConfig, ViewType } from './types';
8
+
9
+ const DRAG_THRESHOLD = 10;
10
+
11
+ const VIEW_ICONS: Record<string, string> = {
12
+ board: IconBoard,
13
+ list: IconList,
14
+ };
15
+
16
+ export interface TabBarOptions {
17
+ views: DatabaseViewConfig[];
18
+ activeViewId: string;
19
+ onTabClick: (viewId: string) => void;
20
+ onAddView: (type: ViewType) => void;
21
+ onRename: (viewId: string, newName: string) => void;
22
+ onDuplicate: (viewId: string) => void;
23
+ onDelete: (viewId: string) => void;
24
+ onReorder: (viewId: string, newPosition: string) => void;
25
+ readOnly?: boolean;
26
+ }
27
+
28
+ export class DatabaseTabBar {
29
+ private readonly options: TabBarOptions;
30
+ private readonly views: DatabaseViewConfig[];
31
+ private readonly onReorder: (viewId: string, newPosition: string) => void;
32
+ private element: HTMLElement | null = null;
33
+ private barEl: HTMLElement | null = null;
34
+ private addBtnEl: HTMLElement | null = null;
35
+ private readOnly: boolean;
36
+ private viewPopover: DatabaseViewPopover | null = null;
37
+ private contextPopover: PopoverDesktop | null = null;
38
+
39
+ private overflowDropdownEl: HTMLElement | null = null;
40
+ private boundOverflowClose: ((e: MouseEvent) => void) | null = null;
41
+ private moreBtnEl: HTMLElement | null = null;
42
+
43
+ private isDragging = false;
44
+ private dragViewId = '';
45
+ private dragStartX = 0;
46
+ private ghostEl: HTMLElement | null = null;
47
+ private readonly boundDragMove: (e: PointerEvent) => void;
48
+ private readonly boundDragUp: (e: PointerEvent) => void;
49
+ private readonly boundDragCancel: () => void;
50
+ private readonly boundDragKeyDown: (e: KeyboardEvent) => void;
51
+
52
+ constructor(options: TabBarOptions) {
53
+ this.options = options;
54
+ this.views = options.views;
55
+ this.onReorder = options.onReorder;
56
+ this.readOnly = options.readOnly ?? false;
57
+
58
+ this.boundDragMove = this.handleDragMove.bind(this);
59
+ this.boundDragUp = this.handleDragUp.bind(this);
60
+ this.boundDragCancel = this.cleanupDrag.bind(this);
61
+ this.boundDragKeyDown = (e: KeyboardEvent): void => {
62
+ if (e.key === 'Escape') { this.cleanupDrag(); }
63
+ };
64
+ }
65
+
66
+ render(): HTMLElement {
67
+ const bar = document.createElement('div');
68
+ bar.setAttribute('data-blok-database-tab-bar', '');
69
+ this.barEl = bar;
70
+ this.element = bar;
71
+
72
+ const sorted = [...this.options.views].sort((a, b) => (a.position < b.position ? -1 : 1));
73
+
74
+ for (const view of sorted) {
75
+ bar.appendChild(this.createTab(view));
76
+ }
77
+
78
+ const addBtn = document.createElement('button');
79
+ addBtn.setAttribute('data-blok-database-add-view', '');
80
+ addBtn.innerHTML = IconPlus;
81
+ addBtn.addEventListener('click', () => {
82
+ this.openViewPopover(addBtn);
83
+ });
84
+ this.addBtnEl = addBtn;
85
+ if (!this.readOnly) {
86
+ bar.appendChild(addBtn);
87
+ }
88
+
89
+ bar.addEventListener('click', (e: MouseEvent) => {
90
+ const target = e.target as HTMLElement;
91
+ const tab = target.closest('[data-blok-database-tab]');
92
+ if (!(tab instanceof HTMLElement)) {
93
+ return;
94
+ }
95
+ const viewId = tab.getAttribute('data-view-id');
96
+ if (viewId === null) {
97
+ return;
98
+ }
99
+ if (tab.hasAttribute('data-active')) {
100
+ return;
101
+ }
102
+ this.options.onTabClick(viewId);
103
+ });
104
+
105
+ bar.addEventListener('contextmenu', (e: MouseEvent) => {
106
+ const target = e.target as HTMLElement;
107
+ const tab = target.closest('[data-blok-database-tab]');
108
+ if (!(tab instanceof HTMLElement)) {
109
+ return;
110
+ }
111
+ e.preventDefault();
112
+ const viewId = tab.getAttribute('data-view-id');
113
+ if (viewId === null) {
114
+ return;
115
+ }
116
+ this.openContextPopover(tab, viewId);
117
+ });
118
+
119
+ bar.addEventListener('dblclick', (e: MouseEvent) => {
120
+ const target = e.target as HTMLElement;
121
+ const tab = target.closest('[data-blok-database-tab]');
122
+ if (!(tab instanceof HTMLElement)) {
123
+ return;
124
+ }
125
+ const viewId = tab.getAttribute('data-view-id');
126
+ if (viewId === null) {
127
+ return;
128
+ }
129
+ this.openContextPopover(tab, viewId);
130
+ });
131
+
132
+ bar.addEventListener('pointerdown', (e) => {
133
+ const target = e.target as HTMLElement;
134
+ const tab = target.closest<HTMLElement>('[data-blok-database-tab]');
135
+ if (tab === null) return;
136
+ const viewId = tab.getAttribute('data-view-id');
137
+ if (viewId === null) return;
138
+ this.dragViewId = viewId;
139
+ this.dragStartX = e.clientX;
140
+ this.isDragging = false;
141
+ document.addEventListener('pointermove', this.boundDragMove);
142
+ document.addEventListener('pointerup', this.boundDragUp);
143
+ document.addEventListener('pointercancel', this.boundDragCancel);
144
+ document.addEventListener('keydown', this.boundDragKeyDown);
145
+ });
146
+
147
+ if (typeof ResizeObserver !== 'undefined') {
148
+ const ro = new ResizeObserver(() => {
149
+ if (this.element === null) {
150
+ return;
151
+ }
152
+
153
+ const tabs = Array.from(this.element.querySelectorAll<HTMLElement>('[data-blok-database-tab]'));
154
+
155
+ for (const tab of tabs) {
156
+ tab.style.display = '';
157
+ }
158
+ this.moreBtnEl?.remove();
159
+ this.moreBtnEl = null;
160
+
161
+ const barWidth = this.element.clientWidth;
162
+ const addBtnWidth = 40;
163
+ const visibleCount = tabs.findIndex((_tab, i) => {
164
+ const consumed = addBtnWidth + tabs.slice(0, i + 1).reduce((w, t) => w + t.offsetWidth + 2, 0);
165
+
166
+ return consumed > barWidth;
167
+ });
168
+ const resolved = visibleCount === -1 ? tabs.length : visibleCount;
169
+
170
+ if (resolved < tabs.length) {
171
+ this.handleOverflow(resolved);
172
+ }
173
+ });
174
+
175
+ ro.observe(bar);
176
+ }
177
+
178
+ return bar;
179
+ }
180
+
181
+ private createTab(view: DatabaseViewConfig): HTMLElement {
182
+ const tab = document.createElement('div');
183
+ tab.setAttribute('data-blok-database-tab', '');
184
+ tab.setAttribute('data-view-id', view.id);
185
+
186
+ if (view.id === this.options.activeViewId) {
187
+ tab.setAttribute('data-active', '');
188
+ }
189
+
190
+ const iconSpan = document.createElement('span');
191
+ iconSpan.innerHTML = VIEW_ICONS[view.type] ?? '';
192
+ tab.appendChild(iconSpan);
193
+
194
+ const nameSpan = document.createElement('span');
195
+ nameSpan.setAttribute('data-blok-database-tab-name', '');
196
+ nameSpan.textContent = view.name;
197
+ tab.appendChild(nameSpan);
198
+
199
+ return tab;
200
+ }
201
+
202
+ private openContextPopover(tab: HTMLElement, viewId: string): void {
203
+ this.closeContextPopover();
204
+
205
+ const canDelete = this.options.views.length > 1;
206
+
207
+ const baseItems = [
208
+ {
209
+ icon: IconPencil,
210
+ title: 'Rename',
211
+ closeOnActivate: true,
212
+ onActivate: () => {
213
+ this.startInlineRename(tab, viewId);
214
+ },
215
+ },
216
+ {
217
+ icon: IconCopy,
218
+ title: 'Duplicate',
219
+ closeOnActivate: true,
220
+ onActivate: () => {
221
+ this.options.onDuplicate(viewId);
222
+ },
223
+ },
224
+ ];
225
+
226
+ const deleteItems = canDelete
227
+ ? [
228
+ { type: PopoverItemType.Separator as const },
229
+ {
230
+ icon: IconTrash,
231
+ title: 'Delete',
232
+ isDestructive: true,
233
+ closeOnActivate: true,
234
+ onActivate: () => {
235
+ this.options.onDelete(viewId);
236
+ },
237
+ },
238
+ ]
239
+ : [];
240
+
241
+ this.contextPopover = new PopoverDesktop({
242
+ trigger: tab,
243
+ width: 'auto',
244
+ minWidth: '160px',
245
+ autoFocusFirstItem: false,
246
+ items: [...baseItems, ...deleteItems],
247
+ });
248
+
249
+ this.contextPopover.on(PopoverEvent.Closed, () => {
250
+ if (this.contextPopover !== null) {
251
+ const p = this.contextPopover;
252
+ this.contextPopover = null;
253
+ p.destroy();
254
+ }
255
+ });
256
+
257
+ this.contextPopover.show();
258
+ }
259
+
260
+ private closeContextPopover(): void {
261
+ if (this.contextPopover !== null) {
262
+ const popover = this.contextPopover;
263
+ this.contextPopover = null;
264
+ popover.destroy();
265
+ }
266
+ }
267
+
268
+ private startInlineRename(tab: HTMLElement, viewId: string): void {
269
+ const nameSpan = tab.querySelector('[data-blok-database-tab-name]');
270
+ if (!(nameSpan instanceof HTMLElement)) {
271
+ return;
272
+ }
273
+
274
+ const originalName = nameSpan.textContent ?? '';
275
+
276
+ const input = document.createElement('input');
277
+ input.setAttribute('data-blok-database-tab-rename-input', '');
278
+ input.value = originalName;
279
+ nameSpan.replaceWith(input);
280
+ input.focus();
281
+ input.select();
282
+
283
+ const commit = (): void => {
284
+ const newName = input.value.trim() || originalName;
285
+ const newSpan = document.createElement('span');
286
+ newSpan.setAttribute('data-blok-database-tab-name', '');
287
+ newSpan.textContent = newName;
288
+ input.replaceWith(newSpan);
289
+ if (newName !== originalName) {
290
+ this.options.onRename(viewId, newName);
291
+ }
292
+ };
293
+
294
+ input.addEventListener('blur', commit);
295
+ input.addEventListener('keydown', (e: KeyboardEvent) => {
296
+ e.stopPropagation();
297
+ if (e.key === 'Enter') {
298
+ input.blur();
299
+ } else if (e.key === 'Escape') {
300
+ input.removeEventListener('blur', commit);
301
+ const cancelSpan = document.createElement('span');
302
+ cancelSpan.setAttribute('data-blok-database-tab-name', '');
303
+ cancelSpan.textContent = originalName;
304
+ input.replaceWith(cancelSpan);
305
+ }
306
+ });
307
+ }
308
+
309
+ private openViewPopover(anchor: HTMLElement): void {
310
+ if (this.viewPopover !== null) {
311
+ this.viewPopover.destroy();
312
+ }
313
+ anchor.setAttribute('data-popover-open', '');
314
+ this.barEl?.setAttribute('data-popover-open', '');
315
+ this.viewPopover = new DatabaseViewPopover({
316
+ onSelect: (type) => {
317
+ this.options.onAddView(type);
318
+ },
319
+ onClose: () => {
320
+ anchor.removeAttribute('data-popover-open');
321
+ this.barEl?.removeAttribute('data-popover-open');
322
+ },
323
+ });
324
+ this.viewPopover.open(anchor);
325
+ }
326
+
327
+ handleOverflow(visibleCount: number): void {
328
+ if (this.element === null) return;
329
+
330
+ // Remove existing more button
331
+ this.moreBtnEl?.remove();
332
+
333
+ const orderedViews = [...this.views].sort((a, b) => (a.position < b.position ? -1 : 1));
334
+ const hiddenCount = orderedViews.length - visibleCount;
335
+ if (hiddenCount <= 0) return;
336
+
337
+ // Hide overflow tabs
338
+ const tabs = Array.from(this.element.querySelectorAll<HTMLElement>('[data-blok-database-tab]'));
339
+
340
+ for (const tab of tabs.slice(visibleCount)) {
341
+ tab.style.display = 'none';
342
+ }
343
+
344
+ // Add "N more..." button before the + button
345
+ const moreBtn = document.createElement('div');
346
+ moreBtn.setAttribute('data-blok-database-tab-more', '');
347
+ moreBtn.textContent = `${hiddenCount} more...`;
348
+ moreBtn.style.cursor = 'pointer';
349
+ moreBtn.addEventListener('click', () => {
350
+ this.openOverflowDropdown(moreBtn);
351
+ });
352
+
353
+ const addBtn = this.element.querySelector('[data-blok-database-add-view]');
354
+ if (addBtn !== null) {
355
+ this.element.insertBefore(moreBtn, addBtn);
356
+ } else {
357
+ this.element.appendChild(moreBtn);
358
+ }
359
+ this.moreBtnEl = moreBtn;
360
+ }
361
+
362
+ private openOverflowDropdown(anchor: HTMLElement): void {
363
+ this.closeOverflowDropdown();
364
+
365
+ const dropdown = document.createElement('div');
366
+ dropdown.setAttribute('data-blok-popover', '');
367
+ dropdown.setAttribute('data-blok-database-tab-overflow-dropdown', '');
368
+ dropdown.style.position = 'fixed';
369
+ dropdown.style.zIndex = '1000';
370
+
371
+ const rect = anchor.getBoundingClientRect();
372
+ dropdown.style.top = `${rect.bottom + 4}px`;
373
+ dropdown.style.left = `${rect.left}px`;
374
+
375
+ const orderedViews = [...this.views].sort((a, b) => (a.position < b.position ? -1 : 1));
376
+
377
+ for (const view of orderedViews) {
378
+ const item = document.createElement('div');
379
+ item.setAttribute('data-blok-database-tab-overflow-item', '');
380
+ item.setAttribute('data-view-id', view.id);
381
+
382
+ if (view.id === this.options.activeViewId) {
383
+ item.setAttribute('data-active', '');
384
+ }
385
+
386
+ const iconSpan = document.createElement('span');
387
+ iconSpan.innerHTML = VIEW_ICONS[view.type] ?? '';
388
+ item.appendChild(iconSpan);
389
+
390
+ const nameSpan = document.createElement('span');
391
+ nameSpan.textContent = view.name;
392
+ item.appendChild(nameSpan);
393
+
394
+ item.addEventListener('click', () => {
395
+ if (view.id !== this.options.activeViewId) {
396
+ this.options.onTabClick(view.id);
397
+ }
398
+ this.closeOverflowDropdown();
399
+ });
400
+
401
+ dropdown.appendChild(item);
402
+ }
403
+
404
+ const separator = document.createElement('div');
405
+ separator.setAttribute('data-blok-database-tab-overflow-separator', '');
406
+ dropdown.appendChild(separator);
407
+
408
+ const addBtn = this.element?.querySelector<HTMLElement>('[data-blok-database-add-view]');
409
+ const newViewBtn = document.createElement('div');
410
+ newViewBtn.setAttribute('data-blok-database-tab-overflow-new', '');
411
+ newViewBtn.textContent = '+ New view';
412
+ newViewBtn.addEventListener('click', () => {
413
+ this.closeOverflowDropdown();
414
+ if (addBtn !== null && addBtn !== undefined) {
415
+ this.openViewPopover(addBtn);
416
+ }
417
+ });
418
+ dropdown.appendChild(newViewBtn);
419
+
420
+ document.body.appendChild(dropdown);
421
+ this.overflowDropdownEl = dropdown;
422
+
423
+ this.boundOverflowClose = (e: MouseEvent): void => {
424
+ const target = e.target as HTMLElement;
425
+ if (!dropdown.contains(target) && !anchor.contains(target)) {
426
+ this.closeOverflowDropdown();
427
+ }
428
+ };
429
+
430
+ document.addEventListener('mousedown', this.boundOverflowClose);
431
+ }
432
+
433
+ private closeOverflowDropdown(): void {
434
+ if (this.overflowDropdownEl !== null) {
435
+ this.overflowDropdownEl.remove();
436
+ this.overflowDropdownEl = null;
437
+ }
438
+ if (this.boundOverflowClose !== null) {
439
+ document.removeEventListener('mousedown', this.boundOverflowClose);
440
+ this.boundOverflowClose = null;
441
+ }
442
+ }
443
+
444
+ private handleDragMove(e: PointerEvent): void {
445
+ const dx = Math.abs(e.clientX - this.dragStartX);
446
+ if (!this.isDragging && dx < DRAG_THRESHOLD) return;
447
+ if (!this.isDragging) {
448
+ this.isDragging = true;
449
+ this.element?.setAttribute('data-dragging', '');
450
+ const sourceTab = this.element?.querySelector(`[data-view-id="${this.dragViewId}"]`) as HTMLElement | null;
451
+ if (sourceTab !== null) {
452
+ this.ghostEl = sourceTab.cloneNode(true) as HTMLElement;
453
+ this.ghostEl.setAttribute('data-blok-database-tab-ghost', '');
454
+ this.ghostEl.style.position = 'fixed';
455
+ this.ghostEl.style.pointerEvents = 'none';
456
+ this.ghostEl.style.zIndex = '50';
457
+ this.ghostEl.style.opacity = '0.7';
458
+ const rect = sourceTab.getBoundingClientRect();
459
+ this.ghostEl.style.top = `${rect.top}px`;
460
+ this.ghostEl.style.width = `${rect.width}px`;
461
+ document.body.appendChild(this.ghostEl);
462
+ sourceTab.style.opacity = '0.4';
463
+ }
464
+ }
465
+ if (this.ghostEl !== null) {
466
+ this.ghostEl.style.left = `${e.clientX - 50}px`;
467
+ }
468
+ }
469
+
470
+ private handleDragUp(e: PointerEvent): void {
471
+ if (!this.isDragging) {
472
+ this.removeDragListeners();
473
+ return;
474
+ }
475
+ const tabs = Array.from(
476
+ this.element?.querySelectorAll<HTMLElement>('[data-blok-database-tab]') ?? []
477
+ ).filter((t) => t.getAttribute('data-view-id') !== this.dragViewId);
478
+
479
+ const dropIndex = tabs.findIndex((t) => {
480
+ const rect = t.getBoundingClientRect();
481
+ return e.clientX < (rect.left + rect.right) / 2;
482
+ });
483
+
484
+ const beforeViewId = dropIndex >= 0 ? tabs[dropIndex].getAttribute('data-view-id') : null;
485
+ const afterViewId = ((): string | null => {
486
+ if (dropIndex > 0) return tabs[dropIndex - 1].getAttribute('data-view-id');
487
+ if (dropIndex === -1 && tabs.length > 0) return tabs[tabs.length - 1].getAttribute('data-view-id');
488
+ return null;
489
+ })();
490
+
491
+ const orderedViews = [...this.views].sort((a, b) => (a.position < b.position ? -1 : 1));
492
+ const beforeView = beforeViewId !== null ? orderedViews.find((v) => v.id === beforeViewId) : null;
493
+ const afterView = afterViewId !== null ? orderedViews.find((v) => v.id === afterViewId) : null;
494
+
495
+ const newPosition = generateKeyBetween(
496
+ afterView?.position ?? null,
497
+ beforeView?.position ?? null
498
+ );
499
+
500
+ this.cleanupDrag();
501
+ this.onReorder(this.dragViewId, newPosition);
502
+ }
503
+
504
+ private cleanupDrag(): void {
505
+ if (this.ghostEl !== null) {
506
+ this.ghostEl.remove();
507
+ this.ghostEl = null;
508
+ }
509
+ this.element?.removeAttribute('data-dragging');
510
+ const sourceTab = this.element?.querySelector(`[data-view-id="${this.dragViewId}"]`) as HTMLElement | null;
511
+ if (sourceTab !== null) {
512
+ sourceTab.style.opacity = '';
513
+ }
514
+ this.isDragging = false;
515
+ this.removeDragListeners();
516
+ }
517
+
518
+ private removeDragListeners(): void {
519
+ document.removeEventListener('pointermove', this.boundDragMove);
520
+ document.removeEventListener('pointerup', this.boundDragUp);
521
+ document.removeEventListener('pointercancel', this.boundDragCancel);
522
+ document.removeEventListener('keydown', this.boundDragKeyDown);
523
+ }
524
+
525
+ setReadOnly(state: boolean): void {
526
+ if (this.readOnly === state) {
527
+ return;
528
+ }
529
+ this.readOnly = state;
530
+
531
+ if (this.barEl === null || this.addBtnEl === null) {
532
+ return;
533
+ }
534
+
535
+ if (state) {
536
+ this.addBtnEl.remove();
537
+ } else {
538
+ // Only re-attach to bar if the button isn't already placed elsewhere (e.g. title row)
539
+ if (!this.addBtnEl.isConnected) {
540
+ this.barEl.appendChild(this.addBtnEl);
541
+ }
542
+ }
543
+ }
544
+
545
+ destroy(): void {
546
+ this.cleanupDrag();
547
+ this.closeContextPopover();
548
+ this.closeOverflowDropdown();
549
+ if (this.viewPopover !== null) {
550
+ this.viewPopover.destroy();
551
+ this.viewPopover = null;
552
+ }
553
+ }
554
+
555
+ getAddBtnEl(): HTMLElement | null {
556
+ return this.addBtnEl;
557
+ }
558
+ }
@@ -0,0 +1,129 @@
1
+ import { IconBoard, IconList } from '../../components/icons';
2
+ import { PopoverDesktop } from '../../components/utils/popover';
3
+ import { PopoverItemType } from '../../components/utils/popover/components/popover-item';
4
+ import { PopoverEvent } from '@/types/utils/popover/popover-event';
5
+ import type { ViewType } from './types';
6
+
7
+ interface ViewTypeOption {
8
+ type: ViewType;
9
+ icon: string;
10
+ label: string;
11
+ description: string;
12
+ }
13
+
14
+ const VIEW_TYPES: ViewTypeOption[] = [
15
+ { type: 'board', icon: IconBoard, label: 'Board', description: 'Visualize work as columns' },
16
+ { type: 'list', icon: IconList, label: 'List', description: 'A simple linear view' },
17
+ ];
18
+
19
+ export interface ViewPopoverOptions {
20
+ onSelect: (type: ViewType) => void;
21
+ onClose?: () => void;
22
+ }
23
+
24
+ export class DatabaseViewPopover {
25
+ private readonly onSelect: (type: ViewType) => void;
26
+ private readonly onClose: (() => void) | undefined;
27
+ private popover: PopoverDesktop | null = null;
28
+
29
+ constructor(options: ViewPopoverOptions) {
30
+ this.onSelect = options.onSelect;
31
+ this.onClose = options.onClose;
32
+ }
33
+
34
+ open(anchor: HTMLElement): void {
35
+ this.close();
36
+
37
+ const headingEl = document.createElement('div');
38
+
39
+ headingEl.setAttribute('data-blok-database-view-popover-heading', '');
40
+ headingEl.textContent = 'Add view';
41
+
42
+ const headingItem = {
43
+ type: PopoverItemType.Html as const,
44
+ element: headingEl,
45
+ };
46
+
47
+ const items = [
48
+ headingItem,
49
+ ...VIEW_TYPES.map((option) => {
50
+ const el = this.createViewItem(option);
51
+
52
+ return {
53
+ type: PopoverItemType.Html as const,
54
+ element: el,
55
+ closeOnActivate: true,
56
+ };
57
+ }),
58
+ ];
59
+
60
+ this.popover = new PopoverDesktop({
61
+ items,
62
+ trigger: anchor,
63
+ width: 'auto',
64
+ minWidth: '200px',
65
+ flippable: false,
66
+ autoFocusFirstItem: false,
67
+ });
68
+
69
+ this.popover.on(PopoverEvent.Closed, () => {
70
+ if (this.popover !== null) {
71
+ const p = this.popover;
72
+ this.popover = null;
73
+ p.destroy();
74
+ this.onClose?.();
75
+ }
76
+ });
77
+
78
+ this.popover.show();
79
+ }
80
+
81
+ private createViewItem(option: ViewTypeOption): HTMLElement {
82
+ const item = document.createElement('div');
83
+
84
+ item.setAttribute('data-blok-database-view-option', option.type);
85
+
86
+ const iconEl = document.createElement('div');
87
+
88
+ iconEl.setAttribute('data-blok-database-view-option-icon', '');
89
+ iconEl.innerHTML = option.icon;
90
+ item.appendChild(iconEl);
91
+
92
+ const textEl = document.createElement('div');
93
+
94
+ textEl.setAttribute('data-blok-database-view-option-text', '');
95
+
96
+ const labelEl = document.createElement('span');
97
+
98
+ labelEl.setAttribute('data-blok-database-view-option-label', '');
99
+ labelEl.textContent = option.label;
100
+ textEl.appendChild(labelEl);
101
+
102
+ const descEl = document.createElement('span');
103
+
104
+ descEl.setAttribute('data-blok-database-view-option-desc', '');
105
+ descEl.textContent = option.description;
106
+ textEl.appendChild(descEl);
107
+
108
+ item.appendChild(textEl);
109
+
110
+ item.addEventListener('click', () => {
111
+ this.onSelect(option.type);
112
+ });
113
+
114
+ return item;
115
+ }
116
+
117
+ close(): void {
118
+ if (this.popover !== null) {
119
+ const popover = this.popover;
120
+ this.popover = null;
121
+ popover.destroy();
122
+ this.onClose?.();
123
+ }
124
+ }
125
+
126
+ destroy(): void {
127
+ this.close();
128
+ }
129
+ }
@@ -0,0 +1,25 @@
1
+ import type { DatabaseRow, SelectOption } from './types';
2
+
3
+ /**
4
+ * Shared contract for all database view renderers (board, list, etc.).
5
+ * Each implementation receives its data through the constructor and renders via createView().
6
+ */
7
+ export interface DatabaseViewRenderer {
8
+ /** Creates the full view DOM. Data is bound at construction time. */
9
+ createView(): HTMLDivElement;
10
+
11
+ /** Appends a row element to the appropriate container within the view. */
12
+ appendRow(container: HTMLElement, row: DatabaseRow): void;
13
+
14
+ /** Removes a row element from the view by its row ID. */
15
+ removeRow(wrapper: HTMLElement, rowId: string): void;
16
+
17
+ /** Updates the visible title of a row element found by its row ID. */
18
+ updateRowTitle(wrapper: HTMLElement, rowId: string, title: string): void;
19
+
20
+ /** Appends a group container (board: column, list: group section). Optional — not all views support it. */
21
+ appendGroup?(wrapper: HTMLElement, option: SelectOption): void;
22
+
23
+ /** Removes a group container by its option ID. Optional. */
24
+ removeGroup?(wrapper: HTMLElement, optionId: string): void;
25
+ }