@celljs/ta-web 4.9.0 → 4.10.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 (376) hide show
  1. package/README.en.md +4 -3
  2. package/README.md +4 -3
  3. package/esm/browser/assistant/assistant-chat-list.js +8 -2
  4. package/esm/browser/assistant/assistant-extension.d.ts +8 -1
  5. package/esm/browser/assistant/assistant-extension.js +33 -5
  6. package/esm/browser/assistant/assistant-protocol.d.ts +3 -1
  7. package/esm/browser/assistant/assistant-task-source.d.ts +2 -0
  8. package/esm/browser/assistant/assistant-task-source.js +2 -0
  9. package/esm/browser/assistant/assistant-task-util.d.ts +8 -0
  10. package/esm/browser/assistant/assistant-task-util.js +13 -3
  11. package/esm/browser/assistant/assistant-tasks.js +3 -2
  12. package/esm/browser/assistant/assistant-view.js +81 -56
  13. package/esm/browser/assistant/assistant.d.ts +30 -1
  14. package/esm/browser/assistant/assistant.js +89 -6
  15. package/esm/browser/assistant/task-views.d.ts +40 -6
  16. package/esm/browser/assistant/task-views.js +73 -21
  17. package/esm/browser/avatar/dino-avatar.d.ts +3 -4
  18. package/esm/browser/avatar/dino-avatar.js +4 -178
  19. package/esm/browser/avatar/dino-face.d.ts +19 -0
  20. package/esm/browser/avatar/dino-face.js +142 -0
  21. package/esm/browser/avatar/dino-geometry.d.ts +11 -0
  22. package/esm/browser/avatar/dino-geometry.js +38 -0
  23. package/esm/browser/avatar/dino-kinds.d.ts +15 -0
  24. package/esm/browser/avatar/dino-kinds.js +544 -0
  25. package/esm/browser/avatar/dino-motion.js +1 -1
  26. package/esm/browser/avatar/dino-shape.d.ts +80 -0
  27. package/esm/browser/avatar/dino-shape.js +113 -0
  28. package/esm/browser/avatar/dino-species.d.ts +1 -61
  29. package/esm/browser/avatar/dino-species.js +2 -653
  30. package/esm/browser/chat/chat-packages.d.ts +39 -0
  31. package/esm/browser/chat/chat-packages.js +70 -0
  32. package/esm/browser/chat/chat-protocol.d.ts +23 -1
  33. package/esm/browser/chat/chat-stores.d.ts +59 -0
  34. package/esm/browser/chat/chat-stores.js +121 -0
  35. package/esm/browser/chat/chat-util.d.ts +17 -0
  36. package/esm/browser/chat/chat-util.js +61 -0
  37. package/esm/browser/chat/chat-view.js +33 -12
  38. package/esm/browser/chat/chat.d.ts +31 -39
  39. package/esm/browser/chat/chat.js +226 -175
  40. package/esm/browser/components/access-view.js +1 -1
  41. package/esm/browser/components/account-menu.js +1 -1
  42. package/esm/browser/components/app-nav.d.ts +6 -3
  43. package/esm/browser/components/app-nav.js +19 -10
  44. package/esm/browser/components/app-shell-hooks.d.ts +47 -0
  45. package/esm/browser/components/app-shell-hooks.js +169 -0
  46. package/esm/browser/components/app-view.js +81 -172
  47. package/esm/browser/components/auth-view.js +1 -1
  48. package/esm/browser/components/chat-list.d.ts +20 -2
  49. package/esm/browser/components/chat-list.js +138 -22
  50. package/esm/browser/components/composer-box.d.ts +5 -5
  51. package/esm/browser/components/composer-box.js +111 -4
  52. package/esm/browser/components/composer.d.ts +7 -0
  53. package/esm/browser/components/composer.js +22 -14
  54. package/esm/browser/components/connection-bar.js +50 -17
  55. package/esm/browser/components/context-menu.d.ts +30 -4
  56. package/esm/browser/components/context-menu.js +199 -37
  57. package/esm/browser/components/conversation-scroll.d.ts +129 -6
  58. package/esm/browser/components/conversation-scroll.js +429 -109
  59. package/esm/browser/components/dino.js +1 -1
  60. package/esm/browser/components/earlier-messages.d.ts +2 -1
  61. package/esm/browser/components/earlier-messages.js +2 -17
  62. package/esm/browser/components/editor-area.d.ts +3 -1
  63. package/esm/browser/components/editor-area.js +6 -5
  64. package/esm/browser/components/empty-pictures.d.ts +0 -2
  65. package/esm/browser/components/empty-pictures.js +0 -16
  66. package/esm/browser/components/folder-picker.d.ts +5 -2
  67. package/esm/browser/components/folder-picker.js +30 -9
  68. package/esm/browser/components/held-talk.d.ts +28 -0
  69. package/esm/browser/components/held-talk.js +76 -0
  70. package/esm/browser/components/host-view.d.ts +1 -1
  71. package/esm/browser/components/host-view.js +1 -1
  72. package/esm/browser/components/icon.d.ts +2 -2
  73. package/esm/browser/components/icon.js +5 -6
  74. package/esm/browser/components/image-viewer.d.ts +124 -0
  75. package/esm/browser/components/image-viewer.js +397 -0
  76. package/esm/browser/components/lightbox.d.ts +11 -0
  77. package/esm/browser/components/lightbox.js +24 -0
  78. package/esm/browser/components/markdown.d.ts +6 -2
  79. package/esm/browser/components/markdown.js +24 -10
  80. package/esm/browser/components/media.js +1 -10
  81. package/esm/browser/components/message-footer.d.ts +16 -2
  82. package/esm/browser/components/message-footer.js +29 -12
  83. package/esm/browser/components/message-list.d.ts +24 -3
  84. package/esm/browser/components/message-list.js +149 -20
  85. package/esm/browser/components/message-menu.d.ts +3 -1
  86. package/esm/browser/components/message-menu.js +18 -3
  87. package/esm/browser/components/nav-places.d.ts +16 -1
  88. package/esm/browser/components/nav-places.js +12 -3
  89. package/esm/browser/components/phone-shell.d.ts +4 -1
  90. package/esm/browser/components/phone-shell.js +3 -1
  91. package/esm/browser/components/run-status.js +3 -3
  92. package/esm/browser/components/select-bar.d.ts +9 -0
  93. package/esm/browser/components/select-bar.js +24 -0
  94. package/esm/browser/components/session-settings.d.ts +6 -0
  95. package/esm/browser/components/session-settings.js +14 -1
  96. package/esm/browser/components/session-view.js +8 -4
  97. package/esm/browser/components/settings-choices.d.ts +35 -0
  98. package/esm/browser/components/settings-choices.js +117 -0
  99. package/esm/browser/components/settings-parts.d.ts +21 -0
  100. package/esm/browser/components/settings-parts.js +323 -0
  101. package/esm/browser/components/settings-view.d.ts +0 -6
  102. package/esm/browser/components/settings-view.js +4 -406
  103. package/esm/browser/components/swipe-row.d.ts +2 -2
  104. package/esm/browser/components/swipe-row.js +7 -3
  105. package/esm/browser/components/tool-view.js +14 -12
  106. package/esm/browser/components/voice-button.d.ts +1 -1
  107. package/esm/browser/components/voice-button.js +1 -1
  108. package/esm/browser/components/voice-talk.d.ts +43 -0
  109. package/esm/browser/components/voice-talk.js +222 -0
  110. package/esm/browser/components/workbench-view.js +1 -1
  111. package/esm/browser/device/device.d.ts +3 -0
  112. package/esm/browser/device/device.js +11 -1
  113. package/esm/browser/device/hold.d.ts +42 -0
  114. package/esm/browser/device/hold.js +136 -0
  115. package/esm/browser/device/launch-screen.d.ts +1 -1
  116. package/esm/browser/device/launch-screen.js +1 -1
  117. package/esm/browser/device/long-press.d.ts +2 -0
  118. package/esm/browser/device/long-press.js +16 -1
  119. package/esm/browser/device/pull-down.d.ts +4 -2
  120. package/esm/browser/device/pull-down.js +64 -76
  121. package/esm/browser/device/row-swipe.d.ts +35 -10
  122. package/esm/browser/device/row-swipe.js +149 -71
  123. package/esm/browser/device/shake-undo.d.ts +16 -0
  124. package/esm/browser/device/shake-undo.js +59 -0
  125. package/esm/browser/device/sheet-swipe.d.ts +118 -18
  126. package/esm/browser/device/sheet-swipe.js +406 -107
  127. package/esm/browser/extension/icons.js +2 -1
  128. package/esm/browser/extension/web-extension-api.d.ts +135 -2
  129. package/esm/browser/extension/web-extension-code.d.ts +6 -0
  130. package/esm/browser/extension/web-extension-code.js +24 -0
  131. package/esm/browser/extension/web-extension-protocol.d.ts +23 -1
  132. package/esm/browser/extension/web-extension-protocol.js +8 -0
  133. package/esm/browser/extension/web-extensions.d.ts +14 -1
  134. package/esm/browser/extension/web-extensions.js +128 -24
  135. package/esm/browser/extension/web-tasks.d.ts +9 -1
  136. package/esm/browser/extension/web-tasks.js +24 -0
  137. package/esm/browser/files/files-protocol.d.ts +25 -0
  138. package/esm/browser/files/files-protocol.js +2 -0
  139. package/esm/browser/files/files.d.ts +35 -0
  140. package/esm/browser/files/files.js +119 -0
  141. package/esm/browser/hooks.d.ts +3 -1
  142. package/esm/browser/hooks.js +8 -0
  143. package/esm/browser/i18n/locales.d.ts +29 -2
  144. package/esm/browser/i18n/messages.d.ts +28 -1
  145. package/esm/browser/i18n/messages.js +58 -4
  146. package/esm/browser/index.d.ts +6 -0
  147. package/esm/browser/index.js +6 -0
  148. package/esm/browser/notices/notices-protocol.d.ts +9 -1
  149. package/esm/browser/notices/notices.d.ts +2 -0
  150. package/esm/browser/notices/notices.js +20 -10
  151. package/esm/browser/offline/device-values.d.ts +55 -0
  152. package/esm/browser/offline/device-values.js +142 -0
  153. package/esm/browser/offline/kept-chats-protocol.d.ts +17 -0
  154. package/esm/browser/offline/kept-chats-protocol.js +2 -0
  155. package/esm/browser/offline/kept-chats.d.ts +47 -0
  156. package/esm/browser/offline/kept-chats.js +146 -0
  157. package/esm/browser/offline/offline-reads.d.ts +44 -0
  158. package/esm/browser/offline/offline-reads.js +107 -0
  159. package/esm/browser/settings/settings-protocol.d.ts +2 -0
  160. package/esm/browser/settings/settings-protocol.js +2 -0
  161. package/esm/browser/style/conversation.d.ts +1 -1
  162. package/esm/browser/style/conversation.js +57 -17
  163. package/esm/browser/style/device.js +43 -4
  164. package/esm/browser/style/layout.d.ts +1 -1
  165. package/esm/browser/style/layout.js +67 -15
  166. package/esm/browser/style/pages.d.ts +1 -1
  167. package/esm/browser/style/pages.js +2 -1
  168. package/esm/browser/style/shell.d.ts +1 -1
  169. package/esm/browser/style/shell.js +47 -3
  170. package/esm/browser/style/tasks.d.ts +1 -1
  171. package/esm/browser/style/tasks.js +2 -0
  172. package/esm/browser/util/frame.d.ts +5 -4
  173. package/esm/browser/util/frame.js +5 -4
  174. package/esm/browser/util/markdown.d.ts +18 -1
  175. package/esm/browser/util/markdown.js +119 -5
  176. package/esm/browser/util/process.d.ts +21 -0
  177. package/esm/browser/util/process.js +45 -1
  178. package/esm/browser/util/voice.d.ts +5 -2
  179. package/esm/browser/util/voice.js +6 -3
  180. package/esm/browser/util/zoom.d.ts +46 -0
  181. package/esm/browser/util/zoom.js +96 -0
  182. package/esm/browser/workbench-calls.d.ts +59 -0
  183. package/esm/browser/workbench-calls.js +141 -0
  184. package/esm/browser/workbench-protocol.d.ts +5 -1
  185. package/esm/browser/workbench-util.d.ts +68 -0
  186. package/esm/browser/workbench-util.js +145 -0
  187. package/esm/browser/workbench.d.ts +15 -42
  188. package/esm/browser/workbench.js +53 -167
  189. package/lib/browser/assistant/assistant-chat-list.js +8 -2
  190. package/lib/browser/assistant/assistant-extension.d.ts +8 -1
  191. package/lib/browser/assistant/assistant-extension.js +33 -5
  192. package/lib/browser/assistant/assistant-protocol.d.ts +3 -1
  193. package/lib/browser/assistant/assistant-task-source.d.ts +2 -0
  194. package/lib/browser/assistant/assistant-task-source.js +2 -0
  195. package/lib/browser/assistant/assistant-task-util.d.ts +8 -0
  196. package/lib/browser/assistant/assistant-task-util.js +13 -3
  197. package/lib/browser/assistant/assistant-tasks.js +2 -1
  198. package/lib/browser/assistant/assistant-view.js +78 -53
  199. package/lib/browser/assistant/assistant.d.ts +30 -1
  200. package/lib/browser/assistant/assistant.js +89 -6
  201. package/lib/browser/assistant/task-views.d.ts +40 -6
  202. package/lib/browser/assistant/task-views.js +74 -21
  203. package/lib/browser/avatar/dino-avatar.d.ts +3 -4
  204. package/lib/browser/avatar/dino-avatar.js +27 -202
  205. package/lib/browser/avatar/dino-face.d.ts +20 -0
  206. package/lib/browser/avatar/dino-face.js +148 -0
  207. package/lib/browser/avatar/dino-geometry.d.ts +12 -0
  208. package/lib/browser/avatar/dino-geometry.js +47 -0
  209. package/lib/browser/avatar/dino-kinds.d.ts +16 -0
  210. package/lib/browser/avatar/dino-kinds.js +547 -0
  211. package/lib/browser/avatar/dino-motion.js +2 -2
  212. package/lib/browser/avatar/dino-shape.d.ts +81 -0
  213. package/lib/browser/avatar/dino-shape.js +126 -0
  214. package/lib/browser/avatar/dino-species.d.ts +1 -61
  215. package/lib/browser/avatar/dino-species.js +34 -687
  216. package/lib/browser/chat/chat-packages.d.ts +40 -0
  217. package/lib/browser/chat/chat-packages.js +74 -0
  218. package/lib/browser/chat/chat-protocol.d.ts +23 -1
  219. package/lib/browser/chat/chat-stores.d.ts +60 -0
  220. package/lib/browser/chat/chat-stores.js +125 -0
  221. package/lib/browser/chat/chat-util.d.ts +18 -0
  222. package/lib/browser/chat/chat-util.js +64 -0
  223. package/lib/browser/chat/chat-view.js +33 -12
  224. package/lib/browser/chat/chat.d.ts +31 -39
  225. package/lib/browser/chat/chat.js +227 -176
  226. package/lib/browser/components/access-view.js +2 -2
  227. package/lib/browser/components/account-menu.js +2 -2
  228. package/lib/browser/components/app-nav.d.ts +6 -3
  229. package/lib/browser/components/app-nav.js +17 -8
  230. package/lib/browser/components/app-shell-hooks.d.ts +48 -0
  231. package/lib/browser/components/app-shell-hooks.js +211 -0
  232. package/lib/browser/components/app-view.js +89 -180
  233. package/lib/browser/components/auth-view.js +3 -3
  234. package/lib/browser/components/chat-list.d.ts +20 -2
  235. package/lib/browser/components/chat-list.js +137 -21
  236. package/lib/browser/components/composer-box.d.ts +5 -5
  237. package/lib/browser/components/composer-box.js +111 -4
  238. package/lib/browser/components/composer.d.ts +7 -0
  239. package/lib/browser/components/composer.js +22 -14
  240. package/lib/browser/components/connection-bar.js +48 -15
  241. package/lib/browser/components/context-menu.d.ts +30 -4
  242. package/lib/browser/components/context-menu.js +198 -36
  243. package/lib/browser/components/conversation-scroll.d.ts +129 -6
  244. package/lib/browser/components/conversation-scroll.js +431 -110
  245. package/lib/browser/components/dino.js +3 -3
  246. package/lib/browser/components/earlier-messages.d.ts +2 -1
  247. package/lib/browser/components/earlier-messages.js +2 -17
  248. package/lib/browser/components/editor-area.d.ts +3 -1
  249. package/lib/browser/components/editor-area.js +5 -4
  250. package/lib/browser/components/empty-pictures.d.ts +0 -2
  251. package/lib/browser/components/empty-pictures.js +0 -17
  252. package/lib/browser/components/folder-picker.d.ts +5 -2
  253. package/lib/browser/components/folder-picker.js +30 -9
  254. package/lib/browser/components/held-talk.d.ts +29 -0
  255. package/lib/browser/components/held-talk.js +79 -0
  256. package/lib/browser/components/host-view.d.ts +1 -1
  257. package/lib/browser/components/host-view.js +5 -5
  258. package/lib/browser/components/icon.d.ts +2 -2
  259. package/lib/browser/components/icon.js +7 -6
  260. package/lib/browser/components/image-viewer.d.ts +125 -0
  261. package/lib/browser/components/image-viewer.js +435 -0
  262. package/lib/browser/components/lightbox.d.ts +12 -0
  263. package/lib/browser/components/lightbox.js +60 -0
  264. package/lib/browser/components/markdown.d.ts +6 -2
  265. package/lib/browser/components/markdown.js +24 -10
  266. package/lib/browser/components/media.js +2 -11
  267. package/lib/browser/components/message-footer.d.ts +16 -2
  268. package/lib/browser/components/message-footer.js +31 -12
  269. package/lib/browser/components/message-list.d.ts +24 -3
  270. package/lib/browser/components/message-list.js +146 -16
  271. package/lib/browser/components/message-menu.d.ts +3 -1
  272. package/lib/browser/components/message-menu.js +17 -2
  273. package/lib/browser/components/nav-places.d.ts +16 -1
  274. package/lib/browser/components/nav-places.js +13 -3
  275. package/lib/browser/components/phone-shell.d.ts +4 -1
  276. package/lib/browser/components/phone-shell.js +3 -1
  277. package/lib/browser/components/run-status.js +3 -3
  278. package/lib/browser/components/select-bar.d.ts +10 -0
  279. package/lib/browser/components/select-bar.js +61 -0
  280. package/lib/browser/components/session-settings.d.ts +6 -0
  281. package/lib/browser/components/session-settings.js +14 -1
  282. package/lib/browser/components/session-view.js +7 -3
  283. package/lib/browser/components/settings-choices.d.ts +36 -0
  284. package/lib/browser/components/settings-choices.js +156 -0
  285. package/lib/browser/components/settings-parts.d.ts +22 -0
  286. package/lib/browser/components/settings-parts.js +359 -0
  287. package/lib/browser/components/settings-view.d.ts +0 -6
  288. package/lib/browser/components/settings-view.js +2 -405
  289. package/lib/browser/components/swipe-row.d.ts +2 -2
  290. package/lib/browser/components/swipe-row.js +7 -3
  291. package/lib/browser/components/tool-view.js +14 -12
  292. package/lib/browser/components/voice-button.d.ts +1 -1
  293. package/lib/browser/components/voice-button.js +1 -1
  294. package/lib/browser/components/voice-talk.d.ts +44 -0
  295. package/lib/browser/components/voice-talk.js +260 -0
  296. package/lib/browser/components/workbench-view.js +3 -3
  297. package/lib/browser/device/device.d.ts +3 -0
  298. package/lib/browser/device/device.js +11 -1
  299. package/lib/browser/device/hold.d.ts +43 -0
  300. package/lib/browser/device/hold.js +173 -0
  301. package/lib/browser/device/launch-screen.d.ts +1 -1
  302. package/lib/browser/device/launch-screen.js +1 -1
  303. package/lib/browser/device/long-press.d.ts +2 -0
  304. package/lib/browser/device/long-press.js +16 -1
  305. package/lib/browser/device/pull-down.d.ts +4 -2
  306. package/lib/browser/device/pull-down.js +63 -75
  307. package/lib/browser/device/row-swipe.d.ts +35 -10
  308. package/lib/browser/device/row-swipe.js +148 -70
  309. package/lib/browser/device/shake-undo.d.ts +17 -0
  310. package/lib/browser/device/shake-undo.js +63 -0
  311. package/lib/browser/device/sheet-swipe.d.ts +118 -18
  312. package/lib/browser/device/sheet-swipe.js +410 -108
  313. package/lib/browser/extension/icons.js +1 -0
  314. package/lib/browser/extension/web-extension-api.d.ts +135 -2
  315. package/lib/browser/extension/web-extension-code.d.ts +6 -0
  316. package/lib/browser/extension/web-extension-code.js +24 -0
  317. package/lib/browser/extension/web-extension-protocol.d.ts +23 -1
  318. package/lib/browser/extension/web-extension-protocol.js +9 -1
  319. package/lib/browser/extension/web-extensions.d.ts +14 -1
  320. package/lib/browser/extension/web-extensions.js +125 -21
  321. package/lib/browser/extension/web-tasks.d.ts +9 -1
  322. package/lib/browser/extension/web-tasks.js +24 -0
  323. package/lib/browser/files/files-protocol.d.ts +26 -0
  324. package/lib/browser/files/files-protocol.js +5 -0
  325. package/lib/browser/files/files.d.ts +36 -0
  326. package/lib/browser/files/files.js +122 -0
  327. package/lib/browser/hooks.d.ts +3 -1
  328. package/lib/browser/hooks.js +9 -0
  329. package/lib/browser/i18n/locales.d.ts +29 -2
  330. package/lib/browser/i18n/messages.d.ts +28 -1
  331. package/lib/browser/i18n/messages.js +58 -4
  332. package/lib/browser/index.d.ts +6 -0
  333. package/lib/browser/index.js +6 -0
  334. package/lib/browser/notices/notices-protocol.d.ts +9 -1
  335. package/lib/browser/notices/notices.d.ts +2 -0
  336. package/lib/browser/notices/notices.js +20 -10
  337. package/lib/browser/offline/device-values.d.ts +56 -0
  338. package/lib/browser/offline/device-values.js +148 -0
  339. package/lib/browser/offline/kept-chats-protocol.d.ts +18 -0
  340. package/lib/browser/offline/kept-chats-protocol.js +5 -0
  341. package/lib/browser/offline/kept-chats.d.ts +48 -0
  342. package/lib/browser/offline/kept-chats.js +149 -0
  343. package/lib/browser/offline/offline-reads.d.ts +45 -0
  344. package/lib/browser/offline/offline-reads.js +111 -0
  345. package/lib/browser/settings/settings-protocol.d.ts +2 -0
  346. package/lib/browser/settings/settings-protocol.js +2 -0
  347. package/lib/browser/style/conversation.d.ts +1 -1
  348. package/lib/browser/style/conversation.js +57 -17
  349. package/lib/browser/style/device.js +43 -4
  350. package/lib/browser/style/layout.d.ts +1 -1
  351. package/lib/browser/style/layout.js +67 -15
  352. package/lib/browser/style/pages.d.ts +1 -1
  353. package/lib/browser/style/pages.js +2 -1
  354. package/lib/browser/style/shell.d.ts +1 -1
  355. package/lib/browser/style/shell.js +47 -3
  356. package/lib/browser/style/tasks.d.ts +1 -1
  357. package/lib/browser/style/tasks.js +2 -0
  358. package/lib/browser/util/frame.d.ts +5 -4
  359. package/lib/browser/util/frame.js +5 -4
  360. package/lib/browser/util/markdown.d.ts +18 -1
  361. package/lib/browser/util/markdown.js +119 -5
  362. package/lib/browser/util/process.d.ts +21 -0
  363. package/lib/browser/util/process.js +46 -2
  364. package/lib/browser/util/voice.d.ts +5 -2
  365. package/lib/browser/util/voice.js +6 -3
  366. package/lib/browser/util/zoom.d.ts +47 -0
  367. package/lib/browser/util/zoom.js +99 -0
  368. package/lib/browser/workbench-calls.d.ts +60 -0
  369. package/lib/browser/workbench-calls.js +145 -0
  370. package/lib/browser/workbench-protocol.d.ts +5 -1
  371. package/lib/browser/workbench-util.d.ts +69 -0
  372. package/lib/browser/workbench-util.js +151 -0
  373. package/lib/browser/workbench.d.ts +15 -42
  374. package/lib/browser/workbench.js +74 -189
  375. package/package.json +10 -10
  376. package/public/launch.svg +46 -42
@@ -1,7 +1,7 @@
1
- import { CircleCheck, RotateCw, WifiOff } from 'lucide-react';
1
+ import { CircleAlert, CircleCheck, RotateCw, WifiOff } from 'lucide-react';
2
2
  import * as React from 'react';
3
3
  import { useDevice } from '../device/device.js';
4
- import { useWorkbench } from '../hooks.js';
4
+ import { useNotices, useWorkbench } from '../hooks.js';
5
5
  import { useT } from '../i18n/use-t.js';
6
6
  import { Icon } from './icon.js';
7
7
  /** How long "connected again" stays. */
@@ -10,6 +10,8 @@ const BACK_MS = 1200;
10
10
  const LEAVE_MS = 240;
11
11
  /** A try the user asked for shows as one for at least this long, however soon it fails. */
12
12
  const TRY_SHOWN_MS = 900;
13
+ /** How long it says that something did not happen for a moment's drop (NoticesState.notDoneAt). */
14
+ const NOT_DONE_MS = 3500;
13
15
  /** The seconds until `at`, counted down once a second; `undefined` without `at`. */
14
16
  function useSecondsUntil(at) {
15
17
  const [now, setNow] = React.useState(Date.now);
@@ -23,12 +25,31 @@ function useSecondsUntil(at) {
23
25
  }, [at]);
24
26
  return at === undefined ? undefined : Math.max(0, Math.ceil((at - now) / 1000));
25
27
  }
26
- /** Offline while the workbench shows it so, then "back" for a moment, then going; nothing for a drop it does not show. */
27
- function usePhase(shown) {
28
+ /** Whether `at` is less than `ms` ago, turning false when it no longer is. */
29
+ function useRecent(at, ms) {
30
+ const recent = at !== undefined && Date.now() - at < ms;
31
+ const [, setTick] = React.useState(0);
32
+ React.useEffect(() => {
33
+ if (!recent || at === undefined) {
34
+ return;
35
+ }
36
+ const timer = setTimeout(() => setTick(tick => tick + 1), at + ms - Date.now());
37
+ return () => clearTimeout(timer);
38
+ }, [recent, at, ms]);
39
+ return recent;
40
+ }
41
+ /**
42
+ * Offline while the workbench shows it so, then "back" for a moment, then going; nothing for a drop it does
43
+ * not show. `notDone` while online: something the user did was cut off by a drop that mended itself.
44
+ */
45
+ function usePhase(shown, notDone) {
28
46
  const [phase, setPhase] = React.useState('none');
29
47
  React.useEffect(() => {
30
48
  setPhase(phase => (shown ? 'offline' : phase === 'offline' ? 'back' : phase));
31
49
  }, [shown]);
50
+ React.useEffect(() => {
51
+ setPhase(phase => (notDone && (phase === 'none' || phase === 'leaving') ? 'notDone' : !notDone && phase === 'notDone' ? 'leaving' : phase));
52
+ }, [notDone]);
32
53
  React.useEffect(() => {
33
54
  if (phase !== 'back' && phase !== 'leaving') {
34
55
  return;
@@ -57,15 +78,23 @@ function usePressed() {
57
78
  */
58
79
  function useConnectionNotice() {
59
80
  const t = useT();
60
- const [{ offlineShown, error, retryAt }, workbench] = useWorkbench();
61
- const phase = usePhase(!!offlineShown);
81
+ const [{ offlineShown, error, retryAt, status }, workbench] = useWorkbench();
82
+ const [{ notDoneAt }] = useNotices();
83
+ // Something the user did did not happen: no notice over the page, this row says it. Offline, it shows at once.
84
+ const notDone = useRecent(notDoneAt, NOT_DONE_MS);
85
+ const online = status === 'online';
86
+ const phase = usePhase(!!offlineShown || (notDone && !online && status !== 'signed-out'), notDone && online);
62
87
  const seconds = useSecondsUntil(phase === 'offline' ? retryAt : undefined);
63
88
  const [pressed, press] = usePressed();
64
89
  const text = error === 'away' ? t('ta.connection.away') : error === 'unreachable' ? t('ta.unreachable') : t('ta.connection.lost');
90
+ // One line, for a phone: what was shown before still shows under it, as a chat app does without network.
91
+ const brief = error === 'away' ? t('ta.connection.awayBrief') : error === 'unreachable' ? t('ta.connection.unreachableBrief') : t('ta.connection.lost');
65
92
  return {
66
93
  phase,
67
- back: phase !== 'offline',
94
+ back: phase === 'back' || phase === 'leaving',
95
+ notDone: phase === 'notDone',
68
96
  text,
97
+ brief,
69
98
  seconds,
70
99
  trying: phase === 'offline' && (pressed || !seconds),
71
100
  retry: () => {
@@ -101,17 +130,20 @@ function useWidth(body, content) {
101
130
  */
102
131
  export function ConnectionBar() {
103
132
  const t = useT();
104
- const { phase, back, text, seconds, trying, retry } = useConnectionNotice();
133
+ const { phase, back, notDone, text, seconds, trying, retry } = useConnectionNotice();
105
134
  const body = React.useRef(null);
106
- const width = useWidth(body, phase === 'none' ? undefined : back ? 'back' : 'offline');
135
+ const shown = phase === 'none' ? undefined : notDone ? 'notDone' : back ? 'back' : 'offline';
136
+ const width = useWidth(body, shown);
107
137
  if (phase === 'none') {
108
138
  return null;
109
139
  }
110
- const classes = ['ta-connection', back && 'ta-connection-back', phase === 'leaving' && 'ta-connection-leaving'];
140
+ const classes = ['ta-connection', back && 'ta-connection-back', notDone && 'ta-connection-notdone', phase === 'leaving' && 'ta-connection-leaving'];
111
141
  // The border of the bar is around the body.
112
142
  const style = width === undefined ? undefined : { width: width + 2 };
113
143
  return (React.createElement("div", { className: classes.filter(Boolean).join(' '), role: "status", style: style },
114
- React.createElement("div", { className: "ta-connection-body", ref: body, key: back ? 'back' : 'offline' }, back ? (React.createElement(React.Fragment, null,
144
+ React.createElement("div", { className: "ta-connection-body", ref: body, key: shown }, notDone ? (React.createElement(React.Fragment, null,
145
+ React.createElement(Icon, { icon: CircleAlert, size: 15, className: "ta-level-icon" }),
146
+ React.createElement("span", { className: "ta-connection-text" }, t('ta.connection.notDone')))) : back ? (React.createElement(React.Fragment, null,
115
147
  React.createElement(Icon, { icon: CircleCheck, size: 15, className: "ta-level-icon" }),
116
148
  React.createElement("span", null, t('ta.connection.back')))) : (React.createElement(React.Fragment, null,
117
149
  React.createElement(Icon, { icon: WifiOff, size: 15, className: "ta-level-icon" }),
@@ -130,18 +162,19 @@ export function ConnectionBar() {
130
162
  export function ConnectionBanner() {
131
163
  const t = useT();
132
164
  const handheld = useDevice(device => device.handheld);
133
- const { phase, back, text, trying, retry } = useConnectionNotice();
165
+ const { phase, back, notDone, text, brief, trying, retry } = useConnectionNotice();
134
166
  if (!handheld) {
135
167
  return null;
136
168
  }
137
- const open = phase === 'offline' || phase === 'back';
169
+ const open = phase === 'offline' || phase === 'back' || notDone;
170
+ const quiet = back || notDone;
138
171
  const classes = ['ta-connection-banner', open && 'ta-open', back && 'ta-connection-back'];
139
172
  // Always there, empty while closed, so that it opens with a transition.
140
173
  return (React.createElement("div", { className: classes.filter(Boolean).join(' '), role: "status", "aria-hidden": !open },
141
- React.createElement("div", { className: "ta-connection-banner-inner" }, phase !== 'none' && (React.createElement("button", { type: "button", className: "ta-connection-banner-row", disabled: back || trying, tabIndex: open ? undefined : -1, onClick: retry },
142
- React.createElement(Icon, { icon: back ? CircleCheck : WifiOff, size: 16, className: "ta-level-icon" }),
143
- React.createElement("span", { className: "ta-connection-banner-text" }, back ? t('ta.connection.back') : text),
144
- !back && (React.createElement("span", { className: "ta-connection-banner-action" },
174
+ React.createElement("div", { className: "ta-connection-banner-inner" }, phase !== 'none' && (React.createElement("button", { type: "button", className: "ta-connection-banner-row", disabled: quiet || trying, tabIndex: open ? undefined : -1, title: quiet ? undefined : text, onClick: retry },
175
+ React.createElement(Icon, { icon: notDone ? CircleAlert : back ? CircleCheck : WifiOff, size: 16, className: "ta-level-icon" }),
176
+ React.createElement("span", { className: "ta-connection-banner-text" }, notDone ? t('ta.connection.notDone') : back ? t('ta.connection.back') : brief),
177
+ !quiet && (React.createElement("span", { className: "ta-connection-banner-action" },
145
178
  trying ? React.createElement("span", { className: "ta-spinner" }) : React.createElement(Icon, { icon: RotateCw, size: 14 }),
146
179
  trying ? t('ta.connection.retrying') : t('ta.connection.retry'))))))));
147
180
  }
@@ -6,10 +6,22 @@ export type ContextMenuItem = '-' | {
6
6
  disabled?: boolean /** Cannot be undone, as delete: drawn in red. */;
7
7
  danger?: boolean;
8
8
  };
9
+ /** Where a menu was opened: the pointer, and the element it is the menu of (a row), which a finger keeps in sight. */
10
+ export interface MenuOpening {
11
+ x: number;
12
+ y: number;
13
+ around?: {
14
+ top: number;
15
+ bottom: number;
16
+ };
17
+ }
9
18
  export declare namespace ContextMenuUtil {
10
19
  /**
11
- * Where a menu of `size` goes for a click at `at`: its corner at the pointer, as a browser's; above a finger
12
- * (below when there is no room), centred on it, as the menus of a phone. Always on the screen.
20
+ * Where a menu of `size` goes for a click at `at`: its corner at the pointer, as a browser's. Under a finger,
21
+ * never where the finger covers it: above the finger and the row it pressed (`around`), centred, as the menus
22
+ * of a phone; with no room there, beside the finger on the side with more room; else below the row, as far
23
+ * from the finger sideways as the screen allows. Always on the screen, out of the status bar and the home
24
+ * indicator (`safe`). `origin` is where it grows from: the side of the finger.
13
25
  */
14
26
  function place(at: {
15
27
  x: number;
@@ -23,13 +35,27 @@ export declare namespace ContextMenuUtil {
23
35
  }, touch: boolean, safe?: {
24
36
  top: number;
25
37
  bottom: number;
38
+ }, around?: {
39
+ top: number;
40
+ bottom: number;
26
41
  }): {
27
42
  left: number;
28
43
  top: number;
44
+ origin: string;
29
45
  };
46
+ /**
47
+ * Places a menu of the page, fixed to the screen, where it was `opened` (`place`), and on a touch screen lets
48
+ * the finger have it as on a phone: the finger of the long press that opened it slides onto an entry and lets go
49
+ * to choose it (the entry under it marked `data-armed`), or slides off and lets go to close it; let go where it
50
+ * was, the menu stays for a tap. A tap outside only closes it (the menu's own listener), not also tapping what is
51
+ * under it. For the menus of a layout effect, after the menu rendered its entries (`role="menuitem"`). Returns
52
+ * how to stop.
53
+ */
54
+ function attach(menu: HTMLElement, opened: MenuOpening, close: () => void): () => void;
30
55
  }
31
56
  /**
32
57
  * A context menu at the pointer, as a browser's tabs have: arrows move, Enter runs, Escape or a click
33
- * elsewhere closes. `open` takes the event of a right click (or of the menu key) and the entries.
58
+ * elsewhere closes. `open` takes the event of a right click (or of the menu key) and the entries. Opened by a
59
+ * long press, it keeps out from under the finger and the finger may slide onto an entry (ContextMenuUtil.attach).
34
60
  */
35
- export declare function useContextMenu(): [React.ReactNode, (event: React.MouseEvent, items: ContextMenuItem[]) => void];
61
+ export declare function useContextMenu(): [React.ReactNode, (event: React.MouseEvent, items: ContextMenuItem[], caption?: string) => void];
@@ -1,63 +1,223 @@
1
1
  import * as React from 'react';
2
- import { Device } from '../device/device.js';
2
+ import { createPortal } from 'react-dom';
3
+ import { Device, nativePlugin } from '../device/device.js';
4
+ import { LongPressUtil } from '../device/long-press.js';
3
5
  export var ContextMenuUtil;
4
6
  (function (ContextMenuUtil) {
5
- /** Between a finger and the menu it opened: the finger does not cover it. */
6
- const FINGER_GAP = 14;
7
+ /** Between the menu and the edges of the screen. */
8
+ const MARGIN = 4;
9
+ /** How far around the point it touches a fingertip covers the screen. */
10
+ const FINGER = 28;
11
+ /** Between the menu and the finger, or the row it was opened on. */
12
+ const GAP = 8;
13
+ /** A row this close to the finger stays in sight whole; of a longer element (a long message) only what is around the finger. */
14
+ const ROW_REACH = 96;
15
+ /** A tap outside a menu a finger opened closes it, and that is all it does: its click, if it comes this soon. */
16
+ const TAP_MS = 1000;
7
17
  /**
8
- * Where a menu of `size` goes for a click at `at`: its corner at the pointer, as a browser's; above a finger
9
- * (below when there is no room), centred on it, as the menus of a phone. Always on the screen.
18
+ * Where a menu of `size` goes for a click at `at`: its corner at the pointer, as a browser's. Under a finger,
19
+ * never where the finger covers it: above the finger and the row it pressed (`around`), centred, as the menus
20
+ * of a phone; with no room there, beside the finger on the side with more room; else below the row, as far
21
+ * from the finger sideways as the screen allows. Always on the screen, out of the status bar and the home
22
+ * indicator (`safe`). `origin` is where it grows from: the side of the finger.
10
23
  */
11
- function place(at, size, screen, touch, safe = { top: 0, bottom: 0 }) {
12
- const clamp = (value, max) => Math.max(4, Math.min(value, max - 4));
13
- if (touch) {
14
- const left = clamp(at.x - size.width / 2, screen.width - size.width);
15
- const above = at.y - FINGER_GAP - size.height;
16
- // Not under the status bar nor the home indicator.
17
- const top = above >= safe.top + 4 ? above : Math.max(safe.top + 4, Math.min(at.y + FINGER_GAP, screen.height - safe.bottom - size.height - 4));
18
- return { left, top };
24
+ function place(at, size, screen, touch, safe = { top: 0, bottom: 0 }, around) {
25
+ const clamp = (value, low, high) => Math.max(low, Math.min(value, high));
26
+ const widest = screen.width - MARGIN - size.width;
27
+ if (!touch) {
28
+ const top = at.y + size.height > screen.height - MARGIN ? Math.max(MARGIN, at.y - size.height) : at.y;
29
+ return { left: clamp(at.x, MARGIN, widest), top, origin: 'left top' };
19
30
  }
20
- const left = clamp(at.x, screen.width - size.width);
21
- const top = at.y + size.height > screen.height - 4 ? Math.max(4, at.y - size.height) : at.y;
22
- return { left, top };
31
+ const highest = safe.top + MARGIN;
32
+ const lowest = screen.height - safe.bottom - MARGIN - size.height;
33
+ const covered = {
34
+ top: Math.min(at.y - FINGER, around && around.top >= at.y - ROW_REACH ? around.top : at.y),
35
+ bottom: Math.max(at.y + FINGER, around && around.bottom <= at.y + ROW_REACH ? around.bottom : at.y),
36
+ };
37
+ // The hand comes from below: above the finger nothing covers the menu.
38
+ const above = covered.top - GAP - size.height;
39
+ if (above >= highest) {
40
+ return { left: clamp(at.x - size.width / 2, MARGIN, widest), top: above, origin: 'center bottom' };
41
+ }
42
+ const leftRoom = at.x - FINGER - GAP - MARGIN;
43
+ const rightRoom = screen.width - at.x - FINGER - GAP - MARGIN;
44
+ // Beside it while the point it touches stays off the menu: at most the edge of the fingertip on its padding.
45
+ if (Math.max(leftRoom, rightRoom) + FINGER >= size.width) {
46
+ const top = clamp(at.y - size.height / 2, highest, lowest);
47
+ return leftRoom >= rightRoom
48
+ ? { left: Math.max(MARGIN, at.x - FINGER - GAP - size.width), top, origin: 'right center' }
49
+ : { left: Math.min(at.x + FINGER + GAP, widest), top, origin: 'left center' };
50
+ }
51
+ const left = at.x >= screen.width / 2 ? MARGIN : widest;
52
+ return { left: clamp(left, MARGIN, widest), top: clamp(covered.bottom + GAP, highest, lowest), origin: 'center top' };
23
53
  }
24
54
  ContextMenuUtil.place = place;
55
+ /**
56
+ * Places a menu of the page, fixed to the screen, where it was `opened` (`place`), and on a touch screen lets
57
+ * the finger have it as on a phone: the finger of the long press that opened it slides onto an entry and lets go
58
+ * to choose it (the entry under it marked `data-armed`), or slides off and lets go to close it; let go where it
59
+ * was, the menu stays for a tap. A tap outside only closes it (the menu's own listener), not also tapping what is
60
+ * under it. For the menus of a layout effect, after the menu rendered its entries (`role="menuitem"`). Returns
61
+ * how to stop.
62
+ */
63
+ function attach(menu, opened, close) {
64
+ const touch = Device.state.touch;
65
+ const size = { width: menu.offsetWidth, height: menu.offsetHeight };
66
+ const screen = { width: window.innerWidth, height: window.innerHeight };
67
+ const at = place(opened, size, screen, touch, touch ? Device.safeArea() : undefined, opened.around);
68
+ menu.style.left = `${at.left}px`;
69
+ menu.style.top = `${at.top}px`;
70
+ if (!touch) {
71
+ return () => undefined;
72
+ }
73
+ menu.style.transformOrigin = at.origin;
74
+ const onOutside = (event) => {
75
+ if (event.pointerType !== 'mouse' && !menu.contains(event.target)) {
76
+ swallowTap(event.timeStamp);
77
+ }
78
+ };
79
+ document.addEventListener('pointerdown', onOutside, true);
80
+ const pressed = LongPressUtil.held();
81
+ const slide = pressed ? slideOn(menu, pressed, opened, close) : () => undefined;
82
+ return () => {
83
+ document.removeEventListener('pointerdown', onOutside, true);
84
+ slide();
85
+ };
86
+ }
87
+ ContextMenuUtil.attach = attach;
88
+ /** The finger that opened `menu` on `pressed` is the menu's until let go: not a scroll, nor a swipe of the row under it. */
89
+ function slideOn(menu, pressed, from, close) {
90
+ let armed;
91
+ let slid = false;
92
+ const still = holdStill(pressed);
93
+ const arm = (item) => {
94
+ var _a;
95
+ if (item === armed) {
96
+ return;
97
+ }
98
+ armed === null || armed === void 0 ? void 0 : armed.removeAttribute('data-armed');
99
+ armed = item;
100
+ if (item) {
101
+ item.setAttribute('data-armed', '');
102
+ (_a = nativePlugin('Haptics')) === null || _a === void 0 ? void 0 : _a('impact', { style: 'LIGHT' }).catch(() => undefined);
103
+ }
104
+ };
105
+ const onMove = (event) => {
106
+ var _a;
107
+ const touch = event.touches[0];
108
+ if (!touch) {
109
+ return;
110
+ }
111
+ if (event.cancelable) {
112
+ event.preventDefault();
113
+ }
114
+ event.stopPropagation();
115
+ slid || (slid = LongPressUtil.moved(from, { x: touch.clientX, y: touch.clientY }));
116
+ const item = (_a = document.elementFromPoint(touch.clientX, touch.clientY)) === null || _a === void 0 ? void 0 : _a.closest('[role="menuitem"]:not(:disabled)');
117
+ arm(item && menu.contains(item) ? item : undefined);
118
+ };
119
+ const onEnd = () => {
120
+ stop();
121
+ const item = armed;
122
+ arm(undefined);
123
+ if (item) {
124
+ item.click();
125
+ }
126
+ else if (slid) {
127
+ close();
128
+ }
129
+ };
130
+ const stop = () => {
131
+ still();
132
+ window.removeEventListener('touchmove', onMove, true);
133
+ window.removeEventListener('touchend', onEnd, true);
134
+ window.removeEventListener('touchcancel', stop, true);
135
+ };
136
+ window.addEventListener('touchmove', onMove, { capture: true, passive: false });
137
+ window.addEventListener('touchend', onEnd, true);
138
+ window.addEventListener('touchcancel', stop, true);
139
+ return () => {
140
+ stop();
141
+ arm(undefined);
142
+ };
143
+ }
144
+ /**
145
+ * Keeps what scrolls around `element` from scrolling until the returned function is called. A touch that began
146
+ * on a list may scroll it however its moves are cancelled after (iOS decides at its start whether they can be),
147
+ * and the finger now slides on the menu: the lists are held still instead.
148
+ */
149
+ function holdStill(element) {
150
+ const held = [];
151
+ for (let node = element.parentElement; node; node = node.parentElement) {
152
+ const style = getComputedStyle(node);
153
+ if (/auto|scroll/.test(style.overflowX + style.overflowY)) {
154
+ held.push([node, node.style.overflow]);
155
+ }
156
+ }
157
+ for (const [node] of held) {
158
+ node.style.overflow = 'hidden';
159
+ }
160
+ return () => {
161
+ for (const [node, overflow] of held.splice(0)) {
162
+ node.style.overflow = overflow;
163
+ }
164
+ };
165
+ }
166
+ /** The click of the touch that began at `since`, if one comes before the next touch: swallowed. */
167
+ function swallowTap(since) {
168
+ const swallow = (event) => {
169
+ off();
170
+ if (event.timeStamp - since < TAP_MS) {
171
+ event.preventDefault();
172
+ event.stopImmediatePropagation();
173
+ }
174
+ };
175
+ const off = () => {
176
+ clearTimeout(timer);
177
+ document.removeEventListener('click', swallow, true);
178
+ document.removeEventListener('pointerdown', off, true);
179
+ };
180
+ const timer = setTimeout(off, TAP_MS);
181
+ document.addEventListener('click', swallow, true);
182
+ document.addEventListener('pointerdown', off, true);
183
+ }
25
184
  })(ContextMenuUtil || (ContextMenuUtil = {}));
26
185
  /**
27
186
  * A context menu at the pointer, as a browser's tabs have: arrows move, Enter runs, Escape or a click
28
- * elsewhere closes. `open` takes the event of a right click (or of the menu key) and the entries.
187
+ * elsewhere closes. `open` takes the event of a right click (or of the menu key) and the entries. Opened by a
188
+ * long press, it keeps out from under the finger and the finger may slide onto an entry (ContextMenuUtil.attach).
29
189
  */
30
190
  export function useContextMenu() {
31
191
  const [menu, setMenu] = React.useState();
32
- const open = React.useCallback((event, items) => {
192
+ const open = React.useCallback((event, items, caption) => {
33
193
  event.preventDefault();
34
194
  event.stopPropagation();
35
195
  const box = event.currentTarget.getBoundingClientRect();
36
196
  // The menu key gives no pointer: under the element.
37
197
  const pointer = event.clientX || event.clientY;
38
- setMenu({ x: pointer ? event.clientX : box.left + 8, y: pointer ? event.clientY : box.bottom, items });
198
+ setMenu(pointer
199
+ ? { x: event.clientX, y: event.clientY, around: { top: box.top, bottom: box.bottom }, items, caption }
200
+ : { x: box.left + 8, y: box.bottom, items, caption });
39
201
  }, []);
40
202
  const close = React.useCallback(() => setMenu(undefined), []);
41
- const element = menu ? React.createElement(ContextMenu, { ...menu, onClose: close }) : null;
203
+ // On the page, not in what opened it: a row far up of a conversation (content-visibility) or one coming in
204
+ // with a motion contains what is fixed in it, which the menu would be clipped by.
205
+ const element = menu ? createPortal(React.createElement(ContextMenu, { ...menu, onClose: close }), document.body) : null;
42
206
  return [element, open];
43
207
  }
44
- function ContextMenu({ x, y, items, onClose }) {
208
+ function ContextMenu({ x, y, around, items, caption, onClose }) {
45
209
  const root = React.useRef(null);
46
- // Measured where it has the whole width, not squeezed against the edge it may open by; then placed.
47
- const [place, setPlace] = React.useState({ left: 0, top: 0, ready: false });
48
210
  React.useLayoutEffect(() => {
49
- var _a, _b;
211
+ var _a;
50
212
  const element = root.current;
51
- // Its size without the scale it comes in with.
52
- const box = element && { width: element.offsetWidth, height: element.offsetHeight };
53
- if (box) {
54
- setPlace({
55
- ...ContextMenuUtil.place({ x, y }, box, { width: window.innerWidth, height: window.innerHeight }, Device.state.touch, Device.safeArea()),
56
- ready: true,
57
- });
213
+ if (!element) {
214
+ return;
58
215
  }
59
- (_b = (_a = root.current) === null || _a === void 0 ? void 0 : _a.querySelector('button:not(:disabled)')) === null || _b === void 0 ? void 0 : _b.focus();
60
- }, [x, y]);
216
+ // Measured where it has the whole width (at 0, 0), not squeezed against the edge it may open by; then placed.
217
+ const stop = ContextMenuUtil.attach(element, { x, y, around }, onClose);
218
+ (_a = element.querySelector('button:not(:disabled)')) === null || _a === void 0 ? void 0 : _a.focus();
219
+ return stop;
220
+ }, [x, y, around, onClose]);
61
221
  React.useEffect(() => {
62
222
  const onPointer = (event) => {
63
223
  var _a;
@@ -88,9 +248,11 @@ function ContextMenu({ x, y, items, onClose }) {
88
248
  const at = buttons.indexOf(document.activeElement);
89
249
  (_b = buttons[(at + (event.key === 'ArrowDown' ? 1 : buttons.length - 1)) % buttons.length]) === null || _b === void 0 ? void 0 : _b.focus();
90
250
  };
91
- return (React.createElement("div", { ref: root, className: "ta-context-menu", role: "menu", style: { left: place.left, top: place.top, visibility: place.ready ? 'visible' : 'hidden' }, onKeyDown: onKeyDown, onContextMenu: event => event.preventDefault() }, items.map((item, index) => item === '-' ? (React.createElement("hr", { key: `-${index}`, className: "ta-context-menu-line" })) : (React.createElement("button", { key: item.label, type: "button", role: "menuitem", className: `ta-context-menu-item${item.danger ? ' ta-danger' : ''}`, disabled: item.disabled, onClick: () => {
92
- onClose();
93
- item.run();
94
- } }, item.label)))));
251
+ return (React.createElement("div", { ref: root, className: "ta-context-menu", role: "menu", onKeyDown: onKeyDown, onContextMenu: event => event.preventDefault() },
252
+ caption && React.createElement("div", { className: "ta-context-menu-caption" }, caption),
253
+ items.map((item, index) => item === '-' ? (React.createElement("hr", { key: `-${index}`, className: "ta-context-menu-line" })) : (React.createElement("button", { key: item.label, type: "button", role: "menuitem", className: `ta-context-menu-item${item.danger ? ' ta-danger' : ''}`, disabled: item.disabled, onClick: () => {
254
+ onClose();
255
+ item.run();
256
+ } }, item.label)))));
95
257
  }
96
258
  //# sourceMappingURL=context-menu.js.map
@@ -1,15 +1,138 @@
1
1
  import * as React from 'react';
2
2
  /** A message of the user in the thread: where the view goes when one is sent. */
3
3
  export declare const ASK_CLASS = "ta-thread-ask";
4
+ /** A row of the thread under which earlier rows come in (what says they load): the row read is the one after it. */
5
+ export declare const SCROLL_SKIP: {
6
+ readonly 'data-scroll-skip': '';
7
+ };
8
+ /** What the scrolling of a conversation reads of its view. */
9
+ export interface ScrollView {
10
+ scrollTop: number;
11
+ readonly scrollHeight: number;
12
+ readonly clientHeight: number;
13
+ scrollTo(options: ScrollToOptions): void;
14
+ getBoundingClientRect(): {
15
+ top: number;
16
+ };
17
+ }
18
+ /** A row of the thread. */
19
+ export interface ScrollRow {
20
+ /** From the top of the thread. */
21
+ readonly offsetTop: number;
22
+ readonly offsetHeight: number;
23
+ readonly isConnected: boolean;
24
+ /** `scrollSkip`: SCROLL_SKIP. */
25
+ readonly dataset?: {
26
+ readonly scrollSkip?: string;
27
+ };
28
+ }
29
+ /** The thread in the view: its rows (HTML elements: ScrollRow), and the room under them for the answer to a message sent. */
30
+ export interface ScrollThread {
31
+ readonly children: ArrayLike<object>;
32
+ readonly offsetHeight: number;
33
+ readonly style: {
34
+ paddingBottom: string;
35
+ };
36
+ }
4
37
  /**
5
- * The scrolling of a conversation, whose thread is the first child of the element of the returned ref.
6
- * A message the user sends goes to the top of the view, and the answer comes in under it: the thread
7
- * keeps the room for that until the answer fills it. Past that, the view follows what comes in while it
8
- * is at the bottom, after layout, on a change of the size of the thread or of the view rather than of the state.
9
- * Opened, and when messages of the user go (a rewind), the view goes to the bottom.
38
+ * The scrolling of a conversation: its view scrolls, its thread (the first child of the view, positioned)
39
+ * holds a row for each message.
40
+ *
41
+ * - At the bottom, the view follows what comes in, after layout, on a change of the size of the thread or of
42
+ * the view. The user scrolling up, by however little, leaves it where they took it: a wheel, a finger, a key,
43
+ * the scroll bar, whatever else moved the view up. Back down near the bottom, it follows again.
44
+ * - Away from the bottom, what the user reads stays where it is: the row at the top of the view keeps its place
45
+ * as rows above it change their height (earlier messages coming in, pictures, rows laid out as they come into
46
+ * view), and the bottom of the view keeps to the message box as it grows and shrinks (lines typed, the
47
+ * keyboard of a phone), as in a chat app.
48
+ * - A part of a message opened or closed by a click (what has `aria-expanded`, a `summary`) stays where it was
49
+ * clicked; opened past the bottom, the view stops following, for the user to read it.
50
+ * - While the user holds the view (a finger on it, the mouse on its scroll bar), nothing moves it under them.
51
+ * - A message the user sends goes to the top of the view, and the answer comes in under it: the thread keeps
52
+ * the room for that until the answer fills it (`send`), and the message keeps to the top as rows above it
53
+ * change their height (the turn it was sent into folding its steps).
54
+ */
55
+ export declare class ConversationScroller {
56
+ private readonly view;
57
+ private readonly thread;
58
+ private readonly now;
59
+ private static readonly views;
60
+ /** The scroller of a view, while it has one. */
61
+ static of(view: object): ConversationScroller | undefined;
62
+ private following;
63
+ /** Where a smooth scroll to a message sent goes: the view need not follow a bottom it is on its way to. */
64
+ private heading;
65
+ /** On a smooth way to the bottom (`toBottom`): what comes in meanwhile moves the end of the way. */
66
+ private chasing;
67
+ /** The message sent last, kept at the top until the user scrolls: rows above it may still change their height. */
68
+ private sent;
69
+ /** Where the view was when it last moved, and how high it was. */
70
+ private top;
71
+ private height;
72
+ private held;
73
+ private touchY;
74
+ /** The row at the top of the view while it does not follow, and how far it starts below the top of the view. */
75
+ private anchor;
76
+ /** What the user just opened or closed, and how far it was below the top of the view. */
77
+ private toggled;
78
+ /**
79
+ * The room under the thread for the answer to the message sent, added to the padding of its bottom: a least
80
+ * height would hide from the observer rows above the message that change their height.
81
+ */
82
+ private room;
83
+ private padding;
84
+ constructor(view: ScrollView, thread: ScrollThread, now?: () => number);
85
+ /** Whether the view follows what comes in. */
86
+ get atLatest(): boolean;
87
+ /** Listens to `view` (the view of this scroller) and its thread; returns what stops it. */
88
+ attach(view: HTMLElement, thread: HTMLElement): () => void;
89
+ /** To the bottom at once, following from there: a conversation opened, loaded again or rewound. */
90
+ reset(): void;
91
+ /** A message sent (its row): to the top of the view, smoothly, with the room under it that its answer will fill. */
92
+ send(message: ScrollRow & Element): void;
93
+ /** Back to the latest (the button that shows away from it): following again at once, the view on its way. */
94
+ toBottom(): void;
95
+ scrolled(): void;
96
+ /** A smooth scroll that ended short of where it went (the page moved under it) counts as there. */
97
+ scrollEnded(): void;
98
+ wheel(deltaY: number, target: EventTarget | null): void;
99
+ key(key: string, shift: boolean): void;
100
+ touchStart(y: number | undefined): void;
101
+ touchMove(y: number | undefined, target: EventTarget | null): void;
102
+ hold(): void;
103
+ /** Let go: what came in meanwhile shows, if the view follows. */
104
+ release(): void;
105
+ clicked(target: EventTarget | null): void;
106
+ /** The thread or the view changed its size. */
107
+ resized(): void;
108
+ /** Where the view goes for the message sent to be at its top, with the room under the thread for that. */
109
+ private place;
110
+ private makeRoom;
111
+ private arrive;
112
+ /** The user moves the view: a smooth scroll on its way is theirs now, the message sent no longer holds the top. */
113
+ private byUser;
114
+ /** The user moves the view up: it stops following before the scroll comes, which a follow would undo. */
115
+ private leave;
116
+ private toBottomNow;
117
+ private moveTo;
118
+ /** The first row in the view, while it does not follow. */
119
+ private remember;
120
+ private offsetOf;
121
+ /** Whether what `element` opened goes on past the bottom of the view. */
122
+ private past;
123
+ }
124
+ export interface ConversationScrollOptions {
125
+ /** Where a message sent goes: to the top of the view with its answer under it (a conversation), or to the bottom (a group chat). */
126
+ sentTo?: 'top' | 'bottom';
127
+ /** Another key (another chat in the same view) goes to the bottom. */
128
+ key?: string;
129
+ }
130
+ /**
131
+ * The scrolling of a conversation (ConversationScroller), whose thread is the first child of the element of the
132
+ * returned ref. Opened, and when messages of the user go (a rewind), the view goes to the bottom.
10
133
  *
11
134
  * `asked`: how many messages of the user there are; the thread marks them with ASK_CLASS.
12
135
  */
13
- export declare function useConversationScroll(asked: number): React.RefObject<HTMLDivElement | null>;
136
+ export declare function useConversationScroll(asked: number, options?: ConversationScrollOptions): React.RefObject<HTMLDivElement | null>;
14
137
  /** Whether the conversation of `ref` is scrolled up from its latest, and a way back to it. */
15
138
  export declare function useAwayFromBottom(ref: React.RefObject<HTMLDivElement | null>): [boolean, () => void];