@threadlabs/looma 0.2.5 → 0.2.7

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 (427) hide show
  1. package/dist/chunk-3HMMDK27.js +2914 -0
  2. package/dist/chunk-3K45IWIJ.js +4733 -0
  3. package/dist/chunk-MLKGABMK.js +9 -0
  4. package/dist/declarative-generated.cjs +135 -0
  5. package/dist/declarative-generated.d.cts +10 -0
  6. package/dist/declarative-generated.d.ts +10 -0
  7. package/dist/declarative-generated.js +111 -0
  8. package/dist/declarative.cjs +2942 -0
  9. package/dist/declarative.d.cts +27 -0
  10. package/dist/declarative.d.ts +27 -0
  11. package/dist/declarative.js +13 -0
  12. package/dist/index.cjs +7478 -6457
  13. package/dist/index.d.cts +4 -58
  14. package/dist/index.d.ts +4 -58
  15. package/dist/index.js +15 -27
  16. package/dist/loader.cjs +7652 -0
  17. package/dist/loader.d.cts +4 -0
  18. package/dist/loader.d.ts +4 -0
  19. package/dist/loader.js +16 -0
  20. package/dist/valibot.cjs +31 -0
  21. package/dist/valibot.d.cts +10 -0
  22. package/dist/valibot.d.ts +1 -43
  23. package/dist/valibot.js +2 -0
  24. package/dist/{types/field/validation.d.ts → validation-bxcou-l-.d.cts} +13 -11
  25. package/dist/validation-bxcou-l-.d.ts +58 -0
  26. package/editor/{chunk-B5WVJOPV.js → chunk-BXICJBWS.js} +118 -8
  27. package/editor/{chunk-ZOUKEZ77.js → chunk-JK53ENSG.js} +8 -21
  28. package/editor/chunk-WI7ZA44X.js +2558 -0
  29. package/editor/extensions/index.d.ts +11 -2
  30. package/editor/extensions/index.js +9 -7
  31. package/editor/index.d.ts +1 -1
  32. package/editor/index.js +10 -8
  33. package/editor/ui.js +2 -2
  34. package/editor.css +32 -0
  35. package/layout/index.cjs +466 -400
  36. package/layout/index.d.cts +1 -2
  37. package/layout/index.d.ts +1 -2
  38. package/layout/index.js +471 -395
  39. package/package.json +14 -5
  40. package/vue/chunk-4DPYH3IT.js +3538 -0
  41. package/vue/editor/index.d.ts +17 -7
  42. package/vue/editor/index.js +53 -35
  43. package/vue/index.d.ts +48 -31
  44. package/vue/index.js +1 -1
  45. package/dist/chunk-24OTMNIU.js +0 -1617
  46. package/dist/chunk-D5WRORG6.js +0 -366
  47. package/dist/chunk-HNFCGIBP.js +0 -8
  48. package/dist/chunk-NB6DBRXQ.js +0 -323
  49. package/dist/chunk-OF57X5AR.js +0 -10
  50. package/dist/chunk-TL4FIE7X.js +0 -93
  51. package/dist/chunk-UL7UIUJZ.js +0 -20
  52. package/dist/cjs/app-globals-V2Kpy_OQ.js +0 -5
  53. package/dist/cjs/controlled-state-BFya8rAX.js +0 -9
  54. package/dist/cjs/events-TcQIzpNv.js +0 -19
  55. package/dist/cjs/icons-BAdjrnhS.js +0 -680
  56. package/dist/cjs/id-CYbKpaYr.js +0 -9
  57. package/dist/cjs/index-BHG9Rpil.js +0 -1602
  58. package/dist/cjs/index.cjs.js +0 -2
  59. package/dist/cjs/loader.cjs.js +0 -13
  60. package/dist/cjs/looma.cjs.js +0 -25
  61. package/dist/cjs/manager-Ce25WRtl.js +0 -95
  62. package/dist/cjs/positioning-CCR6ifPj.js +0 -426
  63. package/dist/cjs/ui-affordance-scope.cjs.entry.js +0 -43
  64. package/dist/cjs/ui-avatar-group.cjs.entry.js +0 -43
  65. package/dist/cjs/ui-avatar.cjs.entry.js +0 -50
  66. package/dist/cjs/ui-badge.cjs.entry.js +0 -19
  67. package/dist/cjs/ui-button.cjs.entry.js +0 -75
  68. package/dist/cjs/ui-callout.cjs.entry.js +0 -27
  69. package/dist/cjs/ui-checkbox.cjs.entry.js +0 -97
  70. package/dist/cjs/ui-chip_2.cjs.entry.js +0 -258
  71. package/dist/cjs/ui-combobox.cjs.entry.js +0 -708
  72. package/dist/cjs/ui-context-menu.cjs.entry.js +0 -239
  73. package/dist/cjs/ui-dialog.cjs.entry.js +0 -131
  74. package/dist/cjs/ui-disclosure.cjs.entry.js +0 -112
  75. package/dist/cjs/ui-editable.cjs.entry.js +0 -100
  76. package/dist/cjs/ui-floating-action-button.cjs.entry.js +0 -20
  77. package/dist/cjs/ui-form-field.cjs.entry.js +0 -114
  78. package/dist/cjs/ui-icon-button.cjs.entry.js +0 -23
  79. package/dist/cjs/ui-input.cjs.entry.js +0 -106
  80. package/dist/cjs/ui-menu-item.cjs.entry.js +0 -19
  81. package/dist/cjs/ui-menu.cjs.entry.js +0 -182
  82. package/dist/cjs/ui-popover.cjs.entry.js +0 -135
  83. package/dist/cjs/ui-radio-group.cjs.entry.js +0 -134
  84. package/dist/cjs/ui-radio.cjs.entry.js +0 -94
  85. package/dist/cjs/ui-search-result-row.cjs.entry.js +0 -47
  86. package/dist/cjs/ui-search-shell.cjs.entry.js +0 -39
  87. package/dist/cjs/ui-select.cjs.entry.js +0 -108
  88. package/dist/cjs/ui-switch.cjs.entry.js +0 -74
  89. package/dist/cjs/ui-tabs.cjs.entry.js +0 -118
  90. package/dist/cjs/ui-textarea.cjs.entry.js +0 -110
  91. package/dist/cjs/ui-toast-region.cjs.entry.js +0 -93
  92. package/dist/cjs/ui-top-bar.cjs.entry.js +0 -43
  93. package/dist/cjs/ui-tree-item.cjs.entry.js +0 -135
  94. package/dist/cjs/ui-tree.cjs.entry.js +0 -500
  95. package/dist/collection/collection-manifest.json +0 -45
  96. package/dist/collection/components/ui-affordance-scope/ui-affordance-scope.css +0 -8
  97. package/dist/collection/components/ui-affordance-scope/ui-affordance-scope.js +0 -70
  98. package/dist/collection/components/ui-avatar/ui-avatar.css +0 -35
  99. package/dist/collection/components/ui-avatar/ui-avatar.js +0 -130
  100. package/dist/collection/components/ui-avatar-group/ui-avatar-group.css +0 -32
  101. package/dist/collection/components/ui-avatar-group/ui-avatar-group.js +0 -95
  102. package/dist/collection/components/ui-badge/ui-badge.css +0 -90
  103. package/dist/collection/components/ui-badge/ui-badge.js +0 -62
  104. package/dist/collection/components/ui-button/ui-button.css +0 -121
  105. package/dist/collection/components/ui-button/ui-button.js +0 -141
  106. package/dist/collection/components/ui-callout/ui-callout.css +0 -74
  107. package/dist/collection/components/ui-callout/ui-callout.js +0 -59
  108. package/dist/collection/components/ui-checkbox/ui-checkbox.css +0 -24
  109. package/dist/collection/components/ui-checkbox/ui-checkbox.js +0 -228
  110. package/dist/collection/components/ui-chip/ui-chip.css +0 -57
  111. package/dist/collection/components/ui-chip/ui-chip.js +0 -67
  112. package/dist/collection/components/ui-combobox/ui-combobox.css +0 -47
  113. package/dist/collection/components/ui-combobox/ui-combobox.js +0 -1295
  114. package/dist/collection/components/ui-context-menu/ui-context-menu.css +0 -34
  115. package/dist/collection/components/ui-context-menu/ui-context-menu.js +0 -311
  116. package/dist/collection/components/ui-dialog/ui-dialog.css +0 -72
  117. package/dist/collection/components/ui-dialog/ui-dialog.js +0 -242
  118. package/dist/collection/components/ui-disclosure/ui-disclosure.css +0 -7
  119. package/dist/collection/components/ui-disclosure/ui-disclosure.js +0 -184
  120. package/dist/collection/components/ui-editable/ui-editable.css +0 -2
  121. package/dist/collection/components/ui-editable/ui-editable.js +0 -196
  122. package/dist/collection/components/ui-floating-action-button/ui-floating-action-button.css +0 -73
  123. package/dist/collection/components/ui-floating-action-button/ui-floating-action-button.js +0 -85
  124. package/dist/collection/components/ui-form-field/ui-form-field.css +0 -25
  125. package/dist/collection/components/ui-form-field/ui-form-field.js +0 -180
  126. package/dist/collection/components/ui-icon-button/ui-icon-button.css +0 -145
  127. package/dist/collection/components/ui-icon-button/ui-icon-button.js +0 -128
  128. package/dist/collection/components/ui-input/ui-input.css +0 -48
  129. package/dist/collection/components/ui-input/ui-input.js +0 -217
  130. package/dist/collection/components/ui-menu/ui-menu.css +0 -73
  131. package/dist/collection/components/ui-menu/ui-menu.js +0 -280
  132. package/dist/collection/components/ui-menu-item/ui-menu-item.css +0 -32
  133. package/dist/collection/components/ui-menu-item/ui-menu-item.js +0 -64
  134. package/dist/collection/components/ui-popover/ui-popover.css +0 -58
  135. package/dist/collection/components/ui-popover/ui-popover.js +0 -232
  136. package/dist/collection/components/ui-radio/ui-radio.css +0 -22
  137. package/dist/collection/components/ui-radio/ui-radio.js +0 -226
  138. package/dist/collection/components/ui-radio-group/ui-radio-group.css +0 -10
  139. package/dist/collection/components/ui-radio-group/ui-radio-group.js +0 -247
  140. package/dist/collection/components/ui-search-result-row/ui-search-result-row.css +0 -80
  141. package/dist/collection/components/ui-search-result-row/ui-search-result-row.js +0 -100
  142. package/dist/collection/components/ui-search-shell/ui-search-shell.css +0 -63
  143. package/dist/collection/components/ui-search-shell/ui-search-shell.js +0 -46
  144. package/dist/collection/components/ui-select/ui-select.css +0 -64
  145. package/dist/collection/components/ui-select/ui-select.js +0 -218
  146. package/dist/collection/components/ui-switch/ui-switch.css +0 -63
  147. package/dist/collection/components/ui-switch/ui-switch.js +0 -185
  148. package/dist/collection/components/ui-tabs/ui-tabs.css +0 -68
  149. package/dist/collection/components/ui-tabs/ui-tabs.js +0 -190
  150. package/dist/collection/components/ui-textarea/ui-textarea.css +0 -49
  151. package/dist/collection/components/ui-textarea/ui-textarea.js +0 -241
  152. package/dist/collection/components/ui-toast-region/ui-toast-region.css +0 -59
  153. package/dist/collection/components/ui-toast-region/ui-toast-region.js +0 -126
  154. package/dist/collection/components/ui-tooltip/ui-tooltip.css +0 -43
  155. package/dist/collection/components/ui-tooltip/ui-tooltip.js +0 -430
  156. package/dist/collection/components/ui-top-bar/ui-top-bar.css +0 -51
  157. package/dist/collection/components/ui-top-bar/ui-top-bar.js +0 -52
  158. package/dist/collection/components/ui-tree/ui-tree.css +0 -12
  159. package/dist/collection/components/ui-tree/ui-tree.js +0 -515
  160. package/dist/collection/components/ui-tree-item/ui-tree-item.css +0 -217
  161. package/dist/collection/components/ui-tree-item/ui-tree-item.js +0 -406
  162. package/dist/collection/field/combobox.js +0 -4
  163. package/dist/collection/field/editable.js +0 -1
  164. package/dist/collection/field/multi-combobox.js +0 -1
  165. package/dist/collection/field/valibot.js +0 -5
  166. package/dist/collection/field/validation.js +0 -62
  167. package/dist/collection/icons.js +0 -71
  168. package/dist/collection/input-modality.js +0 -24
  169. package/dist/collection/overlay/manager.js +0 -92
  170. package/dist/collection/overlay/positioning.js +0 -424
  171. package/dist/collection/utils/controlled-state.js +0 -4
  172. package/dist/collection/utils/drag-drop.js +0 -51
  173. package/dist/collection/utils/events.js +0 -13
  174. package/dist/collection/utils/id.js +0 -5
  175. package/dist/collection/utils/initials.js +0 -11
  176. package/dist/components/index.d.ts +0 -102
  177. package/dist/components/index.js +0 -1
  178. package/dist/components/p-6SWSrfmW.js +0 -1
  179. package/dist/components/p-B_DaIVEY.js +0 -1
  180. package/dist/components/p-Bh_1GxOD.js +0 -1
  181. package/dist/components/p-BnGhGgTH.js +0 -1
  182. package/dist/components/p-BzaB_bXo.js +0 -1
  183. package/dist/components/p-C-0syqXZ.js +0 -1
  184. package/dist/components/p-CoFximGM.js +0 -13
  185. package/dist/components/p-JwSoedEO.js +0 -1
  186. package/dist/components/p-Vc4ExHFc.js +0 -1
  187. package/dist/components/p-hgBUJRDa.js +0 -1
  188. package/dist/components/ui-affordance-scope.d.ts +0 -11
  189. package/dist/components/ui-affordance-scope.js +0 -1
  190. package/dist/components/ui-avatar-group.d.ts +0 -11
  191. package/dist/components/ui-avatar-group.js +0 -1
  192. package/dist/components/ui-avatar.d.ts +0 -11
  193. package/dist/components/ui-avatar.js +0 -1
  194. package/dist/components/ui-badge.d.ts +0 -11
  195. package/dist/components/ui-badge.js +0 -1
  196. package/dist/components/ui-button.d.ts +0 -11
  197. package/dist/components/ui-button.js +0 -1
  198. package/dist/components/ui-callout.d.ts +0 -11
  199. package/dist/components/ui-callout.js +0 -1
  200. package/dist/components/ui-checkbox.d.ts +0 -11
  201. package/dist/components/ui-checkbox.js +0 -1
  202. package/dist/components/ui-chip.d.ts +0 -11
  203. package/dist/components/ui-chip.js +0 -1
  204. package/dist/components/ui-combobox.d.ts +0 -11
  205. package/dist/components/ui-combobox.js +0 -1
  206. package/dist/components/ui-context-menu.d.ts +0 -11
  207. package/dist/components/ui-context-menu.js +0 -1
  208. package/dist/components/ui-dialog.d.ts +0 -11
  209. package/dist/components/ui-dialog.js +0 -1
  210. package/dist/components/ui-disclosure.d.ts +0 -11
  211. package/dist/components/ui-disclosure.js +0 -1
  212. package/dist/components/ui-editable.d.ts +0 -11
  213. package/dist/components/ui-editable.js +0 -1
  214. package/dist/components/ui-floating-action-button.d.ts +0 -11
  215. package/dist/components/ui-floating-action-button.js +0 -1
  216. package/dist/components/ui-form-field.d.ts +0 -11
  217. package/dist/components/ui-form-field.js +0 -1
  218. package/dist/components/ui-icon-button.d.ts +0 -11
  219. package/dist/components/ui-icon-button.js +0 -1
  220. package/dist/components/ui-input.d.ts +0 -11
  221. package/dist/components/ui-input.js +0 -1
  222. package/dist/components/ui-menu-item.d.ts +0 -11
  223. package/dist/components/ui-menu-item.js +0 -1
  224. package/dist/components/ui-menu.d.ts +0 -11
  225. package/dist/components/ui-menu.js +0 -1
  226. package/dist/components/ui-popover.d.ts +0 -11
  227. package/dist/components/ui-popover.js +0 -1
  228. package/dist/components/ui-radio-group.d.ts +0 -11
  229. package/dist/components/ui-radio-group.js +0 -1
  230. package/dist/components/ui-radio.d.ts +0 -11
  231. package/dist/components/ui-radio.js +0 -1
  232. package/dist/components/ui-search-result-row.d.ts +0 -11
  233. package/dist/components/ui-search-result-row.js +0 -1
  234. package/dist/components/ui-search-shell.d.ts +0 -11
  235. package/dist/components/ui-search-shell.js +0 -1
  236. package/dist/components/ui-select.d.ts +0 -11
  237. package/dist/components/ui-select.js +0 -1
  238. package/dist/components/ui-switch.d.ts +0 -11
  239. package/dist/components/ui-switch.js +0 -1
  240. package/dist/components/ui-tabs.d.ts +0 -11
  241. package/dist/components/ui-tabs.js +0 -1
  242. package/dist/components/ui-textarea.d.ts +0 -11
  243. package/dist/components/ui-textarea.js +0 -1
  244. package/dist/components/ui-toast-region.d.ts +0 -11
  245. package/dist/components/ui-toast-region.js +0 -1
  246. package/dist/components/ui-tooltip.d.ts +0 -11
  247. package/dist/components/ui-tooltip.js +0 -1
  248. package/dist/components/ui-top-bar.d.ts +0 -11
  249. package/dist/components/ui-top-bar.js +0 -1
  250. package/dist/components/ui-tree-item.d.ts +0 -11
  251. package/dist/components/ui-tree-item.js +0 -1
  252. package/dist/components/ui-tree.d.ts +0 -11
  253. package/dist/components/ui-tree.js +0 -1
  254. package/dist/esm/app-globals-DQuL1Twl.js +0 -3
  255. package/dist/esm/controlled-state-BnGhGgTH.js +0 -6
  256. package/dist/esm/events-JwSoedEO.js +0 -15
  257. package/dist/esm/icons-CoFximGM.js +0 -678
  258. package/dist/esm/id-hgBUJRDa.js +0 -7
  259. package/dist/esm/index-8BGiMGQ0.js +0 -1593
  260. package/dist/esm/index.js +0 -1
  261. package/dist/esm/loader.js +0 -11
  262. package/dist/esm/looma.js +0 -21
  263. package/dist/esm/manager-C-0syqXZ.js +0 -91
  264. package/dist/esm/positioning-ZOr-2PSe.js +0 -421
  265. package/dist/esm/ui-affordance-scope.entry.js +0 -41
  266. package/dist/esm/ui-avatar-group.entry.js +0 -41
  267. package/dist/esm/ui-avatar.entry.js +0 -48
  268. package/dist/esm/ui-badge.entry.js +0 -17
  269. package/dist/esm/ui-button.entry.js +0 -73
  270. package/dist/esm/ui-callout.entry.js +0 -25
  271. package/dist/esm/ui-checkbox.entry.js +0 -95
  272. package/dist/esm/ui-chip_2.entry.js +0 -255
  273. package/dist/esm/ui-combobox.entry.js +0 -706
  274. package/dist/esm/ui-context-menu.entry.js +0 -237
  275. package/dist/esm/ui-dialog.entry.js +0 -129
  276. package/dist/esm/ui-disclosure.entry.js +0 -110
  277. package/dist/esm/ui-editable.entry.js +0 -98
  278. package/dist/esm/ui-floating-action-button.entry.js +0 -18
  279. package/dist/esm/ui-form-field.entry.js +0 -112
  280. package/dist/esm/ui-icon-button.entry.js +0 -21
  281. package/dist/esm/ui-input.entry.js +0 -104
  282. package/dist/esm/ui-menu-item.entry.js +0 -17
  283. package/dist/esm/ui-menu.entry.js +0 -180
  284. package/dist/esm/ui-popover.entry.js +0 -133
  285. package/dist/esm/ui-radio-group.entry.js +0 -132
  286. package/dist/esm/ui-radio.entry.js +0 -92
  287. package/dist/esm/ui-search-result-row.entry.js +0 -45
  288. package/dist/esm/ui-search-shell.entry.js +0 -37
  289. package/dist/esm/ui-select.entry.js +0 -106
  290. package/dist/esm/ui-switch.entry.js +0 -72
  291. package/dist/esm/ui-tabs.entry.js +0 -116
  292. package/dist/esm/ui-textarea.entry.js +0 -108
  293. package/dist/esm/ui-toast-region.entry.js +0 -91
  294. package/dist/esm/ui-top-bar.entry.js +0 -41
  295. package/dist/esm/ui-tree-item.entry.js +0 -133
  296. package/dist/esm/ui-tree.entry.js +0 -498
  297. package/dist/index.cjs.js +0 -1
  298. package/dist/looma/index.esm.js +0 -0
  299. package/dist/looma/looma.esm.js +0 -1
  300. package/dist/looma/p-08f80207.entry.js +0 -1
  301. package/dist/looma/p-0b5b8d9e.entry.js +0 -1
  302. package/dist/looma/p-1249a806.entry.js +0 -1
  303. package/dist/looma/p-16e0669d.entry.js +0 -1
  304. package/dist/looma/p-1c00670f.entry.js +0 -1
  305. package/dist/looma/p-1c5a7522.entry.js +0 -1
  306. package/dist/looma/p-22842f8c.entry.js +0 -1
  307. package/dist/looma/p-2915d5c0.entry.js +0 -1
  308. package/dist/looma/p-3b2961a6.entry.js +0 -1
  309. package/dist/looma/p-3f60f4c8.entry.js +0 -1
  310. package/dist/looma/p-424d6719.entry.js +0 -1
  311. package/dist/looma/p-4caccfce.entry.js +0 -1
  312. package/dist/looma/p-5fdcee1d.entry.js +0 -1
  313. package/dist/looma/p-6d8b99ee.entry.js +0 -1
  314. package/dist/looma/p-6f20d470.entry.js +0 -1
  315. package/dist/looma/p-7c0b5364.entry.js +0 -1
  316. package/dist/looma/p-8BGiMGQ0.js +0 -2
  317. package/dist/looma/p-8bdd9495.entry.js +0 -1
  318. package/dist/looma/p-99116a72.entry.js +0 -1
  319. package/dist/looma/p-9cfbf722.entry.js +0 -1
  320. package/dist/looma/p-9d2662ca.entry.js +0 -1
  321. package/dist/looma/p-9ff2fa19.entry.js +0 -1
  322. package/dist/looma/p-BnGhGgTH.js +0 -1
  323. package/dist/looma/p-C-0syqXZ.js +0 -1
  324. package/dist/looma/p-CoFximGM.js +0 -13
  325. package/dist/looma/p-DQuL1Twl.js +0 -1
  326. package/dist/looma/p-JwSoedEO.js +0 -1
  327. package/dist/looma/p-ZOr-2PSe.js +0 -1
  328. package/dist/looma/p-a2dd4c6c.entry.js +0 -1
  329. package/dist/looma/p-add67e4c.entry.js +0 -1
  330. package/dist/looma/p-b6ede6bb.entry.js +0 -1
  331. package/dist/looma/p-b76e2111.entry.js +0 -1
  332. package/dist/looma/p-ca2a54fd.entry.js +0 -1
  333. package/dist/looma/p-d372b0db.entry.js +0 -1
  334. package/dist/looma/p-d4825822.entry.js +0 -1
  335. package/dist/looma/p-d56571a2.entry.js +0 -1
  336. package/dist/looma/p-d5c3954f.entry.js +0 -1
  337. package/dist/looma/p-e604e906.entry.js +0 -1
  338. package/dist/looma/p-f1f7c5cb.entry.js +0 -1
  339. package/dist/looma/p-hgBUJRDa.js +0 -1
  340. package/dist/types/components/ui-affordance-scope/ui-affordance-scope.d.ts +0 -11
  341. package/dist/types/components/ui-avatar/ui-avatar.d.ts +0 -11
  342. package/dist/types/components/ui-avatar-group/ui-avatar-group.d.ts +0 -11
  343. package/dist/types/components/ui-badge/ui-badge.d.ts +0 -5
  344. package/dist/types/components/ui-button/ui-button.d.ts +0 -13
  345. package/dist/types/components/ui-callout/ui-callout.d.ts +0 -6
  346. package/dist/types/components/ui-checkbox/ui-checkbox.d.ts +0 -20
  347. package/dist/types/components/ui-chip/ui-chip.d.ts +0 -8
  348. package/dist/types/components/ui-combobox/ui-combobox.d.ts +0 -128
  349. package/dist/types/components/ui-context-menu/ui-context-menu.d.ts +0 -43
  350. package/dist/types/components/ui-dialog/ui-dialog.d.ts +0 -27
  351. package/dist/types/components/ui-disclosure/ui-disclosure.d.ts +0 -21
  352. package/dist/types/components/ui-editable/ui-editable.d.ts +0 -24
  353. package/dist/types/components/ui-floating-action-button/ui-floating-action-button.d.ts +0 -6
  354. package/dist/types/components/ui-form-field/ui-form-field.d.ts +0 -18
  355. package/dist/types/components/ui-icon-button/ui-icon-button.d.ts +0 -9
  356. package/dist/types/components/ui-input/ui-input.d.ts +0 -19
  357. package/dist/types/components/ui-menu/ui-menu.d.ts +0 -28
  358. package/dist/types/components/ui-menu-item/ui-menu-item.d.ts +0 -5
  359. package/dist/types/components/ui-popover/ui-popover.d.ts +0 -26
  360. package/dist/types/components/ui-radio/ui-radio.d.ts +0 -20
  361. package/dist/types/components/ui-radio-group/ui-radio-group.d.ts +0 -21
  362. package/dist/types/components/ui-search-result-row/ui-search-result-row.d.ts +0 -15
  363. package/dist/types/components/ui-search-shell/ui-search-shell.d.ts +0 -9
  364. package/dist/types/components/ui-select/ui-select.d.ts +0 -20
  365. package/dist/types/components/ui-switch/ui-switch.d.ts +0 -16
  366. package/dist/types/components/ui-tabs/ui-tabs.d.ts +0 -18
  367. package/dist/types/components/ui-textarea/ui-textarea.d.ts +0 -20
  368. package/dist/types/components/ui-toast-region/ui-toast-region.d.ts +0 -16
  369. package/dist/types/components/ui-tooltip/ui-tooltip.d.ts +0 -57
  370. package/dist/types/components/ui-top-bar/ui-top-bar.d.ts +0 -12
  371. package/dist/types/components/ui-tree/ui-tree.d.ts +0 -53
  372. package/dist/types/components/ui-tree-item/ui-tree-item.d.ts +0 -44
  373. package/dist/types/components.d.ts +0 -1889
  374. package/dist/types/field/combobox.d.ts +0 -46
  375. package/dist/types/field/editable.d.ts +0 -5
  376. package/dist/types/field/multi-combobox.d.ts +0 -11
  377. package/dist/types/field/valibot.d.ts +0 -7
  378. package/dist/types/icons.d.ts +0 -53
  379. package/dist/types/input-modality.d.ts +0 -6
  380. package/dist/types/overlay/manager.d.ts +0 -17
  381. package/dist/types/overlay/positioning.d.ts +0 -74
  382. package/dist/types/stencil-public-runtime.d.ts +0 -1860
  383. package/dist/types/utils/controlled-state.d.ts +0 -4
  384. package/dist/types/utils/drag-drop.d.ts +0 -15
  385. package/dist/types/utils/events.d.ts +0 -4
  386. package/dist/types/utils/id.d.ts +0 -1
  387. package/dist/types/utils/initials.d.ts +0 -1
  388. package/dist/ui-affordance-scope.entry-L6TIXYOP.js +0 -54
  389. package/dist/ui-avatar-group.entry-TCAA6P72.js +0 -51
  390. package/dist/ui-avatar.entry-52DQ7VXA.js +0 -51
  391. package/dist/ui-badge.entry-2XCAA6LL.js +0 -22
  392. package/dist/ui-button.entry-MNFBMNSX.js +0 -83
  393. package/dist/ui-callout.entry-SSHT5TH2.js +0 -32
  394. package/dist/ui-checkbox.entry-LOWIWIWI.js +0 -111
  395. package/dist/ui-chip_2.entry-BIMTSF6C.js +0 -272
  396. package/dist/ui-combobox.entry-25Z4MN7N.js +0 -717
  397. package/dist/ui-context-menu.entry-YZDL5Y4M.js +0 -248
  398. package/dist/ui-dialog.entry-HIXZX5AB.js +0 -146
  399. package/dist/ui-disclosure.entry-2JZHZNDQ.js +0 -126
  400. package/dist/ui-editable.entry-U3VR3XPT.js +0 -110
  401. package/dist/ui-floating-action-button.entry-6S3QN3KJ.js +0 -23
  402. package/dist/ui-form-field.entry-GQOSMLHT.js +0 -120
  403. package/dist/ui-icon-button.entry-QJXKVDM6.js +0 -26
  404. package/dist/ui-input.entry-UWMQ6JMP.js +0 -114
  405. package/dist/ui-menu-item.entry-NHNZKKJS.js +0 -22
  406. package/dist/ui-menu.entry-D53RUJND.js +0 -192
  407. package/dist/ui-popover.entry-7ZSIWCFQ.js +0 -152
  408. package/dist/ui-radio-group.entry-37MSYIH4.js +0 -142
  409. package/dist/ui-radio.entry-7YGCDHXT.js +0 -108
  410. package/dist/ui-search-result-row.entry-6FCCLGAS.js +0 -50
  411. package/dist/ui-search-shell.entry-HSBEXPER.js +0 -41
  412. package/dist/ui-select.entry-GIDIAYRD.js +0 -117
  413. package/dist/ui-switch.entry-MYAL6XPC.js +0 -87
  414. package/dist/ui-tabs.entry-R4TEXQSD.js +0 -128
  415. package/dist/ui-textarea.entry-FW32JNDV.js +0 -119
  416. package/dist/ui-toast-region.entry-BTMFPKZF.js +0 -104
  417. package/dist/ui-top-bar.entry-5DQGJF3B.js +0 -49
  418. package/dist/ui-tree-item.entry-ADT7DSOS.js +0 -145
  419. package/dist/ui-tree.entry-7PYQ5RIN.js +0 -470
  420. package/editor/chunk-64GLF274.js +0 -1271
  421. package/layout/index.css +0 -387
  422. package/loader/cdn.js +0 -1
  423. package/loader/index.cjs.js +0 -1
  424. package/loader/index.d.ts +0 -24
  425. package/loader/index.es2017.js +0 -1
  426. package/loader/index.js +0 -2
  427. package/vue/chunk-ROMBQS2L.js +0 -352
@@ -1,1271 +0,0 @@
1
- import {
2
- MAX_MENTION_RESULT_LIMIT,
3
- TABLE_CELL_BACKGROUND_OPTIONS
4
- } from "./chunk-ZOUKEZ77.js";
5
-
6
- // src/table-context-menu.ts
7
- import {
8
- clampRectToViewport,
9
- getVisualViewportRect,
10
- loomaIconMarkup
11
- } from "@threadlabs/looma/core";
12
- var TAG = "ui-editor-table-context-menu";
13
- function dispatchTableAction(element, action) {
14
- element.dispatchEvent(
15
- new CustomEvent("looma-editor-table-action", {
16
- detail: { action },
17
- bubbles: true,
18
- composed: true
19
- })
20
- );
21
- }
22
- if (typeof HTMLElement !== "undefined") {
23
- class UIEditorTableContextMenuElement extends HTMLElement {
24
- positionFrame = null;
25
- static get observedAttributes() {
26
- return [
27
- "open",
28
- "cell-background",
29
- "can-add-row-before",
30
- "can-add-row-after",
31
- "can-add-column-before",
32
- "can-add-column-after",
33
- "can-delete-row",
34
- "can-delete-column",
35
- "can-delete-table",
36
- "can-merge-cells",
37
- "can-split-cell"
38
- ];
39
- }
40
- getBoolAttr(name) {
41
- return this.hasAttribute(name) && this.getAttribute(name) !== "false";
42
- }
43
- connectedCallback() {
44
- this.render();
45
- this.addEventListener("click", this.onClick);
46
- window.addEventListener("resize", this.scheduleViewportPosition);
47
- window.visualViewport?.addEventListener("resize", this.scheduleViewportPosition);
48
- window.visualViewport?.addEventListener("scroll", this.scheduleViewportPosition);
49
- }
50
- disconnectedCallback() {
51
- this.removeEventListener("click", this.onClick);
52
- window.removeEventListener("resize", this.scheduleViewportPosition);
53
- window.visualViewport?.removeEventListener("resize", this.scheduleViewportPosition);
54
- window.visualViewport?.removeEventListener("scroll", this.scheduleViewportPosition);
55
- if (this.positionFrame !== null) {
56
- cancelAnimationFrame(this.positionFrame);
57
- this.positionFrame = null;
58
- }
59
- }
60
- attributeChangedCallback() {
61
- this.render();
62
- }
63
- onClick(e) {
64
- const target = e.target;
65
- const trigger = target?.closest("[data-action]");
66
- const action = trigger?.getAttribute("data-action");
67
- if (action) {
68
- dispatchTableAction(this, action);
69
- }
70
- }
71
- positionWithinViewport = () => {
72
- this.positionFrame = null;
73
- const menu = this.querySelector(".ui-editor-table-context-menu");
74
- if (!menu) return;
75
- menu.style.translate = "";
76
- const rect = menu.getBoundingClientRect();
77
- const { x: offsetX, y: offsetY } = clampRectToViewport(
78
- rect,
79
- getVisualViewportRect(window),
80
- 12
81
- );
82
- if (offsetX !== 0 || offsetY !== 0) {
83
- menu.style.translate = `${offsetX}px ${offsetY}px`;
84
- }
85
- };
86
- scheduleViewportPosition = () => {
87
- if (!this.isConnected) return;
88
- if (this.positionFrame !== null) cancelAnimationFrame(this.positionFrame);
89
- this.positionFrame = requestAnimationFrame(this.positionWithinViewport);
90
- };
91
- render() {
92
- const open = this.getBoolAttr("open");
93
- this.hidden = !open;
94
- if (!open) return;
95
- const currentBackground = this.getAttribute("cell-background");
96
- const sections = [
97
- {
98
- heading: "Cell background",
99
- backgrounds: TABLE_CELL_BACKGROUND_OPTIONS
100
- },
101
- {
102
- heading: "Structure",
103
- actions: [
104
- { action: "add-row-before", label: "Add row above", icon: "panel-top", can: "can-add-row-before" },
105
- { action: "add-row-after", label: "Add row below", icon: "panel-bottom", can: "can-add-row-after" },
106
- { action: "add-column-before", label: "Add column left", icon: "panel-left", can: "can-add-column-before" },
107
- { action: "add-column-after", label: "Add column right", icon: "panel-right", can: "can-add-column-after" }
108
- ]
109
- },
110
- {
111
- heading: "Cells",
112
- actions: [
113
- { action: "clear-cells", label: "Clear selected cells", icon: "eraser" },
114
- { action: "merge-cells", label: "Merge cells", icon: "merge", can: "can-merge-cells" },
115
- { action: "split-cell", label: "Split cell", icon: "split", can: "can-split-cell" }
116
- ]
117
- },
118
- {
119
- heading: "Table",
120
- actions: [
121
- { action: "delete-row", label: "Delete row", icon: "trash", can: "can-delete-row", tone: "danger" },
122
- { action: "delete-column", label: "Delete column", icon: "trash", can: "can-delete-column", tone: "danger" },
123
- { action: "delete-table", label: "Delete table", icon: "trash", can: "can-delete-table", tone: "danger" }
124
- ]
125
- }
126
- ];
127
- const availableSections = sections.map((section) => {
128
- if ("backgrounds" in section) {
129
- return section;
130
- }
131
- return {
132
- ...section,
133
- actions: section.actions.filter((action) => !action.can || this.getBoolAttr(action.can))
134
- };
135
- }).filter((section) => "backgrounds" in section ? section.backgrounds.length > 0 : section.actions.length > 0);
136
- let html = '<div class="ui-editor-table-context-menu" role="menu">';
137
- availableSections.forEach((section, sectionIndex) => {
138
- if (sectionIndex > 0) {
139
- html += '<div class="ui-editor-table-context-menu__sep"></div>';
140
- }
141
- html += '<div class="ui-editor-table-context-menu__section" role="none">';
142
- html += `<div class="ui-editor-table-context-menu__heading" role="presentation">${section.heading}</div>`;
143
- if ("backgrounds" in section) {
144
- html += '<div class="ui-editor-table-context-menu__swatches" role="group" aria-label="Cell background">';
145
- section.backgrounds.forEach((background) => {
146
- const isSelected = (background.value ?? "") === (currentBackground ?? "");
147
- html += `<button type="button" class="ui-editor-table-context-menu__swatch-button" role="menuitemradio" aria-checked="${isSelected ? "true" : "false"}" data-action="${background.action}"${isSelected ? ' data-selected="true"' : ""}><span class="ui-editor-table-context-menu__swatch${background.swatch ? "" : " ui-editor-table-context-menu__swatch--default"}"${background.swatch ? ` style="--ui-editor-table-context-swatch:${background.swatch}"` : ""}></span><span class="ui-editor-table-context-menu__swatch-label">${background.label}</span></button>`;
148
- });
149
- html += "</div>";
150
- } else {
151
- section.actions.forEach((action) => {
152
- const tone = "tone" in action ? action.tone : void 0;
153
- html += `<button type="button" role="menuitem" data-action="${action.action}"${tone ? ` data-tone="${tone}"` : ""}>${loomaIconMarkup(action.icon)}<span>${action.label}</span></button>`;
154
- });
155
- }
156
- html += "</div>";
157
- });
158
- html += "</div>";
159
- this.innerHTML = html;
160
- this.scheduleViewportPosition();
161
- }
162
- }
163
- if (typeof window !== "undefined" && !customElements.get(TAG)) {
164
- customElements.define(TAG, UIEditorTableContextMenuElement);
165
- }
166
- }
167
-
168
- // src/table-toolbar.ts
169
- import { loomaIconMarkup as loomaIconMarkup2 } from "@threadlabs/looma/core";
170
- var TAG2 = "ui-editor-table-toolbar";
171
- function dispatchTableAction2(element, action) {
172
- element.dispatchEvent(
173
- new CustomEvent("looma-editor-table-action", {
174
- detail: { action },
175
- bubbles: true,
176
- composed: true
177
- })
178
- );
179
- }
180
- if (typeof HTMLElement !== "undefined") {
181
- class UIEditorTableToolbarElement extends HTMLElement {
182
- #overflowOpen = false;
183
- static get observedAttributes() {
184
- return [
185
- "open",
186
- "cell-alignment",
187
- "cell-background",
188
- "can-add-row-after",
189
- "can-add-column-after",
190
- "can-add-row-before",
191
- "can-add-column-before",
192
- "can-delete-row",
193
- "can-delete-column",
194
- "can-delete-table",
195
- "can-merge-cells",
196
- "can-split-cell"
197
- ];
198
- }
199
- getBoolAttr(name) {
200
- return this.hasAttribute(name) && this.getAttribute(name) !== "false";
201
- }
202
- getAlignmentAttr() {
203
- const value = this.getAttribute("cell-alignment");
204
- if (value === "center") {
205
- return "align-center";
206
- }
207
- if (value === "right") {
208
- return "align-right";
209
- }
210
- return "align-left";
211
- }
212
- connectedCallback() {
213
- this.render();
214
- this.addEventListener("click", this.onClick);
215
- document.addEventListener("pointerdown", this.onDocumentPointerDown, true);
216
- }
217
- disconnectedCallback() {
218
- this.removeEventListener("click", this.onClick);
219
- document.removeEventListener("pointerdown", this.onDocumentPointerDown, true);
220
- }
221
- attributeChangedCallback() {
222
- this.render();
223
- }
224
- onClick = (event) => {
225
- const target = event.target.closest("[data-action]");
226
- if (!target) {
227
- return;
228
- }
229
- if (target.dataset.action === "toggle-overflow") {
230
- this.#overflowOpen = !this.#overflowOpen;
231
- this.render();
232
- return;
233
- }
234
- const action = target.dataset.action;
235
- if (!action) {
236
- return;
237
- }
238
- this.#overflowOpen = false;
239
- this.render();
240
- dispatchTableAction2(this, action);
241
- };
242
- onDocumentPointerDown = (event) => {
243
- if (!this.#overflowOpen) {
244
- return;
245
- }
246
- const path = typeof event.composedPath === "function" ? event.composedPath() : [];
247
- if (path.includes(this)) {
248
- return;
249
- }
250
- if (event.target instanceof Node && this.contains(event.target)) {
251
- return;
252
- }
253
- this.#overflowOpen = false;
254
- this.render();
255
- };
256
- render() {
257
- const open = this.getBoolAttr("open");
258
- this.hidden = !open;
259
- if (!open) {
260
- this.#overflowOpen = false;
261
- return;
262
- }
263
- const activeAlignment = this.getAlignmentAttr();
264
- const currentBackground = this.getAttribute("cell-background");
265
- const alignmentActions = [
266
- { action: "align-left", label: "Align left", icon: "align-left" },
267
- { action: "align-center", label: "Align center", icon: "align-center" },
268
- { action: "align-right", label: "Align right", icon: "align-right" }
269
- ];
270
- const structuralActions = [
271
- { action: "add-row-after", label: "Add row", icon: "rows", can: "can-add-row-after" },
272
- { action: "add-column-after", label: "Add column", icon: "columns", can: "can-add-column-after" }
273
- ].filter((action) => this.getBoolAttr(action.can));
274
- const overflowSections = [
275
- {
276
- heading: "Structure",
277
- actions: [
278
- { action: "add-row-before", label: "Add row above", icon: "panel-top", can: "can-add-row-before" },
279
- { action: "add-column-before", label: "Add column left", icon: "panel-left", can: "can-add-column-before" }
280
- ]
281
- },
282
- {
283
- heading: "Cells",
284
- actions: [
285
- { action: "clear-cells", label: "Clear selected cells", icon: "eraser" },
286
- { action: "merge-cells", label: "Merge selected cells", icon: "merge", can: "can-merge-cells" },
287
- { action: "split-cell", label: "Split merged cell", icon: "split", can: "can-split-cell" }
288
- ]
289
- },
290
- {
291
- heading: "Table",
292
- actions: [
293
- { action: "delete-row", label: "Delete row", icon: "trash", can: "can-delete-row", tone: "danger" },
294
- { action: "delete-column", label: "Delete column", icon: "trash", can: "can-delete-column", tone: "danger" },
295
- { action: "delete-table", label: "Delete table", icon: "trash", can: "can-delete-table", tone: "danger" }
296
- ]
297
- }
298
- ];
299
- const availableOverflowSections = overflowSections.map((section) => ({
300
- ...section,
301
- actions: section.actions.filter((action) => !action.can || this.getBoolAttr(action.can))
302
- })).filter((section) => section.actions.length > 0);
303
- this.innerHTML = [
304
- '<div class="ui-editor-table-toolbar" role="toolbar" aria-label="Table actions">',
305
- '<div class="ui-editor-table-toolbar__group" role="group" aria-label="Cell alignment">',
306
- alignmentActions.map(
307
- (action) => `<button type="button" class="ui-editor-table-toolbar__icon-button" data-action="${action.action}" aria-label="${action.label}" title="${action.label}" aria-pressed="${action.action === activeAlignment ? "true" : "false"}" data-active="${action.action === activeAlignment ? "true" : "false"}">${loomaIconMarkup2(action.icon)}</button>`
308
- ).join(""),
309
- "</div>",
310
- structuralActions.length > 0 ? '<div class="ui-editor-table-toolbar__sep" aria-hidden="true"></div>' : "",
311
- structuralActions.length > 0 ? '<div class="ui-editor-table-toolbar__group" role="group" aria-label="Table structure">' : "",
312
- structuralActions.map(
313
- (action) => `<button type="button" data-action="${action.action}">${loomaIconMarkup2(action.icon)}<span>${action.label}</span></button>`
314
- ).join(""),
315
- structuralActions.length > 0 ? "</div>" : "",
316
- '<div class="ui-editor-table-toolbar__sep" aria-hidden="true"></div>',
317
- '<div class="ui-editor-table-toolbar__overflow">',
318
- `<button type="button" class="ui-editor-table-toolbar__more" data-action="toggle-overflow" aria-haspopup="menu" aria-expanded="${this.#overflowOpen ? "true" : "false"}">${loomaIconMarkup2("table")}<span>Table options</span>${loomaIconMarkup2("chevron-down", "looma-icon looma-icon--chevron")}</button>`,
319
- this.#overflowOpen ? [
320
- '<div class="ui-editor-table-toolbar__menu" role="menu" aria-label="More table actions">',
321
- '<div class="ui-editor-table-toolbar__menu-section" role="none">',
322
- '<div class="ui-editor-table-toolbar__menu-heading" role="presentation">Background</div>',
323
- '<div class="ui-editor-table-toolbar__swatches" role="group" aria-label="Cell background">',
324
- TABLE_CELL_BACKGROUND_OPTIONS.map((background) => {
325
- const isSelected = (background.value ?? "") === (currentBackground ?? "");
326
- return `<button type="button" class="ui-editor-table-toolbar__swatch-button" role="menuitemradio" aria-checked="${isSelected ? "true" : "false"}" data-action="${background.action}"${isSelected ? ' data-selected="true"' : ""}><span class="ui-editor-table-toolbar__swatch${background.swatch ? "" : " ui-editor-table-toolbar__swatch--default"}"${background.swatch ? ` style="--ui-editor-table-toolbar-swatch:${background.swatch}"` : ""}></span><span>${background.label}</span></button>`;
327
- }).join(""),
328
- "</div>",
329
- "</div>",
330
- availableOverflowSections.map(
331
- (section) => [
332
- '<div class="ui-editor-table-toolbar__menu-section ui-editor-table-toolbar__menu-section--divided" role="none">',
333
- `<div class="ui-editor-table-toolbar__menu-heading" role="presentation">${section.heading}</div>`,
334
- section.actions.map((action) => {
335
- const tone = "tone" in action ? action.tone : void 0;
336
- return `<button type="button" role="menuitem" data-action="${action.action}"${tone ? ` data-tone="${tone}"` : ""}>${loomaIconMarkup2(action.icon)}<span>${action.label}</span></button>`;
337
- }).join(""),
338
- "</div>"
339
- ].join("")
340
- ).join(""),
341
- "</div>"
342
- ].join("") : "",
343
- "</div>",
344
- "</div>"
345
- ].join("");
346
- }
347
- }
348
- if (typeof window !== "undefined" && !customElements.get(TAG2)) {
349
- customElements.define(TAG2, UIEditorTableToolbarElement);
350
- }
351
- }
352
-
353
- // src/insert-table-grid.ts
354
- var TAG3 = "ui-editor-insert-table-grid";
355
- var DEFAULT_MAX_ROWS = 8;
356
- var DEFAULT_MAX_COLS = 8;
357
- if (typeof HTMLElement !== "undefined") {
358
- class UIEditorInsertTableGridElement extends HTMLElement {
359
- static get observedAttributes() {
360
- return ["open", "max-rows", "max-cols"];
361
- }
362
- #maxRows = DEFAULT_MAX_ROWS;
363
- #maxCols = DEFAULT_MAX_COLS;
364
- #selectedRows = 3;
365
- #selectedCols = 3;
366
- #previewRows = null;
367
- #previewCols = null;
368
- #withHeaderRow = true;
369
- #selectionCommitted = false;
370
- connectedCallback() {
371
- this.#maxRows = Math.min(10, Math.max(1, parseInt(this.getAttribute("max-rows") ?? String(DEFAULT_MAX_ROWS), 10) || DEFAULT_MAX_ROWS));
372
- this.#maxCols = Math.min(10, Math.max(1, parseInt(this.getAttribute("max-cols") ?? String(DEFAULT_MAX_COLS), 10) || DEFAULT_MAX_COLS));
373
- this.render();
374
- this.addEventListener("click", this.onClick);
375
- this.addEventListener("mouseover", this.onMouseOver);
376
- this.addEventListener("mouseleave", this.onMouseLeave);
377
- }
378
- disconnectedCallback() {
379
- this.removeEventListener("click", this.onClick);
380
- this.removeEventListener("mouseover", this.onMouseOver);
381
- this.removeEventListener("mouseleave", this.onMouseLeave);
382
- }
383
- attributeChangedCallback(name) {
384
- if (name === "max-rows") this.#maxRows = Math.min(10, Math.max(1, parseInt(this.getAttribute("max-rows") ?? String(DEFAULT_MAX_ROWS), 10) || DEFAULT_MAX_ROWS));
385
- if (name === "max-cols") this.#maxCols = Math.min(10, Math.max(1, parseInt(this.getAttribute("max-cols") ?? String(DEFAULT_MAX_COLS), 10) || DEFAULT_MAX_COLS));
386
- this.render();
387
- }
388
- onClick(e) {
389
- const cell = e.target.closest("[data-row][data-col]");
390
- if (cell) {
391
- this.#selectedRows = parseInt(cell.getAttribute("data-row") ?? "1", 10);
392
- this.#selectedCols = parseInt(cell.getAttribute("data-col") ?? "1", 10);
393
- this.#previewRows = null;
394
- this.#previewCols = null;
395
- this.#selectionCommitted = true;
396
- this.updateSelectionPreview();
397
- return;
398
- }
399
- const target = e.target.closest("[data-insert-table]");
400
- if (target) {
401
- const checkbox = this.querySelector('input[type="checkbox"]');
402
- const withHeaderRow = checkbox?.checked ?? this.#withHeaderRow;
403
- this.dispatchEvent(
404
- new CustomEvent("looma-editor-insert-table", {
405
- detail: { rows: this.#selectedRows, cols: this.#selectedCols, withHeaderRow },
406
- bubbles: true,
407
- composed: true
408
- })
409
- );
410
- }
411
- }
412
- onMouseOver(e) {
413
- const cell = e.target.closest("[data-row][data-col]");
414
- if (!cell) {
415
- this.#clearPreview();
416
- return;
417
- }
418
- const nextRows = parseInt(cell.getAttribute("data-row") ?? "1", 10);
419
- const nextCols = parseInt(cell.getAttribute("data-col") ?? "1", 10);
420
- if (nextRows === this.#previewRows && nextCols === this.#previewCols) return;
421
- this.#previewRows = nextRows;
422
- this.#previewCols = nextCols;
423
- this.updateSelectionPreview();
424
- }
425
- onMouseLeave = () => {
426
- this.#clearPreview();
427
- };
428
- #clearPreview() {
429
- if (this.#previewRows === null && this.#previewCols === null) return;
430
- this.#previewRows = null;
431
- this.#previewCols = null;
432
- this.updateSelectionPreview();
433
- }
434
- updateSelectionPreview() {
435
- const activeRows = this.#previewRows ?? this.#selectedRows;
436
- const activeCols = this.#previewCols ?? this.#selectedCols;
437
- const hint = this.querySelector(".ui-editor-insert-table-grid__hint");
438
- if (hint) {
439
- hint.textContent = this.#previewRows !== null && this.#previewCols !== null ? `${activeRows} \xD7 ${activeCols}` : `${this.#selectedRows} \xD7 ${this.#selectedCols}${this.#selectionCommitted ? " selected" : ""}`;
440
- }
441
- const cells = this.querySelectorAll("[data-row][data-col]");
442
- for (const cell of cells) {
443
- const row = parseInt(cell.getAttribute("data-row") ?? "1", 10);
444
- const col = parseInt(cell.getAttribute("data-col") ?? "1", 10);
445
- const selected = row <= activeRows && col <= activeCols;
446
- cell.classList.toggle("ui-editor-insert-table-grid__cell--selected", selected);
447
- cell.setAttribute("aria-pressed", selected ? "true" : "false");
448
- }
449
- }
450
- render() {
451
- const open = this.hasAttribute("open") && this.getAttribute("open") !== "false";
452
- this.hidden = !open;
453
- if (!open) return;
454
- let html = '<div class="ui-editor-insert-table-grid">';
455
- html += `<p class="ui-editor-insert-table-grid__hint">${this.#selectedRows} \xD7 ${this.#selectedCols}</p>`;
456
- html += `<div class="ui-editor-insert-table-grid__grid" role="group" aria-label="Table dimensions" style="--ui-editor-table-grid-rows:${this.#maxRows};--ui-editor-table-grid-cols:${this.#maxCols}">`;
457
- for (let r = 1; r <= this.#maxRows; r++) {
458
- for (let c = 1; c <= this.#maxCols; c++) {
459
- const selected = r <= this.#selectedRows && c <= this.#selectedCols;
460
- html += `<button type="button" data-row="${r}" data-col="${c}" aria-label="${r} rows by ${c} columns" aria-pressed="${selected ? "true" : "false"}" class="ui-editor-insert-table-grid__cell${selected ? " ui-editor-insert-table-grid__cell--selected" : ""}"></button>`;
461
- }
462
- }
463
- html += "</div>";
464
- html += '<label class="ui-editor-insert-table-grid__header"><input type="checkbox" checked /> Header row</label>';
465
- html += '<button type="button" data-insert-table>Insert table</button>';
466
- html += "</div>";
467
- this.innerHTML = html;
468
- const checkbox = this.querySelector('input[type="checkbox"]');
469
- if (checkbox) {
470
- checkbox.checked = this.#withHeaderRow;
471
- checkbox.addEventListener("change", () => {
472
- this.#withHeaderRow = checkbox.checked;
473
- });
474
- }
475
- this.updateSelectionPreview();
476
- }
477
- }
478
- if (typeof window !== "undefined" && !customElements.get(TAG3)) {
479
- customElements.define(TAG3, UIEditorInsertTableGridElement);
480
- }
481
- }
482
-
483
- // src/mention-menu.ts
484
- import { getVisualViewportRect as getVisualViewportRect2 } from "@threadlabs/looma/core";
485
- var TAG4 = "ui-editor-mention-menu";
486
- var MOBILE_BREAKPOINT = 768;
487
- var MENU_HEIGHT_ESTIMATE = 320;
488
- var MENU_WIDTH = 320;
489
- var OFFSET = 8;
490
- function finiteCoordinate(value) {
491
- return typeof value === "number" && Number.isFinite(value) ? value : null;
492
- }
493
- function normalizeAnchorRect(value) {
494
- if (!value || typeof value !== "object") return null;
495
- const rect = value;
496
- const x = finiteCoordinate(rect.x);
497
- const y = finiteCoordinate(rect.y);
498
- const width = finiteCoordinate(rect.width);
499
- const height = finiteCoordinate(rect.height);
500
- const left = finiteCoordinate(rect.left) ?? x;
501
- const top = finiteCoordinate(rect.top) ?? y;
502
- const right = finiteCoordinate(rect.right) ?? (left !== null && width !== null ? left + width : null);
503
- const bottom = finiteCoordinate(rect.bottom) ?? (top !== null && height !== null ? top + height : null);
504
- return left === null || top === null || right === null || bottom === null ? null : { left, top, right, bottom };
505
- }
506
- function escapeHtml(value) {
507
- return value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&#39;");
508
- }
509
- function dispatchMenuEvent(element, name, detail) {
510
- element.dispatchEvent(new CustomEvent(name, { detail, bubbles: true, composed: true }));
511
- }
512
- if (typeof HTMLElement !== "undefined") {
513
- class UIEditorMentionMenuElement extends HTMLElement {
514
- #open = false;
515
- #query = "";
516
- #items = [];
517
- #selectedIndex = 0;
518
- #loading = false;
519
- #anchorRect = null;
520
- #normalizedAnchorRect = null;
521
- get open() {
522
- return this.#open;
523
- }
524
- set open(value) {
525
- this.#open = Boolean(value);
526
- this.render();
527
- }
528
- get query() {
529
- return this.#query;
530
- }
531
- set query(value) {
532
- this.#query = typeof value === "string" ? value : "";
533
- this.render();
534
- }
535
- get items() {
536
- return this.#items;
537
- }
538
- set items(value) {
539
- this.#items = Array.isArray(value) ? value.slice(0, MAX_MENTION_RESULT_LIMIT) : [];
540
- if (this.#selectedIndex >= this.#items.length) this.#selectedIndex = 0;
541
- this.render();
542
- }
543
- get selectedIndex() {
544
- return this.#selectedIndex;
545
- }
546
- set selectedIndex(value) {
547
- this.#selectedIndex = Number.isFinite(value) ? Math.max(0, value) : 0;
548
- this.render();
549
- }
550
- get loading() {
551
- return this.#loading;
552
- }
553
- set loading(value) {
554
- this.#loading = Boolean(value);
555
- this.render();
556
- }
557
- get anchorRect() {
558
- return this.#anchorRect;
559
- }
560
- set anchorRect(value) {
561
- const normalized = normalizeAnchorRect(value);
562
- this.#anchorRect = normalized ? value : null;
563
- this.#normalizedAnchorRect = normalized;
564
- this.render();
565
- }
566
- connectedCallback() {
567
- this.setAttribute("role", "listbox");
568
- this.setAttribute("aria-label", "Mention a person");
569
- this.addEventListener("mousedown", this.onMouseDown);
570
- this.addEventListener("click", this.onClick);
571
- this.addEventListener("mouseover", this.onMouseOver);
572
- window.addEventListener("resize", this.onViewportChange);
573
- window.addEventListener("scroll", this.onViewportChange, true);
574
- window.visualViewport?.addEventListener("resize", this.onViewportChange);
575
- window.visualViewport?.addEventListener("scroll", this.onViewportChange);
576
- this.render();
577
- }
578
- disconnectedCallback() {
579
- this.removeEventListener("mousedown", this.onMouseDown);
580
- this.removeEventListener("click", this.onClick);
581
- this.removeEventListener("mouseover", this.onMouseOver);
582
- window.removeEventListener("resize", this.onViewportChange);
583
- window.removeEventListener("scroll", this.onViewportChange, true);
584
- window.visualViewport?.removeEventListener("resize", this.onViewportChange);
585
- window.visualViewport?.removeEventListener("scroll", this.onViewportChange);
586
- }
587
- onMouseDown = (event) => event.preventDefault();
588
- onClick = (event) => {
589
- const target = event.target.closest("[data-index]");
590
- const index = Number.parseInt(target?.dataset.index ?? "", 10);
591
- if (Number.isFinite(index)) {
592
- dispatchMenuEvent(
593
- this,
594
- "looma-editor-mention-menu-select",
595
- { index }
596
- );
597
- }
598
- };
599
- onMouseOver = (event) => {
600
- const target = event.target.closest("[data-index]");
601
- const index = Number.parseInt(target?.dataset.index ?? "", 10);
602
- if (!Number.isFinite(index) || index === this.#selectedIndex) return;
603
- this.#selectedIndex = index;
604
- dispatchMenuEvent(
605
- this,
606
- "looma-editor-mention-menu-highlight",
607
- { index }
608
- );
609
- this.render();
610
- };
611
- onViewportChange = () => {
612
- if (this.#open) this.applyHostPosition();
613
- };
614
- applyHostPosition() {
615
- const rect = this.#normalizedAnchorRect;
616
- if (!rect) {
617
- this.style.display = "none";
618
- return;
619
- }
620
- const viewport = getVisualViewportRect2(window);
621
- this.style.display = "block";
622
- this.style.position = "fixed";
623
- this.style.zIndex = "500";
624
- if (window.innerWidth < MOBILE_BREAKPOINT) {
625
- const toolbarReserve = 56;
626
- const height = Math.min(MENU_HEIGHT_ESTIMATE, Math.max(0, viewport.height - toolbarReserve));
627
- this.style.left = `${viewport.left}px`;
628
- this.style.top = `${viewport.top + viewport.height - height - toolbarReserve}px`;
629
- this.style.right = "";
630
- this.style.bottom = "";
631
- this.style.width = `${viewport.width}px`;
632
- this.style.maxHeight = `${height}px`;
633
- return;
634
- }
635
- const spaceBelow = viewport.bottom - rect.bottom - OFFSET;
636
- const spaceAbove = rect.top - viewport.top - OFFSET;
637
- const top = spaceBelow >= MENU_HEIGHT_ESTIMATE || spaceBelow >= spaceAbove ? rect.bottom + OFFSET : rect.top - OFFSET - MENU_HEIGHT_ESTIMATE;
638
- const left = Math.max(
639
- viewport.left + 8,
640
- Math.min(rect.left, viewport.right - MENU_WIDTH - 8)
641
- );
642
- this.style.top = `${Math.max(viewport.top + 8, top)}px`;
643
- this.style.left = `${left}px`;
644
- this.style.right = "";
645
- this.style.bottom = "";
646
- this.style.width = `${MENU_WIDTH}px`;
647
- this.style.maxHeight = "";
648
- }
649
- render() {
650
- const visible = this.#open && (this.#loading || this.#items.length > 0) && this.#normalizedAnchorRect;
651
- this.hidden = !visible;
652
- if (!visible) return;
653
- this.applyHostPosition();
654
- const optionIdPrefix = this.id || TAG4;
655
- const selectedId = `${optionIdPrefix}-option-${this.#selectedIndex}`;
656
- this.setAttribute("aria-busy", this.#loading ? "true" : "false");
657
- if (this.#items.length > 0) this.setAttribute("aria-activedescendant", selectedId);
658
- else this.removeAttribute("aria-activedescendant");
659
- const items = this.#items.map((item, index) => {
660
- const selected = index === this.#selectedIndex;
661
- return [
662
- `<li id="${optionIdPrefix}-option-${index}" class="ui-editor-mention-menu__item${selected ? " ui-editor-mention-menu__item--active" : ""}"`,
663
- ` role="option" aria-selected="${selected}" data-index="${index}">`,
664
- `<span class="ui-editor-mention-menu__avatar" aria-hidden="true">${escapeHtml(item.initials ?? item.label.slice(0, 2).toUpperCase())}</span>`,
665
- `<span class="ui-editor-mention-menu__body">`,
666
- `<span class="ui-editor-mention-menu__label">${escapeHtml(item.label)}</span>`,
667
- item.detail ? `<span class="ui-editor-mention-menu__detail">${escapeHtml(item.detail)}</span>` : "",
668
- `</span></li>`
669
- ].join("");
670
- }).join("");
671
- this.innerHTML = [
672
- `<div class="ui-editor-mention-menu">`,
673
- `<div class="ui-editor-mention-menu__header">`,
674
- `<span>People</span><span class="ui-editor-mention-menu__hint">Type after @ to search</span>`,
675
- `</div>`,
676
- this.#loading && this.#items.length === 0 ? `<div class="ui-editor-mention-menu__loading" role="status">Searching\u2026</div>` : `<ul class="ui-editor-mention-menu__list" role="presentation">${items}</ul>`,
677
- `</div>`
678
- ].join("");
679
- }
680
- }
681
- if (typeof window !== "undefined" && !customElements.get(TAG4)) {
682
- customElements.define(TAG4, UIEditorMentionMenuElement);
683
- }
684
- }
685
-
686
- // src/table-overlay.ts
687
- import {
688
- createProximityCoordinator,
689
- loomaIconMarkup as loomaIconMarkup3
690
- } from "@threadlabs/looma/core";
691
- var TAG5 = "ui-editor-table-overlay";
692
- var DEFAULT_ROWS = 3;
693
- var DEFAULT_COLS = 3;
694
- function sameNumbers(left, right) {
695
- return left.length === right.length && left.every((value, index) => value === right[index]);
696
- }
697
- function sameActiveCell(left, right) {
698
- if (left === right) return true;
699
- if (!left || !right) return false;
700
- return left.left === right.left && left.top === right.top && left.width === right.width && left.height === right.height && left.rowIndex === right.rowIndex && left.columnIndex === right.columnIndex;
701
- }
702
- function sameGeometry(left, right) {
703
- if (left === right) return true;
704
- if (!left || !right) return false;
705
- return sameNumbers(left.rowBoundaries, right.rowBoundaries) && sameNumbers(left.columnBoundaries, right.columnBoundaries) && sameActiveCell(left.activeCell, right.activeCell) && sameActiveCell(left.hoveredCell ?? null, right.hoveredCell ?? null);
706
- }
707
- function mapTableCells(table) {
708
- const rows = Array.from(table.rows);
709
- const grid = [];
710
- const coordinates = /* @__PURE__ */ new Map();
711
- rows.forEach((row, rowIndex) => {
712
- grid[rowIndex] ??= [];
713
- let columnIndex = 0;
714
- for (const cell of Array.from(row.cells)) {
715
- while (grid[rowIndex]?.[columnIndex]) columnIndex += 1;
716
- coordinates.set(cell, { rowIndex, columnIndex });
717
- const rowSpan = cell.rowSpan === 0 ? rows.length - rowIndex : Math.max(1, cell.rowSpan);
718
- const columnSpan = Math.max(1, cell.colSpan);
719
- for (let rowOffset = 0; rowOffset < rowSpan; rowOffset += 1) {
720
- const gridRow = grid[rowIndex + rowOffset] ??= [];
721
- for (let columnOffset = 0; columnOffset < columnSpan; columnOffset += 1) {
722
- gridRow[columnIndex + columnOffset] = cell;
723
- }
724
- }
725
- columnIndex += columnSpan;
726
- }
727
- });
728
- return { grid, coordinates };
729
- }
730
- function resolveTableCellAt(table, rowIndex, columnIndex) {
731
- return mapTableCells(table).grid[rowIndex]?.[columnIndex] ?? null;
732
- }
733
- function uniqueSorted(values) {
734
- return values.sort((left, right) => left - right).filter((value, index, all) => index === 0 || Math.abs(value - (all[index - 1] ?? value)) >= 0.5).map((value) => Math.round(value * 100) / 100);
735
- }
736
- function measureTableOverlayGeometry(table, activeCell, hoveredCell = null) {
737
- const tableRect = table.getBoundingClientRect();
738
- const rows = Array.from(table.rows);
739
- const cells = rows.flatMap((row) => Array.from(row.cells));
740
- const { coordinates } = mapTableCells(table);
741
- const rowBoundaries = uniqueSorted(rows.flatMap((row) => {
742
- const rect = row.getBoundingClientRect();
743
- return [rect.top - tableRect.top, rect.bottom - tableRect.top];
744
- }));
745
- const columnBoundaries = uniqueSorted(cells.flatMap((cell) => {
746
- const rect = cell.getBoundingClientRect();
747
- return [rect.left - tableRect.left, rect.right - tableRect.left];
748
- }));
749
- if (!activeCell || !table.contains(activeCell)) {
750
- return {
751
- rowBoundaries,
752
- columnBoundaries,
753
- activeCell: null,
754
- hoveredCell: measureCellRect(table, hoveredCell, coordinates)
755
- };
756
- }
757
- return {
758
- rowBoundaries,
759
- columnBoundaries,
760
- activeCell: measureCellRect(table, activeCell, coordinates),
761
- hoveredCell: measureCellRect(table, hoveredCell, coordinates)
762
- };
763
- }
764
- function measureCellRect(table, cell, coordinates) {
765
- if (!cell || !table.contains(cell)) return null;
766
- const tableRect = table.getBoundingClientRect();
767
- const cellRect = cell.getBoundingClientRect();
768
- const coordinate = coordinates.get(cell);
769
- return {
770
- left: Math.round((cellRect.left - tableRect.left) * 100) / 100,
771
- top: Math.round((cellRect.top - tableRect.top) * 100) / 100,
772
- width: Math.round(cellRect.width * 100) / 100,
773
- height: Math.round(cellRect.height * 100) / 100,
774
- rowIndex: coordinate?.rowIndex ?? 0,
775
- columnIndex: coordinate?.columnIndex ?? 0
776
- };
777
- }
778
- function finiteNumbers(value) {
779
- if (!value) return [];
780
- const values = value.split(",").map((part) => Number(part.trim()));
781
- return values.every(Number.isFinite) ? values : [];
782
- }
783
- function fallbackBoundaries(segments, length) {
784
- return Array.from({ length: segments + 1 }, (_, index) => index * length / segments);
785
- }
786
- if (typeof HTMLElement !== "undefined") {
787
- class UIEditorTableOverlayElement extends HTMLElement {
788
- static get observedAttributes() {
789
- return ["open", "rows", "cols", "row-boundaries", "column-boundaries", "active-cell", "hovered-cell"];
790
- }
791
- #rows = DEFAULT_ROWS;
792
- #cols = DEFAULT_COLS;
793
- #activeControlKey = null;
794
- #proximity = null;
795
- #geometry = null;
796
- #renderPending = false;
797
- get geometry() {
798
- return this.#geometry;
799
- }
800
- set geometry(value) {
801
- if (sameGeometry(this.#geometry, value)) return;
802
- this.#geometry = value;
803
- this.#scheduleRender();
804
- }
805
- connectedCallback() {
806
- this.#rows = this.#readBoundedNumber("rows", DEFAULT_ROWS);
807
- this.#cols = this.#readBoundedNumber("cols", DEFAULT_COLS);
808
- this.render();
809
- this.addEventListener("click", this.onClick);
810
- this.addEventListener("pointerover", this.onPointerOver);
811
- this.addEventListener("pointerout", this.onPointerOut);
812
- this.addEventListener("focusin", this.onFocusIn);
813
- this.addEventListener("focusout", this.onFocusOut);
814
- this.#proximity = createProximityCoordinator(this, {
815
- pointerTarget: this.ownerDocument,
816
- anchorSelector: ".ui-editor-table-overlay__handle[data-ui-affordance]"
817
- });
818
- }
819
- disconnectedCallback() {
820
- this.removeEventListener("click", this.onClick);
821
- this.removeEventListener("pointerover", this.onPointerOver);
822
- this.removeEventListener("pointerout", this.onPointerOut);
823
- this.removeEventListener("focusin", this.onFocusIn);
824
- this.removeEventListener("focusout", this.onFocusOut);
825
- this.#proximity?.destroy();
826
- this.#proximity = null;
827
- }
828
- attributeChangedCallback(name) {
829
- if (name === "rows") this.#rows = this.#readBoundedNumber("rows", DEFAULT_ROWS);
830
- if (name === "cols") this.#cols = this.#readBoundedNumber("cols", DEFAULT_COLS);
831
- this.#scheduleRender();
832
- }
833
- #scheduleRender() {
834
- if (!this.isConnected || this.#renderPending) return;
835
- this.#renderPending = true;
836
- queueMicrotask(() => {
837
- this.#renderPending = false;
838
- if (this.isConnected) this.render();
839
- });
840
- }
841
- #readBoundedNumber(name, fallback) {
842
- const parsed = Number.parseInt(this.getAttribute(name) ?? String(fallback), 10);
843
- return Number.isFinite(parsed) ? Math.min(100, Math.max(1, parsed)) : fallback;
844
- }
845
- #boundaries(name, segments) {
846
- if (this.#geometry) {
847
- return name === "row-boundaries" ? this.#geometry.rowBoundaries : this.#geometry.columnBoundaries;
848
- }
849
- const explicit = finiteNumbers(this.getAttribute(name));
850
- if (explicit.length === segments + 1) return explicit;
851
- const length = name === "row-boundaries" ? this.getBoundingClientRect().height : this.getBoundingClientRect().width;
852
- return fallbackBoundaries(segments, length);
853
- }
854
- #activeCell() {
855
- if (this.#geometry) return this.#geometry.activeCell;
856
- const values = finiteNumbers(this.getAttribute("active-cell"));
857
- if (values.length !== 6) return null;
858
- const [left, top, width, height, rowIndex, columnIndex] = values;
859
- if (left === void 0 || top === void 0 || width === void 0 || height === void 0 || rowIndex === void 0 || columnIndex === void 0) return null;
860
- return { left, top, width, height, rowIndex, columnIndex };
861
- }
862
- #hoveredCell() {
863
- if (this.#geometry) return this.#geometry.hoveredCell ?? null;
864
- const values = finiteNumbers(this.getAttribute("hovered-cell"));
865
- if (values.length !== 6) return null;
866
- const [left, top, width, height, rowIndex, columnIndex] = values;
867
- if (left === void 0 || top === void 0 || width === void 0 || height === void 0 || rowIndex === void 0 || columnIndex === void 0) return null;
868
- return { left, top, width, height, rowIndex, columnIndex };
869
- }
870
- dispatch(detail) {
871
- this.dispatchEvent(new CustomEvent(
872
- "looma-editor-table-overlay-action",
873
- { detail, bubbles: true, composed: true }
874
- ));
875
- }
876
- onClick = (event) => {
877
- const target = event.target.closest("button[data-action]");
878
- if (!target) return;
879
- const action = target.dataset.action;
880
- if (!action) return;
881
- if (action === "select-row" || action === "select-column") {
882
- const rowIndex = Number.parseInt(target.dataset.rowIndex ?? "", 10);
883
- const columnIndex = Number.parseInt(target.dataset.columnIndex ?? "", 10);
884
- if (Number.isFinite(rowIndex) && Number.isFinite(columnIndex)) {
885
- this.dispatch({ action, rowIndex, columnIndex });
886
- }
887
- return;
888
- }
889
- if (action === "open-cell-menu") {
890
- const rowIndex = Number.parseInt(target.dataset.rowIndex ?? "", 10);
891
- const columnIndex = Number.parseInt(target.dataset.columnIndex ?? "", 10);
892
- if (!Number.isFinite(rowIndex) || !Number.isFinite(columnIndex)) return;
893
- const rect = target.getBoundingClientRect();
894
- this.dispatch({
895
- action,
896
- rowIndex,
897
- columnIndex,
898
- anchor: { left: rect.left, top: rect.top, right: rect.right, bottom: rect.bottom }
899
- });
900
- return;
901
- }
902
- const boundaryIndex = Number.parseInt(target.dataset.boundaryIndex ?? "", 10);
903
- if (!Number.isFinite(boundaryIndex) || boundaryIndex < 0) return;
904
- this.dispatch({ action, boundaryIndex });
905
- };
906
- onPointerOver = (event) => {
907
- const control = event.target.closest("[data-control-key]");
908
- this.#setActiveControl(control?.dataset.controlKey ?? null);
909
- };
910
- onPointerOut = (event) => {
911
- const related = event.relatedTarget;
912
- const next = related instanceof Element ? related.closest("[data-control-key]") : null;
913
- this.#setActiveControl(next?.dataset.controlKey ?? null);
914
- };
915
- onFocusIn = (event) => {
916
- const control = event.target.closest("[data-control-key]");
917
- this.#setActiveControl(control?.dataset.controlKey ?? null);
918
- };
919
- onFocusOut = (event) => {
920
- const related = event.relatedTarget;
921
- const next = related instanceof Element ? related.closest("[data-control-key]") : null;
922
- this.#setActiveControl(next?.dataset.controlKey ?? null);
923
- };
924
- #setActiveControl(controlKey) {
925
- if (this.#activeControlKey === controlKey) return;
926
- this.#activeControlKey = controlKey;
927
- this.#syncActiveControl();
928
- }
929
- #syncActiveControl() {
930
- this.querySelectorAll("[data-control-key]").forEach((control) => {
931
- control.dataset.active = this.#activeControlKey === control.dataset.controlKey ? "true" : "false";
932
- });
933
- }
934
- #insertionControl(axis, index, position) {
935
- const first = index === 0;
936
- const action = axis === "row" ? first ? "add-row-before" : "add-row-after" : first ? "add-column-before" : "add-column-after";
937
- const noun = axis === "row" ? "row" : "column";
938
- const relation = first ? axis === "row" ? "above" : "left" : axis === "row" ? "below" : "right";
939
- const label = `Insert ${noun} ${relation}`;
940
- const controlKey = `${axis}:${index}`;
941
- const positionStyle = axis === "row" ? `top:${position}px;` : `left:${position}px;`;
942
- return [
943
- `<div class="ui-editor-table-overlay__control ui-editor-table-overlay__control--${axis}"`,
944
- ` style="${positionStyle}" data-control-key="${controlKey}"`,
945
- ` data-active="${this.#activeControlKey === controlKey ? "true" : "false"}">`,
946
- '<span class="ui-editor-table-overlay__line" aria-hidden="true"></span>',
947
- '<span class="ui-editor-table-overlay__guide" data-ui-guide aria-hidden="true"></span>',
948
- `<button type="button" class="ui-editor-table-overlay__handle" data-ui-affordance="insert-${noun}"`,
949
- ` data-action="${action}" data-boundary-index="${index}" aria-label="${label}">`,
950
- loomaIconMarkup3("plus"),
951
- `<span class="ui-editor-table-overlay__tooltip" role="tooltip">${label}</span>`,
952
- "</button>",
953
- "</div>"
954
- ].join("");
955
- }
956
- #cellSelectors(cell) {
957
- const centerX = cell.left + cell.width / 2;
958
- const centerY = cell.top + cell.height / 2;
959
- const indexes = `data-row-index="${cell.rowIndex}" data-column-index="${cell.columnIndex}"`;
960
- return [
961
- `<button type="button" class="ui-editor-table-overlay__selector ui-editor-table-overlay__selector--row" style="top:${centerY}px" data-action="select-row" ${indexes} title="Select row" aria-label="Select row">${loomaIconMarkup3("grip-vertical")}</button>`,
962
- `<button type="button" class="ui-editor-table-overlay__selector ui-editor-table-overlay__selector--column" style="left:${centerX}px" data-action="select-column" ${indexes} title="Select column" aria-label="Select column">${loomaIconMarkup3("grip-horizontal")}</button>`
963
- ].join("");
964
- }
965
- #cellMenu(cell) {
966
- const indexes = `data-row-index="${cell.rowIndex}" data-column-index="${cell.columnIndex}"`;
967
- return `<button type="button" class="ui-editor-table-overlay__cell-menu" style="left:${cell.left + cell.width - 30}px;top:${cell.top + 6}px" data-action="open-cell-menu" ${indexes} title="Cell actions" aria-label="Cell actions">${loomaIconMarkup3("chevron-down")}</button>`;
968
- }
969
- render() {
970
- const open = this.hasAttribute("open") && this.getAttribute("open") !== "false";
971
- this.hidden = !open;
972
- if (!open) {
973
- this.#setActiveControl(null);
974
- return;
975
- }
976
- const rows = this.#boundaries("row-boundaries", this.#rows);
977
- const columns = this.#boundaries("column-boundaries", this.#cols);
978
- const activeCell = this.#activeCell();
979
- const hoveredCell = this.#hoveredCell();
980
- this.innerHTML = [
981
- '<div class="ui-editor-table-overlay" aria-label="Table controls">',
982
- '<div class="ui-editor-table-overlay__rows">',
983
- rows.map((position, index) => this.#insertionControl("row", index, position)).join(""),
984
- "</div>",
985
- '<div class="ui-editor-table-overlay__cols">',
986
- columns.map((position, index) => this.#insertionControl("col", index, position)).join(""),
987
- "</div>",
988
- hoveredCell ? this.#cellSelectors(hoveredCell) : "",
989
- activeCell ? this.#cellMenu(activeCell) : "",
990
- "</div>"
991
- ].join("");
992
- this.#syncActiveControl();
993
- this.#proximity?.refresh();
994
- }
995
- }
996
- if (typeof window !== "undefined" && !customElements.get(TAG5)) {
997
- customElements.define(TAG5, UIEditorTableOverlayElement);
998
- }
999
- }
1000
-
1001
- // src/slash-menu.ts
1002
- import {
1003
- getVisualViewportRect as getVisualViewportRect3,
1004
- loomaIconMarkup as loomaIconMarkup4
1005
- } from "@threadlabs/looma/core";
1006
- var TAG6 = "ui-editor-slash-menu";
1007
- var MOBILE_BREAKPOINT2 = 768;
1008
- var MENU_HEIGHT_ESTIMATE2 = 320;
1009
- var MENU_WIDTH2 = 280;
1010
- var OFFSET2 = 8;
1011
- function finiteCoordinate2(value) {
1012
- return typeof value === "number" && Number.isFinite(value) ? value : null;
1013
- }
1014
- function normalizeAnchorRect2(value) {
1015
- if (!value || typeof value !== "object") {
1016
- return null;
1017
- }
1018
- const rect = value;
1019
- const x = finiteCoordinate2(rect.x);
1020
- const y = finiteCoordinate2(rect.y);
1021
- const width = finiteCoordinate2(rect.width);
1022
- const height = finiteCoordinate2(rect.height);
1023
- const left = finiteCoordinate2(rect.left) ?? x;
1024
- const top = finiteCoordinate2(rect.top) ?? y;
1025
- const right = finiteCoordinate2(rect.right) ?? (left !== null && width !== null ? left + width : null);
1026
- const bottom = finiteCoordinate2(rect.bottom) ?? (top !== null && height !== null ? top + height : null);
1027
- if (left === null || top === null || right === null || bottom === null) {
1028
- return null;
1029
- }
1030
- return { left, top, right, bottom };
1031
- }
1032
- function dispatchSlashMenuEvent(element, name, detail) {
1033
- element.dispatchEvent(
1034
- new CustomEvent(name, {
1035
- detail,
1036
- bubbles: true,
1037
- composed: true
1038
- })
1039
- );
1040
- }
1041
- function escapeHtml2(value) {
1042
- return value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&#39;");
1043
- }
1044
- if (typeof HTMLElement !== "undefined") {
1045
- class UIEditorSlashMenuElement extends HTMLElement {
1046
- #open = false;
1047
- #query = "";
1048
- #items = [];
1049
- #selectedIndex = 0;
1050
- #anchorRect = null;
1051
- #normalizedAnchorRect = null;
1052
- get open() {
1053
- return this.#open;
1054
- }
1055
- set open(value) {
1056
- this.#open = Boolean(value);
1057
- this.render();
1058
- }
1059
- get query() {
1060
- return this.#query;
1061
- }
1062
- set query(value) {
1063
- this.#query = typeof value === "string" ? value : "";
1064
- this.render();
1065
- }
1066
- get items() {
1067
- return this.#items;
1068
- }
1069
- set items(value) {
1070
- this.#items = Array.isArray(value) ? value : [];
1071
- this.render();
1072
- }
1073
- get selectedIndex() {
1074
- return this.#selectedIndex;
1075
- }
1076
- set selectedIndex(value) {
1077
- this.#selectedIndex = Number.isFinite(value) ? Math.max(0, value) : 0;
1078
- this.updateSelectedItem(true);
1079
- }
1080
- get anchorRect() {
1081
- return this.#anchorRect;
1082
- }
1083
- set anchorRect(value) {
1084
- const normalized = normalizeAnchorRect2(value);
1085
- this.#anchorRect = normalized ? value : null;
1086
- this.#normalizedAnchorRect = normalized;
1087
- this.render();
1088
- }
1089
- connectedCallback() {
1090
- this.setAttribute("role", "listbox");
1091
- this.setAttribute("aria-label", "Insert block");
1092
- this.addEventListener("mousedown", this.onMouseDown);
1093
- this.addEventListener("click", this.onClick);
1094
- this.addEventListener("mouseover", this.onMouseOver);
1095
- window.addEventListener("resize", this.onViewportChange);
1096
- window.addEventListener("scroll", this.onViewportChange, true);
1097
- window.visualViewport?.addEventListener("resize", this.onViewportChange);
1098
- window.visualViewport?.addEventListener("scroll", this.onViewportChange);
1099
- this.render();
1100
- }
1101
- disconnectedCallback() {
1102
- this.removeEventListener("mousedown", this.onMouseDown);
1103
- this.removeEventListener("click", this.onClick);
1104
- this.removeEventListener("mouseover", this.onMouseOver);
1105
- window.removeEventListener("resize", this.onViewportChange);
1106
- window.removeEventListener("scroll", this.onViewportChange, true);
1107
- window.visualViewport?.removeEventListener("resize", this.onViewportChange);
1108
- window.visualViewport?.removeEventListener("scroll", this.onViewportChange);
1109
- }
1110
- onMouseDown = (event) => {
1111
- event.preventDefault();
1112
- };
1113
- onClick = (event) => {
1114
- const target = event.target.closest("[data-index]");
1115
- if (!target) {
1116
- return;
1117
- }
1118
- const index = Number.parseInt(target.dataset.index ?? "", 10);
1119
- if (!Number.isFinite(index)) {
1120
- return;
1121
- }
1122
- dispatchSlashMenuEvent(this, "looma-editor-slash-menu-select", {
1123
- index
1124
- });
1125
- };
1126
- onMouseOver = (event) => {
1127
- const target = event.target.closest("[data-index]");
1128
- if (!target) {
1129
- return;
1130
- }
1131
- const index = Number.parseInt(target.dataset.index ?? "", 10);
1132
- if (!Number.isFinite(index) || index === this.#selectedIndex) {
1133
- return;
1134
- }
1135
- this.#selectedIndex = index;
1136
- this.updateSelectedItem();
1137
- dispatchSlashMenuEvent(
1138
- this,
1139
- "looma-editor-slash-menu-highlight",
1140
- { index }
1141
- );
1142
- };
1143
- onViewportChange = () => {
1144
- if (this.#open) {
1145
- this.applyHostPosition();
1146
- }
1147
- };
1148
- applyHostPosition() {
1149
- const rect = this.#normalizedAnchorRect;
1150
- if (!rect) {
1151
- this.style.display = "none";
1152
- return;
1153
- }
1154
- const viewport = getVisualViewportRect3(window);
1155
- const viewportWidth = viewport.width;
1156
- const viewportHeight = viewport.height;
1157
- this.style.display = "block";
1158
- this.style.position = "fixed";
1159
- this.style.zIndex = "500";
1160
- if (window.innerWidth < MOBILE_BREAKPOINT2) {
1161
- const toolbarReserve = 56;
1162
- const menuHeight = Math.min(
1163
- MENU_HEIGHT_ESTIMATE2,
1164
- Math.max(0, viewportHeight - toolbarReserve)
1165
- );
1166
- this.style.left = `${viewport.left}px`;
1167
- this.style.right = "";
1168
- this.style.bottom = "";
1169
- this.style.top = `${viewport.top + viewportHeight - menuHeight - toolbarReserve}px`;
1170
- this.style.width = `${viewportWidth}px`;
1171
- this.style.maxHeight = `${menuHeight}px`;
1172
- return;
1173
- }
1174
- let top;
1175
- const spaceBelow = viewport.bottom - rect.bottom - OFFSET2;
1176
- const spaceAbove = rect.top - viewport.top - OFFSET2;
1177
- if (spaceBelow >= MENU_HEIGHT_ESTIMATE2 || spaceBelow >= spaceAbove) {
1178
- top = rect.bottom + OFFSET2;
1179
- } else {
1180
- top = rect.top - OFFSET2 - MENU_HEIGHT_ESTIMATE2;
1181
- }
1182
- let left = rect.left;
1183
- if (left + MENU_WIDTH2 > viewport.right - 8) {
1184
- left = viewport.right - MENU_WIDTH2 - 8;
1185
- }
1186
- if (left < viewport.left + 8) {
1187
- left = viewport.left + 8;
1188
- }
1189
- this.style.top = `${Math.max(viewport.top + 8, top)}px`;
1190
- this.style.left = `${left}px`;
1191
- this.style.right = "";
1192
- this.style.bottom = "";
1193
- this.style.width = `${MENU_WIDTH2}px`;
1194
- this.style.maxHeight = "";
1195
- }
1196
- updateSelectedItem(ensureVisible = false) {
1197
- let selectedOption = null;
1198
- for (const option of this.querySelectorAll("[data-index]")) {
1199
- const selected = Number.parseInt(option.dataset.index ?? "", 10) === this.#selectedIndex;
1200
- option.classList.toggle("ui-editor-slash-menu__item--active", selected);
1201
- option.setAttribute("aria-selected", selected ? "true" : "false");
1202
- if (selected) selectedOption = option;
1203
- }
1204
- if (ensureVisible) selectedOption?.scrollIntoView?.({ block: "nearest" });
1205
- }
1206
- render() {
1207
- const visible = this.#open && this.#items.length > 0 && this.#normalizedAnchorRect;
1208
- this.hidden = !visible;
1209
- if (!visible) {
1210
- return;
1211
- }
1212
- this.applyHostPosition();
1213
- const query = this.#query.trim();
1214
- const items = this.#items.map((item, index) => {
1215
- const activeClass = index === this.#selectedIndex ? " ui-editor-slash-menu__item--active" : "";
1216
- return [
1217
- `<li`,
1218
- ` class="ui-editor-slash-menu__item${activeClass}"`,
1219
- ` role="option"`,
1220
- ` aria-selected="${index === this.#selectedIndex ? "true" : "false"}"`,
1221
- ` data-index="${index}"`,
1222
- `>`,
1223
- `<span class="ui-editor-slash-menu__icon" aria-hidden="true">${loomaIconMarkup4(item.icon)}</span>`,
1224
- `<span class="ui-editor-slash-menu__body">`,
1225
- `<span class="ui-editor-slash-menu__title">${escapeHtml2(item.title)}</span>`,
1226
- `<span class="ui-editor-slash-menu__description">${escapeHtml2(item.description)}</span>`,
1227
- `</span>`,
1228
- `</li>`
1229
- ].join("");
1230
- }).join("");
1231
- this.innerHTML = [
1232
- `<div class="ui-editor-slash-menu">`,
1233
- `<div class="ui-editor-slash-menu__header" aria-hidden="true">`,
1234
- `<span class="ui-editor-slash-menu__header-label">Insert</span>`,
1235
- query ? `<span class="ui-editor-slash-menu__header-query">${escapeHtml2(query)}</span>` : "",
1236
- `</div>`,
1237
- `<ul class="ui-editor-slash-menu__list" role="presentation">${items}</ul>`,
1238
- `<div class="ui-editor-slash-menu__footer" aria-hidden="true">`,
1239
- `<kbd>\u2191\u2193</kbd> navigate &nbsp;\xB7&nbsp; <kbd>\u21B5</kbd> insert &nbsp;\xB7&nbsp; <kbd>Esc</kbd> close`,
1240
- `</div>`,
1241
- `</div>`
1242
- ].join("");
1243
- }
1244
- }
1245
- if (typeof window !== "undefined" && !customElements.get(TAG6)) {
1246
- customElements.define(TAG6, UIEditorSlashMenuElement);
1247
- }
1248
- }
1249
-
1250
- // src/toolbar.ts
1251
- var TAG7 = "ui-editor-toolbar";
1252
- if (typeof HTMLElement !== "undefined") {
1253
- class UIEditorToolbarElement extends HTMLElement {
1254
- connectedCallback() {
1255
- if (!this.hasAttribute("role")) {
1256
- this.setAttribute("role", "toolbar");
1257
- }
1258
- if (!this.hasAttribute("aria-label")) {
1259
- this.setAttribute("aria-label", "Editor toolbar");
1260
- }
1261
- }
1262
- }
1263
- if (typeof window !== "undefined" && !customElements.get(TAG7)) {
1264
- customElements.define(TAG7, UIEditorToolbarElement);
1265
- }
1266
- }
1267
-
1268
- export {
1269
- resolveTableCellAt,
1270
- measureTableOverlayGeometry
1271
- };