velvetkit 0.2.2 → 0.4.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 (458) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +80 -0
  3. data/README.md +30 -8
  4. data/lib/generators/velvetkit/add/add_generator.rb +77 -0
  5. data/lib/generators/velvetkit/helpers.rb +29 -2
  6. data/lib/generators/velvetkit/icons/icons_generator.rb +71 -0
  7. data/lib/generators/velvetkit/install/install_generator.rb +9 -12
  8. data/lib/velvetkit/icons.rb +148 -0
  9. data/lib/velvetkit/registry.rb +5 -2
  10. data/lib/velvetkit/version.rb +4 -1
  11. data/lib/velvetkit.rb +8 -0
  12. data/registry/app/assets/tailwind/velvetkit.css +90 -155
  13. data/registry/app/components/ui/alert.rb +1 -1
  14. data/registry/app/components/ui/chart.html.erb +47 -0
  15. data/registry/app/components/ui/chart.rb +177 -0
  16. data/registry/app/components/ui/command/group.rb +27 -0
  17. data/registry/app/components/ui/command/item.rb +64 -0
  18. data/registry/app/components/ui/command.html.erb +41 -0
  19. data/registry/app/components/ui/command.rb +122 -0
  20. data/registry/app/components/ui/confirm_dialog.html.erb +13 -0
  21. data/registry/app/components/ui/confirm_dialog.rb +55 -0
  22. data/registry/app/components/ui/date_picker.html.erb +58 -64
  23. data/registry/app/components/ui/date_picker.rb +199 -75
  24. data/registry/app/components/ui/empty_state.html.erb +20 -0
  25. data/registry/app/components/ui/empty_state.rb +46 -0
  26. data/registry/app/components/ui/file_field.html.erb +14 -4
  27. data/registry/app/components/ui/file_field.rb +179 -28
  28. data/registry/app/components/ui/gallery/image.rb +20 -0
  29. data/registry/app/components/ui/gallery.html.erb +52 -0
  30. data/registry/app/components/ui/gallery.rb +164 -0
  31. data/registry/app/components/ui/icon.html.erb +1 -1
  32. data/registry/app/components/ui/icon.rb +80 -8
  33. data/registry/app/components/ui/kbd.html.erb +27 -0
  34. data/registry/app/components/ui/kbd.rb +134 -0
  35. data/registry/app/components/ui/number_input.html.erb +11 -0
  36. data/registry/app/components/ui/number_input.rb +103 -0
  37. data/registry/app/components/ui/password_input.html.erb +1 -1
  38. data/registry/app/components/ui/progress/segment.rb +25 -0
  39. data/registry/app/components/ui/progress.html.erb +25 -0
  40. data/registry/app/components/ui/progress.rb +182 -0
  41. data/registry/app/components/ui/select.html.erb +24 -5
  42. data/registry/app/components/ui/select.rb +44 -5
  43. data/registry/app/components/ui/stepper/step.html.erb +27 -0
  44. data/registry/app/components/ui/stepper/step.rb +213 -0
  45. data/registry/app/components/ui/stepper.html.erb +19 -0
  46. data/registry/app/components/ui/stepper.rb +145 -0
  47. data/registry/app/components/ui/theme_toggle.rb +2 -4
  48. data/registry/app/components/ui/timeline/item.html.erb +21 -0
  49. data/registry/app/components/ui/timeline/item.rb +145 -0
  50. data/registry/app/components/ui/timeline.html.erb +1 -0
  51. data/registry/app/components/ui/timeline.rb +42 -0
  52. data/registry/app/components/ui/toast.rb +6 -6
  53. data/registry/app/components/ui/toggle_group/item.html.erb +1 -0
  54. data/registry/app/components/ui/toggle_group/item.rb +85 -0
  55. data/registry/app/components/ui/toggle_group.html.erb +1 -0
  56. data/registry/app/components/ui/toggle_group.rb +79 -0
  57. data/registry/app/javascript/chart_js.ts +37 -0
  58. data/registry/app/javascript/controllers/ui/_internal/date_format.ts +74 -0
  59. data/registry/app/javascript/controllers/ui/_internal/shortcut.ts +80 -0
  60. data/registry/app/javascript/controllers/ui/chart_controller.ts +585 -0
  61. data/registry/app/javascript/controllers/ui/command_controller.ts +454 -0
  62. data/registry/app/javascript/controllers/ui/confirm_dialog_controller.ts +110 -0
  63. data/registry/app/javascript/controllers/ui/date_picker_controller.ts +247 -82
  64. data/registry/app/javascript/controllers/ui/file_field_controller.ts +288 -16
  65. data/registry/app/javascript/controllers/ui/gallery_controller.ts +568 -0
  66. data/registry/app/javascript/controllers/ui/kbd_controller.ts +60 -0
  67. data/registry/app/javascript/controllers/ui/number_input_controller.ts +111 -0
  68. data/registry/app/javascript/controllers/ui/progress_controller.ts +87 -0
  69. data/registry/app/javascript/controllers/ui/select_controller.ts +198 -8
  70. data/registry/app/javascript/controllers/ui/stepper_controller.ts +187 -0
  71. data/registry/app/javascript/vanilla_calendar.ts +15 -0
  72. data/registry/components.yml +28 -5
  73. data/registry/config/locales/velvetkit.en.yml +84 -0
  74. data/registry/docs/agents.md +7 -4
  75. data/registry/icons/lucide/LICENSE +39 -0
  76. data/registry/icons/lucide/align-center.svg +17 -0
  77. data/registry/icons/lucide/align-left.svg +17 -0
  78. data/registry/icons/lucide/align-right.svg +17 -0
  79. data/registry/icons/lucide/arrow-left.svg +16 -0
  80. data/registry/icons/lucide/arrow-right.svg +16 -0
  81. data/registry/icons/lucide/badge-check.svg +16 -0
  82. data/registry/icons/lucide/bar-chart-3.svg +18 -0
  83. data/registry/icons/lucide/bell.svg +16 -0
  84. data/registry/icons/lucide/bold.svg +15 -0
  85. data/registry/icons/lucide/book-open.svg +16 -0
  86. data/registry/icons/lucide/calendar.svg +18 -0
  87. data/registry/icons/lucide/chart-column.svg +18 -0
  88. data/registry/icons/lucide/check.svg +15 -0
  89. data/registry/icons/lucide/chevron-down.svg +15 -0
  90. data/registry/icons/lucide/chevron-left.svg +15 -0
  91. data/registry/icons/lucide/chevron-right.svg +15 -0
  92. data/registry/icons/lucide/chevrons-up-down.svg +16 -0
  93. data/registry/icons/lucide/circle-alert.svg +17 -0
  94. data/registry/icons/lucide/circle-check.svg +16 -0
  95. data/registry/icons/lucide/cloud.svg +15 -0
  96. data/registry/icons/lucide/credit-card.svg +16 -0
  97. data/registry/icons/lucide/download.svg +17 -0
  98. data/registry/icons/lucide/ellipsis-vertical.svg +17 -0
  99. data/registry/icons/lucide/ellipsis.svg +17 -0
  100. data/registry/icons/lucide/eye-off.svg +18 -0
  101. data/registry/icons/lucide/eye.svg +16 -0
  102. data/registry/icons/lucide/file-plus.svg +18 -0
  103. data/registry/icons/lucide/file-text.svg +19 -0
  104. data/registry/icons/lucide/file.svg +16 -0
  105. data/registry/icons/lucide/folder-kanban.svg +18 -0
  106. data/registry/icons/lucide/folder.svg +15 -0
  107. data/registry/icons/lucide/git-branch.svg +18 -0
  108. data/registry/icons/lucide/globe.svg +17 -0
  109. data/registry/icons/lucide/graduation-cap.svg +17 -0
  110. data/registry/icons/lucide/grip-vertical.svg +20 -0
  111. data/registry/icons/lucide/home.svg +16 -0
  112. data/registry/icons/lucide/inbox.svg +16 -0
  113. data/registry/icons/lucide/info.svg +17 -0
  114. data/registry/icons/lucide/italic.svg +17 -0
  115. data/registry/icons/lucide/keyboard.svg +23 -0
  116. data/registry/icons/lucide/layout-dashboard.svg +18 -0
  117. data/registry/icons/lucide/layout-grid.svg +18 -0
  118. data/registry/icons/lucide/life-buoy.svg +20 -0
  119. data/registry/icons/lucide/list.svg +20 -0
  120. data/registry/icons/lucide/loader.svg +22 -0
  121. data/registry/icons/lucide/lock.svg +16 -0
  122. data/registry/icons/lucide/log-out.svg +17 -0
  123. data/registry/icons/lucide/mail.svg +16 -0
  124. data/registry/icons/lucide/menu.svg +17 -0
  125. data/registry/icons/lucide/message-circle.svg +15 -0
  126. data/registry/icons/lucide/minus.svg +15 -0
  127. data/registry/icons/lucide/monitor.svg +17 -0
  128. data/registry/icons/lucide/moon.svg +15 -0
  129. data/registry/icons/lucide/newspaper.svg +18 -0
  130. data/registry/icons/lucide/package.svg +18 -0
  131. data/registry/icons/lucide/panel-left.svg +16 -0
  132. data/registry/icons/lucide/pause.svg +16 -0
  133. data/registry/icons/lucide/percent.svg +17 -0
  134. data/registry/icons/lucide/plus.svg +16 -0
  135. data/registry/icons/lucide/printer.svg +17 -0
  136. data/registry/icons/lucide/qr-code.svg +26 -0
  137. data/registry/icons/lucide/receipt.svg +17 -0
  138. data/registry/icons/lucide/rocket.svg +18 -0
  139. data/registry/icons/lucide/rotate-cw.svg +16 -0
  140. data/registry/icons/lucide/search.svg +16 -0
  141. data/registry/icons/lucide/settings.svg +16 -0
  142. data/registry/icons/lucide/shield-check.svg +16 -0
  143. data/registry/icons/lucide/shield.svg +15 -0
  144. data/registry/icons/lucide/store.svg +17 -0
  145. data/registry/icons/lucide/sun-moon.svg +19 -0
  146. data/registry/icons/lucide/sun.svg +23 -0
  147. data/registry/icons/lucide/trash-2.svg +19 -0
  148. data/registry/icons/lucide/truck.svg +19 -0
  149. data/registry/icons/lucide/underline.svg +16 -0
  150. data/registry/icons/lucide/upload.svg +17 -0
  151. data/registry/icons/lucide/user-plus.svg +18 -0
  152. data/registry/icons/lucide/user.svg +16 -0
  153. data/registry/icons/lucide/users.svg +18 -0
  154. data/registry/icons/lucide/workflow.svg +17 -0
  155. data/registry/icons/lucide/x.svg +16 -0
  156. data/registry/icons/lucide/zoom-in.svg +18 -0
  157. data/registry/icons/lucide/zoom-out.svg +17 -0
  158. data/registry/icons/phosphor/LICENSE +21 -0
  159. data/registry/icons/phosphor/arrow-clockwise.svg +2 -0
  160. data/registry/icons/phosphor/arrow-left.svg +2 -0
  161. data/registry/icons/phosphor/arrow-right.svg +2 -0
  162. data/registry/icons/phosphor/bell.svg +2 -0
  163. data/registry/icons/phosphor/book-open.svg +2 -0
  164. data/registry/icons/phosphor/calendar-blank.svg +2 -0
  165. data/registry/icons/phosphor/caret-down.svg +2 -0
  166. data/registry/icons/phosphor/caret-left.svg +2 -0
  167. data/registry/icons/phosphor/caret-right.svg +2 -0
  168. data/registry/icons/phosphor/caret-up-down.svg +2 -0
  169. data/registry/icons/phosphor/chart-bar.svg +2 -0
  170. data/registry/icons/phosphor/chat-circle.svg +2 -0
  171. data/registry/icons/phosphor/check-circle.svg +2 -0
  172. data/registry/icons/phosphor/check.svg +2 -0
  173. data/registry/icons/phosphor/circle-half.svg +2 -0
  174. data/registry/icons/phosphor/cloud.svg +2 -0
  175. data/registry/icons/phosphor/credit-card.svg +2 -0
  176. data/registry/icons/phosphor/desktop.svg +2 -0
  177. data/registry/icons/phosphor/dots-six-vertical.svg +2 -0
  178. data/registry/icons/phosphor/dots-three-vertical.svg +2 -0
  179. data/registry/icons/phosphor/dots-three.svg +2 -0
  180. data/registry/icons/phosphor/download-simple.svg +2 -0
  181. data/registry/icons/phosphor/envelope.svg +2 -0
  182. data/registry/icons/phosphor/eye-slash.svg +2 -0
  183. data/registry/icons/phosphor/eye.svg +2 -0
  184. data/registry/icons/phosphor/file-plus.svg +2 -0
  185. data/registry/icons/phosphor/file-text.svg +2 -0
  186. data/registry/icons/phosphor/file.svg +2 -0
  187. data/registry/icons/phosphor/flow-arrow.svg +2 -0
  188. data/registry/icons/phosphor/folder.svg +2 -0
  189. data/registry/icons/phosphor/gear.svg +2 -0
  190. data/registry/icons/phosphor/git-branch.svg +2 -0
  191. data/registry/icons/phosphor/globe.svg +2 -0
  192. data/registry/icons/phosphor/graduation-cap.svg +2 -0
  193. data/registry/icons/phosphor/grid-four.svg +2 -0
  194. data/registry/icons/phosphor/house.svg +2 -0
  195. data/registry/icons/phosphor/info.svg +2 -0
  196. data/registry/icons/phosphor/kanban.svg +2 -0
  197. data/registry/icons/phosphor/keyboard.svg +2 -0
  198. data/registry/icons/phosphor/lifebuoy.svg +2 -0
  199. data/registry/icons/phosphor/list.svg +2 -0
  200. data/registry/icons/phosphor/lock.svg +2 -0
  201. data/registry/icons/phosphor/magnifying-glass-minus.svg +2 -0
  202. data/registry/icons/phosphor/magnifying-glass-plus.svg +2 -0
  203. data/registry/icons/phosphor/magnifying-glass.svg +2 -0
  204. data/registry/icons/phosphor/minus.svg +2 -0
  205. data/registry/icons/phosphor/moon.svg +2 -0
  206. data/registry/icons/phosphor/newspaper.svg +2 -0
  207. data/registry/icons/phosphor/package.svg +2 -0
  208. data/registry/icons/phosphor/pause.svg +2 -0
  209. data/registry/icons/phosphor/percent.svg +2 -0
  210. data/registry/icons/phosphor/plus.svg +2 -0
  211. data/registry/icons/phosphor/printer.svg +2 -0
  212. data/registry/icons/phosphor/qr-code.svg +2 -0
  213. data/registry/icons/phosphor/receipt.svg +2 -0
  214. data/registry/icons/phosphor/rocket.svg +2 -0
  215. data/registry/icons/phosphor/seal-check.svg +2 -0
  216. data/registry/icons/phosphor/shield-check.svg +2 -0
  217. data/registry/icons/phosphor/shield.svg +2 -0
  218. data/registry/icons/phosphor/sidebar.svg +2 -0
  219. data/registry/icons/phosphor/sign-out.svg +2 -0
  220. data/registry/icons/phosphor/spinner.svg +2 -0
  221. data/registry/icons/phosphor/squares-four.svg +2 -0
  222. data/registry/icons/phosphor/storefront.svg +2 -0
  223. data/registry/icons/phosphor/sun.svg +2 -0
  224. data/registry/icons/phosphor/text-align-center.svg +2 -0
  225. data/registry/icons/phosphor/text-align-left.svg +2 -0
  226. data/registry/icons/phosphor/text-align-right.svg +2 -0
  227. data/registry/icons/phosphor/text-b.svg +2 -0
  228. data/registry/icons/phosphor/text-italic.svg +2 -0
  229. data/registry/icons/phosphor/text-underline.svg +2 -0
  230. data/registry/icons/phosphor/trash.svg +2 -0
  231. data/registry/icons/phosphor/tray.svg +2 -0
  232. data/registry/icons/phosphor/truck.svg +2 -0
  233. data/registry/icons/phosphor/upload-simple.svg +2 -0
  234. data/registry/icons/phosphor/user-plus.svg +2 -0
  235. data/registry/icons/phosphor/user.svg +2 -0
  236. data/registry/icons/phosphor/users.svg +2 -0
  237. data/registry/icons/phosphor/warning-circle.svg +2 -0
  238. data/registry/icons/phosphor/x.svg +2 -0
  239. data/registry/icons/tabler/LICENSE +21 -0
  240. data/registry/icons/tabler/alert-circle.svg +18 -0
  241. data/registry/icons/tabler/align-center.svg +18 -0
  242. data/registry/icons/tabler/align-left.svg +18 -0
  243. data/registry/icons/tabler/align-right.svg +18 -0
  244. data/registry/icons/tabler/arrow-left.svg +18 -0
  245. data/registry/icons/tabler/arrow-right.svg +18 -0
  246. data/registry/icons/tabler/bell.svg +17 -0
  247. data/registry/icons/tabler/bold.svg +17 -0
  248. data/registry/icons/tabler/book.svg +20 -0
  249. data/registry/icons/tabler/building-store.svg +20 -0
  250. data/registry/icons/tabler/calendar.svg +21 -0
  251. data/registry/icons/tabler/chart-bar.svg +19 -0
  252. data/registry/icons/tabler/check.svg +16 -0
  253. data/registry/icons/tabler/chevron-down.svg +16 -0
  254. data/registry/icons/tabler/chevron-left.svg +16 -0
  255. data/registry/icons/tabler/chevron-right.svg +16 -0
  256. data/registry/icons/tabler/circle-check.svg +17 -0
  257. data/registry/icons/tabler/cloud.svg +16 -0
  258. data/registry/icons/tabler/credit-card.svg +19 -0
  259. data/registry/icons/tabler/device-desktop.svg +19 -0
  260. data/registry/icons/tabler/dots-vertical.svg +18 -0
  261. data/registry/icons/tabler/dots.svg +18 -0
  262. data/registry/icons/tabler/download.svg +18 -0
  263. data/registry/icons/tabler/eye-off.svg +18 -0
  264. data/registry/icons/tabler/eye.svg +17 -0
  265. data/registry/icons/tabler/file-plus.svg +19 -0
  266. data/registry/icons/tabler/file-text.svg +20 -0
  267. data/registry/icons/tabler/file.svg +17 -0
  268. data/registry/icons/tabler/folder.svg +16 -0
  269. data/registry/icons/tabler/git-branch.svg +21 -0
  270. data/registry/icons/tabler/grip-vertical.svg +21 -0
  271. data/registry/icons/tabler/home.svg +18 -0
  272. data/registry/icons/tabler/inbox.svg +17 -0
  273. data/registry/icons/tabler/info-circle.svg +18 -0
  274. data/registry/icons/tabler/italic.svg +18 -0
  275. data/registry/icons/tabler/keyboard.svg +23 -0
  276. data/registry/icons/tabler/layout-dashboard.svg +19 -0
  277. data/registry/icons/tabler/layout-grid.svg +19 -0
  278. data/registry/icons/tabler/layout-kanban.svg +19 -0
  279. data/registry/icons/tabler/layout-sidebar.svg +17 -0
  280. data/registry/icons/tabler/lifebuoy.svg +21 -0
  281. data/registry/icons/tabler/list.svg +21 -0
  282. data/registry/icons/tabler/loader.svg +23 -0
  283. data/registry/icons/tabler/lock.svg +18 -0
  284. data/registry/icons/tabler/logout.svg +18 -0
  285. data/registry/icons/tabler/mail.svg +17 -0
  286. data/registry/icons/tabler/menu-2.svg +18 -0
  287. data/registry/icons/tabler/message-circle.svg +16 -0
  288. data/registry/icons/tabler/minus.svg +16 -0
  289. data/registry/icons/tabler/moon.svg +16 -0
  290. data/registry/icons/tabler/news.svg +19 -0
  291. data/registry/icons/tabler/package.svg +20 -0
  292. data/registry/icons/tabler/percentage.svg +18 -0
  293. data/registry/icons/tabler/player-pause.svg +17 -0
  294. data/registry/icons/tabler/plus.svg +17 -0
  295. data/registry/icons/tabler/printer.svg +18 -0
  296. data/registry/icons/tabler/qrcode.svg +27 -0
  297. data/registry/icons/tabler/receipt.svg +16 -0
  298. data/registry/icons/tabler/rocket.svg +18 -0
  299. data/registry/icons/tabler/rosette-discount-check.svg +17 -0
  300. data/registry/icons/tabler/rotate-clockwise.svg +16 -0
  301. data/registry/icons/tabler/school.svg +17 -0
  302. data/registry/icons/tabler/search.svg +17 -0
  303. data/registry/icons/tabler/selector.svg +17 -0
  304. data/registry/icons/tabler/settings.svg +17 -0
  305. data/registry/icons/tabler/shield-check.svg +17 -0
  306. data/registry/icons/tabler/shield.svg +16 -0
  307. data/registry/icons/tabler/sitemap.svg +20 -0
  308. data/registry/icons/tabler/sun-moon.svg +21 -0
  309. data/registry/icons/tabler/sun.svg +17 -0
  310. data/registry/icons/tabler/trash.svg +20 -0
  311. data/registry/icons/tabler/truck.svg +18 -0
  312. data/registry/icons/tabler/underline.svg +17 -0
  313. data/registry/icons/tabler/upload.svg +18 -0
  314. data/registry/icons/tabler/user-plus.svg +19 -0
  315. data/registry/icons/tabler/user.svg +17 -0
  316. data/registry/icons/tabler/users.svg +19 -0
  317. data/registry/icons/tabler/world.svg +20 -0
  318. data/registry/icons/tabler/x.svg +17 -0
  319. data/registry/icons/tabler/zoom-in.svg +19 -0
  320. data/registry/icons/tabler/zoom-out.svg +18 -0
  321. data/registry/icons.yml +90 -0
  322. data/registry/test/components/previews/ui/chart_preview/cash_flow.html.erb +6 -0
  323. data/registry/test/components/previews/ui/chart_preview/donut.html.erb +6 -0
  324. data/registry/test/components/previews/ui/chart_preview/margin.html.erb +6 -0
  325. data/registry/test/components/previews/ui/chart_preview/pie.html.erb +6 -0
  326. data/registry/test/components/previews/ui/chart_preview/sales.html.erb +6 -0
  327. data/registry/test/components/previews/ui/chart_preview/stock.html.erb +6 -0
  328. data/registry/test/components/previews/ui/chart_preview/takings.html.erb +8 -0
  329. data/registry/test/components/previews/ui/chart_preview.rb +46 -0
  330. data/registry/test/components/previews/ui/command_preview/_picked.html.erb +14 -0
  331. data/registry/test/components/previews/ui/command_preview/dialog.html.erb +24 -0
  332. data/registry/test/components/previews/ui/command_preview/inline.html.erb +16 -0
  333. data/registry/test/components/previews/ui/command_preview/playground.html.erb +15 -0
  334. data/registry/test/components/previews/ui/command_preview/server_search.html.erb +24 -0
  335. data/registry/test/components/previews/ui/command_preview/shortcuts.html.erb +12 -0
  336. data/registry/test/components/previews/ui/command_preview/till.html.erb +17 -0
  337. data/registry/test/components/previews/ui/command_preview.rb +25 -0
  338. data/registry/test/components/previews/ui/confirm_dialog_preview/destructive.html.erb +7 -0
  339. data/registry/test/components/previews/ui/confirm_dialog_preview/in_form.html.erb +6 -0
  340. data/registry/test/components/previews/ui/confirm_dialog_preview/on_link.html.erb +5 -0
  341. data/registry/test/components/previews/ui/confirm_dialog_preview/plain.html.erb +3 -0
  342. data/registry/test/components/previews/ui/confirm_dialog_preview/with_description.html.erb +4 -0
  343. data/registry/test/components/previews/ui/confirm_dialog_preview.rb +20 -0
  344. data/registry/test/components/previews/ui/date_picker_preview/custom_presets.html.erb +6 -0
  345. data/registry/test/components/previews/ui/date_picker_preview/in_form.html.erb +11 -0
  346. data/registry/test/components/previews/ui/date_picker_preview/range.html.erb +5 -0
  347. data/registry/test/components/previews/ui/date_picker_preview/states.html.erb +4 -3
  348. data/registry/test/components/previews/ui/date_picker_preview.rb +26 -6
  349. data/registry/test/components/previews/ui/empty_state_preview/in_card.html.erb +7 -0
  350. data/registry/test/components/previews/ui/empty_state_preview/no_results.html.erb +3 -0
  351. data/registry/test/components/previews/ui/empty_state_preview/outline.html.erb +3 -0
  352. data/registry/test/components/previews/ui/empty_state_preview/with_actions.html.erb +4 -0
  353. data/registry/test/components/previews/ui/empty_state_preview/with_media.html.erb +8 -0
  354. data/registry/test/components/previews/ui/empty_state_preview.rb +26 -0
  355. data/registry/test/components/previews/ui/file_field_preview/multiple_files.html.erb +1 -1
  356. data/registry/test/components/previews/ui/file_field_preview/product_photos.html.erb +12 -0
  357. data/registry/test/components/previews/ui/file_field_preview/single_image.html.erb +4 -0
  358. data/registry/test/components/previews/ui/file_field_preview.rb +32 -5
  359. data/registry/test/components/previews/ui/gallery_preview/hover_zoom.html.erb +13 -0
  360. data/registry/test/components/previews/ui/gallery_preview/landscape.html.erb +5 -0
  361. data/registry/test/components/previews/ui/gallery_preview/product_page.html.erb +13 -0
  362. data/registry/test/components/previews/ui/gallery_preview/single.html.erb +3 -0
  363. data/registry/test/components/previews/ui/gallery_preview.rb +45 -0
  364. data/registry/test/components/previews/ui/icon_preview/common.html.erb +19 -3
  365. data/registry/test/components/previews/ui/icon_preview/labelled.html.erb +4 -0
  366. data/registry/test/components/previews/ui/icon_preview/missing.html.erb +3 -0
  367. data/registry/test/components/previews/ui/icon_preview.rb +18 -3
  368. data/registry/test/components/previews/ui/input_group_preview/playground.html.erb +2 -2
  369. data/registry/test/components/previews/ui/input_group_preview.rb +3 -3
  370. data/registry/test/components/previews/ui/kbd_preview/bound.html.erb +20 -0
  371. data/registry/test/components/previews/ui/kbd_preview/keys.html.erb +13 -0
  372. data/registry/test/components/previews/ui/kbd_preview/menu.html.erb +13 -0
  373. data/registry/test/components/previews/ui/kbd_preview/search_field.html.erb +8 -0
  374. data/registry/test/components/previews/ui/kbd_preview/shortcuts_list.html.erb +17 -0
  375. data/registry/test/components/previews/ui/kbd_preview/till.html.erb +23 -0
  376. data/registry/test/components/previews/ui/kbd_preview/tooltip_and_buttons.html.erb +14 -0
  377. data/registry/test/components/previews/ui/kbd_preview.rb +32 -0
  378. data/registry/test/components/previews/ui/number_input_preview/cart.html.erb +11 -0
  379. data/registry/test/components/previews/ui/number_input_preview/decimals.html.erb +4 -0
  380. data/registry/test/components/previews/ui/number_input_preview/sizes.html.erb +5 -0
  381. data/registry/test/components/previews/ui/number_input_preview/states.html.erb +7 -0
  382. data/registry/test/components/previews/ui/number_input_preview/stock_adjustment.html.erb +3 -0
  383. data/registry/test/components/previews/ui/number_input_preview.rb +36 -0
  384. data/registry/test/components/previews/ui/progress_preview/file_upload.html.erb +36 -0
  385. data/registry/test/components/previews/ui/progress_preview/free_shipping.html.erb +4 -0
  386. data/registry/test/components/previews/ui/progress_preview/indeterminate.html.erb +4 -0
  387. data/registry/test/components/previews/ui/progress_preview/sizes_and_tones.html.erb +8 -0
  388. data/registry/test/components/previews/ui/progress_preview/steps.html.erb +9 -0
  389. data/registry/test/components/previews/ui/progress_preview/storage.html.erb +8 -0
  390. data/registry/test/components/previews/ui/progress_preview/storage_by_category.html.erb +7 -0
  391. data/registry/test/components/previews/ui/progress_preview/tasks_by_status.html.erb +14 -0
  392. data/registry/test/components/previews/ui/progress_preview/traffic_by_source.html.erb +15 -0
  393. data/registry/test/components/previews/ui/progress_preview.rb +46 -0
  394. data/registry/test/components/previews/ui/select_preview/server_search.html.erb +22 -0
  395. data/registry/test/components/previews/ui/select_preview.rb +5 -0
  396. data/registry/test/components/previews/ui/stepper_preview/approvals.html.erb +9 -0
  397. data/registry/test/components/previews/ui/stepper_preview/checklist.html.erb +12 -0
  398. data/registry/test/components/previews/ui/stepper_preview/dot_wizard.html.erb +41 -0
  399. data/registry/test/components/previews/ui/stepper_preview/failed_deploy.html.erb +13 -0
  400. data/registry/test/components/previews/ui/stepper_preview/inline.html.erb +31 -0
  401. data/registry/test/components/previews/ui/stepper_preview/onboarding.html.erb +12 -0
  402. data/registry/test/components/previews/ui/stepper_preview/order_tracking.html.erb +10 -0
  403. data/registry/test/components/previews/ui/stepper_preview/price_calculator.html.erb +14 -0
  404. data/registry/test/components/previews/ui/stepper_preview/server_driven.html.erb +20 -0
  405. data/registry/test/components/previews/ui/stepper_preview/sidebar.html.erb +43 -0
  406. data/registry/test/components/previews/ui/stepper_preview/wizard.html.erb +55 -0
  407. data/registry/test/components/previews/ui/stepper_preview.rb +57 -0
  408. data/registry/test/components/previews/ui/timeline_preview/activity_log.html.erb +7 -0
  409. data/registry/test/components/previews/ui/timeline_preview/colored.html.erb +7 -0
  410. data/registry/test/components/previews/ui/timeline_preview/colored_by_meaning.html.erb +7 -0
  411. data/registry/test/components/previews/ui/timeline_preview/failed_delivery.html.erb +6 -0
  412. data/registry/test/components/previews/ui/timeline_preview/order_status.html.erb +9 -0
  413. data/registry/test/components/previews/ui/timeline_preview/real_dates.html.erb +5 -0
  414. data/registry/test/components/previews/ui/timeline_preview/stock_history.html.erb +6 -0
  415. data/registry/test/components/previews/ui/timeline_preview.rb +40 -0
  416. data/registry/test/components/previews/ui/toggle_group_preview/icon_only.html.erb +5 -0
  417. data/registry/test/components/previews/ui/toggle_group_preview/in_form.html.erb +11 -0
  418. data/registry/test/components/previews/ui/toggle_group_preview/multiple.html.erb +5 -0
  419. data/registry/test/components/previews/ui/toggle_group_preview/outline.html.erb +5 -0
  420. data/registry/test/components/previews/ui/toggle_group_preview/sizes.html.erb +9 -0
  421. data/registry/test/components/previews/ui/toggle_group_preview/with_icons.html.erb +5 -0
  422. data/registry/test/components/previews/ui/toggle_group_preview.rb +36 -0
  423. data/registry/test/components/ui/accordion/trigger_test.rb +1 -1
  424. data/registry/test/components/ui/alert_test.rb +10 -10
  425. data/registry/test/components/ui/badge_test.rb +3 -3
  426. data/registry/test/components/ui/banner_test.rb +3 -3
  427. data/registry/test/components/ui/breadcrumb/ellipsis_test.rb +2 -2
  428. data/registry/test/components/ui/button_test.rb +17 -14
  429. data/registry/test/components/ui/button_to_test.rb +2 -2
  430. data/registry/test/components/ui/chart_test.rb +187 -0
  431. data/registry/test/components/ui/checkbox_test.rb +2 -2
  432. data/registry/test/components/ui/command/group_test.rb +19 -0
  433. data/registry/test/components/ui/command/item_test.rb +47 -0
  434. data/registry/test/components/ui/command_test.rb +110 -0
  435. data/registry/test/components/ui/confirm_dialog_test.rb +68 -0
  436. data/registry/test/components/ui/date_picker_test.rb +129 -111
  437. data/registry/test/components/ui/empty_state_test.rb +87 -0
  438. data/registry/test/components/ui/file_field_test.rb +105 -9
  439. data/registry/test/components/ui/gallery_test.rb +192 -0
  440. data/registry/test/components/ui/icon_test.rb +60 -20
  441. data/registry/test/components/ui/input_group_test.rb +1 -1
  442. data/registry/test/components/ui/kbd_test.rb +150 -0
  443. data/registry/test/components/ui/link_test.rb +3 -3
  444. data/registry/test/components/ui/navigation_menu_test.rb +2 -2
  445. data/registry/test/components/ui/number_input_test.rb +155 -0
  446. data/registry/test/components/ui/progress_test.rb +188 -0
  447. data/registry/test/components/ui/select_test.rb +62 -0
  448. data/registry/test/components/ui/session_tabs_test.rb +3 -3
  449. data/registry/test/components/ui/spinner_test.rb +9 -9
  450. data/registry/test/components/ui/stepper_test.rb +239 -0
  451. data/registry/test/components/ui/tabs/trigger_test.rb +2 -2
  452. data/registry/test/components/ui/theme_toggle_test.rb +6 -8
  453. data/registry/test/components/ui/timeline_test.rb +175 -0
  454. data/registry/test/components/ui/toast_test.rb +11 -10
  455. data/registry/test/components/ui/toggle_group_test.rb +162 -0
  456. metadata +399 -3
  457. data/registry/app/javascript/cally.ts +0 -8
  458. data/registry/app/javascript/velvetkit_icons.ts +0 -78
@@ -0,0 +1,239 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
4
+
5
+ class UI::StepperTest < ViewComponent::TestCase
6
+ def setup_fixtures(*); end
7
+ def teardown_fixtures(*); end
8
+
9
+ def render_steps(titles = %w[Account Plan Payment], **opts, &block)
10
+ render_inline(UI::Stepper.new(**opts)) do |stepper|
11
+ titles.each { |title| stepper.with_step(title: title) }
12
+ block&.call(stepper)
13
+ end
14
+ end
15
+
16
+ def statuses = page.all("li[data-slot='stepper-step']").map { |li| li["data-status"] }
17
+
18
+ def test_renders_a_labelled_nav_with_an_ordered_list
19
+ render_steps
20
+ assert_selector "nav[aria-label='Progress'] > ol > li", count: 3
21
+ assert_selector "div[data-slot='stepper'][data-orientation='horizontal'][data-variant='default']"
22
+ end
23
+
24
+ def test_label_names_the_nav
25
+ render_steps(label: "Create a project")
26
+ assert_selector "nav[aria-label='Create a project']"
27
+ end
28
+
29
+ def test_steps_before_current_are_complete_and_after_are_upcoming
30
+ render_steps(%w[A B C D], current: 3)
31
+ assert_equal %w[complete complete current upcoming], statuses
32
+ assert_selector "li[data-status='current'][aria-current='step']", text: "C"
33
+ assert_selector "li[aria-current]", count: 1
34
+ end
35
+
36
+ def test_current_past_the_last_step_marks_them_all_complete
37
+ render_steps(current: 4)
38
+ assert_equal %w[complete complete complete], statuses
39
+ refute_selector "li[aria-current]"
40
+ end
41
+
42
+ def test_status_overrides_the_step
43
+ render_inline(UI::Stepper.new(current: 2)) do |stepper|
44
+ stepper.with_step(title: "Build")
45
+ stepper.with_step(title: "Test", status: :error)
46
+ stepper.with_step(title: "Deploy", status: :loading)
47
+ end
48
+ assert_equal %w[complete error loading], statuses
49
+ end
50
+
51
+ def test_each_step_says_its_state_to_screen_readers
52
+ render_steps(current: 2)
53
+ step = page.find("li[data-status='complete']")
54
+ assert_includes step.find("span.sr-only", text: "Completed", visible: :all)[:class], "group-data-[status=complete]/step:inline"
55
+ end
56
+
57
+ def test_indicator_draws_the_number_and_a_glyph_for_each_state
58
+ render_steps(current: 2)
59
+ indicator = page.find_all("li")[1].find("span[aria-hidden]", match: :first)
60
+ assert_text "2"
61
+ assert_selector "li svg[data-icon='check']", visible: :all
62
+ assert_selector "li svg[data-icon='loader'].animate-spin", visible: :all
63
+ assert_includes indicator[:class], "group-data-[status=current]/step:ring-4"
64
+ end
65
+
66
+ def test_icon_replaces_the_number
67
+ render_inline(UI::Stepper.new) { |stepper| stepper.with_step(title: "Pay", icon: "credit-card") }
68
+ assert_selector "li svg[data-icon='credit-card']", visible: :all
69
+ end
70
+
71
+ def test_connector_between_steps_but_not_after_the_last
72
+ render_steps
73
+ assert_selector "li span.bg-border", count: 2
74
+ refute_selector "li:last-child span.bg-border"
75
+ end
76
+
77
+ def test_connector_fill_grows_once_the_step_is_done
78
+ render_steps
79
+ fill = page.find("li span.bg-border > span", match: :first, visible: :all)
80
+ assert_includes fill[:class], "scale-x-0"
81
+ assert_includes fill[:class], "group-data-[status=complete]/step:scale-x-100"
82
+ end
83
+
84
+ def test_no_connector
85
+ render_steps(connector: false)
86
+ refute_selector "li span.bg-border"
87
+ end
88
+
89
+ def test_vertical_stacks_with_a_vertical_line
90
+ render_steps(orientation: :vertical)
91
+ assert_selector "div[data-orientation='vertical'] ol.flex-col"
92
+ fill = page.find("li span.bg-border > span", match: :first, visible: :all)
93
+ assert_includes fill[:class], "group-data-[status=complete]/step:scale-y-100"
94
+ end
95
+
96
+ def test_dot_variant_draws_no_number
97
+ render_steps(variant: :dot)
98
+ assert_selector "div[data-variant='dot']"
99
+ refute_selector "li span.size-8"
100
+ assert_selector "li span.size-3", count: 3
101
+ assert page.all("li span.size-3").all? { |dot| dot.text.strip.empty? }
102
+ end
103
+
104
+ def test_center_align_centres_each_step
105
+ render_steps(align: :center)
106
+ assert_selector "li.items-center.text-center", count: 3
107
+ end
108
+
109
+ def test_labels_false_keeps_titles_for_screen_readers
110
+ render_steps(labels: false)
111
+ assert_selector "li div.sr-only", count: 3, visible: :all
112
+ end
113
+
114
+ def test_titles_are_hidden_on_phones_with_a_summary_instead
115
+ render_steps(current: 2)
116
+ assert_selector "li div.\\@max-md\\/stepper\\:sr-only", count: 3, visible: :all
117
+ summary = page.find("p.\\@md\\/stepper\\:hidden[aria-hidden='true']")
118
+ assert_equal "Step 2 of 3: Plan", summary.text
119
+ end
120
+
121
+ def test_descriptions
122
+ render_inline(UI::Stepper.new) { |stepper| stepper.with_step(title: "Account", description: "Name and email") }
123
+ assert_selector "li span", text: "Name and email"
124
+ end
125
+
126
+ def test_done_steps_with_href_link_back_but_the_current_one_does_not
127
+ render_inline(UI::Stepper.new(current: 2)) do |stepper|
128
+ stepper.with_step(title: "Account", href: "/signup/account")
129
+ stepper.with_step(title: "Plan", href: "/signup/plan")
130
+ end
131
+ assert_selector "a[href='/signup/account']", text: "Account"
132
+ refute_selector "a[href='/signup/plan']"
133
+ end
134
+
135
+ def test_wires_the_controller_with_the_current_step
136
+ render_steps(current: 2)
137
+ root = page.find("div[data-slot='stepper']")
138
+ controller = "ui--stepper"
139
+ assert_equal controller, root["data-controller"]
140
+ assert_equal "2", root["data-#{controller}-current-value"]
141
+ assert_equal "Step %{current} of %{total}", root["data-#{controller}-summary-value"]
142
+ assert_includes root["data-action"], "#{controller}#keydown"
143
+ assert_selector "li[data-#{controller}-target='step']", count: 3
144
+ end
145
+
146
+ def test_step_blocks_become_panels_and_only_the_current_one_shows
147
+ render_inline(UI::Stepper.new(current: 2)) do |stepper|
148
+ stepper.with_step(title: "Account") { "Account fields" }
149
+ stepper.with_step(title: "Plan") { "Plan fields" }
150
+ end
151
+ panels = page.all("div[role='group'][data-step]", visible: :all)
152
+ assert_equal %w[1 2], panels.map { |panel| panel["data-step"] }
153
+ assert panels.first[:hidden]
154
+ refute panels.last[:hidden]
155
+ assert_text "Plan fields"
156
+ assert_equal panels.last["aria-labelledby"], page.find("li span", text: "Plan", exact_text: true)[:id]
157
+ refute_selector "li", text: "Plan fields"
158
+ end
159
+
160
+ def test_inline_layout_puts_each_panel_in_its_step
161
+ render_inline(UI::Stepper.new(orientation: :vertical, layout: :inline)) do |stepper|
162
+ stepper.with_step(title: "Install") { "Get an app" }
163
+ end
164
+ assert_selector "li div[role='group']", text: "Get an app"
165
+ end
166
+
167
+ def test_side_layout_puts_the_steps_beside_the_panels
168
+ render_inline(UI::Stepper.new(orientation: :vertical, layout: :side)) do |stepper|
169
+ stepper.with_step(title: "Format") { "Pick one" }
170
+ end
171
+ assert_selector "div[data-slot='stepper'] > div.grid > nav + div", text: "Pick one"
172
+ end
173
+
174
+ def test_completion_shows_once_every_step_is_done
175
+ render_inline(UI::Stepper.new(current: 2)) do |stepper|
176
+ stepper.with_step(title: "Only") { "Fields" }
177
+ stepper.with_completion { "All done" }
178
+ end
179
+ assert_text "All done"
180
+ refute_selector "p.\\@md\\/stepper\\:hidden"
181
+ end
182
+
183
+ def test_completion_is_hidden_until_then
184
+ render_inline(UI::Stepper.new) do |stepper|
185
+ stepper.with_step(title: "Only") { "Fields" }
186
+ stepper.with_completion { "All done" }
187
+ end
188
+ assert_selector "div[hidden]", text: "All done", visible: :all
189
+ end
190
+
191
+ def test_block_comes_after_the_panels
192
+ render_inline(UI::Stepper.new) do |stepper|
193
+ stepper.with_step(title: "Only") { "Fields" }
194
+ "Buttons"
195
+ end
196
+ assert_match(/Fields.*Buttons/m, page.native.to_html)
197
+ end
198
+
199
+ def test_class_and_attributes_pass_through
200
+ render_steps(class: "max-w-xl", id: "signup", data: { turbo: false })
201
+ root = page.find("div#signup[data-turbo='false']")
202
+ assert_includes root[:class], "max-w-xl"
203
+ assert_selector "li span[id='signup-step-1']"
204
+ end
205
+
206
+ def render_panels(**opts)
207
+ render_inline(UI::Stepper.new(current: 2, **opts)) do |stepper|
208
+ stepper.with_step(title: "Account") { "Account fields" }
209
+ stepper.with_step(title: "Plan") { "Plan fields" }
210
+ stepper.with_step(title: "Payment") { "Card fields" }
211
+ end
212
+ end
213
+
214
+ def test_with_panels_a_done_step_is_a_button_back_to_it
215
+ render_panels
216
+ controller = "ui--stepper"
217
+ back = page.find("li[data-status='complete'] button[type='button']")
218
+ assert_equal "Account", back.text
219
+ refute back.disabled?
220
+ assert_equal "#{controller}#select", back["data-action"]
221
+ assert_equal "click->#{controller}#select", page.find("li[data-status='complete'] span[aria-hidden]", match: :first)["data-action"]
222
+ end
223
+
224
+ def test_steps_not_done_yet_are_disabled_buttons
225
+ render_panels
226
+ assert_selector "li[data-status='current'] button[disabled]", text: "Plan"
227
+ assert_selector "li[data-status='upcoming'] button[disabled]", text: "Payment"
228
+ end
229
+
230
+ def test_navigable_false_keeps_titles_plain
231
+ render_panels(navigable: false)
232
+ refute_selector "li button"
233
+ end
234
+
235
+ def test_without_panels_titles_are_plain
236
+ render_steps(current: 2)
237
+ refute_selector "li button"
238
+ end
239
+ end
@@ -103,8 +103,8 @@ class UI::Tabs::TriggerTest < ViewComponent::TestCase
103
103
  end
104
104
  tabs.with_panel(value: "a") { "panel-a" }
105
105
  end
106
- icon = page.find("[role='tab'][data-value='a'] i", visible: :all)
107
- assert_equal "user", icon["data-lucide"]
106
+ icon = page.find("[role='tab'][data-value='a'] svg", visible: :all)
107
+ assert icon.matches_css?("[data-icon='user']")
108
108
  end
109
109
 
110
110
  def test_line_variant_size_sm
@@ -46,20 +46,18 @@ class UI::ThemeToggleTest < ViewComponent::TestCase
46
46
  end
47
47
  end
48
48
 
49
- # lucide swaps each <i data-lucide> for an <svg> on first render, so the
50
- # element is gone afterwards and the icon cannot be changed by attribute.
51
- # All three are rendered and shown by the preference on <html data-theme>:
49
+ # All three icons are rendered and shown by the preference on <html data-theme>:
52
50
  # the sun for light, which is the default (and before any script runs).
53
51
  def test_trigger_icon_follows_the_preference_with_light_by_default
54
52
  render_inline(UI::ThemeToggle.new)
55
53
  trigger = page.find("button[aria-haspopup]")
56
- icon = ->(name) { trigger.find("i[data-lucide='#{name}']", visible: :all)[:class].split }
57
- sun = icon.("sun")
54
+ icon = ->(selector) { trigger.find(selector, visible: :all)[:class].split }
55
+ sun = icon.("svg[data-icon='sun']")
58
56
  assert_includes sun, "block"
59
57
  assert_includes sun, "in-data-[theme=dark]:hidden"
60
58
  assert_includes sun, "in-data-[theme=system]:hidden"
61
- assert_includes icon.("moon"), "in-data-[theme=dark]:block"
62
- assert_includes icon.("monitor"), "in-data-[theme=system]:block"
59
+ assert_includes icon.("svg[data-icon='moon']"), "in-data-[theme=dark]:block"
60
+ assert_includes icon.("svg[data-icon='monitor']"), "in-data-[theme=system]:block"
63
61
  end
64
62
 
65
63
  def test_html_attrs_passthrough
@@ -80,7 +78,7 @@ class UI::ThemeToggleTest < ViewComponent::TestCase
80
78
  def test_each_option_has_a_check_indicator_shown_only_when_checked
81
79
  render_inline(UI::ThemeToggle.new)
82
80
  page.all("[data-ui--theme-target='option']", visible: :all).each do |option|
83
- check = option.find("i[data-lucide='check']", visible: :all)
81
+ check = option.find("svg[data-icon='check']", visible: :all)
84
82
  assert_includes check[:class].split, "hidden"
85
83
  assert_includes check[:class].split, "group-aria-checked:block"
86
84
  end
@@ -0,0 +1,175 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
4
+
5
+ class UI::TimelineTest < ViewComponent::TestCase
6
+ def setup_fixtures(*); end
7
+ def teardown_fixtures(*); end
8
+
9
+ def render_items(titles = %w[Placed Paid Shipped], **opts)
10
+ render_inline(UI::Timeline.new(**opts)) { |timeline| titles.each { |title| timeline.with_item(title: title) } }
11
+ end
12
+
13
+ def render_item(variant: :default, **opts, &block)
14
+ render_inline(UI::Timeline.new(variant: variant)) { |timeline| timeline.with_item(title: "Paid", **opts, &block) }
15
+ end
16
+
17
+ def test_renders_a_labelled_ordered_list_in_the_order_given
18
+ render_items
19
+ assert_selector "ol[data-slot='timeline'][aria-label='Timeline'] > li[data-slot='timeline-item']", count: 3
20
+ assert_equal %w[Placed Paid Shipped], page.all("li > div > div > span:first-child").map { |s| s.text.split(",").first }
21
+ end
22
+
23
+ def test_label_names_the_list
24
+ render_items(label: "Order history")
25
+ assert_selector "ol[aria-label='Order history']"
26
+ end
27
+
28
+ def test_status_defaults_to_complete
29
+ render_item
30
+ assert_selector "li[data-status='complete']"
31
+ end
32
+
33
+ def test_each_status_is_marked_and_read_out
34
+ { complete: "Completed", current: "In progress", upcoming: "Not started", error: "Failed" }.each do |status, words|
35
+ render_item(status: status)
36
+ assert_selector "li[data-status='#{status}'] .sr-only", text: words
37
+ end
38
+ end
39
+
40
+ def test_unknown_status_falls_back_to_complete
41
+ render_item(status: :nonsense)
42
+ assert_selector "li[data-status='complete']"
43
+ end
44
+
45
+ def test_only_the_current_item_has_aria_current
46
+ render_item(status: :current)
47
+ assert_selector "li[aria-current='step']"
48
+ render_item(status: :complete)
49
+ assert_no_selector "li[aria-current]"
50
+ end
51
+
52
+ def test_status_marks
53
+ render_item(status: :complete)
54
+ assert_selector "svg[data-icon='check']"
55
+ render_item(status: :error)
56
+ assert_selector "svg[data-icon='x']"
57
+ render_item(status: :upcoming)
58
+ assert_no_selector "svg"
59
+ end
60
+
61
+ def test_icon_replaces_the_status_mark
62
+ render_item(icon: "credit-card")
63
+ assert_selector "svg[data-icon='credit-card']"
64
+ assert_no_selector "svg[data-icon='check']"
65
+ end
66
+
67
+ def test_dot_variant_draws_no_icons
68
+ render_item(variant: :dot, icon: "credit-card")
69
+ assert_selector "ol[data-variant='dot']"
70
+ assert_no_selector "svg"
71
+ end
72
+
73
+ def marker_classes = page.all("li > span[aria-hidden]:not(.absolute)").map { |marker| marker[:class] }
74
+
75
+ def render_colored(*items)
76
+ render_inline(UI::Timeline.new(variant: :colored)) do |timeline|
77
+ items.each { |opts| timeline.with_item(title: "Step", **opts) }
78
+ end
79
+ end
80
+
81
+ def test_colored_variant_gives_each_circle_its_own_colour_and_wraps_round
82
+ count = UI::Timeline::Item::COLORS.size
83
+ render_colored(*Array.new(count + 1) { {} })
84
+ fills = marker_classes.map { |classes| classes[/bg-\w+-600/] }
85
+ assert_equal count, fills.first(count).uniq.size
86
+ assert_equal fills.first, fills.last
87
+ end
88
+
89
+ def test_color_chooses_the_colour_and_an_unknown_one_keeps_its_turn
90
+ render_colored({ color: :rose }, { color: :nonsense })
91
+ assert_includes marker_classes.first, "bg-rose-600"
92
+ assert_includes marker_classes.last, "bg-emerald-600"
93
+ end
94
+
95
+ def test_colored_current_item_wears_a_ring_in_its_colour
96
+ render_colored({ color: :teal, status: :current })
97
+ assert_includes marker_classes.first, "ring-teal-600/20"
98
+ end
99
+
100
+ def test_colored_keeps_the_look_of_errors_and_upcoming_items
101
+ render_colored({ color: :teal, status: :error }, { color: :teal, status: :upcoming })
102
+ assert_includes marker_classes.first, "bg-destructive"
103
+ assert_includes marker_classes.last, "bg-muted"
104
+ end
105
+
106
+ def test_color_is_ignored_outside_the_colored_variant
107
+ render_item(color: :rose)
108
+ assert_includes marker_classes.first, "bg-primary"
109
+ end
110
+
111
+ def test_colored_connectors_stay_neutral
112
+ render_colored({}, {})
113
+ assert_selector "li > span.absolute.bg-border", count: 1
114
+ end
115
+
116
+ def test_unknown_variant_falls_back_to_default
117
+ render_items(variant: :nonsense)
118
+ assert_selector "ol[data-variant='default']"
119
+ end
120
+
121
+ def test_connector_on_every_item_but_the_last
122
+ render_items
123
+ assert_selector "li", count: 3
124
+ assert_selector "li > span.absolute", count: 2
125
+ assert_no_selector "li:last-child > span.absolute"
126
+ end
127
+
128
+ def test_time_renders_a_time_element_with_a_machine_readable_date
129
+ at = Time.utc(2026, 11, 5, 14, 30)
130
+ render_item(time: at)
131
+ assert_selector "time[datetime='#{at.iso8601}']", text: I18n.l(at, format: :long)
132
+ end
133
+
134
+ def test_date_renders_without_a_time_of_day
135
+ render_item(time: Date.new(2026, 11, 5))
136
+ assert_selector "time[datetime='2026-11-05']", text: I18n.l(Date.new(2026, 11, 5), format: :long)
137
+ end
138
+
139
+ def test_time_label_changes_the_words_but_keeps_the_date
140
+ at = Time.utc(2026, 11, 5, 14, 30)
141
+ render_item(time: at, time_label: "2 hours ago")
142
+ assert_selector "time[datetime='#{at.iso8601}']", text: "2 hours ago"
143
+ end
144
+
145
+ def test_string_time_is_shown_as_it_is_with_no_time_element
146
+ render_item(time: "Expected Friday")
147
+ assert_text "Expected Friday"
148
+ assert_no_selector "time"
149
+ end
150
+
151
+ def test_no_time_renders_nothing_for_it
152
+ render_item
153
+ assert_no_selector "time"
154
+ end
155
+
156
+ def test_description_and_block
157
+ render_item(description: "Card ending 4242") { "Refund issued" }
158
+ assert_selector "p", text: "Card ending 4242"
159
+ assert_text "Refund issued"
160
+ end
161
+
162
+ def test_title_is_escaped
163
+ render_inline(UI::Timeline.new) { |t| t.with_item(title: "<b>Paid</b>") }
164
+ assert_no_selector "b"
165
+ assert_text "<b>Paid</b>"
166
+ end
167
+
168
+ def test_class_and_html_attributes_pass_through
169
+ render_inline(UI::Timeline.new(class: "mt-4", id: "history", data: { foo: "bar" })) do |timeline|
170
+ timeline.with_item(title: "Paid", class: "opacity-50", id: "paid")
171
+ end
172
+ assert_selector "ol#history.mt-4[data-foo='bar'][data-slot='timeline']"
173
+ assert_selector "li#paid.opacity-50[data-slot='timeline-item']"
174
+ end
175
+ end
@@ -39,49 +39,50 @@ class UI::ToastTest < ViewComponent::TestCase
39
39
  def test_default_variant_classes
40
40
  render_inline(UI::Toast.new(title: "x"))
41
41
  classes = toast_el[:class].split
42
- assert_includes classes, "[&>i]:text-muted-foreground"
42
+ assert_includes classes, "[&>svg]:text-muted-foreground"
43
43
  end
44
44
 
45
45
  def test_success_variant_classes
46
46
  render_inline(UI::Toast.new(variant: :success, title: "x"))
47
47
  classes = toast_el[:class].split
48
- assert_includes classes, "[&>i]:text-emerald-600"
48
+ assert_includes classes, "[&>svg]:text-emerald-600"
49
49
  end
50
50
 
51
51
  def test_destructive_variant_classes
52
52
  render_inline(UI::Toast.new(variant: :destructive, title: "x"))
53
53
  classes = toast_el[:class].split
54
- assert_includes classes, "[&>i]:text-destructive"
54
+ assert_includes classes, "[&>svg]:text-destructive"
55
55
  end
56
56
 
57
57
  def test_warning_variant_classes
58
58
  render_inline(UI::Toast.new(variant: :warning, title: "x"))
59
59
  classes = toast_el[:class].split
60
- assert_includes classes, "[&>i]:text-amber-600"
60
+ assert_includes classes, "[&>svg]:text-amber-600"
61
61
  end
62
62
 
63
63
  def test_info_variant_classes
64
64
  render_inline(UI::Toast.new(variant: :info, title: "x"))
65
65
  classes = toast_el[:class].split
66
- assert_includes classes, "[&>i]:text-sky-600"
66
+ assert_includes classes, "[&>svg]:text-sky-600"
67
67
  end
68
68
 
69
69
  def test_default_icon_per_variant
70
- { default: "info", success: "circle-check", destructive: "circle-alert", warning: "circle-alert", info: "info" }
71
- .each do |variant, icon|
70
+ { default: "svg[data-icon='info']", success: "svg[data-icon='circle-check']",
71
+ destructive: "svg[data-icon='circle-alert']", warning: "svg[data-icon='circle-alert']",
72
+ info: "svg[data-icon='info']" }.each do |variant, icon|
72
73
  render_inline(UI::Toast.new(variant: variant, title: "x"))
73
- assert_selector "i[data-lucide='#{icon}']"
74
+ assert_selector icon
74
75
  end
75
76
  end
76
77
 
77
78
  def test_icon_false_suppresses_icon
78
79
  render_inline(UI::Toast.new(title: "x", icon: false))
79
- refute_selector "[data-slot='toast'] > i"
80
+ refute_selector "[data-slot='toast'] > svg"
80
81
  end
81
82
 
82
83
  def test_icon_override
83
84
  render_inline(UI::Toast.new(title: "x", icon: "rocket"))
84
- assert_selector "[data-slot='toast'] > i[data-lucide='rocket']"
85
+ assert_selector "[data-slot='toast'] > svg[data-icon='rocket']"
85
86
  end
86
87
 
87
88
  def test_title_renders