@kujoforall/paper-ui 0.1.0 → 0.2.1

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 (553) hide show
  1. package/CHANGELOG.md +94 -0
  2. package/README.md +50 -7
  3. package/dist/components/editor/block-text.d.ts.map +1 -1
  4. package/dist/components/editor/block-text.js +52 -17
  5. package/dist/components/editor/block-text.js.map +1 -1
  6. package/dist/components/editor/blocks.d.ts.map +1 -1
  7. package/dist/components/editor/blocks.js +17 -13
  8. package/dist/components/editor/blocks.js.map +1 -1
  9. package/dist/components/editor/document-editor.d.ts.map +1 -1
  10. package/dist/components/editor/document-editor.js +4 -2
  11. package/dist/components/editor/document-editor.js.map +1 -1
  12. package/dist/components/editor/document-view.d.ts.map +1 -1
  13. package/dist/components/editor/document-view.js +17 -12
  14. package/dist/components/editor/document-view.js.map +1 -1
  15. package/dist/components/editor/editor-state.d.ts +7 -0
  16. package/dist/components/editor/editor-state.d.ts.map +1 -1
  17. package/dist/components/editor/editor-state.js +28 -3
  18. package/dist/components/editor/editor-state.js.map +1 -1
  19. package/dist/components/editor/extensions/kit-blocks.d.ts +34 -0
  20. package/dist/components/editor/extensions/kit-blocks.d.ts.map +1 -0
  21. package/dist/components/editor/extensions/kit-blocks.js +201 -0
  22. package/dist/components/editor/extensions/kit-blocks.js.map +1 -0
  23. package/dist/components/editor/extensions/spoiler.d.ts.map +1 -1
  24. package/dist/components/editor/extensions/spoiler.js +2 -2
  25. package/dist/components/editor/extensions/spoiler.js.map +1 -1
  26. package/dist/components/editor/index.d.ts +1 -0
  27. package/dist/components/editor/index.d.ts.map +1 -1
  28. package/dist/components/editor/index.js +1 -0
  29. package/dist/components/editor/index.js.map +1 -1
  30. package/dist/components/editor/kinds.js +1 -1
  31. package/dist/components/editor/kinds.js.map +1 -1
  32. package/dist/components/editor/look.d.ts +18 -0
  33. package/dist/components/editor/look.d.ts.map +1 -0
  34. package/dist/components/editor/look.js +21 -0
  35. package/dist/components/editor/look.js.map +1 -0
  36. package/dist/components/three/model-viewer.d.ts +36 -0
  37. package/dist/components/three/model-viewer.d.ts.map +1 -0
  38. package/dist/components/three/model-viewer.js +338 -0
  39. package/dist/components/three/model-viewer.js.map +1 -0
  40. package/dist/components/ui/accent-picker.js +1 -1
  41. package/dist/components/ui/accent-picker.js.map +1 -1
  42. package/dist/components/ui/alert-dialog.d.ts +29 -0
  43. package/dist/components/ui/alert-dialog.d.ts.map +1 -0
  44. package/dist/components/ui/alert-dialog.js +72 -0
  45. package/dist/components/ui/alert-dialog.js.map +1 -0
  46. package/dist/components/ui/animated-height.d.ts +6 -0
  47. package/dist/components/ui/animated-height.d.ts.map +1 -0
  48. package/dist/components/ui/animated-height.js +26 -0
  49. package/dist/components/ui/animated-height.js.map +1 -0
  50. package/dist/components/ui/app-shell.d.ts +1 -0
  51. package/dist/components/ui/app-shell.d.ts.map +1 -1
  52. package/dist/components/ui/app-shell.js +5 -3
  53. package/dist/components/ui/app-shell.js.map +1 -1
  54. package/dist/components/ui/avatar.d.ts +30 -0
  55. package/dist/components/ui/avatar.d.ts.map +1 -0
  56. package/dist/components/ui/avatar.js +50 -0
  57. package/dist/components/ui/avatar.js.map +1 -0
  58. package/dist/components/ui/badge.d.ts +3 -3
  59. package/dist/components/ui/badge.d.ts.map +1 -1
  60. package/dist/components/ui/badge.js +2 -2
  61. package/dist/components/ui/badge.js.map +1 -1
  62. package/dist/components/ui/banner.d.ts +33 -0
  63. package/dist/components/ui/banner.d.ts.map +1 -0
  64. package/dist/components/ui/banner.js +21 -0
  65. package/dist/components/ui/banner.js.map +1 -0
  66. package/dist/components/ui/breadcrumbs.js +1 -1
  67. package/dist/components/ui/breadcrumbs.js.map +1 -1
  68. package/dist/components/ui/button.d.ts +8 -6
  69. package/dist/components/ui/button.d.ts.map +1 -1
  70. package/dist/components/ui/button.js +91 -26
  71. package/dist/components/ui/button.js.map +1 -1
  72. package/dist/components/ui/calendar.d.ts.map +1 -1
  73. package/dist/components/ui/calendar.js +6 -5
  74. package/dist/components/ui/calendar.js.map +1 -1
  75. package/dist/components/ui/callout.d.ts +23 -4
  76. package/dist/components/ui/callout.d.ts.map +1 -1
  77. package/dist/components/ui/callout.js +28 -15
  78. package/dist/components/ui/callout.js.map +1 -1
  79. package/dist/components/ui/card.d.ts +13 -8
  80. package/dist/components/ui/card.d.ts.map +1 -1
  81. package/dist/components/ui/card.js +10 -9
  82. package/dist/components/ui/card.js.map +1 -1
  83. package/dist/components/ui/checkbox.d.ts +9 -4
  84. package/dist/components/ui/checkbox.d.ts.map +1 -1
  85. package/dist/components/ui/checkbox.js +25 -5
  86. package/dist/components/ui/checkbox.js.map +1 -1
  87. package/dist/components/ui/choice-label.d.ts +13 -0
  88. package/dist/components/ui/choice-label.d.ts.map +1 -0
  89. package/dist/components/ui/choice-label.js +17 -0
  90. package/dist/components/ui/choice-label.js.map +1 -0
  91. package/dist/components/ui/collapsible.d.ts +10 -0
  92. package/dist/components/ui/collapsible.d.ts.map +1 -0
  93. package/dist/components/ui/collapsible.js +21 -0
  94. package/dist/components/ui/collapsible.js.map +1 -0
  95. package/dist/components/ui/collection-layout.d.ts +24 -0
  96. package/dist/components/ui/collection-layout.d.ts.map +1 -0
  97. package/dist/components/ui/collection-layout.js +16 -0
  98. package/dist/components/ui/collection-layout.js.map +1 -0
  99. package/dist/components/ui/combobox.d.ts +10 -0
  100. package/dist/components/ui/combobox.d.ts.map +1 -0
  101. package/dist/components/ui/combobox.js +93 -0
  102. package/dist/components/ui/combobox.js.map +1 -0
  103. package/dist/components/ui/command-menu.d.ts +5 -2
  104. package/dist/components/ui/command-menu.d.ts.map +1 -1
  105. package/dist/components/ui/command-menu.js +31 -6
  106. package/dist/components/ui/command-menu.js.map +1 -1
  107. package/dist/components/ui/context-menu.d.ts +19 -0
  108. package/dist/components/ui/context-menu.d.ts.map +1 -0
  109. package/dist/components/ui/context-menu.js +42 -0
  110. package/dist/components/ui/context-menu.js.map +1 -0
  111. package/dist/components/ui/copy-button.d.ts +11 -0
  112. package/dist/components/ui/copy-button.d.ts.map +1 -0
  113. package/dist/components/ui/copy-button.js +48 -0
  114. package/dist/components/ui/copy-button.js.map +1 -0
  115. package/dist/components/ui/database/calendar-view.d.ts +10 -0
  116. package/dist/components/ui/database/calendar-view.d.ts.map +1 -0
  117. package/dist/components/ui/database/calendar-view.js +65 -0
  118. package/dist/components/ui/database/calendar-view.js.map +1 -0
  119. package/dist/components/ui/database/card-views.d.ts +22 -0
  120. package/dist/components/ui/database/card-views.d.ts.map +1 -0
  121. package/dist/components/ui/database/card-views.js +74 -0
  122. package/dist/components/ui/database/card-views.js.map +1 -0
  123. package/dist/components/ui/database/cells.d.ts +20 -0
  124. package/dist/components/ui/database/cells.d.ts.map +1 -0
  125. package/dist/components/ui/database/cells.js +132 -0
  126. package/dist/components/ui/database/cells.js.map +1 -0
  127. package/dist/components/ui/database/database.d.ts +19 -0
  128. package/dist/components/ui/database/database.d.ts.map +1 -0
  129. package/dist/components/ui/database/database.js +102 -0
  130. package/dist/components/ui/database/database.js.map +1 -0
  131. package/dist/components/ui/database/icons.d.ts +5 -0
  132. package/dist/components/ui/database/icons.d.ts.map +1 -0
  133. package/dist/components/ui/database/icons.js +13 -0
  134. package/dist/components/ui/database/icons.js.map +1 -0
  135. package/dist/components/ui/database/table-view.d.ts +11 -0
  136. package/dist/components/ui/database/table-view.d.ts.map +1 -0
  137. package/dist/components/ui/database/table-view.js +157 -0
  138. package/dist/components/ui/database/table-view.js.map +1 -0
  139. package/dist/components/ui/date-picker.d.ts +6 -1
  140. package/dist/components/ui/date-picker.d.ts.map +1 -1
  141. package/dist/components/ui/date-picker.js +20 -12
  142. package/dist/components/ui/date-picker.js.map +1 -1
  143. package/dist/components/ui/date-time-picker.d.ts +3 -1
  144. package/dist/components/ui/date-time-picker.d.ts.map +1 -1
  145. package/dist/components/ui/date-time-picker.js +17 -15
  146. package/dist/components/ui/date-time-picker.js.map +1 -1
  147. package/dist/components/ui/dialog.d.ts +13 -9
  148. package/dist/components/ui/dialog.d.ts.map +1 -1
  149. package/dist/components/ui/dialog.js +33 -3
  150. package/dist/components/ui/dialog.js.map +1 -1
  151. package/dist/components/ui/document-layout.d.ts +15 -0
  152. package/dist/components/ui/document-layout.d.ts.map +1 -0
  153. package/dist/components/ui/document-layout.js +15 -0
  154. package/dist/components/ui/document-layout.js.map +1 -0
  155. package/dist/components/ui/dropdown-menu.d.ts +14 -10
  156. package/dist/components/ui/dropdown-menu.d.ts.map +1 -1
  157. package/dist/components/ui/dropdown-menu.js +22 -13
  158. package/dist/components/ui/dropdown-menu.js.map +1 -1
  159. package/dist/components/ui/editable-text.d.ts +9 -2
  160. package/dist/components/ui/editable-text.d.ts.map +1 -1
  161. package/dist/components/ui/editable-text.js +27 -10
  162. package/dist/components/ui/editable-text.js.map +1 -1
  163. package/dist/components/ui/empty-state.d.ts +11 -0
  164. package/dist/components/ui/empty-state.d.ts.map +1 -0
  165. package/dist/components/ui/empty-state.js +9 -0
  166. package/dist/components/ui/empty-state.js.map +1 -0
  167. package/dist/components/ui/error-state.d.ts +20 -0
  168. package/dist/components/ui/error-state.d.ts.map +1 -0
  169. package/dist/components/ui/error-state.js +17 -0
  170. package/dist/components/ui/error-state.js.map +1 -0
  171. package/dist/components/ui/field-button.d.ts +2 -1
  172. package/dist/components/ui/field-button.d.ts.map +1 -1
  173. package/dist/components/ui/field-button.js +7 -5
  174. package/dist/components/ui/field-button.js.map +1 -1
  175. package/dist/components/ui/file-preview.js +1 -1
  176. package/dist/components/ui/file-preview.js.map +1 -1
  177. package/dist/components/ui/file-uploader.d.ts.map +1 -1
  178. package/dist/components/ui/file-uploader.js +5 -4
  179. package/dist/components/ui/file-uploader.js.map +1 -1
  180. package/dist/components/ui/filter-builder.d.ts +18 -0
  181. package/dist/components/ui/filter-builder.d.ts.map +1 -0
  182. package/dist/components/ui/filter-builder.js +98 -0
  183. package/dist/components/ui/filter-builder.js.map +1 -0
  184. package/dist/components/ui/focus-shell.d.ts +14 -0
  185. package/dist/components/ui/focus-shell.d.ts.map +1 -0
  186. package/dist/components/ui/focus-shell.js +13 -0
  187. package/dist/components/ui/focus-shell.js.map +1 -0
  188. package/dist/components/ui/handle-row.d.ts +11 -1
  189. package/dist/components/ui/handle-row.d.ts.map +1 -1
  190. package/dist/components/ui/handle-row.js +101 -32
  191. package/dist/components/ui/handle-row.js.map +1 -1
  192. package/dist/components/ui/header-bar.d.ts +5 -0
  193. package/dist/components/ui/header-bar.d.ts.map +1 -0
  194. package/dist/components/ui/header-bar.js +10 -0
  195. package/dist/components/ui/header-bar.js.map +1 -0
  196. package/dist/components/ui/hover-card.d.ts +6 -0
  197. package/dist/components/ui/hover-card.d.ts.map +1 -0
  198. package/dist/components/ui/hover-card.js +13 -0
  199. package/dist/components/ui/hover-card.js.map +1 -0
  200. package/dist/components/ui/image-block.js +4 -4
  201. package/dist/components/ui/image-block.js.map +1 -1
  202. package/dist/components/ui/image-card.d.ts.map +1 -1
  203. package/dist/components/ui/image-card.js +5 -4
  204. package/dist/components/ui/image-card.js.map +1 -1
  205. package/dist/components/ui/image-framer.d.ts +24 -0
  206. package/dist/components/ui/image-framer.d.ts.map +1 -0
  207. package/dist/components/ui/image-framer.js +89 -0
  208. package/dist/components/ui/image-framer.js.map +1 -0
  209. package/dist/components/ui/image-viewer.d.ts.map +1 -1
  210. package/dist/components/ui/image-viewer.js +38 -5
  211. package/dist/components/ui/image-viewer.js.map +1 -1
  212. package/dist/components/ui/image.d.ts +25 -3
  213. package/dist/components/ui/image.d.ts.map +1 -1
  214. package/dist/components/ui/image.js +50 -21
  215. package/dist/components/ui/image.js.map +1 -1
  216. package/dist/components/ui/index.d.ts +54 -11
  217. package/dist/components/ui/index.d.ts.map +1 -1
  218. package/dist/components/ui/index.js +53 -10
  219. package/dist/components/ui/index.js.map +1 -1
  220. package/dist/components/ui/input.d.ts +71 -12
  221. package/dist/components/ui/input.d.ts.map +1 -1
  222. package/dist/components/ui/input.js +236 -23
  223. package/dist/components/ui/input.js.map +1 -1
  224. package/dist/components/ui/link-block.d.ts.map +1 -1
  225. package/dist/components/ui/link-block.js +1 -1
  226. package/dist/components/ui/link-block.js.map +1 -1
  227. package/dist/components/ui/list-detail.d.ts +23 -0
  228. package/dist/components/ui/list-detail.d.ts.map +1 -0
  229. package/dist/components/ui/list-detail.js +33 -0
  230. package/dist/components/ui/list-detail.js.map +1 -0
  231. package/dist/components/ui/listbox.d.ts +7 -0
  232. package/dist/components/ui/listbox.d.ts.map +1 -0
  233. package/dist/components/ui/listbox.js +29 -0
  234. package/dist/components/ui/listbox.js.map +1 -0
  235. package/dist/components/ui/mac-card.js +1 -1
  236. package/dist/components/ui/mac-card.js.map +1 -1
  237. package/dist/components/ui/month-picker.d.ts +13 -0
  238. package/dist/components/ui/month-picker.d.ts.map +1 -0
  239. package/dist/components/ui/month-picker.js +53 -0
  240. package/dist/components/ui/month-picker.js.map +1 -0
  241. package/dist/components/ui/multi-select.d.ts +22 -0
  242. package/dist/components/ui/multi-select.d.ts.map +1 -0
  243. package/dist/components/ui/multi-select.js +88 -0
  244. package/dist/components/ui/multi-select.js.map +1 -0
  245. package/dist/components/ui/nav-tree.d.ts.map +1 -1
  246. package/dist/components/ui/nav-tree.js +10 -3
  247. package/dist/components/ui/nav-tree.js.map +1 -1
  248. package/dist/components/ui/page.d.ts +16 -5
  249. package/dist/components/ui/page.d.ts.map +1 -1
  250. package/dist/components/ui/page.js +23 -10
  251. package/dist/components/ui/page.js.map +1 -1
  252. package/dist/components/ui/pagination.d.ts +26 -0
  253. package/dist/components/ui/pagination.d.ts.map +1 -0
  254. package/dist/components/ui/pagination.js +54 -0
  255. package/dist/components/ui/pagination.js.map +1 -0
  256. package/dist/components/ui/picker-panel.d.ts +13 -0
  257. package/dist/components/ui/picker-panel.d.ts.map +1 -0
  258. package/dist/components/ui/picker-panel.js +19 -0
  259. package/dist/components/ui/picker-panel.js.map +1 -0
  260. package/dist/components/ui/popover.d.ts +2 -2
  261. package/dist/components/ui/popover.d.ts.map +1 -1
  262. package/dist/components/ui/popover.js +1 -1
  263. package/dist/components/ui/popover.js.map +1 -1
  264. package/dist/components/ui/progress.d.ts +11 -1
  265. package/dist/components/ui/progress.d.ts.map +1 -1
  266. package/dist/components/ui/progress.js +17 -4
  267. package/dist/components/ui/progress.js.map +1 -1
  268. package/dist/components/ui/property.d.ts +2 -6
  269. package/dist/components/ui/property.d.ts.map +1 -1
  270. package/dist/components/ui/property.js +6 -22
  271. package/dist/components/ui/property.js.map +1 -1
  272. package/dist/components/ui/radio-group.d.ts +8 -0
  273. package/dist/components/ui/radio-group.d.ts.map +1 -0
  274. package/dist/components/ui/radio-group.js +18 -0
  275. package/dist/components/ui/radio-group.js.map +1 -0
  276. package/dist/components/ui/rating.d.ts +14 -0
  277. package/dist/components/ui/rating.d.ts.map +1 -0
  278. package/dist/components/ui/rating.js +61 -0
  279. package/dist/components/ui/rating.js.map +1 -0
  280. package/dist/components/ui/save-status.d.ts +8 -0
  281. package/dist/components/ui/save-status.d.ts.map +1 -0
  282. package/dist/components/ui/save-status.js +31 -0
  283. package/dist/components/ui/save-status.js.map +1 -0
  284. package/dist/components/ui/segmented.d.ts +15 -7
  285. package/dist/components/ui/segmented.d.ts.map +1 -1
  286. package/dist/components/ui/segmented.js +8 -6
  287. package/dist/components/ui/segmented.js.map +1 -1
  288. package/dist/components/ui/select-menu.d.ts +3 -1
  289. package/dist/components/ui/select-menu.d.ts.map +1 -1
  290. package/dist/components/ui/select-menu.js +2 -2
  291. package/dist/components/ui/select-menu.js.map +1 -1
  292. package/dist/components/ui/select.d.ts +7 -2
  293. package/dist/components/ui/select.d.ts.map +1 -1
  294. package/dist/components/ui/select.js +19 -5
  295. package/dist/components/ui/select.js.map +1 -1
  296. package/dist/components/ui/selection-bar.js +1 -1
  297. package/dist/components/ui/selection-bar.js.map +1 -1
  298. package/dist/components/ui/settings-layout.d.ts +34 -0
  299. package/dist/components/ui/settings-layout.d.ts.map +1 -0
  300. package/dist/components/ui/settings-layout.js +16 -0
  301. package/dist/components/ui/settings-layout.js.map +1 -0
  302. package/dist/components/ui/share-link.d.ts +14 -0
  303. package/dist/components/ui/share-link.d.ts.map +1 -0
  304. package/dist/components/ui/share-link.js +16 -0
  305. package/dist/components/ui/share-link.js.map +1 -0
  306. package/dist/components/ui/sheet.d.ts +21 -0
  307. package/dist/components/ui/sheet.d.ts.map +1 -0
  308. package/dist/components/ui/sheet.js +53 -0
  309. package/dist/components/ui/sheet.js.map +1 -0
  310. package/dist/components/ui/sidebar.d.ts +82 -0
  311. package/dist/components/ui/sidebar.d.ts.map +1 -0
  312. package/dist/components/ui/sidebar.js +258 -0
  313. package/dist/components/ui/sidebar.js.map +1 -0
  314. package/dist/components/ui/skeleton.d.ts +8 -0
  315. package/dist/components/ui/skeleton.d.ts.map +1 -0
  316. package/dist/components/ui/skeleton.js +15 -0
  317. package/dist/components/ui/skeleton.js.map +1 -0
  318. package/dist/components/ui/spinner.d.ts +12 -0
  319. package/dist/components/ui/spinner.d.ts.map +1 -0
  320. package/dist/components/ui/spinner.js +14 -0
  321. package/dist/components/ui/spinner.js.map +1 -0
  322. package/dist/components/ui/spotlight.d.ts.map +1 -1
  323. package/dist/components/ui/spotlight.js +14 -11
  324. package/dist/components/ui/spotlight.js.map +1 -1
  325. package/dist/components/ui/step-dialog.js +3 -3
  326. package/dist/components/ui/step-dialog.js.map +1 -1
  327. package/dist/components/ui/steps-layout.d.ts +20 -0
  328. package/dist/components/ui/steps-layout.d.ts.map +1 -0
  329. package/dist/components/ui/steps-layout.js +26 -0
  330. package/dist/components/ui/steps-layout.js.map +1 -0
  331. package/dist/components/ui/switch.d.ts +8 -0
  332. package/dist/components/ui/switch.d.ts.map +1 -0
  333. package/dist/components/ui/switch.js +21 -0
  334. package/dist/components/ui/switch.js.map +1 -0
  335. package/dist/components/ui/table.d.ts +13 -5
  336. package/dist/components/ui/table.d.ts.map +1 -1
  337. package/dist/components/ui/table.js +65 -12
  338. package/dist/components/ui/table.js.map +1 -1
  339. package/dist/components/ui/tabs.d.ts +7 -0
  340. package/dist/components/ui/tabs.d.ts.map +1 -0
  341. package/dist/components/ui/tabs.js +19 -0
  342. package/dist/components/ui/tabs.js.map +1 -0
  343. package/dist/components/ui/theme-toggle.d.ts +14 -0
  344. package/dist/components/ui/theme-toggle.d.ts.map +1 -1
  345. package/dist/components/ui/theme-toggle.js +69 -41
  346. package/dist/components/ui/theme-toggle.js.map +1 -1
  347. package/dist/components/ui/time-list.d.ts +16 -0
  348. package/dist/components/ui/time-list.d.ts.map +1 -0
  349. package/dist/components/ui/time-list.js +49 -0
  350. package/dist/components/ui/time-list.js.map +1 -0
  351. package/dist/components/ui/time-picker.d.ts +37 -11
  352. package/dist/components/ui/time-picker.d.ts.map +1 -1
  353. package/dist/components/ui/time-picker.js +130 -52
  354. package/dist/components/ui/time-picker.js.map +1 -1
  355. package/dist/components/ui/toast.d.ts +18 -0
  356. package/dist/components/ui/toast.d.ts.map +1 -0
  357. package/dist/components/ui/toast.js +77 -0
  358. package/dist/components/ui/toast.js.map +1 -0
  359. package/dist/components/ui/toggle.d.ts +15 -0
  360. package/dist/components/ui/toggle.d.ts.map +1 -0
  361. package/dist/components/ui/toggle.js +55 -0
  362. package/dist/components/ui/toggle.js.map +1 -0
  363. package/dist/components/ui/tooltip.d.ts +1 -1
  364. package/dist/components/ui/tooltip.d.ts.map +1 -1
  365. package/dist/components/ui/tooltip.js +13 -2
  366. package/dist/components/ui/tooltip.js.map +1 -1
  367. package/dist/components/ui/top-bar.d.ts +25 -0
  368. package/dist/components/ui/top-bar.d.ts.map +1 -0
  369. package/dist/components/ui/top-bar.js +23 -0
  370. package/dist/components/ui/top-bar.js.map +1 -0
  371. package/dist/components/ui/typography.d.ts +11 -5
  372. package/dist/components/ui/typography.d.ts.map +1 -1
  373. package/dist/components/ui/typography.js +31 -5
  374. package/dist/components/ui/typography.js.map +1 -1
  375. package/dist/components/ui/video-block.d.ts.map +1 -1
  376. package/dist/components/ui/video-block.js +5 -1
  377. package/dist/components/ui/video-block.js.map +1 -1
  378. package/dist/hooks/use-dismiss.d.ts +5 -0
  379. package/dist/hooks/use-dismiss.d.ts.map +1 -0
  380. package/dist/hooks/use-dismiss.js +23 -0
  381. package/dist/hooks/use-dismiss.js.map +1 -0
  382. package/dist/hooks/use-escape-first.d.ts +3 -0
  383. package/dist/hooks/use-escape-first.d.ts.map +1 -0
  384. package/dist/hooks/use-escape-first.js +27 -0
  385. package/dist/hooks/use-escape-first.js.map +1 -0
  386. package/dist/hooks/use-media-query.d.ts +5 -0
  387. package/dist/hooks/use-media-query.d.ts.map +1 -0
  388. package/dist/hooks/use-media-query.js +16 -0
  389. package/dist/hooks/use-media-query.js.map +1 -0
  390. package/dist/hooks/use-save-queue.d.ts.map +1 -1
  391. package/dist/hooks/use-save-queue.js +19 -7
  392. package/dist/hooks/use-save-queue.js.map +1 -1
  393. package/dist/hooks/use-selection.d.ts.map +1 -1
  394. package/dist/hooks/use-selection.js +10 -1
  395. package/dist/hooks/use-selection.js.map +1 -1
  396. package/dist/lib/database.d.ts +92 -0
  397. package/dist/lib/database.d.ts.map +1 -0
  398. package/dist/lib/database.js +272 -0
  399. package/dist/lib/database.js.map +1 -0
  400. package/dist/lib/dates.d.ts +16 -0
  401. package/dist/lib/dates.d.ts.map +1 -1
  402. package/dist/lib/dates.js +27 -0
  403. package/dist/lib/dates.js.map +1 -1
  404. package/dist/lib/keys.d.ts +18 -0
  405. package/dist/lib/keys.d.ts.map +1 -0
  406. package/dist/lib/keys.js +66 -0
  407. package/dist/lib/keys.js.map +1 -0
  408. package/dist/lib/number.d.ts +4 -0
  409. package/dist/lib/number.d.ts.map +1 -0
  410. package/dist/lib/number.js +33 -0
  411. package/dist/lib/number.js.map +1 -0
  412. package/dist/lib/pointer.d.ts +2 -0
  413. package/dist/lib/pointer.d.ts.map +1 -0
  414. package/dist/lib/pointer.js +4 -0
  415. package/dist/lib/pointer.js.map +1 -0
  416. package/dist/lib/prepare-image.d.ts +43 -0
  417. package/dist/lib/prepare-image.d.ts.map +1 -0
  418. package/dist/lib/prepare-image.js +105 -0
  419. package/dist/lib/prepare-image.js.map +1 -0
  420. package/dist/lib/rich-text-dom.d.ts +2 -0
  421. package/dist/lib/rich-text-dom.d.ts.map +1 -1
  422. package/dist/lib/rich-text-dom.js +5 -3
  423. package/dist/lib/rich-text-dom.js.map +1 -1
  424. package/dist/lib/theme.d.ts +6 -0
  425. package/dist/lib/theme.d.ts.map +1 -0
  426. package/dist/lib/theme.js +15 -0
  427. package/dist/lib/theme.js.map +1 -0
  428. package/dist/lib/time.d.ts +19 -0
  429. package/dist/lib/time.d.ts.map +1 -0
  430. package/dist/lib/time.js +91 -0
  431. package/dist/lib/time.js.map +1 -0
  432. package/dist/lib/utils.d.ts.map +1 -1
  433. package/dist/lib/utils.js +20 -2
  434. package/dist/lib/utils.js.map +1 -1
  435. package/dist/styles/notion.css +342 -51
  436. package/package.json +27 -4
  437. package/src/components/editor/block-text.tsx +58 -17
  438. package/src/components/editor/blocks.tsx +19 -14
  439. package/src/components/editor/document-editor.tsx +7 -2
  440. package/src/components/editor/document-view.tsx +37 -24
  441. package/src/components/editor/editor-state.tsx +31 -3
  442. package/src/components/editor/extensions/kit-blocks.tsx +452 -0
  443. package/src/components/editor/extensions/spoiler.tsx +9 -4
  444. package/src/components/editor/index.ts +1 -0
  445. package/src/components/editor/kinds.ts +1 -1
  446. package/src/components/editor/look.tsx +36 -0
  447. package/src/components/three/model-viewer.tsx +514 -0
  448. package/src/components/ui/accent-picker.tsx +2 -2
  449. package/src/components/ui/alert-dialog.tsx +136 -0
  450. package/src/components/ui/animated-height.tsx +34 -0
  451. package/src/components/ui/app-shell.tsx +9 -7
  452. package/src/components/ui/avatar.tsx +106 -0
  453. package/src/components/ui/badge.tsx +4 -4
  454. package/src/components/ui/banner.tsx +53 -0
  455. package/src/components/ui/breadcrumbs.tsx +1 -1
  456. package/src/components/ui/button.tsx +115 -41
  457. package/src/components/ui/calendar.tsx +8 -7
  458. package/src/components/ui/callout.tsx +41 -42
  459. package/src/components/ui/card.tsx +27 -58
  460. package/src/components/ui/checkbox.tsx +53 -19
  461. package/src/components/ui/choice-label.tsx +43 -0
  462. package/src/components/ui/collapsible.tsx +58 -0
  463. package/src/components/ui/collection-layout.tsx +69 -0
  464. package/src/components/ui/combobox.tsx +155 -0
  465. package/src/components/ui/command-menu.tsx +61 -31
  466. package/src/components/ui/context-menu.tsx +89 -0
  467. package/src/components/ui/copy-button.tsx +80 -0
  468. package/src/components/ui/database/calendar-view.tsx +180 -0
  469. package/src/components/ui/database/card-views.tsx +221 -0
  470. package/src/components/ui/database/cells.tsx +237 -0
  471. package/src/components/ui/database/database.tsx +279 -0
  472. package/src/components/ui/database/icons.ts +15 -0
  473. package/src/components/ui/database/table-view.tsx +311 -0
  474. package/src/components/ui/date-picker.tsx +99 -61
  475. package/src/components/ui/date-time-picker.tsx +68 -62
  476. package/src/components/ui/dialog.tsx +48 -21
  477. package/src/components/ui/document-layout.tsx +52 -0
  478. package/src/components/ui/dropdown-menu.tsx +33 -31
  479. package/src/components/ui/editable-text.tsx +40 -7
  480. package/src/components/ui/empty-state.tsx +35 -0
  481. package/src/components/ui/error-state.tsx +67 -0
  482. package/src/components/ui/field-button.tsx +11 -9
  483. package/src/components/ui/file-preview.tsx +1 -1
  484. package/src/components/ui/file-uploader.tsx +23 -24
  485. package/src/components/ui/filter-builder.tsx +304 -0
  486. package/src/components/ui/focus-shell.tsx +48 -0
  487. package/src/components/ui/handle-row.tsx +176 -40
  488. package/src/components/ui/header-bar.tsx +15 -0
  489. package/src/components/ui/hover-card.tsx +30 -0
  490. package/src/components/ui/image-block.tsx +6 -6
  491. package/src/components/ui/image-card.tsx +18 -25
  492. package/src/components/ui/image-framer.tsx +160 -0
  493. package/src/components/ui/image-viewer.tsx +53 -10
  494. package/src/components/ui/image.tsx +133 -29
  495. package/src/components/ui/index.ts +106 -11
  496. package/src/components/ui/input.tsx +437 -65
  497. package/src/components/ui/link-block.tsx +5 -2
  498. package/src/components/ui/list-detail.tsx +115 -0
  499. package/src/components/ui/listbox.ts +26 -0
  500. package/src/components/ui/mac-card.tsx +5 -5
  501. package/src/components/ui/month-picker.tsx +119 -0
  502. package/src/components/ui/multi-select.tsx +221 -0
  503. package/src/components/ui/nav-tree.tsx +11 -5
  504. package/src/components/ui/page.tsx +63 -15
  505. package/src/components/ui/pagination.tsx +143 -0
  506. package/src/components/ui/picker-panel.tsx +69 -0
  507. package/src/components/ui/popover.tsx +3 -3
  508. package/src/components/ui/progress.tsx +56 -16
  509. package/src/components/ui/property.tsx +6 -37
  510. package/src/components/ui/radio-group.tsx +61 -0
  511. package/src/components/ui/rating.tsx +122 -0
  512. package/src/components/ui/save-status.tsx +53 -0
  513. package/src/components/ui/segmented.tsx +48 -16
  514. package/src/components/ui/select-menu.tsx +11 -3
  515. package/src/components/ui/select.tsx +33 -10
  516. package/src/components/ui/selection-bar.tsx +1 -1
  517. package/src/components/ui/settings-layout.tsx +117 -0
  518. package/src/components/ui/share-link.tsx +66 -0
  519. package/src/components/ui/sheet.tsx +90 -0
  520. package/src/components/ui/sidebar.tsx +627 -0
  521. package/src/components/ui/skeleton.tsx +22 -0
  522. package/src/components/ui/spinner.tsx +28 -0
  523. package/src/components/ui/spotlight.tsx +21 -21
  524. package/src/components/ui/step-dialog.tsx +6 -6
  525. package/src/components/ui/steps-layout.tsx +91 -0
  526. package/src/components/ui/switch.tsx +55 -0
  527. package/src/components/ui/table.tsx +75 -18
  528. package/src/components/ui/tabs.tsx +41 -0
  529. package/src/components/ui/theme-toggle.tsx +74 -83
  530. package/src/components/ui/time-list.tsx +106 -0
  531. package/src/components/ui/time-picker.tsx +305 -134
  532. package/src/components/ui/toast.tsx +132 -0
  533. package/src/components/ui/toggle.tsx +76 -0
  534. package/src/components/ui/tooltip.tsx +20 -6
  535. package/src/components/ui/top-bar.tsx +118 -0
  536. package/src/components/ui/typography.tsx +45 -9
  537. package/src/components/ui/video-block.tsx +9 -3
  538. package/src/hooks/use-dismiss.ts +24 -0
  539. package/src/hooks/use-escape-first.ts +25 -0
  540. package/src/hooks/use-media-query.ts +23 -0
  541. package/src/hooks/use-save-queue.ts +19 -7
  542. package/src/hooks/use-selection.ts +8 -1
  543. package/src/lib/database.ts +322 -0
  544. package/src/lib/dates.ts +36 -0
  545. package/src/lib/keys.ts +72 -0
  546. package/src/lib/number.ts +29 -0
  547. package/src/lib/pointer.ts +3 -0
  548. package/src/lib/prepare-image.ts +141 -0
  549. package/src/lib/rich-text-dom.ts +5 -3
  550. package/src/lib/theme.ts +18 -0
  551. package/src/lib/time.ts +83 -0
  552. package/src/lib/utils.ts +21 -2
  553. package/src/styles/notion.css +342 -51
@@ -0,0 +1,514 @@
1
+ "use client";
2
+
3
+ import { Maximize, Minimize, Pause, Play, RotateCcw, Rotate3d } from "lucide-react";
4
+ import { useEffect, useId, useRef, useState, type KeyboardEvent, type ReactNode } from "react";
5
+ import * as THREE from "three";
6
+ import { OrbitControls } from "three/examples/jsm/controls/OrbitControls.js";
7
+ import { RoomEnvironment } from "three/examples/jsm/environments/RoomEnvironment.js";
8
+ import { DRACOLoader } from "three/examples/jsm/loaders/DRACOLoader.js";
9
+ import { GLTFLoader, type GLTF } from "three/examples/jsm/loaders/GLTFLoader.js";
10
+ import { useMediaQuery } from "../../hooks/use-media-query.ts";
11
+ import { cn } from "../../lib/utils.ts";
12
+ import { Button } from "../ui/button.tsx";
13
+ import { ratioOf, type ImageRatio } from "../ui/image.tsx";
14
+ import { Tooltip } from "../ui/tooltip.tsx";
15
+
16
+ /* A 3D model (glTF or GLB) in place, to turn and look at: @kujoforall/paper-ui/three.
17
+
18
+ Loading: a wireframe box traces itself in, edge by edge, on repeat, with a
19
+ line under it filling as the file downloads; then the model eases in, growing and settling as the
20
+ camera comes in to it, as a picture sharpens in.
21
+
22
+ Animation: a model's own animations wait at their first frame until Play
23
+ (`autoPlay` to start them at once); `animation` chooses which.
24
+
25
+ Moving: drag to turn it, scroll or pinch to zoom, right-drag or two fingers to
26
+ move it. From the keyboard, once focused: the arrows turn it, + and − zoom, 0
27
+ puts it back. Buttons for putting the view back, turning on its own, playing the
28
+ model's own animation and filling the screen. The view is framed to the model
29
+ whatever its size.
30
+
31
+ It draws only when something moves, and not at all while off screen or in a
32
+ hidden tab. Reduced motion skips the entrance and does not turn on its own.
33
+ Everything it made is let go of on unmount. Needs `three` (an optional peer
34
+ dependency, from 0.160). */
35
+
36
+ export type ModelInfo = { animations: string[]; size: { x: number; y: number; z: number } };
37
+
38
+ export function ModelViewer({
39
+ src,
40
+ alt,
41
+ ratio = "landscape",
42
+ autoRotate = false,
43
+ animation = 0,
44
+ autoPlay = false,
45
+ draco,
46
+ pending = false,
47
+ controls = true,
48
+ background,
49
+ onLoad,
50
+ onError,
51
+ className,
52
+ children,
53
+ }: {
54
+ src: string;
55
+ /** What the model is, for a screen reader. */
56
+ alt: string;
57
+ ratio?: ImageRatio;
58
+ /** Turn slowly on its own (not under reduced motion). */
59
+ autoRotate?: boolean;
60
+ /** Which of the model's animations to play, by name or number; null for none. */
61
+ animation?: string | number | null;
62
+ /** Start the animation playing; by default it waits, at its first frame, for Play. */
63
+ autoPlay?: boolean;
64
+ /** Where the Draco decoder lives, for a compressed model (e.g. "https://www.gstatic.com/draco/versioned/decoders/1.5.7/"). */
65
+ draco?: string;
66
+ /** The model is on its way but its address is not known yet (still uploading): shows the loading state. */
67
+ pending?: boolean;
68
+ /** Show the buttons. */
69
+ controls?: boolean;
70
+ /** A CSS colour behind the model; the surface's own by default. */
71
+ background?: string;
72
+ onLoad?: (info: ModelInfo) => void;
73
+ onError?: (error: Error) => void;
74
+ className?: string;
75
+ /** Over the model, top left: a caption, a badge. */
76
+ children?: ReactNode;
77
+ }) {
78
+ const box = useRef<HTMLDivElement>(null);
79
+ const canvasHost = useRef<HTMLDivElement>(null);
80
+ const help = useId();
81
+ const reduced = useMediaQuery("(prefers-reduced-motion: reduce)");
82
+ const [progress, setProgress] = useState<number | null>(0);
83
+ const [state, setState] = useState<"loading" | "ready" | "error">("loading");
84
+ const [error, setError] = useState<string | null>(null);
85
+ const [rotating, setRotating] = useState(autoRotate);
86
+ const [playing, setPlaying] = useState(autoPlay);
87
+ const [clips, setClips] = useState<string[]>([]);
88
+ const [full, setFull] = useState(false);
89
+ const [touched, setTouched] = useState(false);
90
+ // The live scene, for the buttons and keys to reach.
91
+ const world = useRef<{
92
+ camera: THREE.PerspectiveCamera;
93
+ controls: OrbitControls;
94
+ home: { position: THREE.Vector3; target: THREE.Vector3 };
95
+ mixer: THREE.AnimationMixer | null;
96
+ actions: THREE.AnimationAction[];
97
+ clipsByName: Map<string, THREE.AnimationAction>;
98
+ flyTo: (position: THREE.Vector3, target: THREE.Vector3, ms?: number) => void;
99
+ wake: () => void;
100
+ } | null>(null);
101
+ const latest = useRef({ onLoad, onError, reduced });
102
+ latest.current = { onLoad, onError, reduced };
103
+
104
+ useEffect(() => {
105
+ const host = canvasHost.current;
106
+ if (!host) return;
107
+ let disposed = false;
108
+ setState("loading");
109
+ setProgress(pending ? null : 0);
110
+ setError(null);
111
+ if (pending) return;
112
+
113
+ let renderer: THREE.WebGLRenderer;
114
+ try {
115
+ renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true });
116
+ } catch {
117
+ setState("error");
118
+ setError("This browser can't show 3D models.");
119
+ return;
120
+ }
121
+ renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
122
+ renderer.outputColorSpace = THREE.SRGBColorSpace;
123
+ renderer.toneMapping = THREE.ACESFilmicToneMapping;
124
+ renderer.domElement.style.display = "block";
125
+ renderer.domElement.setAttribute("aria-hidden", "true");
126
+ host.appendChild(renderer.domElement);
127
+
128
+ const scene = new THREE.Scene();
129
+ const pmrem = new THREE.PMREMGenerator(renderer);
130
+ const room = new RoomEnvironment();
131
+ const environment = pmrem.fromScene(room, 0.04);
132
+ scene.environment = environment.texture;
133
+ const camera = new THREE.PerspectiveCamera(35, 1, 0.01, 1000);
134
+ const orbit = new OrbitControls(camera, renderer.domElement);
135
+ orbit.enableDamping = true;
136
+ orbit.dampingFactor = 0.08;
137
+ orbit.autoRotateSpeed = 1.2;
138
+
139
+ // The time between frames, kept by hand: THREE.Clock is deprecated from r185,
140
+ // and its replacement is not in every three this supports (from 0.160).
141
+ let lastFrame = performance.now();
142
+ let mixer: THREE.AnimationMixer | null = null;
143
+ let model: THREE.Object3D | null = null;
144
+ let visible = true;
145
+ let dirty = true;
146
+ // A camera flight (the entrance, a reset): from, to, start time, length.
147
+ let flight: { from: [THREE.Vector3, THREE.Vector3]; to: [THREE.Vector3, THREE.Vector3]; start: number; ms: number } | null = null;
148
+ let grow: { start: number; ms: number } | null = null;
149
+ const ease = (t: number) => 1 - Math.pow(1 - t, 3);
150
+
151
+ const flyTo = (position: THREE.Vector3, target: THREE.Vector3, ms = 450) => {
152
+ if (latest.current.reduced) {
153
+ camera.position.copy(position);
154
+ orbit.target.copy(target);
155
+ orbit.update();
156
+ dirty = true;
157
+ return;
158
+ }
159
+ flight = { from: [camera.position.clone(), orbit.target.clone()], to: [position.clone(), target.clone()], start: performance.now(), ms };
160
+ };
161
+
162
+ const size = () => {
163
+ const { clientWidth: w, clientHeight: h } = host;
164
+ if (!w || !h) return;
165
+ renderer.setSize(w, h, false);
166
+ renderer.domElement.style.width = "100%";
167
+ renderer.domElement.style.height = "100%";
168
+ camera.aspect = w / h;
169
+ camera.updateProjectionMatrix();
170
+ dirty = true;
171
+ };
172
+ const resize = new ResizeObserver(size);
173
+ resize.observe(host);
174
+ size();
175
+ const seen = new IntersectionObserver(([entry]) => (visible = entry?.isIntersecting ?? true));
176
+ seen.observe(host);
177
+ orbit.addEventListener("change", () => (dirty = true));
178
+ orbit.addEventListener("start", () => setTouched(true));
179
+
180
+ renderer.setAnimationLoop(() => {
181
+ // Off screen or in a hidden tab: nothing drawn, and the clock kept current, so
182
+ // the animation picks up where it was rather than jumping ahead.
183
+ if (!visible || document.hidden) {
184
+ lastFrame = performance.now();
185
+ return;
186
+ }
187
+ const now = performance.now();
188
+ const delta = (now - lastFrame) / 1000;
189
+ lastFrame = now;
190
+ if (flight) {
191
+ const t = Math.min(1, (now - flight.start) / flight.ms);
192
+ camera.position.lerpVectors(flight.from[0], flight.to[0], ease(t));
193
+ orbit.target.lerpVectors(flight.from[1], flight.to[1], ease(t));
194
+ if (t === 1) flight = null;
195
+ dirty = true;
196
+ }
197
+ if (grow && model) {
198
+ const t = Math.min(1, (now - grow.start) / grow.ms);
199
+ model.scale.setScalar(0.9 + 0.1 * ease(t));
200
+ if (t === 1) grow = null;
201
+ dirty = true;
202
+ }
203
+ if (mixer && mixer.timeScale !== 0) {
204
+ mixer.update(delta);
205
+ dirty = true;
206
+ }
207
+ // Damping and turning on its own move the camera inside update().
208
+ if (orbit.update() || orbit.autoRotate) dirty = true;
209
+ if (dirty) {
210
+ renderer.render(scene, camera);
211
+ dirty = false;
212
+ }
213
+ });
214
+
215
+ const loader = new GLTFLoader();
216
+ let dracoLoader: DRACOLoader | null = null;
217
+ if (draco) {
218
+ dracoLoader = new DRACOLoader();
219
+ dracoLoader.setDecoderPath(draco);
220
+ loader.setDRACOLoader(dracoLoader);
221
+ }
222
+ loader.load(
223
+ src,
224
+ (gltf: GLTF) => {
225
+ if (disposed) return;
226
+ model = gltf.scene;
227
+ // Frame it: centred on the origin, the camera far enough back to see all of it.
228
+ const bounds = new THREE.Box3().setFromObject(model);
229
+ const sizeOf = bounds.getSize(new THREE.Vector3());
230
+ const centre = bounds.getCenter(new THREE.Vector3());
231
+ model.position.sub(centre);
232
+ const pivot = new THREE.Group();
233
+ pivot.add(model);
234
+ scene.add(pivot);
235
+ model = pivot;
236
+ const radius = sizeOf.length() / 2 || 1;
237
+ const distance = radius / Math.sin(THREE.MathUtils.degToRad(camera.fov / 2)) * 1.05;
238
+ const home = { position: new THREE.Vector3(0.55, 0.3, 1).normalize().multiplyScalar(distance), target: new THREE.Vector3() };
239
+ camera.near = distance / 100;
240
+ camera.far = distance * 20;
241
+ camera.updateProjectionMatrix();
242
+ orbit.minDistance = radius * 0.6;
243
+ orbit.maxDistance = distance * 4;
244
+ orbit.target.copy(home.target);
245
+
246
+ if (latest.current.reduced) {
247
+ camera.position.copy(home.position);
248
+ } else {
249
+ camera.position.copy(home.position).multiplyScalar(1.35);
250
+ flyTo(home.position, home.target, 900);
251
+ grow = { start: performance.now(), ms: 700 };
252
+ pivot.scale.setScalar(0.9);
253
+ }
254
+ orbit.update();
255
+
256
+ const clipsByName = new Map<string, THREE.AnimationAction>();
257
+ const actions: THREE.AnimationAction[] = [];
258
+ if (gltf.animations.length) {
259
+ mixer = new THREE.AnimationMixer(gltf.scene);
260
+ for (const clip of gltf.animations) {
261
+ const action = mixer.clipAction(clip);
262
+ actions.push(action);
263
+ clipsByName.set(clip.name, action);
264
+ }
265
+ }
266
+ world.current = { camera, controls: orbit, home, mixer, actions, clipsByName, flyTo, wake: () => (dirty = true) };
267
+ setClips(gltf.animations.map((clip) => clip.name));
268
+ setProgress(1);
269
+ setState("ready");
270
+ dirty = true;
271
+ latest.current.onLoad?.({ animations: gltf.animations.map((clip) => clip.name), size: { x: sizeOf.x, y: sizeOf.y, z: sizeOf.z } });
272
+ },
273
+ (event) => {
274
+ if (!disposed) setProgress(event.lengthComputable && event.total ? event.loaded / event.total : null);
275
+ },
276
+ (err) => {
277
+ if (disposed) return;
278
+ setState("error");
279
+ setError("This model couldn't be loaded.");
280
+ latest.current.onError?.(err instanceof Error ? err : new Error(String(err)));
281
+ },
282
+ );
283
+
284
+ return () => {
285
+ disposed = true;
286
+ world.current = null;
287
+ renderer.setAnimationLoop(null);
288
+ resize.disconnect();
289
+ seen.disconnect();
290
+ orbit.dispose();
291
+ mixer?.stopAllAction();
292
+ scene.traverse((object) => {
293
+ const mesh = object as THREE.Mesh;
294
+ mesh.geometry?.dispose();
295
+ const materials = Array.isArray(mesh.material) ? mesh.material : mesh.material ? [mesh.material] : [];
296
+ for (const material of materials) {
297
+ for (const value of Object.values(material)) if (value instanceof THREE.Texture) value.dispose();
298
+ material.dispose();
299
+ }
300
+ });
301
+ environment.dispose();
302
+ room.dispose?.();
303
+ pmrem.dispose();
304
+ dracoLoader?.dispose();
305
+ renderer.dispose();
306
+ // Let the browser have the context back now: switching models makes a new one,
307
+ // and browsers allow only a handful at once.
308
+ renderer.forceContextLoss();
309
+ renderer.domElement.remove();
310
+ };
311
+ }, [src, draco, pending]);
312
+
313
+ // Turning on its own, never under reduced motion.
314
+ useEffect(() => {
315
+ const w = world.current;
316
+ if (!w) return;
317
+ w.controls.autoRotate = rotating && !reduced;
318
+ w.wake();
319
+ }, [rotating, reduced, state]);
320
+
321
+ // The chosen animation, playing or held.
322
+ useEffect(() => {
323
+ const w = world.current;
324
+ if (!w?.mixer) return;
325
+ const chosen = animation === null ? undefined : typeof animation === "number" ? w.actions[animation] : w.clipsByName.get(animation);
326
+ w.mixer.timeScale = playing ? 1 : 0;
327
+ if (playing) {
328
+ for (const action of w.actions) if (action !== chosen) action.fadeOut(0.3);
329
+ chosen?.reset().fadeIn(0.3).play();
330
+ } else {
331
+ // Paused, there is no time for a crossfade: show the chosen one's first frame.
332
+ for (const action of w.actions) if (action !== chosen) action.stop();
333
+ chosen?.reset().setEffectiveWeight(1).play();
334
+ w.mixer.update(0);
335
+ }
336
+ w.wake();
337
+ }, [animation, playing, state]);
338
+
339
+ useEffect(() => {
340
+ const onChange = () => setFull(document.fullscreenElement === box.current);
341
+ document.addEventListener("fullscreenchange", onChange);
342
+ return () => document.removeEventListener("fullscreenchange", onChange);
343
+ }, []);
344
+
345
+ const reset = () => {
346
+ const w = world.current;
347
+ if (w) w.flyTo(w.home.position, w.home.target);
348
+ };
349
+
350
+ const onKeyDown = (e: KeyboardEvent<HTMLDivElement>) => {
351
+ const w = world.current;
352
+ if (!w || e.target !== e.currentTarget) return;
353
+ const offset = w.camera.position.clone().sub(w.controls.target);
354
+ const spherical = new THREE.Spherical().setFromVector3(offset);
355
+ const turn = THREE.MathUtils.degToRad(e.shiftKey ? 45 : 15);
356
+ if (e.key === "ArrowLeft") spherical.theta -= turn;
357
+ else if (e.key === "ArrowRight") spherical.theta += turn;
358
+ else if (e.key === "ArrowUp") spherical.phi = Math.max(0.1, spherical.phi - turn);
359
+ else if (e.key === "ArrowDown") spherical.phi = Math.min(Math.PI - 0.1, spherical.phi + turn);
360
+ else if (e.key === "+" || e.key === "=") spherical.radius = Math.max(w.controls.minDistance, spherical.radius * 0.8);
361
+ else if (e.key === "-" || e.key === "_") spherical.radius = Math.min(w.controls.maxDistance, spherical.radius * 1.25);
362
+ else if (e.key === "0" || e.key === "Home") return (e.preventDefault(), reset());
363
+ else return;
364
+ e.preventDefault();
365
+ setTouched(true);
366
+ w.flyTo(new THREE.Vector3().setFromSpherical(spherical).add(w.controls.target), w.controls.target.clone(), 220);
367
+ };
368
+
369
+ const loading = state === "loading";
370
+ const canFull = typeof document !== "undefined" && document.fullscreenEnabled;
371
+
372
+ return (
373
+ <div
374
+ ref={box}
375
+ role="application"
376
+ aria-roledescription="3D model"
377
+ aria-label={alt}
378
+ aria-describedby={help}
379
+ aria-busy={loading || undefined}
380
+ tabIndex={0}
381
+ onKeyDown={onKeyDown}
382
+ style={{ aspectRatio: full ? undefined : ratioOf(ratio), background: background ?? undefined }}
383
+ className={cn("group/model @container relative bg-surface-sunken rounded-surface overflow-hidden outline-offset-2 select-none", full && "rounded-none", className)}
384
+ >
385
+ <span id={help} className="sr-only">
386
+ Drag, or use the arrow keys, to turn it. Scroll, pinch, or plus and minus, to zoom. Zero puts it back.
387
+ </span>
388
+ <div
389
+ ref={canvasHost}
390
+ className={cn("absolute inset-0 transition-opacity duration-(--duration-reveal) ease-out-notion cursor-grab active:cursor-grabbing", loading || state === "error" ? "opacity-0" : "opacity-100")}
391
+ />
392
+
393
+ {/* Loading: a ring that fills as it downloads, or a pulse when its size is unknown. */}
394
+ <div
395
+ aria-hidden={!loading}
396
+ className={cn("absolute inset-0 flex flex-col justify-center items-center gap-3 transition-opacity duration-(--duration-slow) pointer-events-none", loading ? "opacity-100" : "opacity-0")}
397
+ >
398
+ <span className="absolute inset-0 bg-tint-hover animate-pulse motion-reduce:animate-none" />
399
+ <TracingBox />
400
+ {/* How far, when the server says how large the file is. */}
401
+ <span className={cn("relative bg-hairline rounded-full w-24 h-0.5 overflow-hidden", progress === null && "invisible")}>
402
+ <span className="block bg-accent h-full transition-[width] duration-(--duration-slow) ease-out-notion" style={{ width: `${Math.round((progress ?? 0) * 100)}%` }} />
403
+ </span>
404
+ <span role="status" className="relative tabular-nums text-caption text-ink-secondary">
405
+ {loading ? (progress === null ? "Loading the model…" : `Loading the model, ${Math.round(progress * 100)}%`) : ""}
406
+ </span>
407
+ </div>
408
+
409
+ {state === "error" && (
410
+ <div role="alert" className="absolute inset-0 flex flex-col justify-center items-center gap-1.5 p-4 text-caption text-center text-ink-tertiary">
411
+ <Rotate3d className="size-6" strokeWidth={1.5} />
412
+ <span className="hidden @min-[12rem]:inline">{error}</span>
413
+ </div>
414
+ )}
415
+
416
+ {children !== undefined && <div className="top-3 left-3 absolute">{children}</div>}
417
+
418
+ {state === "ready" && (
419
+ <span
420
+ aria-hidden
421
+ className={cn(
422
+ "bottom-3 left-3 absolute flex items-center gap-1 bg-on-media-strong px-1.5 py-0.5 rounded-control text-caption text-on-media-ink transition-opacity duration-(--duration-slow) pointer-events-none",
423
+ "@max-[20rem]:hidden",
424
+ touched && "opacity-0",
425
+ )}
426
+ >
427
+ <Rotate3d className="size-3.5" /> Drag to turn
428
+ </span>
429
+ )}
430
+
431
+ {controls && state === "ready" && (
432
+ <div className="right-2 bottom-2 absolute flex items-center gap-0.5 bg-on-media-strong p-0.5 rounded-control text-on-media-ink [&_button]:text-on-media-ink [&_button:hover]:bg-on-media">
433
+ {clips.length > 0 && animation !== null && (
434
+ <Tooltip content={playing ? "Pause" : "Play"}>
435
+ <Button variant="ghost" size="icon-sm" aria-label={playing ? "Pause the animation" : "Play the animation"} onClick={() => setPlaying((p) => !p)}>
436
+ {playing ? <Pause /> : <Play />}
437
+ </Button>
438
+ </Tooltip>
439
+ )}
440
+ {!reduced && (
441
+ <Tooltip content={rotating ? "Stop turning" : "Turn on its own"}>
442
+ <Button variant="ghost" size="icon-sm" aria-label="Turn on its own" aria-pressed={rotating} onClick={() => setRotating((r) => !r)} className="aria-pressed:bg-on-media">
443
+ <Rotate3d />
444
+ </Button>
445
+ </Tooltip>
446
+ )}
447
+ <Tooltip content="Reset the view" shortcut="0">
448
+ <Button variant="ghost" size="icon-sm" aria-label="Reset the view" onClick={reset}>
449
+ <RotateCcw />
450
+ </Button>
451
+ </Tooltip>
452
+ {canFull && (
453
+ <Tooltip content={full ? "Exit full screen" : "Full screen"}>
454
+ <Button
455
+ variant="ghost"
456
+ size="icon-sm"
457
+ aria-label={full ? "Exit full screen" : "Full screen"}
458
+ onClick={() => (full ? document.exitFullscreen() : box.current?.requestFullscreen())}
459
+ >
460
+ {full ? <Minimize /> : <Maximize />}
461
+ </Button>
462
+ </Tooltip>
463
+ )}
464
+ </div>
465
+ )}
466
+ </div>
467
+ );
468
+ }
469
+
470
+ /* A wireframe box drawn edge by edge, like a circuit being traced: the three
471
+ edges at its back first (faint), then the back, the edges running forward and
472
+ the front face, each
473
+ a step after the last, then all fade and it draws again. Under reduced
474
+ motion it stands drawn. */
475
+ // The front face, and the back face up and to the right of it.
476
+ const F = { tl: [12, 24], tr: [40, 24], br: [40, 52], bl: [12, 52] } as const;
477
+ const B = { tl: [24, 12], tr: [52, 12], br: [52, 40], bl: [24, 40] } as const;
478
+ const line = (a: readonly number[], b: readonly number[]) => `M${a[0]} ${a[1]} L${b[0]} ${b[1]}`;
479
+ const EDGES: { d: string; back?: boolean }[] = [
480
+ // Behind: the hidden corner's three edges, faint.
481
+ { d: line(B.bl, B.tl), back: true },
482
+ { d: line(B.bl, B.br), back: true },
483
+ { d: line(B.bl, F.bl), back: true },
484
+ // The back's top and side, the edges running forward, then the front face.
485
+ { d: line(B.tl, B.tr) },
486
+ { d: line(B.tr, B.br) },
487
+ { d: line(B.tl, F.tl) },
488
+ { d: line(B.tr, F.tr) },
489
+ { d: line(B.br, F.br) },
490
+ { d: line(F.tl, F.tr) },
491
+ { d: line(F.tr, F.br) },
492
+ { d: line(F.br, F.bl) },
493
+ { d: line(F.bl, F.tl) },
494
+ ];
495
+
496
+ function TracingBox() {
497
+ return (
498
+ <svg viewBox="0 0 64 64" className="relative size-20" aria-hidden fill="none" strokeLinecap="round" strokeLinejoin="round">
499
+ {EDGES.map((edge, i) => (
500
+ <path
501
+ key={i}
502
+ d={edge.d}
503
+ pathLength={1}
504
+ strokeDasharray="1 1"
505
+ strokeWidth={edge.back ? 1.25 : 1.75}
506
+ className={cn(edge.back ? "stroke-hairline-strong" : "stroke-accent", "animate-trace motion-reduce:animate-none")}
507
+ style={{ animationDelay: `${i * 90}ms` }}
508
+ />
509
+ ))}
510
+ {/* The corner nearest, lit as the drawing reaches it. */}
511
+ <circle cx={F.tr[0]} cy={F.tr[1]} r={1.75} className="fill-accent animate-trace motion-reduce:animate-none" style={{ animationDelay: "500ms" }} />
512
+ </svg>
513
+ );
514
+ }
@@ -46,7 +46,7 @@ export function AccentPicker() {
46
46
  <button
47
47
  type="button"
48
48
  aria-label={`Colour theme: ${label(accent)}`}
49
- className="flex h-[30px] w-full items-center gap-2 rounded-control px-2 text-sm font-medium text-ink-secondary transition-colors duration-100 hover:bg-tint-hover data-[state=open]:bg-tint-hover"
49
+ className="flex h-control-sm w-full items-center gap-2 rounded-control px-2 text-sm font-medium text-ink-secondary transition-colors duration-(--duration-fast) hover:bg-tint-hover data-[state=open]:bg-tint-hover"
50
50
  >
51
51
  <span className="flex size-5 items-center justify-center">
52
52
  <Swatch accent={accent} />
@@ -56,7 +56,7 @@ export function AccentPicker() {
56
56
  <ChevronsUpDown className="size-3.5 text-ink-tertiary" />
57
57
  </button>
58
58
  </DropdownMenuTrigger>
59
- <DropdownMenuContent side="top" align="start" className="w-[var(--radix-dropdown-menu-trigger-width)]">
59
+ <DropdownMenuContent side="top" align="start" className="w-(--radix-dropdown-menu-trigger-width)">
60
60
  <DropdownMenuLabel>Colour theme</DropdownMenuLabel>
61
61
  <DropdownMenuRadioGroup value={accent} onValueChange={(next) => choose(next as Accent)}>
62
62
  {ACCENTS.map((a) => (
@@ -0,0 +1,136 @@
1
+ "use client";
2
+
3
+ import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog";
4
+ import { createContext, useCallback, useContext, useRef, useState, type ComponentProps, type ReactNode } from "react";
5
+ import { cn } from "../../lib/utils.ts";
6
+ import { Button } from "./button.tsx";
7
+ import { dialogPanelClasses, overlayClasses } from "./dialog.tsx";
8
+
9
+ /* A question that must be answered before anything else: "Delete these 3 pages?"
10
+ Unlike a Dialog it has no close button and a press outside does not dismiss it;
11
+ Escape answers no. Focus starts on Cancel, the safe answer. It looks like a
12
+ Dialog, a bottom sheet on a phone.
13
+
14
+ Most of the time, `useConfirm()` is all an app needs:
15
+ const confirm = useConfirm();
16
+ if (await confirm({ title: "Delete 3 pages?", confirmLabel: "Delete", danger: true })) …
17
+ with a ConfirmProvider somewhere above. */
18
+
19
+ export const AlertDialog = AlertDialogPrimitive.Root;
20
+ export const AlertDialogTrigger = AlertDialogPrimitive.Trigger;
21
+
22
+ export function AlertDialogContent({ className, children, ...props }: ComponentProps<typeof AlertDialogPrimitive.Content>) {
23
+ return (
24
+ <AlertDialogPrimitive.Portal>
25
+ <AlertDialogPrimitive.Overlay className={overlayClasses} />
26
+ <AlertDialogPrimitive.Content
27
+ className={cn(dialogPanelClasses, "max-w-md", className)}
28
+ {...props}
29
+ >
30
+ {children}
31
+ </AlertDialogPrimitive.Content>
32
+ </AlertDialogPrimitive.Portal>
33
+ );
34
+ }
35
+
36
+ export function AlertDialogHeader({ className, ...props }: ComponentProps<"div">) {
37
+ return <div className={cn("px-5 pt-5", className)} {...props} />;
38
+ }
39
+
40
+ export function AlertDialogTitle({ className, ...props }: ComponentProps<typeof AlertDialogPrimitive.Title>) {
41
+ return <AlertDialogPrimitive.Title className={cn("font-semibold text-h3 text-ink", className)} {...props} />;
42
+ }
43
+
44
+ export function AlertDialogDescription({ className, ...props }: ComponentProps<typeof AlertDialogPrimitive.Description>) {
45
+ return <AlertDialogPrimitive.Description className={cn("mt-1.5 text-ink-secondary text-sm", className)} {...props} />;
46
+ }
47
+
48
+ export function AlertDialogFooter({ className, ...props }: ComponentProps<"div">) {
49
+ return <div className={cn("flex flex-wrap justify-end items-center gap-2 px-5 pt-5 pb-5", className)} {...props} />;
50
+ }
51
+
52
+ /** The safe answer. Takes focus when the question opens. */
53
+ export function AlertDialogCancel({ children = "Cancel", ...props }: ComponentProps<typeof AlertDialogPrimitive.Cancel>) {
54
+ return (
55
+ <AlertDialogPrimitive.Cancel asChild {...props}>
56
+ <Button variant="ghost">{children}</Button>
57
+ </AlertDialogPrimitive.Cancel>
58
+ );
59
+ }
60
+
61
+ /** The answer that goes ahead. `danger` when it cannot be undone. */
62
+ export function AlertDialogAction({ children = "Confirm", danger = false, ...props }: ComponentProps<typeof AlertDialogPrimitive.Action> & { danger?: boolean }) {
63
+ return (
64
+ <AlertDialogPrimitive.Action asChild {...props}>
65
+ <Button variant={danger ? "danger" : "primary"}>{children}</Button>
66
+ </AlertDialogPrimitive.Action>
67
+ );
68
+ }
69
+
70
+ /* ── confirm() ─────────────────────────────────────────────────────────────── */
71
+
72
+ export type ConfirmOptions = {
73
+ title: ReactNode;
74
+ description?: ReactNode;
75
+ confirmLabel?: string;
76
+ cancelLabel?: string;
77
+ /** It cannot be undone: the confirm button is the danger fill. */
78
+ danger?: boolean;
79
+ };
80
+
81
+ const ConfirmContext = createContext<((options: ConfirmOptions) => Promise<boolean>) | null>(null);
82
+
83
+ /** Asks a question and resolves true (confirmed) or false (cancelled, Escape). Needs a ConfirmProvider above. */
84
+ export function useConfirm(): (options: ConfirmOptions) => Promise<boolean> {
85
+ const confirm = useContext(ConfirmContext);
86
+ if (confirm === null) throw new Error("useConfirm must be used inside ConfirmProvider");
87
+ return confirm;
88
+ }
89
+
90
+ export function ConfirmProvider({ children }: { children: ReactNode }) {
91
+ const [asking, setAsking] = useState<ConfirmOptions | null>(null);
92
+ const [open, setOpen] = useState(false);
93
+ const answer = useRef<(yes: boolean) => void>(() => {});
94
+
95
+ const confirm = useCallback(
96
+ (options: ConfirmOptions) =>
97
+ new Promise<boolean>((resolve) => {
98
+ answer.current(false); // a question still open is answered no
99
+ answer.current = resolve;
100
+ setAsking(options);
101
+ setOpen(true);
102
+ }),
103
+ [],
104
+ );
105
+ const settle = (yes: boolean) => {
106
+ answer.current(yes);
107
+ answer.current = () => {};
108
+ setOpen(false);
109
+ };
110
+
111
+ return (
112
+ <ConfirmContext.Provider value={confirm}>
113
+ {children}
114
+ <AlertDialog open={open} onOpenChange={(o) => !o && settle(false)}>
115
+ {asking && (
116
+ // Focus goes to Cancel on every screen. (A dialog with a text field keeps
117
+ // it off on a touch screen so the keyboard stays down, but here there are
118
+ // only buttons, and leaving focus behind on the page would leave a screen
119
+ // reader outside the question, and Enter on the page asking it again.)
120
+ <AlertDialogContent>
121
+ <AlertDialogHeader>
122
+ <AlertDialogTitle>{asking.title}</AlertDialogTitle>
123
+ {asking.description && <AlertDialogDescription>{asking.description}</AlertDialogDescription>}
124
+ </AlertDialogHeader>
125
+ <AlertDialogFooter>
126
+ <AlertDialogCancel onClick={() => settle(false)}>{asking.cancelLabel ?? "Cancel"}</AlertDialogCancel>
127
+ <AlertDialogAction danger={asking.danger} onClick={() => settle(true)}>
128
+ {asking.confirmLabel ?? "Confirm"}
129
+ </AlertDialogAction>
130
+ </AlertDialogFooter>
131
+ </AlertDialogContent>
132
+ )}
133
+ </AlertDialog>
134
+ </ConfirmContext.Provider>
135
+ );
136
+ }