@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,79 @@
1
+ import type { Text } from "./rich-text.js";
2
+ /** Every block has an id the editor chose, so one can be focused before it is saved. */
3
+ type Id = {
4
+ id: number;
5
+ };
6
+ export type Block = Id & ({
7
+ type: "paragraph";
8
+ text: Text;
9
+ } | {
10
+ type: "heading";
11
+ level: 1 | 2 | 3;
12
+ text: Text;
13
+ } | {
14
+ type: "bullet" | "numbered";
15
+ text: Text;
16
+ children: Block[];
17
+ } | {
18
+ type: "check";
19
+ checked: boolean;
20
+ text: Text;
21
+ children: Block[];
22
+ } | {
23
+ type: "quote";
24
+ text: Text;
25
+ } | {
26
+ type: "divider";
27
+ }
28
+ /**
29
+ * A picture. `src` is what the browser loads; `ref` is the owner's own name
30
+ * for an uploaded one (its id in the owner's store), kept beside it so the
31
+ * owner can tell which uploads a document still uses. `width` is the share
32
+ * of the column; `aspect` holds the shape so nothing moves while it loads.
33
+ */
34
+ | {
35
+ type: "image";
36
+ src?: string;
37
+ ref?: string;
38
+ aspect?: number;
39
+ caption: Text;
40
+ width: number;
41
+ }
42
+ /** A YouTube or Vimeo video, played in place. Empty until a link is given. */
43
+ | {
44
+ type: "video";
45
+ url: string;
46
+ caption: Text;
47
+ }
48
+ /** A web page as a card, with a name the writer types. */
49
+ | {
50
+ type: "bookmark";
51
+ url: string;
52
+ title: string;
53
+ });
54
+ /**
55
+ * A block an app adds through a BlockExtension (components/editor): its own
56
+ * `type`, and whatever fields it needs. One with `text` is written in like a
57
+ * paragraph; one with `children` holds blocks; one with neither is picked whole.
58
+ */
59
+ export type CustomBlock = {
60
+ id: number;
61
+ type: string;
62
+ text?: Text;
63
+ children?: AnyBlock[];
64
+ [field: string]: unknown;
65
+ };
66
+ /** What a document holds: the kit's blocks and any an app adds. */
67
+ export type AnyBlock = Block | CustomBlock;
68
+ /** List items nest under one another and run together as one list. */
69
+ export declare const LISTS: readonly ["bullet", "numbered", "check"];
70
+ export declare const isListType: (type: string) => boolean;
71
+ /** The kinds that hold children. */
72
+ export declare const nests: (type: string) => boolean;
73
+ /** Whether `child` may sit inside `parent`. Lists hold list items. */
74
+ export declare const holds: (parent: string, child: string) => boolean;
75
+ /** Kinds without words: picked as a whole in the editor rather than given a caret. */
76
+ export declare const WHOLE: readonly ["divider", "image", "video", "bookmark"];
77
+ export declare const isWhole: (type: string) => boolean;
78
+ export {};
79
+ //# sourceMappingURL=document.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../src/lib/document.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAQ3C,wFAAwF;AACxF,KAAK,EAAE,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC;AAEzB,MAAM,MAAM,KAAK,GAAG,EAAE,GAClB,CACM;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,IAAI,EAAE,IAAI,CAAA;CAAE,GACjC;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAAC,IAAI,EAAE,IAAI,CAAA;CAAE,GACjD;IAAE,IAAI,EAAE,QAAQ,GAAG,UAAU,CAAC;IAAC,IAAI,EAAE,IAAI,CAAC;IAAC,QAAQ,EAAE,KAAK,EAAE,CAAA;CAAE,GAC9D;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,IAAI,CAAC;IAAC,QAAQ,EAAE,KAAK,EAAE,CAAA;CAAE,GAClE;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,IAAI,CAAA;CAAE,GAC7B;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE;AACrB;;;;;GAKG;GACD;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE;AAC9F,8EAA8E;GAC5E;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,IAAI,CAAA;CAAE;AAC/C,0DAA0D;GACxD;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CACrD,CAAC;AAEN;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,CAAC;IAAC,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,CAAC;AAErH,mEAAmE;AACnE,MAAM,MAAM,QAAQ,GAAG,KAAK,GAAG,WAAW,CAAC;AAE3C,sEAAsE;AACtE,eAAO,MAAM,KAAK,0CAA2C,CAAC;AAC9D,eAAO,MAAM,UAAU,GAAI,MAAM,MAAM,KAAG,OAAsD,CAAC;AAEjG,oCAAoC;AACpC,eAAO,MAAM,KAAK,GAAI,MAAM,MAAM,KAAG,OAA2B,CAAC;AAEjE,sEAAsE;AACtE,eAAO,MAAM,KAAK,GAAI,QAAQ,MAAM,EAAE,OAAO,MAAM,KAAG,OAAkD,CAAC;AAEzG,sFAAsF;AACtF,eAAO,MAAM,KAAK,oDAAqD,CAAC;AACxE,eAAO,MAAM,OAAO,GAAI,MAAM,MAAM,KAAG,OAAsD,CAAC"}
@@ -0,0 +1,11 @@
1
+ /** List items nest under one another and run together as one list. */
2
+ export const LISTS = ["bullet", "numbered", "check"];
3
+ export const isListType = (type) => LISTS.includes(type);
4
+ /** The kinds that hold children. */
5
+ export const nests = (type) => isListType(type);
6
+ /** Whether `child` may sit inside `parent`. Lists hold list items. */
7
+ export const holds = (parent, child) => isListType(parent) && isListType(child);
8
+ /** Kinds without words: picked as a whole in the editor rather than given a caret. */
9
+ export const WHOLE = ["divider", "image", "video", "bookmark"];
10
+ export const isWhole = (type) => WHOLE.includes(type);
11
+ //# sourceMappingURL=document.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"document.js","sourceRoot":"","sources":["../../src/lib/document.ts"],"names":[],"mappings":"AA0CA,sEAAsE;AACtE,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,QAAQ,EAAE,UAAU,EAAE,OAAO,CAAU,CAAC;AAC9D,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAY,EAAW,EAAE,CAAE,KAA2B,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAEjG,oCAAoC;AACpC,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,IAAY,EAAW,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;AAEjE,sEAAsE;AACtE,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,MAAc,EAAE,KAAa,EAAW,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC;AAEzG,sFAAsF;AACtF,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,CAAU,CAAC;AACxE,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,IAAY,EAAW,EAAE,CAAE,KAA2B,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC"}
@@ -0,0 +1,14 @@
1
+ /** A web address. Anything else, `javascript:` above all, is refused. */
2
+ export declare function isWebUrl(value: string): boolean;
3
+ /** A link in text a reader may follow: a web or mail address. Never `javascript:` or `data:`. */
4
+ export declare function isSafeHref(value: string): boolean;
5
+ /** The site a link is on, for showing in place of a missing name. */
6
+ export declare function hostOf(url: string): string;
7
+ /**
8
+ * Where a YouTube or Vimeo link plays, or null when it is not one. YouTube is
9
+ * embedded from its privacy-enhanced domain, which sets no cookie until the video
10
+ * is played, and Vimeo is asked not to track. A start time in a YouTube link
11
+ * (`t=`) is kept.
12
+ */
13
+ export declare function videoEmbed(url: string): string | null;
14
+ //# sourceMappingURL=embed.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"embed.d.ts","sourceRoot":"","sources":["../../src/lib/embed.ts"],"names":[],"mappings":"AAIA,yEAAyE;AACzE,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAQ/C;AAED,iGAAiG;AACjG,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEjD;AAED,qEAAqE;AACrE,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAM1C;AASD;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAmBrD"}
@@ -0,0 +1,63 @@
1
+ /* Addresses for things embedded in a document: what counts as a web address, and
2
+ where a video link plays. Pure, so a server can check what a browser sends with
3
+ the same rules. */
4
+ /** A web address. Anything else, `javascript:` above all, is refused. */
5
+ export function isWebUrl(value) {
6
+ if (!/^https?:\/\//i.test(value))
7
+ return false;
8
+ try {
9
+ new URL(value);
10
+ return true;
11
+ }
12
+ catch {
13
+ return false;
14
+ }
15
+ }
16
+ /** A link in text a reader may follow: a web or mail address. Never `javascript:` or `data:`. */
17
+ export function isSafeHref(value) {
18
+ return /^mailto:/i.test(value) || isWebUrl(value);
19
+ }
20
+ /** The site a link is on, for showing in place of a missing name. */
21
+ export function hostOf(url) {
22
+ try {
23
+ return new URL(url).hostname.replace(/^www\./, "");
24
+ }
25
+ catch {
26
+ return url;
27
+ }
28
+ }
29
+ /** "1h2m3s", "90s" or "90" as seconds. */
30
+ function seconds(t) {
31
+ const m = t?.match(/^(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s?)?$/);
32
+ if (!m || !t)
33
+ return null;
34
+ return Number(m[1] ?? 0) * 3600 + Number(m[2] ?? 0) * 60 + Number(m[3] ?? 0);
35
+ }
36
+ /**
37
+ * Where a YouTube or Vimeo link plays, or null when it is not one. YouTube is
38
+ * embedded from its privacy-enhanced domain, which sets no cookie until the video
39
+ * is played, and Vimeo is asked not to track. A start time in a YouTube link
40
+ * (`t=`) is kept.
41
+ */
42
+ export function videoEmbed(url) {
43
+ if (!isWebUrl(url))
44
+ return null;
45
+ const u = new URL(url);
46
+ const host = u.hostname.replace(/^(www|m|music)\./, "");
47
+ if (host === "vimeo.com") {
48
+ const id = u.pathname.match(/^\/(\d+)/)?.[1];
49
+ return id === undefined ? null : `https://player.vimeo.com/video/${id}?dnt=1`;
50
+ }
51
+ const id = host === "youtu.be"
52
+ ? u.pathname.slice(1)
53
+ : host === "youtube.com"
54
+ ? u.pathname === "/watch"
55
+ ? u.searchParams.get("v")
56
+ : (u.pathname.match(/^\/(?:shorts|embed|live)\/([\w-]+)/)?.[1] ?? null)
57
+ : null;
58
+ if (!id || !/^[\w-]{6,}$/.test(id))
59
+ return null;
60
+ const start = seconds(u.searchParams.get("t") ?? u.searchParams.get("start"));
61
+ return `https://www.youtube-nocookie.com/embed/${id}${start ? `?start=${start}` : ""}`;
62
+ }
63
+ //# sourceMappingURL=embed.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"embed.js","sourceRoot":"","sources":["../../src/lib/embed.ts"],"names":[],"mappings":"AAAA;;qBAEqB;AAErB,yEAAyE;AACzE,MAAM,UAAU,QAAQ,CAAC,KAAa;IAClC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAC/C,IAAI,CAAC;QACD,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;QACf,OAAO,IAAI,CAAC;IAChB,CAAC;IAAC,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,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAC7C,OAAO,EAAE,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,kCAAkC,EAAE,QAAQ,CAAC;IAClF,CAAC;IACD,MAAM,EAAE,GACJ,IAAI,KAAK,UAAU;QACf,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;QACrB,CAAC,CAAC,IAAI,KAAK,aAAa;YACtB,CAAC,CAAC,CAAC,CAAC,QAAQ,KAAK,QAAQ;gBACrB,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC;gBACzB,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,oCAAoC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;YAC3E,CAAC,CAAC,IAAI,CAAC;IACjB,IAAI,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC;QAAE,OAAO,IAAI,CAAC;IAChD,MAAM,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;IAC9E,OAAO,0CAA0C,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC,UAAU,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;AAC3F,CAAC"}
@@ -0,0 +1,23 @@
1
+ /** The system dialog for files (or one, with `single`), or for a whole folder. Built on demand: nothing in the page needs to own an <input>. */
2
+ export declare function pickFiles(onPicked: (files: File[]) => void, options?: {
3
+ folder?: boolean;
4
+ accept?: string;
5
+ single?: boolean;
6
+ }): void;
7
+ /** Everything in a drop: loose files as they are, folders walked to their leaves. Call it in the drop handler itself. */
8
+ export declare function filesFromDrop(data: DataTransfer): Promise<File[]>;
9
+ /** True for a drag that is carrying files, as opposed to text or an element of the page. */
10
+ export declare const carriesFiles: (event: {
11
+ dataTransfer: DataTransfer | null;
12
+ }) => boolean;
13
+ /**
14
+ * One request with upload progress, 0 to 1. Resolves with the status and the
15
+ * parsed JSON body whatever the status; rejects only when the connection
16
+ * fails, which is the case worth retrying. `headers` are sent as given: a
17
+ * custom one is how a server tells this from another site's form.
18
+ */
19
+ export declare function sendWithProgress(method: string, url: string, body: Blob | FormData, onProgress: (progress: number) => void, headers?: Record<string, string>): Promise<{
20
+ status: number;
21
+ body: unknown;
22
+ }>;
23
+ //# sourceMappingURL=files.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../src/lib/files.ts"],"names":[],"mappings":"AAKA,gJAAgJ;AAChJ,wBAAgB,SAAS,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,IAAI,EAAE,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,IAAI,CAQxI;AAoBD,yHAAyH;AACzH,wBAAsB,aAAa,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,CASvE;AAED,4FAA4F;AAC5F,eAAO,MAAM,YAAY,GAAI,OAAO;IAAE,YAAY,EAAE,YAAY,GAAG,IAAI,CAAA;CAAE,KAAG,OAA+D,CAAC;AAE5I;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC5B,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,IAAI,GAAG,QAAQ,EACrB,UAAU,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,EACtC,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,GACrC,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC,CAW5C"}
@@ -0,0 +1,69 @@
1
+ /* Getting files from a person: the system's chooser, a whole folder, or a
2
+ drop. And sending one with progress, which `fetch` cannot report. */
3
+ const byName = (files) => files.sort((a, b) => a.name.localeCompare(b.name, undefined, { numeric: true }));
4
+ /** The system dialog for files (or one, with `single`), or for a whole folder. Built on demand: nothing in the page needs to own an <input>. */
5
+ export function pickFiles(onPicked, options = {}) {
6
+ const input = document.createElement("input");
7
+ input.type = "file";
8
+ input.multiple = !options.single;
9
+ if (options.folder)
10
+ input.webkitdirectory = true;
11
+ else if (options.accept !== undefined)
12
+ input.accept = options.accept;
13
+ input.onchange = () => onPicked(byName([...(input.files ?? [])]));
14
+ input.click();
15
+ }
16
+ const fileOf = (entry) => new Promise((resolve, reject) => entry.file(resolve, reject));
17
+ async function childrenOf(directory) {
18
+ const reader = directory.createReader();
19
+ const all = [];
20
+ // readEntries hands back a page at a time and signals the end with an empty one.
21
+ for (;;) {
22
+ const page = await new Promise((resolve, reject) => reader.readEntries(resolve, reject));
23
+ if (page.length === 0)
24
+ return all;
25
+ all.push(...page);
26
+ }
27
+ }
28
+ async function walk(entry, into) {
29
+ if (entry.isFile)
30
+ into.push(await fileOf(entry));
31
+ else if (entry.isDirectory)
32
+ for (const child of await childrenOf(entry))
33
+ await walk(child, into);
34
+ }
35
+ /** Everything in a drop: loose files as they are, folders walked to their leaves. Call it in the drop handler itself. */
36
+ export async function filesFromDrop(data) {
37
+ // The entries must be taken synchronously; the list is emptied once the event returns.
38
+ const dropped = [...data.items].map((item) => ({ entry: item.webkitGetAsEntry(), file: item.getAsFile() }));
39
+ const files = [];
40
+ for (const { entry, file } of dropped) {
41
+ if (entry?.isDirectory)
42
+ await walk(entry, files);
43
+ else if (file !== null)
44
+ files.push(file);
45
+ }
46
+ return byName(files);
47
+ }
48
+ /** True for a drag that is carrying files, as opposed to text or an element of the page. */
49
+ export const carriesFiles = (event) => event.dataTransfer?.types.includes("Files") ?? false;
50
+ /**
51
+ * One request with upload progress, 0 to 1. Resolves with the status and the
52
+ * parsed JSON body whatever the status; rejects only when the connection
53
+ * fails, which is the case worth retrying. `headers` are sent as given: a
54
+ * custom one is how a server tells this from another site's form.
55
+ */
56
+ export function sendWithProgress(method, url, body, onProgress, headers = {}) {
57
+ return new Promise((resolve, reject) => {
58
+ const xhr = new XMLHttpRequest();
59
+ xhr.open(method, url);
60
+ for (const [name, value] of Object.entries(headers))
61
+ xhr.setRequestHeader(name, value);
62
+ xhr.responseType = "json";
63
+ xhr.upload.onprogress = (event) => event.lengthComputable && onProgress(event.loaded / event.total);
64
+ xhr.onload = () => resolve({ status: xhr.status, body: xhr.response });
65
+ xhr.onerror = xhr.ontimeout = xhr.onabort = () => reject(new Error("The connection was lost"));
66
+ xhr.send(body);
67
+ });
68
+ }
69
+ //# sourceMappingURL=files.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files.js","sourceRoot":"","sources":["../../src/lib/files.ts"],"names":[],"mappings":"AAAA;uEACuE;AAEvE,MAAM,MAAM,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AAE3H,gJAAgJ;AAChJ,MAAM,UAAU,SAAS,CAAC,QAAiC,EAAE,UAAmE,EAAE;IAC9H,MAAM,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IAC9C,KAAK,CAAC,IAAI,GAAG,MAAM,CAAC;IACpB,KAAK,CAAC,QAAQ,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC;IACjC,IAAI,OAAO,CAAC,MAAM;QAAE,KAAK,CAAC,eAAe,GAAG,IAAI,CAAC;SAC5C,IAAI,OAAO,CAAC,MAAM,KA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AC,YAAY,GAAG,MAAM,CAAC;QAC1B,GAAG,CAAC,MAAM,CAAC,UAAU,GAAG,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,gBAAgB,IAAI,UAAU,CAAC,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;QACpG,GAAG,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;QACvE,GAAG,CAAC,OAAO,GAAG,GAAG,CAAC,SAAS,GAAG,GAAG,CAAC,OAAO,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC,CAAC;QAC/F,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACnB,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,50 @@
1
+ export type Cell<T> = {
2
+ item: T;
3
+ width: number;
4
+ };
5
+ export type Line<T> = {
6
+ kind: "heading";
7
+ key: string;
8
+ label: string;
9
+ height: number;
10
+ } | {
11
+ kind: "row";
12
+ key: string;
13
+ height: number;
14
+ cells: Cell<T>[];
15
+ };
16
+ /** One height for every row, or a rhythm: a height chosen by the row's number. */
17
+ export type RowHeight = number | ((row: number) => number);
18
+ /** A row height from the room there is: about one and a half pictures across a phone, three a tablet, four a wide screen. */
19
+ export declare const rowHeightFor: (width: number) => number;
20
+ /** A magazine's rhythm: every fourth row is a tall one of one or two pictures, and the rows between alternate taller and shorter. For a selection, not an archive. */
21
+ export declare const editorialRhythm: (width: number) => ((row: number) => number);
22
+ export declare function justify<T>(items: T[], width: number, options: {
23
+ id: (item: T) => string;
24
+ /** Width over height. */
25
+ aspect: (item: T) => number;
26
+ rowHeight: RowHeight;
27
+ gap?: number;
28
+ /** A value that starts a new section when it changes, and that section's heading. */
29
+ group?: (item: T) => {
30
+ key: string;
31
+ label: string;
32
+ };
33
+ headingHeight?: number;
34
+ }): Line<T>[];
35
+ export declare function masonry<T>(items: T[], width: number, options: {
36
+ aspect: (item: T) => number;
37
+ columns: number;
38
+ gap?: number;
39
+ below?: number;
40
+ }): {
41
+ places: {
42
+ item: T;
43
+ x: number;
44
+ y: number;
45
+ width: number;
46
+ height: number;
47
+ }[];
48
+ height: number;
49
+ };
50
+ //# sourceMappingURL=justified.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"justified.d.ts","sourceRoot":"","sources":["../../src/lib/justified.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,IAAI,CAAC,CAAC,IAAI;IAAE,IAAI,EAAE,CAAC,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AACjD,MAAM,MAAM,IAAI,CAAC,CAAC,IACZ;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAC/D;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAA;CAAE,CAAC;AAErE,kFAAkF;AAClF,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,CAAC,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC,CAAC;AAE3D,6HAA6H;AAC7H,eAAO,MAAM,YAAY,GAAI,OAAO,MAAM,KAAG,MAA+D,CAAC;AAE7G,sKAAsK;AACtK,eAAO,MAAM,eAAe,GACvB,OAAO,MAAM,KAAG,CAAC,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAKxC,CAAC;AAEN,wBAAgB,OAAO,CAAC,CAAC,EACrB,KAAK,EAAE,CAAC,EAAE,EACV,KAAK,EAAE,MAAM,EACb,OAAO,EAAE;IACL,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,CAAC;IACxB,yBAAyB;IACzB,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,CAAC;IAC5B,SAAS,EAAE,SAAS,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,qFAAqF;IACrF,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IACpD,aAAa,CAAC,EAAE,MAAM,CAAC;CAC1B,GACF,IAAI,CAAC,CAAC,CAAC,EAAE,CAsCX;AAOD,wBAAgB,OAAO,CAAC,CAAC,EACrB,KAAK,EAAE,CAAC,EAAE,EACV,KAAK,EAAE,MAAM,EACb,OAAO,EAAE;IAAE,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GACxF;IAAE,MAAM,EAAE;QAAE,IAAI,EAAE,CAAC,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAehG"}
@@ -0,0 +1,78 @@
1
+ /* Rows of pictures that each fill the width exactly, like a contact sheet:
2
+ every row is one height, scaled so its pictures and the gaps between them
3
+ add up to the width. The heights are known before anything is drawn, which
4
+ is what lets a long list be virtualised without measuring.
5
+
6
+ Works on anything with an aspect ratio. Give `group` to start a new section
7
+ (with a heading line) whenever its value changes: months, say. */
8
+ /** A row height from the room there is: about one and a half pictures across a phone, three a tablet, four a wide screen. */
9
+ export const rowHeightFor = (width) => Math.round(Math.min(300, Math.max(170, width / 4.6)));
10
+ /** A magazine's rhythm: every fourth row is a tall one of one or two pictures, and the rows between alternate taller and shorter. For a selection, not an archive. */
11
+ export const editorialRhythm = (width) => (row) => {
12
+ const base = rowHeightFor(width);
13
+ if (row % 4 === 0)
14
+ return Math.round(Math.min(560, Math.max(base * 1.5, width * 0.4)));
15
+ return Math.round(base * (row % 2 === 1 ? 1.2 : 0.95));
16
+ };
17
+ export function justify(items, width, options) {
18
+ const { id, aspect, rowHeight, gap = 12, group, headingHeight = 64 } = options;
19
+ const lines = [];
20
+ if (width <= 0)
21
+ return lines;
22
+ // A panorama or a sliver would otherwise set the height of its whole row.
23
+ const clamped = (item) => Math.min(Math.max(aspect(item), 0.5), 3);
24
+ let section = "";
25
+ let pending = [];
26
+ let ratios = 0;
27
+ let row = 0;
28
+ const target = () => (typeof rowHeight === "number" ? rowHeight : rowHeight(row));
29
+ const flush = (full) => {
30
+ if (pending.length === 0)
31
+ return;
32
+ const room = width - gap * (pending.length - 1);
33
+ // A last row that is not full keeps the target height and stays ragged;
34
+ // stretching three pictures across the page would blow them up.
35
+ const height = full ? room / ratios : Math.min(target(), room / ratios);
36
+ lines.push({ kind: "row", key: id(pending[0]), height: Math.round(height) + gap, cells: pending.map((item) => ({ item, width: height * clamped(item) })) });
37
+ pending = [];
38
+ ratios = 0;
39
+ row += 1;
40
+ };
41
+ for (const item of items) {
42
+ const next = group?.(item);
43
+ if (next !== undefined && next.key !== section) {
44
+ flush(false);
45
+ section = next.key;
46
+ lines.push({ kind: "heading", key: next.key, label: next.label, height: headingHeight });
47
+ }
48
+ pending.push(item);
49
+ ratios += clamped(item);
50
+ if (ratios * target() + gap * (pending.length - 1) >= width)
51
+ flush(true);
52
+ }
53
+ flush(false);
54
+ return lines;
55
+ }
56
+ /* Pinterest columns: each picture at its own shape, dealt across the columns
57
+ in order like cards, so the board reads left to right and a last row that
58
+ is not full starts at the left. (Putting each in the shortest column packs
59
+ tighter but drops the last one wherever there is room.) Fewer pictures than
60
+ columns are centred. `below` is room under each picture for a caption. */
61
+ export function masonry(items, width, options) {
62
+ const { aspect, columns, gap = 22, below = 0 } = options;
63
+ if (width <= 0 || columns <= 0)
64
+ return { places: [], height: 0 };
65
+ const column = (width - gap * (columns - 1)) / columns;
66
+ const heights = Array.from({ length: columns }, () => 0);
67
+ const used = Math.min(columns, items.length);
68
+ const inset = (width - (used * column + gap * (used - 1))) / 2;
69
+ const places = items.map((item, index) => {
70
+ const at = index % columns;
71
+ const height = column / aspect(item);
72
+ const y = heights[at];
73
+ heights[at] = y + height + below + gap;
74
+ return { item, x: inset + at * (column + gap), y, width: column, height };
75
+ });
76
+ return { places, height: Math.max(0, Math.max(...heights) - gap) };
77
+ }
78
+ //# sourceMappingURL=justified.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"justified.js","sourceRoot":"","sources":["../../src/lib/justified.ts"],"names":[],"mappings":"AAAA;;;;;;oEAMoE;AAUpE,6HAA6H;AAC7H,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;AAE7G,sKAAsK;AACtK,MAAM,CAAC,MAAM,eAAe,GACxB,CAAC,KAAa,EAA6B,EAAE,CAC7C,CAAC,GAAG,EAAE,EAAE;IACJ,MAAM,IAAI,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;IACjC,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,GAAG,EAAE,KAAK,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;IACvF,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,GAAG,GAAG,CAAC,KAAK,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CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IAC9E,CAAC,CAAC,CAAC;IACH,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,GAAG,CAAC,EAAE,CAAC;AACvE,CAAC"}
@@ -0,0 +1,18 @@
1
+ export type Platform = "apple" | "other";
2
+ /** Which platform the browser says it is. "other" on the server. */
3
+ export declare function platform(): Platform;
4
+ type Key = {
5
+ shown: string;
6
+ spoken: string;
7
+ };
8
+ /** "mod+shift+k" → the keys as shown and as spoken on `on`. */
9
+ export declare function shortcutKeys(shortcut: string, on?: Platform): Key[];
10
+ /** "mod+k" → "⌘K" on Apple, "Ctrl+K" elsewhere: for text, such as a tooltip. */
11
+ export declare function formatShortcut(shortcut: string, on?: Platform): string;
12
+ /** "mod+k" → "Command K": what a screen reader should say. */
13
+ export declare const speakShortcut: (shortcut: string, on?: Platform) => string;
14
+ /** Whether a key press is `shortcut` ("mod+k", "shift+?", "f8"). `mod` is ⌘ or Ctrl, either, as the kit's
15
+ own shortcuts take both. Modifiers not written must be up. Safe for the key events autofill sends with no key. */
16
+ export declare function matchShortcut(e: Pick<KeyboardEvent, "key" | "metaKey" | "ctrlKey" | "altKey" | "shiftKey">, shortcut: string): boolean;
17
+ export {};
18
+ //# sourceMappingURL=keys.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keys.d.ts","sourceRoot":"","sources":["../../src/lib/keys.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,OAAO,CAAC;AAEzC,oEAAoE;AACpE,wBAAgB,QAAQ,IAAI,QAAQ,CAInC;AAED,KAAK,GAAG,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAmB7C,+DAA+D;AAC/D,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,GAAE,QAAqB,GAAG,GAAG,EAAE,CAQ/E;AAED,gFAAgF;AAChF,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,GAAE,QAAqB,GAAG,MAAM,CAIlF;AAED,8DAA8D;AAC9D,eAAO,MAAM,aAAa,GAAI,UAAU,MAAM,EAAE,KAAI,QAAqB,KAAG,MAG1D,CAAC;AAInB;qHACqH;AACrH,wBAAgB,aAAa,CAAC,CAAC,EAAE,IAAI,CAAC,aAAa,EAAE,KAAK,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,UAAU,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAWtI"}
@@ -0,0 +1,66 @@
1
+ /* Keyboard shortcuts written once, shown right on every platform. A shortcut is
2
+ written as "mod+shift+k": `mod` is ⌘ on Apple platforms and Ctrl elsewhere,
3
+ which is what the kit's own shortcuts listen for (⌘\, ⌘K). */
4
+ /** Which platform the browser says it is. "other" on the server. */
5
+ export function platform() {
6
+ if (typeof navigator === "undefined")
7
+ return "other";
8
+ const name = navigator.userAgentData?.platform ?? navigator.platform ?? "";
9
+ return /mac|iphone|ipad|ipod/i.test(name) ? "apple" : "other";
10
+ }
11
+ const NAMES = {
12
+ mod: { apple: { shown: "⌘", spoken: "Command" }, other: { shown: "Ctrl", spoken: "Control" } },
13
+ ctrl: { apple: { shown: "⌃", spoken: "Control" }, other: { shown: "Ctrl", spoken: "Control" } },
14
+ alt: { apple: { shown: "⌥", spoken: "Option" }, other: { shown: "Alt", spoken: "Alt" } },
15
+ shift: { apple: { shown: "⇧", spoken: "Shift" }, other: { shown: "Shift", spoken: "Shift" } },
16
+ enter: { apple: { shown: "↵", spoken: "Enter" }, other: { shown: "Enter", spoken: "Enter" } },
17
+ backspace: { apple: { shown: "⌫", spoken: "Backspace" }, other: { shown: "Backspace", spoken: "Backspace" } },
18
+ escape: { apple: { shown: "Esc", spoken: "Escape" }, other: { shown: "Esc", spoken: "Escape" } },
19
+ tab: { apple: { shown: "⇥", spoken: "Tab" }, other: { shown: "Tab", spoken: "Tab" } },
20
+ up: { apple: { shown: "↑", spoken: "Up" }, other: { shown: "↑", spoken: "Up" } },
21
+ down: { apple: { shown: "↓", spoken: "Down" }, other: { shown: "↓", spoken: "Down" } },
22
+ left: { apple: { shown: "←", spoken: "Left" }, other: { shown: "←", spoken: "Left" } },
23
+ right: { apple: { shown: "→", spoken: "Right" }, other: { shown: "→", spoken: "Right" } },
24
+ "\\": { apple: { shown: "\\", spoken: "Backslash" }, other: { shown: "\\", spoken: "Backslash" } },
25
+ "/": { apple: { shown: "/", spoken: "Slash" }, other: { shown: "/", spoken: "Slash" } },
26
+ };
27
+ /** "mod+shift+k" → the keys as shown and as spoken on `on`. */
28
+ export function shortcutKeys(shortcut, on = platform()) {
29
+ return shortcut
30
+ .split("+")
31
+ .filter(Boolean)
32
+ .map((part) => {
33
+ const key = part.trim().toLowerCase();
34
+ return NAMES[key]?.[on] ?? { shown: key.length === 1 ? key.toUpperCase() : part.trim(), spoken: key.length === 1 ? key.toUpperCase() : part.trim() };
35
+ });
36
+ }
37
+ /** "mod+k" → "⌘K" on Apple, "Ctrl+K" elsewhere: for text, such as a tooltip. */
38
+ export function formatShortcut(shortcut, on = platform()) {
39
+ return shortcutKeys(shortcut, on)
40
+ .map((k) => k.shown)
41
+ .join(on === "apple" ? "" : "+");
42
+ }
43
+ /** "mod+k" → "Command K": what a screen reader should say. */
44
+ export const speakShortcut = (shortcut, on = platform()) => shortcutKeys(shortcut, on)
45
+ .map((k) => k.spoken)
46
+ .join(" ");
47
+ const KEY_NAMES = { enter: "enter", escape: "escape", tab: "tab", backspace: "backspace", up: "arrowup", down: "arrowdown", left: "arrowleft", right: "arrowright", space: " " };
48
+ /** Whether a key press is `shortcut` ("mod+k", "shift+?", "f8"). `mod` is ⌘ or Ctrl, either, as the kit's
49
+ own shortcuts take both. Modifiers not written must be up. Safe for the key events autofill sends with no key. */
50
+ export function matchShortcut(e, shortcut) {
51
+ if (typeof e.key !== "string" || e.key === "")
52
+ return false;
53
+ const parts = shortcut.toLowerCase().split("+");
54
+ const key = parts.pop();
55
+ const want = new Set(parts);
56
+ const mod = want.has("mod");
57
+ if (mod ? !(e.metaKey || e.ctrlKey) : e.metaKey !== want.has("meta") || e.ctrlKey !== want.has("ctrl"))
58
+ return false;
59
+ if (e.altKey !== want.has("alt"))
60
+ return false;
61
+ // A shifted symbol ("?") is its own key; shift is only checked when written, or for a letter.
62
+ if (want.has("shift") ? !e.shiftKey : e.shiftKey && /^[a-z0-9]$/.test(key))
63
+ return false;
64
+ return e.key.toLowerCase() === (KEY_NAMES[key] ?? key);
65
+ }
66
+ //# sourceMappingURL=keys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keys.js","sourceRoot":"","sources":["../../src/lib/keys.ts"],"names":[],"mappings":"AAAA;;gEAEgE;AAIhE,oEAAoE;AACpE,MAAM,UAAU,QAAQ;IACpB,IAAI,OAAO,SAAS,KAAK,WAAW;QAAE,OAAO,OAAO,CAAC;IACrD,MAAM,IAAI,GAAI,SAAmE,CAAC,aAAa,EAAE,QAAQ,IAAI,SAAS,CAAC,QAAQ,IAAI,EAAE,CAAC;IACtI,OAAO,uBAAuB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC;AAClE,CAAC;AAID,MAAM,KAAK,GAA0C;IACjD,GAAG,EAAE,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE;IAC9F,IAAI,EAAE,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,E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CAAC;IAC5D,MAAM,KAAK,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAChD,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,EAAG,CAAC;IACzB,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;IAC5B,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAC5B,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,KAAK,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,KAAK,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC;QAAE,OAAO,KAAK,CAAC;IACrH,IAAI,CAAC,CAAC,MAAM,KAAK,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAC/C,8FAA8F;IAC9F,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,IAAI,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,KAAK,CAAC;IACzF,OAAO,CAAC,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC;AAC3D,CAAC"}
@@ -0,0 +1,4 @@
1
+ export declare function parseNumber(text: string): number | null;
2
+ /** Keeps a number within `min` and `max`, either of which may be absent. */
3
+ export declare const clamp: (n: number, min?: number, max?: number) => number;
4
+ //# sourceMappingURL=number.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"number.d.ts","sourceRoot":"","sources":["../../src/lib/number.ts"],"names":[],"mappings":"AAWA,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAcvD;AAED,4EAA4E;AAC5E,eAAO,MAAM,KAAK,GAAI,GAAG,MAAM,EAAE,MAAM,MAAM,EAAE,MAAM,MAAM,KAAG,MAAkE,CAAC"}
@@ -0,0 +1,33 @@
1
+ /* Reading a number someone typed, in whichever way they write numbers.
2
+
3
+ Currency signs, spaces and apostrophes (1'000, as in Switzerland) are ignored.
4
+ With both "," and ".", the last one is the decimal point: 1,234.5 and 1.234,5
5
+ are both one thousand two hundred and thirty-four and a half. With only commas,
6
+ they are thousands when every group after the first is three digits (1,234 and
7
+ 12,345,678), and otherwise the decimal point (12,5). With only points, one is the
8
+ decimal point and several are thousands (1.234.567).
9
+
10
+ Returns null for an empty field and NaN for anything that is not a number, so a
11
+ caller can tell "cleared" from "typed nonsense". */
12
+ export function parseNumber(text) {
13
+ let s = text.replace(/[\s  '’$€£¥₹]/g, "").replace(/^\((.*)\)$/, "-$1");
14
+ if (s === "")
15
+ return null;
16
+ const comma = s.lastIndexOf(",");
17
+ const point = s.lastIndexOf(".");
18
+ if (comma !== -1 && point !== -1) {
19
+ s = comma > point ? s.replace(/\./g, "").replace(",", ".") : s.replace(/,/g, "");
20
+ }
21
+ else if (comma !== -1) {
22
+ s = /^[-+]?\d{1,3}(,\d{3})+$/.test(s) ? s.replace(/,/g, "") : s.replace(",", ".");
23
+ }
24
+ else if ((s.match(/\./g) ?? []).length > 1) {
25
+ s = s.replace(/\./g, "");
26
+ }
27
+ if (!/^[-+]?(\d+\.?\d*|\.\d+)$/.test(s))
28
+ return Number.NaN;
29
+ return Number(s);
30
+ }
31
+ /** Keeps a number within `min` and `max`, either of which may be absent. */
32
+ export const clamp = (n, min, max) => Math.min(max ?? Infinity, Math.max(min ?? -Infinity, n));
33
+ //# sourceMappingURL=number.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"number.js","sourceRoot":"","sources":["../../src/lib/number.ts"],"names":[],"mappings":"AAAA;;;;;;;;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CAAC,CAAC,CAAC;AACrB,CAAC;AAED,4EAA4E;AAC5E,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,CAAS,EAAE,GAAY,EAAE,GAAY,EAAU,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,QAAQ,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const finePointer: () => boolean;
2
+ //# sourceMappingURL=pointer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pointer.d.ts","sourceRoot":"","sources":["../../src/lib/pointer.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,WAAW,QAAO,OAAwF,CAAC"}
@@ -0,0 +1,4 @@
1
+ // Whether the device is driven by a mouse or trackpad rather than a finger. Asked at
2
+ // the moment of use, in the browser.
3
+ export const finePointer = () => typeof window !== "undefined" && window.matchMedia("(pointer: fine)").matches;
4
+ //# sourceMappingURL=pointer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pointer.js","sourceRoot":"","sources":["../../src/lib/pointer.ts"],"names":[],"mappings":"AAAA,qFAAqF;AACrF,qCAAqC;AACrC,MAAM,CAAC,MAAM,WAAW,GAAG,GAAY,EAAE,CAAC,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC,OAAO,CAAC"}