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
@@ -27,7 +27,7 @@ class UI::Accordion::TriggerTest < ViewComponent::TestCase
27
27
 
28
28
  def test_renders_chevron_icon
29
29
  render_inline(UI::Accordion::Trigger.new) { "x" }
30
- assert_selector "button i[data-lucide='chevron-right']"
30
+ assert_selector "button svg[data-icon='chevron-right']"
31
31
  end
32
32
 
33
33
  def test_aria_controls_when_content_id_provided
@@ -54,23 +54,23 @@ class UI::AlertTest < ViewComponent::TestCase
54
54
 
55
55
  def test_default_variant_renders_default_icon_info
56
56
  render_inline(UI::Alert.new) { "Default" }
57
- icons = page.all("i", visible: :all)
57
+ icons = page.all("svg", visible: :all)
58
58
  assert_equal 1, icons.size
59
- assert_equal "info", icons.first["data-lucide"]
59
+ assert icons.first.matches_css?("[data-icon='info']")
60
60
  end
61
61
 
62
62
  def test_destructive_variant_renders_circle_alert_icon
63
63
  render_inline(UI::Alert.new(variant: :destructive)) { "Error" }
64
- icons = page.all("i", visible: :all)
64
+ icons = page.all("svg", visible: :all)
65
65
  assert_equal 1, icons.size
66
- assert_equal "circle-alert", icons.first["data-lucide"]
66
+ assert icons.first.matches_css?("[data-icon='circle-alert']")
67
67
  end
68
68
 
69
69
  def test_success_variant_renders_circle_check_icon
70
70
  render_inline(UI::Alert.new(variant: :success)) { "Success" }
71
- icons = page.all("i", visible: :all)
71
+ icons = page.all("svg", visible: :all)
72
72
  assert_equal 1, icons.size
73
- assert_equal "circle-check", icons.first["data-lucide"]
73
+ assert icons.first.matches_css?("[data-icon='circle-check']")
74
74
  end
75
75
 
76
76
  def test_custom_icon_slot_overrides_default
@@ -78,9 +78,9 @@ class UI::AlertTest < ViewComponent::TestCase
78
78
  alert.with_icon(name: "badge-check")
79
79
  "Custom icon"
80
80
  end
81
- icons = page.all("i", visible: :all)
81
+ icons = page.all("svg", visible: :all)
82
82
  assert_equal 1, icons.size
83
- assert_equal "badge-check", icons.first["data-lucide"]
83
+ assert icons.first.matches_css?("[data-icon='badge-check']")
84
84
  end
85
85
 
86
86
  def test_title_slot_renders
@@ -150,9 +150,9 @@ class UI::AlertTest < ViewComponent::TestCase
150
150
 
151
151
  def test_close_button_renders_x_icon
152
152
  render_inline(UI::Alert.new(dismissible: true)) { "Dismissible" }
153
- icons = page.all("[role='alert'] button i")
153
+ icons = page.all("[role='alert'] button svg")
154
154
  assert_equal 1, icons.size
155
- assert_equal "x", icons.first["data-lucide"]
155
+ assert icons.first.matches_css?("[data-icon='x']")
156
156
  end
157
157
 
158
158
  def test_close_button_has_dismiss_action
@@ -73,9 +73,9 @@ class UI::BadgeTest < ViewComponent::TestCase
73
73
  "Verified"
74
74
  end
75
75
  span = page.find("span")
76
- icon = span.find("i", visible: :all)
77
- assert_equal "badge-check", icon["data-lucide"]
78
- assert_match(/<i[^>]*data-lucide="badge-check".*Verified/m, span.native.to_html)
76
+ icon = span.find("svg", visible: :all)
77
+ assert icon.matches_css?("[data-icon='badge-check']")
78
+ assert_match(/<svg[^>]*data-icon="badge-check".*Verified/m, span.native.to_html)
79
79
  end
80
80
 
81
81
  def test_user_class_override_via_tailwind_merge
@@ -78,13 +78,13 @@ class UI::BannerTest < ViewComponent::TestCase
78
78
  render_inline(UI::Banner.new) do |banner|
79
79
  banner.with_leading_icon(name: "info")
80
80
  end
81
- assert_selector "[data-slot='banner'] i[data-lucide='info']"
81
+ assert_selector "[data-slot='banner'] svg[data-icon='info']"
82
82
  end
83
83
 
84
84
  def test_dismiss_button_uses_button_component
85
85
  render_inline(UI::Banner.new) { "Message" }
86
86
  assert_selector "button[aria-label='Dismiss']"
87
- assert_selector "button[aria-label='Dismiss'] i[data-lucide='x']"
87
+ assert_selector "button[aria-label='Dismiss'] svg[data-icon='x']"
88
88
  end
89
89
 
90
90
  def test_dismiss_button_wired_to_controller
@@ -95,7 +95,7 @@ class UI::BannerTest < ViewComponent::TestCase
95
95
 
96
96
  def test_custom_dismiss_icon
97
97
  render_inline(UI::Banner.new(dismiss_icon: "check")) { "x" }
98
- assert_selector "button[aria-label='Dismiss'] i[data-lucide='check']"
98
+ assert_selector "button[aria-label='Dismiss'] svg[data-icon='check']"
99
99
  end
100
100
 
101
101
  def test_dismissible_false_hides_close
@@ -13,7 +13,7 @@ class UI::Breadcrumb::EllipsisTest < ViewComponent::TestCase
13
13
 
14
14
  def test_renders_ellipsis_icon
15
15
  render_inline(UI::Breadcrumb::Ellipsis.new)
16
- assert_selector "li i[data-lucide='ellipsis']"
16
+ assert_selector "li svg[data-icon='ellipsis']"
17
17
  end
18
18
 
19
19
  def test_static_ellipsis_is_fully_decorative
@@ -34,7 +34,7 @@ class UI::Breadcrumb::EllipsisTest < ViewComponent::TestCase
34
34
  "<a href=\"/docs\">Documentation</a>".html_safe
35
35
  end
36
36
  assert_selector "li button[aria-label='More breadcrumb pages']"
37
- assert_selector "li i[data-lucide='ellipsis']"
37
+ assert_selector "li svg[data-icon='ellipsis']"
38
38
  end
39
39
 
40
40
  def test_popover_content_includes_provided_html
@@ -179,11 +179,11 @@ class UI::ButtonTest < ViewComponent::TestCase
179
179
  "Continue"
180
180
  end
181
181
  btn = page.find("button")
182
- icons = btn.all("i", visible: :all)
182
+ icons = btn.all("svg", visible: :all)
183
183
  assert_equal 1, icons.size
184
- assert_equal "arrow-right", icons.first["data-lucide"]
184
+ assert icons.first.matches_css?("[data-icon='arrow-right']")
185
185
  # icon precedes text in DOM order
186
- assert_match(/<i[^>]*data-lucide="arrow-right".*Continue/m, btn.native.to_html)
186
+ assert_match(/<svg[^>]*data-icon="arrow-right".*Continue/m, btn.native.to_html)
187
187
  end
188
188
 
189
189
  def test_trailing_icon_renders_after_content
@@ -192,7 +192,7 @@ class UI::ButtonTest < ViewComponent::TestCase
192
192
  "Next"
193
193
  end
194
194
  btn = page.find("button")
195
- assert_match(/Next.*<i[^>]*data-lucide="arrow-right"/m, btn.native.to_html)
195
+ assert_match(/Next.*<svg[^>]*data-icon="arrow-right"/m, btn.native.to_html)
196
196
  end
197
197
 
198
198
  def test_both_leading_and_trailing_icons
@@ -202,8 +202,10 @@ class UI::ButtonTest < ViewComponent::TestCase
202
202
  "Sign in"
203
203
  end
204
204
  btn = page.find("button")
205
- icons = btn.all("i", visible: :all).map { |i| i["data-lucide"] }
206
- assert_equal [ "lock", "arrow-right" ], icons
205
+ icons = btn.all("svg", visible: :all)
206
+ assert_equal 2, icons.size
207
+ assert icons[0].matches_css?("[data-icon='lock']")
208
+ assert icons[1].matches_css?("[data-icon='arrow-right']")
207
209
  end
208
210
 
209
211
  def test_icon_only_button_renders_icon_without_text_slot
@@ -214,7 +216,7 @@ class UI::ButtonTest < ViewComponent::TestCase
214
216
  classes = btn[:class].split
215
217
  assert_includes classes, "h-9"
216
218
  assert_includes classes, "w-9"
217
- assert_equal "menu", btn.find("i", visible: :all)["data-lucide"]
219
+ assert btn.find("svg", visible: :all).matches_css?("[data-icon='menu']")
218
220
  end
219
221
 
220
222
  def test_loading_replaces_leading_icon_with_animated_loader
@@ -223,10 +225,10 @@ class UI::ButtonTest < ViewComponent::TestCase
223
225
  "Saving"
224
226
  end
225
227
  btn = page.find("button")
226
- icons = btn.all("i", visible: :all)
228
+ icons = btn.all("svg", visible: :all)
227
229
  assert_equal 1, icons.size
228
230
  loader = icons.first
229
- assert_equal "loader", loader["data-lucide"]
231
+ assert loader.matches_css?("[data-icon='loader']")
230
232
  assert_includes loader[:class].split, "animate-spin"
231
233
  end
232
234
 
@@ -237,8 +239,9 @@ class UI::ButtonTest < ViewComponent::TestCase
237
239
  end
238
240
  btn = page.find("button")
239
241
  # only the loader is rendered; trailing icon dropped
240
- icons = btn.all("i", visible: :all).map { |i| i["data-lucide"] }
241
- assert_equal [ "loader" ], icons
242
+ icons = btn.all("svg", visible: :all)
243
+ assert_equal 1, icons.size
244
+ assert icons[0].matches_css?("[data-icon='loader']")
242
245
  end
243
246
 
244
247
  def test_icon_slot_auto_sizes_to_button_size_sm
@@ -246,7 +249,7 @@ class UI::ButtonTest < ViewComponent::TestCase
246
249
  btn.with_leading_icon(name: "lock")
247
250
  "Auth"
248
251
  end
249
- icon = page.find("button i", visible: :all)
252
+ icon = page.find("button svg", visible: :all)
250
253
  classes = icon[:class].split
251
254
  assert_includes classes, "w-3"
252
255
  assert_includes classes, "h-3"
@@ -257,7 +260,7 @@ class UI::ButtonTest < ViewComponent::TestCase
257
260
  btn.with_leading_icon(name: "lock")
258
261
  "Auth"
259
262
  end
260
- icon = page.find("button i", visible: :all)
263
+ icon = page.find("button svg", visible: :all)
261
264
  classes = icon[:class].split
262
265
  assert_includes classes, "w-5"
263
266
  assert_includes classes, "h-5"
@@ -268,7 +271,7 @@ class UI::ButtonTest < ViewComponent::TestCase
268
271
  btn.with_leading_icon(name: "lock", size: :xl)
269
272
  "Big"
270
273
  end
271
- icon = page.find("button i", visible: :all)
274
+ icon = page.find("button svg", visible: :all)
272
275
  classes = icon[:class].split
273
276
  assert_includes classes, "w-8"
274
277
  assert_includes classes, "h-8"
@@ -36,7 +36,7 @@ class UI::ButtonToTest < ViewComponent::TestCase
36
36
  button.with_leading_icon(name: "mail")
37
37
  "Continue"
38
38
  end
39
- assert_selector "button i[data-lucide='mail']"
39
+ assert_selector "button svg[data-icon='mail']"
40
40
  end
41
41
 
42
42
  def test_renders_trailing_icon_slot
@@ -44,7 +44,7 @@ class UI::ButtonToTest < ViewComponent::TestCase
44
44
  button.with_trailing_icon(name: "arrow-right")
45
45
  "Continue"
46
46
  end
47
- assert_selector "button i[data-lucide='arrow-right']"
47
+ assert_selector "button svg[data-icon='arrow-right']"
48
48
  end
49
49
 
50
50
  def test_loading_state_shows_spinner_and_disables
@@ -0,0 +1,187 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
4
+
5
+ class UI::ChartTest < ViewComponent::TestCase
6
+ def setup_fixtures(*); end
7
+ def teardown_fixtures(*); end
8
+
9
+ LABELS = %w[Jan Feb Mar].freeze
10
+
11
+ def render_chart(series: [ { name: "Sales", data: [ 1200, 1500.5, 900 ] } ], **opts)
12
+ render_inline(UI::Chart.new(labels: LABELS, series: series, **opts))
13
+ end
14
+
15
+ def two_series = [ { name: "This year", data: [ 1, 2, 3 ] }, { name: "Last year", data: [ 3, 2, 1 ] } ]
16
+
17
+ def config = JSON.parse(page.find("[data-slot='chart']")["data-ui--chart-config-value"])
18
+
19
+ def test_renders_the_controller_with_its_module_and_a_named_canvas
20
+ render_chart(label: "Monthly sales")
21
+ root = page.find("[data-slot='chart'][data-controller='ui--chart'][data-type='line']")
22
+ assert_match(/chart_js.*\.js\z/, root["data-ui--chart-module-url-value"])
23
+ assert_selector "canvas[role='img'][tabindex='0'][data-ui--chart-target='canvas']"
24
+ assert_includes page.find("canvas")["aria-label"], "Monthly sales."
25
+ assert_includes page.find("canvas")["aria-label"], "arrow keys"
26
+ end
27
+
28
+ def test_config_carries_the_type_labels_and_series
29
+ render_chart(type: :bar, stacked: true, series: two_series)
30
+ assert_equal "bar", config["type"]
31
+ assert config["stacked"]
32
+ assert_equal LABELS, config["labels"]
33
+ assert_equal [ "This year", "Last year" ], config["series"].map { |s| s["name"] }
34
+ assert_equal [ 1, 2, 3 ], config["series"].first["data"]
35
+ end
36
+
37
+ def test_stacked_only_applies_to_bars
38
+ render_chart(type: :line, stacked: true)
39
+ assert_equal false, config["stacked"]
40
+ end
41
+
42
+ def test_unknown_type_and_format_fall_back
43
+ render_chart(type: :radar, format: :weird)
44
+ assert_equal "line", config["type"]
45
+ assert_equal "number", config["axis"]["style"]
46
+ end
47
+
48
+ def test_series_take_the_colours_in_order_unless_given_one
49
+ render_chart(series: [ { name: "A", data: [ 1, 2, 3 ] }, { name: "B", data: [ 1, 2, 3 ], color: 5 }, { name: "C", data: [ 1, 2, 3 ], color: 9 } ])
50
+ assert_equal [ 1, 5, 3 ], config["series"].map { |s| s["color"] }
51
+ end
52
+
53
+ def test_more_than_five_series_is_refused
54
+ six = Array.new(6) { |i| { name: "S#{i}", data: [ 1, 2, 3 ] } }
55
+ error = assert_raises(ArgumentError) { render_chart(series: six) }
56
+ assert_includes error.message, "Other"
57
+ end
58
+
59
+ def test_a_series_must_have_a_value_for_each_label
60
+ error = assert_raises(ArgumentError) { render_chart(series: [ { name: "Short", data: [ 1, 2 ] } ]) }
61
+ assert_includes error.message, "Short"
62
+ end
63
+
64
+ def test_one_series_has_no_legend
65
+ render_chart
66
+ assert_no_selector "ul li"
67
+ end
68
+
69
+ def test_two_series_get_a_legend_with_swatches_shaped_like_the_marks
70
+ render_chart(series: two_series)
71
+ assert_selector "ul li", count: 2
72
+ assert_selector "ul li span.bg-chart-1.h-0\\.5"
73
+ assert_selector "ul li", text: "Last year"
74
+ render_chart(type: :bar, series: two_series)
75
+ assert_selector "ul li span.bg-chart-2.size-2\\.5"
76
+ end
77
+
78
+ def test_table_has_every_value_written_out
79
+ render_chart(label: "Monthly sales")
80
+ assert_selector "details summary", text: "Show the data"
81
+ assert_selector "table caption", text: "Monthly sales", visible: :all
82
+ assert_selector "th[scope='col']", text: "Sales", visible: :all
83
+ assert_selector "th[scope='row']", text: "Feb", visible: :all
84
+ assert_selector "td", text: "1,500.5", visible: :all
85
+ end
86
+
87
+ def test_currency_and_percent_formats
88
+ render_chart(format: :currency)
89
+ assert_selector "td", text: "$1,200.00", visible: :all
90
+ assert_equal [ "$1,200.00", "$1,500.50", "$900.00" ], config["series"].first["text"]
91
+ render_chart(format: :currency, unit: "₹")
92
+ assert_selector "td", text: "₹1,200.00", visible: :all
93
+ assert_equal "₹", config["axis"]["unit"]
94
+ render_chart(format: :percent, series: [ { name: "Margin", data: [ 38.25, 40, 41.5 ] } ])
95
+ assert_selector "td", text: "40%", visible: :all
96
+ assert_selector "td", text: "41.5%", visible: :all
97
+ end
98
+
99
+ def test_missing_values_leave_a_gap
100
+ render_chart(series: [ { name: "Sales", data: [ 1, nil, 3 ] } ])
101
+ assert_nil config["series"].first["data"][1]
102
+ assert_selector "td", text: "—", visible: :all
103
+ end
104
+
105
+ def render_pie(type: :pie, labels: %w[Card Cash UPI], data: [ 600, 300, 100 ], **opts)
106
+ render_inline(UI::Chart.new(type: type, labels: labels, series: [ { name: "Takings", data: data } ], **opts))
107
+ end
108
+
109
+ def test_pie_and_donut_are_types
110
+ render_pie
111
+ assert_equal "pie", config["type"]
112
+ render_pie(type: :donut)
113
+ assert_equal "donut", config["type"]
114
+ assert_selector "[data-slot='chart'][data-type='donut']"
115
+ end
116
+
117
+ def test_pie_slices_take_the_colours_in_order_and_carry_their_shares
118
+ render_pie
119
+ slice = config["series"].first
120
+ assert_equal [ 1, 2, 3 ], slice["colors"]
121
+ assert_equal %w[60% 30% 10%], slice["shares"]
122
+ end
123
+
124
+ def test_pie_legend_lists_each_slice_with_its_value_and_share
125
+ render_pie(format: :currency)
126
+ assert_selector "ul li", count: 3
127
+ assert_selector "ul li span.bg-chart-2.size-2\\.5"
128
+ assert_selector "ul li", text: /Cash\s*\$300\.00\s*30%/
129
+ end
130
+
131
+ def test_a_single_slice_still_gets_a_legend
132
+ render_pie(labels: %w[Card], data: [ 5 ])
133
+ assert_selector "ul li", count: 1
134
+ end
135
+
136
+ def test_pie_table_adds_a_share_column
137
+ render_pie
138
+ assert_selector "th[scope='col']", text: "Share", visible: :all
139
+ assert_selector "td", text: "60%", visible: :all
140
+ end
141
+
142
+ def test_donut_carries_its_total
143
+ render_pie(type: :donut, format: :currency)
144
+ assert_equal "$1,000.00", config["total"]
145
+ assert_equal "Total", config["total_label"]
146
+ end
147
+
148
+ def test_line_and_bar_carry_no_slices
149
+ render_chart
150
+ assert_nil config["total"]
151
+ assert_nil config["series"].first["shares"]
152
+ end
153
+
154
+ def test_pie_takes_one_series
155
+ error = assert_raises(ArgumentError) do
156
+ render_inline(UI::Chart.new(type: :pie, labels: LABELS, series: [ { name: "A", data: [ 1, 2, 3 ] }, { name: "B", data: [ 1, 2, 3 ] } ]))
157
+ end
158
+ assert_includes error.message, "one series"
159
+ end
160
+
161
+ def test_pie_draws_up_to_five_slices
162
+ error = assert_raises(ArgumentError) { render_pie(labels: %w[a b c d e f], data: [ 1, 1, 1, 1, 1, 1 ]) }
163
+ assert_includes error.message, "Other"
164
+ end
165
+
166
+ def test_pie_refuses_values_below_zero
167
+ error = assert_raises(ArgumentError) { render_pie(data: [ 5, -1, 3 ]) }
168
+ assert_includes error.message, "below zero"
169
+ end
170
+
171
+ def test_pie_with_no_total_shows_no_shares
172
+ render_pie(data: [ 0, 0, nil ])
173
+ assert_equal %w[— — —], config["series"].first["shares"]
174
+ end
175
+
176
+ def test_names_are_escaped
177
+ render_chart(series: [ { name: "<b>Sales</b>", data: [ 1, 2, 3 ] }, { name: "Other", data: [ 1, 2, 3 ] } ])
178
+ assert_no_selector "b"
179
+ assert_selector "li", text: "<b>Sales</b>"
180
+ end
181
+
182
+ def test_height_class_and_attributes
183
+ render_chart(height: 200, class: "max-w-xl", id: "sales", data: { foo: "bar" })
184
+ assert_selector "#sales.max-w-xl[data-foo='bar'][data-controller='ui--chart']"
185
+ assert_selector "div.relative[style='height: 200px'] canvas"
186
+ end
187
+ end
@@ -86,8 +86,8 @@ class UI::CheckboxTest < ViewComponent::TestCase
86
86
  def test_check_icon_inside_overlay
87
87
  render_inline(UI::Checkbox.new(name: "test"))
88
88
  overlay = page.find("span.pointer-events-none")
89
- icon = overlay.find("i", visible: :all)
90
- assert_equal "check", icon["data-lucide"]
89
+ icon = overlay.find("svg", visible: :all)
90
+ assert icon.matches_css?("[data-icon='check']")
91
91
  end
92
92
 
93
93
  def test_user_class_override_via_tailwind_merge
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
4
+
5
+ class UI::Command::GroupTest < ViewComponent::TestCase
6
+ def setup_fixtures(*); end
7
+ def teardown_fixtures(*); end
8
+
9
+ def test_a_group_named_by_its_heading
10
+ render_inline(UI::Command::Group.new(heading: "Pages")) { |g| g.with_item(label: "Home", href: "/") }
11
+ heading = page.find("[role='group'] > div", text: "Pages")
12
+ assert_selector "[role='group'][data-ui--command-target='group'][aria-labelledby='#{heading[:id]}'] [role='option']", text: "Home"
13
+ end
14
+
15
+ def test_a_group_without_a_heading
16
+ render_inline(UI::Command::Group.new(class: "pt-0")) { |g| g.with_item(label: "Home") }
17
+ assert_selector "[role='group'].pt-0:not([aria-labelledby])"
18
+ end
19
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
4
+
5
+ class UI::Command::ItemTest < ViewComponent::TestCase
6
+ def setup_fixtures(*); end
7
+ def teardown_fixtures(*); end
8
+
9
+ def test_an_option_carrying_what_the_controller_needs
10
+ render_inline(UI::Command::Item.new(label: "Settings", href: "/settings", id: "s"))
11
+ assert_selector "div#s[role='option'][aria-selected='false'][data-ui--command-target='item'][data-label='Settings'][data-href='/settings'][data-value='/settings']", text: "Settings"
12
+ end
13
+
14
+ def test_value_defaults_to_href_then_label
15
+ render_inline(UI::Command::Item.new(label: "New invoice", value: "new-invoice"))
16
+ assert_selector "[data-value='new-invoice']"
17
+ assert_no_selector "[data-href]"
18
+ render_inline(UI::Command::Item.new(label: "Log out"))
19
+ assert_selector "[data-value='Log out']"
20
+ end
21
+
22
+ def test_icon_description_and_keywords
23
+ render_inline(UI::Command::Item.new(label: "Invoices", icon: "receipt", description: "All bills, paid and unpaid", keywords: %w[bills money]))
24
+ assert_selector "span[aria-hidden='true'] svg[data-icon='receipt']"
25
+ assert_selector "span.text-xs.text-muted-foreground", text: "All bills, paid and unpaid"
26
+ assert_selector "[data-keywords='bills money']"
27
+ end
28
+
29
+ def test_a_shortcut_is_shown_and_bound_only_when_asked
30
+ render_inline(UI::Command::Item.new(label: "Settings", shortcut: "mod+,", id: "s"))
31
+ assert_selector "[role='option'] [data-slot='kbd'].ms-auto"
32
+ assert_no_selector "[data-ui--kbd-keys-value]"
33
+ render_inline(UI::Command::Item.new(label: "Settings", shortcut: "mod+,", bind: true, id: "s"))
34
+ assert_selector "[data-ui--kbd-keys-value='mod+,'][data-ui--kbd-target-value='#s']"
35
+ end
36
+
37
+ def test_disabled_items_say_so_and_do_not_bind
38
+ render_inline(UI::Command::Item.new(label: "Export", shortcut: "mod+e", bind: true, disabled: true))
39
+ assert_selector "[role='option'][aria-disabled='true']"
40
+ assert_no_selector "[data-ui--kbd-keys-value]"
41
+ end
42
+
43
+ def test_a_block_replaces_how_it_looks_but_not_its_label
44
+ render_inline(UI::Command::Item.new(label: "Ada Lovelace")) { "<strong>Ada</strong> Lovelace".html_safe }
45
+ assert_selector "[role='option'][data-label='Ada Lovelace'] strong", text: "Ada"
46
+ end
47
+ end
@@ -0,0 +1,110 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
4
+
5
+ class UI::CommandTest < ViewComponent::TestCase
6
+ def setup_fixtures(*); end
7
+ def teardown_fixtures(*); end
8
+
9
+ def render_command(**opts)
10
+ render_inline(UI::Command.new(id: "cmd", **opts)) do |command|
11
+ command.with_trigger if opts[:dialog]
12
+ command.with_group(heading: "Pages") do |group|
13
+ group.with_item(label: "Dashboard", href: "/dashboard", icon: "house")
14
+ group.with_item(label: "Settings", href: "/settings", shortcut: "mod+,")
15
+ end
16
+ command.with_group(heading: "Actions") do |group|
17
+ group.with_item(label: "New invoice", value: "new-invoice", keywords: %w[create bill])
18
+ end
19
+ end
20
+ end
21
+
22
+ def test_a_combobox_over_a_listbox
23
+ render_command
24
+ assert_selector "[data-controller='ui--command'] input#cmd-input[role='combobox'][aria-controls='cmd-list'][aria-expanded='true'][aria-autocomplete='list']"
25
+ assert_selector "#cmd-list[role='listbox'][aria-label='Command menu']"
26
+ assert_selector "input[placeholder='Type a command or search…'][aria-label='Command menu']"
27
+ end
28
+
29
+ def test_groups_and_items_are_listed_in_order
30
+ render_command
31
+ assert_equal %w[Pages Actions], page.all("[role='group'] > div:first-child").map(&:text)
32
+ assert_equal [ "Dashboard", "Settings", "New invoice" ], page.all("[role='option']").map { |o| o["data-label"] }
33
+ assert_selector "[role='group'][aria-labelledby]", count: 2
34
+ end
35
+
36
+ def test_on_a_page_it_is_the_panel_with_no_dialog_or_footer
37
+ render_command
38
+ assert_no_selector "dialog"
39
+ assert_no_selector "button[data-action='ui--command#open']"
40
+ assert_selector "[data-ui--command-dialog-value='false'][data-ui--command-shortcut-value='']"
41
+ assert_no_text "to move"
42
+ end
43
+
44
+ def test_as_a_dialog_it_has_a_trigger_a_shortcut_and_a_footer
45
+ render_command(dialog: true)
46
+ assert_selector "dialog[aria-label='Command menu'][data-ui--command-target='dialog'] [data-ui--command-target='panel']"
47
+ assert_selector "button[data-action='ui--command#open'][aria-haspopup='dialog']", text: "Search…"
48
+ assert_selector "button[data-action='ui--command#open'] [data-slot='kbd']"
49
+ assert_selector "[data-ui--command-dialog-value='true'][data-ui--command-shortcut-value='mod+k']"
50
+ assert_text "to move"
51
+ assert_text "to close"
52
+ end
53
+
54
+ def test_the_shortcut_can_change_or_go
55
+ render_command(dialog: true, shortcut: "/")
56
+ assert_selector "[data-ui--command-shortcut-value='/']"
57
+ render_command(dialog: true, shortcut: nil)
58
+ assert_selector "[data-ui--command-shortcut-value='']"
59
+ assert_no_selector "button[data-action='ui--command#open'] [data-slot='kbd']"
60
+ end
61
+
62
+ def test_more_than_one_shortcut_the_trigger_showing_the_first
63
+ render_inline(UI::Command.new(dialog: true, shortcut: [ "mod+k", "/" ])) { |c| c.with_trigger }
64
+ assert_selector "[data-ui--command-shortcut-value='mod+k /']"
65
+ assert_selector "button[data-action='ui--command#open'] [data-slot='kbd']", count: 1
66
+ assert_selector "button [data-slot='kbd'] kbd", text: "K"
67
+ end
68
+
69
+ def test_the_trigger_keeps_its_own_aria_and_data
70
+ render_inline(UI::Command.new(dialog: true)) do |c|
71
+ c.with_trigger(aria: { label: "Search the docs" }, data: { testid: "open", action: "click->other#thing" })
72
+ end
73
+ assert_selector "button[aria-label='Search the docs'][aria-haspopup='dialog'][data-testid='open']"
74
+ assert_selector "button[data-action='ui--command#open click->other#thing']"
75
+ end
76
+
77
+ def test_sorting_groups_and_saying_what_empty_means
78
+ render_command(sort_groups: true, empty: "Nothing like that here.")
79
+ assert_selector "[data-ui--command-sort-groups-value='true'][data-ui--command-empty-value='Nothing like that here.']"
80
+ render_command
81
+ assert_selector "[data-ui--command-sort-groups-value='false'][data-ui--command-empty-value='No results found.']"
82
+ end
83
+
84
+ def test_a_trigger_with_its_own_label_or_content
85
+ render_inline(UI::Command.new(dialog: true)) { |c| c.with_trigger(label: "Jump to…", class: "w-64") }
86
+ assert_selector "button.w-64", text: "Jump to…"
87
+ render_inline(UI::Command.new(dialog: true)) { |c| c.with_trigger(variant: :ghost) { "Open" } }
88
+ assert_selector "button[data-action='ui--command#open']", exact_text: "Open"
89
+ end
90
+
91
+ def test_searching_the_server_is_set_up_only_with_a_url
92
+ render_command
93
+ assert_no_selector "[data-ui--command-url-value]"
94
+ render_command(url: "/search", param: "term", results_heading: "Customers")
95
+ assert_selector "[data-ui--command-url-value='/search'][data-ui--command-param-value='term'][data-ui--command-results-heading-value='Customers']"
96
+ assert_selector "template[data-ui--command-target='template']", visible: :all
97
+ end
98
+
99
+ def test_messages_for_the_controller
100
+ render_command
101
+ assert_selector "[data-ui--command-empty-value='No results found.'][data-ui--command-searching-value='Searching…']"
102
+ assert_selector "[data-ui--command-target='empty'][hidden]", visible: :all
103
+ assert_selector "[data-ui--command-target='status'][role='status'][hidden]", visible: :all
104
+ end
105
+
106
+ def test_custom_placeholder_label_and_attributes
107
+ render_inline(UI::Command.new(placeholder: "Find a page", label: "Site search", class: "max-w-md", data: { testid: "c" }))
108
+ assert_selector "[data-controller='ui--command'].max-w-md[data-testid='c'] input[placeholder='Find a page'][aria-label='Site search']"
109
+ end
110
+ end