@jackuait/blok 0.4.1-beta.1 → 0.4.1-beta.12

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 (403) hide show
  1. package/README.md +138 -17
  2. package/codemod/README.md +45 -7
  3. package/codemod/migrate-editorjs-to-blok.js +960 -92
  4. package/codemod/test.js +780 -77
  5. package/dist/blok.mjs +5 -2
  6. package/dist/chunks/blok-BU6NwVkN.mjs +13239 -0
  7. package/dist/chunks/i18next-CugVlwWp.mjs +1292 -0
  8. package/dist/chunks/i18next-loader-D8GzSwio.mjs +43 -0
  9. package/dist/{index-CEXLTV6f.mjs → chunks/index-C5e_WLFg.mjs} +2 -2
  10. package/dist/chunks/inline-tool-convert-CLUxkCe_.mjs +1990 -0
  11. package/dist/chunks/messages-0tDXLuyH.mjs +48 -0
  12. package/dist/chunks/messages-2_xedlYw.mjs +48 -0
  13. package/dist/chunks/messages-AHESHJm_.mjs +48 -0
  14. package/dist/chunks/messages-B5hdXZwA.mjs +48 -0
  15. package/dist/chunks/messages-B5jGUnOy.mjs +48 -0
  16. package/dist/chunks/messages-B5puUm7R.mjs +48 -0
  17. package/dist/chunks/messages-B66ZSDCJ.mjs +48 -0
  18. package/dist/chunks/messages-B9Oba7sq.mjs +48 -0
  19. package/dist/chunks/messages-BA0rcTCY.mjs +48 -0
  20. package/dist/chunks/messages-BBJgd5jG.mjs +48 -0
  21. package/dist/chunks/messages-BPqWKx5Z.mjs +48 -0
  22. package/dist/chunks/messages-Bdv-IkfG.mjs +48 -0
  23. package/dist/chunks/messages-BeUhMpsr.mjs +48 -0
  24. package/dist/chunks/messages-Bf6Y3_GI.mjs +48 -0
  25. package/dist/chunks/messages-BiExzWJv.mjs +48 -0
  26. package/dist/chunks/messages-BlpqL8vG.mjs +48 -0
  27. package/dist/chunks/messages-BmKCChWZ.mjs +48 -0
  28. package/dist/chunks/messages-Bn253WWC.mjs +48 -0
  29. package/dist/chunks/messages-BrJHUxQL.mjs +48 -0
  30. package/dist/chunks/messages-C5b7hr_E.mjs +48 -0
  31. package/dist/chunks/messages-C7I_AVH2.mjs +48 -0
  32. package/dist/chunks/messages-CJoBtXU6.mjs +48 -0
  33. package/dist/chunks/messages-CQj2JU2j.mjs +48 -0
  34. package/dist/chunks/messages-CUZ1x1QD.mjs +48 -0
  35. package/dist/chunks/messages-CUy1vn-b.mjs +48 -0
  36. package/dist/chunks/messages-CVeWVKsV.mjs +48 -0
  37. package/dist/chunks/messages-CXHd9SUK.mjs +48 -0
  38. package/dist/chunks/messages-CbMyJSzS.mjs +48 -0
  39. package/dist/chunks/messages-CbhuIWRJ.mjs +48 -0
  40. package/dist/chunks/messages-CeCjVKMW.mjs +48 -0
  41. package/dist/chunks/messages-Cj-t1bdy.mjs +48 -0
  42. package/dist/chunks/messages-CkFT2gle.mjs +48 -0
  43. package/dist/chunks/messages-Cm9aLHeX.mjs +48 -0
  44. package/dist/chunks/messages-CnvW8Slp.mjs +48 -0
  45. package/dist/chunks/messages-Cr-RJ7YB.mjs +48 -0
  46. package/dist/chunks/messages-CrsJ1TEJ.mjs +48 -0
  47. package/dist/chunks/messages-Cu08aLS3.mjs +48 -0
  48. package/dist/chunks/messages-CvaqJFN-.mjs +48 -0
  49. package/dist/chunks/messages-CyDU5lz9.mjs +48 -0
  50. package/dist/chunks/messages-CySyfkMU.mjs +48 -0
  51. package/dist/chunks/messages-Cyi2AMmz.mjs +48 -0
  52. package/dist/chunks/messages-D00OjS2n.mjs +48 -0
  53. package/dist/chunks/messages-DDLgIPDF.mjs +48 -0
  54. package/dist/chunks/messages-DMQIHGRj.mjs +48 -0
  55. package/dist/chunks/messages-DOlC_Tty.mjs +48 -0
  56. package/dist/chunks/messages-DV6shA9b.mjs +48 -0
  57. package/dist/chunks/messages-DY94ykcE.mjs +48 -0
  58. package/dist/chunks/messages-DbVquYKN.mjs +48 -0
  59. package/dist/chunks/messages-DcKOuncK.mjs +48 -0
  60. package/dist/chunks/messages-Dg92dXZ5.mjs +48 -0
  61. package/dist/chunks/messages-DnbbyJT3.mjs +48 -0
  62. package/dist/chunks/messages-DteYq0rv.mjs +48 -0
  63. package/dist/chunks/messages-GC2PhgV3.mjs +48 -0
  64. package/dist/chunks/messages-JGsXAReJ.mjs +48 -0
  65. package/dist/chunks/messages-JZUhXTuV.mjs +48 -0
  66. package/dist/chunks/messages-LvFKBBPa.mjs +48 -0
  67. package/dist/chunks/messages-NP1myMGI.mjs +48 -0
  68. package/dist/chunks/messages-Q4kc_ZtL.mjs +48 -0
  69. package/dist/chunks/messages-RvMHb2Ht.mjs +48 -0
  70. package/dist/chunks/messages-ftMcCEuO.mjs +48 -0
  71. package/dist/chunks/messages-o24dK6CU.mjs +48 -0
  72. package/dist/chunks/messages-pA5TvcAj.mjs +48 -0
  73. package/dist/chunks/messages-rRSHQDCX.mjs +48 -0
  74. package/dist/chunks/messages-srxrv8Yh.mjs +48 -0
  75. package/dist/chunks/messages-wdqp4610.mjs +48 -0
  76. package/dist/chunks/messages-zS1AXZ0y.mjs +48 -0
  77. package/dist/chunks/messages-zSzDzXej.mjs +48 -0
  78. package/dist/full.mjs +50 -0
  79. package/dist/locales.mjs +228 -0
  80. package/dist/messages-0tDXLuyH.mjs +48 -0
  81. package/dist/messages-2_xedlYw.mjs +48 -0
  82. package/dist/messages-AHESHJm_.mjs +48 -0
  83. package/dist/messages-B5hdXZwA.mjs +48 -0
  84. package/dist/messages-B5jGUnOy.mjs +48 -0
  85. package/dist/messages-B5puUm7R.mjs +48 -0
  86. package/dist/messages-B66ZSDCJ.mjs +48 -0
  87. package/dist/messages-B9Oba7sq.mjs +48 -0
  88. package/dist/messages-BA0rcTCY.mjs +48 -0
  89. package/dist/messages-BBJgd5jG.mjs +48 -0
  90. package/dist/messages-BPqWKx5Z.mjs +48 -0
  91. package/dist/messages-Bdv-IkfG.mjs +48 -0
  92. package/dist/messages-BeUhMpsr.mjs +48 -0
  93. package/dist/messages-Bf6Y3_GI.mjs +48 -0
  94. package/dist/messages-BiExzWJv.mjs +48 -0
  95. package/dist/messages-BlpqL8vG.mjs +48 -0
  96. package/dist/messages-BmKCChWZ.mjs +48 -0
  97. package/dist/messages-Bn253WWC.mjs +48 -0
  98. package/dist/messages-BrJHUxQL.mjs +48 -0
  99. package/dist/messages-C5b7hr_E.mjs +48 -0
  100. package/dist/messages-C7I_AVH2.mjs +48 -0
  101. package/dist/messages-CJoBtXU6.mjs +48 -0
  102. package/dist/messages-CQj2JU2j.mjs +48 -0
  103. package/dist/messages-CUZ1x1QD.mjs +48 -0
  104. package/dist/messages-CUy1vn-b.mjs +48 -0
  105. package/dist/messages-CVeWVKsV.mjs +48 -0
  106. package/dist/messages-CXHd9SUK.mjs +48 -0
  107. package/dist/messages-CbMyJSzS.mjs +48 -0
  108. package/dist/messages-CbhuIWRJ.mjs +48 -0
  109. package/dist/messages-CeCjVKMW.mjs +48 -0
  110. package/dist/messages-Cj-t1bdy.mjs +48 -0
  111. package/dist/messages-CkFT2gle.mjs +48 -0
  112. package/dist/messages-Cm9aLHeX.mjs +48 -0
  113. package/dist/messages-CnvW8Slp.mjs +48 -0
  114. package/dist/messages-Cr-RJ7YB.mjs +48 -0
  115. package/dist/messages-CrsJ1TEJ.mjs +48 -0
  116. package/dist/messages-Cu08aLS3.mjs +48 -0
  117. package/dist/messages-CvaqJFN-.mjs +48 -0
  118. package/dist/messages-CyDU5lz9.mjs +48 -0
  119. package/dist/messages-CySyfkMU.mjs +48 -0
  120. package/dist/messages-Cyi2AMmz.mjs +48 -0
  121. package/dist/messages-D00OjS2n.mjs +48 -0
  122. package/dist/messages-DDLgIPDF.mjs +48 -0
  123. package/dist/messages-DMQIHGRj.mjs +48 -0
  124. package/dist/messages-DOlC_Tty.mjs +48 -0
  125. package/dist/messages-DV6shA9b.mjs +48 -0
  126. package/dist/messages-DY94ykcE.mjs +48 -0
  127. package/dist/messages-DbVquYKN.mjs +48 -0
  128. package/dist/messages-DcKOuncK.mjs +48 -0
  129. package/dist/messages-Dg92dXZ5.mjs +48 -0
  130. package/dist/messages-DnbbyJT3.mjs +48 -0
  131. package/dist/messages-DteYq0rv.mjs +48 -0
  132. package/dist/messages-GC2PhgV3.mjs +48 -0
  133. package/dist/messages-JGsXAReJ.mjs +48 -0
  134. package/dist/messages-JZUhXTuV.mjs +48 -0
  135. package/dist/messages-LvFKBBPa.mjs +48 -0
  136. package/dist/messages-NP1myMGI.mjs +48 -0
  137. package/dist/messages-Q4kc_ZtL.mjs +48 -0
  138. package/dist/messages-RvMHb2Ht.mjs +48 -0
  139. package/dist/messages-ftMcCEuO.mjs +48 -0
  140. package/dist/messages-o24dK6CU.mjs +48 -0
  141. package/dist/messages-pA5TvcAj.mjs +48 -0
  142. package/dist/messages-rRSHQDCX.mjs +48 -0
  143. package/dist/messages-srxrv8Yh.mjs +48 -0
  144. package/dist/messages-wdqp4610.mjs +48 -0
  145. package/dist/messages-zS1AXZ0y.mjs +48 -0
  146. package/dist/messages-zSzDzXej.mjs +48 -0
  147. package/dist/tools.mjs +3126 -0
  148. package/dist/vendor.LICENSE.txt +26 -225
  149. package/package.json +63 -24
  150. package/src/blok.ts +267 -0
  151. package/src/components/__module.ts +139 -0
  152. package/src/components/block/api.ts +155 -0
  153. package/src/components/block/index.ts +1428 -0
  154. package/src/components/block-tunes/block-tune-delete.ts +51 -0
  155. package/src/components/blocks.ts +352 -0
  156. package/src/components/constants/data-attributes.ts +344 -0
  157. package/src/components/constants.ts +76 -0
  158. package/src/components/core.ts +392 -0
  159. package/src/components/dom.ts +773 -0
  160. package/src/components/domIterator.ts +189 -0
  161. package/src/components/errors/critical.ts +5 -0
  162. package/src/components/events/BlockChanged.ts +16 -0
  163. package/src/components/events/BlockHovered.ts +21 -0
  164. package/src/components/events/BlockSettingsClosed.ts +12 -0
  165. package/src/components/events/BlockSettingsOpened.ts +12 -0
  166. package/src/components/events/BlokMobileLayoutToggled.ts +15 -0
  167. package/src/components/events/FakeCursorAboutToBeToggled.ts +17 -0
  168. package/src/components/events/FakeCursorHaveBeenSet.ts +17 -0
  169. package/src/components/events/HistoryStateChanged.ts +19 -0
  170. package/src/components/events/RedactorDomChanged.ts +14 -0
  171. package/src/components/events/index.ts +46 -0
  172. package/src/components/flipper.ts +497 -0
  173. package/src/components/i18n/i18next-loader.ts +84 -0
  174. package/src/components/i18n/lightweight-i18n.ts +86 -0
  175. package/src/components/i18n/locales/TRANSLATION_GUIDELINES.md +113 -0
  176. package/src/components/i18n/locales/am/messages.json +45 -0
  177. package/src/components/i18n/locales/ar/messages.json +45 -0
  178. package/src/components/i18n/locales/az/messages.json +45 -0
  179. package/src/components/i18n/locales/bg/messages.json +45 -0
  180. package/src/components/i18n/locales/bn/messages.json +45 -0
  181. package/src/components/i18n/locales/bs/messages.json +45 -0
  182. package/src/components/i18n/locales/cs/messages.json +45 -0
  183. package/src/components/i18n/locales/da/messages.json +45 -0
  184. package/src/components/i18n/locales/de/messages.json +45 -0
  185. package/src/components/i18n/locales/dv/messages.json +45 -0
  186. package/src/components/i18n/locales/el/messages.json +45 -0
  187. package/src/components/i18n/locales/en/messages.json +45 -0
  188. package/src/components/i18n/locales/es/messages.json +45 -0
  189. package/src/components/i18n/locales/et/messages.json +45 -0
  190. package/src/components/i18n/locales/fa/messages.json +45 -0
  191. package/src/components/i18n/locales/fi/messages.json +45 -0
  192. package/src/components/i18n/locales/fil/messages.json +45 -0
  193. package/src/components/i18n/locales/fr/messages.json +45 -0
  194. package/src/components/i18n/locales/gu/messages.json +45 -0
  195. package/src/components/i18n/locales/he/messages.json +45 -0
  196. package/src/components/i18n/locales/hi/messages.json +45 -0
  197. package/src/components/i18n/locales/hr/messages.json +45 -0
  198. package/src/components/i18n/locales/hu/messages.json +45 -0
  199. package/src/components/i18n/locales/hy/messages.json +45 -0
  200. package/src/components/i18n/locales/id/messages.json +45 -0
  201. package/src/components/i18n/locales/index.ts +231 -0
  202. package/src/components/i18n/locales/it/messages.json +45 -0
  203. package/src/components/i18n/locales/ja/messages.json +45 -0
  204. package/src/components/i18n/locales/ka/messages.json +45 -0
  205. package/src/components/i18n/locales/km/messages.json +45 -0
  206. package/src/components/i18n/locales/kn/messages.json +45 -0
  207. package/src/components/i18n/locales/ko/messages.json +45 -0
  208. package/src/components/i18n/locales/ku/messages.json +45 -0
  209. package/src/components/i18n/locales/lo/messages.json +45 -0
  210. package/src/components/i18n/locales/lt/messages.json +45 -0
  211. package/src/components/i18n/locales/lv/messages.json +45 -0
  212. package/src/components/i18n/locales/mk/messages.json +45 -0
  213. package/src/components/i18n/locales/ml/messages.json +45 -0
  214. package/src/components/i18n/locales/mn/messages.json +45 -0
  215. package/src/components/i18n/locales/mr/messages.json +45 -0
  216. package/src/components/i18n/locales/ms/messages.json +45 -0
  217. package/src/components/i18n/locales/my/messages.json +45 -0
  218. package/src/components/i18n/locales/ne/messages.json +45 -0
  219. package/src/components/i18n/locales/nl/messages.json +45 -0
  220. package/src/components/i18n/locales/no/messages.json +45 -0
  221. package/src/components/i18n/locales/pa/messages.json +45 -0
  222. package/src/components/i18n/locales/pl/messages.json +45 -0
  223. package/src/components/i18n/locales/ps/messages.json +45 -0
  224. package/src/components/i18n/locales/pt/messages.json +45 -0
  225. package/src/components/i18n/locales/ro/messages.json +45 -0
  226. package/src/components/i18n/locales/ru/messages.json +45 -0
  227. package/src/components/i18n/locales/sd/messages.json +45 -0
  228. package/src/components/i18n/locales/si/messages.json +45 -0
  229. package/src/components/i18n/locales/sk/messages.json +45 -0
  230. package/src/components/i18n/locales/sl/messages.json +45 -0
  231. package/src/components/i18n/locales/sq/messages.json +45 -0
  232. package/src/components/i18n/locales/sr/messages.json +45 -0
  233. package/src/components/i18n/locales/sv/messages.json +45 -0
  234. package/src/components/i18n/locales/sw/messages.json +45 -0
  235. package/src/components/i18n/locales/ta/messages.json +45 -0
  236. package/src/components/i18n/locales/te/messages.json +45 -0
  237. package/src/components/i18n/locales/th/messages.json +45 -0
  238. package/src/components/i18n/locales/tr/messages.json +45 -0
  239. package/src/components/i18n/locales/ug/messages.json +45 -0
  240. package/src/components/i18n/locales/uk/messages.json +45 -0
  241. package/src/components/i18n/locales/ur/messages.json +45 -0
  242. package/src/components/i18n/locales/vi/messages.json +45 -0
  243. package/src/components/i18n/locales/yi/messages.json +45 -0
  244. package/src/components/i18n/locales/zh/messages.json +45 -0
  245. package/src/components/icons/index.ts +242 -0
  246. package/src/components/inline-tools/inline-tool-bold.ts +2213 -0
  247. package/src/components/inline-tools/inline-tool-convert.ts +142 -0
  248. package/src/components/inline-tools/inline-tool-italic.ts +500 -0
  249. package/src/components/inline-tools/inline-tool-link.ts +540 -0
  250. package/src/components/modules/api/blocks.ts +377 -0
  251. package/src/components/modules/api/caret.ts +125 -0
  252. package/src/components/modules/api/events.ts +51 -0
  253. package/src/components/modules/api/history.ts +73 -0
  254. package/src/components/modules/api/i18n.ts +35 -0
  255. package/src/components/modules/api/index.ts +39 -0
  256. package/src/components/modules/api/inlineToolbar.ts +33 -0
  257. package/src/components/modules/api/listeners.ts +56 -0
  258. package/src/components/modules/api/notifier.ts +46 -0
  259. package/src/components/modules/api/readonly.ts +39 -0
  260. package/src/components/modules/api/sanitizer.ts +30 -0
  261. package/src/components/modules/api/saver.ts +52 -0
  262. package/src/components/modules/api/selection.ts +48 -0
  263. package/src/components/modules/api/styles.ts +72 -0
  264. package/src/components/modules/api/toolbar.ts +79 -0
  265. package/src/components/modules/api/tools.ts +16 -0
  266. package/src/components/modules/api/tooltip.ts +67 -0
  267. package/src/components/modules/api/ui.ts +36 -0
  268. package/src/components/modules/blockEvents.ts +1591 -0
  269. package/src/components/modules/blockManager.ts +1356 -0
  270. package/src/components/modules/blockSelection.ts +708 -0
  271. package/src/components/modules/caret.ts +853 -0
  272. package/src/components/modules/crossBlockSelection.ts +329 -0
  273. package/src/components/modules/dragManager.ts +1204 -0
  274. package/src/components/modules/history.ts +1098 -0
  275. package/src/components/modules/i18n.ts +332 -0
  276. package/src/components/modules/index.ts +139 -0
  277. package/src/components/modules/modificationsObserver.ts +147 -0
  278. package/src/components/modules/paste.ts +1092 -0
  279. package/src/components/modules/readonly.ts +136 -0
  280. package/src/components/modules/rectangleSelection.ts +711 -0
  281. package/src/components/modules/renderer.ts +155 -0
  282. package/src/components/modules/saver.ts +283 -0
  283. package/src/components/modules/toolbar/blockSettings.ts +782 -0
  284. package/src/components/modules/toolbar/index.ts +1296 -0
  285. package/src/components/modules/toolbar/inline.ts +956 -0
  286. package/src/components/modules/tools.ts +625 -0
  287. package/src/components/modules/ui.ts +1283 -0
  288. package/src/components/polyfills.ts +113 -0
  289. package/src/components/selection.ts +1179 -0
  290. package/src/components/tools/base.ts +301 -0
  291. package/src/components/tools/block.ts +339 -0
  292. package/src/components/tools/collection.ts +67 -0
  293. package/src/components/tools/factory.ts +138 -0
  294. package/src/components/tools/inline.ts +71 -0
  295. package/src/components/tools/tune.ts +33 -0
  296. package/src/components/ui/toolbox.ts +610 -0
  297. package/src/components/utils/announcer.ts +205 -0
  298. package/src/components/utils/api.ts +20 -0
  299. package/src/components/utils/bem.ts +26 -0
  300. package/src/components/utils/blocks.ts +284 -0
  301. package/src/components/utils/caret.ts +1067 -0
  302. package/src/components/utils/data-model-transform.ts +382 -0
  303. package/src/components/utils/events.ts +117 -0
  304. package/src/components/utils/keyboard.ts +60 -0
  305. package/src/components/utils/listeners.ts +296 -0
  306. package/src/components/utils/mutations.ts +39 -0
  307. package/src/components/utils/notifier/draw.ts +190 -0
  308. package/src/components/utils/notifier/index.ts +66 -0
  309. package/src/components/utils/notifier/types.ts +1 -0
  310. package/src/components/utils/notifier.ts +77 -0
  311. package/src/components/utils/placeholder.ts +140 -0
  312. package/src/components/utils/popover/components/hint/hint.const.ts +10 -0
  313. package/src/components/utils/popover/components/hint/hint.ts +46 -0
  314. package/src/components/utils/popover/components/hint/index.ts +6 -0
  315. package/src/components/utils/popover/components/popover-header/index.ts +2 -0
  316. package/src/components/utils/popover/components/popover-header/popover-header.const.ts +8 -0
  317. package/src/components/utils/popover/components/popover-header/popover-header.ts +80 -0
  318. package/src/components/utils/popover/components/popover-header/popover-header.types.ts +14 -0
  319. package/src/components/utils/popover/components/popover-item/index.ts +13 -0
  320. package/src/components/utils/popover/components/popover-item/popover-item-default/popover-item-default.const.ts +50 -0
  321. package/src/components/utils/popover/components/popover-item/popover-item-default/popover-item-default.ts +680 -0
  322. package/src/components/utils/popover/components/popover-item/popover-item-html/popover-item-html.const.ts +14 -0
  323. package/src/components/utils/popover/components/popover-item/popover-item-html/popover-item-html.ts +136 -0
  324. package/src/components/utils/popover/components/popover-item/popover-item-separator/popover-item-separator.const.ts +20 -0
  325. package/src/components/utils/popover/components/popover-item/popover-item-separator/popover-item-separator.ts +117 -0
  326. package/src/components/utils/popover/components/popover-item/popover-item.ts +197 -0
  327. package/src/components/utils/popover/components/search-input/index.ts +2 -0
  328. package/src/components/utils/popover/components/search-input/search-input.const.ts +8 -0
  329. package/src/components/utils/popover/components/search-input/search-input.ts +178 -0
  330. package/src/components/utils/popover/components/search-input/search-input.types.ts +59 -0
  331. package/src/components/utils/popover/index.ts +13 -0
  332. package/src/components/utils/popover/popover-abstract.ts +457 -0
  333. package/src/components/utils/popover/popover-desktop.ts +682 -0
  334. package/src/components/utils/popover/popover-inline.ts +338 -0
  335. package/src/components/utils/popover/popover-mobile.ts +201 -0
  336. package/src/components/utils/popover/popover.const.ts +81 -0
  337. package/src/components/utils/popover/utils/popover-states-history.ts +72 -0
  338. package/src/components/utils/promise-queue.ts +43 -0
  339. package/src/components/utils/sanitizer.ts +537 -0
  340. package/src/components/utils/scroll-locker.ts +87 -0
  341. package/src/components/utils/shortcut.ts +231 -0
  342. package/src/components/utils/shortcuts.ts +113 -0
  343. package/src/components/utils/tools.ts +110 -0
  344. package/src/components/utils/tooltip.ts +591 -0
  345. package/src/components/utils/tw.ts +241 -0
  346. package/src/components/utils.ts +1081 -0
  347. package/src/env.d.ts +13 -0
  348. package/src/full.ts +69 -0
  349. package/src/locales.ts +51 -0
  350. package/src/stories/Block.stories.ts +498 -0
  351. package/src/stories/EditorModes.stories.ts +505 -0
  352. package/src/stories/Header.stories.ts +137 -0
  353. package/src/stories/InlineToolbar.stories.ts +498 -0
  354. package/src/stories/List.stories.ts +259 -0
  355. package/src/stories/Notifier.stories.ts +340 -0
  356. package/src/stories/Paragraph.stories.ts +112 -0
  357. package/src/stories/Placeholder.stories.ts +319 -0
  358. package/src/stories/Popover.stories.ts +759 -0
  359. package/src/stories/Selection.stories.ts +250 -0
  360. package/src/stories/StubBlock.stories.ts +156 -0
  361. package/src/stories/Toolbar.stories.ts +223 -0
  362. package/src/stories/Toolbox.stories.ts +166 -0
  363. package/src/stories/Tooltip.stories.ts +198 -0
  364. package/src/stories/helpers.ts +463 -0
  365. package/src/styles/main.css +126 -0
  366. package/src/tools/header/index.ts +647 -0
  367. package/src/tools/index.ts +45 -0
  368. package/src/tools/list/index.ts +1826 -0
  369. package/src/tools/paragraph/index.ts +412 -0
  370. package/src/tools/stub/index.ts +107 -0
  371. package/src/types-internal/blok-modules.d.ts +87 -0
  372. package/src/types-internal/html-janitor.d.ts +28 -0
  373. package/src/types-internal/module-config.d.ts +11 -0
  374. package/src/variants/all-locales.ts +155 -0
  375. package/src/variants/blok-maximum.ts +20 -0
  376. package/src/variants/blok-minimum.ts +243 -0
  377. package/types/api/blocks.d.ts +9 -1
  378. package/types/api/history.d.ts +7 -0
  379. package/types/api/i18n.d.ts +22 -3
  380. package/types/api/selection.d.ts +6 -0
  381. package/types/api/styles.d.ts +23 -10
  382. package/types/configs/blok-config.d.ts +29 -0
  383. package/types/configs/i18n-config.d.ts +52 -2
  384. package/types/configs/i18n-dictionary.d.ts +16 -90
  385. package/types/configs/sanitizer-config.d.ts +25 -1
  386. package/types/data-attributes.d.ts +170 -0
  387. package/types/data-formats/output-data.d.ts +15 -0
  388. package/types/full.d.ts +80 -0
  389. package/types/index.d.ts +30 -13
  390. package/types/locales.d.ts +59 -0
  391. package/types/tools/adapters/inline-tool-adapter.d.ts +10 -0
  392. package/types/tools/block-tool.d.ts +11 -2
  393. package/types/tools/header.d.ts +18 -0
  394. package/types/tools/index.d.ts +1 -0
  395. package/types/tools/list.d.ts +91 -0
  396. package/types/tools/paragraph.d.ts +71 -0
  397. package/types/tools/tool-settings.d.ts +99 -6
  398. package/types/tools/tool.d.ts +6 -0
  399. package/types/tools-entry.d.ts +49 -0
  400. package/types/utils/popover/popover-item.d.ts +24 -5
  401. package/types/utils/popover/popover.d.ts +13 -0
  402. package/dist/blok-C8XbyLHh.mjs +0 -25795
  403. package/dist/blok.umd.js +0 -181
@@ -0,0 +1,680 @@
1
+ import type {
2
+ PopoverItemDefaultParams,
3
+ PopoverItemRenderParamsMap,
4
+ PopoverItemType
5
+ } from '@/types/utils/popover/popover-item';
6
+ import { PopoverItem } from '../popover-item';
7
+ import { css, cssInline, cssNestedInline } from './popover-item-default.const';
8
+ import { DATA_ATTR } from '../../../../../constants/data-attributes';
9
+ import { twMerge } from '../../../../tw';
10
+ import { IconChevronRight } from '../../../../../icons';
11
+
12
+ /**
13
+ * Represents single popover item node
14
+ * @todo replace multiple make() usages with constructing separate instances
15
+ * @todo split regular popover item and popover item with confirmation to separate classes
16
+ * @todo display icon on the right side of the item for rtl languages
17
+ */
18
+ export class PopoverItemDefault extends PopoverItem {
19
+ /**
20
+ * True if item is disabled and hence not clickable
21
+ */
22
+ public get isDisabled(): boolean {
23
+ return this.params.isDisabled === true;
24
+ }
25
+
26
+ /**
27
+ * Exposes popover item toggle parameter
28
+ */
29
+ public get toggle(): boolean | string | undefined {
30
+ return this.params.toggle;
31
+ }
32
+
33
+ /**
34
+ * Item title
35
+ */
36
+ public get title(): string | undefined {
37
+ return this.params.title;
38
+ }
39
+
40
+ /**
41
+ * English title for multilingual search fallback
42
+ */
43
+ public get englishTitle(): string | undefined {
44
+ return this.params.englishTitle;
45
+ }
46
+
47
+ /**
48
+ * Additional search terms for this item
49
+ */
50
+ public get searchTerms(): string[] | undefined {
51
+ return this.params.searchTerms;
52
+ }
53
+
54
+ /**
55
+ * True if confirmation state is enabled for popover item
56
+ */
57
+ public get isConfirmationStateEnabled(): boolean {
58
+ return this.confirmationState !== null;
59
+ }
60
+
61
+ /**
62
+ * True if item is focused in keyboard navigation process
63
+ */
64
+ public get isFocused(): boolean {
65
+ if (this.nodes.root === null) {
66
+ return false;
67
+ }
68
+
69
+ return this.nodes.root.hasAttribute(DATA_ATTR.focused);
70
+ }
71
+
72
+
73
+ /**
74
+ * Item html elements
75
+ */
76
+ private nodes: {
77
+ root: null | HTMLElement;
78
+ icon: null | HTMLElement;
79
+ titleEl: null | HTMLElement;
80
+ secondaryLabelEl: null | HTMLElement;
81
+ chevron: null | HTMLElement;
82
+ } = {
83
+ root: null,
84
+ icon: null,
85
+ titleEl: null,
86
+ secondaryLabelEl: null,
87
+ chevron: null,
88
+ };
89
+
90
+ /**
91
+ * If item is in confirmation state, stores confirmation params such as icon, label, onActivate callback and so on
92
+ */
93
+ private confirmationState: PopoverItemDefaultParams | null = null;
94
+
95
+ /**
96
+ * Render params passed during construction, stored for re-rendering
97
+ */
98
+ private readonly renderParams: PopoverItemRenderParamsMap[PopoverItemType.Default] | undefined;
99
+
100
+ /**
101
+ * Constructs popover item instance
102
+ * @param params - popover item construction params
103
+ * @param renderParams - popover item render params.
104
+ * The parameters that are not set by user via popover api but rather depend on technical implementation
105
+ */
106
+ constructor(protected readonly params: PopoverItemDefaultParams, renderParams?: PopoverItemRenderParamsMap[PopoverItemType.Default]) {
107
+ super(params);
108
+
109
+ this.renderParams = renderParams;
110
+ this.nodes.root = this.createRootElement(params, renderParams);
111
+ }
112
+
113
+ /**
114
+ * Returns popover item root element
115
+ */
116
+ public getElement(): HTMLElement | null {
117
+ return this.nodes.root;
118
+ }
119
+
120
+ /**
121
+ * Called on popover item click
122
+ */
123
+ public handleClick(): void {
124
+ if (this.isConfirmationStateEnabled && this.confirmationState !== null) {
125
+ this.activateOrEnableConfirmationMode(this.confirmationState);
126
+
127
+ return;
128
+ }
129
+
130
+ this.activateOrEnableConfirmationMode(this.params);
131
+ }
132
+
133
+ /**
134
+ * Toggles item active state
135
+ * @param isActive - true if item should strictly should become active
136
+ */
137
+ public toggleActive(isActive?: boolean): void {
138
+ if (this.nodes.root === null) {
139
+ return;
140
+ }
141
+
142
+ const currentlyActive = this.nodes.root.hasAttribute(DATA_ATTR.popoverItemActive);
143
+ const shouldBeActive = isActive !== undefined ? isActive : !currentlyActive;
144
+
145
+ this.setActive(shouldBeActive);
146
+ }
147
+
148
+ /**
149
+ * Toggles item hidden state
150
+ * @param isHidden - true if item should be hidden
151
+ */
152
+ public override toggleHidden(isHidden: boolean): void {
153
+ this.setHidden(isHidden);
154
+ }
155
+
156
+ /**
157
+ * Resets popover item to its original state
158
+ */
159
+ public reset(): void {
160
+ if (this.isConfirmationStateEnabled) {
161
+ this.disableConfirmationMode();
162
+ }
163
+ }
164
+
165
+ /**
166
+ * Method called once item becomes focused during keyboard navigation
167
+ */
168
+ public onFocus(): void {
169
+ this.disableSpecialHoverAndFocusBehavior();
170
+ }
171
+
172
+
173
+ /**
174
+ * Creates the root container element
175
+ * @param params - item construction params
176
+ * @param renderParams - popover item render params
177
+ */
178
+ private createRootElement(
179
+ params: PopoverItemDefaultParams,
180
+ renderParams?: PopoverItemRenderParamsMap[PopoverItemType.Default]
181
+ ): HTMLElement {
182
+ const wrapperTag = renderParams?.wrapperTag ?? 'div';
183
+ const root = document.createElement(wrapperTag);
184
+
185
+ if (wrapperTag === 'button') {
186
+ root.setAttribute('type', 'button');
187
+ }
188
+
189
+ // Set classes
190
+ root.className = this.getContainerClass();
191
+
192
+ // Set data attributes
193
+ root.setAttribute(DATA_ATTR.popoverItem, '');
194
+ root.setAttribute('data-blok-testid', 'popover-item');
195
+
196
+ if (params.name) {
197
+ root.setAttribute('data-blok-item-name', params.name);
198
+ }
199
+ if (params.dataset) {
200
+ Object.entries(params.dataset).forEach(([key, value]) => {
201
+ root.setAttribute(`data-${key}`, value);
202
+ });
203
+ }
204
+ if (params.isDisabled) {
205
+ root.setAttribute(DATA_ATTR.disabled, 'true');
206
+ }
207
+ if (this.isActive) {
208
+ root.setAttribute(DATA_ATTR.popoverItemActive, 'true');
209
+ }
210
+ if (this.hasChildren) {
211
+ root.setAttribute(DATA_ATTR.hasChildren, 'true');
212
+ }
213
+
214
+ // Create content elements
215
+ this.createContentElements(root, params, renderParams);
216
+
217
+ // Add hint if configured
218
+ const shouldAddHint = params.hint !== undefined && renderParams?.hint?.enabled !== false;
219
+
220
+ if (shouldAddHint && params.hint !== undefined) {
221
+ this.addHint(root, {
222
+ ...params.hint,
223
+ position: renderParams?.hint?.position || 'right',
224
+ alignment: renderParams?.hint?.alignment || 'center',
225
+ });
226
+ }
227
+
228
+ return root;
229
+ }
230
+
231
+ /**
232
+ * Creates the content elements (icon, title, secondary label, chevron)
233
+ */
234
+ private createContentElements(
235
+ root: HTMLElement,
236
+ params: PopoverItemDefaultParams,
237
+ renderParams?: PopoverItemRenderParamsMap[PopoverItemType.Default]
238
+ ): void {
239
+ const iconWithGap = renderParams?.iconWithGap ?? true;
240
+ const isInline = renderParams?.isInline ?? false;
241
+ const isNestedInline = renderParams?.isNestedInline ?? false;
242
+
243
+ const title = params.title;
244
+
245
+ // Icon
246
+ if (params.icon) {
247
+ this.nodes.icon = this.createIconElement(params.icon, iconWithGap, isInline, isNestedInline);
248
+ root.appendChild(this.nodes.icon);
249
+ }
250
+
251
+ // Title
252
+ if (title !== undefined) {
253
+ const titleEl = document.createElement('div');
254
+
255
+ titleEl.className = 'mr-auto truncate text-sm font-medium leading-5';
256
+ titleEl.setAttribute(DATA_ATTR.popoverItemTitle, '');
257
+ titleEl.setAttribute('data-blok-testid', 'popover-item-title');
258
+ titleEl.textContent = title;
259
+
260
+ root.appendChild(titleEl);
261
+ this.nodes.titleEl = titleEl;
262
+ }
263
+
264
+ // Secondary label
265
+ if (params.secondaryLabel) {
266
+ const secondaryEl = document.createElement('div');
267
+
268
+ secondaryEl.className = 'whitespace-nowrap pr-1.5 text-xs font-light tracking-[0.25px] text-text-secondary opacity-60';
269
+ secondaryEl.setAttribute(DATA_ATTR.popoverItemSecondaryTitle, '');
270
+ secondaryEl.setAttribute('data-blok-testid', 'popover-item-secondary-title');
271
+ secondaryEl.textContent = params.secondaryLabel;
272
+
273
+ root.appendChild(secondaryEl);
274
+ this.nodes.secondaryLabelEl = secondaryEl;
275
+ }
276
+
277
+ // Chevron
278
+ const showChevron = this.hasChildren && !this.isChevronHidden;
279
+
280
+ if (showChevron) {
281
+ const chevronEl = document.createElement('div');
282
+
283
+ chevronEl.className = this.getChevronClass(isInline);
284
+ chevronEl.setAttribute(DATA_ATTR.popoverItemIcon, '');
285
+ chevronEl.setAttribute(DATA_ATTR.popoverItemIconChevronRight, '');
286
+ chevronEl.setAttribute('data-blok-testid', 'popover-item-chevron-right');
287
+ chevronEl.innerHTML = IconChevronRight;
288
+
289
+ root.appendChild(chevronEl);
290
+ this.nodes.chevron = chevronEl;
291
+ }
292
+ }
293
+
294
+
295
+ /**
296
+ * Creates an icon element
297
+ */
298
+ private createIconElement(icon: string, iconWithGap: boolean, isInline: boolean, isNestedInline: boolean): HTMLElement {
299
+ const iconEl = document.createElement('div');
300
+
301
+ iconEl.className = this.getIconClass(iconWithGap, isInline, isNestedInline, false);
302
+ iconEl.setAttribute(DATA_ATTR.popoverItemIcon, '');
303
+ iconEl.setAttribute('data-blok-testid', 'popover-item-icon');
304
+ iconEl.innerHTML = icon;
305
+
306
+ if (iconWithGap) {
307
+ iconEl.setAttribute(DATA_ATTR.tool, '');
308
+ }
309
+
310
+ return iconEl;
311
+ }
312
+
313
+ /**
314
+ * Gets the container class based on current state
315
+ */
316
+ private getContainerClass(): string {
317
+ const isInline = this.renderParams?.isInline ?? false;
318
+ const isNestedInline = this.renderParams?.isNestedInline ?? false;
319
+
320
+ return twMerge(
321
+ css.item,
322
+ isInline && cssInline.item,
323
+ isNestedInline && cssNestedInline.item,
324
+ this.params.isDisabled && css.itemDisabled
325
+ );
326
+ }
327
+
328
+ /**
329
+ * Gets the icon class based on context
330
+ */
331
+ private getIconClass(iconWithGap: boolean, isInline: boolean, isNestedInline: boolean, isWobbling: boolean): string {
332
+ return twMerge(
333
+ css.icon,
334
+ isInline && 'w-auto h-auto [&_svg]:w-icon [&_svg]:h-icon mobile:[&_svg]:w-icon-mobile mobile:[&_svg]:h-icon-mobile',
335
+ isNestedInline && 'w-toolbox-btn h-toolbox-btn',
336
+ iconWithGap && 'mr-2',
337
+ iconWithGap && isInline && 'shadow-none bg-transparent !mr-0',
338
+ iconWithGap && isNestedInline && '!mr-2',
339
+ isWobbling && 'animate-wobble'
340
+ );
341
+ }
342
+
343
+ /**
344
+ * Gets the chevron class based on context
345
+ */
346
+ private getChevronClass(isInline: boolean): string {
347
+ return twMerge(
348
+ css.icon,
349
+ isInline && 'rotate-90'
350
+ );
351
+ }
352
+
353
+ /**
354
+ * Sets the active state of the item
355
+ */
356
+ private setActive(isActive: boolean): void {
357
+ if (!this.nodes.root) {
358
+ return;
359
+ }
360
+
361
+ if (isActive) {
362
+ this.nodes.root.setAttribute(DATA_ATTR.popoverItemActive, 'true');
363
+ } else {
364
+ this.nodes.root.removeAttribute(DATA_ATTR.popoverItemActive);
365
+ }
366
+ }
367
+
368
+ /**
369
+ * Sets the hidden state of the item
370
+ */
371
+ private setHidden(isHidden: boolean): void {
372
+ if (!this.nodes.root) {
373
+ return;
374
+ }
375
+
376
+ if (isHidden) {
377
+ this.nodes.root.setAttribute(DATA_ATTR.hidden, 'true');
378
+ this.nodes.root.classList.add('!hidden');
379
+ } else {
380
+ this.nodes.root.removeAttribute(DATA_ATTR.hidden);
381
+ this.nodes.root.classList.remove('!hidden');
382
+ }
383
+ }
384
+
385
+ /**
386
+ * Sets the focused state of the item
387
+ * @param isFocused - true if item should be focused
388
+ */
389
+ public setFocused(isFocused: boolean): void {
390
+ if (!this.nodes.root) {
391
+ return;
392
+ }
393
+
394
+ if (isFocused) {
395
+ this.nodes.root.setAttribute(DATA_ATTR.focused, 'true');
396
+ this.nodes.root.classList.add('!bg-item-focus-bg');
397
+ } else {
398
+ this.nodes.root.removeAttribute(DATA_ATTR.focused);
399
+ this.nodes.root.classList.remove('!bg-item-focus-bg');
400
+ }
401
+ }
402
+
403
+ /**
404
+ * Sets the no-hover state
405
+ */
406
+ private setNoHover(noHover: boolean): void {
407
+ if (!this.nodes.root) {
408
+ return;
409
+ }
410
+
411
+ if (noHover) {
412
+ this.nodes.root.setAttribute(DATA_ATTR.popoverItemNoHover, 'true');
413
+ } else {
414
+ this.nodes.root.removeAttribute(DATA_ATTR.popoverItemNoHover);
415
+ }
416
+ }
417
+
418
+ /**
419
+ * Sets the no-focus state
420
+ */
421
+ private setNoFocus(noFocus: boolean): void {
422
+ if (!this.nodes.root) {
423
+ return;
424
+ }
425
+
426
+ if (noFocus) {
427
+ this.nodes.root.setAttribute(DATA_ATTR.popoverItemNoFocus, 'true');
428
+ } else {
429
+ this.nodes.root.removeAttribute(DATA_ATTR.popoverItemNoFocus);
430
+ }
431
+ }
432
+
433
+
434
+ /**
435
+ * Activates confirmation mode for the item.
436
+ * @param newState - new popover item params that should be applied
437
+ */
438
+ private enableConfirmationMode(newState: PopoverItemDefaultParams): void {
439
+ if (this.nodes.root === null) {
440
+ return;
441
+ }
442
+
443
+ const params = {
444
+ ...this.params,
445
+ ...newState,
446
+ confirmation: 'confirmation' in newState ? newState.confirmation : undefined,
447
+ } as PopoverItemDefaultParams;
448
+
449
+ // Update confirmation state
450
+ this.setConfirmation(params);
451
+ this.confirmationState = newState;
452
+
453
+ this.enableSpecialHoverAndFocusBehavior();
454
+ }
455
+
456
+ /**
457
+ * Sets the confirmation state with new params
458
+ */
459
+ private setConfirmation(params: PopoverItemDefaultParams | null): void {
460
+ if (!this.nodes.root) {
461
+ return;
462
+ }
463
+
464
+ if (params === null) {
465
+ this.clearConfirmationState();
466
+
467
+ return;
468
+ }
469
+
470
+ this.applyConfirmationState(params);
471
+ }
472
+
473
+ /**
474
+ * Clears confirmation state and restores original content
475
+ */
476
+ private clearConfirmationState(): void {
477
+ if (!this.nodes.root) {
478
+ return;
479
+ }
480
+
481
+ this.nodes.root.removeAttribute(DATA_ATTR.popoverItemConfirmation);
482
+ this.nodes.root.classList.remove('!bg-item-confirm-bg', '!text-white');
483
+
484
+ this.restoreOriginalIcon();
485
+ this.restoreOriginalTitle();
486
+ this.restoreOriginalSecondaryLabel();
487
+ }
488
+
489
+ /**
490
+ * Applies confirmation state with new params
491
+ */
492
+ private applyConfirmationState(params: PopoverItemDefaultParams): void {
493
+ if (!this.nodes.root) {
494
+ return;
495
+ }
496
+
497
+ this.nodes.root.setAttribute(DATA_ATTR.popoverItemConfirmation, 'true');
498
+ this.nodes.root.classList.add('!bg-item-confirm-bg', '!text-white');
499
+
500
+ this.updateIcon(params.icon);
501
+ this.updateTitle(params);
502
+ this.updateSecondaryLabel(params.secondaryLabel);
503
+ }
504
+
505
+ /**
506
+ * Restores the original icon
507
+ */
508
+ private restoreOriginalIcon(): void {
509
+ if (!this.nodes.icon || !this.params.icon) {
510
+ return;
511
+ }
512
+
513
+ this.nodes.icon.innerHTML = this.params.icon;
514
+ }
515
+
516
+ /**
517
+ * Restores the original title
518
+ */
519
+ private restoreOriginalTitle(): void {
520
+ if (!this.nodes.titleEl || this.params.title === undefined) {
521
+ return;
522
+ }
523
+
524
+ this.nodes.titleEl.textContent = this.params.title;
525
+ }
526
+
527
+ /**
528
+ * Restores the original secondary label
529
+ */
530
+ private restoreOriginalSecondaryLabel(): void {
531
+ if (!this.nodes.secondaryLabelEl) {
532
+ return;
533
+ }
534
+
535
+ this.nodes.secondaryLabelEl.textContent = this.params.secondaryLabel ?? '';
536
+ this.nodes.secondaryLabelEl.style.display = this.params.secondaryLabel ? '' : 'none';
537
+ }
538
+
539
+ /**
540
+ * Updates the icon with new content
541
+ */
542
+ private updateIcon(icon: string | undefined): void {
543
+ if (!this.nodes.icon || !icon) {
544
+ return;
545
+ }
546
+
547
+ this.nodes.icon.innerHTML = icon;
548
+ }
549
+
550
+ /**
551
+ * Updates the title with new content
552
+ */
553
+ private updateTitle(params: PopoverItemDefaultParams): void {
554
+ if (!this.nodes.titleEl || params.title === undefined) {
555
+ return;
556
+ }
557
+
558
+ this.nodes.titleEl.textContent = params.title;
559
+ }
560
+
561
+ /**
562
+ * Updates the secondary label with new content
563
+ */
564
+ private updateSecondaryLabel(secondaryLabel: string | undefined): void {
565
+ if (!this.nodes.secondaryLabelEl) {
566
+ return;
567
+ }
568
+
569
+ this.nodes.secondaryLabelEl.textContent = secondaryLabel ?? '';
570
+ this.nodes.secondaryLabelEl.style.display = secondaryLabel ? '' : 'none';
571
+ }
572
+
573
+ /**
574
+ * Returns item to its original state
575
+ */
576
+ private disableConfirmationMode(): void {
577
+ if (this.nodes.root === null) {
578
+ return;
579
+ }
580
+
581
+ // Clear confirmation state
582
+ this.setConfirmation(null);
583
+ this.confirmationState = null;
584
+
585
+ this.disableSpecialHoverAndFocusBehavior();
586
+ }
587
+
588
+ /**
589
+ * Enables special focus and hover behavior for item in confirmation state.
590
+ * This is needed to prevent item from being highlighted as hovered/focused just after click.
591
+ */
592
+ private enableSpecialHoverAndFocusBehavior(): void {
593
+ this.setNoHover(true);
594
+ this.setNoFocus(true);
595
+
596
+ this.nodes.root?.addEventListener('mouseleave', this.removeSpecialHoverBehavior, { once: true });
597
+ }
598
+
599
+ /**
600
+ * Disables special focus and hover behavior
601
+ */
602
+ private disableSpecialHoverAndFocusBehavior(): void {
603
+ this.removeSpecialFocusBehavior();
604
+ this.removeSpecialHoverBehavior();
605
+
606
+ this.nodes.root?.removeEventListener('mouseleave', this.removeSpecialHoverBehavior);
607
+ }
608
+
609
+ /**
610
+ * Removes class responsible for special focus behavior on an item
611
+ */
612
+ private removeSpecialFocusBehavior = (): void => {
613
+ this.setNoFocus(false);
614
+ };
615
+
616
+ /**
617
+ * Removes class responsible for special hover behavior on an item
618
+ */
619
+ private removeSpecialHoverBehavior = (): void => {
620
+ this.setNoHover(false);
621
+ };
622
+
623
+ /**
624
+ * Executes item's onActivate callback if the item has no confirmation configured
625
+ * @param item - item to activate or bring to confirmation mode
626
+ */
627
+ private activateOrEnableConfirmationMode(item: PopoverItemDefaultParams): void {
628
+ if (!('confirmation' in item) || item.confirmation === undefined) {
629
+ try {
630
+ item.onActivate?.(item);
631
+ this.disableConfirmationMode();
632
+ } catch {
633
+ this.animateError();
634
+ }
635
+ } else {
636
+ this.enableConfirmationMode(item.confirmation);
637
+ }
638
+ }
639
+
640
+ /**
641
+ * Animates item which symbolizes that error occurred while executing 'onActivate()' callback
642
+ */
643
+ private animateError(): void {
644
+ this.triggerWobble();
645
+ }
646
+
647
+ /**
648
+ * Triggers wobble animation on the icon
649
+ */
650
+ private triggerWobble(): void {
651
+ if (!this.nodes.icon) {
652
+ return;
653
+ }
654
+
655
+ const isInline = this.renderParams?.isInline ?? false;
656
+ const isNestedInline = this.renderParams?.isNestedInline ?? false;
657
+ const iconWithGap = this.renderParams?.iconWithGap ?? true;
658
+
659
+ // Add wobble class
660
+ this.nodes.icon.setAttribute(DATA_ATTR.popoverItemWobble, 'true');
661
+ this.nodes.icon.className = this.getIconClass(iconWithGap, isInline, isNestedInline, true);
662
+
663
+ // Remove wobble after animation ends
664
+ const handleAnimationEnd = (): void => {
665
+ if (this.nodes.icon) {
666
+ this.nodes.icon.removeAttribute(DATA_ATTR.popoverItemWobble);
667
+ this.nodes.icon.className = this.getIconClass(iconWithGap, isInline, isNestedInline, false);
668
+ }
669
+ };
670
+
671
+ this.nodes.icon.addEventListener('animationend', handleAnimationEnd, { once: true });
672
+ }
673
+
674
+ /**
675
+ * Gets reference to the icon element
676
+ */
677
+ public getIconElement(): HTMLElement | null {
678
+ return this.nodes.icon;
679
+ }
680
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Tailwind CSS classes for popover item HTML component
3
+ */
4
+ export const css = {
5
+ root: '',
6
+ rootHidden: 'hidden',
7
+ };
8
+
9
+ /**
10
+ * Tailwind CSS classes for inline popover item HTML
11
+ */
12
+ export const cssInline = {
13
+ root: 'flex items-center',
14
+ };