nitro_kit 2.0.0.beta.3 → 2.0.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 (326) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +37 -0
  3. data/LICENSE +21 -28
  4. data/README.md +10 -9
  5. data/app/assets/stylesheets/nitro_kit.css +1660 -1401
  6. data/app/components/nitro_kit/accordion.rb +1 -13
  7. data/app/components/nitro_kit/app_navigation.rb +0 -12
  8. data/app/components/nitro_kit/app_shell.rb +5 -11
  9. data/app/components/nitro_kit/appearance_picker.rb +1 -7
  10. data/app/components/nitro_kit/combobox.rb +366 -21
  11. data/app/components/nitro_kit/command_palette.rb +7 -20
  12. data/app/components/nitro_kit/details_table.rb +5 -11
  13. data/app/components/nitro_kit/dropzone.rb +3 -15
  14. data/app/components/nitro_kit/field.rb +20 -2
  15. data/app/components/nitro_kit/pagination.rb +2 -8
  16. data/app/components/nitro_kit/settings_layout.rb +3 -9
  17. data/app/javascript/controllers/nk/app_shell_controller.js +2 -2
  18. data/app/javascript/controllers/nk/combobox_controller.js +308 -22
  19. data/app/javascript/controllers/nk/combobox_remote.js +70 -0
  20. data/app/javascript/controllers/nk/dropzone_controller.js +2 -2
  21. data/app/javascript/controllers/nk/tabs_controller.js +2 -2
  22. data/config/locales/en.yml +3 -0
  23. data/docs/agent_guide.md +43 -13
  24. data/docs/component_contracts.md +90 -61
  25. data/docs/customization.md +173 -35
  26. data/docs/initialization_prompt.md +4 -5
  27. data/docs/migration_1_to_2.md +10 -8
  28. data/docs/patterns/application_foundation.md +5 -0
  29. data/docs/patterns/composition.md +61 -0
  30. data/docs/patterns/crud_resource.md +5 -0
  31. data/docs/patterns/inset_workspace.md +21 -22
  32. data/docs/patterns/resource_form.md +65 -0
  33. data/docs/rails_integration.md +214 -2
  34. data/lib/generators/nitro_kit/install_generator.rb +5 -4
  35. data/lib/nitro_kit/installation.rb +327 -68
  36. data/lib/nitro_kit/migration_inventory.rb +18 -3
  37. data/lib/nitro_kit/version.rb +1 -1
  38. data/lib/rails/commands/nitro_kit/nitro_kit_command.rb +2 -2
  39. data/patterns/README.md +21 -0
  40. data/patterns/account-settings/files/app/components/ui/account_settings/account_deletion.rb +72 -0
  41. data/patterns/account-settings/files/app/components/ui/account_settings/base.rb +44 -0
  42. data/patterns/account-settings/files/app/components/ui/account_settings/page.rb +57 -0
  43. data/patterns/account-settings/files/app/components/ui/account_settings/preferences.rb +68 -0
  44. data/patterns/account-settings/files/app/components/ui/account_settings/profile.rb +86 -0
  45. data/patterns/account-settings/files/app/components/ui/account_settings/security.rb +69 -0
  46. data/patterns/account-settings/files/app/components/ui/account_settings/sessions.rb +86 -0
  47. data/patterns/account-settings/files/app/controllers/settings/account_deletions_controller.rb +35 -0
  48. data/patterns/account-settings/files/app/controllers/settings/base_controller.rb +12 -0
  49. data/patterns/account-settings/files/app/controllers/settings/other_sessions_controller.rb +8 -0
  50. data/patterns/account-settings/files/app/controllers/settings/preferences_controller.rb +27 -0
  51. data/patterns/account-settings/files/app/controllers/settings/profiles_controller.rb +20 -0
  52. data/patterns/account-settings/files/app/controllers/settings/securities_controller.rb +37 -0
  53. data/patterns/account-settings/files/app/controllers/settings/sessions_controller.rb +31 -0
  54. data/patterns/account-settings/files/app/models/account_settings/account_closure.rb +33 -0
  55. data/patterns/account-settings/files/app/models/account_settings/password_change.rb +42 -0
  56. data/patterns/account-settings/files/app/models/account_settings/session_summary.rb +45 -0
  57. data/patterns/account-settings/files/app/models/concerns/user/account_configurable.rb +18 -0
  58. data/patterns/account-settings/files/config/routes/account_settings.rb +10 -0
  59. data/patterns/account-settings/files/db/migrate/20260731020000_add_account_settings.rb +27 -0
  60. data/patterns/account-settings/files/test/controllers/settings/account_settings_flow_test.rb +84 -0
  61. data/patterns/account-settings/files/test/models/account_settings/password_change_test.rb +40 -0
  62. data/patterns/account-settings/files/test/system/account_settings_test.rb +52 -0
  63. data/patterns/account-settings/item.yml +4 -0
  64. data/patterns/account-settings/pattern.md +44 -0
  65. data/patterns/application-shell/files/app/assets/stylesheets/ui/application_shell.css +267 -0
  66. data/patterns/application-shell/files/app/components/ui/application_shell.rb +184 -0
  67. data/patterns/application-shell/item.yml +4 -0
  68. data/patterns/application-shell/pattern.md +110 -0
  69. data/patterns/authentication/files/app/components/ui/authentication/base.rb +11 -0
  70. data/patterns/authentication/files/app/components/ui/authentication/page.rb +53 -0
  71. data/patterns/authentication/files/app/components/ui/email_verifications/show.rb +62 -0
  72. data/patterns/authentication/files/app/components/ui/password_resets/new.rb +65 -0
  73. data/patterns/authentication/files/app/components/ui/passwords/edit.rb +72 -0
  74. data/patterns/authentication/files/app/components/ui/sessions/new.rb +58 -0
  75. data/patterns/authentication/files/app/components/ui/verification_emails/new.rb +59 -0
  76. data/patterns/authentication/files/app/controllers/concerns/authentication.rb +66 -0
  77. data/patterns/authentication/files/app/controllers/concerns/safe_return_navigation.rb +37 -0
  78. data/patterns/authentication/files/app/controllers/email_verifications_controller.rb +39 -0
  79. data/patterns/authentication/files/app/controllers/password_resets_controller.rb +33 -0
  80. data/patterns/authentication/files/app/controllers/passwords_controller.rb +51 -0
  81. data/patterns/authentication/files/app/controllers/sessions_controller.rb +42 -0
  82. data/patterns/authentication/files/app/controllers/verification_emails_controller.rb +33 -0
  83. data/patterns/authentication/files/app/jobs/authentication_delivery_job.rb +17 -0
  84. data/patterns/authentication/files/app/mailers/authentication_mailer.rb +15 -0
  85. data/patterns/authentication/files/app/models/authentication/credentials.rb +16 -0
  86. data/patterns/authentication/files/app/models/authentication/email_request.rb +17 -0
  87. data/patterns/authentication/files/app/models/concerns/user/email_verifiable.rb +40 -0
  88. data/patterns/authentication/files/app/models/session.rb +5 -0
  89. data/patterns/authentication/files/app/views/authentication_mailer/email_verification.html.erb +3 -0
  90. data/patterns/authentication/files/app/views/authentication_mailer/email_verification.text.erb +5 -0
  91. data/patterns/authentication/files/app/views/authentication_mailer/password_reset.html.erb +3 -0
  92. data/patterns/authentication/files/app/views/authentication_mailer/password_reset.text.erb +5 -0
  93. data/patterns/authentication/files/config/routes/authentication.rb +11 -0
  94. data/patterns/authentication/files/db/migrate/20260731000000_add_authentication_and_recovery.rb +13 -0
  95. data/patterns/authentication/files/test/controllers/authentication_flow_test.rb +103 -0
  96. data/patterns/authentication/files/test/controllers/safe_return_navigation_test.rb +18 -0
  97. data/patterns/authentication/files/test/mailers/authentication_mailer_test.rb +21 -0
  98. data/patterns/authentication/files/test/models/user_email_verifiable_test.rb +36 -0
  99. data/patterns/authentication/files/test/system/authentication_flow_test.rb +23 -0
  100. data/patterns/authentication/item.yml +12 -0
  101. data/patterns/authentication/pattern.md +54 -0
  102. data/patterns/crud-resource/files/app/assets/stylesheets/ui/projects.css +4 -0
  103. data/patterns/crud-resource/files/app/components/ui/projects/form.rb +89 -0
  104. data/patterns/crud-resource/files/app/components/ui/projects/index.rb +161 -0
  105. data/patterns/crud-resource/files/app/components/ui/projects/show.rb +84 -0
  106. data/patterns/crud-resource/files/app/controllers/projects/archivals_controller.rb +23 -0
  107. data/patterns/crud-resource/files/app/controllers/projects_controller.rb +70 -0
  108. data/patterns/crud-resource/files/app/models/project/archival.rb +8 -0
  109. data/patterns/crud-resource/files/app/models/project/event.rb +12 -0
  110. data/patterns/crud-resource/files/app/models/project/filter.rb +41 -0
  111. data/patterns/crud-resource/files/app/models/project.rb +41 -0
  112. data/patterns/crud-resource/files/app/views/projects/edit.html.erb +19 -0
  113. data/patterns/crud-resource/files/app/views/projects/index.html.erb +18 -0
  114. data/patterns/crud-resource/files/app/views/projects/new.html.erb +16 -0
  115. data/patterns/crud-resource/files/app/views/projects/show.html.erb +28 -0
  116. data/patterns/crud-resource/files/config/routes/crud_resource.rb +7 -0
  117. data/patterns/crud-resource/files/db/migrate/20260720000000_create_crud_resource.rb +37 -0
  118. data/patterns/crud-resource/files/test/controllers/projects_controller_test.rb +64 -0
  119. data/patterns/crud-resource/files/test/models/project_test.rb +34 -0
  120. data/patterns/crud-resource/files/test/support/crud_resource_test_helpers.rb +25 -0
  121. data/patterns/crud-resource/files/test/system/projects_crud_test.rb +87 -0
  122. data/patterns/crud-resource/item.yml +6 -0
  123. data/patterns/crud-resource/pattern.md +48 -0
  124. data/patterns/file-uploads/files/app/assets/stylesheets/ui/uploads.css +133 -0
  125. data/patterns/file-uploads/files/app/components/ui/uploads/base.rb +30 -0
  126. data/patterns/file-uploads/files/app/components/ui/uploads/index.rb +188 -0
  127. data/patterns/file-uploads/files/app/components/ui/uploads/page.rb +33 -0
  128. data/patterns/file-uploads/files/app/controllers/uploads/base_controller.rb +29 -0
  129. data/patterns/file-uploads/files/app/controllers/uploads/direct_uploads_controller.rb +55 -0
  130. data/patterns/file-uploads/files/app/controllers/uploads/retries_controller.rb +14 -0
  131. data/patterns/file-uploads/files/app/controllers/uploads_controller.rb +40 -0
  132. data/patterns/file-uploads/files/app/jobs/upload_blob_cleanup_job.rb +9 -0
  133. data/patterns/file-uploads/files/app/jobs/upload_processing_job.rb +10 -0
  134. data/patterns/file-uploads/files/app/jobs/upload_repair_job.rb +17 -0
  135. data/patterns/file-uploads/files/app/models/concerns/team/uploadable.rb +9 -0
  136. data/patterns/file-uploads/files/app/models/upload.rb +295 -0
  137. data/patterns/file-uploads/files/config/recurring/uploads.yml +7 -0
  138. data/patterns/file-uploads/files/config/routes/uploads.rb +5 -0
  139. data/patterns/file-uploads/files/db/migrate/20260802000000_add_file_uploads.rb +30 -0
  140. data/patterns/file-uploads/files/test/controllers/uploads_flow_test.rb +77 -0
  141. data/patterns/file-uploads/files/test/fixtures/files/workspace.png.base64 +1 -0
  142. data/patterns/file-uploads/files/test/fixtures/uploads.yml +17 -0
  143. data/patterns/file-uploads/files/test/models/upload_test.rb +55 -0
  144. data/patterns/file-uploads/files/test/system/file_uploads_test.rb +30 -0
  145. data/patterns/file-uploads/item.yml +4 -0
  146. data/patterns/file-uploads/pattern.md +71 -0
  147. data/patterns/nitro-kit-1-upgrade/files/docs/nitro_kit_1_upgrade.md +57 -0
  148. data/patterns/nitro-kit-1-upgrade/item.yml +4 -0
  149. data/patterns/nitro-kit-1-upgrade/pattern.md +30 -0
  150. data/patterns/onboarding/files/app/assets/stylesheets/ui/onboarding.css +55 -0
  151. data/patterns/onboarding/files/app/components/ui/onboarding/base.rb +11 -0
  152. data/patterns/onboarding/files/app/components/ui/onboarding/branch_form.rb +36 -0
  153. data/patterns/onboarding/files/app/components/ui/onboarding/details_form.rb +67 -0
  154. data/patterns/onboarding/files/app/components/ui/onboarding/invitation_plan_form.rb +48 -0
  155. data/patterns/onboarding/files/app/components/ui/onboarding/page.rb +75 -0
  156. data/patterns/onboarding/files/app/components/ui/onboarding/review.rb +51 -0
  157. data/patterns/onboarding/files/app/components/ui/onboarding/show.rb +32 -0
  158. data/patterns/onboarding/files/app/controllers/concerns/requires_finished_onboarding.rb +14 -0
  159. data/patterns/onboarding/files/app/controllers/onboarding/base_controller.rb +30 -0
  160. data/patterns/onboarding/files/app/controllers/onboarding/branches_controller.rb +16 -0
  161. data/patterns/onboarding/files/app/controllers/onboarding/completions_controller.rb +13 -0
  162. data/patterns/onboarding/files/app/controllers/onboarding/details_controller.rb +16 -0
  163. data/patterns/onboarding/files/app/controllers/onboarding/invitation_plans_controller.rb +20 -0
  164. data/patterns/onboarding/files/app/controllers/onboardings_controller.rb +7 -0
  165. data/patterns/onboarding/files/app/jobs/onboarding_invitation_delivery_job.rb +15 -0
  166. data/patterns/onboarding/files/app/models/concerns/team/onboardable.rb +23 -0
  167. data/patterns/onboarding/files/app/models/onboarding/completion.rb +17 -0
  168. data/patterns/onboarding/files/app/models/onboarding/invitation_delivery.rb +14 -0
  169. data/patterns/onboarding/files/app/models/onboarding.rb +174 -0
  170. data/patterns/onboarding/files/config/routes/onboarding.rb +11 -0
  171. data/patterns/onboarding/files/db/migrate/20260731010000_create_onboarding.rb +60 -0
  172. data/patterns/onboarding/files/test/controllers/onboarding_flow_test.rb +62 -0
  173. data/patterns/onboarding/files/test/fixtures/onboarding_completions.yml +3 -0
  174. data/patterns/onboarding/files/test/fixtures/onboardings.yml +25 -0
  175. data/patterns/onboarding/files/test/jobs/onboarding_invitation_delivery_job_test.rb +18 -0
  176. data/patterns/onboarding/files/test/models/onboarding_test.rb +60 -0
  177. data/patterns/onboarding/files/test/system/onboarding_flow_test.rb +39 -0
  178. data/patterns/onboarding/item.yml +4 -0
  179. data/patterns/onboarding/pattern.md +53 -0
  180. data/patterns/subscription-billing/files/app/components/ui/billing/base.rb +39 -0
  181. data/patterns/subscription-billing/files/app/components/ui/billing/checkout_result.rb +64 -0
  182. data/patterns/subscription-billing/files/app/components/ui/billing/page.rb +33 -0
  183. data/patterns/subscription-billing/files/app/components/ui/billing/show.rb +149 -0
  184. data/patterns/subscription-billing/files/app/controllers/billing/base_controller.rb +16 -0
  185. data/patterns/subscription-billing/files/app/controllers/billing/checkouts_controller.rb +65 -0
  186. data/patterns/subscription-billing/files/app/controllers/billing/portals_controller.rb +18 -0
  187. data/patterns/subscription-billing/files/app/controllers/billing_controller.rb +17 -0
  188. data/patterns/subscription-billing/files/app/controllers/webhooks/stripe_events_controller.rb +21 -0
  189. data/patterns/subscription-billing/files/app/jobs/billing/stripe_event_job.rb +16 -0
  190. data/patterns/subscription-billing/files/app/jobs/billing/subscription_reconciliation_job.rb +16 -0
  191. data/patterns/subscription-billing/files/app/jobs/billing/subscription_reconciliation_sweep_job.rb +9 -0
  192. data/patterns/subscription-billing/files/app/models/billing/checkout.rb +58 -0
  193. data/patterns/subscription-billing/files/app/models/billing/plan.rb +19 -0
  194. data/patterns/subscription-billing/files/app/models/billing/stripe_event.rb +73 -0
  195. data/patterns/subscription-billing/files/app/models/billing/subscription.rb +106 -0
  196. data/patterns/subscription-billing/files/app/models/concerns/team/billable.rb +36 -0
  197. data/patterns/subscription-billing/files/config/initializers/stripe.rb +29 -0
  198. data/patterns/subscription-billing/files/config/routes/subscription_billing.rb +10 -0
  199. data/patterns/subscription-billing/files/db/migrate/20260801000000_add_subscription_billing.rb +61 -0
  200. data/patterns/subscription-billing/files/test/controllers/billing_flow_test.rb +60 -0
  201. data/patterns/subscription-billing/files/test/models/billing/subscription_test.rb +40 -0
  202. data/patterns/subscription-billing/files/test/system/subscription_billing_test.rb +28 -0
  203. data/patterns/subscription-billing/item.yml +4 -0
  204. data/patterns/subscription-billing/pattern.md +59 -0
  205. data/patterns/team-management/files/app/components/ui/invitations/acceptance.rb +33 -0
  206. data/patterns/team-management/files/app/components/ui/teams/index.rb +87 -0
  207. data/patterns/team-management/files/app/components/ui/teams/invitation_form.rb +51 -0
  208. data/patterns/team-management/files/app/components/ui/teams/member_form.rb +78 -0
  209. data/patterns/team-management/files/app/components/ui/teams/members.rb +125 -0
  210. data/patterns/team-management/files/app/controllers/invitations/acceptances_controller.rb +29 -0
  211. data/patterns/team-management/files/app/controllers/teams/base_controller.rb +18 -0
  212. data/patterns/team-management/files/app/controllers/teams/invitations_controller.rb +42 -0
  213. data/patterns/team-management/files/app/controllers/teams/memberships_controller.rb +53 -0
  214. data/patterns/team-management/files/app/controllers/teams_controller.rb +30 -0
  215. data/patterns/team-management/files/app/mailers/team_invitation_mailer.rb +10 -0
  216. data/patterns/team-management/files/app/models/concerns/current_team.rb +13 -0
  217. data/patterns/team-management/files/app/models/concerns/user_teams.rb +37 -0
  218. data/patterns/team-management/files/app/models/invitation.rb +41 -0
  219. data/patterns/team-management/files/app/models/membership.rb +45 -0
  220. data/patterns/team-management/files/app/models/team.rb +25 -0
  221. data/patterns/team-management/files/app/views/invitations/acceptances/show.html.erb +1 -0
  222. data/patterns/team-management/files/app/views/team_invitation_mailer/invite.html.erb +10 -0
  223. data/patterns/team-management/files/app/views/team_invitation_mailer/invite.text.erb +7 -0
  224. data/patterns/team-management/files/app/views/teams/index.html.erb +15 -0
  225. data/patterns/team-management/files/app/views/teams/invitations/new.html.erb +22 -0
  226. data/patterns/team-management/files/app/views/teams/memberships/edit.html.erb +22 -0
  227. data/patterns/team-management/files/app/views/teams/memberships/index.html.erb +20 -0
  228. data/patterns/team-management/files/config/routes/team_management.rb +11 -0
  229. data/patterns/team-management/files/db/migrate/20260717000000_create_team_management.rb +31 -0
  230. data/patterns/team-management/files/test/models/invitation_test.rb +28 -0
  231. data/patterns/team-management/files/test/models/membership_test.rb +29 -0
  232. data/patterns/team-management/files/test/models/team_test.rb +31 -0
  233. data/patterns/team-management/files/test/support/team_management_test_helpers.rb +22 -0
  234. data/patterns/team-management/item.yml +4 -0
  235. data/patterns/team-management/pattern.md +47 -0
  236. data/patterns/webhook-deliveries/files/app/assets/stylesheets/ui/webhooks.css +179 -0
  237. data/patterns/webhook-deliveries/files/app/components/ui/webhooks/base.rb +38 -0
  238. data/patterns/webhook-deliveries/files/app/components/ui/webhooks/delivery.rb +160 -0
  239. data/patterns/webhook-deliveries/files/app/components/ui/webhooks/endpoint.rb +149 -0
  240. data/patterns/webhook-deliveries/files/app/components/ui/webhooks/form.rb +75 -0
  241. data/patterns/webhook-deliveries/files/app/components/ui/webhooks/index.rb +142 -0
  242. data/patterns/webhook-deliveries/files/app/components/ui/webhooks/page.rb +33 -0
  243. data/patterns/webhook-deliveries/files/app/components/ui/webhooks/secret.rb +38 -0
  244. data/patterns/webhook-deliveries/files/app/controllers/webhook_deliveries/replays_controller.rb +13 -0
  245. data/patterns/webhook-deliveries/files/app/controllers/webhook_deliveries_controller.rb +7 -0
  246. data/patterns/webhook-deliveries/files/app/controllers/webhook_endpoints/secrets_controller.rb +41 -0
  247. data/patterns/webhook-deliveries/files/app/controllers/webhook_endpoints_controller.rb +67 -0
  248. data/patterns/webhook-deliveries/files/app/controllers/webhooks/base_controller.rb +15 -0
  249. data/patterns/webhook-deliveries/files/app/jobs/webhook_delivery_job.rb +9 -0
  250. data/patterns/webhook-deliveries/files/app/jobs/webhook_delivery_repair_job.rb +11 -0
  251. data/patterns/webhook-deliveries/files/app/models/concerns/team/webhookable.rb +11 -0
  252. data/patterns/webhook-deliveries/files/app/models/webhook/attempt.rb +30 -0
  253. data/patterns/webhook-deliveries/files/app/models/webhook/delivery.rb +268 -0
  254. data/patterns/webhook-deliveries/files/app/models/webhook/endpoint.rb +58 -0
  255. data/patterns/webhook-deliveries/files/app/models/webhook/event.rb +98 -0
  256. data/patterns/webhook-deliveries/files/app/models/webhook/secret_reveal.rb +53 -0
  257. data/patterns/webhook-deliveries/files/app/models/webhook/signature.rb +22 -0
  258. data/patterns/webhook-deliveries/files/app/models/webhook/transport.rb +176 -0
  259. data/patterns/webhook-deliveries/files/app/views/webhook_deliveries/show.html.erb +5 -0
  260. data/patterns/webhook-deliveries/files/app/views/webhook_endpoints/edit.html.erb +1 -0
  261. data/patterns/webhook-deliveries/files/app/views/webhook_endpoints/index.html.erb +6 -0
  262. data/patterns/webhook-deliveries/files/app/views/webhook_endpoints/new.html.erb +1 -0
  263. data/patterns/webhook-deliveries/files/app/views/webhook_endpoints/secrets/new.html.erb +1 -0
  264. data/patterns/webhook-deliveries/files/app/views/webhook_endpoints/show.html.erb +7 -0
  265. data/patterns/webhook-deliveries/files/config/recurring/webhooks.yml +4 -0
  266. data/patterns/webhook-deliveries/files/config/routes/webhook_deliveries.rb +10 -0
  267. data/patterns/webhook-deliveries/files/db/migrate/20260803000000_add_webhook_deliveries.rb +126 -0
  268. data/patterns/webhook-deliveries/files/test/controllers/webhook_endpoints_flow_test.rb +48 -0
  269. data/patterns/webhook-deliveries/files/test/models/webhook/delivery_test.rb +70 -0
  270. data/patterns/webhook-deliveries/files/test/system/webhook_deliveries_test.rb +29 -0
  271. data/patterns/webhook-deliveries/item.yml +4 -0
  272. data/patterns/webhook-deliveries/pattern.md +120 -0
  273. data/plugins/nitro-kit/.codex-plugin/plugin.json +4 -4
  274. data/plugins/nitro-kit/skills/nitro-kit-hotwire/SKILL.md +7 -9
  275. data/plugins/nitro-kit/skills/nitro-kit-hotwire/agents/openai.yaml +1 -1
  276. data/plugins/nitro-kit/skills/nitro-kit-rails/SKILL.md +10 -9
  277. data/plugins/nitro-kit/skills/nitro-kit-rails/agents/openai.yaml +1 -1
  278. data/plugins/nitro-kit/skills/nitro-kit-ui/SKILL.md +27 -16
  279. data/plugins/nitro-kit/skills/nitro-kit-ui/agents/openai.yaml +1 -1
  280. data/src/stylesheets/nitro_kit/components/accordion.css +40 -40
  281. data/src/stylesheets/nitro_kit/components/alert.css +7 -6
  282. data/src/stylesheets/nitro_kit/components/app_navigation.css +50 -41
  283. data/src/stylesheets/nitro_kit/components/app_shell.css +371 -280
  284. data/src/stylesheets/nitro_kit/components/appearance_picker.css +38 -38
  285. data/src/stylesheets/nitro_kit/components/avatar.css +3 -3
  286. data/src/stylesheets/nitro_kit/components/avatar_stack.css +18 -18
  287. data/src/stylesheets/nitro_kit/components/badge.css +5 -2
  288. data/src/stylesheets/nitro_kit/components/button.css +57 -49
  289. data/src/stylesheets/nitro_kit/components/button_group.css +14 -14
  290. data/src/stylesheets/nitro_kit/components/checkbox.css +24 -24
  291. data/src/stylesheets/nitro_kit/components/checkbox_group.css +13 -13
  292. data/src/stylesheets/nitro_kit/components/combobox.css +152 -25
  293. data/src/stylesheets/nitro_kit/components/command_palette.css +59 -59
  294. data/src/stylesheets/nitro_kit/components/control_group.css +71 -54
  295. data/src/stylesheets/nitro_kit/components/details_table.css +9 -9
  296. data/src/stylesheets/nitro_kit/components/dialog.css +8 -12
  297. data/src/stylesheets/nitro_kit/components/dropdown.css +22 -26
  298. data/src/stylesheets/nitro_kit/components/dropzone.css +97 -100
  299. data/src/stylesheets/nitro_kit/components/empty_state.css +1 -0
  300. data/src/stylesheets/nitro_kit/components/field.css +26 -30
  301. data/src/stylesheets/nitro_kit/components/fieldset.css +2 -2
  302. data/src/stylesheets/nitro_kit/components/input.css +6 -14
  303. data/src/stylesheets/nitro_kit/components/layout.css +165 -165
  304. data/src/stylesheets/nitro_kit/components/page_header.css +3 -3
  305. data/src/stylesheets/nitro_kit/components/pagination.css +66 -49
  306. data/src/stylesheets/nitro_kit/components/pagination_bar.css +6 -6
  307. data/src/stylesheets/nitro_kit/components/palette.css +24 -22
  308. data/src/stylesheets/nitro_kit/components/progressive_image.css +38 -41
  309. data/src/stylesheets/nitro_kit/components/radio_button.css +19 -19
  310. data/src/stylesheets/nitro_kit/components/radio_button_group.css +43 -43
  311. data/src/stylesheets/nitro_kit/components/rich_text_area.css +4 -4
  312. data/src/stylesheets/nitro_kit/components/select.css +2 -2
  313. data/src/stylesheets/nitro_kit/components/settings_layout.css +17 -18
  314. data/src/stylesheets/nitro_kit/components/settings_section.css +12 -12
  315. data/src/stylesheets/nitro_kit/components/sheet.css +10 -10
  316. data/src/stylesheets/nitro_kit/components/stat_grid.css +9 -9
  317. data/src/stylesheets/nitro_kit/components/switch.css +23 -23
  318. data/src/stylesheets/nitro_kit/components/table.css +27 -27
  319. data/src/stylesheets/nitro_kit/components/tabs.css +32 -34
  320. data/src/stylesheets/nitro_kit/components/toolbar.css +6 -6
  321. data/src/stylesheets/nitro_kit/components/tooltip.css +26 -28
  322. data/src/stylesheets/nitro_kit/layers.css +2 -1
  323. data/src/stylesheets/nitro_kit/reset.css +9 -9
  324. data/src/stylesheets/nitro_kit/tailwind.css +6 -2
  325. data/src/stylesheets/nitro_kit/tokens.css +18 -9
  326. metadata +238 -2
@@ -0,0 +1,28 @@
1
+ <% content_for :title, @project.name %>
2
+ <% archival_action = if @project.archived?
3
+ {
4
+ label: "Restore",
5
+ form: UI::Projects::Show.archival_form_id(@project),
6
+ type: :submit
7
+ }
8
+ else
9
+ {
10
+ label: "Archive",
11
+ form: UI::Projects::Show.archival_form_id(@project),
12
+ type: :submit
13
+ }
14
+ end %>
15
+ <%= render UI::ApplicationShell.new(
16
+ title: @project.name,
17
+ current: :projects,
18
+ back: { label: "Back to projects", href: projects_path },
19
+ actions: [
20
+ { label: "Edit", href: edit_project_path(@project) },
21
+ archival_action
22
+ ]
23
+ ) do %>
24
+ <%= render UI::Projects::Show.new(
25
+ project: @project,
26
+ events: @events
27
+ ) %>
28
+ <% end %>
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ resources :projects do
4
+ resource :archival,
5
+ only: %i[create destroy],
6
+ module: :projects
7
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ class CreateCrudResource < ActiveRecord::Migration[8.1]
4
+ def change
5
+ create_table :projects do |table|
6
+ table.references :team, null: false, foreign_key: true
7
+ table.references :creator,
8
+ null: false,
9
+ foreign_key: { to_table: :users }
10
+ table.string :name, null: false
11
+ table.text :description
12
+ table.timestamps
13
+ end
14
+
15
+ create_table :project_archivals do |table|
16
+ table.references :project,
17
+ null: false,
18
+ foreign_key: true,
19
+ index: { unique: true }
20
+ table.references :actor,
21
+ null: false,
22
+ foreign_key: { to_table: :users }
23
+ table.timestamps
24
+ end
25
+
26
+ create_table :project_events do |table|
27
+ table.references :project, null: false, foreign_key: true
28
+ table.references :actor,
29
+ null: false,
30
+ foreign_key: { to_table: :users }
31
+ table.string :action, null: false
32
+ table.timestamps
33
+ end
34
+
35
+ add_index :project_events, [ :project_id, :created_at ]
36
+ end
37
+ end
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
4
+
5
+ class ProjectsControllerTest < ActionDispatch::IntegrationTest
6
+ include CrudResourceTestHelpers
7
+
8
+ setup { sign_in_for_crud_resource }
9
+
10
+ test "creates a project with a 303 redirect" do
11
+ assert_difference -> { crud_resource_team.projects.count }, 1 do
12
+ post projects_path, params: {
13
+ project: { name: "Apollo", description: "Launch work" }
14
+ }
15
+ end
16
+
17
+ assert_response :see_other
18
+ assert_equal crud_resource_team, Project.last.team
19
+ assert_equal crud_resource_user, Project.last.creator
20
+ end
21
+
22
+ test "renders validation errors with 422" do
23
+ post projects_path, params: {
24
+ project: { name: "", description: "Missing a name" }
25
+ }
26
+
27
+ assert_response :unprocessable_entity
28
+ assert_select "[aria-invalid='true']"
29
+ end
30
+
31
+ test "cannot load another team's project" do
32
+ other = teams(:secondary).projects.create!(
33
+ name: "Private",
34
+ creator: users(:other)
35
+ )
36
+
37
+ get project_path(other)
38
+
39
+ assert_response :not_found
40
+ end
41
+
42
+ test "archives through the noun resource" do
43
+ project = create_project!
44
+
45
+ post project_archival_path(project)
46
+
47
+ assert_response :see_other
48
+ assert_predicate project.reload, :archived?
49
+ end
50
+
51
+ test "keeps filters in pagination URLs with ordinary page links" do
52
+ 13.times { |index| create_project!(name: "Project #{index}") }
53
+
54
+ get projects_path(filter: { query: "Project", state: "active" })
55
+
56
+ assert_response :success
57
+ assert_select "turbo-frame", count: 0
58
+ assert_select "form[data-turbo-action='replace']"
59
+ assert_select "a[data-turbo-action='replace']", text: "Reset"
60
+ assert_select "nav[data-nk='pagination'] a[href*='filter%5Bquery%5D=Project']"
61
+ assert_select "a[href]", text: "View", minimum: 1
62
+ assert_select "a[href]", text: "Edit", minimum: 1
63
+ end
64
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
4
+
5
+ class ProjectTest < ActiveSupport::TestCase
6
+ include CrudResourceTestHelpers
7
+
8
+ setup do
9
+ Current.user = crud_resource_user
10
+ Current.team = crud_resource_team
11
+ end
12
+
13
+ teardown { Current.reset }
14
+
15
+ test "archives and restores through records with history" do
16
+ project = create_project!
17
+
18
+ project.archive!
19
+ assert_predicate project.reload, :archived?
20
+ assert_equal "archived", project.events.last.action
21
+
22
+ project.restore!
23
+ refute_predicate project.reload, :archived?
24
+ assert_equal "restored", project.events.last.action
25
+ end
26
+
27
+ test "filters only the current team relation" do
28
+ matching = create_project!(name: "Apollo camera")
29
+ create_project!(name: "Mercury")
30
+ filter = Project::Filter.new(query: "apollo", state: "active")
31
+
32
+ assert_equal [ matching ], filter.apply(crud_resource_team.projects)
33
+ end
34
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CrudResourceTestHelpers
4
+ def crud_resource_user
5
+ users(:owner)
6
+ end
7
+
8
+ def crud_resource_team
9
+ teams(:primary)
10
+ end
11
+
12
+ def sign_in_for_crud_resource
13
+ sign_in(crud_resource_user)
14
+ Current.user = crud_resource_user
15
+ Current.team = crud_resource_team
16
+ end
17
+
18
+ def create_project!(name: "Apollo")
19
+ crud_resource_team.projects.create!(
20
+ name:,
21
+ description: "A useful project",
22
+ creator: crud_resource_user
23
+ )
24
+ end
25
+ end
@@ -0,0 +1,87 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "application_system_test_case"
4
+
5
+ class ProjectsCrudTest < ApplicationSystemTestCase
6
+ include CrudResourceTestHelpers
7
+
8
+ test "filters, paginates, and opens row actions as page visits" do
9
+ sign_in_for_crud_resource
10
+ history_origin = create_project!(name: "History origin")
11
+ 13.times { |index| create_project!(name: "Indexed project #{index}") }
12
+ visit project_path(history_origin)
13
+ visit projects_path
14
+
15
+ assert_selector "[data-nk='pagination']"
16
+ fill_in "Search projects", with: "Indexed project 12"
17
+ click_button "Apply filters"
18
+
19
+ assert_current_path(/Indexed(?:\+|%20)project(?:\+|%20)12/, url: true)
20
+ within "[data-nk=table]" do
21
+ assert_text "Indexed project 12"
22
+ assert_no_text "Indexed project 1", exact: true
23
+ end
24
+
25
+ page.go_back
26
+ assert_current_path project_path(history_origin)
27
+ assert_selector "h1", text: "History origin"
28
+
29
+ page.go_forward
30
+ assert_current_path(/Indexed(?:\+|%20)project(?:\+|%20)12/, url: true)
31
+ within "[data-nk=table]" do
32
+ assert_text "Indexed project 12"
33
+ end
34
+
35
+ click_link "Reset"
36
+ page_two = find("[data-nk='pagination'] a[href*='page=2']", match: :first)
37
+ page_two.click
38
+
39
+ assert_current_path(/page=2/, url: true)
40
+ within "[data-nk=table]" do
41
+ assert_selector "tbody tr", minimum: 1
42
+ end
43
+
44
+ page.go_back
45
+ assert_current_path projects_path
46
+
47
+ page.go_forward
48
+ assert_current_path(/page=2/, url: true)
49
+ assert_no_selector "html[data-turbo-preview]", visible: :all
50
+ click_link "View", match: :first
51
+ assert_no_text "Content missing"
52
+ assert_selector "h1"
53
+ end
54
+
55
+ test "creates, archives, and reviews deletion from edit" do
56
+ sign_in_for_crud_resource
57
+ visit projects_path
58
+
59
+ click_link "New project"
60
+ submitter = find_button("Create project")
61
+ page.execute_script(<<~JAVASCRIPT, submitter)
62
+ const submitter = arguments[0]
63
+ submitter.form.noValidate = true
64
+ submitter.form.requestSubmit(submitter)
65
+ JAVASCRIPT
66
+ assert_selector "[aria-invalid='true']"
67
+
68
+ fill_in "Name", with: "Apollo"
69
+ fill_in "Description", with: "Launch work"
70
+ click_button "Create project"
71
+
72
+ assert_text "Project created"
73
+ assert_selector "h1", text: "Apollo"
74
+ assert_button "Archive", count: 1
75
+
76
+ click_button "Archive"
77
+ assert_text "Project archived"
78
+ assert_button "Restore", count: 1
79
+
80
+ click_link "Edit"
81
+ assert_selector "h1", text: "Edit Apollo"
82
+ click_button "Review deletion"
83
+ assert_selector "[data-slot='dialog-panel'][open]"
84
+ click_button "Cancel deletion"
85
+ assert_text "Apollo"
86
+ end
87
+ end
@@ -0,0 +1,6 @@
1
+ version: 1.8.1
2
+ title: Canonical CRUD resource
3
+ summary: Build a team-scoped resource as one calm Rails workflow with URL-owned queries, one shared form, explicit lifecycle records, and reviewed deletion.
4
+ tags: [admin, crud, forms, hotwire, pagination, rails, teams]
5
+ requires:
6
+ pagy: ">= 43.0, < 44.0"
@@ -0,0 +1,48 @@
1
+ # Canonical CRUD resource
2
+
3
+ ## When to use
4
+
5
+ Use this pattern when a team-scoped product noun needs a complete operational path: queryable index, creation, validation, detail, editing, lifecycle history, and reviewed deletion. It is for durable product records, not a settings toggle or a one-off form.
6
+
7
+ ## Composition checklist
8
+
9
+ Run the page composition checklist in the installed gem's `docs/patterns/composition.md` (`bundle show nitro_kit`) before calling any adapted route finished: one gutter owner (the shell content element, never the index or form), one primary action in the toolbar, and plain View/Edit row actions. Deletion stays in the edit route's `DangerZone`; destructive button treatment appears only there and on its confirming submit, never in index rows. Inspect populated, empty, invalid, and 390px states, with one `h1` at the shell's title scale.
10
+
11
+ ## Composition decisions
12
+
13
+ - Treat the route as one page. The application shell owns the title, navigation, primary action, and outer gutter.
14
+ - Use ordinary GET forms and links with Turbo Drive for a full-page index. Keep filters, sorting, and pagination in the URL and use default caching. Filter refinements may replace history; pagination advances it. Reserve Frames for independently navigable regions.
15
+ - Render pagination with `NitroKit::Pagination`, even when adapting the query or paginator. Keep its shared navigation and accessibility behavior instead of rebuilding Previous/Next with standalone buttons.
16
+ - Use one form component for new, edit, and validation. Associate the shell toolbar's primary submit with that form instead of rendering a duplicate body action.
17
+ - Model lifecycle changes as noun records when actor, timestamp, history, or authorization matters.
18
+ - Put reviewed deletion on edit, where the user has already chosen to change the record.
19
+ - Keep all columns and row actions intact at every width. Table owns a horizontal scroll wrapper; do not hide columns or stack buttons to fit the phone viewport.
20
+
21
+ ## Tradeoffs
22
+
23
+ The exemplar is deliberately opinionated about shell ownership and lifecycle structure. A small resource may not need filtering, events, or archival; remove whole capabilities instead of leaving dormant branches. Pagy is included because pagination behavior belongs to the URL contract, but another paginator is fine if it preserves that contract.
24
+
25
+ ## Adaptation
26
+
27
+ Rename Project across models, routes, migrations, fixtures, labels, and tests. Map `Current.user`, `Current.team`, authorization, and creator presentation to the host application. Keep the shared form, one primary submit, full-page row destinations, and URL history behavior intact while changing domain fields.
28
+
29
+ ## Verification
30
+
31
+ - Exercise empty, populated, filtered, sorted, paginated, invalid, active, archived, and deletion-review states.
32
+ - Assert 422 form failures and 303 successful mutations through ordinary Rails requests.
33
+ - Drive Back and Forward after filter and pagination changes and verify both URL and rendered rows.
34
+ - At 390px, verify the toolbar does not collide and the table scrolls horizontally to reveal intact row actions without overflowing the page.
35
+ - Run the supplied model, request, and system tests after adapting the host contracts.
36
+
37
+ ## Width and destructive actions
38
+
39
+ Tables fill the shell canvas. Form pages own a centered Container inside the
40
+ shared gutter; never constrain every route through the shell. Simple forms use
41
+ a single-column Fieldset with full-width controls, not the split SettingsSection
42
+ layout. Use Container lg for resource forms and md for short invitations. Use Nitro Dialog
43
+ for destructive confirmations, including member removal and invitation
44
+ revocation. Keep a real Rails form inside the dialog and a clear Cancel or
45
+ Keep action. Do not replace these with native browser confirmation.
46
+
47
+ Keep an explicit Cancel button beside the destructive submit in a right-aligned
48
+ Flex row. `dialog.close_button` only configures the corner X.
@@ -0,0 +1,133 @@
1
+ @layer nitro-kit.application {
2
+ :where([data-ui="upload-form"]) {
3
+ grid-template-columns: minmax(0, var(--nk-content-lg));
4
+ row-gap: calc(var(--nk-space) * 4);
5
+ }
6
+
7
+ :where(
8
+ [data-ui="upload-form"] > [data-slot="settings-section-form"],
9
+ [data-ui="upload-form"] > [data-slot="settings-section-status"]
10
+ ) {
11
+ grid-column: 1;
12
+ }
13
+
14
+ :where([data-ui="upload-caption"]) {
15
+ position: absolute;
16
+ width: 1px;
17
+ height: 1px;
18
+ padding: 0;
19
+ overflow: hidden;
20
+ clip: rect(0, 0, 0, 0);
21
+ white-space: nowrap;
22
+ border: 0;
23
+ }
24
+
25
+ :where([data-ui="upload-identity"]) {
26
+ min-inline-size: 15rem;
27
+ text-align: start;
28
+ }
29
+
30
+ :where([data-ui="upload-thumbnail"]) {
31
+ flex: 0 0 auto;
32
+ inline-size: 4rem;
33
+ block-size: 3rem;
34
+ border-radius: var(--nk-radius-md);
35
+ }
36
+
37
+ :where([data-ui="upload-placeholder"]) {
38
+ display: grid;
39
+ place-items: center;
40
+ flex: 0 0 auto;
41
+ inline-size: 4rem;
42
+ block-size: 3rem;
43
+ color: var(--nk-color-muted-foreground);
44
+ background: var(--nk-color-muted);
45
+ border-radius: var(--nk-radius-md);
46
+ }
47
+
48
+ :where([data-ui="upload-filename"]) {
49
+ display: block;
50
+ max-inline-size: 22rem;
51
+ overflow-wrap: anywhere;
52
+ }
53
+
54
+ :where([data-ui="upload-failure"]) {
55
+ display: block;
56
+ max-inline-size: 22rem;
57
+ margin-block-start: var(--nk-space);
58
+ font-weight: normal;
59
+ }
60
+
61
+ @media (max-width: 40rem) {
62
+ :where([data-ui="upload-optional-column"]) {
63
+ display: none;
64
+ }
65
+
66
+ :where([data-ui="upload-table"] [data-slot="table-element"]) {
67
+ display: block;
68
+ }
69
+
70
+ :where([data-ui="upload-table"] [data-slot="table-head"]) {
71
+ position: absolute;
72
+ width: 1px;
73
+ height: 1px;
74
+ padding: 0;
75
+ overflow: hidden;
76
+ clip: rect(0, 0, 0, 0);
77
+ white-space: nowrap;
78
+ border: 0;
79
+ }
80
+
81
+ :where(
82
+ [data-ui="upload-table"] [data-slot="table-body"],
83
+ [data-ui="upload-table"] [data-slot="table-row"]
84
+ ) {
85
+ display: grid;
86
+ }
87
+
88
+ :where([data-ui="upload-table"] [data-slot="table-row"]) {
89
+ grid-template-columns: minmax(0, 1fr) auto;
90
+ grid-template-areas:
91
+ "identity identity"
92
+ "status actions";
93
+ gap: calc(var(--nk-space) * 3);
94
+ padding-block: calc(var(--nk-space) * 4);
95
+ }
96
+
97
+ :where(
98
+ [data-ui="upload-identity-cell"],
99
+ [data-ui="upload-status-cell"],
100
+ [data-ui="upload-actions-cell"]
101
+ ) {
102
+ min-block-size: 0;
103
+ padding: 0;
104
+ }
105
+
106
+ :where([data-ui="upload-identity-cell"]) {
107
+ grid-area: identity;
108
+ }
109
+
110
+ :where([data-ui="upload-status-cell"]) {
111
+ grid-area: status;
112
+ align-self: center;
113
+ padding-inline-start: calc(4rem + (var(--nk-space) * 3));
114
+ }
115
+
116
+ :where([data-ui="upload-actions-cell"]) {
117
+ grid-area: actions;
118
+ justify-self: end;
119
+ }
120
+
121
+ :where([data-ui="upload-actions"] [data-nk="button"]) {
122
+ min-block-size: var(--nk-control-height-md);
123
+ }
124
+
125
+ :where([data-ui="upload-identity"]) {
126
+ min-inline-size: 0;
127
+ }
128
+
129
+ :where([data-ui="upload-filename"], [data-ui="upload-failure"]) {
130
+ max-inline-size: none;
131
+ }
132
+ }
133
+ }
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module UI
4
+ module Uploads
5
+ class Base < Phlex::HTML
6
+ include NitroKit
7
+ include Phlex::Rails::Helpers::FormWith
8
+ include Phlex::Rails::Helpers::Routes
9
+ include Phlex::Rails::Helpers::TurboStreamFrom
10
+
11
+ private
12
+ def status_label(upload)
13
+ upload.status.humanize
14
+ end
15
+
16
+ def status_color(upload)
17
+ {
18
+ "pending" => :neutral,
19
+ "processing" => :info,
20
+ "ready" => :success,
21
+ "failed" => :destructive
22
+ }.fetch(upload.status)
23
+ end
24
+
25
+ def formatted_size(bytes)
26
+ ActiveSupport::NumberHelper.number_to_human_size(bytes)
27
+ end
28
+ end
29
+ end
30
+ end