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
@@ -44,7 +44,7 @@ module NitroKit
44
44
  ensure_collecting!
45
45
 
46
46
  key = normalize_identity(key, name: "accordion item key")
47
- title = validate_title!(title)
47
+ title = validate_text!("Accordion item title", title)
48
48
  expanded = validate_boolean!(:expanded, expanded)
49
49
  raise ArgumentError, "Accordion item #{key.inspect} requires content" unless content
50
50
  raise ArgumentError, "Duplicate accordion item key #{key.inspect}" if @items.any? { |item| item.key == key }
@@ -122,17 +122,5 @@ module NitroKit
122
122
 
123
123
  raise ArgumentError, "Accordion items must be declared inside the render block"
124
124
  end
125
-
126
- def validate_title!(title)
127
- return title if title.is_a?(String) && title.present?
128
-
129
- raise ArgumentError, "Accordion item title must be a non-blank String"
130
- end
131
-
132
- def validate_boolean!(name, value)
133
- return value if value == true || value == false
134
-
135
- raise ArgumentError, "Accordion #{name} must be true or false"
136
- end
137
125
  end
138
126
  end
@@ -300,18 +300,6 @@ module NitroKit
300
300
  raise ArgumentError, "AppNavigation #{location} accepts declarations, not rendered content"
301
301
  end
302
302
 
303
- def validate_text!(name, value)
304
- return value if value.is_a?(String) && !value.strip.empty?
305
-
306
- raise ArgumentError, "#{name} must be a non-blank String"
307
- end
308
-
309
- def validate_optional_text!(name, value)
310
- return if value.nil?
311
-
312
- validate_text!(name, value)
313
- end
314
-
315
303
  def item_icon(value, name: :icon)
316
304
  return if value.nil?
317
305
  unless (value.is_a?(String) || value.is_a?(Symbol)) && !value.to_s.strip.empty?
@@ -32,11 +32,11 @@ module NitroKit
32
32
  if @sidebar == :collapsed && !@collapsible
33
33
  raise ArgumentError, "AppShell sidebar: :collapsed requires collapsible: true"
34
34
  end
35
- @sidebar_toggle_label = validate_label!(:sidebar_toggle_label, sidebar_toggle_label)
36
- @skip_link_label = validate_label!(:skip_link_label, skip_link_label)
37
- @open_navigation_label = validate_label!(:open_navigation_label, open_navigation_label)
38
- @close_navigation_label = validate_label!(:close_navigation_label, close_navigation_label)
39
- @navigation_dialog_label = validate_label!(:navigation_dialog_label, navigation_dialog_label)
35
+ @sidebar_toggle_label = validate_text!("AppShell sidebar_toggle_label", sidebar_toggle_label)
36
+ @skip_link_label = validate_text!("AppShell skip_link_label", skip_link_label)
37
+ @open_navigation_label = validate_text!("AppShell open_navigation_label", open_navigation_label)
38
+ @close_navigation_label = validate_text!("AppShell close_navigation_label", close_navigation_label)
39
+ @navigation_dialog_label = validate_text!("AppShell navigation_dialog_label", navigation_dialog_label)
40
40
  @regions = REGIONS.to_h { |name| [ name, nil ] }
41
41
  @collecting = false
42
42
 
@@ -247,11 +247,5 @@ module NitroKit
247
247
  def main_id
248
248
  "#{identifier}-main"
249
249
  end
250
-
251
- def validate_label!(name, value)
252
- return value if value.is_a?(String) && !value.strip.empty?
253
-
254
- raise ArgumentError, "AppShell #{name} must be a non-blank String"
255
- end
256
250
  end
257
251
  end
@@ -22,7 +22,7 @@ module NitroKit
22
22
  desperately_need_a_class: nil
23
23
  )
24
24
  @identifier = validate_id!("AppearancePicker id", id)
25
- @label = validate_label!(label)
25
+ @label = validate_text!("AppearancePicker label", label)
26
26
  @label_visible = validate_boolean!(:label_visible, label_visible)
27
27
  @presentation = validate_choice!(:presentation, presentation, PRESENTATIONS)
28
28
  @preference = validate_choice!(:preference, preference, PREFERENCES)
@@ -145,11 +145,5 @@ module NitroKit
145
145
  def option_id(preference)
146
146
  "#{identifier}-#{preference}"
147
147
  end
148
-
149
- def validate_label!(value)
150
- return value if value.is_a?(String) && value.present?
151
-
152
- raise ArgumentError, "AppearancePicker label must be a non-blank String"
153
- end
154
148
  end
155
149
  end
@@ -3,13 +3,176 @@
3
3
  module NitroKit
4
4
  class Combobox < Component
5
5
  PLACEMENTS = %i[bottom_start bottom_end top_start top_end].freeze
6
+ ACTION_METHODS = %i[post patch put].freeze
7
+
8
+ # Server-rendered results for a remote Combobox. The application's search
9
+ # endpoint renders this component (without a layout) for the `query`
10
+ # parameter; the Combobox controller moves its items into the listbox.
11
+ class Results < Component
12
+ Item = ::Data.define(:kind, :label, :value, :description, :disabled, :url, :params, :method)
13
+ private_constant :Item
14
+
15
+ def initialize(
16
+ id:,
17
+ html: {},
18
+ aria: {},
19
+ data: {},
20
+ desperately_need_a_class: nil
21
+ )
22
+ @identifier = validate_id!("Combobox::Results id:", id)
23
+ @items = []
24
+
25
+ super(
26
+ component: :combobox_results,
27
+ attributes: { id: "#{@identifier}-results" },
28
+ html:,
29
+ aria:,
30
+ data:,
31
+ desperately_need_a_class:
32
+ )
33
+ end
34
+
35
+ def option(label, value:, description: nil, disabled: false)
36
+ ensure_collecting!
37
+ choice = Choice.new(label:, value:, description:, disabled:)
38
+
39
+ if @items.any? { |item| item.kind == :option && item.value.to_s == choice.value.to_s }
40
+ raise ArgumentError, "Combobox::Results option values must be unique: #{choice.value}"
41
+ end
42
+
43
+ @items << Item.new(
44
+ kind: :option,
45
+ label: choice.label.to_s,
46
+ value: choice.value,
47
+ description: choice.description,
48
+ disabled: choice.disabled,
49
+ url: nil,
50
+ params: nil,
51
+ method: nil
52
+ )
53
+ nil
54
+ end
55
+
56
+ def action(label, url:, params: {}, method: :post, description: nil)
57
+ ensure_collecting!
58
+ unless params.is_a?(Hash)
59
+ raise ArgumentError, "Combobox::Results action params: must be a Hash of form fields"
60
+ end
61
+
62
+ @items << Item.new(
63
+ kind: :action,
64
+ label: validate_text!("Combobox::Results action label", label),
65
+ value: nil,
66
+ description: validate_optional_text!("Combobox::Results action description", description),
67
+ disabled: false,
68
+ url: validate_text!("Combobox::Results action url:", url),
69
+ params: params.to_h { |key, value| [ key.to_s, value.to_s ] },
70
+ method: validate_choice!(:method, method, ACTION_METHODS)
71
+ )
72
+ nil
73
+ end
74
+
75
+ def view_template(&block)
76
+ @collecting = true
77
+ yield(self) if block
78
+ @collecting = false
79
+
80
+ ul(**root_attributes) do
81
+ @items.each_with_index do |item, index|
82
+ item.kind == :action ? render_action(item, index) : render_option(item, index)
83
+ end
84
+ end
85
+ ensure
86
+ @collecting = false
87
+ end
88
+
89
+ private
90
+
91
+ def render_option(item, index)
92
+ id = "#{@identifier}-result-#{index + 1}"
93
+
94
+ li(
95
+ **slot_attributes(
96
+ :option,
97
+ attributes: {
98
+ id:,
99
+ role: "option",
100
+ aria: {
101
+ disabled: item.disabled ? true : nil,
102
+ selected: false,
103
+ label: item.description ? item.label : nil,
104
+ describedby: item.description ? "#{id}-description" : nil
105
+ }.compact,
106
+ data: {
107
+ value: item.value.to_s,
108
+ state: "unselected",
109
+ nk__combobox_target: "option",
110
+ action: item.disabled ? nil : "click->nk--combobox#select pointermove->nk--combobox#activate"
111
+ }
112
+ }
113
+ )
114
+ ) { render_item_content(item, id) }
115
+ end
116
+
117
+ def render_action(item, index)
118
+ id = "#{@identifier}-action-#{index + 1}"
119
+
120
+ li(
121
+ **slot_attributes(
122
+ :action,
123
+ attributes: {
124
+ id:,
125
+ role: "option",
126
+ aria: {
127
+ selected: false,
128
+ label: item.description ? item.label : nil,
129
+ describedby: item.description ? "#{id}-description" : nil
130
+ }.compact,
131
+ data: {
132
+ nk__combobox_target: "option",
133
+ request_url: item.url,
134
+ request_method: item.method.to_s,
135
+ request_params: item.params.to_json,
136
+ action: "click->nk--combobox#select pointermove->nk--combobox#activate"
137
+ }
138
+ }
139
+ )
140
+ ) do
141
+ render_in_slot(Icon.new(:plus, size: :sm), :action_icon)
142
+ render_item_content(item, id)
143
+ end
144
+ end
145
+
146
+ def render_item_content(item, id)
147
+ span(**slot_attributes(:option_label)) { plain(item.label) }
148
+ return unless item.description
149
+
150
+ span(**slot_attributes(:option_description, attributes: { id: "#{id}-description" })) do
151
+ plain(item.description)
152
+ end
153
+ end
154
+
155
+ def ensure_collecting!
156
+ return if @collecting
157
+
158
+ raise ArgumentError, "Combobox::Results items must be declared inside the render block"
159
+ end
160
+
161
+ def qualified_slot(slot)
162
+ slot_name = normalize_identity(slot, name: "slot")
163
+ slot_name.start_with?("combobox-") ? slot_name : "combobox-#{slot_name}"
164
+ end
165
+ end
6
166
 
7
167
  def initialize(
8
168
  id:,
9
169
  name:,
10
170
  label:,
11
- options:,
171
+ options: nil,
12
172
  value: nil,
173
+ src: nil,
174
+ selected: [],
175
+ multiple: false,
13
176
  placeholder: nil,
14
177
  include_blank: true,
15
178
  placement: :bottom_start,
@@ -23,12 +186,11 @@ module NitroKit
23
186
  desperately_need_a_class: nil
24
187
  )
25
188
  @identifier = validate_id!("Combobox id", id)
26
- @name = validate_text!("Combobox name", name)
189
+ @src = validate_optional_text!("Combobox src", src)
190
+ @multiple = validate_boolean!(:multiple, multiple)
191
+ @name = submitted_name(validate_text!("Combobox name", name))
27
192
  @label = visible_label(label)
28
- @options = typed_options(options)
29
- @value = value
30
- @selected_option = selected_option(value)
31
- @placeholder = validate_optional_text!(:placeholder, placeholder)
193
+ @placeholder = validate_optional_text!("Combobox placeholder", placeholder)
32
194
  @include_blank = validate_blank_option!(include_blank)
33
195
  @placement = validate_choice!(:placement, placement, PLACEMENTS)
34
196
  @required = validate_boolean!(:required, required)
@@ -36,9 +198,26 @@ module NitroKit
36
198
  @autocomplete = autocomplete
37
199
  @control_aria = attribute_hash(control_aria, name: "control_aria")
38
200
 
39
- if !value.nil? && !@selected_option
40
- raise ArgumentError, "Combobox value #{value.inspect} does not match a declared option"
201
+ if remote?
202
+ validate_remote_options!(options:, value:, include_blank:)
203
+ @options = [].freeze
204
+ @selected = typed_selection(selected)
205
+ @value = @selected.first&.value
206
+ @selected_option = @multiple ? nil : @selected.first
207
+ else
208
+ validate_local_options!(selected:)
209
+ @options = typed_options(options)
210
+ @selected = [].freeze
211
+ @value = value
212
+ @selected_option = selected_option(value)
213
+
214
+ if !value.nil? && !@selected_option
215
+ raise ArgumentError,
216
+ "Combobox value #{value.inspect} does not match a declared option; " \
217
+ "pass value: nil or add the stale record to options:"
218
+ end
41
219
  end
220
+
42
221
  if @label == false && !named_by_control_aria?
43
222
  raise ArgumentError,
44
223
  "a Combobox without label: requires control_aria: { label: } or control_aria: { labelledby: }"
@@ -57,7 +236,8 @@ module NitroKit
57
236
  nk__combobox_invalid_selection_value: I18n.t("nitro_kit.combobox.invalid_selection"),
58
237
  nk__combobox_no_results_value: I18n.t("nitro_kit.combobox.no_results"),
59
238
  nk__combobox_results_one_value: I18n.t("nitro_kit.combobox.results.one"),
60
- nk__combobox_results_other_value: I18n.t("nitro_kit.combobox.results.other")
239
+ nk__combobox_results_other_value: I18n.t("nitro_kit.combobox.results.other"),
240
+ **remote_values
61
241
  }
62
242
  },
63
243
  html:,
@@ -67,14 +247,23 @@ module NitroKit
67
247
  )
68
248
  end
69
249
 
70
- attr_reader :identifier, :name, :label, :options, :value, :placement
250
+ attr_reader :identifier, :name, :label, :options, :value, :placement, :src, :selected
251
+
252
+ def remote? = !@src.nil?
253
+
254
+ def multiple? = @multiple
71
255
 
72
256
  def view_template
73
257
  div(**root_attributes) do
74
258
  render_label
75
259
  render_control
76
- render_native_select
260
+ if remote?
261
+ render_remote_value
262
+ else
263
+ render_native_select
264
+ end
77
265
  render_listbox
266
+ render_selections if multiple?
78
267
  render_status
79
268
  end
80
269
  end
@@ -88,7 +277,13 @@ module NitroKit
88
277
  end
89
278
 
90
279
  def render_control
91
- span(**slot_attributes(:control, attributes: { hidden: true }, data: { nk__combobox_target: "control" })) do
280
+ span(
281
+ **slot_attributes(
282
+ :control,
283
+ attributes: { hidden: remote? ? nil : true }.compact,
284
+ data: { nk__combobox_target: "control" }
285
+ )
286
+ ) do
92
287
  render_in_slot(
93
288
  Input.new(
94
289
  type: :text,
@@ -117,7 +312,7 @@ module NitroKit
117
312
  :input
118
313
  )
119
314
 
120
- render_in_slot(Icon.new(:chevron_down, size: :sm), :icon)
315
+ render_in_slot(Icon.new(remote? ? :search : :chevron_down, size: :sm), :icon)
121
316
  end
122
317
  end
123
318
 
@@ -140,6 +335,36 @@ module NitroKit
140
335
  )
141
336
  end
142
337
 
338
+ # A remote combobox has no complete option list to fall back to, so its
339
+ # submission source is one hidden field per selected value. Multiple mode
340
+ # also submits Rails' blank `name[]` entry so clearing every chip clears
341
+ # the association.
342
+ def render_remote_value
343
+ if multiple?
344
+ input(
345
+ **slot_attributes(
346
+ :blank,
347
+ attributes: { type: "hidden", name:, value: "", disabled: @disabled || nil, autocomplete: "off" }
348
+ )
349
+ )
350
+ else
351
+ input(
352
+ **slot_attributes(
353
+ :value,
354
+ attributes: {
355
+ type: "hidden",
356
+ id: value_id,
357
+ name:,
358
+ value: @selected_option&.value.to_s,
359
+ disabled: @disabled || nil,
360
+ autocomplete: "off",
361
+ data: { nk__combobox_target: "value" }
362
+ }
363
+ )
364
+ )
365
+ end
366
+ end
367
+
143
368
  def render_listbox
144
369
  ul(
145
370
  **slot_attributes(
@@ -148,7 +373,7 @@ module NitroKit
148
373
  id: listbox_id,
149
374
  role: "listbox",
150
375
  hidden: true,
151
- aria: accessible_naming,
376
+ aria: accessible_naming.merge(multiselectable: multiple? ? "true" : nil).compact,
152
377
  data: {
153
378
  placement: placement_value,
154
379
  state: "closed",
@@ -158,6 +383,7 @@ module NitroKit
158
383
  )
159
384
  ) do
160
385
  options.each_with_index { |option, index| render_option(option, index) }
386
+ render_message if remote?
161
387
  end
162
388
  end
163
389
 
@@ -195,6 +421,78 @@ module NitroKit
195
421
  end
196
422
  end
197
423
 
424
+ # Loading, error, and empty feedback for remote results. The controller
425
+ # owns its text and `data-state`; it is presentational so it never joins
426
+ # the option sequence.
427
+ def render_message
428
+ li(
429
+ **slot_attributes(
430
+ :message,
431
+ attributes: {
432
+ role: "presentation",
433
+ hidden: true,
434
+ data: { state: "idle", nk__combobox_target: "message" }
435
+ }
436
+ )
437
+ )
438
+ end
439
+
440
+ def render_selections
441
+ ul(
442
+ **slot_attributes(
443
+ :selections,
444
+ attributes: {
445
+ aria: accessible_naming,
446
+ data: { nk__combobox_target: "selections" }
447
+ }
448
+ )
449
+ ) do
450
+ @selected.each { |choice| render_selection(choice) }
451
+ end
452
+
453
+ template(**slot_attributes(:selection_template, attributes: { data: { nk__combobox_target: "selectionTemplate" } })) do
454
+ render_selection(nil)
455
+ end
456
+ end
457
+
458
+ def render_selection(choice)
459
+ label = choice&.label&.to_s
460
+
461
+ li(
462
+ **slot_attributes(
463
+ :selection,
464
+ attributes: {
465
+ data: { value: choice&.value.to_s, nk__combobox_target: "selection" }
466
+ }
467
+ )
468
+ ) do
469
+ span(**slot_attributes(:selection_label)) { plain(label.to_s) }
470
+ render_in_slot(
471
+ Button.new(
472
+ icon: :x,
473
+ label: I18n.t("nitro_kit.combobox.remove", label: label || "%{label}"),
474
+ variant: :ghost,
475
+ size: :xs,
476
+ disabled: @disabled,
477
+ data: { action: "nk--combobox#remove" }
478
+ ),
479
+ :remove
480
+ )
481
+ input(
482
+ **slot_attributes(
483
+ :selection_value,
484
+ attributes: {
485
+ type: "hidden",
486
+ name:,
487
+ value: choice&.value.to_s,
488
+ disabled: @disabled || nil,
489
+ autocomplete: "off"
490
+ }
491
+ )
492
+ )
493
+ end
494
+ end
495
+
198
496
  def render_status
199
497
  div(
200
498
  **slot_attributes(
@@ -208,6 +506,60 @@ module NitroKit
208
506
  )
209
507
  end
210
508
 
509
+ def remote_values
510
+ return {} unless remote?
511
+
512
+ {
513
+ nk__combobox_src_value: @src,
514
+ nk__combobox_multiple_value: @multiple,
515
+ nk__combobox_loading_value: I18n.t("nitro_kit.combobox.loading"),
516
+ nk__combobox_error_value: I18n.t("nitro_kit.combobox.error"),
517
+ nk__combobox_remove_value: I18n.t("nitro_kit.combobox.remove", label: "%{label}")
518
+ }
519
+ end
520
+
521
+ def submitted_name(base)
522
+ return base unless @multiple
523
+
524
+ base.end_with?("[]") ? base : "#{base}[]"
525
+ end
526
+
527
+ def validate_remote_options!(options:, value:, include_blank:)
528
+ raise ArgumentError, "Combobox src: and options: are mutually exclusive; the server renders remote results" if options
529
+ raise ArgumentError, "Combobox src: selects through selected:, not value:" unless value.nil?
530
+ raise ArgumentError, "Combobox include_blank: applies only to local options:" unless include_blank == true
531
+ end
532
+
533
+ def validate_local_options!(selected:)
534
+ raise ArgumentError, "Combobox multiple: requires src:" if @multiple
535
+ unless selected.is_a?(Array) && selected.empty?
536
+ raise ArgumentError, "Combobox selected: requires src:; local options select through value:"
537
+ end
538
+ end
539
+
540
+ def typed_selection(value)
541
+ raise ArgumentError, "Combobox selected: must be an Array of choices" unless value.is_a?(Array)
542
+
543
+ coerced = value.map do |choice|
544
+ unless choice.is_a?(Choice) || choice.is_a?(Hash)
545
+ raise ArgumentError, "Combobox selected: entries must be Choice instances or Hashes with label: and value:"
546
+ end
547
+
548
+ Choice.coerce(choice)
549
+ end
550
+
551
+ if !@multiple && coerced.size > 1
552
+ raise ArgumentError, "Combobox selected: holds at most one choice unless multiple: true"
553
+ end
554
+
555
+ duplicates = coerced.group_by { |choice| choice.value.to_s }.select { |_key, choices| choices.many? }
556
+ if duplicates.any?
557
+ raise ArgumentError, "Combobox selected: values must be unique: #{duplicates.keys.join(", ")}"
558
+ end
559
+
560
+ coerced.freeze
561
+ end
562
+
211
563
  def typed_options(value)
212
564
  unless value.is_a?(Array) && value.any?
213
565
  raise ArgumentError, "Combobox options must be a non-empty Array"
@@ -289,13 +641,6 @@ module NitroKit
289
641
  raise ArgumentError, "Combobox label must be a non-blank String or false"
290
642
  end
291
643
 
292
- def validate_optional_text!(name, value)
293
- return if value.nil?
294
- return value if value.is_a?(String) && value.present?
295
-
296
- raise ArgumentError, "Combobox #{name} must be a non-blank String or nil"
297
- end
298
-
299
644
  def validate_blank_option!(value)
300
645
  return value if value == true || value == false || value.is_a?(String) && value.present?
301
646
 
@@ -13,17 +13,6 @@ module NitroKit
13
13
  )
14
14
  private_constant :Destination
15
15
 
16
- module Validation
17
- private
18
-
19
- def required_text(name, value)
20
- return value if value.is_a?(String) && !value.strip.empty?
21
-
22
- raise ArgumentError, "#{name} must be a non-blank String"
23
- end
24
- end
25
- private_constant :Validation
26
-
27
16
  module Destinations
28
17
  def destination(
29
18
  label,
@@ -37,8 +26,8 @@ module NitroKit
37
26
  ensure_collecting!
38
27
 
39
28
  @destinations << Destination.new(
40
- label: required_text(:label, label),
41
- href: required_text(:href, href),
29
+ label: validate_text!(:label, label),
30
+ href: validate_text!(:href, href),
42
31
  description: validate_optional_text!(:description, description),
43
32
  html:,
44
33
  aria:,
@@ -50,11 +39,9 @@ module NitroKit
50
39
  end
51
40
  private_constant :Destinations
52
41
 
53
- include Validation
54
42
  include Destinations
55
43
 
56
44
  class Results < Component
57
- include Validation
58
45
  include Destinations
59
46
 
60
47
  def initialize(
@@ -164,12 +151,12 @@ module NitroKit
164
151
  desperately_need_a_class: nil
165
152
  )
166
153
  @identifier = validate_id!("CommandPalette id:", id)
167
- @label = required_text(:label, label)
168
- @placeholder = required_text(:placeholder, placeholder)
169
- @empty_text = required_text(:empty_text, empty_text)
170
- @close_label = required_text(:close_label, close_label)
154
+ @label = validate_text!(:label, label)
155
+ @placeholder = validate_text!(:placeholder, placeholder)
156
+ @empty_text = validate_text!(:empty_text, empty_text)
157
+ @close_label = validate_text!(:close_label, close_label)
171
158
  @shortcut = validate_boolean!(:shortcut, shortcut)
172
- @shortcut_label = required_text(:shortcut_label, shortcut_label)
159
+ @shortcut_label = validate_text!(:shortcut_label, shortcut_label)
173
160
  @search_url = validate_optional_text!(:search_url, search_url)
174
161
  @destinations = []
175
162
 
@@ -23,12 +23,12 @@ module NitroKit
23
23
  )
24
24
  @record = record
25
25
  @route_base = route_base
26
- @caption = caption.nil? ? nil : validate_text!("caption", caption)
27
- @empty_text = validate_text!("empty_text", empty_text || I18n.t("nitro_kit.details_table.empty"))
26
+ @caption = caption.nil? ? nil : validate_text!("DetailsTable caption", caption)
27
+ @empty_text = validate_text!("DetailsTable empty_text", empty_text || I18n.t("nitro_kit.details_table.empty"))
28
28
  @boolean_labels = validate_boolean_labels!(boolean_labels || default_boolean_labels)
29
29
  @fields = []
30
30
  @table = Table.new(
31
- table_aria: label.nil? ? {} : { label: validate_text!("label", label) }
31
+ table_aria: label.nil? ? {} : { label: validate_text!("DetailsTable label", label) }
32
32
  )
33
33
 
34
34
  super(
@@ -70,7 +70,7 @@ module NitroKit
70
70
  if @fields.any? { |field| field.attribute.to_s == attribute.to_s }
71
71
  raise ArgumentError, "DetailsTable field keys must be unique: #{attribute.inspect}"
72
72
  end
73
- label = label.nil? ? attribute.to_s.humanize : validate_text!("field label", label)
73
+ label = label.nil? ? attribute.to_s.humanize : validate_text!("DetailsTable field label", label)
74
74
  resolved_value = value.equal?(UNSET) ? resolve_attribute(attribute) : value
75
75
 
76
76
  @fields << Field.new(attribute:, label:, value: resolved_value, content:)
@@ -215,12 +215,6 @@ module NitroKit
215
215
  raise ArgumentError, "DetailsTable field attribute must be a Symbol or non-blank String"
216
216
  end
217
217
 
218
- def validate_text!(name, value)
219
- return value if value.is_a?(String) && !value.strip.empty?
220
-
221
- raise ArgumentError, "DetailsTable #{name} must be a non-blank String"
222
- end
223
-
224
218
  def default_boolean_labels
225
219
  {
226
220
  true => I18n.t("nitro_kit.details_table.boolean_true"),
@@ -233,7 +227,7 @@ module NitroKit
233
227
  raise ArgumentError, "DetailsTable boolean_labels must be a Hash with true and false keys"
234
228
  end
235
229
 
236
- labels.each { |key, value| validate_text!("boolean_labels[#{key}]", value) }
230
+ labels.each { |key, value| validate_text!("DetailsTable boolean_labels[#{key}]", value) }
237
231
  labels
238
232
  end
239
233
  end