@agent-native/core 0.101.14 → 0.102.1

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 (316) hide show
  1. package/corpus/README.md +1 -1
  2. package/corpus/core/CHANGELOG.md +12 -0
  3. package/corpus/core/package.json +1 -1
  4. package/corpus/core/src/cli/templates-meta.ts +13 -0
  5. package/corpus/core/src/client/agent-page/AgentTabsPage.tsx +1 -1
  6. package/corpus/core/src/client/org/OrgSwitcher.tsx +2 -0
  7. package/corpus/templates/analytics/changelog/2026-07-15-fixed-the-agent-discarding-a-successful-dashboard-edit-and-r.md +6 -0
  8. package/corpus/templates/analytics/server/lib/real-data-actions.ts +30 -1
  9. package/corpus/templates/analytics/server/plugins/agent-chat.ts +15 -0
  10. package/corpus/templates/content/actions/_database-source-utils.ts +59 -4
  11. package/corpus/templates/content/actions/prepare-builder-source-review.ts +9 -0
  12. package/corpus/templates/content/actions/preview-builder-source-review.ts +6 -4
  13. package/corpus/templates/content/app/components/editor/DescriptionField.tsx +10 -2
  14. package/corpus/templates/content/app/components/editor/database/DatabaseView.tsx +4 -0
  15. package/corpus/templates/content/changelog/2026-07-15-page-and-database-descriptions-now-use-a-clean-single-line-f.md +6 -0
  16. package/corpus/templates/content/changelog/2026-07-15-selected-builder-reviews-now-load-only-the-chosen-rows-avoid.md +6 -0
  17. package/corpus/templates/content/shared/api.ts +1 -0
  18. package/corpus/templates/tasks/.agents/commands/visual-plan.md +9 -0
  19. package/corpus/templates/tasks/.agents/commands/visual-recap.md +8 -0
  20. package/corpus/templates/tasks/.agents/skills/actions/SKILL.md +492 -0
  21. package/corpus/templates/tasks/.agents/skills/adding-a-feature/SKILL.md +189 -0
  22. package/corpus/templates/tasks/.agents/skills/agent-native-docs/SKILL.md +76 -0
  23. package/corpus/templates/tasks/.agents/skills/agent-watchdog/README.md +43 -0
  24. package/corpus/templates/tasks/.agents/skills/agent-watchdog/SKILL.md +110 -0
  25. package/corpus/templates/tasks/.agents/skills/agent-watchdog/agents/openai.yaml +4 -0
  26. package/corpus/templates/tasks/.agents/skills/capture-learnings/SKILL.md +89 -0
  27. package/corpus/templates/tasks/.agents/skills/change-summary/SKILL.md +83 -0
  28. package/corpus/templates/tasks/.agents/skills/create-skill/SKILL.md +221 -0
  29. package/corpus/templates/tasks/.agents/skills/delegate-to-agent/SKILL.md +263 -0
  30. package/corpus/templates/tasks/.agents/skills/efficient-fable/README.md +75 -0
  31. package/corpus/templates/tasks/.agents/skills/efficient-fable/SKILL.md +95 -0
  32. package/corpus/templates/tasks/.agents/skills/efficient-frontier/README.md +53 -0
  33. package/corpus/templates/tasks/.agents/skills/efficient-frontier/SKILL.md +73 -0
  34. package/corpus/templates/tasks/.agents/skills/frontend-design/SKILL.md +112 -0
  35. package/corpus/templates/tasks/.agents/skills/plan-arbiter/README.md +41 -0
  36. package/corpus/templates/tasks/.agents/skills/plan-arbiter/SKILL.md +114 -0
  37. package/corpus/templates/tasks/.agents/skills/plan-arbiter/agents/openai.yaml +4 -0
  38. package/corpus/templates/tasks/.agents/skills/plow-ahead/README.md +42 -0
  39. package/corpus/templates/tasks/.agents/skills/plow-ahead/SKILL.md +104 -0
  40. package/corpus/templates/tasks/.agents/skills/plow-ahead/agents/openai.yaml +4 -0
  41. package/corpus/templates/tasks/.agents/skills/quick-recap/README.md +55 -0
  42. package/corpus/templates/tasks/.agents/skills/quick-recap/SKILL.md +54 -0
  43. package/corpus/templates/tasks/.agents/skills/read-the-damn-docs/README.md +54 -0
  44. package/corpus/templates/tasks/.agents/skills/read-the-damn-docs/SKILL.md +126 -0
  45. package/corpus/templates/tasks/.agents/skills/read-the-damn-docs/agents/openai.yaml +4 -0
  46. package/corpus/templates/tasks/.agents/skills/real-time-sync/SKILL.md +232 -0
  47. package/corpus/templates/tasks/.agents/skills/security/SKILL.md +280 -0
  48. package/corpus/templates/tasks/.agents/skills/self-modifying-code/SKILL.md +106 -0
  49. package/corpus/templates/tasks/.agents/skills/shadcn-ui/SKILL.md +95 -0
  50. package/corpus/templates/tasks/.agents/skills/stay-within-limits/README.md +61 -0
  51. package/corpus/templates/tasks/.agents/skills/stay-within-limits/SKILL.md +83 -0
  52. package/corpus/templates/tasks/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
  53. package/corpus/templates/tasks/.agents/skills/visual-plan/SKILL.md +547 -0
  54. package/corpus/templates/tasks/.agents/skills/visual-plan/agent-native-skill.json +12 -0
  55. package/corpus/templates/tasks/.agents/skills/visual-plan/references/canvas.md +121 -0
  56. package/corpus/templates/tasks/.agents/skills/visual-plan/references/document-quality.md +178 -0
  57. package/corpus/templates/tasks/.agents/skills/visual-plan/references/exemplar.md +62 -0
  58. package/corpus/templates/tasks/.agents/skills/visual-plan/references/wireframe.md +264 -0
  59. package/corpus/templates/tasks/.agents/skills/visual-recap/SKILL.md +634 -0
  60. package/corpus/templates/tasks/.agents/skills/visual-recap/agent-native-skill.json +12 -0
  61. package/corpus/templates/tasks/.agents/skills/visual-recap/references/wireframe.md +264 -0
  62. package/corpus/templates/tasks/.claude/commands/visual-plan.md +9 -0
  63. package/corpus/templates/tasks/.claude/commands/visual-recap.md +8 -0
  64. package/corpus/templates/tasks/.env.example +5 -0
  65. package/corpus/templates/tasks/.ignore +0 -0
  66. package/corpus/templates/tasks/.prettierrc +5 -0
  67. package/corpus/templates/tasks/AGENTS.md +158 -0
  68. package/corpus/templates/tasks/DEVELOPING.md +185 -0
  69. package/corpus/templates/tasks/README.md +16 -0
  70. package/corpus/templates/tasks/actions/bulk-delete-inbox-items.ts +24 -0
  71. package/corpus/templates/tasks/actions/bulk-delete-tasks.ts +21 -0
  72. package/corpus/templates/tasks/actions/bulk-mark-inbox-items-ready.ts +27 -0
  73. package/corpus/templates/tasks/actions/bulk-update-tasks.ts +35 -0
  74. package/corpus/templates/tasks/actions/create-custom-field.ts +22 -0
  75. package/corpus/templates/tasks/actions/create-inbox-item.ts +30 -0
  76. package/corpus/templates/tasks/actions/create-task.ts +33 -0
  77. package/corpus/templates/tasks/actions/delete-custom-field.ts +19 -0
  78. package/corpus/templates/tasks/actions/delete-inbox-item.ts +17 -0
  79. package/corpus/templates/tasks/actions/delete-task.ts +17 -0
  80. package/corpus/templates/tasks/actions/lib/boolean-query-param.ts +30 -0
  81. package/corpus/templates/tasks/actions/list-custom-fields.ts +18 -0
  82. package/corpus/templates/tasks/actions/list-inbox-items.ts +16 -0
  83. package/corpus/templates/tasks/actions/list-tasks.ts +52 -0
  84. package/corpus/templates/tasks/actions/list-visible-task-fields.ts +18 -0
  85. package/corpus/templates/tasks/actions/mark-inbox-item-ready.ts +31 -0
  86. package/corpus/templates/tasks/actions/navigate.ts +51 -0
  87. package/corpus/templates/tasks/actions/reorder-custom-fields.ts +27 -0
  88. package/corpus/templates/tasks/actions/reorder-inbox-items.ts +24 -0
  89. package/corpus/templates/tasks/actions/reorder-tasks.ts +29 -0
  90. package/corpus/templates/tasks/actions/run.ts +2 -0
  91. package/corpus/templates/tasks/actions/update-custom-field.ts +33 -0
  92. package/corpus/templates/tasks/actions/update-inbox-item.ts +24 -0
  93. package/corpus/templates/tasks/actions/update-task.ts +68 -0
  94. package/corpus/templates/tasks/actions/update-visible-task-fields.ts +27 -0
  95. package/corpus/templates/tasks/actions/view-screen-helpers.ts +68 -0
  96. package/corpus/templates/tasks/actions/view-screen.ts +207 -0
  97. package/corpus/templates/tasks/app/components/custom-fields/FieldCreateBar.tsx +121 -0
  98. package/corpus/templates/tasks/app/components/custom-fields/FieldListRow.tsx +116 -0
  99. package/corpus/templates/tasks/app/components/custom-fields/FieldsList.tsx +225 -0
  100. package/corpus/templates/tasks/app/components/custom-fields/FieldsListSkeleton.tsx +18 -0
  101. package/corpus/templates/tasks/app/components/custom-fields/FieldsPage.tsx +42 -0
  102. package/corpus/templates/tasks/app/components/custom-fields/editor/FieldEditorSidebar.tsx +69 -0
  103. package/corpus/templates/tasks/app/components/custom-fields/editor/FieldTitleSection.tsx +32 -0
  104. package/corpus/templates/tasks/app/components/custom-fields/editor/config/CurrencyConfigControl.tsx +49 -0
  105. package/corpus/templates/tasks/app/components/custom-fields/editor/config/FieldConfigControl.tsx +56 -0
  106. package/corpus/templates/tasks/app/components/custom-fields/editor/config/NumberConfigControl.tsx +52 -0
  107. package/corpus/templates/tasks/app/components/custom-fields/editor/config/PercentConfigControl.tsx +30 -0
  108. package/corpus/templates/tasks/app/components/custom-fields/editor/config/SelectConfigControl.tsx +135 -0
  109. package/corpus/templates/tasks/app/components/custom-fields/editor/config/select-colors.ts +23 -0
  110. package/corpus/templates/tasks/app/components/custom-fields/editor/config/utils.ts +52 -0
  111. package/corpus/templates/tasks/app/components/custom-fields/editor/types.ts +7 -0
  112. package/corpus/templates/tasks/app/components/dnd/SortableItem.tsx +72 -0
  113. package/corpus/templates/tasks/app/components/dnd/SortableList.tsx +136 -0
  114. package/corpus/templates/tasks/app/components/dnd/reorder-moving-items.ts +160 -0
  115. package/corpus/templates/tasks/app/components/dnd/sortable-drag-props.ts +60 -0
  116. package/corpus/templates/tasks/app/components/inbox/InboxList.tsx +222 -0
  117. package/corpus/templates/tasks/app/components/inbox/InboxListPage.tsx +39 -0
  118. package/corpus/templates/tasks/app/components/inbox/InboxListRow.tsx +122 -0
  119. package/corpus/templates/tasks/app/components/layout/Header.tsx +55 -0
  120. package/corpus/templates/tasks/app/components/layout/HeaderActions.tsx +84 -0
  121. package/corpus/templates/tasks/app/components/layout/Layout.tsx +134 -0
  122. package/corpus/templates/tasks/app/components/layout/Sidebar.tsx +211 -0
  123. package/corpus/templates/tasks/app/components/shared/AddListItemInput.tsx +57 -0
  124. package/corpus/templates/tasks/app/components/shared/AlertDialog.tsx +53 -0
  125. package/corpus/templates/tasks/app/components/shared/BulkDeleteDialog.tsx +76 -0
  126. package/corpus/templates/tasks/app/components/shared/ChipSelect.tsx +240 -0
  127. package/corpus/templates/tasks/app/components/shared/DeleteItemDialog.tsx +40 -0
  128. package/corpus/templates/tasks/app/components/shared/InlineEditable.tsx +166 -0
  129. package/corpus/templates/tasks/app/components/shared/ListEmptyState.tsx +13 -0
  130. package/corpus/templates/tasks/app/components/shared/ListErrorMessage.tsx +15 -0
  131. package/corpus/templates/tasks/app/components/shared/ListViewHeader.tsx +75 -0
  132. package/corpus/templates/tasks/app/components/shared/PageHeader.tsx +25 -0
  133. package/corpus/templates/tasks/app/components/shared/RowActionsMenu.tsx +42 -0
  134. package/corpus/templates/tasks/app/components/shared/SidePanel.tsx +99 -0
  135. package/corpus/templates/tasks/app/components/shared/dnd/ListRowPreview.tsx +37 -0
  136. package/corpus/templates/tasks/app/components/shared/list/List.tsx +63 -0
  137. package/corpus/templates/tasks/app/components/shared/list/ListRow.tsx +159 -0
  138. package/corpus/templates/tasks/app/components/shared/list/ListRowDragHandle.tsx +52 -0
  139. package/corpus/templates/tasks/app/components/shared/list/ListSkeletonRows.tsx +11 -0
  140. package/corpus/templates/tasks/app/components/shared/list/SortableListItemShell.tsx +32 -0
  141. package/corpus/templates/tasks/app/components/shared/list/types.ts +1 -0
  142. package/corpus/templates/tasks/app/components/shared/selection/ListSelectionBar.tsx +158 -0
  143. package/corpus/templates/tasks/app/components/shared/selection/ListSelectionHeaderToggle.tsx +28 -0
  144. package/corpus/templates/tasks/app/components/shared/selection/ListSelectionToolbar.tsx +81 -0
  145. package/corpus/templates/tasks/app/components/shared/selection/get-list-row-selection-ui.ts +41 -0
  146. package/corpus/templates/tasks/app/components/shared/selection/use-list-selection.ts +196 -0
  147. package/corpus/templates/tasks/app/components/tasks/TaskList.tsx +333 -0
  148. package/corpus/templates/tasks/app/components/tasks/TaskListHeaderRow.tsx +46 -0
  149. package/corpus/templates/tasks/app/components/tasks/TaskListPage.tsx +115 -0
  150. package/corpus/templates/tasks/app/components/tasks/TaskListRow.css +49 -0
  151. package/corpus/templates/tasks/app/components/tasks/TaskListRow.tsx +307 -0
  152. package/corpus/templates/tasks/app/components/tasks/fields/TaskFieldsSidebar.tsx +102 -0
  153. package/corpus/templates/tasks/app/components/tasks/fields/TaskTitleSection.tsx +27 -0
  154. package/corpus/templates/tasks/app/components/tasks/fields/controls/DateValueControl.tsx +21 -0
  155. package/corpus/templates/tasks/app/components/tasks/fields/controls/FieldValueControl.tsx +76 -0
  156. package/corpus/templates/tasks/app/components/tasks/fields/controls/MultiSelectValueControl.tsx +52 -0
  157. package/corpus/templates/tasks/app/components/tasks/fields/controls/NumberValueControl.tsx +56 -0
  158. package/corpus/templates/tasks/app/components/tasks/fields/controls/RichTextValueControl.tsx +115 -0
  159. package/corpus/templates/tasks/app/components/tasks/fields/controls/SingleSelectValueControl.tsx +61 -0
  160. package/corpus/templates/tasks/app/components/tasks/fields/controls/TextValueControl.tsx +20 -0
  161. package/corpus/templates/tasks/app/components/tasks/use-task-row-completion-animation.ts +181 -0
  162. package/corpus/templates/tasks/app/components/ui/accordion.tsx +56 -0
  163. package/corpus/templates/tasks/app/components/ui/alert-dialog.tsx +1 -0
  164. package/corpus/templates/tasks/app/components/ui/alert.tsx +1 -0
  165. package/corpus/templates/tasks/app/components/ui/aspect-ratio.tsx +5 -0
  166. package/corpus/templates/tasks/app/components/ui/avatar.tsx +1 -0
  167. package/corpus/templates/tasks/app/components/ui/badge.tsx +1 -0
  168. package/corpus/templates/tasks/app/components/ui/breadcrumb.tsx +115 -0
  169. package/corpus/templates/tasks/app/components/ui/button.tsx +1 -0
  170. package/corpus/templates/tasks/app/components/ui/calendar.tsx +70 -0
  171. package/corpus/templates/tasks/app/components/ui/card.tsx +1 -0
  172. package/corpus/templates/tasks/app/components/ui/carousel.tsx +260 -0
  173. package/corpus/templates/tasks/app/components/ui/chart.tsx +379 -0
  174. package/corpus/templates/tasks/app/components/ui/checkbox.tsx +1 -0
  175. package/corpus/templates/tasks/app/components/ui/collapsible.tsx +1 -0
  176. package/corpus/templates/tasks/app/components/ui/command.tsx +1 -0
  177. package/corpus/templates/tasks/app/components/ui/context-menu.tsx +1 -0
  178. package/corpus/templates/tasks/app/components/ui/dialog.tsx +1 -0
  179. package/corpus/templates/tasks/app/components/ui/drawer.tsx +1 -0
  180. package/corpus/templates/tasks/app/components/ui/dropdown-menu.tsx +1 -0
  181. package/corpus/templates/tasks/app/components/ui/form.tsx +177 -0
  182. package/corpus/templates/tasks/app/components/ui/hover-card.tsx +27 -0
  183. package/corpus/templates/tasks/app/components/ui/input-otp.tsx +69 -0
  184. package/corpus/templates/tasks/app/components/ui/input.tsx +1 -0
  185. package/corpus/templates/tasks/app/components/ui/label.tsx +1 -0
  186. package/corpus/templates/tasks/app/components/ui/menubar.tsx +254 -0
  187. package/corpus/templates/tasks/app/components/ui/navigation-menu.tsx +128 -0
  188. package/corpus/templates/tasks/app/components/ui/pagination.tsx +121 -0
  189. package/corpus/templates/tasks/app/components/ui/popover.tsx +1 -0
  190. package/corpus/templates/tasks/app/components/ui/progress.tsx +1 -0
  191. package/corpus/templates/tasks/app/components/ui/radio-group.tsx +1 -0
  192. package/corpus/templates/tasks/app/components/ui/resizable.tsx +43 -0
  193. package/corpus/templates/tasks/app/components/ui/scroll-area.tsx +1 -0
  194. package/corpus/templates/tasks/app/components/ui/select.tsx +1 -0
  195. package/corpus/templates/tasks/app/components/ui/separator.tsx +1 -0
  196. package/corpus/templates/tasks/app/components/ui/sheet.tsx +1 -0
  197. package/corpus/templates/tasks/app/components/ui/sidebar.tsx +782 -0
  198. package/corpus/templates/tasks/app/components/ui/skeleton.tsx +1 -0
  199. package/corpus/templates/tasks/app/components/ui/slider.tsx +1 -0
  200. package/corpus/templates/tasks/app/components/ui/sonner.tsx +1 -0
  201. package/corpus/templates/tasks/app/components/ui/spinner.tsx +1 -0
  202. package/corpus/templates/tasks/app/components/ui/switch.tsx +1 -0
  203. package/corpus/templates/tasks/app/components/ui/table.tsx +1 -0
  204. package/corpus/templates/tasks/app/components/ui/tabs.tsx +1 -0
  205. package/corpus/templates/tasks/app/components/ui/textarea.tsx +1 -0
  206. package/corpus/templates/tasks/app/components/ui/toast.tsx +1 -0
  207. package/corpus/templates/tasks/app/components/ui/toaster.tsx +1 -0
  208. package/corpus/templates/tasks/app/components/ui/toggle-group.tsx +1 -0
  209. package/corpus/templates/tasks/app/components/ui/toggle.tsx +43 -0
  210. package/corpus/templates/tasks/app/components/ui/tooltip.tsx +1 -0
  211. package/corpus/templates/tasks/app/components/ui/use-toast.ts +3 -0
  212. package/corpus/templates/tasks/app/entry.client.tsx +19 -0
  213. package/corpus/templates/tasks/app/entry.server.tsx +10 -0
  214. package/corpus/templates/tasks/app/global.css +93 -0
  215. package/corpus/templates/tasks/app/hooks/cache.ts +31 -0
  216. package/corpus/templates/tasks/app/hooks/use-custom-fields.ts +93 -0
  217. package/corpus/templates/tasks/app/hooks/use-inbox-items.ts +196 -0
  218. package/corpus/templates/tasks/app/hooks/use-mobile.tsx +21 -0
  219. package/corpus/templates/tasks/app/hooks/use-navigation-state.ts +40 -0
  220. package/corpus/templates/tasks/app/hooks/use-tasks.ts +276 -0
  221. package/corpus/templates/tasks/app/hooks/use-toast.ts +188 -0
  222. package/corpus/templates/tasks/app/hooks/use-visible-task-fields.ts +140 -0
  223. package/corpus/templates/tasks/app/lib/app-config.ts +11 -0
  224. package/corpus/templates/tasks/app/lib/tab-id.ts +1 -0
  225. package/corpus/templates/tasks/app/lib/utils.ts +1 -0
  226. package/corpus/templates/tasks/app/root.tsx +130 -0
  227. package/corpus/templates/tasks/app/routes/_index.tsx +22 -0
  228. package/corpus/templates/tasks/app/routes/extensions.$id.$slug.tsx +2 -0
  229. package/corpus/templates/tasks/app/routes/extensions.$id.tsx +11 -0
  230. package/corpus/templates/tasks/app/routes/extensions._index.tsx +11 -0
  231. package/corpus/templates/tasks/app/routes/extensions.tsx +5 -0
  232. package/corpus/templates/tasks/app/routes/fields.tsx +16 -0
  233. package/corpus/templates/tasks/app/routes/inbox.tsx +16 -0
  234. package/corpus/templates/tasks/app/routes/tasks.tsx +17 -0
  235. package/corpus/templates/tasks/app/routes/team.tsx +17 -0
  236. package/corpus/templates/tasks/app/routes.ts +4 -0
  237. package/corpus/templates/tasks/app/vite-env.d.ts +6 -0
  238. package/corpus/templates/tasks/components.json +20 -0
  239. package/corpus/templates/tasks/data/sync-config.json +1 -0
  240. package/corpus/templates/tasks/docs/features/README.md +81 -0
  241. package/corpus/templates/tasks/docs/features/f1-tasks.mdx +67 -0
  242. package/corpus/templates/tasks/docs/features/f2-custom-fields.mdx +68 -0
  243. package/corpus/templates/tasks/docs/features/f3-projects.mdx +33 -0
  244. package/corpus/templates/tasks/docs/features/f4-inbox.mdx +55 -0
  245. package/corpus/templates/tasks/docs/features/f5-views.mdx +65 -0
  246. package/corpus/templates/tasks/docs/features/f6-search.mdx +43 -0
  247. package/corpus/templates/tasks/docs/features/f7-first-run.mdx +66 -0
  248. package/corpus/templates/tasks/docs/features/f8-chat.mdx +120 -0
  249. package/corpus/templates/tasks/e2e/global-setup.ts +42 -0
  250. package/corpus/templates/tasks/e2e/helpers/inbox.ts +71 -0
  251. package/corpus/templates/tasks/e2e/helpers/tasks.ts +99 -0
  252. package/corpus/templates/tasks/learnings.defaults.md +5 -0
  253. package/corpus/templates/tasks/netlify.toml +10 -0
  254. package/corpus/templates/tasks/package.json +104 -0
  255. package/corpus/templates/tasks/playwright.config.ts +34 -0
  256. package/corpus/templates/tasks/public/agent-native-icon-dark.svg +10 -0
  257. package/corpus/templates/tasks/public/agent-native-icon-light.svg +10 -0
  258. package/corpus/templates/tasks/public/agent-native-logo-dark.svg +21 -0
  259. package/corpus/templates/tasks/public/agent-native-logo-light.svg +21 -0
  260. package/corpus/templates/tasks/public/favicon.svg +1 -0
  261. package/corpus/templates/tasks/public/icon-180.svg +1 -0
  262. package/corpus/templates/tasks/public/icon-192.svg +1 -0
  263. package/corpus/templates/tasks/public/icon-512.svg +1 -0
  264. package/corpus/templates/tasks/public/manifest.json +21 -0
  265. package/corpus/templates/tasks/react-router.config.ts +7 -0
  266. package/corpus/templates/tasks/server/custom-fields/normalize.ts +163 -0
  267. package/corpus/templates/tasks/server/custom-fields/parse.ts +146 -0
  268. package/corpus/templates/tasks/server/custom-fields/schema.ts +147 -0
  269. package/corpus/templates/tasks/server/custom-fields/store.ts +425 -0
  270. package/corpus/templates/tasks/server/custom-fields/task-fields.ts +104 -0
  271. package/corpus/templates/tasks/server/custom-fields/types.ts +98 -0
  272. package/corpus/templates/tasks/server/custom-fields/validate.ts +210 -0
  273. package/corpus/templates/tasks/server/custom-fields/values/store.ts +386 -0
  274. package/corpus/templates/tasks/server/db/bulk-write.ts +30 -0
  275. package/corpus/templates/tasks/server/db/index.ts +5 -0
  276. package/corpus/templates/tasks/server/db/record-utils.ts +7 -0
  277. package/corpus/templates/tasks/server/db/schema.ts +67 -0
  278. package/corpus/templates/tasks/server/db/test-tasks-table.ts +76 -0
  279. package/corpus/templates/tasks/server/db/transaction.ts +6 -0
  280. package/corpus/templates/tasks/server/errors.ts +31 -0
  281. package/corpus/templates/tasks/server/inbox/store.ts +216 -0
  282. package/corpus/templates/tasks/server/middleware/auth.ts +15 -0
  283. package/corpus/templates/tasks/server/plugins/agent-chat.ts +46 -0
  284. package/corpus/templates/tasks/server/plugins/auth.ts +15 -0
  285. package/corpus/templates/tasks/server/plugins/db.ts +90 -0
  286. package/corpus/templates/tasks/server/routes/[...page].get.ts +5 -0
  287. package/corpus/templates/tasks/server/stored-items/store.ts +548 -0
  288. package/corpus/templates/tasks/server/tasks/store.ts +306 -0
  289. package/corpus/templates/tasks/server/user-config/store.ts +138 -0
  290. package/corpus/templates/tasks/shared/app-state-tabs.ts +15 -0
  291. package/corpus/templates/tasks/shared/boolean-param.ts +22 -0
  292. package/corpus/templates/tasks/shared/bulk-limits.ts +7 -0
  293. package/corpus/templates/tasks/shared/list-screen-snapshot.ts +90 -0
  294. package/corpus/templates/tasks/shared/navigation.ts +104 -0
  295. package/corpus/templates/tasks/shared/visible-task-fields.ts +2 -0
  296. package/corpus/templates/tasks/ssr-entry.ts +15 -0
  297. package/corpus/templates/tasks/tsconfig.json +24 -0
  298. package/corpus/templates/tasks/vite.config.ts +19 -0
  299. package/corpus/templates/tasks/vitest.config.ts +8 -0
  300. package/dist/cli/templates-meta.d.ts.map +1 -1
  301. package/dist/cli/templates-meta.js +13 -0
  302. package/dist/cli/templates-meta.js.map +1 -1
  303. package/dist/client/agent-page/AgentTabsPage.js +1 -1
  304. package/dist/client/agent-page/AgentTabsPage.js.map +1 -1
  305. package/dist/client/org/OrgSwitcher.d.ts.map +1 -1
  306. package/dist/client/org/OrgSwitcher.js +2 -1
  307. package/dist/client/org/OrgSwitcher.js.map +1 -1
  308. package/dist/collab/routes.d.ts +1 -1
  309. package/dist/collab/struct-routes.d.ts +1 -1
  310. package/dist/notifications/routes.d.ts +2 -2
  311. package/dist/observability/routes.d.ts +5 -5
  312. package/dist/resources/handlers.d.ts +3 -3
  313. package/dist/secrets/routes.d.ts +9 -9
  314. package/dist/server/agent-engine-api-key-route.d.ts +1 -1
  315. package/dist/server/transcribe-voice.d.ts +1 -1
  316. package/package.json +1 -1
@@ -0,0 +1,166 @@
1
+ import {
2
+ useEffect,
3
+ useRef,
4
+ useState,
5
+ type HTMLAttributes,
6
+ type KeyboardEvent,
7
+ } from "react";
8
+
9
+ import { Input } from "@/components/ui/input";
10
+ import { cn } from "@/lib/utils";
11
+
12
+ export const LIST_ROW_TITLE_FIELD_CLASS =
13
+ "h-8 w-full rounded-md border px-3 text-sm leading-8";
14
+
15
+ function useInlineTitleEdit(input: {
16
+ title: string;
17
+ onSave: (title: string) => Promise<unknown>;
18
+ }) {
19
+ const [editing, setEditing] = useState(false);
20
+ const [draftTitle, setDraftTitle] = useState(input.title);
21
+ const [optimisticTitle, setOptimisticTitle] = useState<string | null>(null);
22
+ const inputRef = useRef<HTMLInputElement>(null);
23
+ const skipBlurSaveRef = useRef(false);
24
+
25
+ const displayTitle = optimisticTitle ?? input.title;
26
+
27
+ useEffect(() => {
28
+ if (optimisticTitle !== null && input.title === optimisticTitle) {
29
+ setOptimisticTitle(null);
30
+ }
31
+ if (!editing && optimisticTitle === null) {
32
+ setDraftTitle(input.title);
33
+ }
34
+ }, [editing, optimisticTitle, input.title]);
35
+
36
+ useEffect(() => {
37
+ if (editing) {
38
+ inputRef.current?.focus();
39
+ inputRef.current?.select();
40
+ }
41
+ }, [editing]);
42
+
43
+ async function saveTitle() {
44
+ const trimmed = draftTitle.trim();
45
+ if (!trimmed || trimmed === input.title) {
46
+ setDraftTitle(input.title);
47
+ setOptimisticTitle(null);
48
+ setEditing(false);
49
+ return;
50
+ }
51
+ setOptimisticTitle(trimmed);
52
+ setEditing(false);
53
+ try {
54
+ await input.onSave(trimmed);
55
+ } catch {
56
+ setOptimisticTitle(null);
57
+ setDraftTitle(input.title);
58
+ }
59
+ }
60
+
61
+ function handleTitleKeyDown(event: KeyboardEvent<HTMLInputElement>) {
62
+ if (event.key === "Enter") {
63
+ event.preventDefault();
64
+ skipBlurSaveRef.current = true;
65
+ void saveTitle();
66
+ }
67
+ if (event.key === "Escape") {
68
+ event.preventDefault();
69
+ skipBlurSaveRef.current = true;
70
+ setDraftTitle(displayTitle);
71
+ setEditing(false);
72
+ }
73
+ }
74
+
75
+ function handleTitleBlur() {
76
+ if (skipBlurSaveRef.current) {
77
+ skipBlurSaveRef.current = false;
78
+ return;
79
+ }
80
+ void saveTitle();
81
+ }
82
+
83
+ return {
84
+ editing,
85
+ setEditing,
86
+ draftTitle,
87
+ setDraftTitle,
88
+ displayTitle,
89
+ inputRef,
90
+ handleTitleKeyDown,
91
+ handleTitleBlur,
92
+ };
93
+ }
94
+
95
+ interface InlineEditableProps {
96
+ value: string;
97
+ onSave: (title: string) => Promise<unknown>;
98
+ ariaLabel: string;
99
+ disabled?: boolean;
100
+ titleDragProps?: HTMLAttributes<HTMLButtonElement>;
101
+ displayDone?: boolean;
102
+ className?: string;
103
+ onDisplayTitleChange?: (title: string) => void;
104
+ }
105
+
106
+ export function InlineEditable({
107
+ value,
108
+ onSave,
109
+ ariaLabel,
110
+ disabled = false,
111
+ titleDragProps,
112
+ displayDone = false,
113
+ className,
114
+ onDisplayTitleChange,
115
+ }: InlineEditableProps) {
116
+ const {
117
+ editing,
118
+ setEditing,
119
+ draftTitle,
120
+ setDraftTitle,
121
+ displayTitle,
122
+ inputRef,
123
+ handleTitleKeyDown,
124
+ handleTitleBlur,
125
+ } = useInlineTitleEdit({ title: value, onSave });
126
+
127
+ useEffect(() => {
128
+ onDisplayTitleChange?.(displayTitle);
129
+ }, [displayTitle, onDisplayTitleChange]);
130
+
131
+ if (editing) {
132
+ return (
133
+ <Input
134
+ ref={inputRef}
135
+ value={draftTitle}
136
+ onChange={(event) => setDraftTitle(event.target.value)}
137
+ onBlur={handleTitleBlur}
138
+ onKeyDown={handleTitleKeyDown}
139
+ aria-label={ariaLabel}
140
+ className={cn(
141
+ LIST_ROW_TITLE_FIELD_CLASS,
142
+ "border-input bg-background py-0 shadow-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-0",
143
+ className,
144
+ )}
145
+ disabled={disabled}
146
+ />
147
+ );
148
+ }
149
+
150
+ return (
151
+ <button
152
+ type="button"
153
+ {...titleDragProps}
154
+ onClick={() => setEditing(true)}
155
+ disabled={disabled}
156
+ className={cn(
157
+ LIST_ROW_TITLE_FIELD_CLASS,
158
+ "flex cursor-text items-center truncate border-transparent bg-transparent text-left outline-none transition-[color,text-decoration-color] duration-200 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-0 disabled:cursor-not-allowed",
159
+ displayDone && "line-through text-muted-foreground",
160
+ className,
161
+ )}
162
+ >
163
+ {displayTitle}
164
+ </button>
165
+ );
166
+ }
@@ -0,0 +1,13 @@
1
+ interface ListEmptyStateProps {
2
+ heading: string;
3
+ description: string;
4
+ }
5
+
6
+ export function ListEmptyState({ heading, description }: ListEmptyStateProps) {
7
+ return (
8
+ <div className="rounded-lg border border-dashed border-border p-8 text-center">
9
+ <p className="text-sm font-medium">{heading}</p>
10
+ <p className="mt-1 text-sm text-muted-foreground">{description}</p>
11
+ </div>
12
+ );
13
+ }
@@ -0,0 +1,15 @@
1
+ type ListErrorMessageProps = {
2
+ error: unknown;
3
+ fallbackMessage: string;
4
+ };
5
+
6
+ export function ListErrorMessage({
7
+ error,
8
+ fallbackMessage,
9
+ }: ListErrorMessageProps) {
10
+ return (
11
+ <div className="rounded-lg border border-destructive/30 bg-destructive/5 p-4 text-sm text-destructive">
12
+ {(error as Error)?.message ?? fallbackMessage}
13
+ </div>
14
+ );
15
+ }
@@ -0,0 +1,75 @@
1
+ import { AgentToggleButton } from "@agent-native/core/client";
2
+
3
+ import { PageHeader } from "@/components/shared/PageHeader";
4
+ import { ListSelectionHeaderToggle } from "@/components/shared/selection/ListSelectionHeaderToggle";
5
+ import { type ListSelection } from "@/components/shared/selection/use-list-selection";
6
+ import { Label } from "@/components/ui/label";
7
+ import { Switch } from "@/components/ui/switch";
8
+
9
+ export interface ListViewHeaderProps<T extends { id: string }> {
10
+ title: string;
11
+ description: string;
12
+ isPending: boolean;
13
+ showSelectToggle: boolean;
14
+ selection: ListSelection<T> | null;
15
+ toolbarBusy?: boolean;
16
+ includeDone?: boolean;
17
+ onIncludeDoneChange?: (next: boolean) => void;
18
+ showAgentToggle?: boolean;
19
+ }
20
+
21
+ export function ListViewHeader<T extends { id: string }>({
22
+ title,
23
+ description,
24
+ isPending,
25
+ showSelectToggle,
26
+ selection,
27
+ toolbarBusy,
28
+ includeDone,
29
+ onIncludeDoneChange,
30
+ showAgentToggle = false,
31
+ }: ListViewHeaderProps<T>) {
32
+ const showIncludeDone =
33
+ includeDone !== undefined && onIncludeDoneChange !== undefined;
34
+ const hasActions =
35
+ (showSelectToggle && selection) || showIncludeDone || showAgentToggle;
36
+
37
+ return (
38
+ <PageHeader
39
+ title={title}
40
+ description={description}
41
+ actions={
42
+ hasActions ? (
43
+ <>
44
+ {showSelectToggle && selection ? (
45
+ <ListSelectionHeaderToggle
46
+ selectionMode={selection.state.selectionMode}
47
+ disabled={toolbarBusy || isPending}
48
+ onSelectionModeChange={
49
+ selection.actions.setSelectionModeFromHeader
50
+ }
51
+ />
52
+ ) : null}
53
+ {showIncludeDone ? (
54
+ <div className="flex shrink-0 items-center gap-2 rounded-lg border border-border px-3 py-2">
55
+ <Switch
56
+ id="include-done"
57
+ checked={includeDone}
58
+ onCheckedChange={onIncludeDoneChange}
59
+ disabled={isPending}
60
+ />
61
+ <Label
62
+ htmlFor="include-done"
63
+ className="text-sm whitespace-nowrap"
64
+ >
65
+ Show all
66
+ </Label>
67
+ </div>
68
+ ) : null}
69
+ {showAgentToggle ? <AgentToggleButton /> : null}
70
+ </>
71
+ ) : undefined
72
+ }
73
+ />
74
+ );
75
+ }
@@ -0,0 +1,25 @@
1
+ import type { ReactNode } from "react";
2
+
3
+ export function PageHeader({
4
+ title,
5
+ description,
6
+ actions,
7
+ }: {
8
+ title: string;
9
+ description: string;
10
+ actions?: ReactNode;
11
+ }) {
12
+ return (
13
+ <header className="shrink-0 space-y-1">
14
+ <div className="flex items-center justify-between gap-3">
15
+ <h1 className="min-w-0 truncate text-2xl font-semibold tracking-tight">
16
+ {title}
17
+ </h1>
18
+ {actions ? (
19
+ <div className="flex shrink-0 items-center gap-2">{actions}</div>
20
+ ) : null}
21
+ </div>
22
+ <p className="text-sm text-muted-foreground">{description}</p>
23
+ </header>
24
+ );
25
+ }
@@ -0,0 +1,42 @@
1
+ import { IconDots } from "@tabler/icons-react";
2
+ import { type ReactNode } from "react";
3
+
4
+ import { Button } from "@/components/ui/button";
5
+ import {
6
+ DropdownMenu,
7
+ DropdownMenuContent,
8
+ DropdownMenuTrigger,
9
+ } from "@/components/ui/dropdown-menu";
10
+
11
+ interface RowActionsMenuProps {
12
+ ariaLabel: string;
13
+ disabled?: boolean;
14
+ children: ReactNode;
15
+ }
16
+
17
+ export function RowActionsMenu({
18
+ ariaLabel,
19
+ disabled = false,
20
+ children,
21
+ }: RowActionsMenuProps) {
22
+ return (
23
+ <DropdownMenu>
24
+ <DropdownMenuTrigger asChild>
25
+ <Button
26
+ type="button"
27
+ variant="ghost"
28
+ size="icon"
29
+ disabled={disabled}
30
+ aria-label={ariaLabel}
31
+ onClick={(event) => event.stopPropagation()}
32
+ className="relative z-10 size-8 text-muted-foreground opacity-70 hover:text-foreground"
33
+ >
34
+ <IconDots />
35
+ </Button>
36
+ </DropdownMenuTrigger>
37
+ <DropdownMenuContent align="end" sideOffset={4}>
38
+ {children}
39
+ </DropdownMenuContent>
40
+ </DropdownMenu>
41
+ );
42
+ }
@@ -0,0 +1,99 @@
1
+ import { IconX } from "@tabler/icons-react";
2
+ import { useEffect, useState, type ReactNode } from "react";
3
+
4
+ import { Button } from "@/components/ui/button";
5
+ import { cn } from "@/lib/utils";
6
+
7
+ const AGENT_SIDEBAR_WIDTH_KEY = "agent-native-sidebar-width";
8
+ const DEFAULT_AGENT_SIDEBAR_WIDTH = 380;
9
+
10
+ /** Match AgentSidebar width so app-owned panels sit flush on the right edge.
11
+ * Uses the same localStorage key the framework writes on resize (280–700px).
12
+ * Reads once on mount only — live agent-sidebar drags do not update this hook. */
13
+ function useAgentSidebarWidth() {
14
+ const [width, setWidth] = useState(DEFAULT_AGENT_SIDEBAR_WIDTH);
15
+
16
+ useEffect(() => {
17
+ try {
18
+ const saved = window.localStorage.getItem(AGENT_SIDEBAR_WIDTH_KEY);
19
+ if (!saved) return;
20
+ const parsed = Number.parseInt(saved, 10);
21
+ if (parsed >= 280 && parsed <= 700) setWidth(parsed);
22
+ } catch {
23
+ // Keep the default width if storage is unavailable.
24
+ }
25
+ }, []);
26
+
27
+ return width;
28
+ }
29
+
30
+ export function SidePanel({
31
+ children,
32
+ className,
33
+ title,
34
+ subtitle,
35
+ closeLabel = "Close panel",
36
+ onClose,
37
+ }: {
38
+ children: ReactNode;
39
+ className?: string;
40
+ title?: string;
41
+ subtitle?: string;
42
+ closeLabel?: string;
43
+ onClose?: () => void;
44
+ }) {
45
+ const width = useAgentSidebarWidth();
46
+
47
+ useEffect(() => {
48
+ if (!onClose) return;
49
+
50
+ function handleKeyDown(event: KeyboardEvent) {
51
+ if (event.key !== "Escape") return;
52
+ event.preventDefault();
53
+ onClose?.();
54
+ }
55
+
56
+ window.addEventListener("keydown", handleKeyDown);
57
+ return () => window.removeEventListener("keydown", handleKeyDown);
58
+ }, [onClose]);
59
+
60
+ return (
61
+ <aside
62
+ className={cn(
63
+ "fixed inset-y-0 right-0 z-[70] flex max-w-[85vw] flex-col overflow-hidden border-l border-border bg-background text-[13px] leading-[1.2] text-foreground antialiased shadow-2xl transition-transform duration-[260ms] ease-[cubic-bezier(0.32,0.72,0,1)] motion-reduce:transition-none md:shadow-none",
64
+ className,
65
+ )}
66
+ style={{ width }}
67
+ >
68
+ {title || onClose ? (
69
+ <div className="relative z-[240] flex h-12 shrink-0 items-center justify-between gap-2 border-b border-border px-2">
70
+ <div className="min-w-0 px-1">
71
+ {title ? (
72
+ <h2 className="truncate text-[13px] font-semibold leading-tight">
73
+ {title}
74
+ </h2>
75
+ ) : null}
76
+ {subtitle ? (
77
+ <p className="mt-0.5 truncate text-[11px] leading-tight text-muted-foreground">
78
+ {subtitle}
79
+ </p>
80
+ ) : null}
81
+ </div>
82
+ {onClose ? (
83
+ <Button
84
+ type="button"
85
+ variant="ghost"
86
+ size="icon"
87
+ onClick={onClose}
88
+ aria-label={closeLabel}
89
+ className="size-8"
90
+ >
91
+ <IconX className="size-4" />
92
+ </Button>
93
+ ) : null}
94
+ </div>
95
+ ) : null}
96
+ {children}
97
+ </aside>
98
+ );
99
+ }
@@ -0,0 +1,37 @@
1
+ import { type ReactNode } from "react";
2
+
3
+ /**
4
+ * Drag overlay wrapper. It renders the real row (passed as children) so the
5
+ * preview always matches the actual row — no per-list chrome duplication. It
6
+ * only adds the block-drag count badge and the overlay test hook.
7
+ */
8
+ interface ListRowPreviewProps {
9
+ id: string;
10
+ overlayDataAttribute: string;
11
+ blockDragCount?: number;
12
+ children: ReactNode;
13
+ }
14
+
15
+ export function ListRowPreview({
16
+ id,
17
+ overlayDataAttribute,
18
+ blockDragCount,
19
+ children,
20
+ }: ListRowPreviewProps) {
21
+ return (
22
+ <div
23
+ {...{ [overlayDataAttribute]: id }}
24
+ className="relative w-full rounded-lg shadow-lg"
25
+ >
26
+ {blockDragCount && blockDragCount > 1 ? (
27
+ <span
28
+ aria-hidden="true"
29
+ className="absolute -right-2 -top-2 z-10 flex size-6 items-center justify-center rounded-full bg-primary text-xs font-semibold text-primary-foreground shadow-md"
30
+ >
31
+ {blockDragCount}
32
+ </span>
33
+ ) : null}
34
+ {children}
35
+ </div>
36
+ );
37
+ }
@@ -0,0 +1,63 @@
1
+ import { useMemo, type ReactNode } from "react";
2
+
3
+ import { SortableList } from "@/components/dnd/SortableList";
4
+ import type {
5
+ SortableListRenderItemProps,
6
+ SortableListRenderOverlayProps,
7
+ } from "@/components/dnd/SortableList";
8
+ import type { ListIdentifiable } from "@/components/shared/list/types";
9
+ import type { ListSelection } from "@/components/shared/selection/use-list-selection";
10
+
11
+ /**
12
+ * Generic sortable list shell.
13
+ *
14
+ * Composers own scroll layout, loading, empty states, and row UI; `List` wires
15
+ * dnd-kit reordering, listbox ARIA when bulk selection is active, and block-drag
16
+ * for selected items.
17
+ */
18
+ export interface ListProps<T extends ListIdentifiable> {
19
+ items: T[];
20
+ ariaLabel: string;
21
+ onReorder: (nextItems: T[]) => void;
22
+ renderItem: (props: SortableListRenderItemProps<T>) => ReactNode;
23
+ renderOverlay?: (props: SortableListRenderOverlayProps<T>) => ReactNode;
24
+ selection?: ListSelection<T>;
25
+ selectionEnabled?: boolean;
26
+ listClassName?: string;
27
+ }
28
+
29
+ export function List<T extends ListIdentifiable>({
30
+ items,
31
+ ariaLabel,
32
+ onReorder,
33
+ renderItem,
34
+ renderOverlay,
35
+ selection,
36
+ selectionEnabled = true,
37
+ listClassName,
38
+ }: ListProps<T>) {
39
+ const selectionActive =
40
+ selectionEnabled && (selection?.state.selectionMode ?? false);
41
+ const movingIds = useMemo(() => {
42
+ if (!selectionEnabled || !selection) return new Set<string>();
43
+ return new Set(selection.state.selectedItems.map((item) => item.id));
44
+ }, [selection, selectionEnabled]);
45
+
46
+ return (
47
+ <div
48
+ role={selectionActive ? "listbox" : "region"}
49
+ aria-label={ariaLabel}
50
+ aria-multiselectable={selectionActive ? true : undefined}
51
+ tabIndex={selectionActive ? 0 : undefined}
52
+ >
53
+ <SortableList
54
+ items={items}
55
+ movingIds={movingIds}
56
+ onReorder={onReorder}
57
+ renderItem={renderItem}
58
+ renderOverlay={renderOverlay}
59
+ listClassName={listClassName}
60
+ />
61
+ </div>
62
+ );
63
+ }
@@ -0,0 +1,159 @@
1
+ import {
2
+ type AnimationEvent,
3
+ type HTMLAttributes,
4
+ type KeyboardEvent,
5
+ type MouseEvent,
6
+ type ReactNode,
7
+ } from "react";
8
+
9
+ import { getSortableDragProps } from "@/components/dnd/sortable-drag-props";
10
+ import type { SortableItemRenderProps } from "@/components/dnd/SortableItem";
11
+ import { SortableListItemShell } from "@/components/shared/list/SortableListItemShell";
12
+ import type { ListIdentifiable } from "@/components/shared/list/types";
13
+ import { getListRowSelectionUi } from "@/components/shared/selection/get-list-row-selection-ui";
14
+ import type { ListSelection } from "@/components/shared/selection/use-list-selection";
15
+ import { cn } from "@/lib/utils";
16
+
17
+ export type { ListIdentifiable } from "@/components/shared/list/types";
18
+
19
+ export type ListRowDrag = {
20
+ dragHandleProps?: HTMLAttributes<HTMLButtonElement>;
21
+ titleDragProps?: HTMLAttributes<HTMLButtonElement>;
22
+ isDragging: boolean;
23
+ };
24
+
25
+ export type ListRowRowSelection = {
26
+ selectionMode: boolean;
27
+ selected: boolean;
28
+ selectRow: (event: MouseEvent<Element>) => void;
29
+ };
30
+
31
+ export type ListRowRenderArgs = {
32
+ rowDrag: ListRowDrag;
33
+ rowSelection: ListRowRowSelection;
34
+ };
35
+
36
+ export type ListRowDataAttributes = Record<`data-${string}`, string>;
37
+
38
+ export interface ListRowProps<T extends ListIdentifiable> {
39
+ sortable: SortableItemRenderProps;
40
+ item: T;
41
+ itemLabel: string;
42
+ selection?: ListSelection<T>;
43
+ highlighted?: boolean;
44
+ onActivate?: () => void;
45
+ onAnimationEnd?: (event: AnimationEvent<HTMLDivElement>) => void;
46
+ dataAttributes?: ListRowDataAttributes;
47
+ className?: string;
48
+ children: (args: ListRowRenderArgs) => ReactNode;
49
+ }
50
+
51
+ function isInteractiveTarget(
52
+ target: EventTarget | null,
53
+ currentTarget: HTMLElement,
54
+ ) {
55
+ const interactive = (target as HTMLElement | null)?.closest(
56
+ 'button, input, textarea, select, a, [role="button"], [data-radix-collection-item]',
57
+ );
58
+ return Boolean(interactive && interactive !== currentTarget);
59
+ }
60
+
61
+ export function ListRow<T extends ListIdentifiable>({
62
+ sortable,
63
+ item,
64
+ itemLabel,
65
+ selection,
66
+ highlighted = false,
67
+ onActivate,
68
+ onAnimationEnd,
69
+ dataAttributes,
70
+ className,
71
+ children,
72
+ }: ListRowProps<T>) {
73
+ const selectionMode = selection?.state.selectionMode ?? false;
74
+ const selected =
75
+ selection?.state.selectedItems.some((entry) => entry.id === item.id) ??
76
+ false;
77
+ const activateEnabled = Boolean(onActivate) && !selectionMode;
78
+
79
+ function selectRow(event: MouseEvent<Element>) {
80
+ selection?.actions.selectRow(item.id, event);
81
+ }
82
+
83
+ const rowDragEnabled = !selectionMode;
84
+ const { dragHandleProps, rowDragProps, titleDragProps } =
85
+ getSortableDragProps(sortable.attributes, sortable.listeners);
86
+ const isDragging = sortable.isDragging;
87
+ const gatedRowDragProps = rowDragEnabled ? rowDragProps : undefined;
88
+ const renderArgs: ListRowRenderArgs = {
89
+ rowDrag: {
90
+ dragHandleProps,
91
+ titleDragProps: rowDragEnabled ? titleDragProps : undefined,
92
+ isDragging,
93
+ },
94
+ rowSelection: {
95
+ selectionMode,
96
+ selected,
97
+ selectRow,
98
+ },
99
+ };
100
+
101
+ const selectionUi = getListRowSelectionUi({
102
+ selectionMode,
103
+ selected,
104
+ itemLabel,
105
+ onRowSelect: selection ? selectRow : undefined,
106
+ });
107
+
108
+ function handleRowClick(event: MouseEvent<HTMLDivElement>) {
109
+ selectionUi.onClick?.(event);
110
+ if (event.defaultPrevented) return;
111
+ if (
112
+ activateEnabled &&
113
+ !isInteractiveTarget(event.target, event.currentTarget)
114
+ ) {
115
+ onActivate?.();
116
+ }
117
+ }
118
+
119
+ function handleRowKeyDown(event: KeyboardEvent<HTMLDivElement>) {
120
+ if (!activateEnabled || event.defaultPrevented) return;
121
+ if (event.key !== "Enter" && event.key !== " ") return;
122
+ event.preventDefault();
123
+ onActivate?.();
124
+ }
125
+
126
+ return (
127
+ <SortableListItemShell
128
+ setNodeRef={sortable.setNodeRef}
129
+ style={sortable.style}
130
+ isDragging={sortable.isDragging}
131
+ hideForBlockDrag={sortable.hideForBlockDrag}
132
+ >
133
+ <div
134
+ {...dataAttributes}
135
+ {...gatedRowDragProps}
136
+ role={activateEnabled ? "button" : selectionUi.role}
137
+ tabIndex={activateEnabled ? 0 : undefined}
138
+ aria-selected={selectionUi["aria-selected"]}
139
+ aria-label={selectionUi["aria-label"]}
140
+ onClick={handleRowClick}
141
+ onKeyDown={handleRowKeyDown}
142
+ onAnimationEnd={onAnimationEnd}
143
+ className={cn(
144
+ "group flex items-center gap-3 rounded-lg border border-border bg-card px-3 py-2",
145
+ gatedRowDragProps && "cursor-pointer",
146
+ selectionUi.className,
147
+ highlighted &&
148
+ !selectionMode &&
149
+ "border-ring shadow-[inset_0_0_0_2px_hsl(var(--ring))]",
150
+ isDragging && "shadow-md ring-1 ring-border",
151
+ className,
152
+ )}
153
+ data-list-row-id={item.id}
154
+ >
155
+ {children(renderArgs)}
156
+ </div>
157
+ </SortableListItemShell>
158
+ );
159
+ }