@kujoforall/paper-ui 0.0.0-stage → 0.2.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 (661) hide show
  1. package/CHANGELOG.md +93 -0
  2. package/LICENSE +21 -0
  3. package/README.md +295 -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 +248 -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 +191 -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 +42 -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 +110 -0
  19. package/dist/components/editor/document-view.js.map +1 -0
  20. package/dist/components/editor/editor-state.d.ts +107 -0
  21. package/dist/components/editor/editor-state.d.ts.map +1 -0
  22. package/dist/components/editor/editor-state.js +217 -0
  23. package/dist/components/editor/editor-state.js.map +1 -0
  24. package/dist/components/editor/extensions/kit-blocks.d.ts +34 -0
  25. package/dist/components/editor/extensions/kit-blocks.d.ts.map +1 -0
  26. package/dist/components/editor/extensions/kit-blocks.js +201 -0
  27. package/dist/components/editor/extensions/kit-blocks.js.map +1 -0
  28. package/dist/components/editor/extensions/spoiler.d.ts +8 -0
  29. package/dist/components/editor/extensions/spoiler.d.ts.map +1 -0
  30. package/dist/components/editor/extensions/spoiler.js +36 -0
  31. package/dist/components/editor/extensions/spoiler.js.map +1 -0
  32. package/dist/components/editor/index.d.ts +10 -0
  33. package/dist/components/editor/index.d.ts.map +1 -0
  34. package/dist/components/editor/index.js +10 -0
  35. package/dist/components/editor/index.js.map +1 -0
  36. package/dist/components/editor/kinds.d.ts +99 -0
  37. package/dist/components/editor/kinds.d.ts.map +1 -0
  38. package/dist/components/editor/kinds.js +74 -0
  39. package/dist/components/editor/kinds.js.map +1 -0
  40. package/dist/components/editor/look.d.ts +18 -0
  41. package/dist/components/editor/look.d.ts.map +1 -0
  42. package/dist/components/editor/look.js +21 -0
  43. package/dist/components/editor/look.js.map +1 -0
  44. package/dist/components/sketch/rough.d.ts +38 -0
  45. package/dist/components/sketch/rough.d.ts.map +1 -0
  46. package/dist/components/sketch/rough.js +57 -0
  47. package/dist/components/sketch/rough.js.map +1 -0
  48. package/dist/components/three/model-viewer.d.ts +36 -0
  49. package/dist/components/three/model-viewer.d.ts.map +1 -0
  50. package/dist/components/three/model-viewer.js +338 -0
  51. package/dist/components/three/model-viewer.js.map +1 -0
  52. package/dist/components/ui/accent-picker.d.ts +2 -0
  53. package/dist/components/ui/accent-picker.d.ts.map +1 -0
  54. package/dist/components/ui/accent-picker.js +44 -0
  55. package/dist/components/ui/accent-picker.js.map +1 -0
  56. package/dist/components/ui/address-field.d.ts +10 -0
  57. package/dist/components/ui/address-field.d.ts.map +1 -0
  58. package/dist/components/ui/address-field.js +24 -0
  59. package/dist/components/ui/address-field.js.map +1 -0
  60. package/dist/components/ui/alert-dialog.d.ts +29 -0
  61. package/dist/components/ui/alert-dialog.d.ts.map +1 -0
  62. package/dist/components/ui/alert-dialog.js +72 -0
  63. package/dist/components/ui/alert-dialog.js.map +1 -0
  64. package/dist/components/ui/animated-height.d.ts +6 -0
  65. package/dist/components/ui/animated-height.d.ts.map +1 -0
  66. package/dist/components/ui/animated-height.js +26 -0
  67. package/dist/components/ui/animated-height.js.map +1 -0
  68. package/dist/components/ui/app-shell.d.ts +26 -0
  69. package/dist/components/ui/app-shell.d.ts.map +1 -0
  70. package/dist/components/ui/app-shell.js +71 -0
  71. package/dist/components/ui/app-shell.js.map +1 -0
  72. package/dist/components/ui/avatar.d.ts +30 -0
  73. package/dist/components/ui/avatar.d.ts.map +1 -0
  74. package/dist/components/ui/avatar.js +50 -0
  75. package/dist/components/ui/avatar.js.map +1 -0
  76. package/dist/components/ui/badge.d.ts +19 -0
  77. package/dist/components/ui/badge.d.ts.map +1 -0
  78. package/dist/components/ui/badge.js +62 -0
  79. package/dist/components/ui/badge.js.map +1 -0
  80. package/dist/components/ui/banner.d.ts +33 -0
  81. package/dist/components/ui/banner.d.ts.map +1 -0
  82. package/dist/components/ui/banner.js +21 -0
  83. package/dist/components/ui/banner.js.map +1 -0
  84. package/dist/components/ui/breadcrumbs.d.ts +10 -0
  85. package/dist/components/ui/breadcrumbs.d.ts.map +1 -0
  86. package/dist/components/ui/breadcrumbs.js +9 -0
  87. package/dist/components/ui/breadcrumbs.js.map +1 -0
  88. package/dist/components/ui/button.d.ts +15 -0
  89. package/dist/components/ui/button.d.ts.map +1 -0
  90. package/dist/components/ui/button.js +110 -0
  91. package/dist/components/ui/button.js.map +1 -0
  92. package/dist/components/ui/calendar.d.ts +5 -0
  93. package/dist/components/ui/calendar.d.ts.map +1 -0
  94. package/dist/components/ui/calendar.js +65 -0
  95. package/dist/components/ui/calendar.js.map +1 -0
  96. package/dist/components/ui/callout.d.ts +32 -0
  97. package/dist/components/ui/callout.d.ts.map +1 -0
  98. package/dist/components/ui/callout.js +40 -0
  99. package/dist/components/ui/callout.js.map +1 -0
  100. package/dist/components/ui/card.d.ts +18 -0
  101. package/dist/components/ui/card.d.ts.map +1 -0
  102. package/dist/components/ui/card.js +28 -0
  103. package/dist/components/ui/card.js.map +1 -0
  104. package/dist/components/ui/checkbox.d.ts +11 -0
  105. package/dist/components/ui/checkbox.d.ts.map +1 -0
  106. package/dist/components/ui/checkbox.js +30 -0
  107. package/dist/components/ui/checkbox.js.map +1 -0
  108. package/dist/components/ui/choice-label.d.ts +13 -0
  109. package/dist/components/ui/choice-label.d.ts.map +1 -0
  110. package/dist/components/ui/choice-label.js +17 -0
  111. package/dist/components/ui/choice-label.js.map +1 -0
  112. package/dist/components/ui/collapsible.d.ts +10 -0
  113. package/dist/components/ui/collapsible.d.ts.map +1 -0
  114. package/dist/components/ui/collapsible.js +21 -0
  115. package/dist/components/ui/collapsible.js.map +1 -0
  116. package/dist/components/ui/collection-layout.d.ts +24 -0
  117. package/dist/components/ui/collection-layout.d.ts.map +1 -0
  118. package/dist/components/ui/collection-layout.js +16 -0
  119. package/dist/components/ui/collection-layout.js.map +1 -0
  120. package/dist/components/ui/combobox.d.ts +10 -0
  121. package/dist/components/ui/combobox.d.ts.map +1 -0
  122. package/dist/components/ui/combobox.js +93 -0
  123. package/dist/components/ui/combobox.js.map +1 -0
  124. package/dist/components/ui/command-menu.d.ts +18 -0
  125. package/dist/components/ui/command-menu.d.ts.map +1 -0
  126. package/dist/components/ui/command-menu.js +49 -0
  127. package/dist/components/ui/command-menu.js.map +1 -0
  128. package/dist/components/ui/context-menu.d.ts +19 -0
  129. package/dist/components/ui/context-menu.d.ts.map +1 -0
  130. package/dist/components/ui/context-menu.js +42 -0
  131. package/dist/components/ui/context-menu.js.map +1 -0
  132. package/dist/components/ui/copy-button.d.ts +11 -0
  133. package/dist/components/ui/copy-button.d.ts.map +1 -0
  134. package/dist/components/ui/copy-button.js +48 -0
  135. package/dist/components/ui/copy-button.js.map +1 -0
  136. package/dist/components/ui/database/calendar-view.d.ts +10 -0
  137. package/dist/components/ui/database/calendar-view.d.ts.map +1 -0
  138. package/dist/components/ui/database/calendar-view.js +65 -0
  139. package/dist/components/ui/database/calendar-view.js.map +1 -0
  140. package/dist/components/ui/database/card-views.d.ts +22 -0
  141. package/dist/components/ui/database/card-views.d.ts.map +1 -0
  142. package/dist/components/ui/database/card-views.js +74 -0
  143. package/dist/components/ui/database/card-views.js.map +1 -0
  144. package/dist/components/ui/database/cells.d.ts +20 -0
  145. package/dist/components/ui/database/cells.d.ts.map +1 -0
  146. package/dist/components/ui/database/cells.js +132 -0
  147. package/dist/components/ui/database/cells.js.map +1 -0
  148. package/dist/components/ui/database/database.d.ts +19 -0
  149. package/dist/components/ui/database/database.d.ts.map +1 -0
  150. package/dist/components/ui/database/database.js +102 -0
  151. package/dist/components/ui/database/database.js.map +1 -0
  152. package/dist/components/ui/database/icons.d.ts +5 -0
  153. package/dist/components/ui/database/icons.d.ts.map +1 -0
  154. package/dist/components/ui/database/icons.js +13 -0
  155. package/dist/components/ui/database/icons.js.map +1 -0
  156. package/dist/components/ui/database/table-view.d.ts +11 -0
  157. package/dist/components/ui/database/table-view.d.ts.map +1 -0
  158. package/dist/components/ui/database/table-view.js +157 -0
  159. package/dist/components/ui/database/table-view.js.map +1 -0
  160. package/dist/components/ui/date-picker.d.ts +40 -0
  161. package/dist/components/ui/date-picker.d.ts.map +1 -0
  162. package/dist/components/ui/date-picker.js +64 -0
  163. package/dist/components/ui/date-picker.js.map +1 -0
  164. package/dist/components/ui/date-time-picker.d.ts +21 -0
  165. package/dist/components/ui/date-time-picker.d.ts.map +1 -0
  166. package/dist/components/ui/date-time-picker.js +34 -0
  167. package/dist/components/ui/date-time-picker.js.map +1 -0
  168. package/dist/components/ui/dialog.d.ts +21 -0
  169. package/dist/components/ui/dialog.d.ts.map +1 -0
  170. package/dist/components/ui/dialog.js +63 -0
  171. package/dist/components/ui/dialog.js.map +1 -0
  172. package/dist/components/ui/document-layout.d.ts +15 -0
  173. package/dist/components/ui/document-layout.d.ts.map +1 -0
  174. package/dist/components/ui/document-layout.js +15 -0
  175. package/dist/components/ui/document-layout.js.map +1 -0
  176. package/dist/components/ui/dropdown-menu.d.ts +24 -0
  177. package/dist/components/ui/dropdown-menu.d.ts.map +1 -0
  178. package/dist/components/ui/dropdown-menu.js +65 -0
  179. package/dist/components/ui/dropdown-menu.js.map +1 -0
  180. package/dist/components/ui/editable-text.d.ts +24 -0
  181. package/dist/components/ui/editable-text.d.ts.map +1 -0
  182. package/dist/components/ui/editable-text.js +85 -0
  183. package/dist/components/ui/editable-text.js.map +1 -0
  184. package/dist/components/ui/empty-state.d.ts +11 -0
  185. package/dist/components/ui/empty-state.d.ts.map +1 -0
  186. package/dist/components/ui/empty-state.js +9 -0
  187. package/dist/components/ui/empty-state.js.map +1 -0
  188. package/dist/components/ui/error-state.d.ts +20 -0
  189. package/dist/components/ui/error-state.d.ts.map +1 -0
  190. package/dist/components/ui/error-state.js +17 -0
  191. package/dist/components/ui/error-state.js.map +1 -0
  192. package/dist/components/ui/field-button.d.ts +15 -0
  193. package/dist/components/ui/field-button.d.ts.map +1 -0
  194. package/dist/components/ui/field-button.js +18 -0
  195. package/dist/components/ui/field-button.js.map +1 -0
  196. package/dist/components/ui/file-preview.d.ts +5 -0
  197. package/dist/components/ui/file-preview.d.ts.map +1 -0
  198. package/dist/components/ui/file-preview.js +66 -0
  199. package/dist/components/ui/file-preview.js.map +1 -0
  200. package/dist/components/ui/file-uploader.d.ts +39 -0
  201. package/dist/components/ui/file-uploader.d.ts.map +1 -0
  202. package/dist/components/ui/file-uploader.js +111 -0
  203. package/dist/components/ui/file-uploader.js.map +1 -0
  204. package/dist/components/ui/filter-builder.d.ts +18 -0
  205. package/dist/components/ui/filter-builder.d.ts.map +1 -0
  206. package/dist/components/ui/filter-builder.js +98 -0
  207. package/dist/components/ui/filter-builder.js.map +1 -0
  208. package/dist/components/ui/focus-shell.d.ts +14 -0
  209. package/dist/components/ui/focus-shell.d.ts.map +1 -0
  210. package/dist/components/ui/focus-shell.js +13 -0
  211. package/dist/components/ui/focus-shell.js.map +1 -0
  212. package/dist/components/ui/handle-row.d.ts +25 -0
  213. package/dist/components/ui/handle-row.d.ts.map +1 -0
  214. package/dist/components/ui/handle-row.js +110 -0
  215. package/dist/components/ui/handle-row.js.map +1 -0
  216. package/dist/components/ui/header-bar.d.ts +5 -0
  217. package/dist/components/ui/header-bar.d.ts.map +1 -0
  218. package/dist/components/ui/header-bar.js +10 -0
  219. package/dist/components/ui/header-bar.js.map +1 -0
  220. package/dist/components/ui/hover-card.d.ts +6 -0
  221. package/dist/components/ui/hover-card.d.ts.map +1 -0
  222. package/dist/components/ui/hover-card.js +13 -0
  223. package/dist/components/ui/hover-card.js.map +1 -0
  224. package/dist/components/ui/image-block.d.ts +31 -0
  225. package/dist/components/ui/image-block.d.ts.map +1 -0
  226. package/dist/components/ui/image-block.js +103 -0
  227. package/dist/components/ui/image-block.js.map +1 -0
  228. package/dist/components/ui/image-card.d.ts +17 -0
  229. package/dist/components/ui/image-card.d.ts.map +1 -0
  230. package/dist/components/ui/image-card.js +39 -0
  231. package/dist/components/ui/image-card.js.map +1 -0
  232. package/dist/components/ui/image-framer.d.ts +24 -0
  233. package/dist/components/ui/image-framer.d.ts.map +1 -0
  234. package/dist/components/ui/image-framer.js +89 -0
  235. package/dist/components/ui/image-framer.js.map +1 -0
  236. package/dist/components/ui/image-viewer.d.ts +31 -0
  237. package/dist/components/ui/image-viewer.d.ts.map +1 -0
  238. package/dist/components/ui/image-viewer.js +114 -0
  239. package/dist/components/ui/image-viewer.js.map +1 -0
  240. package/dist/components/ui/image.d.ts +33 -0
  241. package/dist/components/ui/image.d.ts.map +1 -0
  242. package/dist/components/ui/image.js +61 -0
  243. package/dist/components/ui/image.js.map +1 -0
  244. package/dist/components/ui/index.d.ts +92 -0
  245. package/dist/components/ui/index.d.ts.map +1 -0
  246. package/dist/components/ui/index.js +92 -0
  247. package/dist/components/ui/index.js.map +1 -0
  248. package/dist/components/ui/input.d.ts +75 -0
  249. package/dist/components/ui/input.d.ts.map +1 -0
  250. package/dist/components/ui/input.js +245 -0
  251. package/dist/components/ui/input.js.map +1 -0
  252. package/dist/components/ui/link-block.d.ts +13 -0
  253. package/dist/components/ui/link-block.d.ts.map +1 -0
  254. package/dist/components/ui/link-block.js +21 -0
  255. package/dist/components/ui/link-block.js.map +1 -0
  256. package/dist/components/ui/list-detail.d.ts +23 -0
  257. package/dist/components/ui/list-detail.d.ts.map +1 -0
  258. package/dist/components/ui/list-detail.js +33 -0
  259. package/dist/components/ui/list-detail.js.map +1 -0
  260. package/dist/components/ui/listbox.d.ts +7 -0
  261. package/dist/components/ui/listbox.d.ts.map +1 -0
  262. package/dist/components/ui/listbox.js +29 -0
  263. package/dist/components/ui/listbox.js.map +1 -0
  264. package/dist/components/ui/mac-card.d.ts +15 -0
  265. package/dist/components/ui/mac-card.d.ts.map +1 -0
  266. package/dist/components/ui/mac-card.js +9 -0
  267. package/dist/components/ui/mac-card.js.map +1 -0
  268. package/dist/components/ui/month-picker.d.ts +13 -0
  269. package/dist/components/ui/month-picker.d.ts.map +1 -0
  270. package/dist/components/ui/month-picker.js +53 -0
  271. package/dist/components/ui/month-picker.js.map +1 -0
  272. package/dist/components/ui/multi-select.d.ts +22 -0
  273. package/dist/components/ui/multi-select.d.ts.map +1 -0
  274. package/dist/components/ui/multi-select.js +88 -0
  275. package/dist/components/ui/multi-select.js.map +1 -0
  276. package/dist/components/ui/nav-tree.d.ts +16 -0
  277. package/dist/components/ui/nav-tree.d.ts.map +1 -0
  278. package/dist/components/ui/nav-tree.js +41 -0
  279. package/dist/components/ui/nav-tree.js.map +1 -0
  280. package/dist/components/ui/page.d.ts +23 -0
  281. package/dist/components/ui/page.d.ts.map +1 -0
  282. package/dist/components/ui/page.js +28 -0
  283. package/dist/components/ui/page.js.map +1 -0
  284. package/dist/components/ui/pagination.d.ts +26 -0
  285. package/dist/components/ui/pagination.d.ts.map +1 -0
  286. package/dist/components/ui/pagination.js +54 -0
  287. package/dist/components/ui/pagination.js.map +1 -0
  288. package/dist/components/ui/picker-panel.d.ts +13 -0
  289. package/dist/components/ui/picker-panel.d.ts.map +1 -0
  290. package/dist/components/ui/picker-panel.js +19 -0
  291. package/dist/components/ui/picker-panel.js.map +1 -0
  292. package/dist/components/ui/popover.d.ts +8 -0
  293. package/dist/components/ui/popover.d.ts.map +1 -0
  294. package/dist/components/ui/popover.js +18 -0
  295. package/dist/components/ui/popover.js.map +1 -0
  296. package/dist/components/ui/progress.d.ts +19 -0
  297. package/dist/components/ui/progress.d.ts.map +1 -0
  298. package/dist/components/ui/progress.js +22 -0
  299. package/dist/components/ui/progress.js.map +1 -0
  300. package/dist/components/ui/property.d.ts +11 -0
  301. package/dist/components/ui/property.d.ts.map +1 -0
  302. package/dist/components/ui/property.js +18 -0
  303. package/dist/components/ui/property.js.map +1 -0
  304. package/dist/components/ui/radio-group.d.ts +8 -0
  305. package/dist/components/ui/radio-group.d.ts.map +1 -0
  306. package/dist/components/ui/radio-group.js +18 -0
  307. package/dist/components/ui/radio-group.js.map +1 -0
  308. package/dist/components/ui/rating.d.ts +14 -0
  309. package/dist/components/ui/rating.d.ts.map +1 -0
  310. package/dist/components/ui/rating.js +61 -0
  311. package/dist/components/ui/rating.js.map +1 -0
  312. package/dist/components/ui/save-status.d.ts +8 -0
  313. package/dist/components/ui/save-status.d.ts.map +1 -0
  314. package/dist/components/ui/save-status.js +31 -0
  315. package/dist/components/ui/save-status.js.map +1 -0
  316. package/dist/components/ui/segmented.d.ts +21 -0
  317. package/dist/components/ui/segmented.d.ts.map +1 -0
  318. package/dist/components/ui/segmented.js +12 -0
  319. package/dist/components/ui/segmented.js.map +1 -0
  320. package/dist/components/ui/select-menu.d.ts +12 -0
  321. package/dist/components/ui/select-menu.d.ts.map +1 -0
  322. package/dist/components/ui/select-menu.js +10 -0
  323. package/dist/components/ui/select-menu.js.map +1 -0
  324. package/dist/components/ui/select.d.ts +16 -0
  325. package/dist/components/ui/select.d.ts.map +1 -0
  326. package/dist/components/ui/select.js +45 -0
  327. package/dist/components/ui/select.js.map +1 -0
  328. package/dist/components/ui/selection-bar.d.ts +12 -0
  329. package/dist/components/ui/selection-bar.d.ts.map +1 -0
  330. package/dist/components/ui/selection-bar.js +15 -0
  331. package/dist/components/ui/selection-bar.js.map +1 -0
  332. package/dist/components/ui/separator.d.ts +4 -0
  333. package/dist/components/ui/separator.d.ts.map +1 -0
  334. package/dist/components/ui/separator.js +12 -0
  335. package/dist/components/ui/separator.js.map +1 -0
  336. package/dist/components/ui/settings-layout.d.ts +34 -0
  337. package/dist/components/ui/settings-layout.d.ts.map +1 -0
  338. package/dist/components/ui/settings-layout.js +16 -0
  339. package/dist/components/ui/settings-layout.js.map +1 -0
  340. package/dist/components/ui/share-link.d.ts +14 -0
  341. package/dist/components/ui/share-link.d.ts.map +1 -0
  342. package/dist/components/ui/share-link.js +16 -0
  343. package/dist/components/ui/share-link.js.map +1 -0
  344. package/dist/components/ui/sheet.d.ts +21 -0
  345. package/dist/components/ui/sheet.d.ts.map +1 -0
  346. package/dist/components/ui/sheet.js +53 -0
  347. package/dist/components/ui/sheet.js.map +1 -0
  348. package/dist/components/ui/sidebar.d.ts +82 -0
  349. package/dist/components/ui/sidebar.d.ts.map +1 -0
  350. package/dist/components/ui/sidebar.js +258 -0
  351. package/dist/components/ui/sidebar.js.map +1 -0
  352. package/dist/components/ui/skeleton.d.ts +8 -0
  353. package/dist/components/ui/skeleton.d.ts.map +1 -0
  354. package/dist/components/ui/skeleton.js +15 -0
  355. package/dist/components/ui/skeleton.js.map +1 -0
  356. package/dist/components/ui/spinner.d.ts +12 -0
  357. package/dist/components/ui/spinner.d.ts.map +1 -0
  358. package/dist/components/ui/spinner.js +14 -0
  359. package/dist/components/ui/spinner.js.map +1 -0
  360. package/dist/components/ui/spotlight.d.ts +23 -0
  361. package/dist/components/ui/spotlight.d.ts.map +1 -0
  362. package/dist/components/ui/spotlight.js +110 -0
  363. package/dist/components/ui/spotlight.js.map +1 -0
  364. package/dist/components/ui/stat-tile.d.ts +8 -0
  365. package/dist/components/ui/stat-tile.d.ts.map +1 -0
  366. package/dist/components/ui/stat-tile.js +9 -0
  367. package/dist/components/ui/stat-tile.js.map +1 -0
  368. package/dist/components/ui/step-dialog.d.ts +20 -0
  369. package/dist/components/ui/step-dialog.d.ts.map +1 -0
  370. package/dist/components/ui/step-dialog.js +36 -0
  371. package/dist/components/ui/step-dialog.js.map +1 -0
  372. package/dist/components/ui/steps-layout.d.ts +20 -0
  373. package/dist/components/ui/steps-layout.d.ts.map +1 -0
  374. package/dist/components/ui/steps-layout.js +26 -0
  375. package/dist/components/ui/steps-layout.js.map +1 -0
  376. package/dist/components/ui/switch.d.ts +8 -0
  377. package/dist/components/ui/switch.d.ts.map +1 -0
  378. package/dist/components/ui/switch.js +21 -0
  379. package/dist/components/ui/switch.js.map +1 -0
  380. package/dist/components/ui/table.d.ts +16 -0
  381. package/dist/components/ui/table.d.ts.map +1 -0
  382. package/dist/components/ui/table.js +76 -0
  383. package/dist/components/ui/table.js.map +1 -0
  384. package/dist/components/ui/tabs.d.ts +7 -0
  385. package/dist/components/ui/tabs.d.ts.map +1 -0
  386. package/dist/components/ui/tabs.js +19 -0
  387. package/dist/components/ui/tabs.js.map +1 -0
  388. package/dist/components/ui/theme-toggle.d.ts +16 -0
  389. package/dist/components/ui/theme-toggle.d.ts.map +1 -0
  390. package/dist/components/ui/theme-toggle.js +65 -0
  391. package/dist/components/ui/theme-toggle.js.map +1 -0
  392. package/dist/components/ui/time-list.d.ts +16 -0
  393. package/dist/components/ui/time-list.d.ts.map +1 -0
  394. package/dist/components/ui/time-list.js +49 -0
  395. package/dist/components/ui/time-list.js.map +1 -0
  396. package/dist/components/ui/time-picker.d.ts +47 -0
  397. package/dist/components/ui/time-picker.d.ts.map +1 -0
  398. package/dist/components/ui/time-picker.js +141 -0
  399. package/dist/components/ui/time-picker.js.map +1 -0
  400. package/dist/components/ui/toast.d.ts +18 -0
  401. package/dist/components/ui/toast.d.ts.map +1 -0
  402. package/dist/components/ui/toast.js +77 -0
  403. package/dist/components/ui/toast.js.map +1 -0
  404. package/dist/components/ui/toggle.d.ts +15 -0
  405. package/dist/components/ui/toggle.d.ts.map +1 -0
  406. package/dist/components/ui/toggle.js +55 -0
  407. package/dist/components/ui/toggle.js.map +1 -0
  408. package/dist/components/ui/tooltip.d.ts +15 -0
  409. package/dist/components/ui/tooltip.d.ts.map +1 -0
  410. package/dist/components/ui/tooltip.js +32 -0
  411. package/dist/components/ui/tooltip.js.map +1 -0
  412. package/dist/components/ui/top-bar.d.ts +25 -0
  413. package/dist/components/ui/top-bar.d.ts.map +1 -0
  414. package/dist/components/ui/top-bar.js +23 -0
  415. package/dist/components/ui/top-bar.js.map +1 -0
  416. package/dist/components/ui/typography.d.ts +40 -0
  417. package/dist/components/ui/typography.d.ts.map +1 -0
  418. package/dist/components/ui/typography.js +98 -0
  419. package/dist/components/ui/typography.js.map +1 -0
  420. package/dist/components/ui/video-block.d.ts +14 -0
  421. package/dist/components/ui/video-block.d.ts.map +1 -0
  422. package/dist/components/ui/video-block.js +22 -0
  423. package/dist/components/ui/video-block.js.map +1 -0
  424. package/dist/hooks/use-dismiss.d.ts +5 -0
  425. package/dist/hooks/use-dismiss.d.ts.map +1 -0
  426. package/dist/hooks/use-dismiss.js +23 -0
  427. package/dist/hooks/use-dismiss.js.map +1 -0
  428. package/dist/hooks/use-escape-first.d.ts +3 -0
  429. package/dist/hooks/use-escape-first.d.ts.map +1 -0
  430. package/dist/hooks/use-escape-first.js +27 -0
  431. package/dist/hooks/use-escape-first.js.map +1 -0
  432. package/dist/hooks/use-media-query.d.ts +5 -0
  433. package/dist/hooks/use-media-query.d.ts.map +1 -0
  434. package/dist/hooks/use-media-query.js +16 -0
  435. package/dist/hooks/use-media-query.js.map +1 -0
  436. package/dist/hooks/use-save-queue.d.ts +13 -0
  437. package/dist/hooks/use-save-queue.d.ts.map +1 -0
  438. package/dist/hooks/use-save-queue.js +57 -0
  439. package/dist/hooks/use-save-queue.js.map +1 -0
  440. package/dist/hooks/use-selection.d.ts +10 -0
  441. package/dist/hooks/use-selection.d.ts.map +1 -0
  442. package/dist/hooks/use-selection.js +52 -0
  443. package/dist/hooks/use-selection.js.map +1 -0
  444. package/dist/hooks/use-shared-transition.d.ts +3 -0
  445. package/dist/hooks/use-shared-transition.d.ts.map +1 -0
  446. package/dist/hooks/use-shared-transition.js +38 -0
  447. package/dist/hooks/use-shared-transition.js.map +1 -0
  448. package/dist/hooks/use-upload-queue.d.ts +22 -0
  449. package/dist/hooks/use-upload-queue.d.ts.map +1 -0
  450. package/dist/hooks/use-upload-queue.js +78 -0
  451. package/dist/hooks/use-upload-queue.js.map +1 -0
  452. package/dist/lib/accent.d.ts +5 -0
  453. package/dist/lib/accent.d.ts.map +1 -0
  454. package/dist/lib/accent.js +10 -0
  455. package/dist/lib/accent.js.map +1 -0
  456. package/dist/lib/bento.d.ts +17 -0
  457. package/dist/lib/bento.d.ts.map +1 -0
  458. package/dist/lib/bento.js +92 -0
  459. package/dist/lib/bento.js.map +1 -0
  460. package/dist/lib/database.d.ts +92 -0
  461. package/dist/lib/database.d.ts.map +1 -0
  462. package/dist/lib/database.js +272 -0
  463. package/dist/lib/database.js.map +1 -0
  464. package/dist/lib/dates.d.ts +30 -0
  465. package/dist/lib/dates.d.ts.map +1 -0
  466. package/dist/lib/dates.js +61 -0
  467. package/dist/lib/dates.js.map +1 -0
  468. package/dist/lib/document.d.ts +79 -0
  469. package/dist/lib/document.d.ts.map +1 -0
  470. package/dist/lib/document.js +11 -0
  471. package/dist/lib/document.js.map +1 -0
  472. package/dist/lib/embed.d.ts +14 -0
  473. package/dist/lib/embed.d.ts.map +1 -0
  474. package/dist/lib/embed.js +63 -0
  475. package/dist/lib/embed.js.map +1 -0
  476. package/dist/lib/files.d.ts +23 -0
  477. package/dist/lib/files.d.ts.map +1 -0
  478. package/dist/lib/files.js +69 -0
  479. package/dist/lib/files.js.map +1 -0
  480. package/dist/lib/justified.d.ts +50 -0
  481. package/dist/lib/justified.d.ts.map +1 -0
  482. package/dist/lib/justified.js +78 -0
  483. package/dist/lib/justified.js.map +1 -0
  484. package/dist/lib/keys.d.ts +18 -0
  485. package/dist/lib/keys.d.ts.map +1 -0
  486. package/dist/lib/keys.js +66 -0
  487. package/dist/lib/keys.js.map +1 -0
  488. package/dist/lib/number.d.ts +4 -0
  489. package/dist/lib/number.d.ts.map +1 -0
  490. package/dist/lib/number.js +33 -0
  491. package/dist/lib/number.js.map +1 -0
  492. package/dist/lib/pointer.d.ts +2 -0
  493. package/dist/lib/pointer.d.ts.map +1 -0
  494. package/dist/lib/pointer.js +4 -0
  495. package/dist/lib/pointer.js.map +1 -0
  496. package/dist/lib/prepare-image.d.ts +43 -0
  497. package/dist/lib/prepare-image.d.ts.map +1 -0
  498. package/dist/lib/prepare-image.js +105 -0
  499. package/dist/lib/prepare-image.js.map +1 -0
  500. package/dist/lib/rich-text-dom.d.ts +16 -0
  501. package/dist/lib/rich-text-dom.d.ts.map +1 -0
  502. package/dist/lib/rich-text-dom.js +145 -0
  503. package/dist/lib/rich-text-dom.js.map +1 -0
  504. package/dist/lib/rich-text.d.ts +15 -0
  505. package/dist/lib/rich-text.d.ts.map +1 -0
  506. package/dist/lib/rich-text.js +35 -0
  507. package/dist/lib/rich-text.js.map +1 -0
  508. package/dist/lib/spotlight.d.ts +22 -0
  509. package/dist/lib/spotlight.d.ts.map +1 -0
  510. package/dist/lib/spotlight.js +66 -0
  511. package/dist/lib/spotlight.js.map +1 -0
  512. package/dist/lib/theme.d.ts +6 -0
  513. package/dist/lib/theme.d.ts.map +1 -0
  514. package/dist/lib/theme.js +15 -0
  515. package/dist/lib/theme.js.map +1 -0
  516. package/dist/lib/time.d.ts +19 -0
  517. package/dist/lib/time.d.ts.map +1 -0
  518. package/dist/lib/time.js +91 -0
  519. package/dist/lib/time.js.map +1 -0
  520. package/dist/lib/tree.d.ts +17 -0
  521. package/dist/lib/tree.d.ts.map +1 -0
  522. package/dist/lib/tree.js +35 -0
  523. package/dist/lib/tree.js.map +1 -0
  524. package/dist/lib/utils.d.ts +3 -0
  525. package/dist/lib/utils.d.ts.map +1 -0
  526. package/dist/lib/utils.js +24 -0
  527. package/dist/lib/utils.js.map +1 -0
  528. package/dist/styles/notion.css +817 -0
  529. package/package.json +129 -5
  530. package/src/components/editor/block-text.tsx +271 -0
  531. package/src/components/editor/blocks.tsx +373 -0
  532. package/src/components/editor/document-editor.tsx +106 -0
  533. package/src/components/editor/document-view.tsx +205 -0
  534. package/src/components/editor/editor-state.tsx +298 -0
  535. package/src/components/editor/extensions/kit-blocks.tsx +452 -0
  536. package/src/components/editor/extensions/spoiler.tsx +81 -0
  537. package/src/components/editor/index.ts +10 -0
  538. package/src/components/editor/kinds.ts +158 -0
  539. package/src/components/editor/look.tsx +36 -0
  540. package/src/components/sketch/rough.tsx +90 -0
  541. package/src/components/three/model-viewer.tsx +514 -0
  542. package/src/components/ui/accent-picker.tsx +72 -0
  543. package/src/components/ui/address-field.tsx +57 -0
  544. package/src/components/ui/alert-dialog.tsx +136 -0
  545. package/src/components/ui/animated-height.tsx +34 -0
  546. package/src/components/ui/app-shell.tsx +140 -0
  547. package/src/components/ui/avatar.tsx +106 -0
  548. package/src/components/ui/badge.tsx +81 -0
  549. package/src/components/ui/banner.tsx +53 -0
  550. package/src/components/ui/breadcrumbs.tsx +25 -0
  551. package/src/components/ui/button.tsx +147 -0
  552. package/src/components/ui/calendar.tsx +101 -0
  553. package/src/components/ui/callout.tsx +61 -0
  554. package/src/components/ui/card.tsx +59 -0
  555. package/src/components/ui/checkbox.tsx +66 -0
  556. package/src/components/ui/choice-label.tsx +43 -0
  557. package/src/components/ui/collapsible.tsx +58 -0
  558. package/src/components/ui/collection-layout.tsx +69 -0
  559. package/src/components/ui/combobox.tsx +155 -0
  560. package/src/components/ui/command-menu.tsx +102 -0
  561. package/src/components/ui/context-menu.tsx +89 -0
  562. package/src/components/ui/copy-button.tsx +80 -0
  563. package/src/components/ui/database/calendar-view.tsx +180 -0
  564. package/src/components/ui/database/card-views.tsx +221 -0
  565. package/src/components/ui/database/cells.tsx +237 -0
  566. package/src/components/ui/database/database.tsx +279 -0
  567. package/src/components/ui/database/icons.ts +15 -0
  568. package/src/components/ui/database/table-view.tsx +311 -0
  569. package/src/components/ui/date-picker.tsx +208 -0
  570. package/src/components/ui/date-time-picker.tsx +123 -0
  571. package/src/components/ui/dialog.tsx +151 -0
  572. package/src/components/ui/document-layout.tsx +52 -0
  573. package/src/components/ui/dropdown-menu.tsx +185 -0
  574. package/src/components/ui/editable-text.tsx +142 -0
  575. package/src/components/ui/empty-state.tsx +35 -0
  576. package/src/components/ui/error-state.tsx +67 -0
  577. package/src/components/ui/field-button.tsx +70 -0
  578. package/src/components/ui/file-preview.tsx +80 -0
  579. package/src/components/ui/file-uploader.tsx +375 -0
  580. package/src/components/ui/filter-builder.tsx +304 -0
  581. package/src/components/ui/focus-shell.tsx +48 -0
  582. package/src/components/ui/handle-row.tsx +252 -0
  583. package/src/components/ui/header-bar.tsx +15 -0
  584. package/src/components/ui/hover-card.tsx +30 -0
  585. package/src/components/ui/image-block.tsx +238 -0
  586. package/src/components/ui/image-card.tsx +95 -0
  587. package/src/components/ui/image-framer.tsx +160 -0
  588. package/src/components/ui/image-viewer.tsx +230 -0
  589. package/src/components/ui/image.tsx +200 -0
  590. package/src/components/ui/index.ts +178 -0
  591. package/src/components/ui/input.tsx +471 -0
  592. package/src/components/ui/link-block.tsx +85 -0
  593. package/src/components/ui/list-detail.tsx +115 -0
  594. package/src/components/ui/listbox.ts +26 -0
  595. package/src/components/ui/mac-card.tsx +46 -0
  596. package/src/components/ui/month-picker.tsx +119 -0
  597. package/src/components/ui/multi-select.tsx +221 -0
  598. package/src/components/ui/nav-tree.tsx +92 -0
  599. package/src/components/ui/page.tsx +73 -0
  600. package/src/components/ui/pagination.tsx +143 -0
  601. package/src/components/ui/picker-panel.tsx +69 -0
  602. package/src/components/ui/popover.tsx +42 -0
  603. package/src/components/ui/progress.tsx +76 -0
  604. package/src/components/ui/property.tsx +33 -0
  605. package/src/components/ui/radio-group.tsx +61 -0
  606. package/src/components/ui/rating.tsx +122 -0
  607. package/src/components/ui/save-status.tsx +53 -0
  608. package/src/components/ui/segmented.tsx +74 -0
  609. package/src/components/ui/select-menu.tsx +54 -0
  610. package/src/components/ui/select.tsx +147 -0
  611. package/src/components/ui/selection-bar.tsx +50 -0
  612. package/src/components/ui/separator.tsx +30 -0
  613. package/src/components/ui/settings-layout.tsx +117 -0
  614. package/src/components/ui/share-link.tsx +66 -0
  615. package/src/components/ui/sheet.tsx +90 -0
  616. package/src/components/ui/sidebar.tsx +627 -0
  617. package/src/components/ui/skeleton.tsx +22 -0
  618. package/src/components/ui/spinner.tsx +28 -0
  619. package/src/components/ui/spotlight.tsx +222 -0
  620. package/src/components/ui/stat-tile.tsx +25 -0
  621. package/src/components/ui/step-dialog.tsx +104 -0
  622. package/src/components/ui/steps-layout.tsx +91 -0
  623. package/src/components/ui/switch.tsx +55 -0
  624. package/src/components/ui/table.tsx +99 -0
  625. package/src/components/ui/tabs.tsx +41 -0
  626. package/src/components/ui/theme-toggle.tsx +80 -0
  627. package/src/components/ui/time-list.tsx +106 -0
  628. package/src/components/ui/time-picker.tsx +344 -0
  629. package/src/components/ui/toast.tsx +132 -0
  630. package/src/components/ui/toggle.tsx +76 -0
  631. package/src/components/ui/tooltip.tsx +78 -0
  632. package/src/components/ui/top-bar.tsx +118 -0
  633. package/src/components/ui/typography.tsx +204 -0
  634. package/src/components/ui/video-block.tsx +66 -0
  635. package/src/hooks/use-dismiss.ts +24 -0
  636. package/src/hooks/use-escape-first.ts +25 -0
  637. package/src/hooks/use-media-query.ts +23 -0
  638. package/src/hooks/use-save-queue.ts +78 -0
  639. package/src/hooks/use-selection.ts +51 -0
  640. package/src/hooks/use-shared-transition.ts +40 -0
  641. package/src/hooks/use-upload-queue.ts +111 -0
  642. package/src/lib/accent.ts +11 -0
  643. package/src/lib/bento.ts +87 -0
  644. package/src/lib/database.ts +322 -0
  645. package/src/lib/dates.ts +75 -0
  646. package/src/lib/document.ts +55 -0
  647. package/src/lib/embed.ts +62 -0
  648. package/src/lib/files.ts +73 -0
  649. package/src/lib/justified.ts +106 -0
  650. package/src/lib/keys.ts +72 -0
  651. package/src/lib/number.ts +29 -0
  652. package/src/lib/pointer.ts +3 -0
  653. package/src/lib/prepare-image.ts +141 -0
  654. package/src/lib/rich-text-dom.ts +138 -0
  655. package/src/lib/rich-text.ts +50 -0
  656. package/src/lib/spotlight.ts +78 -0
  657. package/src/lib/theme.ts +18 -0
  658. package/src/lib/time.ts +83 -0
  659. package/src/lib/tree.ts +41 -0
  660. package/src/lib/utils.ts +25 -0
  661. package/src/styles/notion.css +817 -0
@@ -0,0 +1,43 @@
1
+ export type ImageCopy = {
2
+ /** The longest edge, in pixels. */
3
+ edge?: number;
4
+ /** Or the height, for a thumbnail strip of even height. */
5
+ height?: number;
6
+ /** The most bytes the JPEG may be. */
7
+ bytes: number;
8
+ };
9
+ export type PreparedImage = {
10
+ display: Blob;
11
+ thumb: Blob;
12
+ /** The display copy's size. */
13
+ width: number;
14
+ height: number;
15
+ aspect: number;
16
+ /** SHA-256 of the original, as hex, when asked for. */
17
+ hash?: string;
18
+ };
19
+ export declare const QUALITIES: readonly [0.82, 0.72, 0.6, 0.5, 0.4];
20
+ /** The size a picture of `width` × `height` becomes for `copy`, never larger than it was. */
21
+ export declare function fitSize(width: number, height: number, copy: Pick<ImageCopy, "edge" | "height">): {
22
+ width: number;
23
+ height: number;
24
+ };
25
+ type Crop = {
26
+ x: number;
27
+ y: number;
28
+ width: number;
29
+ height: number;
30
+ };
31
+ /** `source` (its `crop`) drawn at `width` × `height`, halving on the way so nothing shimmers. */
32
+ export declare function resizeTo(source: CanvasImageSource, crop: Crop, width: number, height: number): HTMLCanvasElement;
33
+ /** The best quality JPEG that fits in `bytes`. */
34
+ export declare function jpegUnder(canvas: HTMLCanvasElement, bytes: number, qualities?: readonly number[]): Promise<Blob>;
35
+ export declare function prepareImage(file: Blob, { display, thumb, square, hash, qualities, }?: {
36
+ display?: ImageCopy;
37
+ thumb?: ImageCopy;
38
+ square?: boolean;
39
+ hash?: boolean;
40
+ qualities?: readonly number[];
41
+ }): Promise<PreparedImage>;
42
+ export {};
43
+ //# sourceMappingURL=prepare-image.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prepare-image.d.ts","sourceRoot":"","sources":["../../src/lib/prepare-image.ts"],"names":[],"mappings":"AAiBA,MAAM,MAAM,SAAS,GAAG;IACpB,mCAAmC;IACnC,IAAI,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,SAAqB,GACxB,GAAE;IAAE,OAAO,CAAC,EAAE,SAAS,CAAC;IAAC,KAAK,CAAC,EAAE,SAAS,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,CAAC;IAAC,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAAO,GACpH,OAAO,CAAC,aAAa,CAAC,CA4BxB"}
@@ -0,0 +1,105 @@
1
+ /* Turning a picture off a phone or a camera into what is worth uploading: a display
2
+ JPEG and a thumbnail, each under a byte budget, the right way up, never the
3
+ original. Three apps each wrote this (endgame, medialogue, triptrack); this is
4
+ the one, with their differences as options.
5
+
6
+ - The picture is turned upright from its EXIF orientation (createImageBitmap's
7
+ default) and drawn on white, so a cut-out PNG does not come out on black.
8
+ - It is halved until the last step is small: a canvas shrinking a picture to a
9
+ quarter or less in one go skips pixels and the result shimmers.
10
+ - Each copy is saved at the best quality that fits its budget, stepping down;
11
+ a photograph fits at the first. One that will not fit fails, rather than
12
+ sending what the server will refuse.
13
+ - `square` crops to the middle square first (an avatar, a cover).
14
+ - `hash` adds a SHA-256 of the original file, to spot a picture sent twice.
15
+
16
+ Browser only: it needs a canvas. */
17
+ export const QUALITIES = [0.82, 0.72, 0.6, 0.5, 0.4];
18
+ const DEFAULTS = {
19
+ display: { edge: 1600, bytes: 1_000_000 },
20
+ thumb: { edge: 400, bytes: 140_000 },
21
+ };
22
+ /** The size a picture of `width` × `height` becomes for `copy`, never larger than it was. */
23
+ export function fitSize(width, height, copy) {
24
+ const scale = Math.min(1, copy.height !== undefined ? copy.height / height : (copy.edge ?? Infinity) / Math.max(width, height));
25
+ return { width: Math.max(1, Math.round(width * scale)), height: Math.max(1, Math.round(height * scale)) };
26
+ }
27
+ function canvasOf(width, height) {
28
+ const canvas = document.createElement("canvas");
29
+ canvas.width = width;
30
+ canvas.height = height;
31
+ const context = canvas.getContext("2d");
32
+ if (context === null)
33
+ throw new Error("This browser could not resize the picture.");
34
+ context.fillStyle = "#fff";
35
+ context.fillRect(0, 0, width, height);
36
+ context.imageSmoothingQuality = "high";
37
+ return [canvas, context];
38
+ }
39
+ /** `source` (its `crop`) drawn at `width` × `height`, halving on the way so nothing shimmers. */
40
+ export function resizeTo(source, crop, width, height) {
41
+ let current = source;
42
+ let from = crop;
43
+ let w = crop.width;
44
+ let h = crop.height;
45
+ while (w / 2 >= width && h / 2 >= height) {
46
+ w = Math.round(w / 2);
47
+ h = Math.round(h / 2);
48
+ const [canvas, context] = canvasOf(w, h);
49
+ context.drawImage(current, from.x, from.y, from.width, from.height, 0, 0, w, h);
50
+ // A step's own canvas (never the caller's) is let go of once drawn from: iOS Safari caps the memory canvases may hold.
51
+ if (current !== source && current instanceof HTMLCanvasElement)
52
+ current.width = 0;
53
+ current = canvas;
54
+ from = { x: 0, y: 0, width: w, height: h };
55
+ }
56
+ const [canvas, context] = canvasOf(width, height);
57
+ context.drawImage(current, from.x, from.y, from.width, from.height, 0, 0, width, height);
58
+ if (current !== source && current instanceof HTMLCanvasElement)
59
+ current.width = 0;
60
+ return canvas;
61
+ }
62
+ const encode = (canvas, quality) => new Promise((resolve, reject) => canvas.toBlob((blob) => (blob ? resolve(blob) : reject(new Error("This browser could not save the picture."))), "image/jpeg", quality));
63
+ /** The best quality JPEG that fits in `bytes`. */
64
+ export async function jpegUnder(canvas, bytes, qualities = QUALITIES) {
65
+ let blob = null;
66
+ for (const quality of qualities) {
67
+ blob = await encode(canvas, quality);
68
+ if (blob.size <= bytes)
69
+ return blob;
70
+ }
71
+ throw new Error("That picture would not shrink far enough to keep.");
72
+ }
73
+ const hex = (buffer) => [...new Uint8Array(buffer)].map((b) => b.toString(16).padStart(2, "0")).join("");
74
+ export async function prepareImage(file, { display = DEFAULTS.display, thumb = DEFAULTS.thumb, square = false, hash = false, qualities = QUALITIES, } = {}) {
75
+ let bitmap;
76
+ try {
77
+ bitmap = await createImageBitmap(file);
78
+ }
79
+ catch {
80
+ throw new Error("This browser cannot open that kind of picture.");
81
+ }
82
+ try {
83
+ const side = Math.min(bitmap.width, bitmap.height);
84
+ const crop = square
85
+ ? { x: Math.round((bitmap.width - side) / 2), y: Math.round((bitmap.height - side) / 2), width: side, height: side }
86
+ : { x: 0, y: 0, width: bitmap.width, height: bitmap.height };
87
+ const size = fitSize(crop.width, crop.height, display);
88
+ const big = resizeTo(bitmap, crop, size.width, size.height);
89
+ const small = fitSize(size.width, size.height, thumb);
90
+ const little = resizeTo(big, { x: 0, y: 0, width: size.width, height: size.height }, small.width, small.height);
91
+ return {
92
+ display: await jpegUnder(big, display.bytes, qualities),
93
+ thumb: await jpegUnder(little, thumb.bytes, qualities),
94
+ width: size.width,
95
+ height: size.height,
96
+ aspect: size.width / size.height,
97
+ ...(hash ? { hash: hex(await crypto.subtle.digest("SHA-256", await file.arrayBuffer())) } : null),
98
+ };
99
+ }
100
+ finally {
101
+ // A 24 MP bitmap is about 100 MB; the next file should not wait for the collector.
102
+ bitmap.close();
103
+ }
104
+ }
105
+ //# sourceMappingURL=prepare-image.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prepare-image.js","sourceRoot":"","sources":["../../src/lib/prepare-image.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;sCAesC;AAsBtC,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAU,CAAC;AAE9D,MAAM,QAAQ,GAAG;IACb,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE;IACzC,KAAK,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE;CACH,CAAC;AAEtC,6FAA6F;AAC7F,MAAM,UAAU,OAAO,CAAC,KAAa,EAAE,MAAc,EAAE,IAAwC;IAC3F,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,KAAK,SAAS,CAA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AK,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,EAAE,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;QAChH,OAAO;YACH,OAAO,EAAE,MAAM,SAAS,CAAC,GAAG,EAAE,OAAO,CAAC,KAAK,EAAE,SAAS,CAAC;YACvD,KAAK,EAAE,MAAM,SAAS,CAAC,MAAM,EAAE,KAAK,CAAC,KAAK,EAAE,SAAS,CAAC;YACtD,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,MAAM,EAAE,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,MAAM;YAChC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,MAAM,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;SACpG,CAAC;IACN,CAAC;YAAS,CAAC;QACP,mFAAmF;QACnF,MAAM,CAAC,KAAK,EAAE,CAAC;IACnB,CAAC;AACL,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { type Text } from "./rich-text.js";
2
+ /** Inline code, the same in Code, the editor and the read view. */
3
+ export declare const CODE_CLASSES = "rounded-small bg-tag-red-bg/70 px-1.5 py-0.5 font-mono text-[0.85em] text-tag-red-ink";
4
+ export declare function spansToHtml(text: Text): string;
5
+ export declare function readSpans(root: HTMLElement): Text;
6
+ export declare function caretOffset(root: HTMLElement): number | null;
7
+ export declare function setCaret(root: HTMLElement, at: number | "end"): void;
8
+ export declare function caretRect(): DOMRect | null;
9
+ /**
10
+ * Whether the caret sits on the first or the last visual line of `root`, where
11
+ * ArrowUp or ArrowDown leaves the block, as in Notion. Measured, because a
12
+ * wrapped paragraph has several lines and only its edges lead out. An empty
13
+ * block, or a caret the browser cannot place, counts as both.
14
+ */
15
+ export declare function caretOnEdgeLine(root: HTMLElement, edge: "first" | "last"): boolean;
16
+ //# sourceMappingURL=rich-text-dom.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rich-text-dom.d.ts","sourceRoot":"","sources":["../../src/lib/rich-text-dom.ts"],"names":[],"mappings":"AACA,OAAO,EAAwB,KAAK,IAAI,EAAE,MAAM,gBAAgB,CAAC;AASjE,mEAAmE;AACnE,eAAO,MAAM,YAAY,0FAA0F,CAAC;AAKpH,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAe9C;AAMD,wBAAgB,SAAS,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,CA8BjD;AAYD,wBAAgB,WAAW,CAAC,IAAI,EAAE,WAAW,GAAG,MAAM,GAAG,IAAI,CAS5D;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,WAAW,EAAE,EAAE,EAAE,MAAM,GAAG,KAAK,GAAG,IAAI,CAsBpE;AAED,wBAAgB,SAAS,IAAI,OAAO,GAAG,IAAI,CAS1C;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,CAMlF"}
@@ -0,0 +1,145 @@
1
+ import { isSafeHref } from "./embed.js";
2
+ import { normalize } from "./rich-text.js";
3
+ /* Bridges the span model and the DOM inside a contentEditable element. A link is
4
+ written and read back only when it is a web or mail address, so a `javascript:`
5
+ href pasted in as HTML never survives into the document. */
6
+ const escape = (s) => s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
7
+ const UNDERLINE = "link";
8
+ /** Inline code, the same in Code, the editor and the read view. */
9
+ export const CODE_CLASSES = "rounded-small bg-tag-red-bg/70 px-1.5 py-0.5 font-mono text-[0.85em] text-tag-red-ink";
10
+ const CODE = CODE_CLASSES;
11
+ const PAGE_ICON = '<svg class="mr-1 mb-0.5 inline size-[1em] text-ink-secondary" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"/><path d="M14 2v4a2 2 0 0 0 2 2h4"/><path d="M10 9H8"/><path d="M16 13H8"/><path d="M16 17H8"/></svg>';
12
+ export function spansToHtml(text) {
13
+ return text
14
+ .map((span) => {
15
+ // A page link is one uneditable token, as a Notion mention is.
16
+ if (span.page)
17
+ return `<a data-page="${escape(span.page)}" href="/${escape(span.page)}" contenteditable="false" class="font-medium cursor-pointer rounded-small hover:bg-tint-hover">${PAGE_ICON}<span class="${UNDERLINE}">${escape(span.text)}</span></a>`;
18
+ let html = escape(span.text);
19
+ if (span.code)
20
+ html = `<code class="${CODE}">${html}</code>`;
21
+ if (span.strike)
22
+ html = `<s>${html}</s>`;
23
+ if (span.italic)
24
+ html = `<em>${html}</em>`;
25
+ if (span.bold)
26
+ html = `<strong class="font-semibold">${html}</strong>`;
27
+ if (span.href && isSafeHref(span.href))
28
+ html = `<a href="${escape(span.href)}" target="_blank" rel="noreferrer" class="${UNDERLINE}">${html}</a>`;
29
+ return html;
30
+ })
31
+ .join("");
32
+ }
33
+ // Reads back whatever the browser left after an edit: our own tags, plus the <b>,
34
+ // <i>, <strike> and styled spans that execCommand produces.
35
+ export function readSpans(root) {
36
+ const out = [];
37
+ const walk = (node, marks) => {
38
+ if (node.nodeType === Node.TEXT_NODE) {
39
+ out.push({ ...marks, text: (node.nodeValue ?? "").replace(/ /g, " ") });
40
+ return;
41
+ }
42
+ if (!(node instanceof HTMLElement))
43
+ return;
44
+ if (node.tagName === "BR") {
45
+ out.push({ ...marks, text: "\n" });
46
+ return;
47
+ }
48
+ if (node.dataset.page) {
49
+ out.push({ text: node.textContent ?? "", page: node.dataset.page });
50
+ return;
51
+ }
52
+ const m = { ...marks };
53
+ const tag = node.tagName;
54
+ const { fontWeight, fontStyle, textDecorationLine } = node.style;
55
+ if (tag === "B" || tag === "STRONG" || fontWeight === "bold" || Number(fontWeight) >= 600)
56
+ m.bold = true;
57
+ if (fontWeight === "normal" || fontWeight === "400")
58
+ delete m.bold;
59
+ if (tag === "I" || tag === "EM" || fontStyle === "italic")
60
+ m.italic = true;
61
+ if (tag === "S" || tag === "STRIKE" || tag === "DEL" || textDecorationLine.includes("line-through"))
62
+ m.strike = true;
63
+ if (tag === "CODE")
64
+ m.code = true;
65
+ const href = tag === "A" ? node.getAttribute("href") : null;
66
+ if (href !== null && isSafeHref(href))
67
+ m.href = href;
68
+ node.childNodes.forEach((child) => walk(child, m));
69
+ };
70
+ root.childNodes.forEach((child) => walk(child, {}));
71
+ return normalize(out);
72
+ }
73
+ const length = (node) => {
74
+ if (node.nodeType === Node.TEXT_NODE)
75
+ return node.nodeValue?.length ?? 0;
76
+ if (node instanceof HTMLElement && node.tagName === "BR")
77
+ return 1;
78
+ let n = 0;
79
+ node.childNodes.forEach((child) => (n += length(child)));
80
+ return n;
81
+ };
82
+ // The caret as a character offset into the element's text, or null when the
83
+ // selection is elsewhere or is a range.
84
+ export function caretOffset(root) {
85
+ const sel = window.getSelection();
86
+ if (!sel || sel.rangeCount === 0 || !sel.isCollapsed)
87
+ return null;
88
+ const range = sel.getRangeAt(0);
89
+ if (!root.contains(range.endContainer))
90
+ return null;
91
+ const before = document.createRange();
92
+ before.selectNodeContents(root);
93
+ before.setEnd(range.endContainer, range.endOffset);
94
+ return length(before.cloneContents());
95
+ }
96
+ export function setCaret(root, at) {
97
+ root.focus();
98
+ const sel = window.getSelection();
99
+ if (!sel)
100
+ return;
101
+ const range = document.createRange();
102
+ range.selectNodeContents(root);
103
+ range.collapse(at !== "end");
104
+ if (typeof at === "number" && at > 0) {
105
+ let left = at;
106
+ const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT);
107
+ for (let node = walker.nextNode(); node; node = walker.nextNode()) {
108
+ const n = node.nodeValue?.length ?? 0;
109
+ if (left <= n) {
110
+ range.setStart(node, left);
111
+ range.collapse(true);
112
+ break;
113
+ }
114
+ left -= n;
115
+ }
116
+ }
117
+ sel.removeAllRanges();
118
+ sel.addRange(range);
119
+ }
120
+ export function caretRect() {
121
+ const sel = window.getSelection();
122
+ if (!sel || sel.rangeCount === 0)
123
+ return null;
124
+ const range = sel.getRangeAt(0);
125
+ const rect = range.getClientRects()[0] ?? range.getBoundingClientRect();
126
+ // An empty line has no rects; fall back to the element the caret sits in.
127
+ if (rect.width === 0 && rect.height === 0 && range.startContainer instanceof Element)
128
+ return range.startContainer.getBoundingClientRect();
129
+ return rect;
130
+ }
131
+ /**
132
+ * Whether the caret sits on the first or the last visual line of `root`, where
133
+ * ArrowUp or ArrowDown leaves the block, as in Notion. Measured, because a
134
+ * wrapped paragraph has several lines and only its edges lead out. An empty
135
+ * block, or a caret the browser cannot place, counts as both.
136
+ */
137
+ export function caretOnEdgeLine(root, edge) {
138
+ const rect = caretRect();
139
+ if (rect === null || (rect.top === 0 && rect.bottom === 0))
140
+ return true;
141
+ const box = root.getBoundingClientRect();
142
+ const line = parseFloat(getComputedStyle(root).lineHeight) || rect.height || 20;
143
+ return edge === "first" ? rect.top - box.top < line * 0.8 : box.bottom - rect.bottom < line * 0.8;
144
+ }
145
+ //# sourceMappingURL=rich-text-dom.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rich-text-dom.js","sourceRoot":"","sources":["../../src/lib/rich-text-dom.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,SAAS,EAAwB,MAAM,gBAAgB,CAAC;AAEjE;;8DAE8D;AAE9D,MAAM,MAAM,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,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AiB,EAAE,IAAsB;IACrE,MAAM,IAAI,GAAG,SAAS,EAAE,CAAC;IACzB,IAAI,IAAI,KAAK,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IACxE,MAAM,GAAG,GAAG,IAAI,CAAC,qBAAqB,EAAE,CAAC;IACzC,MAAM,IAAI,GAAG,UAAU,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,IAAI,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC;IAChF,OAAO,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,GAAG,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,GAAG,IAAI,GAAG,GAAG,CAAC;AACtG,CAAC"}
@@ -0,0 +1,15 @@
1
+ export type Span = {
2
+ text: string;
3
+ bold?: true;
4
+ italic?: true;
5
+ strike?: true;
6
+ code?: true;
7
+ href?: string;
8
+ page?: string;
9
+ };
10
+ export type Text = Span[];
11
+ export declare const plain: (text: Text) => string;
12
+ export declare function normalize(text: Text): Text;
13
+ export declare function split(text: Text, at: number): [Text, Text];
14
+ export declare function cut(text: Text, from: number, to: number): Text;
15
+ //# sourceMappingURL=rich-text.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rich-text.d.ts","sourceRoot":"","sources":["../../src/lib/rich-text.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,IAAI,GAAG;IACf,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,MAAM,CAAC,EAAE,IAAI,CAAC;IACd,MAAM,CAAC,EAAE,IAAI,CAAC;IACd,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AACF,MAAM,MAAM,IAAI,GAAG,IAAI,EAAE,CAAC;AAE1B,eAAO,MAAM,KAAK,GAAI,MAAM,IAAI,KAAG,MAA0C,CAAC;AAO9E,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAS1C;AAGD,wBAAgB,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAW1D;AAGD,wBAAgB,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI,CAE9D"}
@@ -0,0 +1,35 @@
1
+ export const plain = (text) => text.map((s) => s.text).join("");
2
+ const sameMarks = (a, b) => a.bold === b.bold && a.italic === b.italic && a.strike === b.strike && a.code === b.code && a.href === b.href && a.page === b.page;
3
+ // Drops empty spans and merges neighbours that carry the same marks. A page link
4
+ // never merges: two links to one page side by side are still two links.
5
+ export function normalize(text) {
6
+ const out = [];
7
+ for (const span of text) {
8
+ if (span.text === "")
9
+ continue;
10
+ const last = out.at(-1);
11
+ if (last && !span.page && sameMarks(last, span))
12
+ out[out.length - 1] = { ...last, text: last.text + span.text };
13
+ else
14
+ out.push(span);
15
+ }
16
+ return out;
17
+ }
18
+ // Splits at a character offset into what comes before and what comes after.
19
+ export function split(text, at) {
20
+ const before = [];
21
+ const after = [];
22
+ let seen = 0;
23
+ for (const span of text) {
24
+ const cut = Math.min(Math.max(at - seen, 0), span.text.length);
25
+ before.push({ ...span, text: span.text.slice(0, cut) });
26
+ after.push({ ...span, text: span.text.slice(cut) });
27
+ seen += span.text.length;
28
+ }
29
+ return [normalize(before), normalize(after)];
30
+ }
31
+ // Removes the characters in [from, to).
32
+ export function cut(text, from, to) {
33
+ return normalize([...split(text, from)[0], ...split(text, to)[1]]);
34
+ }
35
+ //# sourceMappingURL=rich-text.js.map
@@ -0,0 +1 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,4EAA4E;AAC5E,MAAM,UAAU,KAAK,CAAC,IAAU,EAAE,EAAU;IACxC,MAAM,MAAM,GAAS,EAAE,CAAC;IACxB,MAAM,KAAK,GAAS,EAAE,CAAC;IACvB,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE,CAAC;QACtB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC/D,MAAM,CAAC,IAAI,CAAC,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;QACxD,KAAK,CAAC,IAAI,CAAC,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACpD,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;IAC7B,CAAC;IACD,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;AACjD,CAAC;AAED,wCAAwC;AACxC,MAAM,UAAU,GAAG,CAAC,IAAU,EAAE,IAAY,EAAE,EAAU;IACpD,OAAO,SAAS,CAAC,CAAC,GAAG,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACvE,CAAC"}
@@ -0,0 +1,22 @@
1
+ export type SpotlightEntry = {
2
+ key: string;
3
+ label: string;
4
+ /** Shown after the label, and searched: where the page lives, what it is. */
5
+ hint?: string;
6
+ /** Heads a run of entries while nothing is typed; searched too. */
7
+ group?: string;
8
+ /** Searched but never shown: other names for the same page. */
9
+ keywords?: string[];
10
+ };
11
+ export type Ranked<T> = {
12
+ item: T;
13
+ score: number;
14
+ hits: number[];
15
+ };
16
+ /**
17
+ * The entries that match `query`, best first, each with the label positions to
18
+ * highlight. Nothing typed keeps every entry in the order given; equal scores
19
+ * keep that order too, so the owner's ordering breaks ties.
20
+ */
21
+ export declare function rankEntries<T extends SpotlightEntry>(entries: T[], query: string): Ranked<T>[];
22
+ //# sourceMappingURL=spotlight.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spotlight.d.ts","sourceRoot":"","sources":["../../src/lib/spotlight.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,cAAc,GAAG;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,6EAA6E;IAC7E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,mEAAmE;IACnE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+DAA+D;IAC/D,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI;IAAE,IAAI,EAAE,CAAC,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AA6BnE;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,cAAc,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,CAwB9F"}
@@ -0,0 +1,66 @@
1
+ /* Ranking for the Spotlight: what was typed against a list of places to go.
2
+
3
+ Every word typed has to be found somewhere in an entry — its label, or the
4
+ quieter words around it (its hint, its group, keywords) — so "korea money" finds
5
+ the Money page of the Korea trip. A word found in the label counts for more,
6
+ and more again at the start of the label or of one of its words; a word whose
7
+ letters only appear in order ("gwngjng") still counts, for the label alone. */
8
+ const wordStart = (text, at) => at === 0 || !/[\p{L}\p{N}]/u.test(text[at - 1]);
9
+ /** The positions of `word`'s letters, in order, in `text`, or null. */
10
+ function inOrder(text, word) {
11
+ const hits = [];
12
+ let from = 0;
13
+ for (const ch of word) {
14
+ const at = text.indexOf(ch, from);
15
+ if (at < 0)
16
+ return null;
17
+ hits.push(at);
18
+ from = at + 1;
19
+ }
20
+ return hits;
21
+ }
22
+ function scoreWord(label, rest, word) {
23
+ const at = label.indexOf(word);
24
+ if (at >= 0) {
25
+ const hits = Array.from({ length: word.length }, (_, k) => at + k);
26
+ return { score: at === 0 ? 100 : wordStart(label, at) ? 80 : 50, hits };
27
+ }
28
+ const elsewhere = rest.indexOf(word);
29
+ if (elsewhere >= 0)
30
+ return { score: wordStart(rest, elsewhere) ? 30 : 15, hits: [] };
31
+ const scattered = word.length > 1 ? inOrder(label, word) : null;
32
+ return scattered === null ? null : { score: 20, hits: scattered };
33
+ }
34
+ /**
35
+ * The entries that match `query`, best first, each with the label positions to
36
+ * highlight. Nothing typed keeps every entry in the order given; equal scores
37
+ * keep that order too, so the owner's ordering breaks ties.
38
+ */
39
+ export function rankEntries(entries, query) {
40
+ const words = query.toLowerCase().split(/\s+/).filter(Boolean);
41
+ if (words.length === 0)
42
+ return entries.map((item) => ({ item, score: 0, hits: [] }));
43
+ const ranked = [];
44
+ for (const item of entries) {
45
+ const label = item.label.toLowerCase();
46
+ const rest = [item.hint, item.group, ...(item.keywords ?? [])].filter(Boolean).join(" · ").toLowerCase();
47
+ let score = 0;
48
+ const hits = new Set();
49
+ let matched = true;
50
+ for (const word of words) {
51
+ const found = scoreWord(label, rest, word);
52
+ if (found === null) {
53
+ matched = false;
54
+ break;
55
+ }
56
+ score += found.score;
57
+ for (const h of found.hits)
58
+ hits.add(h);
59
+ }
60
+ // A short label that matches is a closer match than a long one.
61
+ if (matched)
62
+ ranked.push({ item, score: score - label.length / 100, hits: [...hits].sort((a, b) => a - b) });
63
+ }
64
+ return ranked.sort((a, b) => b.score - a.score);
65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AAQ,IAAI,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;QACzG,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;QAC/B,IAAI,OAAO,GAAG,IAAI,CAAC;QACnB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACvB,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;YAC3C,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;gBACjB,OAAO,GAAG,KAAK,CAAC;gBAChB,MAAM;YACV,CAAC;YACD,KAAK,IAAI,KAAK,CAAC,KAAK,CAAC;YACrB,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC,IAAI;gBAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAC5C,CAAC;QACD,gEAAgE;QAChE,IAAI,OAAO;YAAE,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,GAAG,KAAK,CAAC,MAAM,GAAG,GAAG,EAAE,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC;IACjH,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;AACpD,CAAC"}
@@ -0,0 +1,6 @@
1
+ export type Theme = "light" | "dark" | "system";
2
+ export declare const THEMES: readonly Theme[];
3
+ export declare const THEME_KEY = "theme";
4
+ export declare const isTheme: (value: unknown) => value is Theme;
5
+ export declare function themeInitScript(storageKey?: string): string;
6
+ //# sourceMappingURL=theme.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/lib/theme.ts"],"names":[],"mappings":"AASA,MAAM,MAAM,KAAK,GAAG,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC;AAChD,eAAO,MAAM,MAAM,EAAE,SAAS,KAAK,EAAgC,CAAC;AACpE,eAAO,MAAM,SAAS,UAAU,CAAC;AAEjC,eAAO,MAAM,OAAO,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,KAAoE,CAAC;AAEvH,wBAAgB,eAAe,CAAC,UAAU,GAAE,MAAkB,GAAG,MAAM,CAEtE"}
@@ -0,0 +1,15 @@
1
+ /* Light, dark, or whatever the system says, kept in localStorage under a key the app
2
+ chooses (each app on one domain wants its own). Dark mode is the `dark` class on
3
+ <html>; the stylesheet does the rest.
4
+
5
+ themeInitScript() is the same choice made before first paint, so a reload never
6
+ flashes the wrong theme: put it in a <script> in <head> (index.html in Vite,
7
+ `dangerouslySetInnerHTML` in Next's root layout). It also applies the colour theme
8
+ kept by AccentPicker. */
9
+ export const THEMES = ["light", "dark", "system"];
10
+ export const THEME_KEY = "theme";
11
+ export const isTheme = (value) => value === "light" || value === "dark" || value === "system";
12
+ export function themeInitScript(storageKey = THEME_KEY) {
13
+ return `try{var t=localStorage.getItem(${JSON.stringify(storageKey)});if(t==="dark"||((t===null||t==="system")&&matchMedia("(prefers-color-scheme: dark)").matches))document.documentElement.classList.add("dark");var a=localStorage.getItem("accent");if(a&&a!=="paper")document.documentElement.dataset.accent=a}catch(e){}`;
14
+ }
15
+ //# sourceMappingURL=theme.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme.js","sourceRoot":"","sources":["../../src/lib/theme.ts"],"names":[],"mappings":"AAAA;;;;;;;2BAO2B;AAG3B,MAAM,CAAC,MAAM,MAAM,GAAqB,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;AACpE,MAAM,CAAC,MAAM,SAAS,GAAG,OAAO,CAAC;AAEjC,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,KAAc,EAAkB,EAAE,CAAC,KAAK,KAAK,OAAO,IAAI,KAAK,KAAK,MAAM,IAAI,KAAK,KAAK,QAAQ,CAAC;AAEvH,MAAM,UAAU,eAAe,CAAC,aAAqB,SAAS;IAC1D,OAAO,kCAAkC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,4PAA4P,CAAC;AACpU,CAAC"}
@@ -0,0 +1,19 @@
1
+ export type HourCycle = "h12" | "h23";
2
+ /** Whether this reader's locale writes times on a 12-hour clock (9:30 PM) or a 24-hour one (21:30). */
3
+ export declare function localHourCycle(locale?: string): HourCycle;
4
+ export declare function parseTime(text: string): string | null;
5
+ /** "21:30" → "9:30 PM" on a 12-hour clock, "21:30" on a 24-hour one. */
6
+ export declare function formatTime(time: string, cycle?: HourCycle): string;
7
+ /** Minutes since midnight. */
8
+ export declare const minutesOf: (time: string) => number;
9
+ export declare const timeOf: (minutes: number) => string;
10
+ /** Every `step` minutes through the day (from `after`, exclusive, when given), plus `include` if it falls between. */
11
+ export declare function timesEvery(step: number, { after, include }?: {
12
+ after?: string | null;
13
+ include?: string | null;
14
+ }): string[];
15
+ /** 30 → "30 min", 60 → "1 hr", 90 → "1.5 hrs", 135 → "2 hr 15 min". */
16
+ export declare function durationLabel(minutes: number): string;
17
+ /** The listed time closest to `time` (or to now), for where a list should open. */
18
+ export declare function nearest(times: readonly string[], time?: string | null, now?: Date): string | undefined;
19
+ //# sourceMappingURL=time.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../../src/lib/time.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,KAAK,CAAC;AAItC,uGAAuG;AACvG,wBAAgB,cAAc,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAOzD;AAQD,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAiBrD;AAED,wEAAwE;AACxE,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,GAAE,SAA4B,GAAG,MAAM,CAKpF;AAED,8BAA8B;AAC9B,eAAO,MAAM,SAAS,GAAI,MAAM,MAAM,KAAG,MAGxC,CAAC;AAEF,eAAO,MAAM,MAAM,GAAI,SAAS,MAAM,KAAG,MAAsE,CAAC;AAEhH,sHAAsH;AACtH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,GAAE;IAAE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAO,GAAG,MAAM,EAAE,CAO9H;AAED,uEAAuE;AACvE,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAMrD;AAED,mFAAmF;AACnF,wBAAgB,OAAO,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,EAAE,GAAG,GAAE,IAAiB,GAAG,MAAM,GAAG,SAAS,CAIlH"}