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,155 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
4
+
5
+ class UI::NumberInputTest < ViewComponent::TestCase
6
+ def setup_fixtures(*); end
7
+ def teardown_fixtures(*); end
8
+
9
+ def render_input(**opts) = render_inline(UI::NumberInput.new(name: "quantity", **opts))
10
+
11
+ def test_renders_a_number_input_in_a_group_with_the_controller
12
+ render_input
13
+ assert_selector "[data-slot='input-group'][data-controller='ui--number-input']"
14
+ assert_selector "input[type='number'][name='quantity'][data-ui--number-input-target='input']"
15
+ end
16
+
17
+ def test_passes_value_and_limits_to_the_input
18
+ render_input(value: 3, min: 1, max: 9, step: 2)
19
+ assert_selector "input[value='3'][min='1'][max='9'][step='2']"
20
+ end
21
+
22
+ def test_leaves_out_limits_that_are_not_set
23
+ render_input
24
+ assert_no_selector "input[min]"
25
+ assert_no_selector "input[max]"
26
+ assert_no_selector "input[step]"
27
+ end
28
+
29
+ def test_buttons_are_named_and_point_at_the_input
30
+ render_input(id: "qty")
31
+ assert_selector "button[aria-label='Decrease'][aria-controls='qty'][data-ui--number-input-target='decrement']"
32
+ assert_selector "button[aria-label='Increase'][aria-controls='qty'][data-ui--number-input-target='increment']"
33
+ assert_selector "input#qty"
34
+ end
35
+
36
+ def test_buttons_do_not_submit_and_stay_out_of_the_tab_order
37
+ render_input
38
+ assert_selector "button[type='button'][tabindex='-1']", count: 2
39
+ end
40
+
41
+ def test_buttons_are_wired_to_step_in_their_direction
42
+ render_input
43
+ assert_selector "button[data-ui--number-input-direction-param='down'] svg[data-icon='minus']"
44
+ assert_selector "button[data-ui--number-input-direction-param='up'] svg[data-icon='plus']"
45
+ assert_includes page.find("button[aria-label='Increase']")["data-action"], "pointerdown->ui--number-input#press"
46
+ end
47
+
48
+ def test_buttons_keep_the_kits_focus_ring
49
+ render_input
50
+ assert_selector "button.focus\\:ring-2.focus\\:ring-primary.focus\\:z-10", count: 2
51
+ assert_no_selector "button.focus\\:ring-0"
52
+ assert_no_selector "[data-slot='input-group'].overflow-hidden"
53
+ end
54
+
55
+ def test_decrease_comes_before_the_field_and_increase_after_it
56
+ render_input
57
+ assert_selector "[data-align='inline-start'] button[aria-label='Decrease']"
58
+ assert_selector "[data-align='inline-end'] button[aria-label='Increase']"
59
+ end
60
+
61
+ def test_label_points_at_the_field
62
+ render_input(label: "Quantity", id: "qty")
63
+ assert_selector "label[for='qty']", text: "Quantity"
64
+ end
65
+
66
+ def test_generates_an_id_for_the_label_and_buttons_to_share
67
+ render_input(label: "Quantity")
68
+ id = page.find("input")[:id]
69
+ assert_selector "label[for='#{id}']"
70
+ assert_selector "button[aria-controls='#{id}']", count: 2
71
+ end
72
+
73
+ def test_hint_describes_the_field
74
+ render_input(hint: "Up to 10")
75
+ assert_text "Up to 10"
76
+ assert page.find("input")["aria-describedby"].present?
77
+ end
78
+
79
+ def test_error_marks_the_field_invalid
80
+ render_input(error: "Too many")
81
+ assert_text "Too many"
82
+ assert_selector "input[aria-invalid='true']"
83
+ end
84
+
85
+ def test_disabled_turns_off_the_field_and_both_buttons
86
+ render_input(disabled: true)
87
+ assert_selector "input[disabled]"
88
+ assert_selector "button[disabled]", count: 2
89
+ end
90
+
91
+ def test_readonly_keeps_the_field_and_turns_off_both_buttons
92
+ render_input(readonly: true)
93
+ assert_selector "input[readonly]"
94
+ assert_no_selector "input[disabled]"
95
+ assert_selector "button[disabled]", count: 2
96
+ end
97
+
98
+ def test_required_reaches_the_field
99
+ render_input(required: true)
100
+ assert_selector "input[required]"
101
+ end
102
+
103
+ def test_sizes_set_the_height_of_the_group_and_width_of_the_buttons
104
+ { sm: %w[h-8 w-8], default: %w[h-9 w-9], lg: %w[h-12 w-12] }.each do |size, (height, width)|
105
+ render_input(size: size)
106
+ assert_selector "[data-slot='input-group'].#{height}"
107
+ assert_selector "button.#{width}", count: 2
108
+ end
109
+ end
110
+
111
+ def test_unknown_size_falls_back_to_default
112
+ render_input(size: :huge)
113
+ assert_selector "[data-slot='input-group'].h-9"
114
+ end
115
+
116
+ def test_keypad_suits_what_the_field_takes
117
+ { { min: 0 } => "numeric", { min: 1, step: 2 } => "numeric", { step: 0.25 } => "decimal",
118
+ { min: 0, step: 0.5 } => "decimal", { step: "any" } => "decimal" }.each do |opts, mode|
119
+ render_input(**opts)
120
+ assert_selector "input[inputmode='#{mode}']"
121
+ end
122
+ end
123
+
124
+ def test_no_numeric_keypad_when_the_field_can_go_negative
125
+ render_input
126
+ assert_no_selector "input[inputmode]"
127
+ render_input(min: -5)
128
+ assert_no_selector "input[inputmode]"
129
+ end
130
+
131
+ def test_inputmode_can_be_overridden
132
+ render_input(min: 0, inputmode: "text")
133
+ assert_selector "input[inputmode='text']"
134
+ end
135
+
136
+ def test_data_and_actions_from_the_caller_join_the_controllers
137
+ render_input(data: { foo: "bar", action: "change->cart#update" })
138
+ input = page.find("input")
139
+ assert_equal "bar", input["data-foo"]
140
+ assert_includes input["data-action"], "change->cart#update"
141
+ assert_includes input["data-action"], "input->ui--number-input#sync"
142
+ end
143
+
144
+ def test_class_reaches_the_group
145
+ render_input(class: "w-32")
146
+ assert_selector "[data-slot='input-group'].w-32"
147
+ end
148
+
149
+ def test_form_builder_names_the_field_and_fills_it_in
150
+ item = Struct.new(:quantity).new(4)
151
+ builder = ActionView::Helpers::FormBuilder.new(:item, item, vc_test_controller.view_context, {})
152
+ render_inline(UI::NumberInput.new(form: builder, field: :quantity, min: 1))
153
+ assert_selector "input[type='number'][name='item[quantity]'][value='4'][min='1']"
154
+ end
155
+ end
@@ -0,0 +1,188 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
4
+
5
+ class UI::ProgressTest < ViewComponent::TestCase
6
+ def setup_fixtures(*); end
7
+ def teardown_fixtures(*); end
8
+
9
+ def render_progress(**opts) = render_inline(UI::Progress.new(**opts))
10
+
11
+ def test_renders_a_progressbar_filled_to_its_value
12
+ render_progress(value: 40)
13
+ assert_selector "[data-slot='progress'][data-controller='ui--progress']"
14
+ assert_selector "[role='progressbar'][aria-valuemin='0'][aria-valuemax='100'][aria-valuenow='40'][aria-valuetext='40%']"
15
+ assert_selector "[data-slot='progress-indicator'][style='width: 40%']"
16
+ end
17
+
18
+ def test_scales_to_max_and_says_it_with_value_text
19
+ render_progress(value: 3, max: 12, value_text: "%{value} of %{max} files", show_value: true)
20
+ assert_selector "[role='progressbar'][aria-valuenow='3'][aria-valuemax='12'][aria-valuetext='3 of 12 files']"
21
+ assert_selector "[data-slot='progress-indicator'][style='width: 25%']"
22
+ assert_selector "[data-ui--progress-target='text']", text: "3 of 12 files"
23
+ assert_selector "[data-ui--progress-format-value='%{value} of %{max} files']"
24
+ end
25
+
26
+ def test_rounds_down_so_it_never_says_done_too_early
27
+ render_progress(value: 99.7)
28
+ assert_selector "[role='progressbar'][aria-valuetext='99%']"
29
+ assert_selector "[data-slot='progress-indicator'][style='width: 99%']"
30
+ end
31
+
32
+ def test_keeps_the_value_inside_the_bar
33
+ render_progress(value: 150)
34
+ assert_selector "[role='progressbar'][aria-valuenow='100'][data-state='complete']"
35
+ render_progress(value: -5)
36
+ assert_selector "[role='progressbar'][aria-valuenow='0'][data-state='loading']"
37
+ end
38
+
39
+ def test_is_busy_until_complete
40
+ render_progress(value: 50)
41
+ assert_selector "[role='progressbar'][aria-busy='true'][data-state='loading']"
42
+ render_progress(value: 100)
43
+ assert_selector "[role='progressbar'][data-state='complete']"
44
+ assert_no_selector "[aria-busy]"
45
+ end
46
+
47
+ def test_with_no_value_it_shows_work_going_on_without_an_amount
48
+ render_progress(label: "Preparing your export", show_value: true)
49
+ assert_selector "[role='progressbar'][data-state='indeterminate'][aria-busy='true']"
50
+ assert_no_selector "[aria-valuenow]"
51
+ assert_no_selector "[aria-valuetext]"
52
+ assert_no_selector "[data-ui--progress-value-value]"
53
+ assert_selector "[data-slot='progress-indicator'].animate-\\[velvetkit-progress_1\\.4s_ease-in-out_infinite\\]"
54
+ assert_no_selector "[data-slot='progress-indicator'][style]"
55
+ assert_selector "[data-ui--progress-target='text'].hidden"
56
+ end
57
+
58
+ def test_the_label_names_the_bar
59
+ render_progress(value: 10, label: "Uploading report.pdf")
60
+ id = page.find("span", text: "Uploading report.pdf")["id"]
61
+ assert_selector "[role='progressbar'][aria-labelledby='#{id}']"
62
+ assert_no_selector "[role='progressbar'][aria-label]"
63
+ end
64
+
65
+ def test_without_a_label_it_has_a_default_name_that_can_be_replaced
66
+ render_progress(value: 10)
67
+ assert_selector "[role='progressbar'][aria-label='Progress']"
68
+ assert_no_selector "[data-slot='progress'] > div.flex"
69
+ render_progress(value: 10, aria: { label: "Storage used" })
70
+ assert_selector "[role='progressbar'][aria-label='Storage used']"
71
+ end
72
+
73
+ def test_value_is_shown_only_when_asked
74
+ render_progress(value: 40, label: "Profile")
75
+ assert_selector "[data-ui--progress-target='text'].hidden"
76
+ render_progress(value: 40, label: "Profile", show_value: true)
77
+ assert_selector "[data-ui--progress-target='text']:not(.hidden)", text: "40%"
78
+ end
79
+
80
+ def test_sizes_and_tones
81
+ render_progress(value: 5, size: :lg, tone: :warning)
82
+ assert_selector "[role='progressbar'].h-3.bg-amber-500\\/15"
83
+ assert_selector "[data-slot='progress-indicator'].bg-amber-500"
84
+ render_progress(value: 5, size: :nonsense, tone: :nonsense)
85
+ assert_selector "[role='progressbar'].h-2.bg-primary\\/15"
86
+ end
87
+
88
+ def test_gives_the_controller_what_it_needs_to_move_the_bar
89
+ render_progress(value: 2.5, max: 10)
90
+ assert_selector "[data-ui--progress-value-value='2.5'][data-ui--progress-max-value='10']"
91
+ assert_selector "[data-ui--progress-determinate-class][data-ui--progress-indeterminate-class]"
92
+ assert_selector "[role='progressbar'][data-ui--progress-target='bar'] [data-ui--progress-target='indicator']"
93
+ end
94
+
95
+ def render_storage(**opts)
96
+ render_inline(UI::Progress.new(max: 15, label: "Storage", value_text: "%{value} GB of %{max} GB",
97
+ segment_text: "%{value} GB", show_value: true, **opts)) do |progress|
98
+ progress.with_segment(value: 6.4, label: "Photos")
99
+ progress.with_segment(value: 3.1, label: "Mail")
100
+ progress.with_segment(value: 2, label: "Documents", color: 5)
101
+ end
102
+ end
103
+
104
+ def test_segments_add_up_to_the_bars_value
105
+ render_storage
106
+ assert_selector "[role='progressbar'][aria-valuenow='11.5'][aria-valuetext='11.5 GB of 15 GB']"
107
+ assert_selector "[data-ui--progress-target='text']", text: "11.5 GB of 15 GB"
108
+ assert_selector "[data-slot='progress-indicator'][style='width: 76%']"
109
+ assert_selector "[data-ui--progress-value-value='11.5']"
110
+ end
111
+
112
+ def test_each_segment_is_sized_by_its_share_and_coloured_in_turn
113
+ render_storage
114
+ segments = page.all("[data-slot='progress-indicator'] > [data-slot='progress-segment']")
115
+ assert_equal [ "flex: 6.4 1 0%", "flex: 3.1 1 0%", "flex: 2 1 0%" ], segments.map { |s| s["style"] }
116
+ assert_equal %w[bg-chart-1 bg-chart-2 bg-chart-5], segments.map { |s| s["class"][/bg-chart-\d/] }
117
+ assert_equal "Photos: 6.4 GB", segments.first["title"]
118
+ assert_selector "[data-slot='progress-indicator'].flex:not(.bg-primary)"
119
+ end
120
+
121
+ def test_a_legend_names_each_segment_with_its_amount
122
+ render_storage
123
+ items = page.all("[data-slot='progress-legend'] li").map { |li| li.text.squish }
124
+ assert_equal [ "Photos 6.4 GB", "Mail 3.1 GB", "Documents 2 GB" ], items
125
+ assert_selector "[data-slot='progress-legend'] li span.bg-chart-5.rounded-full", count: 1
126
+ end
127
+
128
+ def test_the_legend_can_be_left_out_and_the_amounts_written_per_segment
129
+ render_inline(UI::Progress.new(max: 100, legend: false, segment_text: "%{percent}%")) do |progress|
130
+ progress.with_segment(value: 30, label: "Done")
131
+ progress.with_segment(value: 10, label: "In review", value_text: "10 tasks")
132
+ end
133
+ assert_no_selector "[data-slot='progress-legend']"
134
+ assert_equal [ "Done: 30%", "In review: 10 tasks" ], page.all("[data-slot='progress-segment']").map { |s| s["title"] }
135
+ end
136
+
137
+ def test_segments_past_max_are_capped_at_a_full_bar
138
+ render_inline(UI::Progress.new(max: 10)) do |progress|
139
+ progress.with_segment(value: 8, label: "A")
140
+ progress.with_segment(value: 7, label: "B")
141
+ progress.with_segment(value: -3, label: "C")
142
+ end
143
+ assert_selector "[role='progressbar'][aria-valuenow='10'][data-state='complete']"
144
+ end
145
+
146
+ def test_segments_with_no_max_fill_the_bar_as_shares_of_a_whole
147
+ render_inline(UI::Progress.new(label: "Visits by source")) do |progress|
148
+ progress.with_segment(value: 5_210, label: "Search")
149
+ progress.with_segment(value: 2_870, label: "Direct")
150
+ progress.with_segment(value: 1_420, label: "Social")
151
+ end
152
+ assert_selector "[role='progressbar'][aria-valuenow='9500'][aria-valuemax='9500'][data-state='complete']"
153
+ assert_selector "[data-slot='progress-indicator'][style='width: 100%']"
154
+ assert_selector "[data-ui--progress-max-value='9500']"
155
+ assert_no_selector "[aria-busy]"
156
+ items = page.all("[data-slot='progress-legend'] li").map { |li| li.text.squish }
157
+ assert_equal [ "Search 55%", "Direct 30%", "Social 15%" ], items
158
+ end
159
+
160
+ def test_shares_of_a_whole_can_still_show_their_values
161
+ render_inline(UI::Progress.new(segment_text: "%{value} visits")) do |progress|
162
+ progress.with_segment(value: 30, label: "Search")
163
+ progress.with_segment(value: 10, label: "Direct")
164
+ end
165
+ assert_equal [ "Search 30 visits", "Direct 10 visits" ],
166
+ page.all("[data-slot='progress-legend'] li").map { |li| li.text.squish }
167
+ end
168
+
169
+ def test_segments_that_add_up_to_nothing_leave_the_bar_empty
170
+ render_inline(UI::Progress.new(label: "Nothing yet")) do |progress|
171
+ progress.with_segment(value: 0, label: "Search")
172
+ end
173
+ assert_selector "[role='progressbar'][aria-valuenow='0'][aria-valuemax='100'][data-state='loading']"
174
+ assert_selector "[data-slot='progress-indicator'][style='width: 0%']"
175
+ end
176
+
177
+ def test_a_single_bar_has_no_segments_or_legend
178
+ render_progress(value: 40, label: "Upload")
179
+ assert_no_selector "[data-slot='progress-segment']"
180
+ assert_no_selector "[data-slot='progress-legend']"
181
+ assert_selector "[data-slot='progress-indicator'].bg-primary"
182
+ end
183
+
184
+ def test_passes_class_and_attributes_through
185
+ render_progress(value: 1, id: "upload", class: "max-w-sm", data: { turbo_permanent: true })
186
+ assert_selector "#upload.w-full.max-w-sm[data-turbo-permanent][data-controller='ui--progress']"
187
+ end
188
+ end
@@ -192,4 +192,66 @@ class UI::SelectTest < ViewComponent::TestCase
192
192
  refute_selector "button[aria-describedby]"
193
193
  refute_selector "p.text-destructive"
194
194
  end
195
+
196
+ # ── Searching the server ──────────────────────────────────────────────────
197
+
198
+ def render_remote(**opts)
199
+ render_inline(UI::Select.new(name: "order[customer_id]", url: "/customers/search", **opts))
200
+ end
201
+
202
+ def test_url_searches_the_server_with_a_search_box
203
+ render_remote
204
+ root = page.find("[data-controller='ui--select']")
205
+ assert_equal "/customers/search", root["data-ui--select-url-value"]
206
+ assert_equal "q", root["data-ui--select-param-value"]
207
+ assert_selector "input[type='search'][data-ui--select-target='search']", visible: :all
208
+ end
209
+
210
+ def test_param_renames_the_query
211
+ render_remote(param: "term")
212
+ assert_equal "term", page.find("[data-controller='ui--select']")["data-ui--select-param-value"]
213
+ end
214
+
215
+ def test_remote_says_when_searching_or_failing
216
+ render_remote
217
+ root = page.find("[data-controller='ui--select']")
218
+ assert_equal "Searching…", root["data-ui--select-searching-value"]
219
+ assert_includes root["data-ui--select-failed-value"], "Couldn't load"
220
+ assert_selector "[data-ui--select-target='status'][role='status']", visible: :all
221
+ end
222
+
223
+ def test_remote_search_box_has_a_spinner_in_waiting
224
+ render_remote
225
+ assert_selector "[data-ui--select-target='searchIcon'] svg[data-icon='search']", visible: :all
226
+ assert_selector "[data-ui--select-target='spinner'].hidden[aria-hidden='true'] svg[data-icon='loader'].animate-spin", visible: :all
227
+ end
228
+
229
+ def test_remote_options_are_built_from_a_template_with_the_options_classes
230
+ render_remote
231
+ template = rendered_content[%r{<template data-ui--select-target="template">.*?</template>}m]
232
+ assert template, "no option template"
233
+ assert_includes template, 'role="option"'
234
+ assert_includes template, 'data-ui--select-target="check"'
235
+ end
236
+
237
+ def test_remote_starts_with_the_options_given_so_an_edit_form_names_its_choice
238
+ render_remote(options: [ [ "Acme Traders", 7 ] ], selected: 7)
239
+ assert_selector "[role='option'][data-value='7'][aria-selected='true']", text: "Acme Traders", visible: :all
240
+ assert_selector "button[role='combobox']", text: "Acme Traders"
241
+ assert_selector "select[name='order[customer_id]'] option[value='7'][selected]", visible: :all
242
+ end
243
+
244
+ def test_remote_with_nothing_chosen_shows_the_prompt
245
+ render_remote(prompt: "Find a customer")
246
+ assert_selector "button[role='combobox']", text: "Find a customer"
247
+ end
248
+
249
+ def test_without_url_there_is_no_server_search
250
+ render_inline(UI::Select.new(name: "plan", options: %w[Free Pro], searchable: true))
251
+ root = page.find("[data-controller='ui--select']")
252
+ assert_nil root["data-ui--select-url-value"]
253
+ assert_no_selector "template", visible: :all
254
+ assert_no_selector "[data-ui--select-target='spinner']", visible: :all
255
+ assert_no_selector "[data-ui--select-target='status']", visible: :all
256
+ end
195
257
  end
@@ -169,16 +169,16 @@ class UI::SessionTabsTest < ViewComponent::TestCase
169
169
  assert_equal "pointerdown->ui--session-tabs#dragStart", handle["data-action"]
170
170
  assert_equal "true", handle["aria-hidden"]
171
171
  assert_includes handle[:class], "touch-none"
172
- assert handle.has_selector?("[data-lucide='grip-vertical']", visible: :all)
172
+ assert handle.has_selector?("[data-icon='grip-vertical']", visible: :all)
173
173
  end
174
174
 
175
175
  def test_controls_reveal_on_hover_and_slide_in
176
176
  render_tabs do |t|
177
177
  t.with_tab(value: "a", move: true, rename: true) { "Alpha" }
178
178
  end
179
- grip = page.find("[data-ui--session-tabs-target='handle'] [data-lucide]", visible: :all)[:class]
179
+ grip = page.find("[data-ui--session-tabs-target='handle'] [data-icon]", visible: :all)[:class]
180
180
  menu = page.find("[data-ui--session-tabs-target='menuTrigger']")[:class]
181
- dots = page.find("[data-ui--session-tabs-target='menuTrigger'] [data-lucide]", visible: :all)[:class]
181
+ dots = page.find("[data-ui--session-tabs-target='menuTrigger'] [data-icon]", visible: :all)[:class]
182
182
  [ grip, menu ].each do |classes|
183
183
  assert_includes classes, "opacity-0"
184
184
  assert_includes classes, "group-hover/tab:opacity-100"
@@ -8,56 +8,56 @@ class UI::SpinnerTest < ViewComponent::TestCase
8
8
 
9
9
  def test_renders_loader_icon_with_animate_spin
10
10
  render_inline UI::Spinner.new
11
- icon = page.find("i", visible: :all)
12
- assert_equal "loader", icon["data-lucide"]
11
+ icon = page.find("svg", visible: :all)
12
+ assert icon.matches_css?("[data-icon='loader']")
13
13
  assert_includes icon[:class].split, "animate-spin"
14
14
  end
15
15
 
16
16
  def test_default_size_classes
17
17
  render_inline UI::Spinner.new
18
- classes = page.find("i", visible: :all)[:class].split
18
+ classes = page.find("svg", visible: :all)[:class].split
19
19
  assert_includes classes, "w-5"
20
20
  assert_includes classes, "h-5"
21
21
  end
22
22
 
23
23
  def test_size_xs
24
24
  render_inline UI::Spinner.new(size: :xs)
25
- classes = page.find("i", visible: :all)[:class].split
25
+ classes = page.find("svg", visible: :all)[:class].split
26
26
  assert_includes classes, "w-3"
27
27
  assert_includes classes, "h-3"
28
28
  end
29
29
 
30
30
  def test_size_sm
31
31
  render_inline UI::Spinner.new(size: :sm)
32
- classes = page.find("i", visible: :all)[:class].split
32
+ classes = page.find("svg", visible: :all)[:class].split
33
33
  assert_includes classes, "w-4"
34
34
  assert_includes classes, "h-4"
35
35
  end
36
36
 
37
37
  def test_size_lg
38
38
  render_inline UI::Spinner.new(size: :lg)
39
- classes = page.find("i", visible: :all)[:class].split
39
+ classes = page.find("svg", visible: :all)[:class].split
40
40
  assert_includes classes, "w-6"
41
41
  assert_includes classes, "h-6"
42
42
  end
43
43
 
44
44
  def test_size_xl
45
45
  render_inline UI::Spinner.new(size: :xl)
46
- classes = page.find("i", visible: :all)[:class].split
46
+ classes = page.find("svg", visible: :all)[:class].split
47
47
  assert_includes classes, "w-8"
48
48
  assert_includes classes, "h-8"
49
49
  end
50
50
 
51
51
  def test_user_class_merges
52
52
  render_inline UI::Spinner.new(class: "text-primary")
53
- classes = page.find("i", visible: :all)[:class].split
53
+ classes = page.find("svg", visible: :all)[:class].split
54
54
  assert_includes classes, "text-primary"
55
55
  assert_includes classes, "animate-spin"
56
56
  end
57
57
 
58
58
  def test_html_attrs_pass_through
59
59
  render_inline UI::Spinner.new(aria: { label: "Loading" })
60
- icon = page.find("i", visible: :all)
60
+ icon = page.find("svg", visible: :all)
61
61
  assert_equal "Loading", icon["aria-label"]
62
62
  end
63
63
  end