@jackuait/blok 0.10.0-beta.3 → 0.10.0-beta.5

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 (251) hide show
  1. package/dist/blok.mjs +2 -2
  2. package/dist/chunks/{blok-CrfCy6RQ.mjs → blok-DH-WEcA8.mjs} +2213 -2200
  3. package/dist/chunks/{constants-BzBmIAnT.mjs → constants-Ccno9NZS.mjs} +86 -64
  4. package/dist/chunks/{i18next-Ch0gVA3V.mjs → i18next-G6FKbZqA.mjs} +1 -1
  5. package/dist/chunks/{i18next-loader-BOlOKRt8.mjs → i18next-loader-CwNimni3.mjs} +2 -2
  6. package/dist/chunks/{lightweight-i18n-D1n0OClP.mjs → lightweight-i18n-DWCdzAw0.mjs} +17 -1
  7. package/dist/{messages-D7Wofcg3.mjs → chunks/messages-1Raf1IK82.mjs} +16 -0
  8. package/dist/chunks/{messages-Du6j7HqD2.mjs → messages-6mikOS4D2.mjs} +16 -0
  9. package/dist/{messages-CyQQ8g9w2.mjs → chunks/messages-B0ffBqzr.mjs} +16 -0
  10. package/dist/{messages-CfaiAQHW2.mjs → chunks/messages-B2pW6jO_.mjs} +16 -0
  11. package/dist/{messages-4kMr3vfK2.mjs → chunks/messages-B3s2vra72.mjs} +16 -0
  12. package/dist/{messages-CBWUNVHy.mjs → chunks/messages-B7MIRzCa2.mjs} +16 -0
  13. package/dist/chunks/{messages-0Nh_GHU02.mjs → messages-BPog17132.mjs} +16 -0
  14. package/dist/chunks/{messages-CbXL5f99.mjs → messages-BS1nOvZ-.mjs} +16 -0
  15. package/dist/{messages-BCIuVjwb.mjs → chunks/messages-BW_7lfqG2.mjs} +16 -0
  16. package/dist/chunks/{messages-naWwXCx3.mjs → messages-BaPZuLjN.mjs} +16 -0
  17. package/dist/chunks/{messages-DcrkPXXn.mjs → messages-BbdNugdi.mjs} +16 -0
  18. package/dist/{messages-CeyO7HXV.mjs → chunks/messages-BdnSVKOw.mjs} +16 -0
  19. package/dist/chunks/{messages-BORQKKT9.mjs → messages-BgVEGd4c.mjs} +16 -0
  20. package/dist/chunks/{messages-C1pm6RWX.mjs → messages-BgsPQXfP.mjs} +16 -0
  21. package/dist/chunks/{messages-CYZgPXFK.mjs → messages-BkCjgGxc.mjs} +16 -0
  22. package/dist/{messages-DB1-0FXB.mjs → chunks/messages-BnznaKEP2.mjs} +16 -0
  23. package/dist/{messages-CIpXgMRr2.mjs → chunks/messages-Bpda_3PM2.mjs} +16 -0
  24. package/dist/{messages-D2GHT83V2.mjs → chunks/messages-BrFl5773.mjs} +16 -0
  25. package/dist/chunks/{messages-BLD1DC722.mjs → messages-C-b6tPad2.mjs} +16 -0
  26. package/dist/chunks/{messages-LiSIeruD2.mjs → messages-C11byid72.mjs} +16 -0
  27. package/dist/chunks/{messages-IKrYzwFq.mjs → messages-C1OqT_nL.mjs} +16 -0
  28. package/dist/chunks/{messages-fitmpwb3.mjs → messages-Cdx4QMR1.mjs} +16 -0
  29. package/dist/{messages-CLB0caVL.mjs → chunks/messages-CgRvtOEY.mjs} +16 -0
  30. package/dist/{messages-BxcqzUx0.mjs → chunks/messages-ClRHDxzh.mjs} +16 -0
  31. package/dist/{messages-DwroI9YW.mjs → chunks/messages-CljStrYi.mjs} +16 -0
  32. package/dist/chunks/{messages-CR48wvl32.mjs → messages-CmXADeab2.mjs} +16 -0
  33. package/dist/{messages-BkZDaKu6.mjs → chunks/messages-CmrMwBv3.mjs} +16 -0
  34. package/dist/chunks/{messages-B7Vlzmgw.mjs → messages-CpzO7KRA.mjs} +16 -0
  35. package/dist/{messages-DwTwecgF2.mjs → chunks/messages-Cqc-6rfh2.mjs} +16 -0
  36. package/dist/chunks/{messages-BN_zp4oj.mjs → messages-CrMfiGu5.mjs} +16 -0
  37. package/dist/{messages-BRlbE8SE.mjs → chunks/messages-Cs9XBt4T.mjs} +16 -0
  38. package/dist/chunks/{messages-DDM4t-j8.mjs → messages-Csvm4mtA.mjs} +16 -0
  39. package/dist/chunks/{messages-CuHxfDvL2.mjs → messages-Ct7AMBS82.mjs} +16 -0
  40. package/dist/{messages-BjEY7_jw.mjs → chunks/messages-CvfKofOP.mjs} +16 -0
  41. package/dist/{messages-Du0fWeyE.mjs → chunks/messages-CyNsByCY.mjs} +16 -0
  42. package/dist/{messages-6Cq_jyNk2.mjs → chunks/messages-Czny5pPT2.mjs} +16 -0
  43. package/dist/{messages-CGqRnKaM.mjs → chunks/messages-D5IgUbBD2.mjs} +16 -0
  44. package/dist/{messages-uP6wmMOs.mjs → chunks/messages-DA7Zk-Cy.mjs} +16 -0
  45. package/dist/chunks/{messages-DJ9yyqUO2.mjs → messages-DAVsuDWh2.mjs} +16 -0
  46. package/dist/chunks/{messages-i9ThpxZk2.mjs → messages-DBpXyvRe2.mjs} +16 -0
  47. package/dist/chunks/{messages-CogKhvJL.mjs → messages-DC7TX-YT.mjs} +16 -0
  48. package/dist/{messages-C-KPP7bC.mjs → chunks/messages-DD7BI6BK.mjs} +16 -0
  49. package/dist/{messages-ZMa-zmIc.mjs → chunks/messages-DHCVA7XQ.mjs} +16 -0
  50. package/dist/chunks/{messages-BPQA3B862.mjs → messages-DJA6fb_P2.mjs} +16 -0
  51. package/dist/chunks/{messages-D9SfB6MI.mjs → messages-DJkIeapn.mjs} +16 -0
  52. package/dist/{messages-CZkwcbV12.mjs → chunks/messages-DPykxECP2.mjs} +16 -0
  53. package/dist/chunks/{messages-BQvBhQem.mjs → messages-DQ5AyNCU.mjs} +16 -0
  54. package/dist/chunks/{messages-rxlf-Ule.mjs → messages-DR09nkcZ.mjs} +16 -0
  55. package/dist/chunks/{messages-B1uFbxNg.mjs → messages-DSjXen8E.mjs} +16 -0
  56. package/dist/chunks/{messages-OFFQT8Fg.mjs → messages-DT7fRpCy.mjs} +16 -0
  57. package/dist/{messages-DnNNd3RW2.mjs → chunks/messages-DUDgFEEe2.mjs} +16 -0
  58. package/dist/chunks/{messages-7PIvzufT.mjs → messages-Df87zXXG.mjs} +16 -0
  59. package/dist/chunks/{messages-CvA7Fbqf.mjs → messages-Dfpi8pDY.mjs} +16 -0
  60. package/dist/{messages-CXlAjnEQ.mjs → chunks/messages-Dm4YVlrm.mjs} +16 -0
  61. package/dist/chunks/{messages-CuJLHCj5.mjs → messages-Dplnp19q.mjs} +16 -0
  62. package/dist/{messages-DEfeDBuV2.mjs → chunks/messages-FHrCEJmY2.mjs} +16 -0
  63. package/dist/chunks/{messages-nZP1GShd.mjs → messages-ID1PHnMv.mjs} +16 -0
  64. package/dist/{messages-BiK5fMYF2.mjs → chunks/messages-IDEUsFhQ2.mjs} +16 -0
  65. package/dist/{messages-C672uqt-.mjs → chunks/messages-JQKFJo7C.mjs} +16 -0
  66. package/dist/{messages-DVHWIOfr2.mjs → chunks/messages-LxumrNue2.mjs} +16 -0
  67. package/dist/chunks/{messages-By-gACFM2.mjs → messages-R2W_rGOo2.mjs} +16 -0
  68. package/dist/chunks/{messages-FEjIF48t.mjs → messages-ZJ0b1C3a.mjs} +16 -0
  69. package/dist/{messages-nosa-xnx2.mjs → chunks/messages-d0Ky6QjR.mjs} +16 -0
  70. package/dist/{messages-CHaVGY89.mjs → chunks/messages-p4byLfvR.mjs} +16 -0
  71. package/dist/{messages-D-bnq2qy.mjs → chunks/messages-u2yxkNTE2.mjs} +16 -0
  72. package/dist/{messages-axsznSTn2.mjs → chunks/messages-wLSVQbsA2.mjs} +16 -0
  73. package/dist/chunks/{messages-DiaQNuPV.mjs → messages-xfjdrZmx.mjs} +16 -0
  74. package/dist/chunks/{objectSpread2-CyPxu8-u.mjs → objectSpread2-BY4mgzrQ.mjs} +1 -1
  75. package/dist/chunks/{tools-B6tibTzs.mjs → tools-C2_IVsQY.mjs} +2868 -1082
  76. package/dist/full.mjs +11 -11
  77. package/dist/locales.mjs +83 -67
  78. package/dist/{messages-BfbYJ8Wk2.mjs → messages--S8_taOd2.mjs} +16 -0
  79. package/dist/{chunks/messages-CkWidbwX2.mjs → messages-B-4fku2H2.mjs} +16 -0
  80. package/dist/{chunks/messages-Dn1ZDZUy.mjs → messages-BAcH6PtT2.mjs} +16 -0
  81. package/dist/{chunks/messages-2nj1xBDo.mjs → messages-BBq0M604.mjs} +16 -0
  82. package/dist/{messages-Dzqb5lg6.mjs → messages-BBvDbp62.mjs} +16 -0
  83. package/dist/{messages-kuLrhtV2.mjs → messages-BCG_evLg.mjs} +16 -0
  84. package/dist/{messages-DEKkIgU6.mjs → messages-BCuTVHBV.mjs} +16 -0
  85. package/dist/{chunks/messages-CYZL_rhV2.mjs → messages-BGsDZTQp2.mjs} +16 -0
  86. package/dist/{chunks/messages-cMwiuDZM.mjs → messages-BJ7BuFZi.mjs} +16 -0
  87. package/dist/{chunks/messages-Dl16RBg1.mjs → messages-BKjqW08U.mjs} +16 -0
  88. package/dist/{messages-Daza4lOM.mjs → messages-BSe3QDnQ.mjs} +16 -0
  89. package/dist/{chunks/messages-CDV8VcSZ2.mjs → messages-BVKZK-3t.mjs} +16 -0
  90. package/dist/{messages-CcPrYMHE.mjs → messages-BXI3qIos.mjs} +16 -0
  91. package/dist/{messages-B_6S7hBj2.mjs → messages-BcFQFcJ92.mjs} +16 -0
  92. package/dist/{chunks/messages-CmSsyItg.mjs → messages-Bio7KYsr2.mjs} +16 -0
  93. package/dist/{chunks/messages-CqdYWY192.mjs → messages-Bk984gRE2.mjs} +16 -0
  94. package/dist/{chunks/messages-CQgP-Fo22.mjs → messages-BmNaAyKS.mjs} +16 -0
  95. package/dist/{messages-DbPt9d2U.mjs → messages-Bo_FUvVH.mjs} +16 -0
  96. package/dist/{chunks/messages-x6GyZWWT.mjs → messages-BokEflKa.mjs} +16 -0
  97. package/dist/{chunks/messages-C9qPNbrJ2.mjs → messages-BtxaN-xx.mjs} +16 -0
  98. package/dist/{messages-6edZhK922.mjs → messages-BvgTQLf72.mjs} +16 -0
  99. package/dist/{chunks/messages-BVl-X2wo2.mjs → messages-BvgXeMSL2.mjs} +16 -0
  100. package/dist/{messages-BBauvpFc.mjs → messages-BywbKcPC.mjs} +16 -0
  101. package/dist/{chunks/messages-D06U2QNl2.mjs → messages-C30Vz-UZ2.mjs} +16 -0
  102. package/dist/{messages-BwyQiBdm2.mjs → messages-C5XPUD9T2.mjs} +16 -0
  103. package/dist/{chunks/messages-BivhofAQ2.mjs → messages-C6OJvnJg2.mjs} +16 -0
  104. package/dist/{chunks/messages-D6ZvH6hX.mjs → messages-C6Y4Jv2N.mjs} +16 -0
  105. package/dist/{messages-DaFDdCrr.mjs → messages-CBdQ3XP9.mjs} +16 -0
  106. package/dist/{chunks/messages-KihEeXdr.mjs → messages-CBzd_x7H.mjs} +16 -0
  107. package/dist/{messages-CsVZUVra.mjs → messages-CHJ5SOZI.mjs} +16 -0
  108. package/dist/{messages-us2JotS-2.mjs → messages-CM5fsPo02.mjs} +16 -0
  109. package/dist/{chunks/messages-DjhgPQtb.mjs → messages-CVcQD-9u.mjs} +16 -0
  110. package/dist/{messages-BQi_l2vs.mjs → messages-CYX48nfg.mjs} +16 -0
  111. package/dist/{chunks/messages-BF8c-lMm.mjs → messages-Ccd587Yn.mjs} +16 -0
  112. package/dist/{chunks/messages-5WyxUYVR2.mjs → messages-CdlsTFB1.mjs} +16 -0
  113. package/dist/{messages-ke15helG2.mjs → messages-CgzbJ8_l2.mjs} +16 -0
  114. package/dist/{messages-D1-_eTfM.mjs → messages-CjmSrt1D.mjs} +16 -0
  115. package/dist/{chunks/messages-C7YpgZ9m.mjs → messages-CqkRG9mH.mjs} +16 -0
  116. package/dist/{messages-Dtw27ih4.mjs → messages-D3cAcyzj.mjs} +16 -0
  117. package/dist/{messages-CLN3oL77.mjs → messages-DA-o8X3A.mjs} +16 -0
  118. package/dist/{chunks/messages-BtZ8oQXS.mjs → messages-DD5pW0zJ.mjs} +16 -0
  119. package/dist/{chunks/messages-A3Z4jxwt2.mjs → messages-DIRha_gg2.mjs} +16 -0
  120. package/dist/{chunks/messages-rnd6qiJ12.mjs → messages-DJKLtW7u.mjs} +16 -0
  121. package/dist/{messages-h_VN1Kyo2.mjs → messages-DJT4Bt_02.mjs} +16 -0
  122. package/dist/{chunks/messages-D3hNTep_.mjs → messages-DOTJ2NvJ.mjs} +16 -0
  123. package/dist/{chunks/messages-B18MZnaY.mjs → messages-DUBHHfEt.mjs} +16 -0
  124. package/dist/{chunks/messages-92ma9RJD2.mjs → messages-DV9e1DW7.mjs} +16 -0
  125. package/dist/{chunks/messages-DQUUtL5v.mjs → messages-DVQNjdPk.mjs} +16 -0
  126. package/dist/{messages-DflAKRLd.mjs → messages-DZEcrbmH.mjs} +16 -0
  127. package/dist/{messages-BLjz6V7y2.mjs → messages-DbxbxUiK2.mjs} +16 -0
  128. package/dist/{messages-QkGAxuVC2.mjs → messages-Dcyrzdxa2.mjs} +16 -0
  129. package/dist/{chunks/messages-DBZ-uuAV.mjs → messages-Dddxv8-f2.mjs} +16 -0
  130. package/dist/{messages-DVILiJw52.mjs → messages-DjJQoYvP2.mjs} +16 -0
  131. package/dist/{messages-B-lXqB1z2.mjs → messages-Dkg99bfr2.mjs} +16 -0
  132. package/dist/{messages-CCBgCmyq.mjs → messages-DnatBKPm.mjs} +16 -0
  133. package/dist/{messages-Dn-khi3a.mjs → messages-DqyqEw1_.mjs} +16 -0
  134. package/dist/{chunks/messages-D4QXMtW52.mjs → messages-DtrSrdfE2.mjs} +16 -0
  135. package/dist/{messages-BHIdzfAS2.mjs → messages-JhoVMjfX2.mjs} +16 -0
  136. package/dist/{messages-YlWV9cSl.mjs → messages-eTourT12.mjs} +16 -0
  137. package/dist/{messages-DzlmoWqQ.mjs → messages-fLi0P2dP.mjs} +16 -0
  138. package/dist/{messages-C-v50b4r.mjs → messages-hTpeKUaW.mjs} +16 -0
  139. package/dist/{chunks/messages-16UmLAWZ2.mjs → messages-i4S6q64n2.mjs} +16 -0
  140. package/dist/{messages-DP9PhNTo.mjs → messages-pgPcitDH.mjs} +16 -0
  141. package/dist/{chunks/messages-D5iRrf9M.mjs → messages-tK67CBqn.mjs} +16 -0
  142. package/dist/{chunks/messages-BTyEo5Kb.mjs → messages-tsHpMdDT2.mjs} +16 -0
  143. package/dist/{chunks/messages-Ct_H_5cB2.mjs → messages-upqrRZQH2.mjs} +16 -0
  144. package/dist/{messages-CyZZ10br.mjs → messages-xEI8gEDK.mjs} +16 -0
  145. package/dist/react.mjs +3 -3
  146. package/dist/tools.mjs +3 -3
  147. package/dist/vendor.LICENSE.txt +136 -1
  148. package/package.json +2 -1
  149. package/src/components/block/style-manager.ts +1 -1
  150. package/src/components/i18n/locales/am/messages.json +16 -0
  151. package/src/components/i18n/locales/ar/messages.json +16 -0
  152. package/src/components/i18n/locales/az/messages.json +16 -0
  153. package/src/components/i18n/locales/bg/messages.json +16 -0
  154. package/src/components/i18n/locales/bn/messages.json +16 -0
  155. package/src/components/i18n/locales/bs/messages.json +16 -0
  156. package/src/components/i18n/locales/cs/messages.json +16 -0
  157. package/src/components/i18n/locales/da/messages.json +16 -0
  158. package/src/components/i18n/locales/de/messages.json +16 -0
  159. package/src/components/i18n/locales/dv/messages.json +16 -0
  160. package/src/components/i18n/locales/el/messages.json +16 -0
  161. package/src/components/i18n/locales/en/messages.json +16 -0
  162. package/src/components/i18n/locales/es/messages.json +16 -0
  163. package/src/components/i18n/locales/et/messages.json +16 -0
  164. package/src/components/i18n/locales/fa/messages.json +16 -0
  165. package/src/components/i18n/locales/fi/messages.json +16 -0
  166. package/src/components/i18n/locales/fil/messages.json +16 -0
  167. package/src/components/i18n/locales/fr/messages.json +16 -0
  168. package/src/components/i18n/locales/gu/messages.json +16 -0
  169. package/src/components/i18n/locales/he/messages.json +16 -0
  170. package/src/components/i18n/locales/hi/messages.json +16 -0
  171. package/src/components/i18n/locales/hr/messages.json +16 -0
  172. package/src/components/i18n/locales/hu/messages.json +16 -0
  173. package/src/components/i18n/locales/hy/messages.json +16 -0
  174. package/src/components/i18n/locales/id/messages.json +16 -0
  175. package/src/components/i18n/locales/it/messages.json +16 -0
  176. package/src/components/i18n/locales/ja/messages.json +16 -0
  177. package/src/components/i18n/locales/ka/messages.json +16 -0
  178. package/src/components/i18n/locales/km/messages.json +16 -0
  179. package/src/components/i18n/locales/kn/messages.json +16 -0
  180. package/src/components/i18n/locales/ko/messages.json +16 -0
  181. package/src/components/i18n/locales/ku/messages.json +16 -0
  182. package/src/components/i18n/locales/lo/messages.json +16 -0
  183. package/src/components/i18n/locales/lt/messages.json +16 -0
  184. package/src/components/i18n/locales/lv/messages.json +16 -0
  185. package/src/components/i18n/locales/mk/messages.json +16 -0
  186. package/src/components/i18n/locales/ml/messages.json +16 -0
  187. package/src/components/i18n/locales/mn/messages.json +16 -0
  188. package/src/components/i18n/locales/mr/messages.json +16 -0
  189. package/src/components/i18n/locales/ms/messages.json +16 -0
  190. package/src/components/i18n/locales/my/messages.json +16 -0
  191. package/src/components/i18n/locales/ne/messages.json +16 -0
  192. package/src/components/i18n/locales/nl/messages.json +16 -0
  193. package/src/components/i18n/locales/no/messages.json +16 -0
  194. package/src/components/i18n/locales/pa/messages.json +16 -0
  195. package/src/components/i18n/locales/pl/messages.json +16 -0
  196. package/src/components/i18n/locales/ps/messages.json +16 -0
  197. package/src/components/i18n/locales/pt/messages.json +16 -0
  198. package/src/components/i18n/locales/ro/messages.json +16 -0
  199. package/src/components/i18n/locales/ru/messages.json +16 -0
  200. package/src/components/i18n/locales/sd/messages.json +16 -0
  201. package/src/components/i18n/locales/si/messages.json +16 -0
  202. package/src/components/i18n/locales/sk/messages.json +16 -0
  203. package/src/components/i18n/locales/sl/messages.json +16 -0
  204. package/src/components/i18n/locales/sq/messages.json +16 -0
  205. package/src/components/i18n/locales/sr/messages.json +16 -0
  206. package/src/components/i18n/locales/sv/messages.json +16 -0
  207. package/src/components/i18n/locales/sw/messages.json +16 -0
  208. package/src/components/i18n/locales/ta/messages.json +16 -0
  209. package/src/components/i18n/locales/te/messages.json +16 -0
  210. package/src/components/i18n/locales/th/messages.json +16 -0
  211. package/src/components/i18n/locales/tr/messages.json +16 -0
  212. package/src/components/i18n/locales/ug/messages.json +16 -0
  213. package/src/components/i18n/locales/uk/messages.json +16 -0
  214. package/src/components/i18n/locales/ur/messages.json +16 -0
  215. package/src/components/i18n/locales/vi/messages.json +16 -0
  216. package/src/components/i18n/locales/yi/messages.json +16 -0
  217. package/src/components/i18n/locales/zh/messages.json +16 -0
  218. package/src/components/icons/index.ts +56 -0
  219. package/src/components/modules/api/tools.ts +19 -0
  220. package/src/components/modules/blockEvents/composers/keyboardNavigation.ts +5 -5
  221. package/src/components/modules/blockManager/blockManager.ts +11 -0
  222. package/src/components/modules/blockManager/event-binder.ts +12 -1
  223. package/src/components/modules/themeManager.ts +3 -1
  224. package/src/components/modules/toolbar/blockSettings.ts +0 -1
  225. package/src/components/modules/toolbar/inline/index.ts +0 -3
  226. package/src/components/modules/uiControllers/controllers/keyboard.ts +29 -0
  227. package/src/components/modules/uiControllers/controllers/selection.ts +14 -2
  228. package/src/components/ui/toolbox.ts +0 -1
  229. package/src/components/utils/popover/popover-position.ts +4 -2
  230. package/src/styles/main.css +1139 -0
  231. package/src/tools/callout/constants.ts +2 -1
  232. package/src/tools/database/database-backend-sync.ts +101 -0
  233. package/src/tools/database/database-board-view.ts +301 -0
  234. package/src/tools/database/database-card-drag.ts +306 -0
  235. package/src/tools/database/database-card-drawer.ts +546 -0
  236. package/src/tools/database/database-column-controls.ts +46 -0
  237. package/src/tools/database/database-column-drag.ts +262 -0
  238. package/src/tools/database/database-keyboard.ts +35 -0
  239. package/src/tools/database/database-list-row-drag.ts +245 -0
  240. package/src/tools/database/database-list-view.ts +333 -0
  241. package/src/tools/database/database-model.ts +246 -0
  242. package/src/tools/database/database-property-type-popover.ts +108 -0
  243. package/src/tools/database/database-tab-bar.ts +532 -0
  244. package/src/tools/database/database-view-popover.ts +109 -0
  245. package/src/tools/database/database-view-renderer.ts +25 -0
  246. package/src/tools/database/index.ts +948 -0
  247. package/src/tools/database/types.ts +144 -0
  248. package/src/tools/index.ts +2 -0
  249. package/types/api/tools.d.ts +18 -0
  250. package/types/index.d.ts +16 -0
  251. package/types/tools/database.d.ts +145 -0
@@ -0,0 +1,532 @@
1
+ import { generateKeyBetween } from 'fractional-indexing';
2
+ import { IconBoard, IconList, IconPencil, IconCopy, IconTrash } from '../../components/icons';
3
+ import { DatabaseViewPopover } from './database-view-popover';
4
+ import type { DatabaseViewConfig, ViewType } from './types';
5
+
6
+ const DRAG_THRESHOLD = 10;
7
+
8
+ const VIEW_ICONS: Record<string, string> = {
9
+ board: IconBoard,
10
+ list: IconList,
11
+ };
12
+
13
+ export interface TabBarOptions {
14
+ views: DatabaseViewConfig[];
15
+ activeViewId: string;
16
+ onTabClick: (viewId: string) => void;
17
+ onAddView: (type: ViewType) => void;
18
+ onRename: (viewId: string, newName: string) => void;
19
+ onDuplicate: (viewId: string) => void;
20
+ onDelete: (viewId: string) => void;
21
+ onReorder: (viewId: string, newPosition: string) => void;
22
+ }
23
+
24
+ export class DatabaseTabBar {
25
+ private readonly options: TabBarOptions;
26
+ private readonly views: DatabaseViewConfig[];
27
+ private readonly onReorder: (viewId: string, newPosition: string) => void;
28
+ private element: HTMLElement | null = null;
29
+ private barEl: HTMLElement | null = null;
30
+ private viewPopover: DatabaseViewPopover | null = null;
31
+ private contextPopoverEl: HTMLElement | null = null;
32
+ private boundOutsideContextClick: ((e: MouseEvent) => void) | null = null;
33
+
34
+ private overflowDropdownEl: HTMLElement | null = null;
35
+ private boundOverflowClose: ((e: MouseEvent) => void) | null = null;
36
+ private moreBtnEl: HTMLElement | null = null;
37
+
38
+ private isDragging = false;
39
+ private dragViewId = '';
40
+ private dragStartX = 0;
41
+ private ghostEl: HTMLElement | null = null;
42
+ private readonly boundDragMove: (e: PointerEvent) => void;
43
+ private readonly boundDragUp: (e: PointerEvent) => void;
44
+ private readonly boundDragCancel: () => void;
45
+ private readonly boundDragKeyDown: (e: KeyboardEvent) => void;
46
+
47
+ constructor(options: TabBarOptions) {
48
+ this.options = options;
49
+ this.views = options.views;
50
+ this.onReorder = options.onReorder;
51
+
52
+ this.boundDragMove = this.handleDragMove.bind(this);
53
+ this.boundDragUp = this.handleDragUp.bind(this);
54
+ this.boundDragCancel = this.cleanupDrag.bind(this);
55
+ this.boundDragKeyDown = (e: KeyboardEvent): void => {
56
+ if (e.key === 'Escape') { this.cleanupDrag(); }
57
+ };
58
+ }
59
+
60
+ render(): HTMLElement {
61
+ const bar = document.createElement('div');
62
+ bar.setAttribute('data-blok-database-tab-bar', '');
63
+ this.barEl = bar;
64
+ this.element = bar;
65
+
66
+ const sorted = [...this.options.views].sort((a, b) => (a.position < b.position ? -1 : 1));
67
+
68
+ for (const view of sorted) {
69
+ bar.appendChild(this.createTab(view));
70
+ }
71
+
72
+ const addBtn = document.createElement('button');
73
+ addBtn.setAttribute('data-blok-database-add-view', '');
74
+ addBtn.textContent = '+';
75
+ addBtn.addEventListener('click', () => {
76
+ this.openViewPopover(addBtn);
77
+ });
78
+ bar.appendChild(addBtn);
79
+
80
+ bar.addEventListener('click', (e: MouseEvent) => {
81
+ const target = e.target as HTMLElement;
82
+ const tab = target.closest('[data-blok-database-tab]');
83
+ if (!(tab instanceof HTMLElement)) {
84
+ return;
85
+ }
86
+ const viewId = tab.getAttribute('data-view-id');
87
+ if (viewId === null) {
88
+ return;
89
+ }
90
+ if (tab.hasAttribute('data-active')) {
91
+ return;
92
+ }
93
+ this.options.onTabClick(viewId);
94
+ });
95
+
96
+ bar.addEventListener('contextmenu', (e: MouseEvent) => {
97
+ const target = e.target as HTMLElement;
98
+ const tab = target.closest('[data-blok-database-tab]');
99
+ if (!(tab instanceof HTMLElement)) {
100
+ return;
101
+ }
102
+ e.preventDefault();
103
+ const viewId = tab.getAttribute('data-view-id');
104
+ if (viewId === null) {
105
+ return;
106
+ }
107
+ this.openContextPopover(tab, viewId);
108
+ });
109
+
110
+ bar.addEventListener('pointerdown', (e) => {
111
+ const target = e.target as HTMLElement;
112
+ const tab = target.closest<HTMLElement>('[data-blok-database-tab]');
113
+ if (tab === null) return;
114
+ const viewId = tab.getAttribute('data-view-id');
115
+ if (viewId === null) return;
116
+ this.dragViewId = viewId;
117
+ this.dragStartX = e.clientX;
118
+ this.isDragging = false;
119
+ document.addEventListener('pointermove', this.boundDragMove);
120
+ document.addEventListener('pointerup', this.boundDragUp);
121
+ document.addEventListener('pointercancel', this.boundDragCancel);
122
+ document.addEventListener('keydown', this.boundDragKeyDown);
123
+ });
124
+
125
+ if (typeof ResizeObserver !== 'undefined') {
126
+ const ro = new ResizeObserver(() => {
127
+ if (this.element === null) {
128
+ return;
129
+ }
130
+
131
+ const tabs = Array.from(this.element.querySelectorAll<HTMLElement>('[data-blok-database-tab]'));
132
+
133
+ for (const tab of tabs) {
134
+ tab.style.display = '';
135
+ }
136
+ this.moreBtnEl?.remove();
137
+ this.moreBtnEl = null;
138
+
139
+ const barWidth = this.element.clientWidth;
140
+ const addBtnWidth = 40;
141
+ const visibleCount = tabs.findIndex((_tab, i) => {
142
+ const consumed = addBtnWidth + tabs.slice(0, i + 1).reduce((w, t) => w + t.offsetWidth + 2, 0);
143
+
144
+ return consumed > barWidth;
145
+ });
146
+ const resolved = visibleCount === -1 ? tabs.length : visibleCount;
147
+
148
+ if (resolved < tabs.length) {
149
+ this.handleOverflow(resolved);
150
+ }
151
+ });
152
+
153
+ ro.observe(bar);
154
+ }
155
+
156
+ return bar;
157
+ }
158
+
159
+ private createTab(view: DatabaseViewConfig): HTMLElement {
160
+ const tab = document.createElement('div');
161
+ tab.setAttribute('data-blok-database-tab', '');
162
+ tab.setAttribute('data-view-id', view.id);
163
+
164
+ if (view.id === this.options.activeViewId) {
165
+ tab.setAttribute('data-active', '');
166
+ }
167
+
168
+ const iconSpan = document.createElement('span');
169
+ iconSpan.innerHTML = VIEW_ICONS[view.type] ?? '';
170
+ tab.appendChild(iconSpan);
171
+
172
+ const nameSpan = document.createElement('span');
173
+ nameSpan.setAttribute('data-blok-database-tab-name', '');
174
+ nameSpan.textContent = view.name;
175
+ tab.appendChild(nameSpan);
176
+
177
+ return tab;
178
+ }
179
+
180
+ private openContextPopover(tab: HTMLElement, viewId: string): void {
181
+ this.closeContextPopover();
182
+
183
+ const popover = document.createElement('div');
184
+ popover.setAttribute('data-blok-popover', '');
185
+ popover.setAttribute('data-blok-database-tab-context', '');
186
+ popover.style.position = 'fixed';
187
+ popover.style.zIndex = '1000';
188
+
189
+ const rect = tab.getBoundingClientRect();
190
+ popover.style.top = `${rect.bottom + 4}px`;
191
+ popover.style.left = `${rect.left}px`;
192
+
193
+ const renameItem = document.createElement('div');
194
+ renameItem.setAttribute('data-blok-database-tab-action', 'rename');
195
+ const renameIcon = document.createElement('span');
196
+ renameIcon.setAttribute('data-blok-database-tab-action-icon', '');
197
+ renameIcon.innerHTML = IconPencil;
198
+ renameItem.appendChild(renameIcon);
199
+ const renameLabel = document.createElement('span');
200
+ renameLabel.textContent = 'Rename';
201
+ renameItem.appendChild(renameLabel);
202
+ renameItem.addEventListener('click', () => {
203
+ this.closeContextPopover();
204
+ this.startInlineRename(tab, viewId);
205
+ });
206
+ popover.appendChild(renameItem);
207
+
208
+ const duplicateItem = document.createElement('div');
209
+ duplicateItem.setAttribute('data-blok-database-tab-action', 'duplicate');
210
+ const duplicateIcon = document.createElement('span');
211
+ duplicateIcon.setAttribute('data-blok-database-tab-action-icon', '');
212
+ duplicateIcon.innerHTML = IconCopy;
213
+ duplicateItem.appendChild(duplicateIcon);
214
+ const duplicateLabel = document.createElement('span');
215
+ duplicateLabel.textContent = 'Duplicate';
216
+ duplicateItem.appendChild(duplicateLabel);
217
+ duplicateItem.addEventListener('click', () => {
218
+ this.closeContextPopover();
219
+ this.options.onDuplicate(viewId);
220
+ });
221
+ popover.appendChild(duplicateItem);
222
+
223
+ const separator = document.createElement('div');
224
+ separator.setAttribute('data-blok-database-tab-context-separator', '');
225
+ if (this.options.views.length === 1) {
226
+ separator.style.display = 'none';
227
+ }
228
+ popover.appendChild(separator);
229
+
230
+ const deleteItem = document.createElement('div');
231
+ deleteItem.setAttribute('data-blok-database-tab-action', 'delete');
232
+ const deleteIcon = document.createElement('span');
233
+ deleteIcon.setAttribute('data-blok-database-tab-action-icon', '');
234
+ deleteIcon.innerHTML = IconTrash;
235
+ deleteItem.appendChild(deleteIcon);
236
+ const deleteLabel = document.createElement('span');
237
+ deleteLabel.textContent = 'Delete';
238
+ deleteItem.appendChild(deleteLabel);
239
+ if (this.options.views.length === 1) {
240
+ deleteItem.style.display = 'none';
241
+ }
242
+ deleteItem.addEventListener('click', () => {
243
+ this.closeContextPopover();
244
+ this.options.onDelete(viewId);
245
+ });
246
+ popover.appendChild(deleteItem);
247
+
248
+ document.body.appendChild(popover);
249
+ this.contextPopoverEl = popover;
250
+
251
+ this.boundOutsideContextClick = (e: MouseEvent): void => {
252
+ const target = e.target as HTMLElement;
253
+ if (!popover.contains(target) && !tab.contains(target)) {
254
+ this.closeContextPopover();
255
+ }
256
+ };
257
+
258
+ document.addEventListener('mousedown', this.boundOutsideContextClick);
259
+ }
260
+
261
+ private closeContextPopover(): void {
262
+ if (this.contextPopoverEl !== null) {
263
+ this.contextPopoverEl.remove();
264
+ this.contextPopoverEl = null;
265
+ }
266
+ if (this.boundOutsideContextClick !== null) {
267
+ document.removeEventListener('mousedown', this.boundOutsideContextClick);
268
+ this.boundOutsideContextClick = null;
269
+ }
270
+ }
271
+
272
+ private startInlineRename(tab: HTMLElement, viewId: string): void {
273
+ const nameSpan = tab.querySelector('[data-blok-database-tab-name]');
274
+ if (!(nameSpan instanceof HTMLElement)) {
275
+ return;
276
+ }
277
+
278
+ const originalName = nameSpan.textContent ?? '';
279
+
280
+ const input = document.createElement('input');
281
+ input.setAttribute('data-blok-database-tab-rename-input', '');
282
+ input.value = originalName;
283
+ nameSpan.replaceWith(input);
284
+ input.focus();
285
+ input.select();
286
+
287
+ const commit = (): void => {
288
+ const newName = input.value.trim() || originalName;
289
+ const newSpan = document.createElement('span');
290
+ newSpan.setAttribute('data-blok-database-tab-name', '');
291
+ newSpan.textContent = newName;
292
+ input.replaceWith(newSpan);
293
+ if (newName !== originalName) {
294
+ this.options.onRename(viewId, newName);
295
+ }
296
+ };
297
+
298
+ input.addEventListener('blur', commit);
299
+ input.addEventListener('keydown', (e: KeyboardEvent) => {
300
+ e.stopPropagation();
301
+ if (e.key === 'Enter') {
302
+ input.blur();
303
+ } else if (e.key === 'Escape') {
304
+ input.removeEventListener('blur', commit);
305
+ const cancelSpan = document.createElement('span');
306
+ cancelSpan.setAttribute('data-blok-database-tab-name', '');
307
+ cancelSpan.textContent = originalName;
308
+ input.replaceWith(cancelSpan);
309
+ }
310
+ });
311
+ }
312
+
313
+ private openViewPopover(anchor: HTMLElement): void {
314
+ if (this.viewPopover !== null) {
315
+ this.viewPopover.destroy();
316
+ }
317
+ this.viewPopover = new DatabaseViewPopover({
318
+ onSelect: (type) => {
319
+ this.options.onAddView(type);
320
+ },
321
+ });
322
+ this.viewPopover.open(anchor);
323
+ }
324
+
325
+ handleOverflow(visibleCount: number): void {
326
+ if (this.element === null) return;
327
+
328
+ // Remove existing more button
329
+ this.moreBtnEl?.remove();
330
+
331
+ const orderedViews = [...this.views].sort((a, b) => (a.position < b.position ? -1 : 1));
332
+ const hiddenCount = orderedViews.length - visibleCount;
333
+ if (hiddenCount <= 0) return;
334
+
335
+ // Hide overflow tabs
336
+ const tabs = Array.from(this.element.querySelectorAll<HTMLElement>('[data-blok-database-tab]'));
337
+
338
+ for (const tab of tabs.slice(visibleCount)) {
339
+ tab.style.display = 'none';
340
+ }
341
+
342
+ // Add "N more..." button before the + button
343
+ const moreBtn = document.createElement('div');
344
+ moreBtn.setAttribute('data-blok-database-tab-more', '');
345
+ moreBtn.textContent = `${hiddenCount} more...`;
346
+ moreBtn.style.cursor = 'pointer';
347
+ moreBtn.addEventListener('click', () => {
348
+ this.openOverflowDropdown(moreBtn);
349
+ });
350
+
351
+ const addBtn = this.element.querySelector('[data-blok-database-add-view]');
352
+ if (addBtn !== null) {
353
+ this.element.insertBefore(moreBtn, addBtn);
354
+ } else {
355
+ this.element.appendChild(moreBtn);
356
+ }
357
+ this.moreBtnEl = moreBtn;
358
+ }
359
+
360
+ private openOverflowDropdown(anchor: HTMLElement): void {
361
+ this.closeOverflowDropdown();
362
+
363
+ const dropdown = document.createElement('div');
364
+ dropdown.setAttribute('data-blok-popover', '');
365
+ dropdown.setAttribute('data-blok-database-tab-overflow-dropdown', '');
366
+ dropdown.style.position = 'fixed';
367
+ dropdown.style.zIndex = '1000';
368
+
369
+ const rect = anchor.getBoundingClientRect();
370
+ dropdown.style.top = `${rect.bottom + 4}px`;
371
+ dropdown.style.left = `${rect.left}px`;
372
+
373
+ const orderedViews = [...this.views].sort((a, b) => (a.position < b.position ? -1 : 1));
374
+
375
+ for (const view of orderedViews) {
376
+ const item = document.createElement('div');
377
+ item.setAttribute('data-blok-database-tab-overflow-item', '');
378
+ item.setAttribute('data-view-id', view.id);
379
+
380
+ if (view.id === this.options.activeViewId) {
381
+ item.setAttribute('data-active', '');
382
+ }
383
+
384
+ const iconSpan = document.createElement('span');
385
+ iconSpan.innerHTML = VIEW_ICONS[view.type] ?? '';
386
+ item.appendChild(iconSpan);
387
+
388
+ const nameSpan = document.createElement('span');
389
+ nameSpan.textContent = view.name;
390
+ item.appendChild(nameSpan);
391
+
392
+ item.addEventListener('click', () => {
393
+ if (view.id !== this.options.activeViewId) {
394
+ this.options.onTabClick(view.id);
395
+ }
396
+ this.closeOverflowDropdown();
397
+ });
398
+
399
+ dropdown.appendChild(item);
400
+ }
401
+
402
+ const separator = document.createElement('div');
403
+ separator.setAttribute('data-blok-database-tab-overflow-separator', '');
404
+ dropdown.appendChild(separator);
405
+
406
+ const addBtn = this.element?.querySelector<HTMLElement>('[data-blok-database-add-view]');
407
+ const newViewBtn = document.createElement('div');
408
+ newViewBtn.setAttribute('data-blok-database-tab-overflow-new', '');
409
+ newViewBtn.textContent = '+ New view';
410
+ newViewBtn.addEventListener('click', () => {
411
+ this.closeOverflowDropdown();
412
+ if (addBtn !== null && addBtn !== undefined) {
413
+ this.openViewPopover(addBtn);
414
+ }
415
+ });
416
+ dropdown.appendChild(newViewBtn);
417
+
418
+ document.body.appendChild(dropdown);
419
+ this.overflowDropdownEl = dropdown;
420
+
421
+ this.boundOverflowClose = (e: MouseEvent): void => {
422
+ const target = e.target as HTMLElement;
423
+ if (!dropdown.contains(target) && !anchor.contains(target)) {
424
+ this.closeOverflowDropdown();
425
+ }
426
+ };
427
+
428
+ document.addEventListener('mousedown', this.boundOverflowClose);
429
+ }
430
+
431
+ private closeOverflowDropdown(): void {
432
+ if (this.overflowDropdownEl !== null) {
433
+ this.overflowDropdownEl.remove();
434
+ this.overflowDropdownEl = null;
435
+ }
436
+ if (this.boundOverflowClose !== null) {
437
+ document.removeEventListener('mousedown', this.boundOverflowClose);
438
+ this.boundOverflowClose = null;
439
+ }
440
+ }
441
+
442
+ private handleDragMove(e: PointerEvent): void {
443
+ const dx = Math.abs(e.clientX - this.dragStartX);
444
+ if (!this.isDragging && dx < DRAG_THRESHOLD) return;
445
+ if (!this.isDragging) {
446
+ this.isDragging = true;
447
+ this.element?.setAttribute('data-dragging', '');
448
+ const sourceTab = this.element?.querySelector(`[data-view-id="${this.dragViewId}"]`) as HTMLElement | null;
449
+ if (sourceTab !== null) {
450
+ this.ghostEl = sourceTab.cloneNode(true) as HTMLElement;
451
+ this.ghostEl.setAttribute('data-blok-database-tab-ghost', '');
452
+ this.ghostEl.style.position = 'fixed';
453
+ this.ghostEl.style.pointerEvents = 'none';
454
+ this.ghostEl.style.zIndex = '50';
455
+ this.ghostEl.style.opacity = '0.7';
456
+ const rect = sourceTab.getBoundingClientRect();
457
+ this.ghostEl.style.top = `${rect.top}px`;
458
+ this.ghostEl.style.width = `${rect.width}px`;
459
+ document.body.appendChild(this.ghostEl);
460
+ sourceTab.style.opacity = '0.4';
461
+ }
462
+ }
463
+ if (this.ghostEl !== null) {
464
+ this.ghostEl.style.left = `${e.clientX - 50}px`;
465
+ }
466
+ }
467
+
468
+ private handleDragUp(e: PointerEvent): void {
469
+ if (!this.isDragging) {
470
+ this.removeDragListeners();
471
+ return;
472
+ }
473
+ const tabs = Array.from(
474
+ this.element?.querySelectorAll<HTMLElement>('[data-blok-database-tab]') ?? []
475
+ ).filter((t) => t.getAttribute('data-view-id') !== this.dragViewId);
476
+
477
+ const dropIndex = tabs.findIndex((t) => {
478
+ const rect = t.getBoundingClientRect();
479
+ return e.clientX < (rect.left + rect.right) / 2;
480
+ });
481
+
482
+ const beforeViewId = dropIndex >= 0 ? tabs[dropIndex].getAttribute('data-view-id') : null;
483
+ const afterViewId = ((): string | null => {
484
+ if (dropIndex > 0) return tabs[dropIndex - 1].getAttribute('data-view-id');
485
+ if (dropIndex === -1 && tabs.length > 0) return tabs[tabs.length - 1].getAttribute('data-view-id');
486
+ return null;
487
+ })();
488
+
489
+ const orderedViews = [...this.views].sort((a, b) => (a.position < b.position ? -1 : 1));
490
+ const beforeView = beforeViewId !== null ? orderedViews.find((v) => v.id === beforeViewId) : null;
491
+ const afterView = afterViewId !== null ? orderedViews.find((v) => v.id === afterViewId) : null;
492
+
493
+ const newPosition = generateKeyBetween(
494
+ afterView?.position ?? null,
495
+ beforeView?.position ?? null
496
+ );
497
+
498
+ this.cleanupDrag();
499
+ this.onReorder(this.dragViewId, newPosition);
500
+ }
501
+
502
+ private cleanupDrag(): void {
503
+ if (this.ghostEl !== null) {
504
+ this.ghostEl.remove();
505
+ this.ghostEl = null;
506
+ }
507
+ this.element?.removeAttribute('data-dragging');
508
+ const sourceTab = this.element?.querySelector(`[data-view-id="${this.dragViewId}"]`) as HTMLElement | null;
509
+ if (sourceTab !== null) {
510
+ sourceTab.style.opacity = '';
511
+ }
512
+ this.isDragging = false;
513
+ this.removeDragListeners();
514
+ }
515
+
516
+ private removeDragListeners(): void {
517
+ document.removeEventListener('pointermove', this.boundDragMove);
518
+ document.removeEventListener('pointerup', this.boundDragUp);
519
+ document.removeEventListener('pointercancel', this.boundDragCancel);
520
+ document.removeEventListener('keydown', this.boundDragKeyDown);
521
+ }
522
+
523
+ destroy(): void {
524
+ this.cleanupDrag();
525
+ this.closeContextPopover();
526
+ this.closeOverflowDropdown();
527
+ if (this.viewPopover !== null) {
528
+ this.viewPopover.destroy();
529
+ this.viewPopover = null;
530
+ }
531
+ }
532
+ }
@@ -0,0 +1,109 @@
1
+ import { IconBoard, IconGallery, IconList, IconTable } from '../../components/icons';
2
+ import type { ViewType } from './types';
3
+
4
+ interface ViewTypeOption {
5
+ type: ViewType;
6
+ icon: string;
7
+ label: string;
8
+ disabled?: boolean;
9
+ }
10
+
11
+ const VIEW_TYPES: ViewTypeOption[] = [
12
+ { type: 'board', icon: IconBoard, label: 'Board' },
13
+ { type: 'list', icon: IconList, label: 'List' },
14
+ { type: 'table', icon: IconTable, label: 'Table', disabled: true },
15
+ { type: 'gallery', icon: IconGallery, label: 'Gallery', disabled: true },
16
+ ];
17
+
18
+ export interface ViewPopoverOptions {
19
+ onSelect: (type: ViewType) => void;
20
+ }
21
+
22
+ export class DatabaseViewPopover {
23
+ private readonly onSelect: (type: ViewType) => void;
24
+ private popoverEl: HTMLElement | null = null;
25
+ private boundOutsideClick: ((e: MouseEvent) => void) | null = null;
26
+
27
+ constructor(options: ViewPopoverOptions) {
28
+ this.onSelect = options.onSelect;
29
+ }
30
+
31
+ open(anchor: HTMLElement): void {
32
+ this.close();
33
+
34
+ const popover = document.createElement('div');
35
+ popover.setAttribute('data-blok-popover', '');
36
+ popover.setAttribute('data-blok-database-view-popover', '');
37
+ popover.style.position = 'fixed';
38
+ popover.style.zIndex = '1000';
39
+
40
+ const rect = anchor.getBoundingClientRect();
41
+ popover.style.top = `${rect.bottom + 4}px`;
42
+ popover.style.left = `${rect.left}px`;
43
+
44
+ const heading = document.createElement('div');
45
+ heading.setAttribute('data-blok-database-view-popover-heading', '');
46
+ heading.textContent = 'Add a new view';
47
+ popover.appendChild(heading);
48
+
49
+ const grid = document.createElement('div');
50
+ grid.setAttribute('data-blok-database-view-popover-grid', '');
51
+ grid.style.display = 'grid';
52
+ grid.style.gridTemplateColumns = '1fr 1fr';
53
+ grid.style.gap = '2px';
54
+
55
+ for (const option of VIEW_TYPES) {
56
+ const item = document.createElement('div');
57
+ item.setAttribute('data-blok-database-view-option', option.type);
58
+
59
+ const iconEl = document.createElement('div');
60
+ iconEl.setAttribute('data-blok-database-view-option-icon', '');
61
+ iconEl.innerHTML = option.icon;
62
+ item.appendChild(iconEl);
63
+
64
+ const label = document.createElement('span');
65
+ label.textContent = option.label;
66
+ item.appendChild(label);
67
+
68
+ if (option.disabled === true) {
69
+ item.style.opacity = '0.35';
70
+ item.style.pointerEvents = 'none';
71
+ } else {
72
+ item.addEventListener('click', () => {
73
+ this.onSelect(option.type);
74
+ this.close();
75
+ });
76
+ }
77
+
78
+ grid.appendChild(item);
79
+ }
80
+
81
+ popover.appendChild(grid);
82
+ document.body.appendChild(popover);
83
+ this.popoverEl = popover;
84
+
85
+ this.boundOutsideClick = (e: MouseEvent): void => {
86
+ const target = e.target as HTMLElement;
87
+ if (!popover.contains(target) && !anchor.contains(target)) {
88
+ this.close();
89
+ }
90
+ };
91
+
92
+ document.addEventListener('mousedown', this.boundOutsideClick);
93
+ }
94
+
95
+ close(): void {
96
+ if (this.popoverEl !== null) {
97
+ this.popoverEl.remove();
98
+ this.popoverEl = null;
99
+ }
100
+ if (this.boundOutsideClick !== null) {
101
+ document.removeEventListener('mousedown', this.boundOutsideClick);
102
+ this.boundOutsideClick = null;
103
+ }
104
+ }
105
+
106
+ destroy(): void {
107
+ this.close();
108
+ }
109
+ }
@@ -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
+ }