@yaks/ux 0.0.0-stage → 0.2.36

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 (286) hide show
  1. package/Answer.js +43 -0
  2. package/Answer.js.map +1 -0
  3. package/Answer.ts +84 -0
  4. package/Conversation.js +520 -0
  5. package/Conversation.js.map +1 -0
  6. package/Conversation.ts +649 -0
  7. package/ConversationBox.js +106 -0
  8. package/ConversationBox.js.map +1 -0
  9. package/ConversationBox.ts +198 -0
  10. package/ConversationLines.js +29 -0
  11. package/ConversationLines.js.map +1 -0
  12. package/ConversationLines.ts +48 -0
  13. package/Disclosure.js +79 -0
  14. package/Disclosure.js.map +1 -0
  15. package/Disclosure.ts +130 -0
  16. package/Edit.js +330 -0
  17. package/Edit.js.map +1 -0
  18. package/Edit.ts +488 -0
  19. package/EntityPopup.js +35 -0
  20. package/EntityPopup.js.map +1 -0
  21. package/EntityPopup.ts +52 -0
  22. package/Fields.js +161 -0
  23. package/Fields.js.map +1 -0
  24. package/Fields.ts +276 -0
  25. package/LICENSE +202 -0
  26. package/Order.js +105 -0
  27. package/Order.js.map +1 -0
  28. package/Order.ts +159 -0
  29. package/README.md +1023 -2
  30. package/Save.js +50 -0
  31. package/Save.js.map +1 -0
  32. package/Save.ts +115 -0
  33. package/Sort.js +49 -0
  34. package/Sort.js.map +1 -0
  35. package/Sort.ts +98 -0
  36. package/Submit.js +115 -0
  37. package/Submit.js.map +1 -0
  38. package/Submit.ts +174 -0
  39. package/Text.js +114 -0
  40. package/Text.js.map +1 -0
  41. package/Text.ts +140 -0
  42. package/TokenPicker.js +65 -0
  43. package/TokenPicker.js.map +1 -0
  44. package/TokenPicker.ts +117 -0
  45. package/_dist/Answer.d.ts +39 -0
  46. package/_dist/Answer.d.ts.map +1 -0
  47. package/_dist/Conversation.d.ts +131 -0
  48. package/_dist/Conversation.d.ts.map +1 -0
  49. package/_dist/ConversationBox.d.ts +29 -0
  50. package/_dist/ConversationBox.d.ts.map +1 -0
  51. package/_dist/ConversationLines.d.ts +13 -0
  52. package/_dist/ConversationLines.d.ts.map +1 -0
  53. package/_dist/Disclosure.d.ts +36 -0
  54. package/_dist/Disclosure.d.ts.map +1 -0
  55. package/_dist/Edit.d.ts +87 -0
  56. package/_dist/Edit.d.ts.map +1 -0
  57. package/_dist/EntityPopup.d.ts +12 -0
  58. package/_dist/EntityPopup.d.ts.map +1 -0
  59. package/_dist/Fields.d.ts +29 -0
  60. package/_dist/Fields.d.ts.map +1 -0
  61. package/_dist/Order.d.ts +40 -0
  62. package/_dist/Order.d.ts.map +1 -0
  63. package/_dist/Save.d.ts +28 -0
  64. package/_dist/Save.d.ts.map +1 -0
  65. package/_dist/Sort.d.ts +28 -0
  66. package/_dist/Sort.d.ts.map +1 -0
  67. package/_dist/Submit.d.ts +48 -0
  68. package/_dist/Submit.d.ts.map +1 -0
  69. package/_dist/Text.d.ts +27 -0
  70. package/_dist/Text.d.ts.map +1 -0
  71. package/_dist/TokenPicker.d.ts +19 -0
  72. package/_dist/TokenPicker.d.ts.map +1 -0
  73. package/_dist/anchor.d.ts +52 -0
  74. package/_dist/anchor.d.ts.map +1 -0
  75. package/_dist/anchored.d.ts +30 -0
  76. package/_dist/anchored.d.ts.map +1 -0
  77. package/_dist/completion-state.d.ts +65 -0
  78. package/_dist/completion-state.d.ts.map +1 -0
  79. package/_dist/completion.d.ts +73 -0
  80. package/_dist/completion.d.ts.map +1 -0
  81. package/_dist/composer-browser.d.ts +1 -0
  82. package/_dist/composer-browser.d.ts.map +1 -0
  83. package/_dist/composer.d.ts +31 -0
  84. package/_dist/composer.d.ts.map +1 -0
  85. package/_dist/context-menu-browser.d.ts +4 -0
  86. package/_dist/context-menu-browser.d.ts.map +1 -0
  87. package/_dist/context-menu.d.ts +95 -0
  88. package/_dist/context-menu.d.ts.map +1 -0
  89. package/_dist/drag.d.ts +29 -0
  90. package/_dist/drag.d.ts.map +1 -0
  91. package/_dist/edit-keys.d.ts +42 -0
  92. package/_dist/edit-keys.d.ts.map +1 -0
  93. package/_dist/emit.d.ts +7 -0
  94. package/_dist/emit.d.ts.map +1 -0
  95. package/_dist/entity-popup-browser.d.ts +3 -0
  96. package/_dist/entity-popup-browser.d.ts.map +1 -0
  97. package/_dist/face/FaceTagger.d.ts +25 -0
  98. package/_dist/face/FaceTagger.d.ts.map +1 -0
  99. package/_dist/face/review.d.ts +5 -0
  100. package/_dist/face/review.d.ts.map +1 -0
  101. package/_dist/face/tags.d.ts +99 -0
  102. package/_dist/face/tags.d.ts.map +1 -0
  103. package/_dist/field-values.d.ts +4 -0
  104. package/_dist/field-values.d.ts.map +1 -0
  105. package/_dist/fit-list.d.ts +4 -0
  106. package/_dist/fit-list.d.ts.map +1 -0
  107. package/_dist/hits.d.ts +27 -0
  108. package/_dist/hits.d.ts.map +1 -0
  109. package/_dist/host.d.ts +91 -0
  110. package/_dist/host.d.ts.map +1 -0
  111. package/_dist/image-fallback.d.ts +5 -0
  112. package/_dist/image-fallback.d.ts.map +1 -0
  113. package/_dist/keys.d.ts +95 -0
  114. package/_dist/keys.d.ts.map +1 -0
  115. package/_dist/kit.d.ts +23 -0
  116. package/_dist/kit.d.ts.map +1 -0
  117. package/_dist/lightbox-browser.d.ts +2 -0
  118. package/_dist/lightbox-browser.d.ts.map +1 -0
  119. package/_dist/lightbox.d.ts +42 -0
  120. package/_dist/lightbox.d.ts.map +1 -0
  121. package/_dist/live.d.ts +21 -0
  122. package/_dist/live.d.ts.map +1 -0
  123. package/_dist/mod.d.ts +67 -0
  124. package/_dist/mod.d.ts.map +1 -0
  125. package/_dist/read.d.ts +12 -0
  126. package/_dist/read.d.ts.map +1 -0
  127. package/_dist/resize.d.ts +43 -0
  128. package/_dist/resize.d.ts.map +1 -0
  129. package/_dist/rows.d.ts +31 -0
  130. package/_dist/rows.d.ts.map +1 -0
  131. package/_dist/save-browser.d.ts +29 -0
  132. package/_dist/save-browser.d.ts.map +1 -0
  133. package/_dist/select-browser.d.ts +1 -0
  134. package/_dist/select-browser.d.ts.map +1 -0
  135. package/_dist/select.d.ts +12 -0
  136. package/_dist/select.d.ts.map +1 -0
  137. package/_dist/sending.d.ts +10 -0
  138. package/_dist/sending.d.ts.map +1 -0
  139. package/_dist/sort-browser.d.ts +11 -0
  140. package/_dist/sort-browser.d.ts.map +1 -0
  141. package/_dist/state.d.ts +74 -0
  142. package/_dist/state.d.ts.map +1 -0
  143. package/_dist/suggest.d.ts +18 -0
  144. package/_dist/suggest.d.ts.map +1 -0
  145. package/_dist/swipe.d.ts +60 -0
  146. package/_dist/swipe.d.ts.map +1 -0
  147. package/_dist/ui.d.ts +6 -0
  148. package/_dist/ui.d.ts.map +1 -0
  149. package/_dist/upload-browser.d.ts +13 -0
  150. package/_dist/upload-browser.d.ts.map +1 -0
  151. package/_dist/views.d.ts +8 -0
  152. package/_dist/views.d.ts.map +1 -0
  153. package/_dist/vocab.d.ts +6 -0
  154. package/_dist/vocab.d.ts.map +1 -0
  155. package/anchor.js +58 -0
  156. package/anchor.js.map +1 -0
  157. package/anchor.ts +87 -0
  158. package/anchored.js +180 -0
  159. package/anchored.js.map +1 -0
  160. package/anchored.ts +232 -0
  161. package/completion-state.js +76 -0
  162. package/completion-state.js.map +1 -0
  163. package/completion-state.ts +120 -0
  164. package/completion.js +301 -0
  165. package/completion.js.map +1 -0
  166. package/completion.ts +433 -0
  167. package/composer-browser.js +4 -0
  168. package/composer-browser.js.map +1 -0
  169. package/composer-browser.ts +5 -0
  170. package/composer.js +42 -0
  171. package/composer.js.map +1 -0
  172. package/composer.ts +53 -0
  173. package/context-menu-browser.js +221 -0
  174. package/context-menu-browser.js.map +1 -0
  175. package/context-menu-browser.ts +231 -0
  176. package/context-menu.js +146 -0
  177. package/context-menu.js.map +1 -0
  178. package/context-menu.ts +194 -0
  179. package/deno.json +1 -0
  180. package/drag.js +33 -0
  181. package/drag.js.map +1 -0
  182. package/drag.ts +41 -0
  183. package/edit-keys.js +51 -0
  184. package/edit-keys.js.map +1 -0
  185. package/edit-keys.ts +81 -0
  186. package/emit.js +34 -0
  187. package/emit.js.map +1 -0
  188. package/emit.ts +55 -0
  189. package/entity-popup-browser.js +94 -0
  190. package/entity-popup-browser.js.map +1 -0
  191. package/entity-popup-browser.ts +100 -0
  192. package/face/FaceTagger.js +361 -0
  193. package/face/FaceTagger.js.map +1 -0
  194. package/face/FaceTagger.ts +507 -0
  195. package/face/NameProposal.js +61 -0
  196. package/face/NameProposal.js.map +1 -0
  197. package/face/NameProposal.ts +100 -0
  198. package/face/review.js +33 -0
  199. package/face/review.js.map +1 -0
  200. package/face/review.ts +49 -0
  201. package/face/tags.js +344 -0
  202. package/face/tags.js.map +1 -0
  203. package/face/tags.ts +357 -0
  204. package/field-values.js +20 -0
  205. package/field-values.js.map +1 -0
  206. package/field-values.ts +35 -0
  207. package/fit-list.js +66 -0
  208. package/fit-list.js.map +1 -0
  209. package/fit-list.ts +81 -0
  210. package/hits.js +65 -0
  211. package/hits.js.map +1 -0
  212. package/hits.ts +75 -0
  213. package/host.js +88 -0
  214. package/host.js.map +1 -0
  215. package/host.ts +212 -0
  216. package/image-fallback.js +32 -0
  217. package/image-fallback.js.map +1 -0
  218. package/image-fallback.ts +37 -0
  219. package/keys.js +418 -0
  220. package/keys.js.map +1 -0
  221. package/keys.ts +444 -0
  222. package/kit.js +41 -0
  223. package/kit.js.map +1 -0
  224. package/kit.ts +71 -0
  225. package/lightbox-browser.js +248 -0
  226. package/lightbox-browser.js.map +1 -0
  227. package/lightbox-browser.ts +232 -0
  228. package/lightbox.js +84 -0
  229. package/lightbox.js.map +1 -0
  230. package/lightbox.ts +103 -0
  231. package/live.js +111 -0
  232. package/live.js.map +1 -0
  233. package/live.ts +139 -0
  234. package/mod.js +67 -0
  235. package/mod.js.map +1 -0
  236. package/mod.ts +180 -0
  237. package/package.json +143 -4
  238. package/read.js +33 -0
  239. package/read.js.map +1 -0
  240. package/read.ts +56 -0
  241. package/resize.js +159 -0
  242. package/resize.js.map +1 -0
  243. package/resize.ts +203 -0
  244. package/rows.js +73 -0
  245. package/rows.js.map +1 -0
  246. package/rows.ts +97 -0
  247. package/save-browser.js +469 -0
  248. package/save-browser.js.map +1 -0
  249. package/save-browser.ts +530 -0
  250. package/select-browser.js +4 -0
  251. package/select-browser.js.map +1 -0
  252. package/select-browser.ts +5 -0
  253. package/select.js +296 -0
  254. package/select.js.map +1 -0
  255. package/select.ts +343 -0
  256. package/sending.js +36 -0
  257. package/sending.js.map +1 -0
  258. package/sending.ts +44 -0
  259. package/sort-browser.js +51 -0
  260. package/sort-browser.js.map +1 -0
  261. package/sort-browser.ts +70 -0
  262. package/state.js +99 -0
  263. package/state.js.map +1 -0
  264. package/state.ts +121 -0
  265. package/suggest.js +28 -0
  266. package/suggest.js.map +1 -0
  267. package/suggest.ts +32 -0
  268. package/swipe.js +186 -0
  269. package/swipe.js.map +1 -0
  270. package/swipe.ts +250 -0
  271. package/ui.js +507 -0
  272. package/ui.js.map +1 -0
  273. package/ui.ts +378 -0
  274. package/upload-browser.js +195 -0
  275. package/upload-browser.js.map +1 -0
  276. package/upload-browser.ts +303 -0
  277. package/upload-files.js +41 -0
  278. package/upload-files.js.map +1 -0
  279. package/upload-files.ts +49 -0
  280. package/views.js +8 -0
  281. package/views.js.map +1 -0
  282. package/views.ts +9 -0
  283. package/vocab.js +16 -0
  284. package/vocab.js.map +1 -0
  285. package/vocab.json +287 -0
  286. package/vocab.ts +17 -0
package/Answer.js ADDED
@@ -0,0 +1,43 @@
1
+ /**
2
+ * What a query answered, drawn the same on every screen: `Loading` until its
3
+ * first answer arrives, `Empty` when it answered none, `ErrorNotice` with the
4
+ * refusal when it was refused, and otherwise its rows, drawn by the caller. A
5
+ * screen draws only its rows; the other three states are this component's.
6
+ *
7
+ * It draws from an `Answered`: `useAnswered` (./rows.ts) reads one off a
8
+ * query's watch, and a host with its own subscriptions hands its state over in
9
+ * that shape.
10
+ *
11
+ * @module
12
+ */ /* @ts-types="npm:@types/react@19.3.0" */ import { createElement as h, Fragment } from "react";
13
+ import { Button } from "@yaks/ui/Button";
14
+ import { Empty } from "@yaks/ui/Empty";
15
+ import { ErrorNotice } from "@yaks/ui/ErrorNotice";
16
+ import { Loading } from "@yaks/ui/Loading";
17
+ /** Say a read was refused: what could not load, the refusal's words, and a
18
+ * way to ask again. `Answer` says it of a query; a read of one entity says
19
+ * it alone. */ export let Refused = ({ failed, refused, retry })=>/*#__PURE__*/ h(ErrorNotice, null, [
20
+ failed ?? 'This could not load.',
21
+ refused
22
+ ].filter(Boolean).join(' '), retry && ' ', retry && /*#__PURE__*/ h(Button, {
23
+ type: 'button',
24
+ mod: 'quiet',
25
+ onClick: retry
26
+ }, 'Try again'));
27
+ /** Draw a query's rows, or say it is loading, empty or could not load. Rows
28
+ * already on screen stay while the next answer is awaited. */ export let Answer = ({ answered, empty, loading, name, failed, retry, children })=>{
29
+ let { rows, ready, refused } = answered;
30
+ if (refused !== undefined) return /*#__PURE__*/ h(Refused, {
31
+ failed,
32
+ refused,
33
+ retry
34
+ });
35
+ let pending = !ready && /*#__PURE__*/ h(Loading, {
36
+ state: name
37
+ }, loading);
38
+ if (!rows.length) {
39
+ return pending || /*#__PURE__*/ h(Empty, null, typeof empty == 'string' ? /*#__PURE__*/ h(Empty.Title, null, empty) : empty);
40
+ }
41
+ return /*#__PURE__*/ h(Fragment, null, children(rows), pending);
42
+ };
43
+ //# sourceMappingURL=Answer.js.map
package/Answer.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Answer.js","sources":["./Answer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;CAWC,GAED,uCAAuC,GAAG,SAAS,iBAAiB,CAAC,EAAE,QAAQ,gBAA0C;AACzH,SAAS,MAAM,+BAAoC;AACnD,SAAS,KAAK,8BAAmC;AACjD,SAAS,WAAW,oCAAyC;AAC7D,SAAS,OAAO,gCAAqC;AAmCrD;;aAEa,GACb,OAAO,IAAI,UAAU,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAgB,iBAC5D,EACE,aACA,MACA;IAAC,UAAU;IAAwB;GAAQ,CAAC,MAAM,CAAC,SAAS,IAAI,CAAC,MACjE,SAAS,KACT,uBACE,EAAE,QAAQ;IAAE,MAAM;IAAU,KAAK;IAAS,SAAS;EAAM,GAAG,cAC/D;AAEH;4DAC4D,GAC5D,OAAO,IAAI,SAAS,CAClB,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAExD;EAED,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG;EAC/B,IAAI,YAAY,WAAW,qBAAO,EAAE,SAAS;IAAE;IAAQ;IAAS;EAAM;EACtE,IAAI,UAAU,CAAC,uBAAS,EAAE,SAAS;IAAE,OAAO;EAAK,GAAG;EACpD,IAAI,CAAC,KAAK,MAAM,EAAE;IAChB,OAAO,yBAAW,EAChB,OACA,MACA,OAAO,SAAS,yBAAW,EAAE,MAAM,KAAK,EAAE,MAAM,SAAS;EAE7D;EACA,qBAAO,EAAE,UAAU,MAAM,SAAS,OAAO;AAC3C,EAAC"}
package/Answer.ts ADDED
@@ -0,0 +1,84 @@
1
+ /**
2
+ * What a query answered, drawn the same on every screen: `Loading` until its
3
+ * first answer arrives, `Empty` when it answered none, `ErrorNotice` with the
4
+ * refusal when it was refused, and otherwise its rows, drawn by the caller. A
5
+ * screen draws only its rows; the other three states are this component's.
6
+ *
7
+ * It draws from an `Answered`: `useAnswered` (./rows.ts) reads one off a
8
+ * query's watch, and a host with its own subscriptions hands its state over in
9
+ * that shape.
10
+ *
11
+ * @module
12
+ */
13
+
14
+ /* @ts-types="npm:@types/react@19.3.0" */ import { createElement as h, Fragment, type ReactNode } from 'react'
15
+ import { Button } from '@yaks/ui/Button'
16
+ import { Empty } from '@yaks/ui/Empty'
17
+ import { ErrorNotice } from '@yaks/ui/ErrorNotice'
18
+ import { Loading } from '@yaks/ui/Loading'
19
+ import type { Bundle } from 'jsr:@yaks/graph@0.2.36'
20
+
21
+ /** A query's state: the rows it answered so far, whether its first answer
22
+ * has arrived, and why it was refused. A refused query is not ready. */
23
+ export type Answered<T = Bundle> = {
24
+ rows: T[]
25
+ ready: boolean
26
+ refused?: string
27
+ }
28
+
29
+ /** What `Answer` takes. */
30
+ export type AnswerProps<T> = {
31
+ answered: Answered<T>
32
+ /** what fills `Empty` when the query answered none: words become its
33
+ * title; nodes are drawn as given (an `Empty.Title` and a line saying how
34
+ * to start) */
35
+ empty: ReactNode
36
+ /** what is awaited, in words; `Loading…` */
37
+ loading?: ReactNode
38
+ /** a diagnostic name for the read, on its `Loading` */
39
+ name?: string
40
+ /** what could not load, as a person reads it; the refusal follows */
41
+ failed?: string
42
+ /** ask again, offered beside the refusal */
43
+ retry?: () => unknown
44
+ /** the rows, drawn */
45
+ children: (rows: T[]) => ReactNode
46
+ }
47
+
48
+ /** What `Refused` takes. */
49
+ export type RefusedProps = Pick<AnswerProps<never>, 'failed' | 'retry'> & {
50
+ refused: string
51
+ }
52
+
53
+ /** Say a read was refused: what could not load, the refusal's words, and a
54
+ * way to ask again. `Answer` says it of a query; a read of one entity says
55
+ * it alone. */
56
+ export let Refused = ({ failed, refused, retry }: RefusedProps): ReactNode =>
57
+ h(
58
+ ErrorNotice,
59
+ null,
60
+ [failed ?? 'This could not load.', refused].filter(Boolean).join(' '),
61
+ retry && ' ',
62
+ retry &&
63
+ h(Button, { type: 'button', mod: 'quiet', onClick: retry }, 'Try again'),
64
+ )
65
+
66
+ /** Draw a query's rows, or say it is loading, empty or could not load. Rows
67
+ * already on screen stay while the next answer is awaited. */
68
+ export let Answer = <T>(
69
+ { answered, empty, loading, name, failed, retry, children }: AnswerProps<
70
+ T
71
+ >,
72
+ ): ReactNode => {
73
+ let { rows, ready, refused } = answered
74
+ if (refused !== undefined) return h(Refused, { failed, refused, retry })
75
+ let pending = !ready && h(Loading, { state: name }, loading)
76
+ if (!rows.length) {
77
+ return pending || h(
78
+ Empty,
79
+ null,
80
+ typeof empty == 'string' ? h(Empty.Title, null, empty) : empty,
81
+ )
82
+ }
83
+ return h(Fragment, null, children(rows), pending)
84
+ }
@@ -0,0 +1,520 @@
1
+ /**
2
+ * A conversation's lines, newest last, as a reader follows them: it stays at
3
+ * the newest line while lines arrive, until the reader scrolls up to read,
4
+ * and it draws the last `take` lines it is given, more when asked. Its state
5
+ * is `Conversation{take, away}` on the page entity its owner names
6
+ * (`conversationAt`): how many lines back it draws, and whether the reader
7
+ * has scrolled away from the newest. It knows no data names: its owner
8
+ * gives it lines already drawn, and what the conversation is doing now.
9
+ *
10
+ * `Conversation.Box` is where a person writes to it: their words are a draft
11
+ * (the host's `drafts`), Enter sends them and Shift+Enter starts a line, and
12
+ * Send emits them as the bundle its owner says they become, Stop a `Stop`
13
+ * event; the owner says where each goes, and spends the draft once the words
14
+ * are taken. Given `onFiles`, it takes files pasted or dropped anywhere on it
15
+ * and emits them, lit while they are held over it; the owner holds them and
16
+ * draws them in its slots.
17
+ *
18
+ * Where it scrolls in a place of its own rather than the page, it holds the
19
+ * page to what a person sees (`fit`): a phone's keyboard shortens the page,
20
+ * so its own scroll area gets shorter and the box sits on the keyboard, and
21
+ * the page itself never scrolls.
22
+ *
23
+ * Whether each fold in a line is open is `Disclosure{open}` in the same page
24
+ * graph, on the page entity of the line and the fold's place in it (`Folds`,
25
+ * `useFold`), so a line drawn again keeps its folds as the reader left them
26
+ * though its words changed ("Reading…" to "Read").
27
+ *
28
+ * Only `h` and hooks, so it paints under any renderer that has them.
29
+ *
30
+ * @module
31
+ */ /* @ts-types="npm:@types/react@19.3.0" */ import { createContext, createElement as h, useContext, useLayoutEffect, useRef, useState } from "react";
32
+ import { derivedEid } from "@yaks/graph/identity";
33
+ import { Button, Transcript } from "@yaks/ui/parts";
34
+ import { useNow } from "@yaks/ui/Time";
35
+ import { datedRows } from "./ConversationLines.js";
36
+ import { anchored, scroller } from "./anchored.js";
37
+ export { activityRuns, DatedRows, datedRows } from "./ConversationLines.js";
38
+ import { Box } from "./ConversationBox.js";
39
+ import { disclosed, Disclosure, disclosureAt, DisclosureMark, isOpen, Loading, UNFETCHED } from "./Disclosure.js";
40
+ /** How many lines it draws before it is asked for more, and how many more
41
+ * each time: a screen or two, so moving to a page holding it lays over a few
42
+ * thousand nodes rather than tens of thousands. A reader scrolling up to the
43
+ * oldest drawn asks for the next. */ export let TAKE = 40;
44
+ /** How close to the oldest line drawn, in px, a reader scrolling up brings
45
+ * the earlier ones in. */ export let NEAR = 120;
46
+ /** The page entity of `owner`'s conversation with `session`. */ export let conversationAt = (owner, session)=>derivedEid([
47
+ 'Conversation',
48
+ owner,
49
+ session
50
+ ].join('|'));
51
+ /** Its state, as `e` holds it. */ export let conversingOf = (e)=>e?.Conversation ?? {};
52
+ /** The bundle it emits: its state, changed. */ export let conversed = (e, change)=>({
53
+ entity: {
54
+ eid: e.entity.eid
55
+ },
56
+ Conversation: {
57
+ ...conversingOf(e),
58
+ ...change
59
+ }
60
+ });
61
+ /** The lines it draws of those it is given, and how many earlier it does
62
+ * not: those before its `take`, and those its owner was not given
63
+ * (`earlier`). */ export let shown = (lines, take = TAKE, earlier = 0)=>{
64
+ let drawn = take >= lines.length ? lines : lines.slice(lines.length - take);
65
+ return {
66
+ lines: drawn,
67
+ hidden: lines.length - drawn.length + earlier
68
+ };
69
+ };
70
+ let Held = /*#__PURE__*/ createContext({});
71
+ /** What is drawn under it is a line's, `line` its id: each fold in it is
72
+ * owned by the line and its place there. A conversation puts every line it
73
+ * draws under one, and a line inside a fold (a call's turn) is under one of
74
+ * its own. */ export let Folds = ({ line, children })=>{
75
+ let up = useContext(Held);
76
+ // How many folds it has drawn, kept while it is: a fold drawn again keeps
77
+ // its place though its line drew others before it.
78
+ let placed = useRef({
79
+ n: 0
80
+ });
81
+ return /*#__PURE__*/ h(Held.Provider, {
82
+ value: {
83
+ ...up,
84
+ line: Object.assign(placed.current, {
85
+ at: line
86
+ })
87
+ },
88
+ children
89
+ });
90
+ };
91
+ /** The state of a fold its line draws, for a `Disclosure` and its
92
+ * `DisclosureMark`: on `disclosureAt` its line and its place in it, the
93
+ * order its line first drew its folds in, which a server's drawing and the
94
+ * page's mounted over it share. Its conversation reads and keeps it; outside
95
+ * one it is closed, and outside a line it is none and the fold is a plain
96
+ * `details`. */ export let useFold = ()=>{
97
+ let held = useContext(Held);
98
+ let place = useRef(null);
99
+ if (!held.line) return {};
100
+ place.current ??= held.line.n++;
101
+ let eid = disclosureAt(`${held.line.at} ${place.current}`);
102
+ return {
103
+ e: held.state?.(eid) ?? {
104
+ entity: {
105
+ eid
106
+ }
107
+ },
108
+ onChange: held.onChange
109
+ };
110
+ };
111
+ /** A fold in a line: a `Disclosure` on the state `useFold` gives it. */ export let Fold = (props)=>/*#__PURE__*/ h(Disclosure, {
112
+ ...props,
113
+ ...useFold()
114
+ });
115
+ export { stopped } from "./ConversationBox.js";
116
+ export { disclosed, Disclosure, DisclosureMark, isOpen, Loading, UNFETCHED };
117
+ // What scrolls the page.
118
+ let paged = (doc)=>doc.scrollingElement ?? doc.documentElement;
119
+ // An address outside the conversation names a layer over it.
120
+ let addressed = (el)=>{
121
+ let doc = el.ownerDocument;
122
+ let id = decodeURIComponent(doc.defaultView?.location?.hash?.slice(1) ?? '');
123
+ return id ? doc.getElementById(id) : null;
124
+ };
125
+ // The lines a reader is held at: those drawn in its list, not the rows a
126
+ // grouped line holds of its own.
127
+ let rowsOf = (el)=>[
128
+ ...el.querySelectorAll('.Transcript_Lines [id^="row-"]')
129
+ ].filter((row)=>!row.parentElement?.closest('[id^="row-"]'));
130
+ export let transcriptRow = (line, divider, before)=>{
131
+ let props = {
132
+ id: `row-${line.id}`,
133
+ 'data-line-at': line.at,
134
+ 'data-line-of': line.of?.join(','),
135
+ 'data-transient': line.transient ? '' : undefined,
136
+ 'data-before': before
137
+ };
138
+ return line.html == null ? /*#__PURE__*/ h(Folds, {
139
+ key: line.id,
140
+ line: line.id
141
+ }, /*#__PURE__*/ h(Transcript.Row, props, divider, /*#__PURE__*/ h(Transcript.Content, {}, line.node))) : /*#__PURE__*/ h(Transcript.Row, {
142
+ ...props,
143
+ key: line.id
144
+ }, divider, /*#__PURE__*/ h(Transcript.Content, {
145
+ dangerouslySetInnerHTML: {
146
+ __html: line.html
147
+ }
148
+ }));
149
+ };
150
+ let activityRows = (lines, visible)=>{
151
+ let rows = [];
152
+ let before;
153
+ for(let i = lines.length - 1; i >= 0; i--){
154
+ let line = lines[i];
155
+ if (line.transient) rows.push(transcriptRow(line, undefined, before));
156
+ else if (visible.has(line.id)) before = line.id;
157
+ }
158
+ return rows.reverse();
159
+ };
160
+ /** What the page is held to, given the visual viewport, how far the page is
161
+ * scrolled, whether a field is typed in, and the window's height: while one
162
+ * is and a keyboard covers part of the window, the visual viewport's height
163
+ * in px at the page's own scale, and otherwise none, so it is the whole
164
+ * window; and whether the page goes back to its top, which it does unless a
165
+ * person pinched it larger, when where it is shown is theirs. A field typed
166
+ * in with nothing over the window holds no height: the root's property
167
+ * changing restyles every element on the page, so leaving the field would
168
+ * cost a press a frame of the whole page for nothing. */ export let seen = (view, scrollY, typing, whole)=>{
169
+ let height = Math.round(view.height * view.scale);
170
+ return {
171
+ ...typing && height < whole && {
172
+ height
173
+ },
174
+ top: view.scale == 1 && (scrollY > 0 || view.offsetTop > 0)
175
+ };
176
+ };
177
+ /** The property a page's frame takes its height from, set on its root:
178
+ * `height: var(--viewport-height, 100dvh)`. */ export let VIEWPORT = '--viewport-height';
179
+ // What a keyboard comes up for.
180
+ let EDITABLE = 'input, textarea, select, [contenteditable]';
181
+ /** Holds `doc`'s page to what a person sees as it changes (`seen`): a
182
+ * keyboard opening shortens it rather than scrolling it, which iOS Safari
183
+ * does whatever the viewport meta says. It holds a height only while a field
184
+ * is typed in, and reads it again whenever the visual viewport or window
185
+ * changes, focus moves and a finger lifts, since iOS does not always tell the
186
+ * visual viewport a keyboard closed (around a swipe). Returns what lets it
187
+ * go. */ export let fit = (doc)=>{
188
+ let win = doc.defaultView;
189
+ let view = win?.visualViewport;
190
+ if (!win || !view) return ()=>{};
191
+ let root = doc.documentElement;
192
+ // Focus leaving is heard before it has gone.
193
+ let held = (ev)=>{
194
+ let at = doc.activeElement;
195
+ let typing = !!at?.matches?.(EDITABLE) && !(ev?.type == 'focusout' && ev.target == at);
196
+ let { height, top } = seen(view, win.scrollY ?? 0, typing, win.innerHeight);
197
+ if (height == null) root.style.removeProperty(VIEWPORT);
198
+ else root.style.setProperty(VIEWPORT, `${height}px`);
199
+ if (top) win.scrollTo(0, 0);
200
+ };
201
+ let heard = [
202
+ [
203
+ view,
204
+ 'resize'
205
+ ],
206
+ [
207
+ view,
208
+ 'scroll'
209
+ ],
210
+ [
211
+ win,
212
+ 'resize'
213
+ ],
214
+ [
215
+ doc,
216
+ 'focusin'
217
+ ],
218
+ [
219
+ doc,
220
+ 'focusout'
221
+ ],
222
+ [
223
+ doc,
224
+ 'touchend'
225
+ ],
226
+ [
227
+ doc,
228
+ 'touchcancel'
229
+ ]
230
+ ];
231
+ held();
232
+ for (let [at, type] of heard)at.addEventListener(type, held);
233
+ return ()=>{
234
+ for (let [at, type] of heard)at.removeEventListener(type, held);
235
+ root.style.removeProperty(VIEWPORT);
236
+ };
237
+ };
238
+ /** The lines, the newest last, with what it is doing now under them;
239
+ * `Conversation.Box` is where a person writes to it. Showing nothing at all,
240
+ * no line, no way to earlier ones and nothing going on, it is marked
241
+ * `data-empty`, for its owner's empty state. */ export let Conversation = Object.assign(({ e, onChange, state, lines, display, beforeLines, now, earlier, more, pane, news, ...rest })=>{
242
+ let { take = TAKE, away = false } = conversingOf(e);
243
+ let clock = useNow();
244
+ let previous = useRef(null);
245
+ let permanent = lines.filter((line)=>!line.transient);
246
+ // The initial window limits what a fresh view draws. Keep the rows this
247
+ // reader has already seen as messages arrive at its other end.
248
+ let start = permanent.findIndex((line)=>previous.current?.visible.has(line.id));
249
+ let drawn = shown(permanent, start < 0 ? take : Math.max(take, permanent.length - start), earlier);
250
+ let visible = new Set(drawn.lines.map((line)=>line.id));
251
+ let durable = permanent.flatMap((line)=>line.of ?? [
252
+ line.id
253
+ ]);
254
+ let activity = lines.filter((line)=>line.transient);
255
+ let [unread, setUnread] = useState(false);
256
+ let kept = new Set([
257
+ ...drawn.lines,
258
+ ...activity
259
+ ].filter((line)=>line.html != null).map((line)=>`row-${line.id}`));
260
+ let root = useRef(null);
261
+ // What the listeners read: the latest of what it was given, the place
262
+ // that scrolls, and where the reader last was in it.
263
+ let at = useRef({
264
+ e,
265
+ onChange,
266
+ state,
267
+ kept,
268
+ lines,
269
+ news,
270
+ away,
271
+ pane: null,
272
+ list: null,
273
+ y: 0,
274
+ hidden: 0,
275
+ take,
276
+ asked: 0,
277
+ older: ()=>{}
278
+ });
279
+ at.current = {
280
+ ...at.current,
281
+ e,
282
+ onChange,
283
+ state,
284
+ kept,
285
+ lines,
286
+ news
287
+ };
288
+ let fromServer = (target)=>{
289
+ // A grouped line can hold rows of its own, including a sub-thread.
290
+ let row = target.closest?.('.Transcript_Row');
291
+ while(row && root.current?.contains(row)){
292
+ if (at.current.kept.has(row.id)) return true;
293
+ row = row.parentElement?.closest('.Transcript_Row') ?? null;
294
+ }
295
+ return false;
296
+ };
297
+ let say = (away)=>{
298
+ if (away == at.current.away) return;
299
+ at.current.away = away;
300
+ at.current.onChange(conversed(at.current.e, {
301
+ away
302
+ }));
303
+ };
304
+ // A conversation standing hidden (another view of its page showing) moves
305
+ // nothing: the pane it shares is that view's.
306
+ let unseen = ()=>!!root.current?.closest('[hidden]');
307
+ let covered = ()=>{
308
+ let el = root.current;
309
+ if (!el) return false;
310
+ let address = addressed(el);
311
+ return address && !el.contains(address);
312
+ };
313
+ let newest = (slide = false)=>at.current.list?.newest(slide);
314
+ // A line kept as the server drew it holds folds and marks no state drew:
315
+ // each is opened or closed as the page holds it.
316
+ useLayoutEffect(()=>{
317
+ let el = root.current;
318
+ if (!el || !state) return;
319
+ for (let fold of el.querySelectorAll('[data-disclosure]')){
320
+ if (!fromServer(fold)) continue;
321
+ let open = isOpen(state(fold.getAttribute('data-disclosure')));
322
+ if (open != fold.hasAttribute('open')) fold.toggleAttribute('open', open);
323
+ }
324
+ for (let mark of el.querySelectorAll('[data-disclosure-mark]')){
325
+ if (!fromServer(mark)) continue;
326
+ let open = isOpen(state(mark.getAttribute('data-disclosure-mark')));
327
+ mark.setAttribute('aria-expanded', String(open));
328
+ }
329
+ });
330
+ // Earlier lines are put above where the reader is, who stays there
331
+ // (`anchored`).
332
+ let older = ()=>{
333
+ // Away first, so leaving the newest line is said once, with the take.
334
+ at.current.away = true;
335
+ at.current.list?.read(false);
336
+ onChange(conversed(e, {
337
+ take: Math.max(take, drawn.lines.length) + TAKE,
338
+ away: true
339
+ }));
340
+ };
341
+ at.current = {
342
+ ...at.current,
343
+ hidden: drawn.hidden + Number(!!more),
344
+ take,
345
+ older
346
+ };
347
+ // Set up before the first paint, so it is first seen at the newest.
348
+ useLayoutEffect(()=>{
349
+ let el = root.current;
350
+ let win = el?.ownerDocument.defaultView;
351
+ if (!el || !win) return;
352
+ let p = pane?.() ?? scroller(el);
353
+ at.current.pane = p;
354
+ let unfit = p == paged(el.ownerDocument) ? ()=>{} : fit(el.ownerDocument);
355
+ let list = anchored(p, {
356
+ content: el,
357
+ rows: ()=>rowsOf(el),
358
+ follow: !at.current.away,
359
+ onFollow: (follow)=>say(!follow),
360
+ counts: (row)=>{
361
+ let { lines, news } = at.current;
362
+ let line = lines.find((l)=>`row-${l.id}` == row.id);
363
+ return !!line && (news?.(line) ?? true);
364
+ },
365
+ onUnseen: setUnread,
366
+ idle: ()=>unseen() || !!covered()
367
+ });
368
+ at.current.list = list;
369
+ let opened = ()=>{
370
+ let line = addressed(el);
371
+ if (!line || !el.contains(line)) return void newest();
372
+ // A copied link can name an entry within an activity fold.
373
+ for(let fold = line.closest('details'); fold; fold = fold.parentElement?.closest('details') ?? null){
374
+ if (fold.open) continue;
375
+ fold.open = true;
376
+ let eid = fold.getAttribute('data-disclosure');
377
+ if (eid) {
378
+ queueMicrotask(()=>{
379
+ if (!root.current) return;
380
+ let was = at.current.state?.(eid) ?? {
381
+ entity: {
382
+ eid
383
+ }
384
+ };
385
+ if (!isOpen(was)) at.current.onChange(disclosed(was, true));
386
+ });
387
+ }
388
+ }
389
+ line.scrollIntoView({
390
+ block: 'center',
391
+ behavior: 'instant'
392
+ });
393
+ at.current.y = p.scrollTop;
394
+ list.read();
395
+ };
396
+ opened();
397
+ let scroll = ()=>{
398
+ if (covered() || unseen()) return;
399
+ let now = p.scrollTop;
400
+ let was = at.current.y;
401
+ at.current.y = now;
402
+ // Near the oldest drawn, the next earlier lines come in, once a take.
403
+ let { hidden, take, asked } = at.current;
404
+ if (now < was && now < NEAR && hidden && asked != take) {
405
+ at.current.asked = take;
406
+ at.current.older();
407
+ }
408
+ };
409
+ let hash = ()=>{
410
+ if (addressed(el)) opened();
411
+ else if (!at.current.away) newest();
412
+ };
413
+ // A fold of a line kept as the server drew it that the browser opened or
414
+ // closed by itself (a find in the page), which the page then holds so;
415
+ // one drawn from its state only says what it was told.
416
+ let toggled = (ev)=>{
417
+ let fold = ev.target;
418
+ if (!fromServer(fold)) return;
419
+ let eid = fold.getAttribute?.('data-disclosure');
420
+ if (!eid) return;
421
+ let open = fold.hasAttribute('open');
422
+ let was = at.current.state?.(eid) ?? {
423
+ entity: {
424
+ eid
425
+ }
426
+ };
427
+ if (isOpen(was) != open) at.current.onChange(disclosed(was, open));
428
+ };
429
+ // A press on such a fold's summary, or on a mark, which no script drawn
430
+ // there hears: the page holds the other state at once, as a fold drawn
431
+ // from its state does. Left to the browser, the fold would change first
432
+ // and the page hear of it later, and a drawing in between (a scroll, a
433
+ // word streamed) would put it back as the page last held it. Live
434
+ // components handle their own events through their renderer.
435
+ let pressed = (ev)=>{
436
+ if (ev.defaultPrevented) return;
437
+ let target = ev.target;
438
+ if (!fromServer(target)) return;
439
+ let mark = target.closest?.('[data-disclosure-mark]');
440
+ let summary = mark ? null : target.closest?.('summary');
441
+ let fold = summary?.parentElement;
442
+ // A link or button in a summary is its own to press.
443
+ let own = summary?.contains(target.closest('a, button'));
444
+ let eid = mark?.getAttribute('data-disclosure-mark') ?? (own ? null : fold?.getAttribute('data-disclosure'));
445
+ if (!eid) return;
446
+ if (!mark) ev.preventDefault();
447
+ let was = at.current.state?.(eid) ?? {
448
+ entity: {
449
+ eid
450
+ }
451
+ };
452
+ at.current.onChange(disclosed(was, !isOpen(was)));
453
+ };
454
+ el.addEventListener('toggle', toggled, true);
455
+ el.addEventListener('click', pressed);
456
+ let scrolls = p == paged(el.ownerDocument) ? el.ownerDocument : p;
457
+ scrolls.addEventListener('scroll', scroll, {
458
+ passive: true
459
+ });
460
+ win.addEventListener('hashchange', hash);
461
+ return ()=>{
462
+ el.removeEventListener('toggle', toggled, true);
463
+ el.removeEventListener('click', pressed);
464
+ scrolls.removeEventListener('scroll', scroll);
465
+ win.removeEventListener('hashchange', hash);
466
+ list.stop();
467
+ at.current.list = null;
468
+ unfit();
469
+ };
470
+ }, []);
471
+ useLayoutEffect(()=>{
472
+ let was = previous.current;
473
+ previous.current = {
474
+ visible,
475
+ durable: new Set(durable),
476
+ activity: new Set(activity.map((line)=>line.id))
477
+ };
478
+ // History may be prepended. It is an arrival only when a new line
479
+ // follows the first line we knew, or work in the slot has settled.
480
+ let known = durable.findIndex((id)=>was?.durable.has(id));
481
+ let arrived = !!was && durable.some((id, i)=>!was.durable.has(id) && (i > known || was.activity.has(id)));
482
+ let returning = at.current.away && !away;
483
+ at.current.away = away;
484
+ if (away) {
485
+ if (at.current.list?.follows()) at.current.list.read(false);
486
+ at.current.list?.hold();
487
+ } else {
488
+ if (arrived || returning) newest(arrived);
489
+ else at.current.list?.hold();
490
+ }
491
+ });
492
+ return /*#__PURE__*/ h(Held.Provider, {
493
+ value: {
494
+ state,
495
+ onChange
496
+ }
497
+ }, /*#__PURE__*/ h(Transcript, {
498
+ ...rest,
499
+ elRef: root,
500
+ // Nothing drawn, nothing earlier to bring and nothing going on: its
501
+ // owner's empty state shows only then.
502
+ 'data-empty': drawn.lines.length || drawn.hidden || more || now != null || activity.length ? undefined : ''
503
+ }, drawn.hidden || more ? /*#__PURE__*/ h(Button, {
504
+ type: 'button',
505
+ mod: 'quiet',
506
+ onClick: older
507
+ }, more ? 'Show earlier' : `Show ${drawn.hidden} earlier`) : null, beforeLines, /*#__PURE__*/ h(Transcript.Lines, {}, display ? display(drawn.lines, transcriptRow, clock) : datedRows(drawn.lines, transcriptRow, clock)), /*#__PURE__*/ h(Transcript.Activity, {}, now == null ? null : /*#__PURE__*/ h(Transcript.Status, {
508
+ role: 'status'
509
+ }, now), activityRows(lines, visible)), away ? /*#__PURE__*/ h(Transcript.Jump, {}, /*#__PURE__*/ h(Transcript.Newest, {
510
+ type: 'button',
511
+ mod: 'quiet',
512
+ onClick: ()=>{
513
+ say(false);
514
+ newest();
515
+ }
516
+ }, unread ? 'New message' : 'Newest')) : null));
517
+ }, {
518
+ Box
519
+ });
520
+ //# sourceMappingURL=Conversation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Conversation.js","sources":["./Conversation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8BC,GAED,uCAAuC,GAAG,SACxC,aAAa,EACb,iBAAiB,CAAC,EAGlB,UAAU,EACV,eAAe,EACf,MAAM,EACN,QAAQ,gBACe;AAEzB,SAAS,UAAU,oCAAyC;AAC5D,SAAS,MAAM,EAAE,UAAU,8BAAmC;AAC9D,SAAS,MAAM,6BAAkC;AACjD,SAAwB,SAAS,iCAA4C;AAC7E,SAAwB,QAAQ,EAAE,QAAQ,wBAAuB;AACjE,SACE,YAAY,EAEZ,SAAS,EACT,SAAS,iCACoB;AAC/B,SAAS,GAAG,+BAA6C;AACzD,SAEE,SAAS,EACT,UAAU,EACV,YAAY,EACZ,cAAc,EAEd,MAAM,EACN,OAAO,EACP,SAAS,0BACa;AAExB;;;mCAGmC,GACnC,OAAO,IAAI,OAAO,GA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