@kujoforall/paper-ui 0.0.0-stage → 0.1.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 (366) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/LICENSE +21 -0
  3. package/README.md +252 -2
  4. package/dist/components/editor/block-text.d.ts +8 -0
  5. package/dist/components/editor/block-text.d.ts.map +1 -0
  6. package/dist/components/editor/block-text.js +213 -0
  7. package/dist/components/editor/block-text.js.map +1 -0
  8. package/dist/components/editor/blocks.d.ts +33 -0
  9. package/dist/components/editor/blocks.d.ts.map +1 -0
  10. package/dist/components/editor/blocks.js +187 -0
  11. package/dist/components/editor/blocks.js.map +1 -0
  12. package/dist/components/editor/document-editor.d.ts +27 -0
  13. package/dist/components/editor/document-editor.d.ts.map +1 -0
  14. package/dist/components/editor/document-editor.js +40 -0
  15. package/dist/components/editor/document-editor.js.map +1 -0
  16. package/dist/components/editor/document-view.d.ts +22 -0
  17. package/dist/components/editor/document-view.d.ts.map +1 -0
  18. package/dist/components/editor/document-view.js +105 -0
  19. package/dist/components/editor/document-view.js.map +1 -0
  20. package/dist/components/editor/editor-state.d.ts +100 -0
  21. package/dist/components/editor/editor-state.d.ts.map +1 -0
  22. package/dist/components/editor/editor-state.js +192 -0
  23. package/dist/components/editor/editor-state.js.map +1 -0
  24. package/dist/components/editor/extensions/spoiler.d.ts +8 -0
  25. package/dist/components/editor/extensions/spoiler.d.ts.map +1 -0
  26. package/dist/components/editor/extensions/spoiler.js +36 -0
  27. package/dist/components/editor/extensions/spoiler.js.map +1 -0
  28. package/dist/components/editor/index.d.ts +9 -0
  29. package/dist/components/editor/index.d.ts.map +1 -0
  30. package/dist/components/editor/index.js +9 -0
  31. package/dist/components/editor/index.js.map +1 -0
  32. package/dist/components/editor/kinds.d.ts +99 -0
  33. package/dist/components/editor/kinds.d.ts.map +1 -0
  34. package/dist/components/editor/kinds.js +74 -0
  35. package/dist/components/editor/kinds.js.map +1 -0
  36. package/dist/components/sketch/rough.d.ts +38 -0
  37. package/dist/components/sketch/rough.d.ts.map +1 -0
  38. package/dist/components/sketch/rough.js +57 -0
  39. package/dist/components/sketch/rough.js.map +1 -0
  40. package/dist/components/ui/accent-picker.d.ts +2 -0
  41. package/dist/components/ui/accent-picker.d.ts.map +1 -0
  42. package/dist/components/ui/accent-picker.js +44 -0
  43. package/dist/components/ui/accent-picker.js.map +1 -0
  44. package/dist/components/ui/address-field.d.ts +10 -0
  45. package/dist/components/ui/address-field.d.ts.map +1 -0
  46. package/dist/components/ui/address-field.js +24 -0
  47. package/dist/components/ui/address-field.js.map +1 -0
  48. package/dist/components/ui/app-shell.d.ts +25 -0
  49. package/dist/components/ui/app-shell.d.ts.map +1 -0
  50. package/dist/components/ui/app-shell.js +69 -0
  51. package/dist/components/ui/app-shell.js.map +1 -0
  52. package/dist/components/ui/badge.d.ts +19 -0
  53. package/dist/components/ui/badge.d.ts.map +1 -0
  54. package/dist/components/ui/badge.js +62 -0
  55. package/dist/components/ui/badge.js.map +1 -0
  56. package/dist/components/ui/breadcrumbs.d.ts +10 -0
  57. package/dist/components/ui/breadcrumbs.d.ts.map +1 -0
  58. package/dist/components/ui/breadcrumbs.js +9 -0
  59. package/dist/components/ui/breadcrumbs.js.map +1 -0
  60. package/dist/components/ui/button.d.ts +13 -0
  61. package/dist/components/ui/button.d.ts.map +1 -0
  62. package/dist/components/ui/button.js +45 -0
  63. package/dist/components/ui/button.js.map +1 -0
  64. package/dist/components/ui/calendar.d.ts +5 -0
  65. package/dist/components/ui/calendar.d.ts.map +1 -0
  66. package/dist/components/ui/calendar.js +64 -0
  67. package/dist/components/ui/calendar.js.map +1 -0
  68. package/dist/components/ui/callout.d.ts +13 -0
  69. package/dist/components/ui/callout.d.ts.map +1 -0
  70. package/dist/components/ui/callout.js +27 -0
  71. package/dist/components/ui/callout.js.map +1 -0
  72. package/dist/components/ui/card.d.ts +13 -0
  73. package/dist/components/ui/card.d.ts.map +1 -0
  74. package/dist/components/ui/card.js +27 -0
  75. package/dist/components/ui/card.js.map +1 -0
  76. package/dist/components/ui/checkbox.d.ts +6 -0
  77. package/dist/components/ui/checkbox.d.ts.map +1 -0
  78. package/dist/components/ui/checkbox.js +10 -0
  79. package/dist/components/ui/checkbox.js.map +1 -0
  80. package/dist/components/ui/command-menu.d.ts +15 -0
  81. package/dist/components/ui/command-menu.d.ts.map +1 -0
  82. package/dist/components/ui/command-menu.js +24 -0
  83. package/dist/components/ui/command-menu.js.map +1 -0
  84. package/dist/components/ui/date-picker.d.ts +35 -0
  85. package/dist/components/ui/date-picker.d.ts.map +1 -0
  86. package/dist/components/ui/date-picker.js +56 -0
  87. package/dist/components/ui/date-picker.js.map +1 -0
  88. package/dist/components/ui/date-time-picker.d.ts +19 -0
  89. package/dist/components/ui/date-time-picker.d.ts.map +1 -0
  90. package/dist/components/ui/date-time-picker.js +32 -0
  91. package/dist/components/ui/date-time-picker.js.map +1 -0
  92. package/dist/components/ui/dialog.d.ts +17 -0
  93. package/dist/components/ui/dialog.d.ts.map +1 -0
  94. package/dist/components/ui/dialog.js +33 -0
  95. package/dist/components/ui/dialog.js.map +1 -0
  96. package/dist/components/ui/dropdown-menu.d.ts +20 -0
  97. package/dist/components/ui/dropdown-menu.d.ts.map +1 -0
  98. package/dist/components/ui/dropdown-menu.js +56 -0
  99. package/dist/components/ui/dropdown-menu.js.map +1 -0
  100. package/dist/components/ui/editable-text.d.ts +17 -0
  101. package/dist/components/ui/editable-text.d.ts.map +1 -0
  102. package/dist/components/ui/editable-text.js +68 -0
  103. package/dist/components/ui/editable-text.js.map +1 -0
  104. package/dist/components/ui/field-button.d.ts +14 -0
  105. package/dist/components/ui/field-button.d.ts.map +1 -0
  106. package/dist/components/ui/field-button.js +16 -0
  107. package/dist/components/ui/field-button.js.map +1 -0
  108. package/dist/components/ui/file-preview.d.ts +5 -0
  109. package/dist/components/ui/file-preview.d.ts.map +1 -0
  110. package/dist/components/ui/file-preview.js +66 -0
  111. package/dist/components/ui/file-preview.js.map +1 -0
  112. package/dist/components/ui/file-uploader.d.ts +39 -0
  113. package/dist/components/ui/file-uploader.d.ts.map +1 -0
  114. package/dist/components/ui/file-uploader.js +110 -0
  115. package/dist/components/ui/file-uploader.js.map +1 -0
  116. package/dist/components/ui/handle-row.d.ts +15 -0
  117. package/dist/components/ui/handle-row.d.ts.map +1 -0
  118. package/dist/components/ui/handle-row.js +41 -0
  119. package/dist/components/ui/handle-row.js.map +1 -0
  120. package/dist/components/ui/image-block.d.ts +31 -0
  121. package/dist/components/ui/image-block.d.ts.map +1 -0
  122. package/dist/components/ui/image-block.js +103 -0
  123. package/dist/components/ui/image-block.js.map +1 -0
  124. package/dist/components/ui/image-card.d.ts +17 -0
  125. package/dist/components/ui/image-card.d.ts.map +1 -0
  126. package/dist/components/ui/image-card.js +38 -0
  127. package/dist/components/ui/image-card.js.map +1 -0
  128. package/dist/components/ui/image-viewer.d.ts +31 -0
  129. package/dist/components/ui/image-viewer.d.ts.map +1 -0
  130. package/dist/components/ui/image-viewer.js +81 -0
  131. package/dist/components/ui/image-viewer.js.map +1 -0
  132. package/dist/components/ui/image.d.ts +11 -0
  133. package/dist/components/ui/image.d.ts.map +1 -0
  134. package/dist/components/ui/image.js +32 -0
  135. package/dist/components/ui/image.js.map +1 -0
  136. package/dist/components/ui/index.d.ts +49 -0
  137. package/dist/components/ui/index.d.ts.map +1 -0
  138. package/dist/components/ui/index.js +49 -0
  139. package/dist/components/ui/index.js.map +1 -0
  140. package/dist/components/ui/input.d.ts +16 -0
  141. package/dist/components/ui/input.d.ts.map +1 -0
  142. package/dist/components/ui/input.js +32 -0
  143. package/dist/components/ui/input.js.map +1 -0
  144. package/dist/components/ui/link-block.d.ts +13 -0
  145. package/dist/components/ui/link-block.d.ts.map +1 -0
  146. package/dist/components/ui/link-block.js +21 -0
  147. package/dist/components/ui/link-block.js.map +1 -0
  148. package/dist/components/ui/mac-card.d.ts +15 -0
  149. package/dist/components/ui/mac-card.d.ts.map +1 -0
  150. package/dist/components/ui/mac-card.js +9 -0
  151. package/dist/components/ui/mac-card.js.map +1 -0
  152. package/dist/components/ui/nav-tree.d.ts +16 -0
  153. package/dist/components/ui/nav-tree.d.ts.map +1 -0
  154. package/dist/components/ui/nav-tree.js +34 -0
  155. package/dist/components/ui/nav-tree.js.map +1 -0
  156. package/dist/components/ui/page.d.ts +12 -0
  157. package/dist/components/ui/page.d.ts.map +1 -0
  158. package/dist/components/ui/page.js +15 -0
  159. package/dist/components/ui/page.js.map +1 -0
  160. package/dist/components/ui/popover.d.ts +8 -0
  161. package/dist/components/ui/popover.d.ts.map +1 -0
  162. package/dist/components/ui/popover.js +18 -0
  163. package/dist/components/ui/popover.js.map +1 -0
  164. package/dist/components/ui/progress.d.ts +9 -0
  165. package/dist/components/ui/progress.d.ts.map +1 -0
  166. package/dist/components/ui/progress.js +9 -0
  167. package/dist/components/ui/progress.js.map +1 -0
  168. package/dist/components/ui/property.d.ts +15 -0
  169. package/dist/components/ui/property.d.ts.map +1 -0
  170. package/dist/components/ui/property.js +34 -0
  171. package/dist/components/ui/property.js.map +1 -0
  172. package/dist/components/ui/segmented.d.ts +13 -0
  173. package/dist/components/ui/segmented.d.ts.map +1 -0
  174. package/dist/components/ui/segmented.js +10 -0
  175. package/dist/components/ui/segmented.js.map +1 -0
  176. package/dist/components/ui/select-menu.d.ts +10 -0
  177. package/dist/components/ui/select-menu.d.ts.map +1 -0
  178. package/dist/components/ui/select-menu.js +10 -0
  179. package/dist/components/ui/select-menu.js.map +1 -0
  180. package/dist/components/ui/select.d.ts +11 -0
  181. package/dist/components/ui/select.d.ts.map +1 -0
  182. package/dist/components/ui/select.js +31 -0
  183. package/dist/components/ui/select.js.map +1 -0
  184. package/dist/components/ui/selection-bar.d.ts +12 -0
  185. package/dist/components/ui/selection-bar.d.ts.map +1 -0
  186. package/dist/components/ui/selection-bar.js +15 -0
  187. package/dist/components/ui/selection-bar.js.map +1 -0
  188. package/dist/components/ui/separator.d.ts +4 -0
  189. package/dist/components/ui/separator.d.ts.map +1 -0
  190. package/dist/components/ui/separator.js +12 -0
  191. package/dist/components/ui/separator.js.map +1 -0
  192. package/dist/components/ui/spotlight.d.ts +23 -0
  193. package/dist/components/ui/spotlight.d.ts.map +1 -0
  194. package/dist/components/ui/spotlight.js +107 -0
  195. package/dist/components/ui/spotlight.js.map +1 -0
  196. package/dist/components/ui/stat-tile.d.ts +8 -0
  197. package/dist/components/ui/stat-tile.d.ts.map +1 -0
  198. package/dist/components/ui/stat-tile.js +9 -0
  199. package/dist/components/ui/stat-tile.js.map +1 -0
  200. package/dist/components/ui/step-dialog.d.ts +20 -0
  201. package/dist/components/ui/step-dialog.d.ts.map +1 -0
  202. package/dist/components/ui/step-dialog.js +36 -0
  203. package/dist/components/ui/step-dialog.js.map +1 -0
  204. package/dist/components/ui/table.d.ts +8 -0
  205. package/dist/components/ui/table.d.ts.map +1 -0
  206. package/dist/components/ui/table.js +23 -0
  207. package/dist/components/ui/table.js.map +1 -0
  208. package/dist/components/ui/theme-toggle.d.ts +2 -0
  209. package/dist/components/ui/theme-toggle.d.ts.map +1 -0
  210. package/dist/components/ui/theme-toggle.js +49 -0
  211. package/dist/components/ui/theme-toggle.js.map +1 -0
  212. package/dist/components/ui/time-picker.d.ts +21 -0
  213. package/dist/components/ui/time-picker.d.ts.map +1 -0
  214. package/dist/components/ui/time-picker.js +63 -0
  215. package/dist/components/ui/time-picker.js.map +1 -0
  216. package/dist/components/ui/tooltip.d.ts +15 -0
  217. package/dist/components/ui/tooltip.d.ts.map +1 -0
  218. package/dist/components/ui/tooltip.js +21 -0
  219. package/dist/components/ui/tooltip.js.map +1 -0
  220. package/dist/components/ui/typography.d.ts +34 -0
  221. package/dist/components/ui/typography.d.ts.map +1 -0
  222. package/dist/components/ui/typography.js +72 -0
  223. package/dist/components/ui/typography.js.map +1 -0
  224. package/dist/components/ui/video-block.d.ts +14 -0
  225. package/dist/components/ui/video-block.d.ts.map +1 -0
  226. package/dist/components/ui/video-block.js +18 -0
  227. package/dist/components/ui/video-block.js.map +1 -0
  228. package/dist/hooks/use-save-queue.d.ts +13 -0
  229. package/dist/hooks/use-save-queue.d.ts.map +1 -0
  230. package/dist/hooks/use-save-queue.js +45 -0
  231. package/dist/hooks/use-save-queue.js.map +1 -0
  232. package/dist/hooks/use-selection.d.ts +10 -0
  233. package/dist/hooks/use-selection.d.ts.map +1 -0
  234. package/dist/hooks/use-selection.js +43 -0
  235. package/dist/hooks/use-selection.js.map +1 -0
  236. package/dist/hooks/use-shared-transition.d.ts +3 -0
  237. package/dist/hooks/use-shared-transition.d.ts.map +1 -0
  238. package/dist/hooks/use-shared-transition.js +38 -0
  239. package/dist/hooks/use-shared-transition.js.map +1 -0
  240. package/dist/hooks/use-upload-queue.d.ts +22 -0
  241. package/dist/hooks/use-upload-queue.d.ts.map +1 -0
  242. package/dist/hooks/use-upload-queue.js +78 -0
  243. package/dist/hooks/use-upload-queue.js.map +1 -0
  244. package/dist/lib/accent.d.ts +5 -0
  245. package/dist/lib/accent.d.ts.map +1 -0
  246. package/dist/lib/accent.js +10 -0
  247. package/dist/lib/accent.js.map +1 -0
  248. package/dist/lib/bento.d.ts +17 -0
  249. package/dist/lib/bento.d.ts.map +1 -0
  250. package/dist/lib/bento.js +92 -0
  251. package/dist/lib/bento.js.map +1 -0
  252. package/dist/lib/dates.d.ts +14 -0
  253. package/dist/lib/dates.d.ts.map +1 -0
  254. package/dist/lib/dates.js +34 -0
  255. package/dist/lib/dates.js.map +1 -0
  256. package/dist/lib/document.d.ts +79 -0
  257. package/dist/lib/document.d.ts.map +1 -0
  258. package/dist/lib/document.js +11 -0
  259. package/dist/lib/document.js.map +1 -0
  260. package/dist/lib/embed.d.ts +14 -0
  261. package/dist/lib/embed.d.ts.map +1 -0
  262. package/dist/lib/embed.js +63 -0
  263. package/dist/lib/embed.js.map +1 -0
  264. package/dist/lib/files.d.ts +23 -0
  265. package/dist/lib/files.d.ts.map +1 -0
  266. package/dist/lib/files.js +69 -0
  267. package/dist/lib/files.js.map +1 -0
  268. package/dist/lib/justified.d.ts +50 -0
  269. package/dist/lib/justified.d.ts.map +1 -0
  270. package/dist/lib/justified.js +78 -0
  271. package/dist/lib/justified.js.map +1 -0
  272. package/dist/lib/rich-text-dom.d.ts +14 -0
  273. package/dist/lib/rich-text-dom.d.ts.map +1 -0
  274. package/dist/lib/rich-text-dom.js +143 -0
  275. package/dist/lib/rich-text-dom.js.map +1 -0
  276. package/dist/lib/rich-text.d.ts +15 -0
  277. package/dist/lib/rich-text.d.ts.map +1 -0
  278. package/dist/lib/rich-text.js +35 -0
  279. package/dist/lib/rich-text.js.map +1 -0
  280. package/dist/lib/spotlight.d.ts +22 -0
  281. package/dist/lib/spotlight.d.ts.map +1 -0
  282. package/dist/lib/spotlight.js +66 -0
  283. package/dist/lib/spotlight.js.map +1 -0
  284. package/dist/lib/tree.d.ts +17 -0
  285. package/dist/lib/tree.d.ts.map +1 -0
  286. package/dist/lib/tree.js +35 -0
  287. package/dist/lib/tree.js.map +1 -0
  288. package/dist/lib/utils.d.ts +3 -0
  289. package/dist/lib/utils.d.ts.map +1 -0
  290. package/dist/lib/utils.js +6 -0
  291. package/dist/lib/utils.js.map +1 -0
  292. package/dist/styles/notion.css +526 -0
  293. package/package.json +106 -5
  294. package/src/components/editor/block-text.tsx +230 -0
  295. package/src/components/editor/blocks.tsx +368 -0
  296. package/src/components/editor/document-editor.tsx +101 -0
  297. package/src/components/editor/document-view.tsx +192 -0
  298. package/src/components/editor/editor-state.tsx +270 -0
  299. package/src/components/editor/extensions/spoiler.tsx +76 -0
  300. package/src/components/editor/index.ts +9 -0
  301. package/src/components/editor/kinds.ts +158 -0
  302. package/src/components/sketch/rough.tsx +90 -0
  303. package/src/components/ui/accent-picker.tsx +72 -0
  304. package/src/components/ui/address-field.tsx +57 -0
  305. package/src/components/ui/app-shell.tsx +138 -0
  306. package/src/components/ui/badge.tsx +81 -0
  307. package/src/components/ui/breadcrumbs.tsx +25 -0
  308. package/src/components/ui/button.tsx +73 -0
  309. package/src/components/ui/calendar.tsx +100 -0
  310. package/src/components/ui/callout.tsx +62 -0
  311. package/src/components/ui/card.tsx +90 -0
  312. package/src/components/ui/checkbox.tsx +32 -0
  313. package/src/components/ui/command-menu.tsx +72 -0
  314. package/src/components/ui/date-picker.tsx +170 -0
  315. package/src/components/ui/date-time-picker.tsx +117 -0
  316. package/src/components/ui/dialog.tsx +124 -0
  317. package/src/components/ui/dropdown-menu.tsx +183 -0
  318. package/src/components/ui/editable-text.tsx +109 -0
  319. package/src/components/ui/field-button.tsx +68 -0
  320. package/src/components/ui/file-preview.tsx +80 -0
  321. package/src/components/ui/file-uploader.tsx +376 -0
  322. package/src/components/ui/handle-row.tsx +116 -0
  323. package/src/components/ui/image-block.tsx +238 -0
  324. package/src/components/ui/image-card.tsx +102 -0
  325. package/src/components/ui/image-viewer.tsx +187 -0
  326. package/src/components/ui/image.tsx +96 -0
  327. package/src/components/ui/index.ts +83 -0
  328. package/src/components/ui/input.tsx +99 -0
  329. package/src/components/ui/link-block.tsx +82 -0
  330. package/src/components/ui/mac-card.tsx +46 -0
  331. package/src/components/ui/nav-tree.tsx +86 -0
  332. package/src/components/ui/page.tsx +25 -0
  333. package/src/components/ui/popover.tsx +42 -0
  334. package/src/components/ui/progress.tsx +36 -0
  335. package/src/components/ui/property.tsx +64 -0
  336. package/src/components/ui/segmented.tsx +42 -0
  337. package/src/components/ui/select-menu.tsx +46 -0
  338. package/src/components/ui/select.tsx +124 -0
  339. package/src/components/ui/selection-bar.tsx +50 -0
  340. package/src/components/ui/separator.tsx +30 -0
  341. package/src/components/ui/spotlight.tsx +222 -0
  342. package/src/components/ui/stat-tile.tsx +25 -0
  343. package/src/components/ui/step-dialog.tsx +104 -0
  344. package/src/components/ui/table.tsx +42 -0
  345. package/src/components/ui/theme-toggle.tsx +101 -0
  346. package/src/components/ui/time-picker.tsx +173 -0
  347. package/src/components/ui/tooltip.tsx +64 -0
  348. package/src/components/ui/typography.tsx +168 -0
  349. package/src/components/ui/video-block.tsx +60 -0
  350. package/src/hooks/use-save-queue.ts +66 -0
  351. package/src/hooks/use-selection.ts +44 -0
  352. package/src/hooks/use-shared-transition.ts +40 -0
  353. package/src/hooks/use-upload-queue.ts +111 -0
  354. package/src/lib/accent.ts +11 -0
  355. package/src/lib/bento.ts +87 -0
  356. package/src/lib/dates.ts +39 -0
  357. package/src/lib/document.ts +55 -0
  358. package/src/lib/embed.ts +62 -0
  359. package/src/lib/files.ts +73 -0
  360. package/src/lib/justified.ts +106 -0
  361. package/src/lib/rich-text-dom.ts +136 -0
  362. package/src/lib/rich-text.ts +50 -0
  363. package/src/lib/spotlight.ts +78 -0
  364. package/src/lib/tree.ts +41 -0
  365. package/src/lib/utils.ts +6 -0
  366. package/src/styles/notion.css +526 -0
@@ -0,0 +1,101 @@
1
+ "use client";
2
+
3
+ import { useEffect, useState } from "react";
4
+ import { AnimatePresence, motion, useAnimationControls } from "framer-motion";
5
+ import { Moon, Sun } from "lucide-react";
6
+ import { Button } from "./button.tsx";
7
+ import { cn } from "../../lib/utils.ts";
8
+
9
+ type Theme = "light" | "dark";
10
+
11
+ function getResolved(): Theme {
12
+ if (typeof document === "undefined") return "light";
13
+ // Read what the inline THEME_INIT_SCRIPT already applied to <html>
14
+ return document.documentElement.classList.contains("dark")
15
+ ? "dark"
16
+ : "light";
17
+ }
18
+
19
+ function apply(theme: Theme) {
20
+ const root = document.documentElement;
21
+ root.classList.remove("light", "dark");
22
+ root.classList.add(theme);
23
+ root.setAttribute("data-theme", theme);
24
+ root.style.colorScheme = theme;
25
+ window.localStorage.setItem("theme", theme);
26
+ }
27
+
28
+ export function ThemeToggle() {
29
+ const [mounted, setMounted] = useState(false);
30
+ const [theme, setTheme] = useState<Theme>("light");
31
+ const [fillDark, setFillDark] = useState(false);
32
+ const fillControls = useAnimationControls();
33
+
34
+ useEffect(() => {
35
+ // eslint-disable-next-line react-hooks/set-state-in-effect
36
+ setTheme(getResolved());
37
+ setMounted(true);
38
+ }, []);
39
+
40
+ function toggle() {
41
+ const next: Theme = theme === "dark" ? "light" : "dark";
42
+ setFillDark(next === "dark");
43
+ setTheme(next);
44
+ apply(next);
45
+ // Reset to collapsed then sweep — only on explicit click, never on mount
46
+ fillControls.set({ clipPath: "circle(0% at 100% 0%)" });
47
+ fillControls.start({
48
+ clipPath: "circle(150% at 100% 0%)",
49
+ transition: { duration: 0.45, ease: [0.22, 1, 0.36, 1] },
50
+ });
51
+ }
52
+
53
+ const isDark = theme === "dark";
54
+
55
+ return (
56
+ <Button
57
+ variant="secondary"
58
+ size="icon"
59
+ onClick={toggle}
60
+ aria-label={`Switch to ${isDark ? "light" : "dark"} mode`}
61
+ className="relative overflow-hidden"
62
+ >
63
+ <motion.span
64
+ className={cn(
65
+ "absolute inset-0 rounded-[inherit] pointer-events-none",
66
+ fillDark ? "bg-zinc-900" : "bg-amber-50",
67
+ )}
68
+ initial={{ clipPath: "circle(0% at 100% 0%)" }}
69
+ animate={fillControls}
70
+ />
71
+
72
+ <AnimatePresence mode="wait" initial={false}>
73
+ {!mounted ? (
74
+ <span key="placeholder" className="size-4" />
75
+ ) : isDark ? (
76
+ <motion.span
77
+ key="moon"
78
+ className="z-10 relative"
79
+ initial={{ opacity: 0, rotate: -45, scale: 0.5 }}
80
+ animate={{ opacity: 1, rotate: 0, scale: 1 }}
81
+ exit={{ opacity: 0, rotate: 45, scale: 0.5 }}
82
+ transition={{ duration: 0.15 }}
83
+ >
84
+ <Moon className="size-4 text-indigo-300" />
85
+ </motion.span>
86
+ ) : (
87
+ <motion.span
88
+ key="sun"
89
+ className="z-10 relative"
90
+ initial={{ opacity: 0, rotate: 45, scale: 0.5 }}
91
+ animate={{ opacity: 1, rotate: 0, scale: 1 }}
92
+ exit={{ opacity: 0, rotate: -45, scale: 0.5 }}
93
+ transition={{ duration: 0.15 }}
94
+ >
95
+ <Sun className="size-4 text-amber-600" />
96
+ </motion.span>
97
+ )}
98
+ </AnimatePresence>
99
+ </Button>
100
+ );
101
+ }
@@ -0,0 +1,173 @@
1
+ "use client";
2
+
3
+ import { Clock } from "lucide-react";
4
+ import { useLayoutEffect, useRef, useState, type KeyboardEvent } from "react";
5
+ import { FieldButton, type FieldButtonProps } from "./field-button.tsx";
6
+ import { Popover, PopoverClose, PopoverContent, PopoverTrigger } from "./popover.tsx";
7
+ import { Button } from "./button.tsx";
8
+ import { isTime } from "../../lib/dates.ts";
9
+ import { cn } from "../../lib/utils.ts";
10
+
11
+ const pad = (n: number): string => String(n).padStart(2, "0");
12
+ const HOURS = Array.from({ length: 24 }, (_, hour) => pad(hour));
13
+
14
+ /** Every `step` minutes, plus the one already chosen if it falls between them. */
15
+ function minutesFor(step: number, chosen: string | null): string[] {
16
+ const safe = Number.isInteger(step) && step > 0 && step <= 30 ? step : 5;
17
+ const minutes = new Set<string>();
18
+ for (let minute = 0; minute < 60; minute += safe) minutes.add(pad(minute));
19
+ if (chosen !== null) minutes.add(chosen);
20
+ return [...minutes].sort();
21
+ }
22
+
23
+ /* One scrolling column of a clock. A listbox with one tab stop: arrows move, and
24
+ moving does not choose, so a time can be read off before it is changed. */
25
+ function Column({
26
+ label,
27
+ options,
28
+ value,
29
+ onChange,
30
+ }: {
31
+ label: string;
32
+ options: string[];
33
+ value: string | null;
34
+ onChange: (value: string) => void;
35
+ }) {
36
+ const list = useRef<HTMLDivElement>(null);
37
+
38
+ // Open on the chosen value, centred. Set on the column itself: scrollIntoView
39
+ // would scroll every ancestor too, and the page would jump under the popover.
40
+ useLayoutEffect(() => {
41
+ const el = list.current;
42
+ const chosen = el?.querySelector<HTMLElement>("[aria-selected=true]");
43
+ if (el == null || chosen == null) return;
44
+ el.scrollTop = chosen.offsetTop - el.clientHeight / 2 + chosen.offsetHeight / 2;
45
+ }, []);
46
+
47
+ const move = (event: KeyboardEvent<HTMLDivElement>) => {
48
+ const keys = ["ArrowDown", "ArrowUp", "Home", "End"];
49
+ if (!keys.includes(event.key)) return;
50
+ event.preventDefault();
51
+ const items = [...(list.current?.querySelectorAll<HTMLElement>("[role=option]") ?? [])];
52
+ const at = items.indexOf(document.activeElement as HTMLElement);
53
+ const next =
54
+ event.key === "Home" ? 0 : event.key === "End" ? items.length - 1 : event.key === "ArrowDown" ? at + 1 : at - 1;
55
+ items[Math.max(0, Math.min(items.length - 1, next))]?.focus();
56
+ };
57
+
58
+ const tabStop = value !== null && options.includes(value) ? value : options[0];
59
+
60
+ return (
61
+ <div
62
+ ref={list}
63
+ role="listbox"
64
+ aria-label={label}
65
+ onKeyDown={move}
66
+ className="relative flex h-56 w-14 flex-col gap-0.5 overflow-y-auto overscroll-contain p-1.5 [scrollbar-width:thin]"
67
+ >
68
+ {options.map((option) => (
69
+ <button
70
+ key={option}
71
+ type="button"
72
+ role="option"
73
+ aria-selected={option === value}
74
+ tabIndex={option === tabStop ? 0 : -1}
75
+ onClick={() => onChange(option)}
76
+ className={cn(
77
+ "flex h-7 shrink-0 items-center justify-center rounded-control text-sm tabular-nums cursor-pointer",
78
+ "transition-colors duration-75",
79
+ option === value
80
+ ? "bg-accent font-medium text-accent-ink hover:bg-accent-hover"
81
+ : "text-ink hover:bg-tint-hover",
82
+ )}
83
+ >
84
+ {option}
85
+ </button>
86
+ ))}
87
+ </div>
88
+ );
89
+ }
90
+
91
+ /* Hours beside minutes. Choosing one before the other fills the other in: an hour
92
+ alone is on the hour, a minute alone is in the hour given as `fallbackHour`. */
93
+ export function TimeColumns({
94
+ value,
95
+ onChange,
96
+ minuteStep = 5,
97
+ fallbackHour = "12",
98
+ className,
99
+ }: {
100
+ /** `HH:MM`, 24-hour, or null for none. */
101
+ value: string | null;
102
+ onChange: (value: string) => void;
103
+ minuteStep?: number;
104
+ fallbackHour?: string;
105
+ className?: string;
106
+ }) {
107
+ const [hour, minute] = isTime(value) ? (value.split(":") as [string, string]) : [null, null];
108
+
109
+ return (
110
+ <div className={cn("flex divide-x divide-hairline", className)}>
111
+ <Column label="Hour" options={HOURS} value={hour} onChange={(next) => onChange(`${next}:${minute ?? "00"}`)} />
112
+ <Column
113
+ label="Minute"
114
+ options={minutesFor(minuteStep, minute)}
115
+ value={minute}
116
+ onChange={(next) => onChange(`${hour ?? fallbackHour}:${next}`)}
117
+ />
118
+ </div>
119
+ );
120
+ }
121
+
122
+ export interface TimePickerProps extends Omit<FieldButtonProps, "value" | "onChange" | "children" | "onClear" | "icon"> {
123
+ /** `HH:MM`, 24-hour, or null for none. */
124
+ value: string | null;
125
+ onChange: (value: string | null) => void;
126
+ minuteStep?: number;
127
+ /** Show the cross that empties it. On by default; turn off for a required time. */
128
+ clearable?: boolean;
129
+ /** Sends the value with a form, as a hidden field of this name. */
130
+ name?: string;
131
+ }
132
+
133
+ /* A time of day. The value is a string, `HH:MM`, which is what a form holds and
134
+ what a `time` column takes; anything else passed in shows as empty. */
135
+ export function TimePicker({
136
+ value,
137
+ onChange,
138
+ minuteStep = 5,
139
+ clearable = true,
140
+ placeholder = "Pick a time",
141
+ name,
142
+ ...props
143
+ }: TimePickerProps) {
144
+ const [open, setOpen] = useState(false);
145
+ const time = isTime(value) ? value : null;
146
+
147
+ return (
148
+ <Popover open={open} onOpenChange={setOpen}>
149
+ <PopoverTrigger asChild>
150
+ <FieldButton
151
+ icon={Clock}
152
+ placeholder={placeholder}
153
+ onClear={clearable ? () => onChange(null) : undefined}
154
+ clearLabel="Clear the time"
155
+ {...props}
156
+ >
157
+ {time === null ? null : <span className="tabular-nums">{time}</span>}
158
+ </FieldButton>
159
+ </PopoverTrigger>
160
+ {name !== undefined && <input type="hidden" name={name} value={time ?? ""} />}
161
+ <PopoverContent className="w-auto">
162
+ <TimeColumns value={time} onChange={onChange} minuteStep={minuteStep} />
163
+ <div className="flex justify-end border-hairline border-t p-1.5">
164
+ <PopoverClose asChild>
165
+ <Button variant="ghost" size="sm">
166
+ Done
167
+ </Button>
168
+ </PopoverClose>
169
+ </div>
170
+ </PopoverContent>
171
+ </Popover>
172
+ );
173
+ }
@@ -0,0 +1,64 @@
1
+ "use client";
2
+
3
+ import * as TooltipPrimitive from "@radix-ui/react-tooltip";
4
+ import type { ComponentPropsWithoutRef, ReactNode } from "react";
5
+ import { cn } from "../../lib/utils.ts";
6
+
7
+ /* A tooltip is a small overlay like any other: the theme's own surface and
8
+ ink, lifted by the popover shadow, so it is light in light mode, dark in
9
+ dark, and takes an accent wash with everything else.
10
+
11
+ Until 2026-12-02 it was a dark chip in both modes, to raise contrast. In a
12
+ real app that read as a piece of dark mode left on a light page. */
13
+
14
+ export const TooltipProvider = TooltipPrimitive.Provider;
15
+ export const TooltipRoot = TooltipPrimitive.Root;
16
+ export const TooltipTrigger = TooltipPrimitive.Trigger;
17
+
18
+ export function TooltipContent({
19
+ className,
20
+ sideOffset = 6,
21
+ ...props
22
+ }: ComponentPropsWithoutRef<typeof TooltipPrimitive.Content>) {
23
+ return (
24
+ <TooltipPrimitive.Portal>
25
+ <TooltipPrimitive.Content
26
+ sideOffset={sideOffset}
27
+ className={cn(
28
+ "z-50 bg-surface-overlay shadow-popover px-2 py-1 rounded-control",
29
+ "max-w-56 font-medium text-ink text-caption",
30
+ "data-[state=delayed-open]:animate-fade-in",
31
+ className,
32
+ )}
33
+ {...props}
34
+ />
35
+ </TooltipPrimitive.Portal>
36
+ );
37
+ }
38
+
39
+ /** Convenience wrapper — the common case in one element. */
40
+ export function Tooltip({
41
+ children,
42
+ content,
43
+ side = "top",
44
+ shortcut,
45
+ delayDuration = 400,
46
+ }: {
47
+ children: ReactNode;
48
+ content: ReactNode;
49
+ side?: "top" | "right" | "bottom" | "left";
50
+ shortcut?: string;
51
+ delayDuration?: number;
52
+ }) {
53
+ return (
54
+ <TooltipRoot delayDuration={delayDuration}>
55
+ <TooltipTrigger asChild>{children}</TooltipTrigger>
56
+ <TooltipContent side={side}>
57
+ {content}
58
+ {shortcut && (
59
+ <span className="ml-1.5 text-ink-tertiary">{shortcut}</span>
60
+ )}
61
+ </TooltipContent>
62
+ </TooltipRoot>
63
+ );
64
+ }
@@ -0,0 +1,168 @@
1
+ import { cva, type VariantProps } from "class-variance-authority";
2
+ import type { ComponentPropsWithoutRef, ElementType, ReactNode } from "react";
3
+ import { cn } from "../../lib/utils.ts";
4
+
5
+ /* ────────────────────────────────────────────────────────────────────────
6
+ Typography carries the entire hierarchy in this system. There are no
7
+ boxes around headings, no coloured section bars, no rules above titles.
8
+ Rank is communicated by size, weight and the space above a block — and
9
+ by nothing else. Keep it that way and the UI stays calm as it grows.
10
+ ──────────────────────────────────────────────────────────────────────── */
11
+
12
+ const headingVariants = cva("text-ink font-sans text-balance", {
13
+ variants: {
14
+ level: {
15
+ title: "text-title mt-0 mb-2",
16
+ 1: "text-h1 mt-8 mb-1",
17
+ 2: "text-h2 mt-6 mb-1",
18
+ 3: "text-h3 mt-4 mb-0.5",
19
+ },
20
+ },
21
+ defaultVariants: { level: 1 },
22
+ });
23
+
24
+ type HeadingLevel = "title" | 1 | 2 | 3;
25
+
26
+ const defaultTag: Record<string, ElementType> = {
27
+ title: "h1",
28
+ 1: "h1",
29
+ 2: "h2",
30
+ 3: "h3",
31
+ };
32
+
33
+ export interface HeadingProps
34
+ extends Omit<ComponentPropsWithoutRef<"h1">, "color"> {
35
+ level?: HeadingLevel;
36
+ as?: ElementType;
37
+ /** Drop the default top/bottom margin when composing custom layouts. */
38
+ flush?: boolean;
39
+ }
40
+
41
+ export function Heading({
42
+ level = 1,
43
+ as,
44
+ flush,
45
+ className,
46
+ ...props
47
+ }: HeadingProps) {
48
+ const Tag = (as ?? defaultTag[String(level)] ?? "h2") as ElementType;
49
+ return (
50
+ <Tag
51
+ className={cn(
52
+ headingVariants({ level }),
53
+ flush && "my-0 mt-0 mb-0",
54
+ className,
55
+ )}
56
+ {...props}
57
+ />
58
+ );
59
+ }
60
+
61
+ const textVariants = cva("font-sans", {
62
+ variants: {
63
+ tone: {
64
+ default: "text-ink",
65
+ secondary: "text-ink-secondary",
66
+ tertiary: "text-ink-tertiary",
67
+ accent: "text-accent",
68
+ danger: "text-danger",
69
+ },
70
+ size: {
71
+ body: "text-body",
72
+ sm: "text-sm",
73
+ caption: "text-caption",
74
+ },
75
+ weight: {
76
+ normal: "font-normal",
77
+ medium: "font-medium",
78
+ semibold: "font-semibold",
79
+ },
80
+ },
81
+ defaultVariants: { tone: "default", size: "body", weight: "normal" },
82
+ });
83
+
84
+ export interface TextProps
85
+ extends Omit<ComponentPropsWithoutRef<"p">, "color">,
86
+ VariantProps<typeof textVariants> {
87
+ as?: ElementType;
88
+ }
89
+
90
+ export function Text({
91
+ as,
92
+ tone,
93
+ size,
94
+ weight,
95
+ className,
96
+ ...props
97
+ }: TextProps) {
98
+ const Tag = (as ?? "p") as ElementType;
99
+ return (
100
+ <Tag
101
+ className={cn(textVariants({ tone, size, weight }), className)}
102
+ {...props}
103
+ />
104
+ );
105
+ }
106
+
107
+ /** Inline code. Tinted, not boxed — a box would outrank the paragraph. */
108
+ export function Code({
109
+ className,
110
+ ...props
111
+ }: ComponentPropsWithoutRef<"code">) {
112
+ return (
113
+ <code
114
+ className={cn(
115
+ "bg-tag-red-bg/70 px-1.5 py-0.5 rounded-[3px] font-mono text-tag-red-ink text-[0.85em]",
116
+ className,
117
+ )}
118
+ {...props}
119
+ />
120
+ );
121
+ }
122
+
123
+ export function Kbd({ className, ...props }: ComponentPropsWithoutRef<"kbd">) {
124
+ return (
125
+ <kbd
126
+ className={cn(
127
+ "inline-flex justify-center items-center bg-surface shadow-xs px-1.5 rounded-[3px] min-w-5 h-5 font-sans font-medium text-ink-secondary text-caption",
128
+ className,
129
+ )}
130
+ {...props}
131
+ />
132
+ );
133
+ }
134
+
135
+ /**
136
+ * Long-form content wrapper. Applies the reading measure plus the
137
+ * vertical rhythm Notion uses between blocks. Wrap raw markdown output
138
+ * in this and it looks intentional with no further work.
139
+ */
140
+ export function Prose({
141
+ children,
142
+ className,
143
+ serif,
144
+ }: {
145
+ children: ReactNode;
146
+ className?: string;
147
+ serif?: boolean;
148
+ }) {
149
+ return (
150
+ <div
151
+ className={cn(
152
+ "measure text-ink text-body",
153
+ serif && "font-serif",
154
+ "[&>*+*]:mt-3",
155
+ "[&_p]:text-ink [&_p]:leading-[1.6]",
156
+ "[&_a]:text-ink [&_a]:underline [&_a]:decoration-ink-tertiary [&_a]:underline-offset-2 [&_a:hover]:decoration-ink",
157
+ "[&_strong]:font-semibold",
158
+ "[&_ul]:list-disc [&_ul]:pl-6 [&_ol]:list-decimal [&_ol]:pl-6",
159
+ "[&_li]:mt-1 [&_li]:leading-[1.6]",
160
+ "[&_blockquote]:border-ink/40 [&_blockquote]:pl-4 [&_blockquote]:border-l-2 [&_blockquote]:text-ink",
161
+ "[&_hr]:my-6 [&_hr]:border-hairline",
162
+ className,
163
+ )}
164
+ >
165
+ {children}
166
+ </div>
167
+ );
168
+ }
@@ -0,0 +1,60 @@
1
+ "use client";
2
+
3
+ import { SquarePlay } from "lucide-react";
4
+ import type { ReactNode } from "react";
5
+ import { videoEmbed } from "../../lib/embed.ts";
6
+ import { AddressField } from "./address-field.tsx";
7
+
8
+ /* A YouTube or Vimeo video in a document, played in place at the column's full
9
+ width, with a caption slot under it. Until it has a link it asks for one, and
10
+ refuses anything `videoEmbed` cannot play.
11
+
12
+ The player is sandboxed: it may run, go full screen and open YouTube in a new
13
+ tab, and nothing else on the page. */
14
+ export function VideoBlock({
15
+ url,
16
+ onLink,
17
+ check,
18
+ caption,
19
+ title = "Video",
20
+ className,
21
+ }: {
22
+ /** The link as given, not the embed address. */
23
+ url?: string;
24
+ onLink?: (url: string) => void;
25
+ /** The owner's own rule for a link, after this block's: why it is refused, or null. */
26
+ check?: (url: string) => string | null;
27
+ /** Under the video: usually an EditableText. */
28
+ caption?: ReactNode;
29
+ /** Read out for the player. */
30
+ title?: string;
31
+ className?: string;
32
+ }) {
33
+ const embed = url ? videoEmbed(url) : null;
34
+ if (embed === null)
35
+ return onLink ? (
36
+ <AddressField
37
+ icon={<SquarePlay />}
38
+ placeholder="Paste a YouTube or Vimeo link, then Enter"
39
+ check={(link) => (videoEmbed(link) === null ? "That is not a YouTube or Vimeo link." : null) ?? check?.(link) ?? null}
40
+ onCommit={onLink}
41
+ className={className}
42
+ />
43
+ ) : null;
44
+ return (
45
+ <figure className={className}>
46
+ <div className="aspect-video overflow-hidden rounded-surface bg-surface-sunken">
47
+ <iframe
48
+ src={embed}
49
+ title={title}
50
+ className="size-full"
51
+ allow="fullscreen; picture-in-picture; encrypted-media"
52
+ sandbox="allow-scripts allow-same-origin allow-presentation allow-popups"
53
+ referrerPolicy="strict-origin-when-cross-origin"
54
+ loading="lazy"
55
+ />
56
+ </div>
57
+ {caption !== undefined && <figcaption className="mt-1.5 text-sm text-ink-secondary">{caption}</figcaption>}
58
+ </figure>
59
+ );
60
+ }
@@ -0,0 +1,66 @@
1
+ "use client";
2
+
3
+ import { useCallback, useEffect, useRef, useState } from "react";
4
+
5
+ /* Optimistic saving, the way an editor needs it. Change local state first, then:
6
+
7
+ - `schedule(key)` saves that thing after a pause in typing;
8
+ - `flush(key)` saves it now;
9
+ - `enqueue(job)` runs any other write (create, move, delete).
10
+
11
+ Everything goes to the server one request at a time, in the order it was asked
12
+ for, so a move can never overtake the edit before it. Pending saves are flushed
13
+ when the page is hidden. The first failure is kept in `error` and nothing is
14
+ retried: show it and offer a reload, rather than guess what the server holds. */
15
+ export function useSaveQueue<K>({
16
+ save,
17
+ delay = 600,
18
+ }: {
19
+ // Sends the current state of `key`. `keepalive` is true while the page is
20
+ // closing: pass it to fetch so the request outlives the tab.
21
+ save: (key: K, opts: { keepalive: boolean }) => Promise<unknown>;
22
+ delay?: number;
23
+ }) {
24
+ const [error, setError] = useState<string | null>(null);
25
+ const queue = useRef<Promise<unknown>>(Promise.resolve());
26
+ const timers = useRef(new Map<K, ReturnType<typeof setTimeout>>());
27
+ // The latest `save`, so callers need not memoise it.
28
+ const saver = useRef(save);
29
+ saver.current = save;
30
+
31
+ const enqueue = useCallback((job: () => Promise<unknown>) => {
32
+ queue.current = queue.current.then(job).catch((err: Error) => setError(err.message));
33
+ }, []);
34
+
35
+ const cancel = useCallback((key: K) => {
36
+ clearTimeout(timers.current.get(key));
37
+ timers.current.delete(key);
38
+ }, []);
39
+
40
+ const flush = useCallback(
41
+ (key: K, keepalive = false) => {
42
+ cancel(key);
43
+ enqueue(() => saver.current(key, { keepalive }));
44
+ },
45
+ [cancel, enqueue],
46
+ );
47
+
48
+ const schedule = useCallback(
49
+ (key: K) => {
50
+ cancel(key);
51
+ timers.current.set(key, setTimeout(() => flush(key), delay));
52
+ },
53
+ [cancel, flush, delay],
54
+ );
55
+
56
+ useEffect(() => {
57
+ const flushAll = () => [...timers.current.keys()].forEach((key) => flush(key, true));
58
+ window.addEventListener("pagehide", flushAll);
59
+ return () => {
60
+ window.removeEventListener("pagehide", flushAll);
61
+ flushAll();
62
+ };
63
+ }, [flush]);
64
+
65
+ return { error, enqueue, schedule, flush, cancel };
66
+ }
@@ -0,0 +1,44 @@
1
+ "use client";
2
+
3
+ import { useEffect, useState } from "react";
4
+
5
+ export type Selection = { ids: Set<string>; toggle: (id: string, range: boolean) => void };
6
+
7
+ /* Picking several things from an ordered list. `selection` is null until
8
+ `start()`; then a press toggles one, and a press with `range` (Shift) picks
9
+ everything between it and the last one pressed. Escape stops.
10
+
11
+ `order` is every id on the page, in the order shown; it is what "between"
12
+ means. */
13
+ export function useSelection(order: string[]): { selection: Selection | null; start: () => void; stop: () => void } {
14
+ const [ids, setIds] = useState<Set<string> | null>(null);
15
+ const [anchor, setAnchor] = useState<string | null>(null);
16
+ const selecting = ids !== null;
17
+
18
+ const stop = () => {
19
+ setIds(null);
20
+ setAnchor(null);
21
+ };
22
+ useEffect(() => {
23
+ if (!selecting) return;
24
+ const onKey = (event: KeyboardEvent) => event.key === "Escape" && stop();
25
+ window.addEventListener("keydown", onKey);
26
+ return () => window.removeEventListener("keydown", onKey);
27
+ }, [selecting]);
28
+
29
+ const toggle = (id: string, range: boolean) => {
30
+ setIds((prev) => {
31
+ const next = new Set(prev);
32
+ const from = anchor === null ? -1 : order.indexOf(anchor);
33
+ const to = order.indexOf(id);
34
+ if (range && from !== -1 && to !== -1) {
35
+ for (const between of order.slice(Math.min(from, to), Math.max(from, to) + 1)) next.add(between);
36
+ } else if (next.has(id)) next.delete(id);
37
+ else next.add(id);
38
+ return next;
39
+ });
40
+ setAnchor(id);
41
+ };
42
+
43
+ return { selection: ids === null ? null : { ids, toggle }, start: () => setIds(new Set()), stop };
44
+ }