@esportsplus/ui 0.61.0 → 0.63.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (678) hide show
  1. package/.audit/audit.json +4 -132
  2. package/.audit/check-scss.mjs +2 -2
  3. package/.audit/rules-audit.md +3 -28
  4. package/README.md +18 -17
  5. package/RULES.md +30 -0
  6. package/build/components/accordion/index.d.ts +5 -1
  7. package/build/components/accordion/index.js +29 -27
  8. package/build/components/accordion/scss/index.scss +1 -1
  9. package/build/components/announcement/index.d.ts +720 -2164
  10. package/build/components/announcement/index.js +12 -9
  11. package/build/components/announcement/scss/index.scss +1 -1
  12. package/build/components/breadcrumb/index.d.ts +4 -1
  13. package/build/components/breadcrumb/index.js +54 -49
  14. package/build/components/breadcrumb/scss/index.scss +1 -1
  15. package/build/components/button/copy.d.ts +1 -10
  16. package/build/components/button/copy.js +14 -11
  17. package/build/components/button/faces.d.ts +2 -1
  18. package/build/components/button/faces.js +9 -10
  19. package/build/components/button/kbd.d.ts +2 -10
  20. package/build/components/button/kbd.js +17 -15
  21. package/build/components/button/morph/index.d.ts +1443 -2165
  22. package/build/components/button/morph/save.d.ts +1 -10
  23. package/build/components/button/morph/save.js +5 -5
  24. package/build/components/button/morph/template.d.ts +2 -1
  25. package/build/components/button/morph/template.js +49 -29
  26. package/build/components/button/scss/index.scss +1 -1
  27. package/build/components/button/sidebar.d.ts +1 -10
  28. package/build/components/button/sidebar.js +14 -12
  29. package/build/components/button/split.d.ts +6 -1
  30. package/build/components/button/split.js +16 -11
  31. package/build/components/capslock/index.d.ts +1 -10
  32. package/build/components/capslock/index.js +16 -13
  33. package/build/components/capslock/scss/index.scss +1 -1
  34. package/build/components/card/scss/index.scss +1 -1
  35. package/build/components/chat/minimap/index.d.ts +12 -1
  36. package/build/components/chat/minimap/index.js +98 -74
  37. package/build/components/checkbox/group.d.ts +2 -10
  38. package/build/components/checkbox/group.js +39 -29
  39. package/build/components/checkbox/options.d.ts +5005 -6440
  40. package/build/components/checkbox/options.js +72 -44
  41. package/build/components/checkbox/scss/index.scss +1 -1
  42. package/build/components/color-picker/index.d.ts +10 -1
  43. package/build/components/color-picker/index.js +99 -82
  44. package/build/components/color-picker/scss/index.scss +1 -1
  45. package/build/components/command/palette.d.ts +13 -5
  46. package/build/components/command/palette.js +141 -130
  47. package/build/components/command/scss/index.scss +1 -1
  48. package/build/components/command/search.d.ts +2 -20
  49. package/build/components/command/search.js +17 -16
  50. package/build/components/container/scss/index.scss +1 -1
  51. package/build/components/counter/index.d.ts +1 -10
  52. package/build/components/counter/index.js +34 -31
  53. package/build/components/counter/scss/index.scss +1 -1
  54. package/build/components/dock/index.d.ts +4 -1
  55. package/build/components/dock/index.js +154 -114
  56. package/build/components/dock/scss/index.scss +1 -1
  57. package/build/components/editor/code/editor.d.ts +1 -10
  58. package/build/components/editor/code/features.d.ts +3 -3
  59. package/build/components/editor/code/features.js +65 -52
  60. package/build/components/editor/code/field.d.ts +1 -1
  61. package/build/components/editor/code/find.d.ts +4 -4
  62. package/build/components/editor/code/find.js +39 -37
  63. package/build/components/editor/code/folding.d.ts +1 -1
  64. package/build/components/editor/code/goto.d.ts +2 -1
  65. package/build/components/editor/code/goto.js +7 -7
  66. package/build/components/editor/code/gutter.js +12 -12
  67. package/build/components/editor/code/html.d.ts +4 -0
  68. package/build/components/editor/code/html.js +8 -0
  69. package/build/components/editor/code/minimap.d.ts +4 -10
  70. package/build/components/editor/code/minimap.js +18 -13
  71. package/build/components/editor/code/rows.js +6 -12
  72. package/build/components/editor/code/search.d.ts +1 -2
  73. package/build/components/editor/code/search.js +1 -1
  74. package/build/components/editor/code/services/index.d.ts +1 -1
  75. package/build/components/editor/code/services/index.js +27 -23
  76. package/build/components/editor/code/services/model.d.ts +1 -5
  77. package/build/components/editor/code/services/model.js +1 -1
  78. package/build/components/editor/code/services/session.d.ts +3 -2
  79. package/build/components/editor/code/services/session.js +1 -4
  80. package/build/components/editor/code/syntax.d.ts +1 -1
  81. package/build/components/editor/code/view.d.ts +2 -1
  82. package/build/components/editor/code/view.js +50 -39
  83. package/build/components/editor/diffs/merge.d.ts +1 -10
  84. package/build/components/editor/diffs/merge.js +126 -102
  85. package/build/components/editor/diffs/render.d.ts +1 -2
  86. package/build/components/editor/diffs/render.js +2 -8
  87. package/build/components/editor/diffs/view.d.ts +1 -10
  88. package/build/components/editor/diffs/view.js +112 -105
  89. package/build/components/editor/markdown/editing.d.ts +1 -1
  90. package/build/components/editor/markdown/erase.js +1 -1
  91. package/build/components/editor/markdown/format.d.ts +23 -0
  92. package/build/components/editor/markdown/format.js +319 -0
  93. package/build/components/editor/markdown/html.d.ts +1 -1
  94. package/build/components/editor/markdown/inline.d.ts +1 -1
  95. package/build/components/editor/markdown/inline.js +6 -5
  96. package/build/components/editor/markdown/layout.d.ts +1 -3
  97. package/build/components/editor/markdown/layout.js +1 -1
  98. package/build/components/editor/markdown/model.d.ts +3 -9
  99. package/build/components/editor/markdown/model.js +1 -8
  100. package/build/components/editor/markdown/render.d.ts +2 -1
  101. package/build/components/editor/markdown/render.js +278 -247
  102. package/build/components/editor/markdown/template.d.ts +1 -10
  103. package/build/components/editor/markdown/toolbar.d.ts +32 -0
  104. package/build/components/editor/markdown/toolbar.js +556 -0
  105. package/build/components/editor/markdown/view.d.ts +12 -1
  106. package/build/components/editor/markdown/view.js +154 -60
  107. package/build/components/editor/tree/compact.d.ts +2 -1
  108. package/build/components/editor/tree/compact.js +12 -11
  109. package/build/components/editor/tree/drag.d.ts +3 -2
  110. package/build/components/editor/tree/drag.js +29 -26
  111. package/build/components/editor/tree/edit.d.ts +1 -1
  112. package/build/components/editor/tree/edit.js +10 -9
  113. package/build/components/editor/tree/find.d.ts +1 -1
  114. package/build/components/editor/tree/find.js +10 -6
  115. package/build/components/editor/tree/icons.d.ts +1 -1
  116. package/build/components/editor/tree/icons.js +1 -1
  117. package/build/components/editor/tree/lazy.d.ts +2 -1
  118. package/build/components/editor/tree/lazy.js +17 -16
  119. package/build/components/editor/tree/sticky.d.ts +3 -2
  120. package/build/components/editor/tree/sticky.js +7 -6
  121. package/build/components/editor/tree/template.d.ts +2 -1
  122. package/build/components/editor/tree/template.js +144 -157
  123. package/build/components/editor/viewer/model.js +1 -7
  124. package/build/components/editor/viewer/template.d.ts +1 -10
  125. package/build/components/editor/viewer/template.js +74 -65
  126. package/build/components/editor/workspace/navigate.d.ts +2 -1
  127. package/build/components/editor/workspace/navigate.js +2 -4
  128. package/build/components/editor/workspace/session.d.ts +2 -1
  129. package/build/components/editor/workspace/session.js +14 -9
  130. package/build/components/editor/workspace/shortcuts.js +39 -33
  131. package/build/components/editor/workspace/status.js +2 -2
  132. package/build/components/editor/workspace/statusbar.d.ts +2 -1
  133. package/build/components/editor/workspace/statusbar.js +49 -48
  134. package/build/components/editor/workspace/strip.js +6 -5
  135. package/build/components/editor/workspace/template.d.ts +2 -10
  136. package/build/components/editor/workspace/template.js +149 -144
  137. package/build/components/error/index.d.ts +1 -10
  138. package/build/components/error/index.js +64 -32
  139. package/build/components/error/scss/index.scss +1 -1
  140. package/build/components/filter/index.js +138 -74
  141. package/build/components/filter/scss/index.scss +1 -1
  142. package/build/components/form/action.d.ts +2 -2
  143. package/build/components/form/action.js +12 -9
  144. package/build/components/frame/scss/index.scss +1 -1
  145. package/build/components/group/index.d.ts +3 -1
  146. package/build/components/group/index.js +10 -7
  147. package/build/components/group/scss/index.scss +1 -1
  148. package/build/components/heatmap/index.d.ts +5 -2
  149. package/build/components/heatmap/index.js +72 -59
  150. package/build/components/heatmap/scss/index.scss +1 -1
  151. package/build/components/highlight/index.d.ts +1 -10
  152. package/build/components/highlight/index.js +21 -19
  153. package/build/components/highlight/scss/index.scss +1 -1
  154. package/build/components/icon/index.d.ts +1 -10
  155. package/build/components/icon/index.js +11 -10
  156. package/build/components/image/lazyload.d.ts +2 -1
  157. package/build/components/image/lazyload.js +29 -26
  158. package/build/components/image/scss/index.scss +1 -1
  159. package/build/components/index.d.ts +0 -4
  160. package/build/components/index.js +0 -4
  161. package/build/components/inline-edit/index.d.ts +5 -1
  162. package/build/components/inline-edit/index.js +34 -27
  163. package/build/components/inline-edit/rich.d.ts +10 -15
  164. package/build/components/inline-edit/rich.js +81 -1193
  165. package/build/components/inline-edit/scss/index.scss +1 -1
  166. package/build/components/inline-edit/status.d.ts +3 -2
  167. package/build/components/inline-edit/status.js +22 -18
  168. package/build/components/input/field.d.ts +2 -1
  169. package/build/components/input/field.js +12 -9
  170. package/build/components/input/scrub.d.ts +4 -1
  171. package/build/components/input/scrub.js +25 -20
  172. package/build/components/input/scss/index.scss +1 -1
  173. package/build/components/input/tag.d.ts +4 -2
  174. package/build/components/input/tag.js +58 -53
  175. package/build/components/link/scss/index.scss +1 -1
  176. package/build/components/loading/index.d.ts +2 -1
  177. package/build/components/loading/index.js +6 -3
  178. package/build/components/loading/scss/index.scss +1 -1
  179. package/build/components/marquee/index.d.ts +2 -1
  180. package/build/components/marquee/index.js +77 -72
  181. package/build/components/marquee/scss/index.scss +1 -1
  182. package/build/components/marquee/velocity.js +4 -3
  183. package/build/components/metric/flash.d.ts +2 -1
  184. package/build/components/metric/flash.js +25 -25
  185. package/build/components/metric/index.d.ts +13 -2
  186. package/build/components/metric/index.js +60 -56
  187. package/build/components/metric/scss/index.scss +1 -1
  188. package/build/components/nav/scss/index.scss +1 -1
  189. package/build/components/nav/spy.js +9 -6
  190. package/build/components/nav/toc.d.ts +1 -10
  191. package/build/components/nav/tree.d.ts +3 -1
  192. package/build/components/nav/tree.js +60 -58
  193. package/build/components/notification/index.d.ts +1 -10
  194. package/build/components/notification/index.js +26 -36
  195. package/build/components/notification/scss/index.scss +1 -1
  196. package/build/components/overlay/index.d.ts +4 -5
  197. package/build/components/overlay/index.js +399 -196
  198. package/build/components/overlay/popup.d.ts +5 -6
  199. package/build/components/overlay/popup.js +80 -39
  200. package/build/components/overlay/scss/index.scss +1 -1
  201. package/build/components/pagination/arrows.d.ts +2 -1
  202. package/build/components/pagination/arrows.js +48 -45
  203. package/build/components/pagination/cards.d.ts +5 -2
  204. package/build/components/pagination/cards.js +70 -45
  205. package/build/components/pagination/dots.d.ts +3 -1
  206. package/build/components/pagination/dots.js +29 -24
  207. package/build/components/pagination/index.d.ts +2 -1
  208. package/build/components/pagination/index.js +27 -28
  209. package/build/components/pagination/scss/index.scss +1 -1
  210. package/build/components/panels/dnd.js +30 -22
  211. package/build/components/panels/group.d.ts +3 -2
  212. package/build/components/panels/group.js +134 -131
  213. package/build/components/panels/index.d.ts +2 -10
  214. package/build/components/panels/index.js +84 -80
  215. package/build/components/panels/resize.js +39 -3
  216. package/build/components/panels/scss/index.scss +1 -1
  217. package/build/components/panels/subtree.d.ts +2 -1
  218. package/build/components/panels/subtree.js +8 -7
  219. package/build/components/preview/buttons.d.ts +2 -10
  220. package/build/components/preview/buttons.js +6 -6
  221. package/build/components/preview/code.d.ts +1 -10
  222. package/build/components/preview/code.js +6 -6
  223. package/build/components/preview/header.d.ts +2 -10
  224. package/build/components/preview/header.js +15 -12
  225. package/build/components/preview/index.d.ts +13 -8680
  226. package/build/components/preview/index.js +22 -22
  227. package/build/components/preview/scss/index.scss +1 -1
  228. package/build/components/preview/source.d.ts +1 -10
  229. package/build/components/preview/source.js +18 -15
  230. package/build/components/preview/stage.d.ts +2 -10
  231. package/build/components/preview/stage.js +19 -15
  232. package/build/components/progress/index.d.ts +2 -1
  233. package/build/components/progress/index.js +30 -26
  234. package/build/components/progress/scss/index.scss +1 -1
  235. package/build/components/progress/text.d.ts +2 -1
  236. package/build/components/progress/text.js +27 -25
  237. package/build/components/range/filter.d.ts +2 -1
  238. package/build/components/range/filter.js +126 -127
  239. package/build/components/range/index.d.ts +2 -1
  240. package/build/components/range/index.js +17 -22
  241. package/build/components/range/scss/index.scss +1 -1
  242. package/build/components/relative-time/index.d.ts +3 -1
  243. package/build/components/relative-time/index.js +56 -41
  244. package/build/components/relative-time/scss/index.scss +1 -1
  245. package/build/components/root/scss/index.scss +1 -1
  246. package/build/components/select/expand.d.ts +44 -0
  247. package/build/components/select/expand.js +215 -0
  248. package/build/components/select/index.d.ts +18 -9
  249. package/build/components/select/index.js +108 -81
  250. package/build/components/select/scss/index.scss +1 -1
  251. package/build/components/shell/index.d.ts +2 -1
  252. package/build/components/shell/index.js +127 -109
  253. package/build/components/shell/scss/index.scss +1 -1
  254. package/build/components/shortcut-recorder/index.js +46 -43
  255. package/build/components/shortcut-recorder/scss/index.scss +1 -1
  256. package/build/components/sortable/index.d.ts +2 -714
  257. package/build/components/sortable/index.js +75 -64
  258. package/build/components/sortable/scss/index.scss +1 -1
  259. package/build/components/story/index.d.ts +4 -10
  260. package/build/components/story/index.js +121 -63
  261. package/build/components/story/scss/index.scss +1 -1
  262. package/build/components/surface-field/engine.js +51 -53
  263. package/build/components/surface-field/index.d.ts +2180 -2921
  264. package/build/components/surface-field/index.js +42 -38
  265. package/build/components/surface-field/scss/index.scss +1 -1
  266. package/build/components/surface-field/surface.d.ts +1 -10
  267. package/build/components/surface-field/surface.js +42 -36
  268. package/build/components/tasklist/index.d.ts +8 -1
  269. package/build/components/tasklist/index.js +63 -46
  270. package/build/components/tasklist/scss/index.scss +1 -1
  271. package/build/components/textarea/index.d.ts +722 -2170
  272. package/build/components/textarea/index.js +67 -91
  273. package/build/components/textarea/scss/index.scss +1 -1
  274. package/build/components/theme/cards.d.ts +4 -0
  275. package/build/components/theme/cards.js +21 -0
  276. package/build/components/theme/index.d.ts +12 -3
  277. package/build/components/theme/index.js +38 -14
  278. package/build/components/theme/reveal.d.ts +6 -0
  279. package/build/components/theme/reveal.js +100 -0
  280. package/build/components/theme/scss/index.scss +1 -1
  281. package/build/components/{theme-picker → theme}/shared.d.ts +4 -4
  282. package/build/components/{theme-picker → theme}/shared.js +5 -3
  283. package/build/components/theme/swatches.d.ts +4 -0
  284. package/build/components/theme/swatches.js +21 -0
  285. package/build/components/theme/toggle.d.ts +15 -0
  286. package/build/components/theme/toggle.js +33 -0
  287. package/build/components/toast/index.d.ts +6 -2
  288. package/build/components/toast/index.js +62 -50
  289. package/build/components/toast/scss/index.scss +1 -1
  290. package/build/components/tooltip/menu.d.ts +10 -2
  291. package/build/components/tooltip/menu.js +194 -179
  292. package/build/components/tooltip/onclick.d.ts +1 -10
  293. package/build/components/tooltip/onclick.js +25 -27
  294. package/build/components/tooltip/onhover.d.ts +8 -709
  295. package/build/components/tooltip/onhover.js +60 -60
  296. package/build/components/tooltip/scss/index.scss +1 -1
  297. package/build/components/tooltip/shared.d.ts +5 -3
  298. package/build/components/tooltip/shared.js +201 -91
  299. package/build/components/tooltip/utilities.d.ts +10 -4
  300. package/build/components/tooltip/utilities.js +95 -18
  301. package/build/components/typewriter/index.d.ts +2855 -1413
  302. package/build/components/typewriter/index.js +17 -18
  303. package/build/components/typewriter/retype.d.ts +2 -1
  304. package/build/components/typewriter/retype.js +21 -18
  305. package/build/components/typewriter/rotate.d.ts +2 -1
  306. package/build/components/typewriter/rotate.js +34 -29
  307. package/build/components/typewriter/scss/index.scss +1 -1
  308. package/build/components/uptime/index.d.ts +2 -1
  309. package/build/components/uptime/index.js +51 -47
  310. package/build/components/uptime/scss/index.scss +1 -1
  311. package/build/components/usage-meter/index.d.ts +719 -2161
  312. package/build/components/usage-meter/index.js +23 -20
  313. package/build/components/usage-meter/scss/index.scss +1 -1
  314. package/build/modifiers/border/scss/index.scss +1 -1
  315. package/build/modifiers/box-shadow/scss/index.scss +1 -1
  316. package/build/modifiers/color/scss/index.scss +1 -1
  317. package/build/modifiers/disabled/scss/index.scss +2 -0
  318. package/build/modifiers/glass/index.d.ts +3 -2
  319. package/build/modifiers/glass/index.js +7 -7
  320. package/build/modifiers/glass/scss/index.scss +1 -1
  321. package/build/modifiers/scrollbar/index.d.ts +13 -13
  322. package/build/modifiers/scrollbar/index.js +74 -90
  323. package/build/modifiers/scrollbar/scss/index.scss +1 -1
  324. package/build/shared/animation.d.ts +1 -1
  325. package/build/shared/animation.js +5 -3
  326. package/build/shared/dispatch.d.ts +7 -0
  327. package/build/shared/dispatch.js +25 -0
  328. package/build/shared/drag.d.ts +2 -4
  329. package/build/shared/press.d.ts +1 -1
  330. package/build/shared/press.js +5 -3
  331. package/build/shared/resize.js +2 -25
  332. package/build/shared/transition.d.ts +1 -1
  333. package/build/shared/transition.js +2 -2
  334. package/build/shared/visible.js +1 -24
  335. package/package.json +13 -14
  336. package/src/components/accordion/index.ts +2 -4
  337. package/src/components/accordion/scss/index.scss +17 -14
  338. package/src/components/accordion/scss/variables.scss +6 -7
  339. package/src/components/announcement/scss/index.scss +8 -13
  340. package/src/components/announcement/scss/variables.scss +12 -8
  341. package/src/components/breadcrumb/index.ts +4 -4
  342. package/src/components/breadcrumb/scss/index.scss +12 -12
  343. package/src/components/breadcrumb/scss/variables.scss +5 -12
  344. package/src/components/button/copy.ts +1 -1
  345. package/src/components/button/kbd.ts +8 -7
  346. package/src/components/button/morph/save.ts +2 -2
  347. package/src/components/button/morph/template.ts +18 -20
  348. package/src/components/button/scss/index.scss +84 -59
  349. package/src/components/button/scss/variables.scss +44 -29
  350. package/src/components/button/sidebar.ts +2 -2
  351. package/src/components/button/split.ts +7 -8
  352. package/src/components/capslock/index.ts +4 -4
  353. package/src/components/capslock/scss/index.scss +4 -2
  354. package/src/components/capslock/scss/variables.scss +14 -15
  355. package/src/components/card/scss/index.scss +10 -19
  356. package/src/components/card/scss/variables.scss +6 -2
  357. package/src/components/chat/minimap/index.ts +14 -13
  358. package/src/components/chat/minimap/scss/index.scss +19 -28
  359. package/src/components/chat/minimap/scss/variables.scss +33 -29
  360. package/src/components/checkbox/group.ts +5 -5
  361. package/src/components/checkbox/options.ts +2 -2
  362. package/src/components/checkbox/scss/index.scss +10 -6
  363. package/src/components/checkbox/scss/variables.scss +59 -44
  364. package/src/components/clipboard/write.ts +2 -1
  365. package/src/components/color-picker/index.ts +9 -11
  366. package/src/components/color-picker/scss/index.scss +2 -2
  367. package/src/components/color-picker/scss/variables.scss +26 -41
  368. package/src/components/command/palette.ts +15 -29
  369. package/src/components/command/scss/index.scss +8 -13
  370. package/src/components/command/scss/variables.scss +8 -8
  371. package/src/components/command/search.ts +3 -8
  372. package/src/components/container/scss/index.scss +2 -4
  373. package/src/components/container/scss/variables.scss +0 -2
  374. package/src/components/counter/index.ts +2 -1
  375. package/src/components/counter/scss/index.scss +2 -1
  376. package/src/components/counter/scss/variables.scss +3 -9
  377. package/src/components/dock/index.ts +17 -8
  378. package/src/components/dock/scss/index.scss +26 -56
  379. package/src/components/dock/scss/variables.scss +11 -20
  380. package/src/components/editor/code/features.ts +4 -5
  381. package/src/components/editor/code/field.ts +1 -1
  382. package/src/components/editor/code/find.ts +1 -1
  383. package/src/components/editor/code/folding.ts +1 -1
  384. package/src/components/editor/code/html.ts +17 -0
  385. package/src/components/editor/code/minimap.ts +7 -5
  386. package/src/components/editor/code/rows.ts +1 -14
  387. package/src/components/editor/code/scss/_editor.scss +10 -23
  388. package/src/components/editor/code/scss/_features.scss +17 -26
  389. package/src/components/editor/code/scss/_minimap.scss +29 -0
  390. package/src/components/editor/code/scss/_services.scss +4 -7
  391. package/src/components/editor/code/scss/index.scss +0 -1
  392. package/src/components/editor/code/scss/variables.scss +22 -14
  393. package/src/components/editor/code/search.ts +1 -1
  394. package/src/components/editor/code/services/completion.ts +1 -0
  395. package/src/components/editor/code/services/hover.ts +1 -0
  396. package/src/components/editor/code/services/index.ts +1 -1
  397. package/src/components/editor/code/services/model.ts +1 -1
  398. package/src/components/editor/code/services/session.ts +1 -4
  399. package/src/components/editor/code/syntax.ts +1 -1
  400. package/src/components/editor/diffs/merge.ts +3 -3
  401. package/src/components/editor/diffs/render.ts +2 -17
  402. package/src/components/editor/diffs/scss/_diffs.scss +22 -57
  403. package/src/components/editor/diffs/scss/_merge.scss +8 -29
  404. package/src/components/editor/diffs/scss/variables.scss +1 -10
  405. package/src/components/editor/diffs/view.ts +4 -5
  406. package/src/components/editor/markdown/editing.ts +1 -1
  407. package/src/components/editor/markdown/erase.ts +3 -3
  408. package/src/components/editor/markdown/format.ts +517 -0
  409. package/src/components/editor/markdown/html.ts +1 -1
  410. package/src/components/editor/markdown/inline.ts +9 -6
  411. package/src/components/editor/markdown/layout.ts +1 -1
  412. package/src/components/editor/markdown/model.ts +2 -17
  413. package/src/components/editor/markdown/render.ts +3 -2
  414. package/src/components/editor/markdown/scss/index.scss +132 -57
  415. package/src/components/editor/markdown/scss/variables.scss +124 -4
  416. package/src/components/editor/markdown/toolbar.ts +628 -0
  417. package/src/components/editor/markdown/view.ts +121 -10
  418. package/src/components/editor/tree/drag.ts +16 -15
  419. package/src/components/editor/tree/icons.ts +1 -1
  420. package/src/components/editor/tree/scss/index.scss +69 -44
  421. package/src/components/editor/tree/scss/variables.scss +75 -44
  422. package/src/components/editor/tree/sticky.ts +1 -1
  423. package/src/components/editor/tree/template.ts +2 -2
  424. package/src/components/editor/viewer/model.ts +1 -14
  425. package/src/components/editor/viewer/scss/_viewer.scss +22 -72
  426. package/src/components/editor/viewer/scss/index.scss +1 -1
  427. package/src/components/editor/viewer/scss/variables.scss +1 -3
  428. package/src/components/editor/viewer/template.ts +4 -2
  429. package/src/components/editor/workspace/navigate.ts +3 -6
  430. package/src/components/editor/workspace/scss/_keybindings.scss +9 -7
  431. package/src/components/editor/workspace/scss/_status.scss +14 -38
  432. package/src/components/editor/workspace/scss/_tabs.scss +6 -3
  433. package/src/components/editor/workspace/scss/index.scss +38 -33
  434. package/src/components/editor/workspace/scss/variables.scss +57 -53
  435. package/src/components/editor/workspace/session.ts +20 -13
  436. package/src/components/editor/workspace/status.ts +2 -2
  437. package/src/components/editor/workspace/template.ts +12 -21
  438. package/src/components/error/index.ts +36 -18
  439. package/src/components/error/scss/index.scss +3 -1
  440. package/src/components/error/scss/variables.scss +1 -0
  441. package/src/components/filter/index.ts +146 -99
  442. package/src/components/filter/scss/variables.scss +1 -1
  443. package/src/components/form/action.ts +1 -1
  444. package/src/components/frame/scss/index.scss +10 -6
  445. package/src/components/frame/scss/variables.scss +11 -6
  446. package/src/components/grid/scss/index.scss +1 -1
  447. package/src/components/grid/scss/variables.scss +1 -1
  448. package/src/components/heatmap/index.ts +2 -2
  449. package/src/components/heatmap/scss/index.scss +22 -17
  450. package/src/components/heatmap/scss/variables.scss +16 -34
  451. package/src/components/highlight/index.ts +0 -1
  452. package/src/components/highlight/scss/index.scss +13 -21
  453. package/src/components/highlight/scss/variables.scss +12 -14
  454. package/src/components/icon/index.ts +0 -4
  455. package/src/components/icon/scss/index.scss +2 -0
  456. package/src/components/image/lazyload.ts +1 -1
  457. package/src/components/image/scss/index.scss +14 -13
  458. package/src/components/image/scss/variables.scss +16 -12
  459. package/src/components/index.ts +0 -4
  460. package/src/components/inline-edit/index.ts +6 -5
  461. package/src/components/inline-edit/rich.ts +85 -1400
  462. package/src/components/inline-edit/scss/index.scss +24 -191
  463. package/src/components/inline-edit/scss/variables.scss +24 -191
  464. package/src/components/inline-edit/status.ts +6 -3
  465. package/src/components/input/field.ts +2 -2
  466. package/src/components/input/scrub.ts +1 -5
  467. package/src/components/input/scss/_scrub.scss +7 -0
  468. package/src/components/input/scss/_tag.scss +4 -2
  469. package/src/components/input/scss/index.scss +1 -2
  470. package/src/components/input/scss/variables.scss +14 -21
  471. package/src/components/input/tag.ts +6 -7
  472. package/src/components/json/download.ts +2 -1
  473. package/src/components/link/scss/index.scss +0 -1
  474. package/src/components/loading/index.ts +1 -1
  475. package/src/components/loading/scss/index.scss +4 -4
  476. package/src/components/loading/scss/variables.scss +4 -4
  477. package/src/components/marquee/index.ts +5 -5
  478. package/src/components/marquee/scss/index.scss +6 -4
  479. package/src/components/marquee/scss/variables.scss +3 -4
  480. package/src/components/marquee/velocity.ts +7 -3
  481. package/src/components/metric/flash.ts +1 -1
  482. package/src/components/metric/index.ts +5 -13
  483. package/src/components/metric/scss/_flash.scss +9 -4
  484. package/src/components/metric/scss/index.scss +11 -9
  485. package/src/components/metric/scss/variables.scss +73 -73
  486. package/src/components/nav/scss/index.scss +2 -1
  487. package/src/components/nav/scss/variables.scss +9 -11
  488. package/src/components/nav/spy.ts +15 -8
  489. package/src/components/nav/tree.ts +28 -30
  490. package/src/components/notification/index.ts +37 -16
  491. package/src/components/notification/scss/index.scss +32 -17
  492. package/src/components/notification/scss/variables.scss +12 -12
  493. package/src/components/overlay/index.ts +212 -142
  494. package/src/components/overlay/popup.ts +89 -52
  495. package/src/components/overlay/scss/index.scss +68 -85
  496. package/src/components/overlay/scss/variables.scss +15 -12
  497. package/src/components/pagination/cards.ts +1 -2
  498. package/src/components/pagination/index.ts +3 -9
  499. package/src/components/pagination/scss/index.scss +12 -12
  500. package/src/components/pagination/scss/variables.scss +39 -21
  501. package/src/components/panels/dnd.ts +35 -29
  502. package/src/components/panels/group.ts +5 -13
  503. package/src/components/panels/index.ts +4 -6
  504. package/src/components/panels/resize.ts +30 -4
  505. package/src/components/panels/scss/index.scss +13 -28
  506. package/src/components/panels/scss/variables.scss +3 -3
  507. package/src/components/preview/code.ts +1 -1
  508. package/src/components/preview/index.ts +12 -7
  509. package/src/components/preview/scss/index.scss +30 -15
  510. package/src/components/preview/scss/variables.scss +56 -34
  511. package/src/components/progress/scss/index.scss +14 -11
  512. package/src/components/progress/scss/variables.scss +34 -31
  513. package/src/components/progress/text.ts +9 -8
  514. package/src/components/range/filter.ts +9 -11
  515. package/src/components/range/index.ts +2 -9
  516. package/src/components/range/scss/_filter.scss +4 -3
  517. package/src/components/range/scss/_slider.scss +2 -1
  518. package/src/components/range/scss/variables.scss +2 -16
  519. package/src/components/relative-time/index.ts +15 -16
  520. package/src/components/relative-time/scss/index.scss +8 -4
  521. package/src/components/relative-time/scss/variables.scss +7 -3
  522. package/src/components/root/scss/index.scss +3 -0
  523. package/src/components/root/scss/variables.scss +11 -11
  524. package/src/components/select/expand.ts +272 -0
  525. package/src/components/select/index.ts +142 -119
  526. package/src/components/select/scss/index.scss +79 -7
  527. package/src/components/select/scss/variables.scss +67 -3
  528. package/src/components/shell/index.ts +73 -50
  529. package/src/components/shell/scss/index.scss +34 -47
  530. package/src/components/shell/scss/variables.scss +16 -16
  531. package/src/components/shortcut-recorder/index.ts +14 -17
  532. package/src/components/shortcut-recorder/scss/index.scss +15 -10
  533. package/src/components/shortcut-recorder/scss/variables.scss +4 -7
  534. package/src/components/sortable/index.ts +25 -28
  535. package/src/components/sortable/scss/index.scss +28 -27
  536. package/src/components/sortable/scss/variables.scss +12 -7
  537. package/src/components/story/index.ts +110 -47
  538. package/src/components/story/scss/index.scss +13 -18
  539. package/src/components/story/scss/variables.scss +4 -16
  540. package/src/components/surface-field/engine.ts +71 -72
  541. package/src/components/surface-field/index.ts +17 -20
  542. package/src/components/surface-field/scss/index.scss +9 -11
  543. package/src/components/surface-field/scss/variables.scss +20 -23
  544. package/src/components/surface-field/surface.ts +4 -3
  545. package/src/components/tasklist/index.ts +1 -6
  546. package/src/components/tasklist/scss/index.scss +22 -26
  547. package/src/components/tasklist/scss/variables.scss +14 -20
  548. package/src/components/textarea/index.ts +49 -91
  549. package/src/components/textarea/scss/index.scss +20 -15
  550. package/src/components/textarea/scss/variables.scss +15 -0
  551. package/src/components/theme/cards.ts +19 -0
  552. package/src/components/theme/index.ts +58 -17
  553. package/src/components/theme/reveal.ts +190 -0
  554. package/src/components/theme/scss/index.scss +109 -0
  555. package/src/components/theme/scss/variables.scss +153 -3
  556. package/src/components/{theme-picker → theme}/shared.ts +9 -6
  557. package/src/components/theme/swatches.ts +15 -0
  558. package/src/components/theme/toggle.ts +47 -0
  559. package/src/components/toast/index.ts +2 -3
  560. package/src/components/toast/scss/index.scss +63 -0
  561. package/src/components/toast/scss/variables.scss +121 -16
  562. package/src/components/tooltip/menu.ts +141 -131
  563. package/src/components/tooltip/onclick.ts +16 -21
  564. package/src/components/tooltip/onhover.ts +5 -8
  565. package/src/components/tooltip/scss/index.scss +534 -56
  566. package/src/components/tooltip/scss/variables.scss +64 -13
  567. package/src/components/tooltip/shared.ts +129 -87
  568. package/src/components/tooltip/utilities.ts +75 -24
  569. package/src/components/typewriter/index.ts +7 -10
  570. package/src/components/typewriter/rotate.ts +11 -7
  571. package/src/components/typewriter/scss/index.scss +2 -0
  572. package/src/components/typewriter/scss/variables.scss +1 -1
  573. package/src/components/uptime/index.ts +12 -6
  574. package/src/components/uptime/scss/index.scss +86 -75
  575. package/src/components/uptime/scss/variables.scss +82 -51
  576. package/src/components/usage-meter/index.ts +1 -1
  577. package/src/components/usage-meter/scss/index.scss +0 -3
  578. package/src/components/usage-meter/scss/variables.scss +13 -14
  579. package/src/css-utilities/background.scss +9 -1
  580. package/src/css-utilities/border.scss +3 -0
  581. package/src/css-utilities/box-shadow.scss +3 -2
  582. package/src/css-utilities/color.scss +13 -3
  583. package/src/css-utilities/disabled.scss +12 -0
  584. package/src/css-utilities/font/geist/index.scss +2 -1
  585. package/src/css-utilities/font/montserrat/index.scss +1 -1
  586. package/src/css-utilities/group.scss +1 -2
  587. package/src/css-utilities/icon.scss +1 -0
  588. package/src/css-utilities/layer.scss +2 -1
  589. package/src/css-utilities/skeleton.scss +4 -1
  590. package/src/css-utilities/surface.scss +97 -108
  591. package/src/css-utilities/text.scss +13 -13
  592. package/src/modifiers/background/scss/variables.scss +2 -4
  593. package/src/modifiers/border/scss/variables.scss +6 -8
  594. package/src/modifiers/disabled/scss/index.scss +5 -0
  595. package/src/modifiers/glass/index.ts +2 -1
  596. package/src/modifiers/glass/scss/index.scss +8 -11
  597. package/src/modifiers/glass/scss/variables.scss +1 -0
  598. package/src/modifiers/scrollbar/index.ts +94 -113
  599. package/src/modifiers/scrollbar/scss/index.scss +20 -2
  600. package/src/modifiers/scrollbar/scss/variables.scss +2 -2
  601. package/src/normalize/scss/index.scss +1 -0
  602. package/src/shared/anchor.ts +1 -1
  603. package/src/shared/animation.ts +6 -4
  604. package/src/shared/dispatch.ts +42 -0
  605. package/src/shared/drag.ts +2 -1
  606. package/src/shared/press.ts +7 -5
  607. package/src/shared/resize.ts +4 -35
  608. package/src/shared/scss/list.scss +1 -2
  609. package/src/shared/transition.ts +2 -2
  610. package/src/shared/visible.ts +3 -35
  611. package/src/tokens/scss/color.scss +16 -20
  612. package/src/tokens/scss/focus.scss +5 -0
  613. package/src/tokens/scss/font-size.scss +1 -2
  614. package/src/tokens/scss/index.scss +1 -0
  615. package/src/tokens/scss/scale.scss +4 -8
  616. package/src/tokens/scss/size.scss +3 -3
  617. package/src/tokens/scss/spacer.scss +1 -1
  618. package/src/tokens/scss/state.scss +11 -30
  619. package/vite-env.d.ts +1 -1
  620. package/vite.config.ts +10 -8
  621. package/build/components/cc/index.d.ts +0 -30
  622. package/build/components/cc/index.js +0 -561
  623. package/build/components/cc/scss/index.scss +0 -2
  624. package/build/components/datalist/index.d.ts +0 -42
  625. package/build/components/datalist/index.js +0 -186
  626. package/build/components/datalist/scss/index.scss +0 -2
  627. package/build/components/inline-edit/format.d.ts +0 -29
  628. package/build/components/inline-edit/format.js +0 -112
  629. package/build/components/inline-edit/history.d.ts +0 -14
  630. package/build/components/inline-edit/history.js +0 -40
  631. package/build/components/inline-edit/markdown.d.ts +0 -7
  632. package/build/components/inline-edit/markdown.js +0 -314
  633. package/build/components/inline-edit/model.d.ts +0 -61
  634. package/build/components/inline-edit/model.js +0 -192
  635. package/build/components/inline-edit/selection.d.ts +0 -7
  636. package/build/components/inline-edit/selection.js +0 -114
  637. package/build/components/inline-edit/utilities.d.ts +0 -4
  638. package/build/components/inline-edit/utilities.js +0 -12
  639. package/build/components/sticky-header/index.d.ts +0 -2166
  640. package/build/components/sticky-header/index.js +0 -58
  641. package/build/components/sticky-header/scss/index.scss +0 -2
  642. package/build/components/theme-picker/cards.d.ts +0 -13
  643. package/build/components/theme-picker/cards.js +0 -17
  644. package/build/components/theme-picker/index.d.ts +0 -12
  645. package/build/components/theme-picker/index.js +0 -7
  646. package/build/components/theme-picker/scss/index.scss +0 -2
  647. package/build/components/theme-picker/swatches.d.ts +0 -13
  648. package/build/components/theme-picker/swatches.js +0 -17
  649. package/build/components/theme-picker/toggle.d.ts +0 -19
  650. package/build/components/theme-picker/toggle.js +0 -109
  651. package/src/components/cc/index.ts +0 -563
  652. package/src/components/cc/scss/index.scss +0 -386
  653. package/src/components/cc/scss/variables.scss +0 -254
  654. package/src/components/datalist/index.ts +0 -256
  655. package/src/components/datalist/scss/index.scss +0 -104
  656. package/src/components/datalist/scss/variables.scss +0 -43
  657. package/src/components/inline-edit/format.ts +0 -183
  658. package/src/components/inline-edit/history.ts +0 -71
  659. package/src/components/inline-edit/markdown.ts +0 -485
  660. package/src/components/inline-edit/model.ts +0 -366
  661. package/src/components/inline-edit/selection.ts +0 -188
  662. package/src/components/inline-edit/utilities.ts +0 -18
  663. package/src/components/sticky-header/index.ts +0 -78
  664. package/src/components/sticky-header/scss/index.scss +0 -141
  665. package/src/components/sticky-header/scss/variables.scss +0 -78
  666. package/src/components/theme-picker/cards.ts +0 -19
  667. package/src/components/theme-picker/index.ts +0 -12
  668. package/src/components/theme-picker/scss/index.scss +0 -174
  669. package/src/components/theme-picker/scss/variables.scss +0 -220
  670. package/src/components/theme-picker/swatches.ts +0 -15
  671. package/src/components/theme-picker/toggle.ts +0 -150
  672. package/src/components/tooltip/scss/_center.scss +0 -9
  673. package/src/components/tooltip/scss/_east.scss +0 -33
  674. package/src/components/tooltip/scss/_menu.scss +0 -325
  675. package/src/components/tooltip/scss/_north.scss +0 -33
  676. package/src/components/tooltip/scss/_shared.scss +0 -112
  677. package/src/components/tooltip/scss/_south.scss +0 -33
  678. package/src/components/tooltip/scss/_west.scss +0 -33
@@ -0,0 +1,628 @@
1
+ import { effect, flush, reactive, untrack } from '@esportsplus/reactivity';
2
+ import { html, type Renderable } from '@esportsplus/template';
3
+ import faces from '~/components/button/faces';
4
+ import clipboard from '~/components/clipboard/write';
5
+ import icon from '~/components/icon';
6
+ import input from '~/components/input';
7
+ import selectInput from '~/components/select';
8
+ import tooltip from '~/components/tooltip';
9
+ import { finished } from '~/shared/animation';
10
+ import { clamp } from '~/shared/clamp';
11
+ import { mac } from '~/shared/platform';
12
+ import { viewport } from '~/shared/viewport';
13
+ import { safeUrl } from './inline';
14
+ import type { BlockKind, Formats, Mark } from './format';
15
+ import boldSvg from '@esportsplus/ui/svg/bold.svg';
16
+ import checkSvg from '@esportsplus/ui/svg/check.svg';
17
+ import clearSvg from '@esportsplus/ui/svg/clear-format.svg';
18
+ import closeSvg from '@esportsplus/ui/svg/close.svg';
19
+ import codeSvg from '@esportsplus/ui/svg/code.svg';
20
+ import copySvg from '@esportsplus/ui/svg/copy.svg';
21
+ import highlightSvg from '@esportsplus/ui/svg/highlight.svg';
22
+ import italicSvg from '@esportsplus/ui/svg/italic.svg';
23
+ import linkSvg from '@esportsplus/ui/svg/link.svg';
24
+ import openSvg from '@esportsplus/ui/svg/external-link.svg';
25
+ import strikeSvg from '@esportsplus/ui/svg/strikethrough.svg';
26
+ import unlinkSvg from '@esportsplus/ui/svg/unlink.svg';
27
+ import '~/components/button/scss/index.scss';
28
+ import '~/components/select/scss/index.scss';
29
+
30
+
31
+ type Action = Mark | 'clear' | 'copy' | 'link';
32
+
33
+ // What the toolbar asks of the editor it formats.
34
+ type Host = {
35
+ block: (kind: BlockKind) => boolean;
36
+ clear: () => boolean;
37
+ // The selection's markdown.
38
+ copy: () => string;
39
+ // Back to the text, with its selection.
40
+ focus: () => void;
41
+ formats: () => Formats;
42
+ link: (href: string | null) => boolean;
43
+ mark: (mark: Mark) => boolean;
44
+ // The drawn selection, while the text holds focus and something is selected.
45
+ range: () => Range | null;
46
+ // Whether the text holds focus with something selected, drawn or about to be.
47
+ selected: () => boolean;
48
+ selection: () => { end: number; start: number };
49
+ };
50
+
51
+ type Hinted = HTMLElement & { [HINT]: Renderable<unknown> };
52
+
53
+ // The tools a toolbar may offer: its marks, the link, clearing and copying, and the kinds of block it can turn lines into.
54
+ type Tool = Action | 'bullet' | 'codeblock' | 'heading' | 'ordered' | 'quote' | 'task';
55
+
56
+
57
+ const ACTIONS: { action: Action, label: string, shortcut?: string }[] = [
58
+ { action: 'bold', label: 'Bold', shortcut: 'B' },
59
+ { action: 'italic', label: 'Italic', shortcut: 'I' },
60
+ { action: 'strike', label: 'Strikethrough', shortcut: 'Shift+X' },
61
+ { action: 'code', label: 'Code', shortcut: 'E' },
62
+ { action: 'highlight', label: 'Highlight', shortcut: 'Shift+H' },
63
+ { action: 'link', label: 'Link', shortcut: 'K' },
64
+ { action: 'clear', label: 'Clear formatting' },
65
+ { action: 'copy', label: 'Copy as markdown' }
66
+ ];
67
+
68
+ // Long enough to read the check, short enough to copy again right away.
69
+ const COPIED_FOR = 1400;
70
+
71
+ const EMAIL = /^[^\s/@]+@[^\s/@]+\.[^\s/@]+$/;
72
+
73
+ // Space between the selection and the toolbar, and between the toolbar and the viewport's edge.
74
+ const GAP = 8;
75
+
76
+ const HINT = Symbol();
77
+
78
+ const ICONS: Record<Exclude<Action, 'copy'> | 'apply' | 'open' | 'unlink', string> = {
79
+ apply: checkSvg,
80
+ bold: boldSvg,
81
+ clear: clearSvg,
82
+ code: codeSvg,
83
+ highlight: highlightSvg,
84
+ italic: italicSvg,
85
+ link: linkSvg,
86
+ open: openSvg,
87
+ strike: strikeSvg,
88
+ unlink: unlinkSvg
89
+ };
90
+
91
+ const KINDS: { label: string, tool?: Tool, value: BlockKind }[] = [
92
+ { label: 'Text', value: 'paragraph' },
93
+ { label: 'Heading 1', tool: 'heading', value: 'h1' },
94
+ { label: 'Heading 2', tool: 'heading', value: 'h2' },
95
+ { label: 'Heading 3', tool: 'heading', value: 'h3' },
96
+ { label: 'Quote', tool: 'quote', value: 'quote' },
97
+ { label: 'Code block', tool: 'codeblock', value: 'codeblock' },
98
+ { label: 'Bulleted list', tool: 'bullet', value: 'bullet' },
99
+ { label: 'Numbered list', tool: 'ordered', value: 'ordered' },
100
+ { label: 'Checklist', tool: 'task', value: 'task' }
101
+ ];
102
+
103
+ const MAC_SHORTCUT = /(⇧?)(\w)$/;
104
+
105
+ const RELATIVE_URL = /^[/#?]/;
106
+
107
+ // Long enough that labels only show once the pointer rests, so passing across the toolbar stays quiet.
108
+ const TOOLTIP_DELAY = 700;
109
+
110
+ const URL_SCHEME = /^[a-z][a-z\d+.-]*:/i;
111
+
112
+
113
+ // What was typed into the link field, as an address: a bare domain gets https, a bare email mailto.
114
+ function address(value: string) {
115
+ let href = value.trim();
116
+
117
+ if (href && !URL_SCHEME.test(href) && !RELATIVE_URL.test(href)) {
118
+ href = (EMAIL.test(href) ? 'mailto:' : 'https://') + href;
119
+ }
120
+
121
+ return (href && safeUrl(href)) || '';
122
+ }
123
+
124
+ function glyph(name: Exclude<Action, 'copy'> | 'apply' | 'open' | 'unlink') {
125
+ return icon({ 'aria-hidden': 'true', class: 'markdown-editor-toolbar-icon' }, ICONS[name]);
126
+ }
127
+
128
+ function hint(label: string, shortcut?: string) {
129
+ if (!shortcut) {
130
+ return label;
131
+ }
132
+
133
+ return mac()
134
+ ? `${label} ${shortcut.replace('Shift+', '⇧')}`.replace(MAC_SHORTCUT, '$1⌘$2')
135
+ : `${label} Ctrl+${shortcut}`;
136
+ }
137
+
138
+
139
+ // The formatting toolbar: it floats over the selection in the top layer, so nothing around the editor clips or covers
140
+ // it, and offers the tools it was given. Shown once a selection settles, never while a press is still dragging one out.
141
+ const toolbar = (host: Host) => {
142
+ let apple = mac(),
143
+ block = reactive({ active: false, error: '', selected: 'paragraph' }),
144
+ hyperlink = reactive({ existing: false, invalid: false, url: '' }),
145
+ // 'focus' is the control the arrow keys rove to, the toolbar's one tab stop.
146
+ local = reactive({ copied: 'idle' as 'error' | 'idle' | 'success', focus: 0, live: '' }),
147
+ // 'link' swaps the buttons for the link field, 'instant' holds the toolbar still, 'origin' and 'x'/'y' place it.
148
+ panel = reactive({ instant: false, link: false, open: false, origin: '', x: 0, y: 0 }),
149
+ pressed = reactive({ bold: false, code: false, highlight: false, italic: false, strike: false } as Record<Mark, boolean>),
150
+ tip = tooltip.shared({ delay: { open: TOOLTIP_DELAY } });
151
+
152
+ let bar: HTMLElement | undefined,
153
+ copyTimer: ReturnType<typeof setTimeout> | undefined,
154
+ // The selection a dismissal closed the toolbar on; it stays closed until the selection changes.
155
+ dismissed: { end: number; start: number } | null = null,
156
+ enabled = new Set<Tool>(),
157
+ hiding = 0,
158
+ items: HTMLElement[] = [],
159
+ layer: HTMLElement | undefined,
160
+ pressing = false,
161
+ shown: BlockKind = 'paragraph',
162
+ url: HTMLInputElement | undefined;
163
+
164
+ // The select only reports a value; one that differs from the block under the selection is a choice.
165
+ effect(() => {
166
+ let next = block.selected as BlockKind;
167
+
168
+ if (next !== shown) {
169
+ untrack(() => {
170
+ shown = next;
171
+ host.focus();
172
+ host.block(next);
173
+ });
174
+ }
175
+ });
176
+
177
+ function apply(value: string | null) {
178
+ let href = value === null ? null : address(value);
179
+
180
+ if (href === '') {
181
+ hyperlink.invalid = true;
182
+ return;
183
+ }
184
+
185
+ back();
186
+ host.link(href);
187
+ local.live = href ? 'Link set' : 'Link removed';
188
+ }
189
+
190
+ // Leaves the link field for the buttons, handing focus back to the text.
191
+ function back() {
192
+ panel.link = false;
193
+ host.focus();
194
+ }
195
+
196
+ async function copy() {
197
+ // Confirms on press; waiting for the write makes the click feel ignored.
198
+ clearTimeout(copyTimer);
199
+ local.copied = 'success';
200
+ local.live = 'Copied';
201
+ copyTimer = setTimeout(() => {
202
+ local.copied = 'idle';
203
+ }, COPIED_FOR);
204
+
205
+ if (!(await clipboard(host.copy()))) {
206
+ local.copied = 'error';
207
+ local.live = 'Couldn\'t copy';
208
+ }
209
+ }
210
+
211
+ function dismiss() {
212
+ dismissed = host.selection();
213
+ show(false);
214
+ }
215
+
216
+ function focus(index: number) {
217
+ local.focus = (index + items.length) % items.length;
218
+ items[local.focus]?.focus();
219
+ }
220
+
221
+ function inspect() {
222
+ let formats = host.formats();
223
+
224
+ for (let mark in pressed) {
225
+ pressed[mark as Mark] = formats.marks[mark as Mark];
226
+ }
227
+
228
+ shown = formats.block ?? 'paragraph';
229
+ block.selected = shown;
230
+ hyperlink.existing = formats.link !== null;
231
+ hyperlink.url = formats.link ?? '';
232
+ }
233
+
234
+ function linker() {
235
+ let formats = host.formats();
236
+
237
+ panel.link = true;
238
+ hyperlink.existing = formats.link !== null;
239
+ hyperlink.invalid = false;
240
+ hyperlink.url = formats.link ?? '';
241
+
242
+ // The field shows, and takes its value, once the link mode lands.
243
+ flush();
244
+ url?.focus({ preventScroll: true });
245
+ url?.select();
246
+ }
247
+
248
+ // Out of the top layer once the close has played out, unless it opened again meanwhile.
249
+ function lower() {
250
+ let current = ++hiding;
251
+
252
+ if (!layer) {
253
+ return;
254
+ }
255
+
256
+ void finished(layer, { subtree: true }).then(() => {
257
+ if (current === hiding && !panel.open && layer?.matches(':popover-open')) {
258
+ layer.hidePopover();
259
+ }
260
+ });
261
+ }
262
+
263
+ function navigate(e: KeyboardEvent) {
264
+ if (e.target === url) {
265
+ if (e.key === 'Enter') {
266
+ e.preventDefault();
267
+ apply(url.value);
268
+ }
269
+ else if (e.key === 'Escape') {
270
+ e.preventDefault();
271
+ back();
272
+ }
273
+
274
+ return;
275
+ }
276
+
277
+ if (e.key === 'ArrowLeft' || e.key === 'ArrowRight') {
278
+ e.preventDefault();
279
+ focus(local.focus + (e.key === 'ArrowRight' ? 1 : -1));
280
+ }
281
+ else if (e.key === 'Home' || e.key === 'End') {
282
+ e.preventDefault();
283
+ focus(e.key === 'Home' ? 0 : -1);
284
+ }
285
+ else if (e.key === 'Escape' && !block.active) {
286
+ e.preventDefault();
287
+ dismiss();
288
+ host.focus();
289
+ }
290
+ }
291
+
292
+ // Floats over the selection, flipping below it when there's no room above; only the viewport bounds it.
293
+ function place(range: Range) {
294
+ if (!bar) {
295
+ return;
296
+ }
297
+
298
+ let bounds = range.getBoundingClientRect(),
299
+ h = bar.offsetHeight,
300
+ lines = [...range.getClientRects()].filter((rect) => rect.width > 0),
301
+ w = bar.offsetWidth;
302
+
303
+ let first = lines[0] ?? bounds,
304
+ last = lines[lines.length - 1] ?? bounds,
305
+ below = first.top < h + GAP,
306
+ center = bounds.left + bounds.width / 2,
307
+ x = clamp(center - w / 2, GAP, Math.max(GAP, viewport().width - w - GAP));
308
+
309
+ // Scales out of the selection itself, even when held off the edge.
310
+ panel.origin = `${center - x}px ${below ? 0 : h}px`;
311
+ panel.x = x;
312
+ panel.y = below ? last.bottom + GAP : first.top - h - GAP;
313
+
314
+ // Shown afresh it jumps there, committed before its moves glide again; once open it glides along.
315
+ if (!panel.open) {
316
+ panel.instant = true;
317
+ flush();
318
+ void bar.offsetWidth;
319
+ panel.instant = false;
320
+ }
321
+ }
322
+
323
+ // Into the top layer before anything measures it, since it lays out only once it shows.
324
+ function raise() {
325
+ hiding++;
326
+
327
+ if (layer && !layer.matches(':popover-open')) {
328
+ layer.showPopover();
329
+ }
330
+ }
331
+
332
+ // Follows the selection: shown over one that settled, closed once it collapses or the text loses focus. Focus in
333
+ // the toolbar itself (its buttons, the select, the link field) holds it where it is.
334
+ function refresh() {
335
+ if (!bar || !enabled.size || bar.contains(bar.ownerDocument.activeElement)) {
336
+ return;
337
+ }
338
+
339
+ if (!host.selected()) {
340
+ dismissed = null;
341
+
342
+ if (panel.open) {
343
+ show(false);
344
+ }
345
+
346
+ return;
347
+ }
348
+
349
+ // A block drawn afresh takes the selection a frame later; the toolbar stays put until it has.
350
+ let range = host.range();
351
+
352
+ if (!range) {
353
+ return;
354
+ }
355
+
356
+ if (pressing) {
357
+ return;
358
+ }
359
+
360
+ let { end, start } = host.selection();
361
+
362
+ if (dismissed) {
363
+ if (dismissed.start === start && dismissed.end === end) {
364
+ return;
365
+ }
366
+
367
+ dismissed = null;
368
+ }
369
+
370
+ raise();
371
+ place(range);
372
+ inspect();
373
+
374
+ if (!panel.open) {
375
+ local.focus = 0;
376
+ show(true);
377
+ }
378
+ }
379
+
380
+ function show(next: boolean) {
381
+ panel.open = next;
382
+
383
+ if (!next) {
384
+ panel.link = false;
385
+ lower();
386
+ }
387
+ }
388
+
389
+ // Runs a tool's shortcut, when it is one of this toolbar's.
390
+ function shortcut(e: KeyboardEvent) {
391
+ if (!(apple ? e.metaKey : e.ctrlKey) || e.altKey) {
392
+ return false;
393
+ }
394
+
395
+ let chord = (e.shiftKey ? 'shift+' : '') + e.key.toLowerCase(),
396
+ found = ACTIONS.find(({ shortcut }) => shortcut?.toLowerCase() === chord);
397
+
398
+ if (!found || !enabled.has(found.action)) {
399
+ return false;
400
+ }
401
+
402
+ trigger(found.action);
403
+
404
+ return true;
405
+ }
406
+
407
+ function trigger(action: Action) {
408
+ switch (action) {
409
+ case 'clear':
410
+ if (host.clear()) {
411
+ local.live = 'Formatting cleared';
412
+ }
413
+
414
+ break;
415
+ case 'copy':
416
+ void copy();
417
+ return;
418
+ case 'link':
419
+ if (host.range()) {
420
+ linker();
421
+ }
422
+
423
+ return;
424
+ default:
425
+ host.mark(action);
426
+ }
427
+
428
+ inspect();
429
+ }
430
+
431
+ let template = (tools: readonly Tool[]) => {
432
+ enabled = new Set(tools);
433
+ items = [];
434
+
435
+ let actions = ACTIONS.filter(({ action }) => enabled.has(action)),
436
+ kinds = KINDS.filter(({ tool }) => !tool || enabled.has(tool)),
437
+ lead = kinds.length > 1 ? 1 : 0,
438
+ marks = actions.filter(({ action }) => action !== 'clear' && action !== 'copy'),
439
+ rest = actions.filter(({ action }) => action === 'clear' || action === 'copy');
440
+
441
+ if (!actions.length && kinds.length < 2) {
442
+ enabled.clear();
443
+ return '';
444
+ }
445
+
446
+ // 'index' is the button's place among the controls the arrow keys rove.
447
+ let button = ({ action, label, shortcut }: (typeof ACTIONS)[number], content: Renderable<unknown>, index: number) => html`
448
+ <button
449
+ aria-label='${label}'
450
+ class='button button--feedback markdown-editor-toolbar-button'
451
+ tabindex='${() => local.focus === index ? '0' : '-1'}'
452
+ type='button'
453
+ ${action === 'clear' || action === 'copy' || action === 'link' ? {} : { 'aria-pressed': () => pressed[action] ? 'true' : 'false' }}
454
+ ${{
455
+ onclick: () => trigger(action),
456
+ onconnect: (element: Hinted) => {
457
+ element[HINT] = action === 'copy' ? () => local.copied === 'success' ? 'Copied' : label : hint(label, shortcut);
458
+ items[index] = element;
459
+ }
460
+ }}
461
+ >
462
+ ${content}
463
+ </button>
464
+ `;
465
+
466
+ return html`
467
+ <div
468
+ class='tooltip tooltip--context markdown-editor-toolbar-layer'
469
+ popover='manual'
470
+ ${{
471
+ class: () => panel.open && '--active',
472
+ onconnect: (element: HTMLElement) => {
473
+ layer = element;
474
+ },
475
+ ondisconnect: () => {
476
+ clearTimeout(copyTimer);
477
+ layer = undefined;
478
+ },
479
+ onwindowpointercancel: () => {
480
+ pressing = false;
481
+ },
482
+ // The selection finalises after the release, so it is read a frame later.
483
+ onwindowpointerup: () => {
484
+ if (pressing) {
485
+ pressing = false;
486
+ requestAnimationFrame(refresh);
487
+ }
488
+ }
489
+ }}
490
+ >
491
+ <div
492
+ aria-label='Formatting'
493
+ class='tooltip-content tooltip-content--context markdown-editor-toolbar'
494
+ role='toolbar'
495
+ ${{
496
+ 'aria-hidden': () => panel.open ? 'false' : 'true',
497
+ class: [
498
+ () => panel.instant && 'markdown-editor-toolbar--instant',
499
+ () => panel.link && 'markdown-editor-toolbar--link'
500
+ ],
501
+ inert: () => !panel.open,
502
+ onconnect: (element: HTMLElement, on) => {
503
+ bar = element;
504
+ // Direct: delegation only runs the nearest bound handler, which for the select is its own.
505
+ on(element, 'keydown', navigate, { direct: true });
506
+ },
507
+ // Keeps the text selected and focused when a control is pressed; the link field takes focus.
508
+ onmousedown: (e: MouseEvent) => {
509
+ if ((e.target as Element).tagName !== 'INPUT') {
510
+ e.preventDefault();
511
+ }
512
+ },
513
+ style: () => `--toolbar-origin: ${panel.origin}; --toolbar-x: ${panel.x}px; --toolbar-y: ${panel.y}px;`
514
+ }}
515
+ >
516
+ <div
517
+ class='markdown-editor-toolbar-format'
518
+ ${tip.delegate({ content: (trigger) => (trigger as Hinted)[HINT], edge: true, selector: '.markdown-editor-toolbar-button' })}
519
+ >
520
+ ${kinds.length > 1 && html`
521
+ ${selectInput({
522
+ [selectInput.trigger]: {
523
+ onconnect: (element: HTMLElement) => {
524
+ items[0] = element;
525
+ },
526
+ tabindex: () => local.focus === 0 ? '0' : '-1'
527
+ },
528
+ class: 'markdown-editor-toolbar-block',
529
+ label: 'Text style',
530
+ options: kinds.map(({ label, value }) => ({ label, value })),
531
+ state: block
532
+ })}
533
+ ${actions.length > 0 && html`<span aria-hidden='true' class='markdown-editor-toolbar-divider'></span>`}
534
+ `}
535
+ ${marks.map((item, i) => button(item, glyph(item.action as Exclude<Action, 'copy'>), lead + i))}
536
+ ${marks.length > 0 && rest.length > 0 && html`<span aria-hidden='true' class='markdown-editor-toolbar-divider'></span>`}
537
+ ${rest.map((item, i) => button(
538
+ item,
539
+ item.action === 'copy'
540
+ ? faces(() => local.copied, [
541
+ { content: icon({ 'aria-hidden': 'true', class: 'button-icon' }, copySvg), key: 'idle' },
542
+ { content: icon({ 'aria-hidden': 'true', class: 'button-icon button-icon--draw' }, checkSvg), key: 'success', tone: 'success' },
543
+ { content: icon({ 'aria-hidden': 'true', class: 'button-icon button-icon--draw' }, closeSvg), key: 'error', tone: 'error' }
544
+ ])
545
+ : glyph(item.action as Exclude<Action, 'copy'>),
546
+ lead + marks.length + i
547
+ ))}
548
+ ${tip.render()}
549
+ </div>
550
+ ${enabled.has('link') && html`
551
+ <div class='markdown-editor-toolbar-link'>
552
+ ${input({
553
+ 'aria-invalid': () => hyperlink.invalid && 'true',
554
+ 'aria-label': 'Link address',
555
+ class: 'markdown-editor-toolbar-url',
556
+ onconnect: (element: HTMLInputElement) => {
557
+ url = element;
558
+ },
559
+ oninput: (e: Event) => {
560
+ hyperlink.invalid = false;
561
+ hyperlink.url = (e.currentTarget as HTMLInputElement).value;
562
+ },
563
+ placeholder: 'Paste or type a link',
564
+ type: 'url',
565
+ value: () => hyperlink.url
566
+ })}
567
+ <button
568
+ aria-label='Apply link'
569
+ class='button button--feedback markdown-editor-toolbar-button'
570
+ type='button'
571
+ ${{ onclick: () => apply(hyperlink.url) }}
572
+ >
573
+ ${glyph('apply')}
574
+ </button>
575
+ <button
576
+ aria-label='Open link in a new tab'
577
+ class='button button--feedback markdown-editor-toolbar-button'
578
+ type='button'
579
+ ${{
580
+ onclick: () => {
581
+ let href = address(hyperlink.url);
582
+
583
+ if (href) {
584
+ window.open(href, '_blank', 'noopener');
585
+ }
586
+ }
587
+ }}
588
+ >
589
+ ${glyph('open')}
590
+ </button>
591
+ <button
592
+ aria-label='Remove link'
593
+ class='button button--feedback markdown-editor-toolbar-button'
594
+ type='button'
595
+ ${{
596
+ hidden: () => !hyperlink.existing,
597
+ onclick: () => apply(null)
598
+ }}
599
+ >
600
+ ${glyph('unlink')}
601
+ </button>
602
+ </div>
603
+ `}
604
+ <span aria-live='polite' class='markdown-editor-toolbar-live'>${() => local.live}</span>
605
+ </div>
606
+ </div>
607
+ `;
608
+ };
609
+
610
+ return {
611
+ contains: (node: Node | null) => !!node && !!layer?.contains(node),
612
+ dismiss,
613
+ get open() {
614
+ return panel.open;
615
+ },
616
+ // A press in the text drags a selection out; the toolbar waits for its release.
617
+ press: () => {
618
+ pressing = true;
619
+ },
620
+ refresh,
621
+ shortcut,
622
+ template
623
+ };
624
+ };
625
+
626
+
627
+ export { toolbar };
628
+ export type { Host, Tool };