@zonsh/ui 0.5.0 → 0.6.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 (559) hide show
  1. package/CHANGELOG.md +639 -0
  2. package/README.md +49 -21
  3. package/dist/brand.d.ts +3 -0
  4. package/dist/brand.js +7 -0
  5. package/dist/components/_breadcrumb-more.d.ts +6 -0
  6. package/dist/components/_breadcrumb-more.js +5 -0
  7. package/dist/components/_drawing-svg.d.ts +11 -0
  8. package/dist/components/_drawing-svg.js +30 -0
  9. package/dist/components/_media.d.ts +159 -0
  10. package/dist/components/_media.js +266 -0
  11. package/dist/components/_overlay.d.ts +8 -5
  12. package/dist/components/_overlay.js +11 -6
  13. package/dist/components/_scheduler-calendar.d.ts +71 -0
  14. package/dist/components/_scheduler-calendar.js +940 -0
  15. package/dist/components/_scheduler-editor.d.ts +29 -0
  16. package/dist/components/_scheduler-editor.js +111 -0
  17. package/dist/components/_scheduler-menu.d.ts +16 -0
  18. package/dist/components/_scheduler-menu.js +18 -0
  19. package/dist/components/_scheduler-parts.d.ts +164 -0
  20. package/dist/components/_scheduler-parts.js +327 -0
  21. package/dist/components/_suggest-list.d.ts +142 -0
  22. package/dist/components/_suggest-list.js +159 -0
  23. package/dist/components/_toolbar-more.d.ts +24 -0
  24. package/dist/components/_toolbar-more.js +25 -0
  25. package/dist/components/accordion.d.ts +1 -1
  26. package/dist/components/accordion.js +6 -6
  27. package/dist/components/action-sheet.d.ts +88 -0
  28. package/dist/components/action-sheet.js +124 -0
  29. package/dist/components/alert-dialog.js +3 -1
  30. package/dist/components/alert.d.ts +11 -18
  31. package/dist/components/alert.js +9 -6
  32. package/dist/components/app-bar.d.ts +93 -0
  33. package/dist/components/app-bar.js +175 -0
  34. package/dist/components/audio-player.d.ts +134 -0
  35. package/dist/components/audio-player.js +618 -0
  36. package/dist/components/avatar.d.ts +6 -6
  37. package/dist/components/avatar.js +13 -11
  38. package/dist/components/badge.d.ts +12 -12
  39. package/dist/components/badge.js +7 -5
  40. package/dist/components/bottom-nav.d.ts +53 -11
  41. package/dist/components/bottom-nav.js +388 -23
  42. package/dist/components/breadcrumb.d.ts +11 -2
  43. package/dist/components/breadcrumb.js +60 -6
  44. package/dist/components/button-group.js +5 -1
  45. package/dist/components/button.d.ts +23 -6
  46. package/dist/components/button.js +63 -7
  47. package/dist/components/calendar.js +8 -6
  48. package/dist/components/card.d.ts +10 -8
  49. package/dist/components/card.js +15 -14
  50. package/dist/components/carousel.d.ts +2 -2
  51. package/dist/components/carousel.js +21 -8
  52. package/dist/components/chart.d.ts +27 -1
  53. package/dist/components/chart.js +15 -5
  54. package/dist/components/checkbox.js +2 -2
  55. package/dist/components/code-block.d.ts +9 -2
  56. package/dist/components/code-block.js +26 -7
  57. package/dist/components/collapsible.js +3 -3
  58. package/dist/components/color-picker.d.ts +2 -2
  59. package/dist/components/color-picker.js +5 -5
  60. package/dist/components/combobox.d.ts +26 -7
  61. package/dist/components/combobox.js +32 -13
  62. package/dist/components/command.d.ts +29 -5
  63. package/dist/components/command.js +35 -10
  64. package/dist/components/context-menu.d.ts +5 -2
  65. package/dist/components/context-menu.js +24 -3
  66. package/dist/components/conversation.d.ts +1 -1
  67. package/dist/components/conversation.js +67 -13
  68. package/dist/components/copy-button.d.ts +1 -1
  69. package/dist/components/copy-button.js +1 -1
  70. package/dist/components/data-table.d.ts +6 -6
  71. package/dist/components/data-table.js +41 -15
  72. package/dist/components/date-picker.d.ts +31 -9
  73. package/dist/components/date-picker.js +100 -18
  74. package/dist/components/dialog.d.ts +17 -10
  75. package/dist/components/dialog.js +20 -13
  76. package/dist/components/drawer.d.ts +26 -8
  77. package/dist/components/drawer.js +75 -16
  78. package/dist/components/drawing.d.ts +25 -0
  79. package/dist/components/drawing.js +32 -0
  80. package/dist/components/empty.js +2 -2
  81. package/dist/components/feature-list.d.ts +65 -13
  82. package/dist/components/feature-list.js +116 -15
  83. package/dist/components/field.js +2 -2
  84. package/dist/components/file-drop.d.ts +9 -7
  85. package/dist/components/file-drop.js +8 -43
  86. package/dist/components/filter-bar.d.ts +10 -9
  87. package/dist/components/filter-bar.js +42 -25
  88. package/dist/components/graph.d.ts +19 -3
  89. package/dist/components/graph.js +170 -25
  90. package/dist/components/illustration.js +3 -28
  91. package/dist/components/input-group.d.ts +5 -10
  92. package/dist/components/input-group.js +16 -16
  93. package/dist/components/input.d.ts +2 -2
  94. package/dist/components/input.js +3 -3
  95. package/dist/components/item.d.ts +9 -6
  96. package/dist/components/item.js +13 -8
  97. package/dist/components/kbd.d.ts +1 -1
  98. package/dist/components/kbd.js +1 -1
  99. package/dist/components/lightbox.d.ts +76 -9
  100. package/dist/components/lightbox.js +333 -45
  101. package/dist/components/locale.d.ts +6 -6
  102. package/dist/components/logo.d.ts +21 -1
  103. package/dist/components/logo.js +32 -2
  104. package/dist/components/markdown-editor.d.ts +275 -0
  105. package/dist/components/markdown-editor.js +831 -0
  106. package/dist/components/mentions.d.ts +153 -0
  107. package/dist/components/mentions.js +507 -0
  108. package/dist/components/menu.d.ts +2 -1
  109. package/dist/components/menu.js +5 -4
  110. package/dist/components/menubar.d.ts +23 -5
  111. package/dist/components/menubar.js +97 -22
  112. package/dist/components/message.d.ts +62 -11
  113. package/dist/components/message.js +49 -13
  114. package/dist/components/meter.js +1 -1
  115. package/dist/components/money-input.d.ts +1 -1
  116. package/dist/components/money-input.js +1 -1
  117. package/dist/components/native-select.d.ts +2 -2
  118. package/dist/components/native-select.js +4 -4
  119. package/dist/components/navigation-menu.d.ts +3 -1
  120. package/dist/components/navigation-menu.js +23 -12
  121. package/dist/components/number-field.d.ts +2 -9
  122. package/dist/components/number-field.js +86 -36
  123. package/dist/components/number-roll.d.ts +26 -0
  124. package/dist/components/number-roll.js +81 -0
  125. package/dist/components/otp-field.d.ts +1 -1
  126. package/dist/components/otp-field.js +24 -3
  127. package/dist/components/pagination.d.ts +11 -3
  128. package/dist/components/pagination.js +59 -13
  129. package/dist/components/pdf-viewer.d.ts +1 -1
  130. package/dist/components/pdf-viewer.js +8 -8
  131. package/dist/components/phone-input.d.ts +1 -1
  132. package/dist/components/phone-input.js +2 -2
  133. package/dist/components/popover.js +5 -3
  134. package/dist/components/preview-card.d.ts +37 -2
  135. package/dist/components/preview-card.js +226 -2
  136. package/dist/components/progress.js +1 -1
  137. package/dist/components/prompt-input.d.ts +1 -1
  138. package/dist/components/prompt-input.js +24 -14
  139. package/dist/components/pull-to-refresh.d.ts +50 -0
  140. package/dist/components/pull-to-refresh.js +189 -0
  141. package/dist/components/quote.d.ts +6 -1
  142. package/dist/components/quote.js +3 -2
  143. package/dist/components/radio-group.js +1 -1
  144. package/dist/components/rating.d.ts +4 -1
  145. package/dist/components/rating.js +131 -10
  146. package/dist/components/reasoning.d.ts +1 -1
  147. package/dist/components/reasoning.js +7 -3
  148. package/dist/components/resizable.d.ts +1 -1
  149. package/dist/components/resizable.js +2 -2
  150. package/dist/components/response.d.ts +1 -1
  151. package/dist/components/response.js +18 -6
  152. package/dist/components/scheduler.d.ts +352 -0
  153. package/dist/components/scheduler.js +1717 -0
  154. package/dist/components/scroll-area.js +1 -1
  155. package/dist/components/select.d.ts +17 -4
  156. package/dist/components/select.js +140 -9
  157. package/dist/components/separator.d.ts +1 -1
  158. package/dist/components/separator.js +3 -3
  159. package/dist/components/sidebar.d.ts +44 -3
  160. package/dist/components/sidebar.js +57 -17
  161. package/dist/components/site-header.d.ts +18 -13
  162. package/dist/components/site-header.js +23 -11
  163. package/dist/components/skeleton.d.ts +17 -7
  164. package/dist/components/skeleton.js +22 -7
  165. package/dist/components/slider.js +2 -2
  166. package/dist/components/sortable.d.ts +55 -4
  167. package/dist/components/sortable.js +172 -103
  168. package/dist/components/sources.d.ts +1 -1
  169. package/dist/components/sources.js +2 -2
  170. package/dist/components/spinner.d.ts +4 -4
  171. package/dist/components/spinner.js +4 -4
  172. package/dist/components/stat.d.ts +21 -4
  173. package/dist/components/stat.js +17 -8
  174. package/dist/components/stepper.d.ts +1 -1
  175. package/dist/components/stepper.js +8 -7
  176. package/dist/components/suggestions.d.ts +11 -3
  177. package/dist/components/suggestions.js +10 -4
  178. package/dist/components/swipe-actions.d.ts +66 -0
  179. package/dist/components/swipe-actions.js +292 -0
  180. package/dist/components/switch.js +1 -1
  181. package/dist/components/table.d.ts +12 -6
  182. package/dist/components/table.js +78 -30
  183. package/dist/components/tabs.js +7 -4
  184. package/dist/components/tag.d.ts +19 -20
  185. package/dist/components/tag.js +9 -5
  186. package/dist/components/tags-input.d.ts +2 -7
  187. package/dist/components/tags-input.js +11 -8
  188. package/dist/components/textarea.d.ts +3 -2
  189. package/dist/components/textarea.js +4 -3
  190. package/dist/components/theme.d.ts +49 -6
  191. package/dist/components/theme.js +147 -9
  192. package/dist/components/time-field.d.ts +4 -9
  193. package/dist/components/time-field.js +6 -6
  194. package/dist/components/timeline.d.ts +19 -3
  195. package/dist/components/timeline.js +21 -9
  196. package/dist/components/tippy.d.ts +17 -1
  197. package/dist/components/tippy.js +95 -15
  198. package/dist/components/toast.d.ts +2 -7
  199. package/dist/components/toast.js +12 -8
  200. package/dist/components/toggle-group.d.ts +7 -1
  201. package/dist/components/toggle-group.js +16 -5
  202. package/dist/components/toggle.d.ts +2 -2
  203. package/dist/components/toggle.js +3 -2
  204. package/dist/components/tool-call.d.ts +1 -1
  205. package/dist/components/tool-call.js +4 -4
  206. package/dist/components/toolbar.d.ts +57 -4
  207. package/dist/components/toolbar.js +216 -16
  208. package/dist/components/tooltip.d.ts +1 -1
  209. package/dist/components/tooltip.js +4 -2
  210. package/dist/components/tour.d.ts +1 -1
  211. package/dist/components/tour.js +36 -15
  212. package/dist/components/tree.js +5 -5
  213. package/dist/components/typography.d.ts +31 -8
  214. package/dist/components/typography.js +21 -10
  215. package/dist/components/video-player.d.ts +7 -2
  216. package/dist/components/video-player.js +121 -220
  217. package/dist/index.d.ts +99 -92
  218. package/dist/index.js +99 -92
  219. package/dist/lib/calendar.d.ts +153 -0
  220. package/dist/lib/calendar.js +312 -0
  221. package/dist/lib/cn.d.ts +3 -1
  222. package/dist/lib/cn.js +5 -0
  223. package/dist/lib/code-highlight.d.ts +14 -0
  224. package/dist/lib/code-highlight.js +81 -18
  225. package/dist/lib/drag.d.ts +39 -0
  226. package/dist/lib/drag.js +96 -0
  227. package/dist/lib/editorial-assets.js +16 -8
  228. package/dist/lib/figure/figures/automation.js +25 -6
  229. package/dist/lib/figure/figures/bar-chart.js +6 -1
  230. package/dist/lib/figure/figures/brackets-classic.js +4 -1
  231. package/dist/lib/figure/figures/city.js +12 -2
  232. package/dist/lib/figure/figures/conveyor.js +17 -4
  233. package/dist/lib/figure/figures/database.js +5 -2
  234. package/dist/lib/figure/figures/documents.js +11 -3
  235. package/dist/lib/figure/figures/inbox.js +5 -2
  236. package/dist/lib/figure/figures/laptop.js +3 -1
  237. package/dist/lib/figure/figures/pipeline.js +45 -10
  238. package/dist/lib/figure/figures/platform.js +62 -7
  239. package/dist/lib/figure/figures/server.js +21 -5
  240. package/dist/lib/figure/figures/spreadsheet.js +29 -5
  241. package/dist/lib/figure/kernel.d.ts +4 -2
  242. package/dist/lib/figure/kernel.js +10 -5
  243. package/dist/lib/figure/parts.js +6 -2
  244. package/dist/lib/files.d.ts +31 -0
  245. package/dist/lib/files.js +60 -0
  246. package/dist/lib/gesture.d.ts +70 -0
  247. package/dist/lib/gesture.js +141 -0
  248. package/dist/lib/glide.d.ts +5 -0
  249. package/dist/lib/glide.js +9 -1
  250. package/dist/lib/icons.d.ts +1 -0
  251. package/dist/lib/icons.js +6 -0
  252. package/dist/lib/illustration-library.js +1 -6
  253. package/dist/lib/markdown-edit.d.ts +112 -0
  254. package/dist/lib/markdown-edit.js +557 -0
  255. package/dist/lib/markdown-rich-editor.d.ts +188 -0
  256. package/dist/lib/markdown-rich-editor.js +1153 -0
  257. package/dist/lib/markdown-rich.d.ts +63 -0
  258. package/dist/lib/markdown-rich.js +534 -0
  259. package/dist/lib/mentions.d.ts +100 -0
  260. package/dist/lib/mentions.js +246 -0
  261. package/dist/lib/motion.d.ts +18 -0
  262. package/dist/lib/motion.js +43 -5
  263. package/dist/lib/number-roll.d.ts +89 -0
  264. package/dist/lib/number-roll.js +391 -0
  265. package/dist/lib/platform.d.ts +6 -0
  266. package/dist/lib/platform.js +14 -0
  267. package/dist/lib/portal-container.d.ts +9 -0
  268. package/dist/lib/portal-container.js +10 -0
  269. package/dist/lib/press.d.ts +5 -0
  270. package/dist/lib/press.js +186 -0
  271. package/dist/lib/scheduler.d.ts +128 -0
  272. package/dist/lib/scheduler.js +272 -0
  273. package/dist/lib/scroll-edges.d.ts +9 -0
  274. package/dist/lib/scroll-edges.js +50 -0
  275. package/dist/lib/table-fit.d.ts +1 -1
  276. package/dist/lib/table-fit.js +65 -8
  277. package/dist/lib/theme-preset.d.ts +267 -0
  278. package/dist/lib/theme-preset.js +1046 -0
  279. package/dist/lib/theme-script.d.ts +23 -3
  280. package/dist/lib/theme-script.js +17 -5
  281. package/dist/lib/tippy/sprite.d.ts +36 -4
  282. package/dist/lib/tippy/sprite.js +188 -15
  283. package/dist/lib/tone.d.ts +4 -0
  284. package/dist/lib/tone.js +1 -0
  285. package/dist/messages/de.d.ts +3 -3
  286. package/dist/messages/de.js +274 -3
  287. package/dist/skills/zon-ui/SKILL.md +279 -0
  288. package/dist/skills/zon-ui/references/authoring.md +265 -0
  289. package/dist/skills/zon-ui/references/brand.md +416 -0
  290. package/dist/skills/zon-ui/references/components/accordion.md +199 -0
  291. package/dist/skills/zon-ui/references/components/action-sheet.md +268 -0
  292. package/dist/skills/zon-ui/references/components/alert-dialog.md +276 -0
  293. package/dist/skills/zon-ui/references/components/alert.md +167 -0
  294. package/dist/skills/zon-ui/references/components/app-bar.md +307 -0
  295. package/dist/skills/zon-ui/references/components/ascii-field.md +121 -0
  296. package/dist/skills/zon-ui/references/components/aspect-ratio.md +112 -0
  297. package/dist/skills/zon-ui/references/components/audio-player.md +231 -0
  298. package/dist/skills/zon-ui/references/components/avatar.md +98 -0
  299. package/dist/skills/zon-ui/references/components/badge.md +227 -0
  300. package/dist/skills/zon-ui/references/components/bottom-nav.md +709 -0
  301. package/dist/skills/zon-ui/references/components/breadcrumb.md +143 -0
  302. package/dist/skills/zon-ui/references/components/button-group.md +216 -0
  303. package/dist/skills/zon-ui/references/components/button.md +309 -0
  304. package/dist/skills/zon-ui/references/components/calendar.md +296 -0
  305. package/dist/skills/zon-ui/references/components/card.md +158 -0
  306. package/dist/skills/zon-ui/references/components/carousel.md +297 -0
  307. package/dist/skills/zon-ui/references/components/chart.md +739 -0
  308. package/dist/skills/zon-ui/references/components/chat.md +417 -0
  309. package/dist/skills/zon-ui/references/components/checkbox.md +219 -0
  310. package/dist/skills/zon-ui/references/components/code-block.md +143 -0
  311. package/dist/skills/zon-ui/references/components/code-highlight.md +118 -0
  312. package/dist/skills/zon-ui/references/components/collapsible.md +146 -0
  313. package/dist/skills/zon-ui/references/components/color-picker.md +200 -0
  314. package/dist/skills/zon-ui/references/components/combobox.md +455 -0
  315. package/dist/skills/zon-ui/references/components/command.md +326 -0
  316. package/dist/skills/zon-ui/references/components/contact-form.md +562 -0
  317. package/dist/skills/zon-ui/references/components/context-menu.md +159 -0
  318. package/dist/skills/zon-ui/references/components/conversation.md +146 -0
  319. package/dist/skills/zon-ui/references/components/copy-button.md +162 -0
  320. package/dist/skills/zon-ui/references/components/crm.md +1022 -0
  321. package/dist/skills/zon-ui/references/components/dashboard.md +612 -0
  322. package/dist/skills/zon-ui/references/components/data-table.md +776 -0
  323. package/dist/skills/zon-ui/references/components/date-picker.md +444 -0
  324. package/dist/skills/zon-ui/references/components/dialog.md +335 -0
  325. package/dist/skills/zon-ui/references/components/direction.md +165 -0
  326. package/dist/skills/zon-ui/references/components/drawer.md +276 -0
  327. package/dist/skills/zon-ui/references/components/drawing.md +94 -0
  328. package/dist/skills/zon-ui/references/components/empty.md +225 -0
  329. package/dist/skills/zon-ui/references/components/feature-list.md +412 -0
  330. package/dist/skills/zon-ui/references/components/field.md +209 -0
  331. package/dist/skills/zon-ui/references/components/file-drop.md +234 -0
  332. package/dist/skills/zon-ui/references/components/filter-bar.md +485 -0
  333. package/dist/skills/zon-ui/references/components/form.md +970 -0
  334. package/dist/skills/zon-ui/references/components/graph.md +339 -0
  335. package/dist/skills/zon-ui/references/components/illustration.md +497 -0
  336. package/dist/skills/zon-ui/references/components/inbox.md +263 -0
  337. package/dist/skills/zon-ui/references/components/input-group.md +339 -0
  338. package/dist/skills/zon-ui/references/components/input.md +189 -0
  339. package/dist/skills/zon-ui/references/components/item.md +277 -0
  340. package/dist/skills/zon-ui/references/components/kanban.md +626 -0
  341. package/dist/skills/zon-ui/references/components/kbd.md +116 -0
  342. package/dist/skills/zon-ui/references/components/label.md +104 -0
  343. package/dist/skills/zon-ui/references/components/layout.md +291 -0
  344. package/dist/skills/zon-ui/references/components/lightbox.md +235 -0
  345. package/dist/skills/zon-ui/references/components/locale.md +279 -0
  346. package/dist/skills/zon-ui/references/components/logo.md +257 -0
  347. package/dist/skills/zon-ui/references/components/markdown-editor.md +558 -0
  348. package/dist/skills/zon-ui/references/components/mentions.md +512 -0
  349. package/dist/skills/zon-ui/references/components/menu.md +218 -0
  350. package/dist/skills/zon-ui/references/components/menubar.md +292 -0
  351. package/dist/skills/zon-ui/references/components/message.md +243 -0
  352. package/dist/skills/zon-ui/references/components/meter.md +105 -0
  353. package/dist/skills/zon-ui/references/components/money-input.md +333 -0
  354. package/dist/skills/zon-ui/references/components/native-select.md +197 -0
  355. package/dist/skills/zon-ui/references/components/navigation-menu.md +253 -0
  356. package/dist/skills/zon-ui/references/components/number-field.md +210 -0
  357. package/dist/skills/zon-ui/references/components/number-roll.md +175 -0
  358. package/dist/skills/zon-ui/references/components/onboarding.md +896 -0
  359. package/dist/skills/zon-ui/references/components/otp-field.md +166 -0
  360. package/dist/skills/zon-ui/references/components/pagination.md +109 -0
  361. package/dist/skills/zon-ui/references/components/pdf-viewer.md +177 -0
  362. package/dist/skills/zon-ui/references/components/phone-input.md +252 -0
  363. package/dist/skills/zon-ui/references/components/popover.md +176 -0
  364. package/dist/skills/zon-ui/references/components/preview-card.md +193 -0
  365. package/dist/skills/zon-ui/references/components/pricing.md +724 -0
  366. package/dist/skills/zon-ui/references/components/progress.md +92 -0
  367. package/dist/skills/zon-ui/references/components/prompt-input.md +307 -0
  368. package/dist/skills/zon-ui/references/components/pull-to-refresh.md +188 -0
  369. package/dist/skills/zon-ui/references/components/quote.md +115 -0
  370. package/dist/skills/zon-ui/references/components/radio-group.md +215 -0
  371. package/dist/skills/zon-ui/references/components/rating.md +260 -0
  372. package/dist/skills/zon-ui/references/components/reasoning.md +102 -0
  373. package/dist/skills/zon-ui/references/components/resizable.md +213 -0
  374. package/dist/skills/zon-ui/references/components/response.md +170 -0
  375. package/dist/skills/zon-ui/references/components/scheduler.md +732 -0
  376. package/dist/skills/zon-ui/references/components/scroll-area.md +122 -0
  377. package/dist/skills/zon-ui/references/components/select.md +351 -0
  378. package/dist/skills/zon-ui/references/components/separator.md +103 -0
  379. package/dist/skills/zon-ui/references/components/settings.md +793 -0
  380. package/dist/skills/zon-ui/references/components/shop.md +1715 -0
  381. package/dist/skills/zon-ui/references/components/sidebar.md +813 -0
  382. package/dist/skills/zon-ui/references/components/sign-in.md +1639 -0
  383. package/dist/skills/zon-ui/references/components/site-header.md +303 -0
  384. package/dist/skills/zon-ui/references/components/skeleton.md +256 -0
  385. package/dist/skills/zon-ui/references/components/slider.md +172 -0
  386. package/dist/skills/zon-ui/references/components/sortable.md +405 -0
  387. package/dist/skills/zon-ui/references/components/sources.md +106 -0
  388. package/dist/skills/zon-ui/references/components/spinner.md +222 -0
  389. package/dist/skills/zon-ui/references/components/stat.md +267 -0
  390. package/dist/skills/zon-ui/references/components/stepper.md +285 -0
  391. package/dist/skills/zon-ui/references/components/suggestions.md +146 -0
  392. package/dist/skills/zon-ui/references/components/swipe-actions.md +344 -0
  393. package/dist/skills/zon-ui/references/components/switch.md +160 -0
  394. package/dist/skills/zon-ui/references/components/table.md +999 -0
  395. package/dist/skills/zon-ui/references/components/tabs.md +258 -0
  396. package/dist/skills/zon-ui/references/components/tag.md +115 -0
  397. package/dist/skills/zon-ui/references/components/tags-input.md +216 -0
  398. package/dist/skills/zon-ui/references/components/textarea.md +95 -0
  399. package/dist/skills/zon-ui/references/components/theme-editor.md +3940 -0
  400. package/dist/skills/zon-ui/references/components/theme.md +362 -0
  401. package/dist/skills/zon-ui/references/components/time-field.md +222 -0
  402. package/dist/skills/zon-ui/references/components/timeline.md +285 -0
  403. package/dist/skills/zon-ui/references/components/tippy.md +243 -0
  404. package/dist/skills/zon-ui/references/components/toast.md +220 -0
  405. package/dist/skills/zon-ui/references/components/toggle-group.md +261 -0
  406. package/dist/skills/zon-ui/references/components/toggle.md +167 -0
  407. package/dist/skills/zon-ui/references/components/tool-call.md +146 -0
  408. package/dist/skills/zon-ui/references/components/toolbar.md +260 -0
  409. package/dist/skills/zon-ui/references/components/tooltip.md +172 -0
  410. package/dist/skills/zon-ui/references/components/tour.md +423 -0
  411. package/dist/skills/zon-ui/references/components/tree.md +481 -0
  412. package/dist/skills/zon-ui/references/components/typography.md +347 -0
  413. package/dist/skills/zon-ui/references/components/video-player.md +386 -0
  414. package/dist/skills/zon-ui/references/marketing.md +467 -0
  415. package/dist/skills/zon-ui/references/motion.md +455 -0
  416. package/dist/skills/zon-ui/references/recipes.md +1232 -0
  417. package/dist/skills/zon-ui/references/tokens.md +866 -0
  418. package/dist/sources/accordion.css +4 -0
  419. package/dist/sources/action-sheet.css +11 -0
  420. package/dist/sources/alert-dialog.css +6 -0
  421. package/dist/sources/alert.css +3 -0
  422. package/dist/sources/app-bar.css +14 -0
  423. package/dist/sources/ascii-field.css +3 -0
  424. package/dist/sources/aspect-ratio.css +3 -0
  425. package/dist/sources/audio-player.css +20 -0
  426. package/dist/sources/avatar.css +3 -0
  427. package/dist/sources/badge.css +3 -0
  428. package/dist/sources/bottom-nav.css +9 -0
  429. package/dist/sources/breadcrumb.css +14 -0
  430. package/dist/sources/button-group.css +3 -0
  431. package/dist/sources/button.css +9 -0
  432. package/dist/sources/calendar.css +13 -0
  433. package/dist/sources/card.css +3 -0
  434. package/dist/sources/carousel.css +11 -0
  435. package/dist/sources/chart.css +5 -0
  436. package/dist/sources/checkbox.css +6 -0
  437. package/dist/sources/code-block.css +13 -0
  438. package/dist/sources/collapsible.css +4 -0
  439. package/dist/sources/color-picker.css +13 -0
  440. package/dist/sources/combobox.css +13 -0
  441. package/dist/sources/command.css +13 -0
  442. package/dist/sources/context-menu.css +12 -0
  443. package/dist/sources/conversation.css +10 -0
  444. package/dist/sources/copy-button.css +10 -0
  445. package/dist/sources/data-table.css +27 -0
  446. package/dist/sources/date-picker.css +20 -0
  447. package/dist/sources/dialog.css +9 -0
  448. package/dist/sources/direction.css +2 -0
  449. package/dist/sources/drawer.css +9 -0
  450. package/dist/sources/drawing.css +5 -0
  451. package/dist/sources/empty.css +3 -0
  452. package/dist/sources/feature-list.css +4 -0
  453. package/dist/sources/field.css +4 -0
  454. package/dist/sources/file-drop.css +15 -0
  455. package/dist/sources/filter-bar.css +30 -0
  456. package/dist/sources/form.css +4 -0
  457. package/dist/sources/graph.css +19 -0
  458. package/dist/sources/illustration.css +28 -0
  459. package/dist/sources/input-group.css +7 -0
  460. package/dist/sources/input.css +3 -0
  461. package/dist/sources/item.css +4 -0
  462. package/dist/sources/kbd.css +5 -0
  463. package/dist/sources/label.css +3 -0
  464. package/dist/sources/layout.css +3 -0
  465. package/dist/sources/lightbox.css +33 -0
  466. package/dist/sources/locale.css +2 -0
  467. package/dist/sources/logo.css +4 -0
  468. package/dist/sources/markdown-editor.css +41 -0
  469. package/dist/sources/mentions.css +13 -0
  470. package/dist/sources/menu.css +11 -0
  471. package/dist/sources/menubar.css +14 -0
  472. package/dist/sources/message.css +16 -0
  473. package/dist/sources/meter.css +4 -0
  474. package/dist/sources/money-input.css +10 -0
  475. package/dist/sources/native-select.css +4 -0
  476. package/dist/sources/navigation-menu.css +8 -0
  477. package/dist/sources/number-field.css +8 -0
  478. package/dist/sources/number-roll.css +6 -0
  479. package/dist/sources/otp-field.css +5 -0
  480. package/dist/sources/pagination.css +11 -0
  481. package/dist/sources/pdf-viewer.css +30 -0
  482. package/dist/sources/phone-input.css +20 -0
  483. package/dist/sources/popover.css +7 -0
  484. package/dist/sources/preview-card.css +7 -0
  485. package/dist/sources/progress.css +4 -0
  486. package/dist/sources/prompt-input.css +15 -0
  487. package/dist/sources/pull-to-refresh.css +14 -0
  488. package/dist/sources/quote.css +3 -0
  489. package/dist/sources/radio-group.css +5 -0
  490. package/dist/sources/rating.css +6 -0
  491. package/dist/sources/reasoning.css +6 -0
  492. package/dist/sources/resizable.css +4 -0
  493. package/dist/sources/response.css +16 -0
  494. package/dist/sources/scheduler.css +44 -0
  495. package/dist/sources/scroll-area.css +3 -0
  496. package/dist/sources/select.css +12 -0
  497. package/dist/sources/separator.css +3 -0
  498. package/dist/sources/sidebar.css +19 -0
  499. package/dist/sources/site-header.css +15 -0
  500. package/dist/sources/skeleton.css +3 -0
  501. package/dist/sources/slider.css +6 -0
  502. package/dist/sources/sortable.css +12 -0
  503. package/dist/sources/sources.css +6 -0
  504. package/dist/sources/spinner.css +6 -0
  505. package/dist/sources/stat.css +9 -0
  506. package/dist/sources/stepper.css +6 -0
  507. package/dist/sources/suggestions.css +10 -0
  508. package/dist/sources/swipe-actions.css +20 -0
  509. package/dist/sources/switch.css +5 -0
  510. package/dist/sources/table.css +7 -0
  511. package/dist/sources/tabs.css +5 -0
  512. package/dist/sources/tag.css +3 -0
  513. package/dist/sources/tags-input.css +6 -0
  514. package/dist/sources/textarea.css +3 -0
  515. package/dist/sources/theme.css +13 -0
  516. package/dist/sources/time-field.css +7 -0
  517. package/dist/sources/timeline.css +7 -0
  518. package/dist/sources/tippy.css +6 -0
  519. package/dist/sources/toast.css +6 -0
  520. package/dist/sources/toggle-group.css +5 -0
  521. package/dist/sources/toggle.css +3 -0
  522. package/dist/sources/tool-call.css +16 -0
  523. package/dist/sources/toolbar.css +14 -0
  524. package/dist/sources/tooltip.css +6 -0
  525. package/dist/sources/tour.css +14 -0
  526. package/dist/sources/tree.css +6 -0
  527. package/dist/sources/typography.css +4 -0
  528. package/dist/sources/video-player.css +21 -0
  529. package/dist/styles/ai.css +3 -0
  530. package/dist/styles/brand.css +98 -0
  531. package/dist/styles/core.css +266 -0
  532. package/dist/styles/editor.css +3 -0
  533. package/dist/styles/expressive.css +35 -56
  534. package/dist/styles/fonts.css +61 -117
  535. package/dist/styles/graph.css +4 -0
  536. package/dist/styles/illustration.css +4 -0
  537. package/dist/styles/index.css +11 -201
  538. package/dist/styles/material.css +138 -12
  539. package/dist/styles/parts/ai.css +18 -13
  540. package/dist/styles/parts/brand.css +2 -2
  541. package/dist/styles/parts/controls.css +29 -20
  542. package/dist/styles/parts/data.css +13 -9
  543. package/dist/styles/parts/editor.css +372 -0
  544. package/dist/styles/parts/feedback.css +32 -2
  545. package/dist/styles/parts/foundations.css +12 -7
  546. package/dist/styles/parts/graph.css +25 -9
  547. package/dist/styles/parts/inputs.css +172 -9
  548. package/dist/styles/parts/isometric.css +6 -5
  549. package/dist/styles/parts/navigation.css +206 -27
  550. package/dist/styles/parts/overlays.css +19 -4
  551. package/dist/styles/parts/pdf.css +2 -2
  552. package/dist/styles/pdf.css +3 -0
  553. package/dist/styles/prose.css +3 -0
  554. package/dist/styles/tokens.css +89 -14
  555. package/dist/theme.d.ts +1 -0
  556. package/dist/theme.js +5 -0
  557. package/dist/vite.d.ts +48 -59
  558. package/dist/vite.js +54 -21
  559. package/package.json +69 -2
@@ -0,0 +1,1639 @@
1
+ # Sign in and sign up
2
+
3
+ ```tsx
4
+ import { Button, Card, CardDescription, CardHeader, CardTitle, Checkbox, Field, FieldDescription, FieldError, FieldLabel, Form, FormActions, Input, InputGroup, InputGroupAddon, InputGroupInput, InputGroupPasswordToggle, OtpField, Separator, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, TwoTone } from "@zonsh/ui";
5
+ import { Wordmark } from "@zonsh/ui/brand";
6
+ import { Tippy, type TippyMove } from "@zonsh/ui/tippy";
7
+ import { ArrowLeftIcon, CheckIcon } from "lucide-react";
8
+ import * as React from "react";
9
+
10
+ /** Your product's mark — a placeholder for "Acme". Replace it and the name with your own; never zon's Logo. */
11
+ function AcmeMark() {
12
+ return (
13
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinejoin="round">
14
+ <path d="M3.5 20.5 12 3.5l8.5 17z" />
15
+ <path d="M8 14.5h8" />
16
+ </svg>
17
+ );
18
+ }
19
+
20
+ /* The fake backend for a fictional notes app. Nothing leaves the page: any email works, the
21
+ * password "wrong" is refused, taken@example.com already has an account, and the one-time code is
22
+ * always 246810. */
23
+ const DEMO_CODE = "246810";
24
+
25
+ const WRONG_PASSWORD = "wrong";
26
+
27
+ const TAKEN_EMAIL = "taken@example.com";
28
+
29
+ const LATENCY = 700;
30
+
31
+ const RESEND_COOLDOWN = 30;
32
+
33
+ const MIN_PASSWORD = 10;
34
+
35
+ const WRONG_PASSWORD_ERROR = "That password does not match this email. Check it, or reset it.";
36
+
37
+ type Errors = Record<string, string>;
38
+
39
+ type Mode = "sign-in" | "sign-up";
40
+
41
+ type Layout = "card" | "page" | "tippy";
42
+
43
+ /** Each step's title: the page's h1 when the form is the page, an h2 in a card. */
44
+ const StepHeading = React.createContext<"h1" | "h2">("h2");
45
+
46
+ function useStepHeading() {
47
+ return React.useContext(StepHeading) === "h1" ? <h1 /> : <h2 />;
48
+ }
49
+
50
+ /** Fake latency that is cancelled when the component unmounts. */
51
+ function useWait() {
52
+ const timers = React.useRef(new Set<ReturnType<typeof setTimeout>>());
53
+ React.useEffect(() => {
54
+ const pending = timers.current;
55
+ return () => {
56
+ pending.forEach(clearTimeout);
57
+ pending.clear();
58
+ };
59
+ }, []);
60
+ return React.useCallback(
61
+ (ms: number) =>
62
+ new Promise<void>((resolve) => {
63
+ const id = setTimeout(() => {
64
+ timers.current.delete(id);
65
+ resolve();
66
+ }, ms);
67
+ timers.current.add(id);
68
+ }),
69
+ [],
70
+ );
71
+ }
72
+
73
+ /** Drops one field's error, returning the same object when there was none. */
74
+ function without(errors: Errors, name: string) {
75
+ if (!(name in errors)) return errors;
76
+ const next = { ...errors };
77
+ delete next[name];
78
+ return next;
79
+ }
80
+
81
+ /** The submit button keeps its width while pending: Button's `loading` lays a spinner over the label. */
82
+ function SubmitButton({
83
+ pending,
84
+ pendingLabel,
85
+ children,
86
+ }: {
87
+ pending: boolean;
88
+ pendingLabel: string;
89
+ children: React.ReactNode;
90
+ }) {
91
+ return (
92
+ <Button type="submit" loading={pending} loadingLabel={pendingLabel}>
93
+ {children}
94
+ </Button>
95
+ );
96
+ }
97
+
98
+ /* ── Social sign-in ─────────────────────────────────────────────────────────────────────────── */
99
+
100
+ type Provider = "Google" | "GitHub" | "Apple";
101
+
102
+ /* The providers' own marks, drawn in the current ink: they name the provider, so they stay theirs. */
103
+ const providerMarks: Record<Provider, string> = {
104
+ Google:
105
+ "M12.48 10.92v3.28h7.84c-.24 1.84-.853 3.187-1.787 4.133-1.147 1.147-2.933 2.4-6.053 2.4-4.827 0-8.6-3.893-8.6-8.72s3.773-8.72 8.6-8.72c2.6 0 4.507 1.027 5.907 2.347l2.307-2.307C18.747 1.44 16.133 0 12.48 0 5.867 0 .307 5.387.307 12s5.56 12 12.173 12c3.573 0 6.267-1.173 8.373-3.36 2.16-2.16 2.84-5.213 2.84-7.667 0-.76-.053-1.467-.173-2.053H12.48z",
106
+ GitHub:
107
+ "M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12",
108
+ Apple:
109
+ "M12.152 6.896c-.948 0-2.415-1.078-3.96-1.04-2.04.027-3.91 1.183-4.961 3.014-2.117 3.675-.546 9.103 1.519 12.09 1.013 1.454 2.208 3.09 3.792 3.039 1.52-.065 2.09-.987 3.935-.987 1.831 0 2.35.987 3.96.948 1.637-.026 2.676-1.48 3.676-2.948 1.156-1.688 1.636-3.325 1.662-3.415-.039-.013-3.182-1.221-3.22-4.857-.026-3.04 2.48-4.494 2.597-4.559-1.429-2.09-3.623-2.324-4.39-2.376-2-.156-3.675 1.09-4.61 1.09zM15.53 3.83c.843-1.012 1.4-2.427 1.245-3.83-1.207.052-2.662.805-3.532 1.818-.78.896-1.454 2.338-1.273 3.714 1.338.104 2.715-.688 3.559-1.701",
110
+ };
111
+
112
+ const providers = Object.keys(providerMarks) as Provider[];
113
+
114
+ /**
115
+ * Google, GitHub and Apple as a row of three equal buttons, each the provider's mark alone, named
116
+ * "Continue with …" for assistive technology and in a tooltip; then an "or" rule. In an app each
117
+ * goes to the provider and comes back signed in; here each waits a moment and finishes the flow,
118
+ * with no code step: the provider has already checked the email.
119
+ */
120
+ function SocialSignIn({ onProvider }: { onProvider: (provider: Provider) => void }) {
121
+ const wait = useWait();
122
+ const [pending, setPending] = React.useState<Provider | null>(null);
123
+ return (
124
+ <>
125
+ <TooltipProvider>
126
+ <div className="grid grid-cols-3 gap-2">
127
+ {providers.map((provider) => (
128
+ <Tooltip key={provider}>
129
+ <TooltipTrigger
130
+ render={
131
+ <Button
132
+ type="button"
133
+ variant="secondary"
134
+ className="w-full"
135
+ // While it opens, the button says so: its label is the spinner's.
136
+ aria-label={pending === provider ? `Opening ${provider}` : `Continue with ${provider}`}
137
+ loading={pending === provider}
138
+ loadingLabel={`Opening ${provider}`}
139
+ onClick={async () => {
140
+ if (pending) return;
141
+ setPending(provider);
142
+ await wait(LATENCY);
143
+ setPending(null);
144
+ onProvider(provider);
145
+ }}
146
+ />
147
+ }
148
+ >
149
+ <svg aria-hidden viewBox="0 0 24 24" className="size-[18px] fill-current">
150
+ <path d={providerMarks[provider]} />
151
+ </svg>
152
+ </TooltipTrigger>
153
+ <TooltipContent>Continue with {provider}</TooltipContent>
154
+ </Tooltip>
155
+ ))}
156
+ </div>
157
+ </TooltipProvider>
158
+ <Separator label="or" />
159
+ </>
160
+ );
161
+ }
162
+
163
+ /** A link to the other flow. In an app it goes to its page; here it switches the block over. */
164
+ function ModeLink({
165
+ to,
166
+ onSwitch,
167
+ children,
168
+ }: {
169
+ to: Mode;
170
+ onSwitch: (to: Mode) => void;
171
+ children: React.ReactNode;
172
+ }) {
173
+ return (
174
+ <a
175
+ href={`#${to}`}
176
+ className="link text-foreground"
177
+ onClick={(event) => {
178
+ event.preventDefault();
179
+ onSwitch(to);
180
+ }}
181
+ >
182
+ {children}
183
+ </a>
184
+ );
185
+ }
186
+
187
+ /* ── Sign in ────────────────────────────────────────────────────────────────────────────────── */
188
+
189
+ interface CredentialsStepProps {
190
+ defaultEmail?: string;
191
+ defaultPassword?: string;
192
+ defaultErrors?: Errors;
193
+ /** Focus the email field on mount, when someone comes back from the code step. */
194
+ autoFocusEmail?: boolean;
195
+ onContinue: (email: string) => void;
196
+ onProvider: (provider: Provider) => void;
197
+ }
198
+
199
+ function CredentialsStep({
200
+ defaultEmail,
201
+ defaultPassword,
202
+ defaultErrors = {},
203
+ autoFocusEmail,
204
+ onContinue,
205
+ onProvider,
206
+ }: CredentialsStepProps) {
207
+ const heading = useStepHeading();
208
+ const wait = useWait();
209
+ const [visible, setVisible] = React.useState(false);
210
+ const [pending, setPending] = React.useState(false);
211
+ const [errors, setErrors] = React.useState<Errors>(defaultErrors);
212
+ const passwordRef = React.useRef<HTMLInputElement>(null);
213
+
214
+ return (
215
+ <>
216
+ <CardHeader>
217
+ <p className="m-0 eyebrow">Step 1 of 2</p>
218
+ <CardTitle render={heading}>Sign in</CardTitle>
219
+ <CardDescription>With your Google, GitHub or Apple account, or with your email.</CardDescription>
220
+ </CardHeader>
221
+
222
+ <SocialSignIn onProvider={onProvider} />
223
+
224
+ <Form
225
+ errors={errors}
226
+ onFormSubmit={async (values) => {
227
+ if (pending) return;
228
+ setPending(true);
229
+ setErrors({});
230
+ await wait(LATENCY);
231
+ setPending(false);
232
+ if (values.password === WRONG_PASSWORD) {
233
+ setErrors({ password: WRONG_PASSWORD_ERROR });
234
+ passwordRef.current?.select();
235
+ return;
236
+ }
237
+ onContinue(String(values.email));
238
+ }}
239
+ >
240
+ <Field name="email">
241
+ <FieldLabel>Work email</FieldLabel>
242
+ <Input
243
+ required
244
+ type="email"
245
+ autoComplete="username"
246
+ placeholder="alex@company.de"
247
+ defaultValue={defaultEmail}
248
+ autoFocus={autoFocusEmail}
249
+ />
250
+ <FieldError match="valueMissing">Enter the email address you signed up with.</FieldError>
251
+ <FieldError match="typeMismatch">
252
+ That does not look like an email address. Check the @ part.
253
+ </FieldError>
254
+ </Field>
255
+
256
+ <Field name="password">
257
+ <FieldLabel>Password</FieldLabel>
258
+ <InputGroup>
259
+ <InputGroupInput
260
+ ref={passwordRef}
261
+ required
262
+ type={visible ? "text" : "password"}
263
+ autoComplete="current-password"
264
+ spellCheck={false}
265
+ defaultValue={defaultPassword}
266
+ onValueChange={() => setErrors((e) => without(e, "password"))}
267
+ />
268
+ <InputGroupAddon align="inline-end">
269
+ <InputGroupPasswordToggle visible={visible} onVisibleChange={setVisible} />
270
+ </InputGroupAddon>
271
+ </InputGroup>
272
+ <FieldError match="valueMissing">Enter your password.</FieldError>
273
+ {errors.password && <FieldError match>{errors.password}</FieldError>}
274
+ </Field>
275
+
276
+ <FormActions align="between">
277
+ <Button variant="link" nativeButton={false} render={<a href="#forgot-password" />}>
278
+ Forgot your password?
279
+ </Button>
280
+ <SubmitButton pending={pending} pendingLabel="Checking your password">
281
+ Continue
282
+ </SubmitButton>
283
+ </FormActions>
284
+ </Form>
285
+ </>
286
+ );
287
+ }
288
+
289
+ function SignedIn({
290
+ email,
291
+ provider,
292
+ onSignOut,
293
+ }: {
294
+ email: string;
295
+ provider?: Provider;
296
+ onSignOut: () => void;
297
+ }) {
298
+ // The step and its focused field are gone: focus starts again at the heading.
299
+ const heading = useStepHeading();
300
+ const headingRef = React.useRef<HTMLHeadingElement>(null);
301
+ React.useEffect(() => headingRef.current?.focus(), []);
302
+ return (
303
+ <>
304
+ <CardHeader>
305
+ <p role="status" className="m-0 flex items-center gap-1.5 font-mono text-xs text-success">
306
+ <CheckIcon aria-hidden className="size-3.5" />
307
+ Signed in
308
+ </p>
309
+ <CardTitle render={heading} ref={headingRef} tabIndex={-1} className="outline-none">
310
+ Welcome back
311
+ </CardTitle>
312
+ <CardDescription>
313
+ You are signed in as <span className="wrap-anywhere text-foreground">{email}</span>
314
+ {provider ? `, with ${provider}.` : "."}
315
+ </CardDescription>
316
+ </CardHeader>
317
+ <Button variant="secondary" className="self-start" onClick={onSignOut}>
318
+ Sign out
319
+ </Button>
320
+ </>
321
+ );
322
+ }
323
+
324
+ /* ── Sign up ────────────────────────────────────────────────────────────────────────────────── */
325
+
326
+ interface Account {
327
+ name: string;
328
+ email: string;
329
+ }
330
+
331
+ interface DetailsStepProps {
332
+ defaults?: Partial<Account>;
333
+ defaultErrors?: Errors;
334
+ /** Focus the email field on mount, when someone comes back from the code step to change it. */
335
+ autoFocusEmail?: boolean;
336
+ onCreated: (account: Account) => void;
337
+ onProvider: (provider: Provider) => void;
338
+ /** "Sign in instead", from the error on an email that already has an account. */
339
+ onSignIn: (email: string) => void;
340
+ }
341
+
342
+ function DetailsStep({
343
+ defaults = {},
344
+ defaultErrors = {},
345
+ autoFocusEmail,
346
+ onCreated,
347
+ onProvider,
348
+ onSignIn,
349
+ }: DetailsStepProps) {
350
+ const heading = useStepHeading();
351
+ const wait = useWait();
352
+ const [visible, setVisible] = React.useState(false);
353
+ const [pending, setPending] = React.useState(false);
354
+ const [errors, setErrors] = React.useState<Errors>(defaultErrors);
355
+ const emailRef = React.useRef<HTMLInputElement>(null);
356
+
357
+ return (
358
+ <>
359
+ <CardHeader>
360
+ <p className="m-0 eyebrow">Step 1 of 2</p>
361
+ <CardTitle render={heading}>Create your account</CardTitle>
362
+ <CardDescription>Free for one person, on the Personal plan.</CardDescription>
363
+ </CardHeader>
364
+
365
+ <SocialSignIn onProvider={onProvider} />
366
+
367
+ <Form
368
+ errors={errors}
369
+ onFormSubmit={async (values) => {
370
+ if (pending) return;
371
+ setPending(true);
372
+ setErrors({});
373
+ await wait(LATENCY);
374
+ setPending(false);
375
+ const email = String(values.email).trim();
376
+ if (email.toLowerCase() === TAKEN_EMAIL) {
377
+ setErrors({ email: "taken" });
378
+ emailRef.current?.select();
379
+ return;
380
+ }
381
+ onCreated({ name: String(values.name).trim(), email });
382
+ }}
383
+ >
384
+ <Field name="name">
385
+ <FieldLabel>Your name</FieldLabel>
386
+ <Input required autoComplete="name" placeholder="Alex Weber" defaultValue={defaults.name} />
387
+ <FieldError match="valueMissing">Tell us what to call you.</FieldError>
388
+ </Field>
389
+
390
+ <Field name="email">
391
+ <FieldLabel>Work email</FieldLabel>
392
+ <Input
393
+ ref={emailRef}
394
+ required
395
+ type="email"
396
+ autoComplete="email"
397
+ placeholder="alex@company.de"
398
+ defaultValue={defaults.email}
399
+ autoFocus={autoFocusEmail}
400
+ onChange={() => setErrors((e) => without(e, "email"))}
401
+ />
402
+ <FieldError match="valueMissing">Enter the email address you want to sign in with.</FieldError>
403
+ <FieldError match="typeMismatch">
404
+ That does not look like an email address. Check the @ part.
405
+ </FieldError>
406
+ {errors.email && (
407
+ <FieldError match>
408
+ This email already has an account.{" "}
409
+ <a
410
+ href="#sign-in"
411
+ className="link"
412
+ onClick={(event) => {
413
+ event.preventDefault();
414
+ onSignIn(emailRef.current?.value.trim() ?? "");
415
+ }}
416
+ >
417
+ Sign in instead
418
+ </a>
419
+ , or use a different email.
420
+ </FieldError>
421
+ )}
422
+ </Field>
423
+
424
+ <Field name="password">
425
+ <FieldLabel>Password</FieldLabel>
426
+ <InputGroup>
427
+ <InputGroupInput
428
+ required
429
+ minLength={MIN_PASSWORD}
430
+ type={visible ? "text" : "password"}
431
+ autoComplete="new-password"
432
+ spellCheck={false}
433
+ />
434
+ <InputGroupAddon align="inline-end">
435
+ <InputGroupPasswordToggle visible={visible} onVisibleChange={setVisible} />
436
+ </InputGroupAddon>
437
+ </InputGroup>
438
+ <FieldDescription>
439
+ At least {MIN_PASSWORD} characters. A few words you will remember work well.
440
+ </FieldDescription>
441
+ <FieldError match="valueMissing">Choose a password.</FieldError>
442
+ <FieldError match="tooShort">
443
+ That is shorter than {MIN_PASSWORD} characters. Add a word or two.
444
+ </FieldError>
445
+ </Field>
446
+
447
+ <Field name="terms">
448
+ <FieldLabel>
449
+ <Checkbox required />
450
+ <span>
451
+ I agree to the{" "}
452
+ <a href="#terms" className="link">
453
+ terms
454
+ </a>{" "}
455
+ and have read the{" "}
456
+ <a href="#privacy" className="link">
457
+ privacy policy
458
+ </a>
459
+ .
460
+ </span>
461
+ </FieldLabel>
462
+ <FieldError match="valueMissing" className="ps-7">
463
+ Tick this box to create the account.
464
+ </FieldError>
465
+ </Field>
466
+
467
+ <FormActions>
468
+ <SubmitButton pending={pending} pendingLabel="Creating your account">
469
+ Create account
470
+ </SubmitButton>
471
+ </FormActions>
472
+ </Form>
473
+ </>
474
+ );
475
+ }
476
+
477
+ function Created({ account, provider }: { account: Account; provider?: Provider }) {
478
+ // The step and its focused field are gone: focus starts again at the heading.
479
+ const heading = useStepHeading();
480
+ const headingRef = React.useRef<HTMLHeadingElement>(null);
481
+ React.useEffect(() => headingRef.current?.focus(), []);
482
+ const name = account.name.split(/\s+/)[0] ?? "";
483
+ return (
484
+ <>
485
+ <CardHeader>
486
+ <p role="status" className="m-0 flex items-center gap-1.5 font-mono text-xs text-success">
487
+ <CheckIcon aria-hidden className="size-3.5" />
488
+ Account created
489
+ </p>
490
+ <CardTitle render={heading} ref={headingRef} tabIndex={-1} className="outline-none">
491
+ {name ? `Welcome, ${name}` : "Welcome"}
492
+ </CardTitle>
493
+ <CardDescription>
494
+ You are signed in as <span className="wrap-anywhere text-foreground">{account.email}</span>
495
+ {provider ? `, with ${provider}` : ""}. Next, set up a workspace for your notes.
496
+ </CardDescription>
497
+ </CardHeader>
498
+ <Button className="self-start" nativeButton={false} render={<a href="#onboarding" />}>
499
+ Set up your workspace
500
+ </Button>
501
+ </>
502
+ );
503
+ }
504
+
505
+ /* ── The code, for both ─────────────────────────────────────────────────────────────────────── */
506
+
507
+ interface CodeCopy {
508
+ title: string;
509
+ /** What follows the email in "We sent a 6-digit code to …". */
510
+ why: string;
511
+ label: string;
512
+ submit: string;
513
+ pending: string;
514
+ back: string;
515
+ nothingArrived: string;
516
+ }
517
+
518
+ const signInCode: CodeCopy = {
519
+ title: "Check your email",
520
+ why: ".",
521
+ label: "Sign-in code",
522
+ submit: "Verify and sign in",
523
+ pending: "Checking your code",
524
+ back: "Use a different email",
525
+ nothingArrived: "Nothing arrived?",
526
+ };
527
+
528
+ const signUpCode: CodeCopy = {
529
+ title: "Check your inbox",
530
+ why: " to make sure it is yours.",
531
+ label: "Verification code",
532
+ submit: "Verify email",
533
+ pending: "Checking your code",
534
+ back: "Change email",
535
+ nothingArrived: "Nothing arrived? Check your spam folder, or",
536
+ };
537
+
538
+ interface CodeStepProps {
539
+ email: string;
540
+ copy: CodeCopy;
541
+ /** Move focus into the code on mount, when the step follows the first one. */
542
+ autoFocusCode?: boolean;
543
+ /** Go back to the first step. Without it, the back link is not shown. */
544
+ onBack?: () => void;
545
+ onVerified: () => void;
546
+ }
547
+
548
+ function CodeStep({ email, copy, autoFocusCode, onBack, onVerified }: CodeStepProps) {
549
+ const wait = useWait();
550
+ const heading = useStepHeading();
551
+ const codeRef = React.useRef<HTMLDivElement>(null);
552
+ const [code, setCode] = React.useState("");
553
+ const [pending, setPending] = React.useState(false);
554
+ const [errors, setErrors] = React.useState<Errors>({});
555
+ const [resending, setResending] = React.useState(false);
556
+ const [resent, setResent] = React.useState(false);
557
+ const [cooldown, setCooldown] = React.useState(0);
558
+ /**
559
+ * Counts the times the code starts over: a new code, or a wrong one. Each starts the form over,
560
+ * nothing typed; clearing the digits in the same form would flag them as missing, since after a
561
+ * submit a form checks its fields on every change. The server's error survives in `errors`.
562
+ */
563
+ const [round, setRound] = React.useState(0);
564
+ /** Set when the next round comes from a new code, so its status line is read out once it is there. */
565
+ const announce = React.useRef(false);
566
+
567
+ React.useEffect(() => {
568
+ if (autoFocusCode) codeRef.current?.querySelector("input")?.focus();
569
+ }, [autoFocusCode]);
570
+
571
+ // Once the fresh form is there: into the first slot, then, after a new code, the status line
572
+ // changes, so it is read out.
573
+ React.useEffect(() => {
574
+ if (round === 0) return;
575
+ codeRef.current?.querySelector("input")?.focus();
576
+ if (announce.current) {
577
+ announce.current = false;
578
+ setResent(true);
579
+ }
580
+ }, [round]);
581
+
582
+ // Count the resend cooldown down one second at a time.
583
+ React.useEffect(() => {
584
+ if (cooldown <= 0) return;
585
+ const id = setTimeout(() => setCooldown((s) => s - 1), 1000);
586
+ return () => clearTimeout(id);
587
+ }, [cooldown]);
588
+
589
+ async function resend() {
590
+ if (resending || cooldown > 0) return;
591
+ setResending(true);
592
+ setResent(false);
593
+ await wait(LATENCY);
594
+ setResending(false);
595
+ setCode("");
596
+ setErrors({});
597
+ setCooldown(RESEND_COOLDOWN);
598
+ announce.current = true;
599
+ setRound((r) => r + 1);
600
+ }
601
+
602
+ return (
603
+ <>
604
+ <CardHeader>
605
+ <p className="m-0 eyebrow">Step 2 of 2</p>
606
+ <CardTitle render={heading}>{copy.title}</CardTitle>
607
+ <CardDescription>
608
+ We sent a 6-digit code to <span className="wrap-anywhere text-foreground">{email}</span>
609
+ {copy.why}
610
+ </CardDescription>
611
+ </CardHeader>
612
+
613
+ <Form
614
+ key={round}
615
+ errors={errors}
616
+ onFormSubmit={async (values) => {
617
+ if (pending) return;
618
+ setPending(true);
619
+ setErrors({});
620
+ await wait(LATENCY);
621
+ setPending(false);
622
+ if (values.code !== DEMO_CODE) {
623
+ // Empty again, so the next digit typed starts a new code rather than sending this one.
624
+ setCode("");
625
+ setErrors({ code: "That code is not right. Check the latest email, or send a new code." });
626
+ setRound((r) => r + 1);
627
+ return;
628
+ }
629
+ onVerified();
630
+ }}
631
+ >
632
+ <Field name="code">
633
+ <FieldLabel>{copy.label}</FieldLabel>
634
+ <OtpField
635
+ ref={codeRef}
636
+ length={6}
637
+ required
638
+ autoSubmit
639
+ readOnly={pending}
640
+ value={code}
641
+ onValueChange={(value) => {
642
+ setCode(value);
643
+ setErrors((e) => without(e, "code"));
644
+ }}
645
+ />
646
+ <FieldDescription>Paste the whole code if that is easier.</FieldDescription>
647
+ <FieldError match="valueMissing">Enter the code from the email.</FieldError>
648
+ <FieldError match="patternMismatch">The code has 6 digits. Check for a missing one.</FieldError>
649
+ {errors.code && <FieldError match>{errors.code}</FieldError>}
650
+ </Field>
651
+
652
+ <div className="flex flex-col gap-1 text-13 leading-normal text-muted-foreground">
653
+ <p className="m-0 flex flex-wrap items-center gap-x-1.5">
654
+ {copy.nothingArrived}
655
+ <Button
656
+ type="button"
657
+ variant="link"
658
+ className="text-13 tabular-nums"
659
+ aria-busy={resending}
660
+ disabled={cooldown > 0}
661
+ focusableWhenDisabled
662
+ onClick={resend}
663
+ >
664
+ {resending ? "Sending…" : cooldown > 0 ? `Send a new code in ${cooldown}s` : "Send a new code"}
665
+ </Button>
666
+ </p>
667
+ <p role="status" className="m-0">
668
+ {resent ? `We sent a new code to ${email}. The old one no longer works.` : ""}
669
+ </p>
670
+ </div>
671
+
672
+ <FormActions align={onBack ? "between" : "end"}>
673
+ {onBack && (
674
+ <Button type="button" variant="link" onClick={onBack}>
675
+ <ArrowLeftIcon aria-hidden className="rtl:-scale-x-100" />
676
+ {copy.back}
677
+ </Button>
678
+ )}
679
+ <SubmitButton pending={pending} pendingLabel={copy.pending}>
680
+ {copy.submit}
681
+ </SubmitButton>
682
+ </FormActions>
683
+ </Form>
684
+ </>
685
+ );
686
+ }
687
+
688
+ /* ── The frame: in a card, on the page, or with Tippy ───────────────────────────────────────── */
689
+
690
+ type StepName = "first" | "code" | "done";
691
+
692
+ function DemoHint({ mode, step }: { mode: Mode; step: StepName }) {
693
+ const strong = "text-foreground";
694
+ let text: React.ReactNode = null;
695
+ if (step === "code")
696
+ text = (
697
+ <>
698
+ Demo: the code is <span className={`${strong} tabular-nums`}>{DEMO_CODE}</span>. Paste it or type it;
699
+ the form sends itself when the last digit is in.
700
+ </>
701
+ );
702
+ else if (step === "first" && mode === "sign-in")
703
+ text = (
704
+ <>
705
+ Demo: any email works. Type the password <span className={strong}>{WRONG_PASSWORD}</span> to see the
706
+ error.
707
+ </>
708
+ );
709
+ else if (step === "first")
710
+ text = (
711
+ <>
712
+ Demo: any email works but <span className={strong}>{TAKEN_EMAIL}</span>, which already has an account.
713
+ </>
714
+ );
715
+ if (!text) return null;
716
+ return <p className="m-0 font-mono text-xs leading-relaxed text-muted-foreground">{text}</p>;
717
+ }
718
+
719
+ /** The way to the other flow, under the first step. */
720
+ function ModeLine({ mode, onSwitch }: { mode: Mode; onSwitch: (to: Mode) => void }) {
721
+ return (
722
+ <p className="m-0 text-13 leading-normal text-muted-foreground">
723
+ {mode === "sign-in" ? (
724
+ <>
725
+ No account yet?{" "}
726
+ <ModeLink to="sign-up" onSwitch={onSwitch}>
727
+ Create an account
728
+ </ModeLink>
729
+ </>
730
+ ) : (
731
+ <>
732
+ Already have an account?{" "}
733
+ <ModeLink to="sign-in" onSwitch={onSwitch}>
734
+ Sign in
735
+ </ModeLink>
736
+ </>
737
+ )}
738
+ </p>
739
+ );
740
+ }
741
+
742
+ function LegalLinks() {
743
+ // 11px type, but a 24px target: the padding is taken back by the margin, so the row keeps its height.
744
+ const link =
745
+ "-my-1 inline-flex min-h-6 items-center py-1 transition-colors duration-(--duration-fade) ease-(--ease) hover:text-foreground";
746
+ return (
747
+ <nav aria-label="Legal">
748
+ <ul className="m-0 flex list-none gap-5 p-0 font-mono text-11 tracking-[0.14em] text-muted-foreground uppercase">
749
+ <li>
750
+ <a href="#terms" className={link}>
751
+ Terms
752
+ </a>
753
+ </li>
754
+ <li>
755
+ <a href="#privacy" className={link}>
756
+ Privacy
757
+ </a>
758
+ </li>
759
+ </ul>
760
+ </nav>
761
+ );
762
+ }
763
+
764
+ /* ── The page's other half: a picture for each flow ─────────────────────────────────────────── */
765
+
766
+ /** Where the docs site serves the pictures: two pieces from the zon gallery's duotone set. */
767
+ const FILES = `${import.meta.env.BASE_URL}files/`;
768
+
769
+ /**
770
+ * One of the two flows' halves, in a shared grid cell: the current one is shown, the other fades
771
+ * out under it, and the taller of the two sets the height, so switching flows moves nothing.
772
+ */
773
+ function Layer({
774
+ shown,
775
+ className = "",
776
+ children,
777
+ }: {
778
+ shown: boolean;
779
+ className?: string;
780
+ children: React.ReactNode;
781
+ }) {
782
+ return (
783
+ <div
784
+ aria-hidden={shown ? undefined : true}
785
+ inert={!shown}
786
+ className={`transition-opacity duration-[calc(var(--duration-fade)*2)] ease-(--ease) [grid-area:1/1] ${
787
+ shown ? "opacity-100" : "opacity-0"
788
+ } ${className}`}
789
+ >
790
+ {children}
791
+ </div>
792
+ );
793
+ }
794
+
795
+ const picture = "block w-full rounded-[20px] bg-muted object-cover";
796
+
797
+ /**
798
+ * Sign in: a street at dusk, the way home, tall, with one line under it. Sign up: the line first,
799
+ * a path into a field of flowers, and what a new account starts with, on hairlines. Only from
800
+ * 48rem: narrower, the form is the whole page, and nothing comes before it.
801
+ */
802
+ function ArtAside({ mode }: { mode: Mode }) {
803
+ return (
804
+ <div className="hidden min-w-0 items-start ps-16 @3xl/auth:grid @3xl/auth:py-2">
805
+ <Layer shown={mode === "sign-in"} className="flex flex-col gap-8">
806
+ <img
807
+ src={`${FILES}sign-in-town.webp`}
808
+ alt="A quiet street at dusk under the crescent moon: lit windows, a vending machine and a bicycle by the wall, in cobalt and cream."
809
+ width={1200}
810
+ height={800}
811
+ decoding="async"
812
+ className={`${picture} aspect-[4/5] max-h-[34rem] object-[72%_50%]`}
813
+ />
814
+ <TwoTone as="p" className="m-0 text-28">
815
+ {"Welcome back."}
816
+ {"Your notes are where you left them."}
817
+ </TwoTone>
818
+ </Layer>
819
+ <Layer shown={mode === "sign-up"} className="flex flex-col gap-8">
820
+ <TwoTone as="p" className="m-0 text-28">
821
+ {"Start with a notebook of your own."}
822
+ {"Bring the team in when you are ready."}
823
+ </TwoTone>
824
+ <img
825
+ src={`${FILES}sign-up-flowers.webp`}
826
+ alt="A path through a field of white flowers to a lone tree on a hill, the crescent moon in a cobalt sky, in cobalt and cream."
827
+ width={1200}
828
+ height={800}
829
+ decoding="async"
830
+ className={`${picture} aspect-[4/3] object-[60%_50%]`}
831
+ />
832
+ <ul className="m-0 list-none p-0 text-sm text-muted-foreground">
833
+ {[
834
+ "Free for one person, on the Personal plan.",
835
+ "Your notes on every device, in sync.",
836
+ "Invite people by email when you want to share.",
837
+ ].map((line, i) => (
838
+ <li key={line} className="flex gap-4 border-t border-border/60 py-3">
839
+ <span className="font-mono text-xs leading-5 text-foreground tabular-nums">0{i + 1}</span>
840
+ {line}
841
+ </li>
842
+ ))}
843
+ </ul>
844
+ </Layer>
845
+ </div>
846
+ );
847
+ }
848
+
849
+ /* ── Tippy, beside the form ─────────────────────────────────────────────────────────────────── */
850
+
851
+ let measurer: CanvasRenderingContext2D | null = null;
852
+
853
+ /** Where the caret is in a text field, on the page: after the text before it, as the field draws it. */
854
+ function caretOf(el: Element) {
855
+ const r = el.getBoundingClientRect();
856
+ const middle = { x: r.left + r.width / 2, y: r.top + r.height / 2 };
857
+ if (!(el instanceof HTMLInputElement) || !/^(text|email|password|search|tel|url)$/.test(el.type))
858
+ return middle;
859
+ measurer ??= document.createElement("canvas").getContext("2d");
860
+ if (!measurer) return middle;
861
+ const cs = getComputedStyle(el);
862
+ measurer.font = `${cs.fontWeight} ${cs.fontSize} ${cs.fontFamily}`;
863
+ const before = el.value.slice(0, el.selectionEnd ?? el.value.length);
864
+ // A hidden password is drawn in dots.
865
+ const text = el.type === "password" ? "•".repeat(before.length) : before;
866
+ const x = r.left + parseFloat(cs.paddingInlineStart) + measurer.measureText(text).width - el.scrollLeft;
867
+ return { x: Math.max(r.left, Math.min(r.right, x)), y: middle.y };
868
+ }
869
+
870
+ const PASSWORD = "input[autocomplete$=password]";
871
+
872
+ /**
873
+ * What Tippy does beside a form, read from the form itself (focus, typing, the password's type,
874
+ * `aria-busy` and `aria-invalid`), so the steps know nothing of it: it watches the field being
875
+ * typed in, its eyes on the caret; won't look while the password is shown, covering its eyes or
876
+ * turning away by turns; thinks while the form is pending; shakes its head at an error and hops
877
+ * with a check when the flow is done. With nothing in focus it follows the pointer. Off without
878
+ * `enabled`, when there is no Tippy to tell.
879
+ */
880
+ function useTippyCues(root: React.RefObject<HTMLElement | null>, done: boolean, enabled = true) {
881
+ const [focus, setFocus] = React.useState<Element | null>(null);
882
+ const [look, setLook] = React.useState<{ x: number; y: number } | null>(null);
883
+ const [shown, setShown] = React.useState(false);
884
+ const [busy, setBusy] = React.useState(false);
885
+ const [verdict, setVerdict] = React.useState<"shake" | "success" | null>(null);
886
+ const [keys, setKeys] = React.useState(0);
887
+ // Showing the password: which way it won't look this time (it takes turns, covering first).
888
+ const [shy, setShy] = React.useState<"cover" | "away">("away");
889
+
890
+ React.useEffect(() => {
891
+ const el = root.current;
892
+ if (!el || !enabled) return;
893
+ let focused: Element | null = null;
894
+ const track = () => {
895
+ const pw = el.querySelector<HTMLInputElement>(PASSWORD);
896
+ // The password field, shown, is where it won't look; else the caret in the field in focus.
897
+ const at = focused ?? (pw?.type === "text" ? pw : null);
898
+ setLook(at?.isConnected ? caretOf(at) : null);
899
+ };
900
+ const read = () => {
901
+ const pw = el.querySelector<HTMLInputElement>(PASSWORD);
902
+ const now = pw?.type === "text";
903
+ setShown((was) => {
904
+ if (now && !was) setShy((s) => (s === "cover" ? "away" : "cover"));
905
+ return now;
906
+ });
907
+ setBusy(Boolean(el.querySelector("[aria-busy=true]")));
908
+ track();
909
+ };
910
+ const onFocusIn = (e: FocusEvent) => {
911
+ focused = e.target instanceof Element && e.target.matches("input,textarea") ? e.target : null;
912
+ setFocus(focused);
913
+ track();
914
+ };
915
+ const onFocusOut = () => {
916
+ focused = null;
917
+ setFocus(null);
918
+ track();
919
+ };
920
+ const onInput = () => {
921
+ track();
922
+ setKeys((k) => k + 1);
923
+ };
924
+ const observer = new MutationObserver((records) => {
925
+ for (const r of records)
926
+ if (
927
+ r.type === "attributes" &&
928
+ r.attributeName === "aria-invalid" &&
929
+ (r.target as Element).getAttribute("aria-invalid") === "true" &&
930
+ r.oldValue !== "true"
931
+ )
932
+ setVerdict("shake");
933
+ read();
934
+ });
935
+ observer.observe(el, {
936
+ subtree: true,
937
+ childList: true,
938
+ attributes: true,
939
+ attributeOldValue: true,
940
+ attributeFilter: ["type", "aria-busy", "aria-invalid"],
941
+ });
942
+ el.addEventListener("focusin", onFocusIn);
943
+ el.addEventListener("focusout", onFocusOut);
944
+ el.addEventListener("input", onInput);
945
+ el.addEventListener("keyup", track);
946
+ el.addEventListener("select", track);
947
+ el.addEventListener("pointerup", track);
948
+ // The caret moves when the page does, too.
949
+ window.addEventListener("scroll", track, { capture: true, passive: true });
950
+ window.addEventListener("resize", track);
951
+ read();
952
+ return () => {
953
+ observer.disconnect();
954
+ el.removeEventListener("focusin", onFocusIn);
955
+ el.removeEventListener("focusout", onFocusOut);
956
+ el.removeEventListener("input", onInput);
957
+ el.removeEventListener("keyup", track);
958
+ el.removeEventListener("select", track);
959
+ el.removeEventListener("pointerup", track);
960
+ window.removeEventListener("scroll", track, { capture: true });
961
+ window.removeEventListener("resize", track);
962
+ };
963
+ }, [root, enabled]);
964
+
965
+ // Done: a hop with a check.
966
+ React.useEffect(() => {
967
+ if (done) setVerdict("success");
968
+ }, [done]);
969
+
970
+ // A verdict is shown for a moment, then it goes back to what the form is doing.
971
+ React.useEffect(() => {
972
+ if (!verdict) return;
973
+ const id = setTimeout(() => setVerdict(null), verdict === "success" ? 2600 : 1700);
974
+ return () => clearTimeout(id);
975
+ }, [verdict]);
976
+
977
+ const move: TippyMove = verdict ?? (busy ? "think" : shown ? shy : focus ? "watch" : "idle");
978
+ return { move, look, keys };
979
+ }
980
+
981
+ /** Poked: a giggle or a shy blush, by turns, each one round long. Neither moves it off its spot. */
982
+ const POKES: { move: TippyMove; ms: number }[] = [
983
+ { move: "giggle", ms: 2000 },
984
+ { move: "shy", ms: 2800 },
985
+ ];
986
+
987
+ /**
988
+ * Tippy where it stands, following the form. Poke it and it giggles or blushes, then settles: the
989
+ * press is taken by Tippy alone, so focus stays in the field and nothing under it is dragged or
990
+ * selected, and its canvas never moves — the moves play inside it.
991
+ */
992
+ function PokableTippy({
993
+ cues,
994
+ facing,
995
+ scale,
996
+ }: {
997
+ cues: ReturnType<typeof useTippyCues>;
998
+ facing: "left" | "right";
999
+ scale: number;
1000
+ }) {
1001
+ const wait = useWait();
1002
+ const [poke, setPoke] = React.useState<TippyMove | null>(null);
1003
+ const pokes = React.useRef(0);
1004
+ const poking = React.useRef(false);
1005
+ return (
1006
+ <Tippy
1007
+ move={poke ?? cues.move}
1008
+ facing={facing}
1009
+ scale={scale}
1010
+ lookAt={cues.look}
1011
+ followPointer={!cues.look}
1012
+ keystrokes={cues.keys}
1013
+ draggable={false}
1014
+ // A press would move focus out of the field, and a drag would start a selection.
1015
+ onMouseDown={(event) => event.preventDefault()}
1016
+ onPointerDown={async (event) => {
1017
+ event.preventDefault();
1018
+ if (poking.current) return;
1019
+ poking.current = true;
1020
+ const { move, ms } = POKES[pokes.current++ % POKES.length]!;
1021
+ setPoke(move);
1022
+ await wait(ms);
1023
+ poking.current = false;
1024
+ setPoke(null);
1025
+ }}
1026
+ className="shrink-0 cursor-pointer touch-manipulation"
1027
+ />
1028
+ );
1029
+ }
1030
+
1031
+ /** Whether the page runs right to left, read once before the first paint. */
1032
+ function useRtl(ref: React.RefObject<HTMLElement | null>) {
1033
+ const [rtl, setRtl] = React.useState(false);
1034
+ React.useLayoutEffect(() => {
1035
+ if (ref.current) setRtl(getComputedStyle(ref.current).direction === "rtl");
1036
+ }, [ref]);
1037
+ return rtl;
1038
+ }
1039
+
1040
+ /* ── The frames: in a card, on the page, or with Tippy ──────────────────────────────────────── */
1041
+
1042
+ interface FrameProps {
1043
+ layout: Layout;
1044
+ mode: Mode;
1045
+ step: StepName;
1046
+ onSwitch: (to: Mode) => void;
1047
+ children: React.ReactNode;
1048
+ }
1049
+
1050
+ /**
1051
+ * The frame stays while the flows change inside it: switching between sign in and sign up remounts
1052
+ * the flow, never the logo, the picture or Tippy, and nothing here is measured, so nothing jumps.
1053
+ */
1054
+ function Frame(props: FrameProps) {
1055
+ return props.layout === "card" ? <CardFrame {...props} /> : <PageFrame {...props} />;
1056
+ }
1057
+
1058
+ /** Card: the logo, a 20px card and the way to the other flow under it, on a blueprint grid that fades out. */
1059
+ function CardFrame({ mode, step, onSwitch, children }: FrameProps) {
1060
+ return (
1061
+ <div className="relative isolate flex w-full justify-center py-6">
1062
+ <div
1063
+ aria-hidden
1064
+ className="blueprint pointer-events-none absolute inset-x-0 -inset-y-12 -z-1 [mask-image:radial-gradient(ellipse_50%_55%_at_50%_50%,#000_25%,transparent_80%)]"
1065
+ />
1066
+ <div data-layout="card" className="flex w-full flex-col items-center gap-8 py-2">
1067
+ <Wordmark href="#home" mark={<AcmeMark />} size={24}>
1068
+ Acme
1069
+ </Wordmark>
1070
+ <Card variant="card" className="w-full max-w-[27rem]">
1071
+ {children}
1072
+ {step !== "done" && (
1073
+ <div className="flex flex-col gap-4">
1074
+ <Separator />
1075
+ <DemoHint mode={mode} step={step} />
1076
+ </div>
1077
+ )}
1078
+ </Card>
1079
+ <div className="flex flex-col items-center gap-4 text-center">
1080
+ {step === "first" && <ModeLine mode={mode} onSwitch={onSwitch} />}
1081
+ <LegalLinks />
1082
+ </div>
1083
+ </div>
1084
+ </div>
1085
+ );
1086
+ }
1087
+
1088
+ /**
1089
+ * Page and Tippy: no card. The form on the start side under the logo, a vertical hairline, and on
1090
+ * the other half the flow's picture, or Tippy, large and standing still. Below 48rem one column:
1091
+ * the form first; the picture is left out, and Tippy stands under the form, smaller.
1092
+ */
1093
+ function PageFrame({ layout, mode, step, onSwitch, children }: FrameProps) {
1094
+ const tippy = layout === "tippy";
1095
+ const rootRef = React.useRef<HTMLDivElement>(null);
1096
+ const formRef = React.useRef<HTMLDivElement>(null);
1097
+ const rtl = useRtl(rootRef);
1098
+ const cues = useTippyCues(formRef, step === "done", tippy);
1099
+ return (
1100
+ <StepHeading.Provider value="h1">
1101
+ <div ref={rootRef} className="@container/auth flex w-full justify-center py-6">
1102
+ <div
1103
+ data-layout={layout}
1104
+ className="grid w-full max-w-5xl @3xl/auth:grid-cols-[minmax(0,26rem)_minmax(0,1fr)]"
1105
+ >
1106
+ {/* The form column; from 48rem the hairline runs down its end side, between it and the other half. */}
1107
+ <div
1108
+ ref={formRef}
1109
+ className="flex min-w-0 flex-col gap-8 @3xl/auth:border-e @3xl/auth:border-border/60 @3xl/auth:py-2 @3xl/auth:pe-16"
1110
+ >
1111
+ <Wordmark href="#home" mark={<AcmeMark />} size={24}>
1112
+ Acme
1113
+ </Wordmark>
1114
+ <Card variant="plain" className="pt-8 pb-0">
1115
+ {children}
1116
+ {step !== "done" && (
1117
+ <div className="flex flex-col gap-4 border-t border-border/60 pt-5">
1118
+ {step === "first" && <ModeLine mode={mode} onSwitch={onSwitch} />}
1119
+ <DemoHint mode={mode} step={step} />
1120
+ </div>
1121
+ )}
1122
+ </Card>
1123
+ </div>
1124
+ {tippy ? (
1125
+ <>
1126
+ {/* Narrow: under the form, facing along the line. */}
1127
+ <div className="flex justify-center pt-8 @3xl/auth:hidden">
1128
+ <PokableTippy cues={cues} facing={rtl ? "left" : "right"} scale={2} />
1129
+ </div>
1130
+ {/* Wide: in the other half, facing the form, centred in a box of its own height, so it stays
1131
+ put while the form grows and shrinks; larger again from 64rem. Each size is its own
1132
+ Tippy, so none is ever measured or resized, and the hidden one does not draw. */}
1133
+ <div className="hidden min-w-0 items-start ps-16 @3xl/auth:flex">
1134
+ <div className="flex h-[40rem] w-full items-center justify-center">
1135
+ <div className="contents @5xl/auth:hidden">
1136
+ <PokableTippy cues={cues} facing={rtl ? "right" : "left"} scale={3} />
1137
+ </div>
1138
+ <div className="hidden @5xl/auth:contents">
1139
+ <PokableTippy cues={cues} facing={rtl ? "right" : "left"} scale={4} />
1140
+ </div>
1141
+ </div>
1142
+ </div>
1143
+ </>
1144
+ ) : (
1145
+ <ArtAside mode={mode} />
1146
+ )}
1147
+ </div>
1148
+ </div>
1149
+ </StepHeading.Provider>
1150
+ );
1151
+ }
1152
+
1153
+ const stepOrder: StepName[] = ["first", "code", "done"];
1154
+
1155
+ /**
1156
+ * A new step comes in from the way people are going: from the end when they go on, from the start
1157
+ * when they go back (so in a right-to-left page, from the left when they go on). No exit, no
1158
+ * stagger; under reduced motion only the fade is left. A flow switched to fades in.
1159
+ */
1160
+ const stepEntrance = {
1161
+ forward:
1162
+ "transition-[opacity,translate] duration-[calc(var(--duration-fade)*4/3),calc(var(--duration)*4/3)] ease-(--ease) starting:opacity-0 starting:translate-x-3 rtl:starting:-translate-x-3",
1163
+ back: "transition-[opacity,translate] duration-[calc(var(--duration-fade)*4/3),calc(var(--duration)*4/3)] ease-(--ease) starting:opacity-0 starting:-translate-x-3 rtl:starting:translate-x-3",
1164
+ fade: "transition-opacity duration-[calc(var(--duration-fade)*4/3)] ease-(--ease) starting:opacity-0",
1165
+ };
1166
+
1167
+ /** Which way the last step change went, worked out while rendering: null until the first one. */
1168
+ function useDirectionOfTravel(step: StepName) {
1169
+ const [shown, setShown] = React.useState(step);
1170
+ const [direction, setDirection] = React.useState<"forward" | "back" | null>(null);
1171
+ if (shown !== step) {
1172
+ setShown(step);
1173
+ setDirection(stepOrder.indexOf(step) > stepOrder.indexOf(shown) ? "forward" : "back");
1174
+ }
1175
+ return direction;
1176
+ }
1177
+
1178
+ /** The steps of a flow. Keyed by step, so each step mounts afresh and plays its entrance once. */
1179
+ function Steps({ step, enter, children }: { step: StepName; enter?: boolean; children: React.ReactNode }) {
1180
+ const direction = useDirectionOfTravel(step);
1181
+ const entrance = direction ? stepEntrance[direction] : enter ? stepEntrance.fade : "";
1182
+ return (
1183
+ <div key={step} className={`flex flex-col gap-6 ${entrance}`}>
1184
+ {children}
1185
+ </div>
1186
+ );
1187
+ }
1188
+
1189
+ /* ── The flows ──────────────────────────────────────────────────────────────────────────────── */
1190
+
1191
+ interface FlowProps {
1192
+ onSwitch: (to: Mode, email?: string) => void;
1193
+ /** Tells the frame which step is shown, for the hint, the way to the other flow and Tippy. */
1194
+ onStep: (step: StepName) => void;
1195
+ /** Fade the first step in: the flow was switched to. */
1196
+ enter?: boolean;
1197
+ defaultEmail?: string;
1198
+ defaultName?: string;
1199
+ defaultPassword?: string;
1200
+ defaultErrors?: Errors;
1201
+ }
1202
+
1203
+ /** Who a provider signs in, in the demo. */
1204
+ const PROVIDER_ACCOUNT: Account = { name: "Alex Weber", email: "alex@company.de" };
1205
+
1206
+ type SignInStep =
1207
+ | { name: "credentials"; returning: boolean }
1208
+ | { name: "code"; email: string }
1209
+ | { name: "done"; email: string; provider?: Provider };
1210
+
1211
+ /** Password, then code, then signed in. The defaults only fill the first visit to step one. */
1212
+ function SignInFlow({ onStep, enter, defaultEmail = "", defaultPassword, defaultErrors }: FlowProps) {
1213
+ const [step, setStep] = React.useState<SignInStep>({ name: "credentials", returning: false });
1214
+ const [email, setEmail] = React.useState(defaultEmail);
1215
+ const go = (next: SignInStep) => {
1216
+ setStep(next);
1217
+ onStep(next.name === "credentials" ? "first" : next.name);
1218
+ };
1219
+
1220
+ return (
1221
+ <Steps step={step.name === "credentials" ? "first" : step.name} enter={enter}>
1222
+ {step.name === "credentials" && (
1223
+ <CredentialsStep
1224
+ key={step.returning ? "returning" : "first"}
1225
+ defaultEmail={email}
1226
+ defaultPassword={step.returning ? undefined : defaultPassword}
1227
+ defaultErrors={step.returning ? undefined : defaultErrors}
1228
+ autoFocusEmail={step.returning}
1229
+ onContinue={(value) => {
1230
+ setEmail(value);
1231
+ go({ name: "code", email: value });
1232
+ }}
1233
+ onProvider={(provider) => go({ name: "done", email: PROVIDER_ACCOUNT.email, provider })}
1234
+ />
1235
+ )}
1236
+ {step.name === "code" && (
1237
+ <CodeStep
1238
+ email={step.email}
1239
+ copy={signInCode}
1240
+ autoFocusCode
1241
+ onBack={() => go({ name: "credentials", returning: true })}
1242
+ onVerified={() => go({ name: "done", email: step.email })}
1243
+ />
1244
+ )}
1245
+ {step.name === "done" && (
1246
+ <SignedIn
1247
+ email={step.email}
1248
+ provider={step.provider}
1249
+ onSignOut={() => {
1250
+ setEmail("");
1251
+ go({ name: "credentials", returning: true });
1252
+ }}
1253
+ />
1254
+ )}
1255
+ </Steps>
1256
+ );
1257
+ }
1258
+
1259
+ type SignUpStep =
1260
+ | { name: "details"; returning: boolean }
1261
+ | { name: "code"; account: Account }
1262
+ | { name: "done"; account: Account; provider?: Provider };
1263
+
1264
+ /** Details, then the code, then the account. The defaults only fill the first visit to step one. */
1265
+ function SignUpFlow({ onSwitch, onStep, enter, defaultEmail, defaultName, defaultErrors }: FlowProps) {
1266
+ const [step, setStep] = React.useState<SignUpStep>({ name: "details", returning: false });
1267
+ const [account, setAccount] = React.useState<Partial<Account>>({
1268
+ name: defaultName,
1269
+ email: defaultEmail,
1270
+ });
1271
+ const go = (next: SignUpStep) => {
1272
+ setStep(next);
1273
+ onStep(next.name === "details" ? "first" : next.name);
1274
+ };
1275
+
1276
+ return (
1277
+ <Steps step={step.name === "details" ? "first" : step.name} enter={enter}>
1278
+ {step.name === "details" && (
1279
+ <DetailsStep
1280
+ key={step.returning ? "returning" : "first"}
1281
+ defaults={account}
1282
+ defaultErrors={step.returning ? undefined : defaultErrors}
1283
+ autoFocusEmail={step.returning}
1284
+ onSignIn={(email) => onSwitch("sign-in", email)}
1285
+ onCreated={(value) => {
1286
+ setAccount(value);
1287
+ go({ name: "code", account: value });
1288
+ }}
1289
+ onProvider={(provider) => go({ name: "done", account: PROVIDER_ACCOUNT, provider })}
1290
+ />
1291
+ )}
1292
+ {step.name === "code" && (
1293
+ <CodeStep
1294
+ email={step.account.email}
1295
+ copy={signUpCode}
1296
+ autoFocusCode
1297
+ onBack={() => go({ name: "details", returning: true })}
1298
+ onVerified={() => go({ name: "done", account: step.account })}
1299
+ />
1300
+ )}
1301
+ {step.name === "done" && <Created account={step.account} provider={step.provider} />}
1302
+ </Steps>
1303
+ );
1304
+ }
1305
+
1306
+ /** The demo's Flow control, shown by the docs frame in its toolbar: `flow="in"` or `"up"`. */
1307
+ type Flow = "in" | "up";
1308
+
1309
+ const flowControls = [
1310
+ {
1311
+ name: "flow",
1312
+ label: "Flow",
1313
+ options: [
1314
+ { value: "in", label: "Sign in" },
1315
+ { value: "up", label: "Sign up" },
1316
+ ],
1317
+ },
1318
+ ];
1319
+
1320
+ const modeOf = (flow: Flow): Mode => (flow === "up" ? "sign-up" : "sign-in");
1321
+
1322
+ interface AuthProps extends Omit<FlowProps, "onSwitch" | "onStep" | "enter"> {
1323
+ /** The flow to show; changing it starts that flow afresh. Defaults to sign in. */
1324
+ flow?: Flow;
1325
+ layout?: Layout;
1326
+ }
1327
+
1328
+ /**
1329
+ * Sign in and sign up in one block. The links between the flows switch the mode, and so does the
1330
+ * frame's Flow control; a new mode starts its flow from the first step, carrying the email over when
1331
+ * a taken email's "Sign in instead" sent it. The frame stays; only the flow inside it starts over.
1332
+ */
1333
+ function Auth({ flow = "in", layout = "card", ...defaults }: AuthProps) {
1334
+ const [mode, setMode] = React.useState(modeOf(flow));
1335
+ const [step, setStep] = React.useState<StepName>("first");
1336
+ // Each switch of mode is a fresh flow; the first one gets the demo's defaults.
1337
+ const [visit, setVisit] = React.useState<{ n: number; email?: string }>({ n: 0 });
1338
+ const flowDefaults = visit.n === 0 ? defaults : { defaultEmail: visit.email };
1339
+
1340
+ function switchMode(to: Mode, email?: string) {
1341
+ if (to === mode) return;
1342
+ setMode(to);
1343
+ setStep("first");
1344
+ setVisit((v) => ({ n: v.n + 1, email }));
1345
+ }
1346
+
1347
+ // The frame's control changed: that flow, from its first step.
1348
+ const [asked, setAsked] = React.useState(flow);
1349
+ if (asked !== flow) {
1350
+ setAsked(flow);
1351
+ switchMode(modeOf(flow));
1352
+ }
1353
+
1354
+ const Flow = mode === "sign-in" ? SignInFlow : SignUpFlow;
1355
+ return (
1356
+ <Frame layout={layout} mode={mode} step={step} onSwitch={switchMode}>
1357
+ <Flow
1358
+ key={`${mode}-${visit.n}`}
1359
+ onSwitch={switchMode}
1360
+ onStep={setStep}
1361
+ enter={visit.n > 0}
1362
+ {...flowDefaults}
1363
+ />
1364
+ </Frame>
1365
+ );
1366
+ }
1367
+
1368
+ /* ── Demos ──────────────────────────────────────────────────────────────────────────────────── */
1369
+
1370
+ export function SignInCard({ flow }: { flow?: Flow }) {
1371
+ return <Auth flow={flow} />;
1372
+ }
1373
+ SignInCard.controls = flowControls;
1374
+ ```
1375
+
1376
+ Two ways into a fictional notes app, in three versions: in a card, on the page beside a picture, and beside Tippy. The demo's **Flow** control, and the links between the flows, switch sign in and sign up; only the form fades in anew.
1377
+
1378
+ - **Sign in**: Google, GitHub and Apple icon buttons, "or", email and password, then a 6-digit emailed code that signs in on the last digit.
1379
+ - **Sign up**: the same providers, then name, work email, password and the terms, then a code that verifies the email.
1380
+
1381
+ A provider skips the code and shows a spinner while it opens. Nothing is sent: the password `wrong` is refused, `taken@example.com` is taken, the code is `246810`, and providers finish as Alex Weber.
1382
+
1383
+ ## Usage
1384
+
1385
+ ```tsx
1386
+ import { Button, Field, FieldError, FieldLabel, Form, FormActions, Input } from "@zonsh/ui";
1387
+
1388
+ // Server errors go into `errors`, keyed by field name, and show on their field.
1389
+ <Form errors={errors} onFormSubmit={signIn}>
1390
+ <Field name="email">
1391
+ <FieldLabel>Work email</FieldLabel>
1392
+ <Input required type="email" autoComplete="username" />
1393
+ <FieldError match="valueMissing">Enter the email address you signed up with.</FieldError>
1394
+ </Field>
1395
+ <Field name="password">
1396
+ <FieldLabel>Password</FieldLabel>
1397
+ <Input required type="password" autoComplete="current-password" />
1398
+ {errors.password && <FieldError match>{errors.password}</FieldError>}
1399
+ </Field>
1400
+ <FormActions>
1401
+ <Button type="submit" loading={pending} loadingLabel="Checking your password">
1402
+ Continue
1403
+ </Button>
1404
+ </FormActions>
1405
+ </Form>;
1406
+ ```
1407
+
1408
+ - `Form.errors` — server errors by field name, shown on that field.
1409
+ - `Button.loading` / `loadingLabel` — the pending submit, named, its width kept.
1410
+ - `OtpField.autoSubmit` — submits on the last digit.
1411
+
1412
+ ## When to use
1413
+
1414
+ - **Card** when the form shares the screen or sits in a dialog; **On the page** when the page is the form; **With Tippy** for a lighter voice.
1415
+ - Offer only the providers you support; with none, drop the buttons and the "or".
1416
+ - Password only: drop the code step (Form → Sign in). A magic code: start at the code step. Invitation only: leave sign-up out and say how to get invited.
1417
+ - After sign-up, continue with the Onboarding block.
1418
+
1419
+ ## Card
1420
+
1421
+ A 27rem card (full width on a phone) under the logo on a fading `blueprint` grid, the other flow and legal links below. A new step fades in from the end going on, from the start going back. "Send a new code in 30s" counts in tabular figures.
1422
+
1423
+ The other steps:
1424
+
1425
+ ```tsx
1426
+ import {
1427
+ Button,
1428
+ Card,
1429
+ CardHeader,
1430
+ CardTitle,
1431
+ Checkbox,
1432
+ Field,
1433
+ FieldDescription,
1434
+ FieldError,
1435
+ FieldLabel,
1436
+ Form,
1437
+ FormActions,
1438
+ Input,
1439
+ InputGroup,
1440
+ InputGroupAddon,
1441
+ InputGroupInput,
1442
+ InputGroupPasswordToggle,
1443
+ OtpField,
1444
+ Separator,
1445
+ Tooltip,
1446
+ TooltipContent,
1447
+ TooltipProvider,
1448
+ TooltipTrigger,
1449
+ } from "@zonsh/ui";
1450
+
1451
+ // Sign in, step one: email and password. Server errors go into `errors`, keyed by field name.
1452
+ // `GoogleMark`, `continueWith` and the state are written out in full in the example above.
1453
+ <Card className="w-full max-w-[27rem]">
1454
+ <CardHeader>
1455
+ <p className="eyebrow">Step 1 of 2</p>
1456
+ <CardTitle render={<h2 />}>Sign in</CardTitle>
1457
+ </CardHeader>
1458
+ <TooltipProvider>
1459
+ <div className="grid grid-cols-3 gap-2">
1460
+ <Tooltip>
1461
+ <TooltipTrigger
1462
+ render={
1463
+ <Button
1464
+ variant="secondary"
1465
+ className="w-full"
1466
+ aria-label="Continue with Google"
1467
+ onClick={() => continueWith("google")}
1468
+ />
1469
+ }
1470
+ >
1471
+ <GoogleMark aria-hidden className="size-[18px]" />
1472
+ </TooltipTrigger>
1473
+ <TooltipContent>Continue with Google</TooltipContent>
1474
+ </Tooltip>
1475
+ {/* GitHub and Apple the same */}
1476
+ </div>
1477
+ </TooltipProvider>
1478
+ <Separator label="or" />
1479
+ {/* the email and password form from Usage */}
1480
+ </Card>;
1481
+
1482
+ // Sign up, step one, without a card: a `plain` Card is a top hairline and whitespace.
1483
+ <Card variant="plain">
1484
+ <Form errors={errors} onFormSubmit={createAccount}>
1485
+ <Field name="email">
1486
+ <FieldLabel>Work email</FieldLabel>
1487
+ <Input required type="email" autoComplete="email" />
1488
+ {errors.email && (
1489
+ <FieldError match>
1490
+ This email already has an account.{" "}
1491
+ <a href="/sign-in" className="link">
1492
+ Sign in instead
1493
+ </a>
1494
+ , or use a different email.
1495
+ </FieldError>
1496
+ )}
1497
+ </Field>
1498
+ <Field name="password">
1499
+ <FieldLabel>Password</FieldLabel>
1500
+ <InputGroup>
1501
+ <InputGroupInput
1502
+ required
1503
+ minLength={10}
1504
+ type={visible ? "text" : "password"}
1505
+ autoComplete="new-password"
1506
+ />
1507
+ <InputGroupAddon align="inline-end">
1508
+ <InputGroupPasswordToggle visible={visible} onVisibleChange={setVisible} />
1509
+ </InputGroupAddon>
1510
+ </InputGroup>
1511
+ <FieldDescription>At least 10 characters. A few words you will remember work well.</FieldDescription>
1512
+ <FieldError match="tooShort">That is shorter than 10 characters. Add a word or two.</FieldError>
1513
+ </Field>
1514
+ <Field name="terms">
1515
+ <FieldLabel>
1516
+ <Checkbox required />
1517
+ <span>
1518
+ I agree to the{" "}
1519
+ <a href="/terms" className="link">
1520
+ terms
1521
+ </a>
1522
+ .
1523
+ </span>
1524
+ </FieldLabel>
1525
+ <FieldError match="valueMissing" className="ps-7">
1526
+ Tick this box to create the account.
1527
+ </FieldError>
1528
+ </Field>
1529
+ <FormActions>
1530
+ <Button type="submit">Create account</Button>
1531
+ </FormActions>
1532
+ </Form>
1533
+ </Card>;
1534
+
1535
+ // Step two, in both flows: the code. `autoSubmit` sends the form when the last digit is in.
1536
+ <Form errors={errors} onFormSubmit={verify}>
1537
+ <Field name="code">
1538
+ <FieldLabel>Sign-in code</FieldLabel>
1539
+ <OtpField length={6} required autoSubmit />
1540
+ {errors.code && <FieldError match>{errors.code}</FieldError>}
1541
+ </Field>
1542
+ <FormActions align="between">
1543
+ <Button type="button" variant="link" onClick={back}>
1544
+ Use a different email
1545
+ </Button>
1546
+ <Button type="submit">Verify and sign in</Button>
1547
+ </FormActions>
1548
+ </Form>;
1549
+ ```
1550
+
1551
+ Native constraints catch empty, malformed and short fields, each with its `FieldError match`; what only the server knows goes into `errors` on its field, cleared on edit. Provider marks are 18px inline SVGs in the current ink.
1552
+
1553
+ ## Examples
1554
+
1555
+ ### On the page
1556
+
1557
+ The form in a 26rem column under the logo, a hairline, then a duotone picture in a 20px frame per flow:
1558
+
1559
+ - **Sign in**: a street at dusk under the crescent, then "Welcome back. Your notes are where you left them."
1560
+ - **Sign up**: "Start with a notebook of your own. Bring the team in when you are ready.", a field of flowers, then three indexed lines on what a new account starts with.
1561
+
1562
+ The halves cross-fade in one grid cell. Pictures: `files/sign-in-town.webp`, `files/sign-up-flowers.webp` (1200px, about 230 KB). The form comes first in source order; below 48rem of the block's width the picture is left out. The steps sit in a `plain` Card.
1563
+
1564
+ ```tsx
1565
+ import { Button, Card, CardDescription, CardHeader, CardTitle, Checkbox, Field, FieldDescription, FieldError, FieldLabel, Form, FormActions, Input, InputGroup, InputGroupAddon, InputGroupInput, InputGroupPasswordToggle, OtpField, Separator, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, TwoTone } from "@zonsh/ui";
1566
+ import { Wordmark } from "@zonsh/ui/brand";
1567
+ import { Tippy, type TippyMove } from "@zonsh/ui/tippy";
1568
+ import { ArrowLeftIcon, CheckIcon } from "lucide-react";
1569
+ import * as React from "react";
1570
+
1571
+ // AcmeMark, DEMO_CODE, WRONG_PASSWORD, TAKEN_EMAIL, LATENCY, RESEND_COOLDOWN, MIN_PASSWORD, WRONG_PASSWORD_ERROR, Errors, Mode, Layout, StepHeading, useStepHeading, useWait, without, SubmitButton, Provider, providerMarks, providers, SocialSignIn, ModeLink, CredentialsStepProps, CredentialsStep, SignedIn, Account, DetailsStepProps, DetailsStep, Created, CodeCopy, signInCode, signUpCode, CodeStepProps, CodeStep, StepName, DemoHint, ModeLine, LegalLinks, FILES, Layer, picture, ArtAside, measurer, caretOf, PASSWORD, useTippyCues, POKES, PokableTippy, useRtl, FrameProps, Frame, CardFrame, PageFrame, stepOrder, stepEntrance, useDirectionOfTravel, Steps, FlowProps, PROVIDER_ACCOUNT, SignInStep, SignInFlow, SignUpStep, SignUpFlow, Flow, flowControls, modeOf, AuthProps, Auth: as in the first example on this page that uses them.
1572
+
1573
+ export function OnThePage({ flow }: { flow?: Flow }) {
1574
+ return <Auth flow={flow} layout="page" />;
1575
+ }
1576
+ OnThePage.controls = flowControls;
1577
+ ```
1578
+
1579
+ ### With Tippy
1580
+
1581
+ Tippy in place of the picture (4 CSS px per sprite pixel from 64rem, 3 below; under the form on a phone), never leaving its place. It reads the form (focus, typing, the password field's type, `aria-busy`, `aria-invalid`): watches the caret, looks away while the password shows, thinks while pending, shakes its head at an error, hops when done; poked, it giggles. Decoration only. See [Tippy](tippy.md).
1582
+
1583
+ ```tsx
1584
+ import { Button, Card, CardDescription, CardHeader, CardTitle, Checkbox, Field, FieldDescription, FieldError, FieldLabel, Form, FormActions, Input, InputGroup, InputGroupAddon, InputGroupInput, InputGroupPasswordToggle, OtpField, Separator, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, TwoTone } from "@zonsh/ui";
1585
+ import { Wordmark } from "@zonsh/ui/brand";
1586
+ import { Tippy, type TippyMove } from "@zonsh/ui/tippy";
1587
+ import { ArrowLeftIcon, CheckIcon } from "lucide-react";
1588
+ import * as React from "react";
1589
+
1590
+ // AcmeMark, DEMO_CODE, WRONG_PASSWORD, TAKEN_EMAIL, LATENCY, RESEND_COOLDOWN, MIN_PASSWORD, WRONG_PASSWORD_ERROR, Errors, Mode, Layout, StepHeading, useStepHeading, useWait, without, SubmitButton, Provider, providerMarks, providers, SocialSignIn, ModeLink, CredentialsStepProps, CredentialsStep, SignedIn, Account, DetailsStepProps, DetailsStep, Created, CodeCopy, signInCode, signUpCode, CodeStepProps, CodeStep, StepName, DemoHint, ModeLine, LegalLinks, FILES, Layer, picture, ArtAside, measurer, caretOf, PASSWORD, useTippyCues, POKES, PokableTippy, useRtl, FrameProps, Frame, CardFrame, PageFrame, stepOrder, stepEntrance, useDirectionOfTravel, Steps, FlowProps, PROVIDER_ACCOUNT, SignInStep, SignInFlow, SignUpStep, SignUpFlow, Flow, flowControls, modeOf, AuthProps, Auth: as in the first example on this page that uses them.
1591
+
1592
+ export function WithTippy({ flow }: { flow?: Flow }) {
1593
+ return <Auth flow={flow} layout="tippy" />;
1594
+ }
1595
+ WithTippy.controls = flowControls;
1596
+ ```
1597
+
1598
+ ## The parts
1599
+
1600
+ | Part | Page | Job |
1601
+ | ------------ | ----------- | ----------------------------------------------------------------------------------------- |
1602
+ | `Wordmark` | Logo | Your product's mark and name above the card or the form column, linking home — not zon's |
1603
+ | `Card` | Cards | `default`: the 20px object the steps sit in. `plain`: the same steps with no box |
1604
+ | `Button` | Button | The providers (secondary, icon only), the one primary per step, links for back and resend |
1605
+ | `Tooltip` | Tooltip | "Continue with Google" on each provider's icon button |
1606
+ | `Separator` | Separator | The "or" between the providers and the email |
1607
+ | `Form` | Form | Native validation, server errors by field name, the actions row |
1608
+ | `Field` | Field | Label, control, description and each error, linked for screen readers |
1609
+ | `Input` | Input | The name and the email |
1610
+ | `InputGroup` | Input Group | The password with a ghost show / hide button inside the field |
1611
+ | `Checkbox` | Checkbox | Agreement to the terms, required to create an account |
1612
+ | `OtpField` | OTP Field | The 6-digit code: one recessed square per digit, paste welcome |
1613
+ | `TwoTone` | Typography | The line beside the picture on the page, in Licht, its second half muted |
1614
+ | `Tippy` | Tippy | On the other half in the Tippy version, looking where the form tells it |
1615
+
1616
+ ## Brand rules
1617
+
1618
+ - **Do** keep one primary per step, named for the outcome ("Continue", "Verify and sign in"); providers secondary; back, resend and "Forgot your password?" are links.
1619
+ - **Do** name each provider in label and tooltip; never its colours.
1620
+ - **Do** put the server's answer on its field with the way forward: "Sign in instead".
1621
+ - **Do** state password rules in a `FieldDescription` and the error in the same words; say where the code went, and allow paste.
1622
+ - **Do** let the form stand on the ground when it is the page.
1623
+ - **Don't** disable the submit to signal missing fields.
1624
+ - **Don't** reveal who has an account if accounts are private: "Does not match this email"; for sign up, accept and email the existing account.
1625
+ - **Don't** add user numbers, ratings or quotes beside the form.
1626
+ - **Don't** give Tippy words or let it move about.
1627
+ - **Don't** colour the card: red for errors, green for "Signed in", each with text.
1628
+
1629
+ ## Accessibility
1630
+
1631
+ - On the page each step's title is the page's `h1`; in a card it is an `h2`.
1632
+ - Every control has a visible `FieldLabel`; errors and password rules are linked through `aria-describedby`.
1633
+ - Provider marks are `aria-hidden`; a pending provider button is `aria-busy`, named "Opening Google".
1634
+ - A wrong password, or a taken email, is selected for retyping; a wrong code empties the digits and focuses the first.
1635
+ - The code step focuses the first digit; going back keeps and focuses the email and clears the password. At the end focus moves to the "Welcome" heading.
1636
+ - The pending submit is `aria-busy` with a labelled spinner; repeats are ignored. Legal links reach 24px tall.
1637
+ - "We sent a new code" is `role="status"`; the resend link stays focusable in its cooldown.
1638
+ - `autoComplete`: `"username"`, `"current-password"`; `"name"`, `"email"`, `"new-password"`; `"one-time-code"`.
1639
+ - Pictures have alt text; the faded one is hidden. Tippy is hidden and takes no focus; under reduced motion only its eyes move.