@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,452 @@
1
+ "use client";
2
+
3
+ import { ChevronRight, Code2, Lightbulb, ListCollapse, Minus, Plus, Table2 } from "lucide-react";
4
+ import { useId, useLayoutEffect, useRef, type KeyboardEvent } from "react";
5
+ import type { AnyBlock } from "../../../lib/document.ts";
6
+ import type { Text } from "../../../lib/rich-text.ts";
7
+ import { cn } from "../../../lib/utils.ts";
8
+ import { calloutVariants } from "../../ui/callout.tsx";
9
+ import { CopyButton } from "../../ui/copy-button.tsx";
10
+ import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger } from "../../ui/dropdown-menu.tsx";
11
+ import { SelectMenu } from "../../ui/select-menu.tsx";
12
+ import { Table, Td, Th } from "../../ui/table.tsx";
13
+ import { BlockList, BlockRow } from "../blocks.tsx";
14
+ import { BlockText } from "../block-text.tsx";
15
+ import { Blocks, Spans } from "../document-view.tsx";
16
+ import { useEditor } from "../editor-state.tsx";
17
+ import type { BlockExtension, Node, TextNode } from "../kinds.ts";
18
+
19
+ /* The kit's own blocks beyond text, lists and media: toggle, callout, code and a
20
+ simple table. Written as BlockExtensions, from the same parts an app's own
21
+ blocks use, and given to every DocumentEditor and DocumentView. */
22
+
23
+ /* ── Toggle ──────────────────────────────────────────────────────────────────
24
+ A line that folds away what is under it. Open or closed is a reader's choice,
25
+ not the document's: it starts open in the editor (to write in) and closed when
26
+ read. Stored as { type: "toggle", text, children }. */
27
+
28
+ function ToggleEdit({ block, depth }: { block: Node; depth: number }) {
29
+ const ed = useEditor();
30
+ // Folded in the editor's own state, so the arrows step over what is hidden.
31
+ const open = !ed.folded(block.id);
32
+ const setOpen = (next: (open: boolean) => boolean) => ed.fold(block.id, !next(open));
33
+ const inside = useId();
34
+ return (
35
+ <div className="my-px">
36
+ <BlockRow block={block}>
37
+ <div className="flex items-start px-0.5 py-[3px]">
38
+ <button
39
+ type="button"
40
+ contentEditable={false}
41
+ aria-expanded={open}
42
+ aria-controls={inside}
43
+ aria-label={open ? "Fold" : "Unfold"}
44
+ onClick={() => setOpen((o) => !o)}
45
+ className="flex justify-center items-center hover:bg-tint-hover rounded-control w-6 h-[1.5em] text-ink-secondary shrink-0"
46
+ >
47
+ <ChevronRight className={cn("size-4 transition-transform duration-(--duration-fast)", open && "rotate-90")} />
48
+ </button>
49
+ <BlockText block={block as TextNode} placeholder="Toggle" alwaysShowPlaceholder className="flex-1" />
50
+ </div>
51
+ </BlockRow>
52
+ <div id={inside} hidden={!open} className="pl-6">
53
+ {block.children.length > 0 ? (
54
+ <BlockList blocks={block.children} depth={depth + 1} />
55
+ ) : (
56
+ <button
57
+ type="button"
58
+ onClick={() => ed.create(block.id, null, { type: "paragraph", text: [] }, { focus: true })}
59
+ className="px-0.5 py-[3px] text-ink-tertiary hover:text-ink-secondary text-sm text-left"
60
+ >
61
+ Empty. Click to write inside.
62
+ </button>
63
+ )}
64
+ </div>
65
+ </div>
66
+ );
67
+ }
68
+
69
+ function ToggleView({ block, depth }: { block: AnyBlock; depth: number }) {
70
+ const { text = [], children = [] } = block as { text?: Text; children?: AnyBlock[] };
71
+ return (
72
+ <details className="group/toggle my-1 [&[open]>summary_svg]:rotate-90">
73
+ <summary className="flex items-start py-0.5 rounded-control cursor-pointer list-none [&::-webkit-details-marker]:hidden">
74
+ <span aria-hidden className="flex justify-center items-center w-6 h-[1.5em] text-ink-secondary shrink-0">
75
+ <ChevronRight className="size-4 transition-transform duration-(--duration-fast)" />
76
+ </span>
77
+ <span className="flex-1 min-w-0">
78
+ <Spans text={text} />
79
+ </span>
80
+ </summary>
81
+ <div className="pl-6">
82
+ <Blocks blocks={children} depth={depth + 1} />
83
+ </div>
84
+ </details>
85
+ );
86
+ }
87
+
88
+ export const toggleBlock: BlockExtension<{ text: Text; children?: AnyBlock[] }> = {
89
+ type: "toggle",
90
+ kinds: [{ key: "toggle", label: "Toggle", hint: "A line that folds away what is under it", icon: ListCollapse, make: (text) => ({ type: "toggle", text }) }],
91
+ holds: () => true,
92
+ toggle: true,
93
+ Edit: ToggleEdit,
94
+ View: ToggleView,
95
+ };
96
+
97
+ /* ── Callout ─────────────────────────────────────────────────────────────────
98
+ A tinted note with an emoji in its gutter: the kit's Callout, written in.
99
+ The emoji and the colour are chosen from a menu on the emoji. Stored as
100
+ { type: "callout", text, icon, color }. */
101
+
102
+ const CALLOUT_ICONS = ["💡", "⚠️", "✅", "📌", "❗", "ℹ️", "🧭", "✈️"] as const;
103
+ const CALLOUT_COLORS = ["gray", "brown", "orange", "yellow", "green", "blue", "purple", "pink", "red"] as const;
104
+ type CalloutColor = (typeof CALLOUT_COLORS)[number];
105
+
106
+ function CalloutEdit({ block }: { block: Node & { icon?: string; color?: CalloutColor } }) {
107
+ const ed = useEditor();
108
+ const set = (patch: { icon?: string; color?: CalloutColor }) => ed.edit(block.id, (b) => ({ ...b, ...patch }) as Node);
109
+ return (
110
+ <BlockRow block={block} className="my-1">
111
+ <div className={cn(calloutVariants({ color: block.color ?? "gray" }), "py-3")}>
112
+ <DropdownMenu>
113
+ <DropdownMenuTrigger asChild>
114
+ <button
115
+ type="button"
116
+ contentEditable={false}
117
+ aria-label="The callout's icon and colour"
118
+ className="flex justify-center items-center hover:bg-tint-active rounded-control size-6 text-body leading-none shrink-0"
119
+ >
120
+ <span aria-hidden>{block.icon ?? "💡"}</span>
121
+ </button>
122
+ </DropdownMenuTrigger>
123
+ <DropdownMenuContent align="start">
124
+ <DropdownMenuLabel>Icon</DropdownMenuLabel>
125
+ <div className="gap-0.5 grid grid-cols-4 px-1 pb-1">
126
+ {CALLOUT_ICONS.map((icon) => (
127
+ <DropdownMenuItem key={icon} onSelect={() => set({ icon })} className="justify-center p-0 text-body" aria-label={`Icon ${icon}`}>
128
+ {icon}
129
+ </DropdownMenuItem>
130
+ ))}
131
+ </div>
132
+ <DropdownMenuSeparator />
133
+ <DropdownMenuLabel>Colour</DropdownMenuLabel>
134
+ {CALLOUT_COLORS.map((color) => (
135
+ <DropdownMenuItem key={color} onSelect={() => set({ color })}>
136
+ <span aria-hidden className={cn("rounded-small size-4 shadow-edge", calloutVariants({ color }).split(" ").find((c) => c.startsWith("bg-")))} />
137
+ {color[0]!.toUpperCase() + color.slice(1)}
138
+ </DropdownMenuItem>
139
+ ))}
140
+ </DropdownMenuContent>
141
+ </DropdownMenu>
142
+ <BlockText block={block as TextNode} placeholder="A note worth noticing" alwaysShowPlaceholder className="flex-1 min-w-0" />
143
+ </div>
144
+ </BlockRow>
145
+ );
146
+ }
147
+
148
+ function CalloutView({ block }: { block: AnyBlock }) {
149
+ const { text = [], icon = "💡", color = "gray" } = block as { text?: Text; icon?: string; color?: CalloutColor };
150
+ return (
151
+ <div role="note" className={cn(calloutVariants({ color }), "my-4")}>
152
+ <span aria-hidden className="text-body leading-snug shrink-0">
153
+ {icon}
154
+ </span>
155
+ <div className="min-w-0">
156
+ <Spans text={text} />
157
+ </div>
158
+ </div>
159
+ );
160
+ }
161
+
162
+ export const calloutBlock: BlockExtension<{ text: Text; icon?: string; color?: CalloutColor }> = {
163
+ type: "callout",
164
+ kinds: [{ key: "callout", label: "Callout", hint: "A note that stands out", icon: Lightbulb, make: (text) => ({ type: "callout", text, icon: "💡", color: "gray" }) }],
165
+ Edit: CalloutEdit,
166
+ View: CalloutView,
167
+ };
168
+
169
+ /* ── Code ────────────────────────────────────────────────────────────────────
170
+ Code in a monospace box, with its language named and a copy button. No
171
+ highlighting in v1. Tab indents (two spaces) inside it, so Escape first, then
172
+ Tab, moves on: Escape selects the block. Stored as { type: "code", code,
173
+ language }. */
174
+
175
+ const LANGUAGES = ["Plain text", "TypeScript", "JavaScript", "Python", "Go", "Rust", "SQL", "Shell", "JSON", "HTML", "CSS", "YAML", "Markdown"] as const;
176
+
177
+ function CodeEdit({ block }: { block: Node & { code?: string; language?: string } }) {
178
+ const ed = useEditor();
179
+ const area = useRef<HTMLTextAreaElement>(null);
180
+ const code = block.code ?? "";
181
+ // Grows with its lines rather than scrolling inside itself.
182
+ useLayoutEffect(() => {
183
+ const el = area.current;
184
+ if (!el) return;
185
+ el.style.height = "auto";
186
+ el.style.height = `${el.scrollHeight}px`;
187
+ }, [code]);
188
+ const write = (next: string) => ed.edit(block.id, (b) => ({ ...b, code: next }) as Node, { typing: true });
189
+ const onKeyDown = (e: KeyboardEvent<HTMLTextAreaElement>) => {
190
+ if (e.key === "Escape") {
191
+ e.preventDefault();
192
+ ed.select(block.id);
193
+ } else if (e.key === "Tab" && !e.metaKey && !e.ctrlKey && !e.altKey) {
194
+ e.preventDefault();
195
+ const el = e.currentTarget;
196
+ const { selectionStart: s, selectionEnd: end } = el;
197
+ const lineStart = (i: number) => (i === 0 ? 0 : code.lastIndexOf("\n", i - 1) + 1);
198
+ if (!e.shiftKey && s === end) {
199
+ write(code.slice(0, s) + " " + code.slice(end));
200
+ requestAnimationFrame(() => el.setSelectionRange(s + 2, s + 2));
201
+ return;
202
+ }
203
+ // Every line the selection touches (or the caret's line) moves in or out by two spaces.
204
+ const from = lineStart(s);
205
+ const lines = code.slice(from, end).split("\n");
206
+ const shifted = lines.map((line) => (e.shiftKey ? line.replace(/^ {1,2}/, "") : " " + line));
207
+ const firstChange = shifted[0]!.length - lines[0]!.length;
208
+ const total = shifted.join("\n").length - lines.join("\n").length;
209
+ if (total === 0) return;
210
+ write(code.slice(0, from) + shifted.join("\n") + code.slice(end));
211
+ requestAnimationFrame(() => el.setSelectionRange(Math.max(from, s + firstChange), Math.max(from, end + total)));
212
+ }
213
+ };
214
+ return (
215
+ <BlockRow block={block} className="my-1">
216
+ <div className="group/code relative bg-surface-sunken rounded-surface shadow-edge">
217
+ <div className="flex items-center gap-1 px-2 pt-1.5">
218
+ <SelectMenu
219
+ label="Language"
220
+ value={(block.language ?? "Plain text") as (typeof LANGUAGES)[number]}
221
+ options={LANGUAGES}
222
+ onChange={(language) => ed.edit(block.id, (b) => ({ ...b, language }) as Node)}
223
+ className="text-caption text-ink-tertiary"
224
+ />
225
+ <CopyButton value={() => code} label="Copy the code" className="ml-auto" />
226
+ </div>
227
+ <textarea
228
+ ref={area}
229
+ data-code={block.id}
230
+ aria-label={`Code, ${block.language ?? "plain text"}`}
231
+ spellCheck={false}
232
+ autoCapitalize="off"
233
+ autoCorrect="off"
234
+ value={code}
235
+ placeholder="// Code"
236
+ rows={1}
237
+ onChange={(e) => write(e.target.value)}
238
+ onKeyDown={onKeyDown}
239
+ className="block bg-transparent px-4 pt-1 pb-4 outline-none w-full overflow-x-auto font-mono text-ink placeholder:text-ink-tertiary text-sm leading-relaxed whitespace-pre resize-none"
240
+ />
241
+ </div>
242
+ </BlockRow>
243
+ );
244
+ }
245
+
246
+ function CodeView({ block }: { block: AnyBlock }) {
247
+ const { code = "", language = "Plain text" } = block as { code?: string; language?: string };
248
+ return (
249
+ <figure className="relative bg-surface-sunken my-4 rounded-surface shadow-edge">
250
+ <figcaption className="flex items-center px-4 pt-2 text-caption text-ink-tertiary">
251
+ {language}
252
+ <CopyButton value={code} label="Copy the code" className="ml-auto -mr-2" />
253
+ </figcaption>
254
+ <pre className="px-4 pt-1 pb-4 overflow-x-auto font-mono text-sm leading-relaxed" tabIndex={0}>
255
+ <code>{code}</code>
256
+ </pre>
257
+ </figure>
258
+ );
259
+ }
260
+
261
+ export const codeBlock: BlockExtension<{ code?: string; language?: string }> = {
262
+ type: "code",
263
+ kinds: [{ key: "code", label: "Code", hint: "A snippet, in monospace", icon: Code2, make: () => ({ type: "code", code: "", language: "Plain text" }) }],
264
+ shortcuts: { "```": "code" },
265
+ Edit: CodeEdit,
266
+ View: CodeView,
267
+ focus: (element) => {
268
+ const area = element.querySelector<HTMLTextAreaElement>("textarea[data-code]");
269
+ area?.focus();
270
+ return area !== null;
271
+ },
272
+ };
273
+
274
+ /* ── Table ───────────────────────────────────────────────────────────────────
275
+ A simple table: words in cells, the first row a header if wanted. Tab and
276
+ Shift+Tab move along cells as in a form; Enter goes down a row, and from the
277
+ last row adds one. Rows and columns are added from the buttons at its edges
278
+ and removed from a cell's menu. Stored as { type: "table", rows, header }. */
279
+
280
+ type Grid = string[][];
281
+
282
+ function TableEdit({ block }: { block: Node & { rows?: Grid; header?: boolean } }) {
283
+ const ed = useEditor();
284
+ const rows: Grid = block.rows && block.rows.length > 0 ? block.rows : [["", ""], ["", ""]];
285
+ const header = block.header !== false;
286
+ const box = useRef<HTMLDivElement>(null);
287
+ const set = (patch: { rows?: Grid; header?: boolean }, typing = false) => ed.edit(block.id, (b) => ({ ...b, ...patch }) as Node, typing ? { typing: true } : undefined);
288
+ const cols = Math.max(...rows.map((r) => r.length));
289
+ const focusCell = (r: number, c: number) => requestAnimationFrame(() => box.current?.querySelector<HTMLInputElement>(`[data-cell="${r}-${c}"]`)?.focus());
290
+ const addRow = (at = rows.length) => {
291
+ set({ rows: [...rows.slice(0, at), Array(cols).fill(""), ...rows.slice(at)] });
292
+ focusCell(at, 0);
293
+ };
294
+ const addCol = () => set({ rows: rows.map((r) => [...r, ...Array(cols - r.length + 1).fill("")]) });
295
+ const removeRow = (r: number) => rows.length > 1 && set({ rows: rows.filter((_, i) => i !== r) });
296
+ const removeCol = (c: number) => cols > 1 && set({ rows: rows.map((row) => row.filter((_, i) => i !== c)) });
297
+
298
+ return (
299
+ <BlockRow block={block} className="my-2">
300
+ <div ref={box} className="group group/table flex items-start gap-1">
301
+ <div className="flex-1 min-w-0">
302
+ <div className="overflow-x-auto">
303
+ <table className="border-collapse w-full text-sm">
304
+ <tbody>
305
+ {rows.map((row, r) => (
306
+ <tr key={r}>
307
+ {Array.from({ length: cols }, (_, c) => (
308
+ <td key={c} className={cn("p-0 border border-hairline-strong min-w-28", header && r === 0 && "bg-surface-sunken font-medium")}>
309
+ <div className="flex items-center">
310
+ <input
311
+ data-cell={`${r}-${c}`}
312
+ aria-label={`Row ${r + 1}, column ${c + 1}${header && r === 0 ? ", heading" : ""}`}
313
+ value={row[c] ?? ""}
314
+ onChange={(e) => {
315
+ const next = rows.map((x) => [...x]);
316
+ next[r]![c] = e.target.value;
317
+ set({ rows: next }, true);
318
+ }}
319
+ onKeyDown={(e) => {
320
+ if (e.key === "Enter" && !e.nativeEvent.isComposing) {
321
+ e.preventDefault();
322
+ if (r === rows.length - 1) addRow();
323
+ else focusCell(r + 1, c);
324
+ } else if (e.key === "Escape") {
325
+ e.preventDefault();
326
+ ed.select(block.id);
327
+ }
328
+ }}
329
+ className="flex-1 bg-transparent px-2.25 py-1.75 outline-none focus:bg-accent-tint min-w-0"
330
+ />
331
+ <DropdownMenu>
332
+ <DropdownMenuTrigger asChild>
333
+ <button
334
+ type="button"
335
+ aria-label={`Row ${r + 1}, column ${c + 1}: options`}
336
+ className="mr-0.5 rounded-control size-5 text-ink-tertiary hover:bg-tint-hover affordance"
337
+ >
338
+ <ChevronRight className="mx-auto size-3.5 rotate-90" />
339
+ </button>
340
+ </DropdownMenuTrigger>
341
+ <DropdownMenuContent align="end">
342
+ <DropdownMenuItem onSelect={() => addRow(r)}>
343
+ <Plus /> Row above
344
+ </DropdownMenuItem>
345
+ <DropdownMenuItem onSelect={() => addRow(r + 1)}>
346
+ <Plus /> Row below
347
+ </DropdownMenuItem>
348
+ <DropdownMenuItem onSelect={addCol}>
349
+ <Plus /> Column at the end
350
+ </DropdownMenuItem>
351
+ <DropdownMenuSeparator />
352
+ <DropdownMenuItem disabled={rows.length <= 1} onSelect={() => removeRow(r)}>
353
+ <Minus /> Delete row
354
+ </DropdownMenuItem>
355
+ <DropdownMenuItem disabled={cols <= 1} onSelect={() => removeCol(c)}>
356
+ <Minus /> Delete column
357
+ </DropdownMenuItem>
358
+ <DropdownMenuSeparator />
359
+ <DropdownMenuItem onSelect={() => set({ header: !header })}>{header ? "First row is plain" : "First row is a header"}</DropdownMenuItem>
360
+ </DropdownMenuContent>
361
+ </DropdownMenu>
362
+ </div>
363
+ </td>
364
+ ))}
365
+ </tr>
366
+ ))}
367
+ </tbody>
368
+ </table>
369
+ </div>
370
+ <button
371
+ type="button"
372
+ onClick={() => addRow()}
373
+ className="flex justify-center items-center hover:bg-tint-hover mt-0.5 rounded-control w-full h-5 text-ink-tertiary affordance"
374
+ aria-label="Add a row"
375
+ >
376
+ <Plus className="size-3.5" />
377
+ </button>
378
+ </div>
379
+ <button type="button" onClick={addCol} className="flex justify-center items-center hover:bg-tint-hover rounded-control w-5 h-8 text-ink-tertiary affordance" aria-label="Add a column">
380
+ <Plus className="size-3.5" />
381
+ </button>
382
+ </div>
383
+ </BlockRow>
384
+ );
385
+ }
386
+
387
+ function TableView({ block }: { block: AnyBlock }) {
388
+ const { rows = [], header = true } = block as { rows?: Grid; header?: boolean };
389
+ if (rows.length === 0) return null;
390
+ const cols = Math.max(...rows.map((r) => r.length));
391
+ const [head, ...body] = header ? rows : [null, ...rows];
392
+ return (
393
+ <div className="my-4">
394
+ <Table>
395
+ {head && (
396
+ <thead>
397
+ <tr>
398
+ {Array.from({ length: cols }, (_, c) => (
399
+ <Th key={c}>{head[c]}</Th>
400
+ ))}
401
+ </tr>
402
+ </thead>
403
+ )}
404
+ <tbody>
405
+ {body.map((row, r) => (
406
+ <tr key={r}>
407
+ {Array.from({ length: cols }, (_, c) => (
408
+ <Td key={c}>{row?.[c]}</Td>
409
+ ))}
410
+ </tr>
411
+ ))}
412
+ </tbody>
413
+ </Table>
414
+ </div>
415
+ );
416
+ }
417
+
418
+ export const tableBlock: BlockExtension<{ rows?: Grid; header?: boolean }> = {
419
+ type: "table",
420
+ kinds: [
421
+ {
422
+ key: "table",
423
+ label: "Table",
424
+ hint: "Words in rows and columns",
425
+ icon: Table2,
426
+ make: () => ({
427
+ type: "table",
428
+ header: true,
429
+ rows: [
430
+ ["", "", ""],
431
+ ["", "", ""],
432
+ ],
433
+ }),
434
+ },
435
+ ],
436
+ Edit: TableEdit,
437
+ View: TableView,
438
+ focus: (element) => {
439
+ const cell = element.querySelector<HTMLInputElement>('[data-cell="0-0"]');
440
+ cell?.focus();
441
+ return cell !== null;
442
+ },
443
+ };
444
+
445
+ /** The kit's own extra blocks, given to every editor and view before an app's. */
446
+ export const KIT_BLOCKS = [toggleBlock, calloutBlock, codeBlock, tableBlock];
447
+
448
+ /** An app's extensions with the kit's blocks before them; an app's own block of the same type wins. */
449
+ export const withKitBlocks = <X extends { type: string }>(extensions: readonly X[] = []): (X | (typeof KIT_BLOCKS)[number])[] => [
450
+ ...KIT_BLOCKS.filter((k) => !extensions.some((x) => x.type === k.type)),
451
+ ...extensions,
452
+ ];
@@ -0,0 +1,81 @@
1
+ "use client";
2
+
3
+ import { EyeOff } from "lucide-react";
4
+ import type { AnyBlock } from "../../../lib/document.ts";
5
+ import type { Text } from "../../../lib/rich-text.ts";
6
+ import { BlockList, BlockRow } from "../blocks.tsx";
7
+ import { BlockText } from "../block-text.tsx";
8
+ import { Blocks, Spans } from "../document-view.tsx";
9
+ import { useEditor } from "../editor-state.tsx";
10
+ import type { BlockExtension, Node, TextNode } from "../kinds.ts";
11
+
12
+ /*
13
+ * A spoiler: its own line says what it hides, and the blocks inside it are the
14
+ * spoiler. Written open, read closed until pressed. Built only from what the kit
15
+ * exports to extensions, so it doubles as the example of writing one.
16
+ *
17
+ * Stored as { type: "spoiler", text, children }. It hides text in the interface
18
+ * only: whoever stores a document must keep a spoiler's children out of any
19
+ * summary or excerpt shown beside it.
20
+ */
21
+
22
+ function SpoilerEdit({ block, depth }: { block: Node; depth: number }) {
23
+ const ed = useEditor();
24
+ return (
25
+ <div className="my-1.5 rounded-surface bg-tint-hover/70 py-1 shadow-edge">
26
+ <BlockRow block={block}>
27
+ <div className="flex items-start gap-2 px-2.5 py-[3px]">
28
+ <span contentEditable={false} className="flex h-[1.5em] shrink-0 items-center text-ink-tertiary select-none" title="Spoiler: hidden from readers until opened">
29
+ <EyeOff className="size-4" />
30
+ </span>
31
+ <BlockText block={block as TextNode} placeholder="Spoiler — say what it hides, e.g. “The ending”" alwaysShowPlaceholder className="flex-1 font-medium" />
32
+ </div>
33
+ </BlockRow>
34
+ <div className="pr-2.5 pl-8">
35
+ {block.children.length > 0 ? (
36
+ <BlockList blocks={block.children} depth={depth + 1} />
37
+ ) : (
38
+ <button type="button" onClick={() => ed.create(block.id, null, { type: "paragraph", text: [] }, { focus: true })} className="px-0.5 py-[3px] text-left text-sm text-ink-tertiary hover:text-ink-secondary">
39
+ Write what it hides
40
+ </button>
41
+ )}
42
+ </div>
43
+ </div>
44
+ );
45
+ }
46
+
47
+ function SpoilerView({ block, depth }: { block: AnyBlock; depth: number }) {
48
+ // A View receives any block; this one is always a spoiler's shape.
49
+ const { text = [], children = [] } = block as { text?: Text; children?: AnyBlock[] };
50
+ return (
51
+ <details className="my-4 [&[open]>summary>[data-when=closed]]:hidden [&:not([open])>summary>[data-when=open]]:hidden rounded-surface bg-tint-hover/70 shadow-edge">
52
+ <summary className="flex cursor-pointer list-none items-center gap-2 px-4 py-3 font-medium select-none [&::-webkit-details-marker]:hidden">
53
+ <EyeOff className="size-4 shrink-0 text-ink-tertiary" />
54
+ <span className="min-w-0 flex-1">
55
+ <Spans text={text.length > 0 ? text : [{ text: "Spoiler" }]} />
56
+ </span>
57
+ {/* Its own open state, not any open spoiler around it: spoilers can hold spoilers. */}
58
+ <span data-when="closed" className="text-caption font-normal text-ink-tertiary">
59
+ Spoiler · show
60
+ </span>
61
+ <span data-when="open" className="text-caption font-normal text-ink-tertiary">
62
+ Hide
63
+ </span>
64
+ </summary>
65
+ <div className="px-4 pb-3">
66
+ <Blocks blocks={children} depth={depth + 1} />
67
+ </div>
68
+ </details>
69
+ );
70
+ }
71
+
72
+ export const spoilerBlock: BlockExtension<{ text: Text; children?: AnyBlock[] }> = {
73
+ type: "spoiler",
74
+ kinds: [{ key: "spoiler", label: "Spoiler", hint: "Hidden until a reader opens it", icon: EyeOff, make: (text) => ({ type: "spoiler", text }) }],
75
+ shortcuts: { "!! ": "spoiler" },
76
+ // Anything can be hidden; a spoiler inside a spoiler is allowed but rarely wanted.
77
+ holds: () => true,
78
+ toggle: true,
79
+ Edit: SpoilerEdit,
80
+ View: SpoilerView,
81
+ };
@@ -0,0 +1,10 @@
1
+ export { DocumentEditor, type CheckLink, type DocumentEditorHandle, type ImageExtras, type OnLink, type UploadImage } from "./document-editor.tsx";
2
+ export { DocumentView, Blocks, Spans, type Density } from "./document-view.tsx";
3
+ export { spoilerBlock } from "./extensions/spoiler.tsx";
4
+ export { calloutBlock, codeBlock, KIT_BLOCKS, tableBlock, toggleBlock } from "./extensions/kit-blocks.tsx";
5
+ // What an app needs to write its own block (see BlockExtension and extensions/spoiler).
6
+ export { BlockList, BlockRow, Caption, PictureBlock } from "./blocks.tsx";
7
+ export { BlockText } from "./block-text.tsx";
8
+ export { useEditor } from "./editor-state.tsx";
9
+ export { schemaFor, type AnyExtension, type BlockExtension, type BlockKind, type KindOptions, type Node, type TextNode } from "./kinds.ts";
10
+ export type { AnyBlock, Block, CustomBlock } from "../../lib/document.ts";