@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.
- package/corpus/README.md +1 -1
- package/corpus/core/CHANGELOG.md +12 -0
- package/corpus/core/package.json +1 -1
- package/corpus/core/src/cli/templates-meta.ts +13 -0
- package/corpus/core/src/client/agent-page/AgentTabsPage.tsx +1 -1
- package/corpus/core/src/client/org/OrgSwitcher.tsx +2 -0
- package/corpus/templates/analytics/changelog/2026-07-15-fixed-the-agent-discarding-a-successful-dashboard-edit-and-r.md +6 -0
- package/corpus/templates/analytics/server/lib/real-data-actions.ts +30 -1
- package/corpus/templates/analytics/server/plugins/agent-chat.ts +15 -0
- package/corpus/templates/content/actions/_database-source-utils.ts +59 -4
- package/corpus/templates/content/actions/prepare-builder-source-review.ts +9 -0
- package/corpus/templates/content/actions/preview-builder-source-review.ts +6 -4
- package/corpus/templates/content/app/components/editor/DescriptionField.tsx +10 -2
- package/corpus/templates/content/app/components/editor/database/DatabaseView.tsx +4 -0
- package/corpus/templates/content/changelog/2026-07-15-page-and-database-descriptions-now-use-a-clean-single-line-f.md +6 -0
- package/corpus/templates/content/changelog/2026-07-15-selected-builder-reviews-now-load-only-the-chosen-rows-avoid.md +6 -0
- package/corpus/templates/content/shared/api.ts +1 -0
- package/corpus/templates/tasks/.agents/commands/visual-plan.md +9 -0
- package/corpus/templates/tasks/.agents/commands/visual-recap.md +8 -0
- package/corpus/templates/tasks/.agents/skills/actions/SKILL.md +492 -0
- package/corpus/templates/tasks/.agents/skills/adding-a-feature/SKILL.md +189 -0
- package/corpus/templates/tasks/.agents/skills/agent-native-docs/SKILL.md +76 -0
- package/corpus/templates/tasks/.agents/skills/agent-watchdog/README.md +43 -0
- package/corpus/templates/tasks/.agents/skills/agent-watchdog/SKILL.md +110 -0
- package/corpus/templates/tasks/.agents/skills/agent-watchdog/agents/openai.yaml +4 -0
- package/corpus/templates/tasks/.agents/skills/capture-learnings/SKILL.md +89 -0
- package/corpus/templates/tasks/.agents/skills/change-summary/SKILL.md +83 -0
- package/corpus/templates/tasks/.agents/skills/create-skill/SKILL.md +221 -0
- package/corpus/templates/tasks/.agents/skills/delegate-to-agent/SKILL.md +263 -0
- package/corpus/templates/tasks/.agents/skills/efficient-fable/README.md +75 -0
- package/corpus/templates/tasks/.agents/skills/efficient-fable/SKILL.md +95 -0
- package/corpus/templates/tasks/.agents/skills/efficient-frontier/README.md +53 -0
- package/corpus/templates/tasks/.agents/skills/efficient-frontier/SKILL.md +73 -0
- package/corpus/templates/tasks/.agents/skills/frontend-design/SKILL.md +112 -0
- package/corpus/templates/tasks/.agents/skills/plan-arbiter/README.md +41 -0
- package/corpus/templates/tasks/.agents/skills/plan-arbiter/SKILL.md +114 -0
- package/corpus/templates/tasks/.agents/skills/plan-arbiter/agents/openai.yaml +4 -0
- package/corpus/templates/tasks/.agents/skills/plow-ahead/README.md +42 -0
- package/corpus/templates/tasks/.agents/skills/plow-ahead/SKILL.md +104 -0
- package/corpus/templates/tasks/.agents/skills/plow-ahead/agents/openai.yaml +4 -0
- package/corpus/templates/tasks/.agents/skills/quick-recap/README.md +55 -0
- package/corpus/templates/tasks/.agents/skills/quick-recap/SKILL.md +54 -0
- package/corpus/templates/tasks/.agents/skills/read-the-damn-docs/README.md +54 -0
- package/corpus/templates/tasks/.agents/skills/read-the-damn-docs/SKILL.md +126 -0
- package/corpus/templates/tasks/.agents/skills/read-the-damn-docs/agents/openai.yaml +4 -0
- package/corpus/templates/tasks/.agents/skills/real-time-sync/SKILL.md +232 -0
- package/corpus/templates/tasks/.agents/skills/security/SKILL.md +280 -0
- package/corpus/templates/tasks/.agents/skills/self-modifying-code/SKILL.md +106 -0
- package/corpus/templates/tasks/.agents/skills/shadcn-ui/SKILL.md +95 -0
- package/corpus/templates/tasks/.agents/skills/stay-within-limits/README.md +61 -0
- package/corpus/templates/tasks/.agents/skills/stay-within-limits/SKILL.md +83 -0
- package/corpus/templates/tasks/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/corpus/templates/tasks/.agents/skills/visual-plan/SKILL.md +547 -0
- package/corpus/templates/tasks/.agents/skills/visual-plan/agent-native-skill.json +12 -0
- package/corpus/templates/tasks/.agents/skills/visual-plan/references/canvas.md +121 -0
- package/corpus/templates/tasks/.agents/skills/visual-plan/references/document-quality.md +178 -0
- package/corpus/templates/tasks/.agents/skills/visual-plan/references/exemplar.md +62 -0
- package/corpus/templates/tasks/.agents/skills/visual-plan/references/wireframe.md +264 -0
- package/corpus/templates/tasks/.agents/skills/visual-recap/SKILL.md +634 -0
- package/corpus/templates/tasks/.agents/skills/visual-recap/agent-native-skill.json +12 -0
- package/corpus/templates/tasks/.agents/skills/visual-recap/references/wireframe.md +264 -0
- package/corpus/templates/tasks/.claude/commands/visual-plan.md +9 -0
- package/corpus/templates/tasks/.claude/commands/visual-recap.md +8 -0
- package/corpus/templates/tasks/.env.example +5 -0
- package/corpus/templates/tasks/.ignore +0 -0
- package/corpus/templates/tasks/.prettierrc +5 -0
- package/corpus/templates/tasks/AGENTS.md +158 -0
- package/corpus/templates/tasks/DEVELOPING.md +185 -0
- package/corpus/templates/tasks/README.md +16 -0
- package/corpus/templates/tasks/actions/bulk-delete-inbox-items.ts +24 -0
- package/corpus/templates/tasks/actions/bulk-delete-tasks.ts +21 -0
- package/corpus/templates/tasks/actions/bulk-mark-inbox-items-ready.ts +27 -0
- package/corpus/templates/tasks/actions/bulk-update-tasks.ts +35 -0
- package/corpus/templates/tasks/actions/create-custom-field.ts +22 -0
- package/corpus/templates/tasks/actions/create-inbox-item.ts +30 -0
- package/corpus/templates/tasks/actions/create-task.ts +33 -0
- package/corpus/templates/tasks/actions/delete-custom-field.ts +19 -0
- package/corpus/templates/tasks/actions/delete-inbox-item.ts +17 -0
- package/corpus/templates/tasks/actions/delete-task.ts +17 -0
- package/corpus/templates/tasks/actions/lib/boolean-query-param.ts +30 -0
- package/corpus/templates/tasks/actions/list-custom-fields.ts +18 -0
- package/corpus/templates/tasks/actions/list-inbox-items.ts +16 -0
- package/corpus/templates/tasks/actions/list-tasks.ts +52 -0
- package/corpus/templates/tasks/actions/list-visible-task-fields.ts +18 -0
- package/corpus/templates/tasks/actions/mark-inbox-item-ready.ts +31 -0
- package/corpus/templates/tasks/actions/navigate.ts +51 -0
- package/corpus/templates/tasks/actions/reorder-custom-fields.ts +27 -0
- package/corpus/templates/tasks/actions/reorder-inbox-items.ts +24 -0
- package/corpus/templates/tasks/actions/reorder-tasks.ts +29 -0
- package/corpus/templates/tasks/actions/run.ts +2 -0
- package/corpus/templates/tasks/actions/update-custom-field.ts +33 -0
- package/corpus/templates/tasks/actions/update-inbox-item.ts +24 -0
- package/corpus/templates/tasks/actions/update-task.ts +68 -0
- package/corpus/templates/tasks/actions/update-visible-task-fields.ts +27 -0
- package/corpus/templates/tasks/actions/view-screen-helpers.ts +68 -0
- package/corpus/templates/tasks/actions/view-screen.ts +207 -0
- package/corpus/templates/tasks/app/components/custom-fields/FieldCreateBar.tsx +121 -0
- package/corpus/templates/tasks/app/components/custom-fields/FieldListRow.tsx +116 -0
- package/corpus/templates/tasks/app/components/custom-fields/FieldsList.tsx +225 -0
- package/corpus/templates/tasks/app/components/custom-fields/FieldsListSkeleton.tsx +18 -0
- package/corpus/templates/tasks/app/components/custom-fields/FieldsPage.tsx +42 -0
- package/corpus/templates/tasks/app/components/custom-fields/editor/FieldEditorSidebar.tsx +69 -0
- package/corpus/templates/tasks/app/components/custom-fields/editor/FieldTitleSection.tsx +32 -0
- package/corpus/templates/tasks/app/components/custom-fields/editor/config/CurrencyConfigControl.tsx +49 -0
- package/corpus/templates/tasks/app/components/custom-fields/editor/config/FieldConfigControl.tsx +56 -0
- package/corpus/templates/tasks/app/components/custom-fields/editor/config/NumberConfigControl.tsx +52 -0
- package/corpus/templates/tasks/app/components/custom-fields/editor/config/PercentConfigControl.tsx +30 -0
- package/corpus/templates/tasks/app/components/custom-fields/editor/config/SelectConfigControl.tsx +135 -0
- package/corpus/templates/tasks/app/components/custom-fields/editor/config/select-colors.ts +23 -0
- package/corpus/templates/tasks/app/components/custom-fields/editor/config/utils.ts +52 -0
- package/corpus/templates/tasks/app/components/custom-fields/editor/types.ts +7 -0
- package/corpus/templates/tasks/app/components/dnd/SortableItem.tsx +72 -0
- package/corpus/templates/tasks/app/components/dnd/SortableList.tsx +136 -0
- package/corpus/templates/tasks/app/components/dnd/reorder-moving-items.ts +160 -0
- package/corpus/templates/tasks/app/components/dnd/sortable-drag-props.ts +60 -0
- package/corpus/templates/tasks/app/components/inbox/InboxList.tsx +222 -0
- package/corpus/templates/tasks/app/components/inbox/InboxListPage.tsx +39 -0
- package/corpus/templates/tasks/app/components/inbox/InboxListRow.tsx +122 -0
- package/corpus/templates/tasks/app/components/layout/Header.tsx +55 -0
- package/corpus/templates/tasks/app/components/layout/HeaderActions.tsx +84 -0
- package/corpus/templates/tasks/app/components/layout/Layout.tsx +134 -0
- package/corpus/templates/tasks/app/components/layout/Sidebar.tsx +211 -0
- package/corpus/templates/tasks/app/components/shared/AddListItemInput.tsx +57 -0
- package/corpus/templates/tasks/app/components/shared/AlertDialog.tsx +53 -0
- package/corpus/templates/tasks/app/components/shared/BulkDeleteDialog.tsx +76 -0
- package/corpus/templates/tasks/app/components/shared/ChipSelect.tsx +240 -0
- package/corpus/templates/tasks/app/components/shared/DeleteItemDialog.tsx +40 -0
- package/corpus/templates/tasks/app/components/shared/InlineEditable.tsx +166 -0
- package/corpus/templates/tasks/app/components/shared/ListEmptyState.tsx +13 -0
- package/corpus/templates/tasks/app/components/shared/ListErrorMessage.tsx +15 -0
- package/corpus/templates/tasks/app/components/shared/ListViewHeader.tsx +75 -0
- package/corpus/templates/tasks/app/components/shared/PageHeader.tsx +25 -0
- package/corpus/templates/tasks/app/components/shared/RowActionsMenu.tsx +42 -0
- package/corpus/templates/tasks/app/components/shared/SidePanel.tsx +99 -0
- package/corpus/templates/tasks/app/components/shared/dnd/ListRowPreview.tsx +37 -0
- package/corpus/templates/tasks/app/components/shared/list/List.tsx +63 -0
- package/corpus/templates/tasks/app/components/shared/list/ListRow.tsx +159 -0
- package/corpus/templates/tasks/app/components/shared/list/ListRowDragHandle.tsx +52 -0
- package/corpus/templates/tasks/app/components/shared/list/ListSkeletonRows.tsx +11 -0
- package/corpus/templates/tasks/app/components/shared/list/SortableListItemShell.tsx +32 -0
- package/corpus/templates/tasks/app/components/shared/list/types.ts +1 -0
- package/corpus/templates/tasks/app/components/shared/selection/ListSelectionBar.tsx +158 -0
- package/corpus/templates/tasks/app/components/shared/selection/ListSelectionHeaderToggle.tsx +28 -0
- package/corpus/templates/tasks/app/components/shared/selection/ListSelectionToolbar.tsx +81 -0
- package/corpus/templates/tasks/app/components/shared/selection/get-list-row-selection-ui.ts +41 -0
- package/corpus/templates/tasks/app/components/shared/selection/use-list-selection.ts +196 -0
- package/corpus/templates/tasks/app/components/tasks/TaskList.tsx +333 -0
- package/corpus/templates/tasks/app/components/tasks/TaskListHeaderRow.tsx +46 -0
- package/corpus/templates/tasks/app/components/tasks/TaskListPage.tsx +115 -0
- package/corpus/templates/tasks/app/components/tasks/TaskListRow.css +49 -0
- package/corpus/templates/tasks/app/components/tasks/TaskListRow.tsx +307 -0
- package/corpus/templates/tasks/app/components/tasks/fields/TaskFieldsSidebar.tsx +102 -0
- package/corpus/templates/tasks/app/components/tasks/fields/TaskTitleSection.tsx +27 -0
- package/corpus/templates/tasks/app/components/tasks/fields/controls/DateValueControl.tsx +21 -0
- package/corpus/templates/tasks/app/components/tasks/fields/controls/FieldValueControl.tsx +76 -0
- package/corpus/templates/tasks/app/components/tasks/fields/controls/MultiSelectValueControl.tsx +52 -0
- package/corpus/templates/tasks/app/components/tasks/fields/controls/NumberValueControl.tsx +56 -0
- package/corpus/templates/tasks/app/components/tasks/fields/controls/RichTextValueControl.tsx +115 -0
- package/corpus/templates/tasks/app/components/tasks/fields/controls/SingleSelectValueControl.tsx +61 -0
- package/corpus/templates/tasks/app/components/tasks/fields/controls/TextValueControl.tsx +20 -0
- package/corpus/templates/tasks/app/components/tasks/use-task-row-completion-animation.ts +181 -0
- package/corpus/templates/tasks/app/components/ui/accordion.tsx +56 -0
- package/corpus/templates/tasks/app/components/ui/alert-dialog.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/alert.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/aspect-ratio.tsx +5 -0
- package/corpus/templates/tasks/app/components/ui/avatar.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/badge.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/breadcrumb.tsx +115 -0
- package/corpus/templates/tasks/app/components/ui/button.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/calendar.tsx +70 -0
- package/corpus/templates/tasks/app/components/ui/card.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/carousel.tsx +260 -0
- package/corpus/templates/tasks/app/components/ui/chart.tsx +379 -0
- package/corpus/templates/tasks/app/components/ui/checkbox.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/collapsible.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/command.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/context-menu.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/dialog.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/drawer.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/dropdown-menu.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/form.tsx +177 -0
- package/corpus/templates/tasks/app/components/ui/hover-card.tsx +27 -0
- package/corpus/templates/tasks/app/components/ui/input-otp.tsx +69 -0
- package/corpus/templates/tasks/app/components/ui/input.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/label.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/menubar.tsx +254 -0
- package/corpus/templates/tasks/app/components/ui/navigation-menu.tsx +128 -0
- package/corpus/templates/tasks/app/components/ui/pagination.tsx +121 -0
- package/corpus/templates/tasks/app/components/ui/popover.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/progress.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/radio-group.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/resizable.tsx +43 -0
- package/corpus/templates/tasks/app/components/ui/scroll-area.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/select.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/separator.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/sheet.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/sidebar.tsx +782 -0
- package/corpus/templates/tasks/app/components/ui/skeleton.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/slider.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/sonner.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/spinner.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/switch.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/table.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/tabs.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/textarea.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/toast.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/toaster.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/toggle-group.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/toggle.tsx +43 -0
- package/corpus/templates/tasks/app/components/ui/tooltip.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/use-toast.ts +3 -0
- package/corpus/templates/tasks/app/entry.client.tsx +19 -0
- package/corpus/templates/tasks/app/entry.server.tsx +10 -0
- package/corpus/templates/tasks/app/global.css +93 -0
- package/corpus/templates/tasks/app/hooks/cache.ts +31 -0
- package/corpus/templates/tasks/app/hooks/use-custom-fields.ts +93 -0
- package/corpus/templates/tasks/app/hooks/use-inbox-items.ts +196 -0
- package/corpus/templates/tasks/app/hooks/use-mobile.tsx +21 -0
- package/corpus/templates/tasks/app/hooks/use-navigation-state.ts +40 -0
- package/corpus/templates/tasks/app/hooks/use-tasks.ts +276 -0
- package/corpus/templates/tasks/app/hooks/use-toast.ts +188 -0
- package/corpus/templates/tasks/app/hooks/use-visible-task-fields.ts +140 -0
- package/corpus/templates/tasks/app/lib/app-config.ts +11 -0
- package/corpus/templates/tasks/app/lib/tab-id.ts +1 -0
- package/corpus/templates/tasks/app/lib/utils.ts +1 -0
- package/corpus/templates/tasks/app/root.tsx +130 -0
- package/corpus/templates/tasks/app/routes/_index.tsx +22 -0
- package/corpus/templates/tasks/app/routes/extensions.$id.$slug.tsx +2 -0
- package/corpus/templates/tasks/app/routes/extensions.$id.tsx +11 -0
- package/corpus/templates/tasks/app/routes/extensions._index.tsx +11 -0
- package/corpus/templates/tasks/app/routes/extensions.tsx +5 -0
- package/corpus/templates/tasks/app/routes/fields.tsx +16 -0
- package/corpus/templates/tasks/app/routes/inbox.tsx +16 -0
- package/corpus/templates/tasks/app/routes/tasks.tsx +17 -0
- package/corpus/templates/tasks/app/routes/team.tsx +17 -0
- package/corpus/templates/tasks/app/routes.ts +4 -0
- package/corpus/templates/tasks/app/vite-env.d.ts +6 -0
- package/corpus/templates/tasks/components.json +20 -0
- package/corpus/templates/tasks/data/sync-config.json +1 -0
- package/corpus/templates/tasks/docs/features/README.md +81 -0
- package/corpus/templates/tasks/docs/features/f1-tasks.mdx +67 -0
- package/corpus/templates/tasks/docs/features/f2-custom-fields.mdx +68 -0
- package/corpus/templates/tasks/docs/features/f3-projects.mdx +33 -0
- package/corpus/templates/tasks/docs/features/f4-inbox.mdx +55 -0
- package/corpus/templates/tasks/docs/features/f5-views.mdx +65 -0
- package/corpus/templates/tasks/docs/features/f6-search.mdx +43 -0
- package/corpus/templates/tasks/docs/features/f7-first-run.mdx +66 -0
- package/corpus/templates/tasks/docs/features/f8-chat.mdx +120 -0
- package/corpus/templates/tasks/e2e/global-setup.ts +42 -0
- package/corpus/templates/tasks/e2e/helpers/inbox.ts +71 -0
- package/corpus/templates/tasks/e2e/helpers/tasks.ts +99 -0
- package/corpus/templates/tasks/learnings.defaults.md +5 -0
- package/corpus/templates/tasks/netlify.toml +10 -0
- package/corpus/templates/tasks/package.json +104 -0
- package/corpus/templates/tasks/playwright.config.ts +34 -0
- package/corpus/templates/tasks/public/agent-native-icon-dark.svg +10 -0
- package/corpus/templates/tasks/public/agent-native-icon-light.svg +10 -0
- package/corpus/templates/tasks/public/agent-native-logo-dark.svg +21 -0
- package/corpus/templates/tasks/public/agent-native-logo-light.svg +21 -0
- package/corpus/templates/tasks/public/favicon.svg +1 -0
- package/corpus/templates/tasks/public/icon-180.svg +1 -0
- package/corpus/templates/tasks/public/icon-192.svg +1 -0
- package/corpus/templates/tasks/public/icon-512.svg +1 -0
- package/corpus/templates/tasks/public/manifest.json +21 -0
- package/corpus/templates/tasks/react-router.config.ts +7 -0
- package/corpus/templates/tasks/server/custom-fields/normalize.ts +163 -0
- package/corpus/templates/tasks/server/custom-fields/parse.ts +146 -0
- package/corpus/templates/tasks/server/custom-fields/schema.ts +147 -0
- package/corpus/templates/tasks/server/custom-fields/store.ts +425 -0
- package/corpus/templates/tasks/server/custom-fields/task-fields.ts +104 -0
- package/corpus/templates/tasks/server/custom-fields/types.ts +98 -0
- package/corpus/templates/tasks/server/custom-fields/validate.ts +210 -0
- package/corpus/templates/tasks/server/custom-fields/values/store.ts +386 -0
- package/corpus/templates/tasks/server/db/bulk-write.ts +30 -0
- package/corpus/templates/tasks/server/db/index.ts +5 -0
- package/corpus/templates/tasks/server/db/record-utils.ts +7 -0
- package/corpus/templates/tasks/server/db/schema.ts +67 -0
- package/corpus/templates/tasks/server/db/test-tasks-table.ts +76 -0
- package/corpus/templates/tasks/server/db/transaction.ts +6 -0
- package/corpus/templates/tasks/server/errors.ts +31 -0
- package/corpus/templates/tasks/server/inbox/store.ts +216 -0
- package/corpus/templates/tasks/server/middleware/auth.ts +15 -0
- package/corpus/templates/tasks/server/plugins/agent-chat.ts +46 -0
- package/corpus/templates/tasks/server/plugins/auth.ts +15 -0
- package/corpus/templates/tasks/server/plugins/db.ts +90 -0
- package/corpus/templates/tasks/server/routes/[...page].get.ts +5 -0
- package/corpus/templates/tasks/server/stored-items/store.ts +548 -0
- package/corpus/templates/tasks/server/tasks/store.ts +306 -0
- package/corpus/templates/tasks/server/user-config/store.ts +138 -0
- package/corpus/templates/tasks/shared/app-state-tabs.ts +15 -0
- package/corpus/templates/tasks/shared/boolean-param.ts +22 -0
- package/corpus/templates/tasks/shared/bulk-limits.ts +7 -0
- package/corpus/templates/tasks/shared/list-screen-snapshot.ts +90 -0
- package/corpus/templates/tasks/shared/navigation.ts +104 -0
- package/corpus/templates/tasks/shared/visible-task-fields.ts +2 -0
- package/corpus/templates/tasks/ssr-entry.ts +15 -0
- package/corpus/templates/tasks/tsconfig.json +24 -0
- package/corpus/templates/tasks/vite.config.ts +19 -0
- package/corpus/templates/tasks/vitest.config.ts +8 -0
- package/dist/cli/templates-meta.d.ts.map +1 -1
- package/dist/cli/templates-meta.js +13 -0
- package/dist/cli/templates-meta.js.map +1 -1
- package/dist/client/agent-page/AgentTabsPage.js +1 -1
- package/dist/client/agent-page/AgentTabsPage.js.map +1 -1
- package/dist/client/org/OrgSwitcher.d.ts.map +1 -1
- package/dist/client/org/OrgSwitcher.js +2 -1
- package/dist/client/org/OrgSwitcher.js.map +1 -1
- package/dist/collab/routes.d.ts +1 -1
- package/dist/collab/struct-routes.d.ts +1 -1
- package/dist/notifications/routes.d.ts +2 -2
- package/dist/observability/routes.d.ts +5 -5
- package/dist/resources/handlers.d.ts +3 -3
- package/dist/secrets/routes.d.ts +9 -9
- package/dist/server/agent-engine-api-key-route.d.ts +1 -1
- package/dist/server/transcribe-voice.d.ts +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { defineAction } from "@agent-native/core/action";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
fieldValueInputSchema,
|
|
6
|
+
parseJsonArg,
|
|
7
|
+
} from "../server/custom-fields/schema.js";
|
|
8
|
+
import { listTaskFieldValues } from "../server/custom-fields/task-fields.js";
|
|
9
|
+
import type { FieldValueInput } from "../server/custom-fields/values/store.js";
|
|
10
|
+
import { UserInputError } from "../server/errors.js";
|
|
11
|
+
import { updateTask, requireUserEmail } from "../server/tasks/store.js";
|
|
12
|
+
|
|
13
|
+
type FieldValuePatch = {
|
|
14
|
+
fieldId: string;
|
|
15
|
+
value: FieldValueInput;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const fieldValuePatchSchema: z.ZodType<FieldValuePatch> = z.object({
|
|
19
|
+
fieldId: z.string().describe("Custom field id"),
|
|
20
|
+
value: fieldValueInputSchema.describe("Custom field value; null clears it"),
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const fieldValuesSchema: z.ZodType<FieldValuePatch[]> = z.preprocess(
|
|
24
|
+
parseJsonArg,
|
|
25
|
+
z.array(fieldValuePatchSchema),
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
export default defineAction({
|
|
29
|
+
description: "Update a task title, completion state, and/or custom fields.",
|
|
30
|
+
schema: z.object({
|
|
31
|
+
taskId: z.string().describe("Task id"),
|
|
32
|
+
title: z.string().min(1).optional().describe("New task title"),
|
|
33
|
+
done: z.boolean().optional().describe("Completion state"),
|
|
34
|
+
fieldValues: fieldValuesSchema
|
|
35
|
+
.optional()
|
|
36
|
+
.describe("Custom field values to set or clear for this task"),
|
|
37
|
+
}),
|
|
38
|
+
run: async (args, ctx) => {
|
|
39
|
+
const ownerEmail = requireUserEmail(ctx?.userEmail);
|
|
40
|
+
if (
|
|
41
|
+
args.title === undefined &&
|
|
42
|
+
args.done === undefined &&
|
|
43
|
+
args.fieldValues === undefined
|
|
44
|
+
) {
|
|
45
|
+
throw new UserInputError(
|
|
46
|
+
"Provide at least one of title, done, or fieldValues.",
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const task = await updateTask({
|
|
51
|
+
ownerEmail,
|
|
52
|
+
id: args.taskId,
|
|
53
|
+
title: args.title,
|
|
54
|
+
done: args.done,
|
|
55
|
+
fieldValues: args.fieldValues,
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
if (args.fieldValues !== undefined) {
|
|
59
|
+
const fields = await listTaskFieldValues({
|
|
60
|
+
ownerEmail,
|
|
61
|
+
taskId: args.taskId,
|
|
62
|
+
});
|
|
63
|
+
return { ...task, fields };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return task;
|
|
67
|
+
},
|
|
68
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { defineAction } from "@agent-native/core/action";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
|
|
4
|
+
import { requireUserEmail } from "../server/custom-fields/store.js";
|
|
5
|
+
import { setTaskCardFieldIds } from "../server/user-config/store.js";
|
|
6
|
+
import { TASK_CARD_FIELD_LIMIT } from "../shared/visible-task-fields.js";
|
|
7
|
+
|
|
8
|
+
export default defineAction({
|
|
9
|
+
description:
|
|
10
|
+
"Replace the custom fields shown on task cards for the current user.",
|
|
11
|
+
schema: z.object({
|
|
12
|
+
fieldIds: z
|
|
13
|
+
.array(z.string())
|
|
14
|
+
.max(TASK_CARD_FIELD_LIMIT)
|
|
15
|
+
.describe(
|
|
16
|
+
`Field ids to show on task cards, top-to-bottom. Max ${TASK_CARD_FIELD_LIMIT}.`,
|
|
17
|
+
),
|
|
18
|
+
}),
|
|
19
|
+
run: async (args, ctx) => {
|
|
20
|
+
const ownerEmail = requireUserEmail(ctx?.userEmail);
|
|
21
|
+
const fieldIds = await setTaskCardFieldIds({
|
|
22
|
+
ownerEmail,
|
|
23
|
+
fieldIds: args.fieldIds,
|
|
24
|
+
});
|
|
25
|
+
return { fieldIds };
|
|
26
|
+
},
|
|
27
|
+
});
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import {
|
|
2
|
+
buildAgentListSnapshot,
|
|
3
|
+
buildSelectionSnapshot,
|
|
4
|
+
resolveSelectedFromList,
|
|
5
|
+
} from "../shared/list-screen-snapshot.js";
|
|
6
|
+
|
|
7
|
+
export async function buildListViewScreen<
|
|
8
|
+
TItem extends { id: string },
|
|
9
|
+
TSummary,
|
|
10
|
+
>(input: {
|
|
11
|
+
ownerEmail: string;
|
|
12
|
+
cap: number;
|
|
13
|
+
fetchItems: (ownerEmail: string) => Promise<TItem[]>;
|
|
14
|
+
toSummary: (item: TItem) => TSummary;
|
|
15
|
+
getById: (id: string) => Promise<TItem | null>;
|
|
16
|
+
selection?: {
|
|
17
|
+
/** Deep-link highlight from navigation (single row). */
|
|
18
|
+
highlightId?: string;
|
|
19
|
+
/** Bulk-select mode ids from app state. */
|
|
20
|
+
bulkIds?: string[];
|
|
21
|
+
};
|
|
22
|
+
resolveSelectedMiss?: (id: string) => Promise<Record<string, unknown> | null>;
|
|
23
|
+
}): Promise<Record<string, unknown>> {
|
|
24
|
+
const screen: Record<string, unknown> = {};
|
|
25
|
+
const items = await input.fetchItems(input.ownerEmail);
|
|
26
|
+
const { snapshot, list } = buildAgentListSnapshot(
|
|
27
|
+
items,
|
|
28
|
+
input.cap,
|
|
29
|
+
input.toSummary,
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
screen.list = {
|
|
33
|
+
totalCount: list.totalCount,
|
|
34
|
+
truncated: list.truncated,
|
|
35
|
+
items: list.items,
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const highlightId = input.selection?.highlightId;
|
|
39
|
+
if (highlightId) {
|
|
40
|
+
const selectedItem = await resolveSelectedFromList({
|
|
41
|
+
selectedId: highlightId,
|
|
42
|
+
items,
|
|
43
|
+
snapshot,
|
|
44
|
+
toSummary: input.toSummary,
|
|
45
|
+
getById: (id) => input.getById(id),
|
|
46
|
+
inSnapshotKey: "inListSnapshot",
|
|
47
|
+
});
|
|
48
|
+
if (selectedItem) {
|
|
49
|
+
screen.selectedItem = selectedItem;
|
|
50
|
+
} else if (input.resolveSelectedMiss) {
|
|
51
|
+
const fallback = await input.resolveSelectedMiss(highlightId);
|
|
52
|
+
if (fallback) {
|
|
53
|
+
screen.selectedItem = fallback;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const bulkIds = input.selection?.bulkIds;
|
|
59
|
+
if (bulkIds && bulkIds.length > 0) {
|
|
60
|
+
screen.selection = buildSelectionSnapshot({
|
|
61
|
+
selectedIds: bulkIds,
|
|
62
|
+
items,
|
|
63
|
+
toSummary: input.toSummary,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return screen;
|
|
68
|
+
}
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* See what the user is currently looking at on screen.
|
|
3
|
+
*
|
|
4
|
+
* Usage:
|
|
5
|
+
* pnpm action view-screen
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { defineAction } from "@agent-native/core/action";
|
|
9
|
+
import { readAppStateForCurrentTab } from "@agent-native/core/application-state";
|
|
10
|
+
import { z } from "zod";
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
getCustomField,
|
|
14
|
+
listCustomFields,
|
|
15
|
+
type FieldConfig,
|
|
16
|
+
type FieldDefinition,
|
|
17
|
+
} from "../server/custom-fields/store.js";
|
|
18
|
+
import {
|
|
19
|
+
listTaskFieldValues,
|
|
20
|
+
type TaskFieldValue,
|
|
21
|
+
} from "../server/custom-fields/task-fields.js";
|
|
22
|
+
import { getInboxItem, listInboxItems } from "../server/inbox/store.js";
|
|
23
|
+
import { getTask, listTasks, requireUserEmail } from "../server/tasks/store.js";
|
|
24
|
+
import { getTaskCardFieldIds } from "../server/user-config/store.js";
|
|
25
|
+
import { buildListViewScreen } from "./view-screen-helpers.js";
|
|
26
|
+
|
|
27
|
+
/** Max tasks in the agent tool payload (token budget). The UI may show more rows; */
|
|
28
|
+
const AGENT_TASKS_LIST_CAP = 25;
|
|
29
|
+
const AGENT_INBOX_ITEMS_LIST_CAP = 25;
|
|
30
|
+
const AGENT_FIELDS_LIST_CAP = 25;
|
|
31
|
+
|
|
32
|
+
type TaskSummary = { id: string; title: string; done: boolean };
|
|
33
|
+
type InboxItemSummary = { id: string; title: string };
|
|
34
|
+
type FieldSummary = {
|
|
35
|
+
id: string;
|
|
36
|
+
title: string;
|
|
37
|
+
type: string;
|
|
38
|
+
config: FieldConfig;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const navigationStateSchema = z.object({
|
|
42
|
+
view: z.string(),
|
|
43
|
+
path: z.string().optional(),
|
|
44
|
+
includeDone: z.boolean().optional(),
|
|
45
|
+
taskId: z.string().optional(),
|
|
46
|
+
inboxItemId: z.string().optional(),
|
|
47
|
+
fieldId: z.string().optional(),
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
const listSelectionStateSchema = z.object({
|
|
51
|
+
selectionMode: z.boolean(),
|
|
52
|
+
selectedIds: z.array(z.string()),
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
function toTaskSummary(task: TaskSummary): TaskSummary {
|
|
56
|
+
return { id: task.id, title: task.title, done: task.done };
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function toInboxItemSummary(item: InboxItemSummary): InboxItemSummary {
|
|
60
|
+
return { id: item.id, title: item.title };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function toFieldSummary(field: FieldDefinition): FieldSummary {
|
|
64
|
+
return {
|
|
65
|
+
id: field.id,
|
|
66
|
+
title: field.title,
|
|
67
|
+
type: field.type,
|
|
68
|
+
config: field.config,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function toTaskFieldValueSummary(field: TaskFieldValue) {
|
|
73
|
+
return {
|
|
74
|
+
id: field.id,
|
|
75
|
+
title: field.title,
|
|
76
|
+
type: field.type,
|
|
77
|
+
value: field.value,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
async function readParsedAppState<T>(
|
|
82
|
+
key: string,
|
|
83
|
+
schema: z.ZodType<T>,
|
|
84
|
+
): Promise<T | undefined> {
|
|
85
|
+
const raw = await readAppStateForCurrentTab(key);
|
|
86
|
+
const parsed = schema.safeParse(raw);
|
|
87
|
+
return parsed.success ? parsed.data : undefined;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export default defineAction({
|
|
91
|
+
description:
|
|
92
|
+
"See what the user is currently looking at on screen. Returns navigation state, UI bulk selection on /tasks or /inbox when active, visible list snapshot, and selected item. Always call this first before ambiguous task or inbox edits.",
|
|
93
|
+
schema: z.object({}),
|
|
94
|
+
http: false,
|
|
95
|
+
readOnly: true,
|
|
96
|
+
run: async (_args, ctx) => {
|
|
97
|
+
const navigation = await readParsedAppState(
|
|
98
|
+
"navigation",
|
|
99
|
+
navigationStateSchema,
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
const screen: Record<string, unknown> = {};
|
|
103
|
+
if (navigation) screen.navigation = navigation;
|
|
104
|
+
|
|
105
|
+
const ownerEmail = requireUserEmail(ctx?.userEmail);
|
|
106
|
+
|
|
107
|
+
if (navigation?.view === "tasks") {
|
|
108
|
+
const tasksSelection = await readParsedAppState(
|
|
109
|
+
"tasksSelection",
|
|
110
|
+
listSelectionStateSchema,
|
|
111
|
+
);
|
|
112
|
+
const visibleFieldIds = await getTaskCardFieldIds({ ownerEmail });
|
|
113
|
+
Object.assign(
|
|
114
|
+
screen,
|
|
115
|
+
await buildListViewScreen({
|
|
116
|
+
ownerEmail,
|
|
117
|
+
cap: AGENT_TASKS_LIST_CAP,
|
|
118
|
+
fetchItems: (email) =>
|
|
119
|
+
listTasks({
|
|
120
|
+
ownerEmail: email,
|
|
121
|
+
includeDone: navigation.includeDone === true,
|
|
122
|
+
}),
|
|
123
|
+
toSummary: toTaskSummary,
|
|
124
|
+
getById: (id) => getTask({ ownerEmail, id }),
|
|
125
|
+
selection: {
|
|
126
|
+
highlightId: navigation.taskId,
|
|
127
|
+
bulkIds:
|
|
128
|
+
tasksSelection?.selectionMode &&
|
|
129
|
+
tasksSelection.selectedIds.length > 0
|
|
130
|
+
? tasksSelection.selectedIds
|
|
131
|
+
: undefined,
|
|
132
|
+
},
|
|
133
|
+
}),
|
|
134
|
+
);
|
|
135
|
+
if (visibleFieldIds.length > 0) {
|
|
136
|
+
const { fields } = await listCustomFields({
|
|
137
|
+
ownerEmail,
|
|
138
|
+
fieldIds: visibleFieldIds,
|
|
139
|
+
});
|
|
140
|
+
screen.visibleTaskFields = fields.map(toFieldSummary);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (navigation.taskId && "selectedItem" in screen) {
|
|
144
|
+
screen.selectedTaskFields = (
|
|
145
|
+
await listTaskFieldValues({
|
|
146
|
+
ownerEmail,
|
|
147
|
+
taskId: navigation.taskId,
|
|
148
|
+
})
|
|
149
|
+
).map(toTaskFieldValueSummary);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (navigation?.view === "inbox") {
|
|
154
|
+
const inboxSelection = await readParsedAppState(
|
|
155
|
+
"inboxSelection",
|
|
156
|
+
listSelectionStateSchema,
|
|
157
|
+
);
|
|
158
|
+
Object.assign(
|
|
159
|
+
screen,
|
|
160
|
+
await buildListViewScreen({
|
|
161
|
+
ownerEmail,
|
|
162
|
+
cap: AGENT_INBOX_ITEMS_LIST_CAP,
|
|
163
|
+
fetchItems: (email) => listInboxItems({ ownerEmail: email }),
|
|
164
|
+
toSummary: toInboxItemSummary,
|
|
165
|
+
getById: (id) => getInboxItem({ ownerEmail, id }),
|
|
166
|
+
selection: {
|
|
167
|
+
highlightId: navigation.inboxItemId,
|
|
168
|
+
bulkIds:
|
|
169
|
+
inboxSelection?.selectionMode &&
|
|
170
|
+
inboxSelection.selectedIds.length > 0
|
|
171
|
+
? inboxSelection.selectedIds
|
|
172
|
+
: undefined,
|
|
173
|
+
},
|
|
174
|
+
resolveSelectedMiss: async (id) => {
|
|
175
|
+
const promotedTask = await getTask({ ownerEmail, id });
|
|
176
|
+
if (!promotedTask) return null;
|
|
177
|
+
return {
|
|
178
|
+
...toTaskSummary(promotedTask),
|
|
179
|
+
inListSnapshot: false,
|
|
180
|
+
promotedFromInbox: true,
|
|
181
|
+
};
|
|
182
|
+
},
|
|
183
|
+
}),
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
if (navigation?.view === "fields") {
|
|
188
|
+
Object.assign(
|
|
189
|
+
screen,
|
|
190
|
+
await buildListViewScreen({
|
|
191
|
+
ownerEmail,
|
|
192
|
+
cap: AGENT_FIELDS_LIST_CAP,
|
|
193
|
+
fetchItems: async (email) =>
|
|
194
|
+
(await listCustomFields({ ownerEmail: email })).fields,
|
|
195
|
+
toSummary: toFieldSummary,
|
|
196
|
+
getById: (id) => getCustomField({ ownerEmail, fieldId: id }),
|
|
197
|
+
selection: { highlightId: navigation.fieldId },
|
|
198
|
+
}),
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
if (Object.keys(screen).length === 0) {
|
|
203
|
+
return "No application state found. Is the app running?";
|
|
204
|
+
}
|
|
205
|
+
return screen;
|
|
206
|
+
},
|
|
207
|
+
});
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { IconPlus } from "@tabler/icons-react";
|
|
2
|
+
import { useState, type FormEvent } from "react";
|
|
3
|
+
|
|
4
|
+
import { Button } from "@/components/ui/button";
|
|
5
|
+
import { Input } from "@/components/ui/input";
|
|
6
|
+
import { Label } from "@/components/ui/label";
|
|
7
|
+
import {
|
|
8
|
+
Select,
|
|
9
|
+
SelectContent,
|
|
10
|
+
SelectGroup,
|
|
11
|
+
SelectItem,
|
|
12
|
+
SelectTrigger,
|
|
13
|
+
SelectValue,
|
|
14
|
+
} from "@/components/ui/select";
|
|
15
|
+
import type { FieldConfig, FieldType } from "@/hooks/use-custom-fields";
|
|
16
|
+
|
|
17
|
+
import { FieldConfigControl } from "./editor/config/FieldConfigControl";
|
|
18
|
+
import { normalizedInitialConfig } from "./editor/config/utils";
|
|
19
|
+
import type { FieldDraft } from "./editor/types";
|
|
20
|
+
|
|
21
|
+
const FIELD_TYPE_OPTIONS: Array<{ value: FieldType; label: string }> = [
|
|
22
|
+
{ value: "text", label: "Text" },
|
|
23
|
+
{ value: "rich_text", label: "Rich text" },
|
|
24
|
+
{ value: "number", label: "Number" },
|
|
25
|
+
{ value: "percent", label: "Percent" },
|
|
26
|
+
{ value: "currency", label: "Currency" },
|
|
27
|
+
{ value: "single_select", label: "Single-select" },
|
|
28
|
+
{ value: "multi_select", label: "Multi-select" },
|
|
29
|
+
{ value: "date", label: "Date" },
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
const FIELD_TYPES_WITH_CONFIG = new Set<FieldType>([
|
|
33
|
+
"currency",
|
|
34
|
+
"number",
|
|
35
|
+
"percent",
|
|
36
|
+
"single_select",
|
|
37
|
+
"multi_select",
|
|
38
|
+
]);
|
|
39
|
+
|
|
40
|
+
export function FieldCreateBar({
|
|
41
|
+
busy,
|
|
42
|
+
onCreate,
|
|
43
|
+
}: {
|
|
44
|
+
busy: boolean;
|
|
45
|
+
onCreate: (draft: FieldDraft) => Promise<void>;
|
|
46
|
+
}) {
|
|
47
|
+
const [title, setTitle] = useState("");
|
|
48
|
+
const [type, setType] = useState<FieldType>("text");
|
|
49
|
+
const [config, setConfig] = useState<FieldConfig>(
|
|
50
|
+
normalizedInitialConfig("text"),
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
function handleTypeChange(nextType: FieldType) {
|
|
54
|
+
setType(nextType);
|
|
55
|
+
setConfig(normalizedInitialConfig(nextType));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
async function handleSubmit(event: FormEvent<HTMLFormElement>) {
|
|
59
|
+
event.preventDefault();
|
|
60
|
+
const trimmedTitle = title.trim();
|
|
61
|
+
if (!trimmedTitle) return;
|
|
62
|
+
|
|
63
|
+
await onCreate({ title: trimmedTitle, type, config });
|
|
64
|
+
setTitle("");
|
|
65
|
+
setType("text");
|
|
66
|
+
setConfig(normalizedInitialConfig("text"));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<form
|
|
71
|
+
onSubmit={(event) => void handleSubmit(event)}
|
|
72
|
+
className="grid shrink-0 gap-3 rounded-lg border border-border bg-card p-3 md:grid-cols-[minmax(180px,1fr)_180px_auto] md:items-start"
|
|
73
|
+
>
|
|
74
|
+
<h2 className="text-sm font-medium md:col-span-3">Create new field</h2>
|
|
75
|
+
<div className="grid gap-2">
|
|
76
|
+
<Label htmlFor="new-field-title" className="sr-only">
|
|
77
|
+
Field title
|
|
78
|
+
</Label>
|
|
79
|
+
<Input
|
|
80
|
+
id="new-field-title"
|
|
81
|
+
value={title}
|
|
82
|
+
disabled={busy}
|
|
83
|
+
placeholder="New field title"
|
|
84
|
+
onChange={(event) => setTitle(event.currentTarget.value)}
|
|
85
|
+
/>
|
|
86
|
+
</div>
|
|
87
|
+
<Select
|
|
88
|
+
value={type}
|
|
89
|
+
disabled={busy}
|
|
90
|
+
onValueChange={(value) => handleTypeChange(value as FieldType)}
|
|
91
|
+
>
|
|
92
|
+
<SelectTrigger aria-label="Field type">
|
|
93
|
+
<SelectValue />
|
|
94
|
+
</SelectTrigger>
|
|
95
|
+
<SelectContent>
|
|
96
|
+
<SelectGroup>
|
|
97
|
+
{FIELD_TYPE_OPTIONS.map((option) => (
|
|
98
|
+
<SelectItem key={option.value} value={option.value}>
|
|
99
|
+
{option.label}
|
|
100
|
+
</SelectItem>
|
|
101
|
+
))}
|
|
102
|
+
</SelectGroup>
|
|
103
|
+
</SelectContent>
|
|
104
|
+
</Select>
|
|
105
|
+
<Button type="submit" disabled={busy || title.trim().length === 0}>
|
|
106
|
+
<IconPlus className="size-4" />
|
|
107
|
+
Create
|
|
108
|
+
</Button>
|
|
109
|
+
{FIELD_TYPES_WITH_CONFIG.has(type) ? (
|
|
110
|
+
<div className="md:col-span-3">
|
|
111
|
+
<FieldConfigControl
|
|
112
|
+
type={type}
|
|
113
|
+
config={config}
|
|
114
|
+
disabled={busy}
|
|
115
|
+
onChange={setConfig}
|
|
116
|
+
/>
|
|
117
|
+
</div>
|
|
118
|
+
) : null}
|
|
119
|
+
</form>
|
|
120
|
+
);
|
|
121
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { IconTrash } from "@tabler/icons-react";
|
|
2
|
+
|
|
3
|
+
import type { SortableItemRenderProps } from "@/components/dnd/SortableItem";
|
|
4
|
+
import { ListRow } from "@/components/shared/list/ListRow";
|
|
5
|
+
import { ListRowDragHandle } from "@/components/shared/list/ListRowDragHandle";
|
|
6
|
+
import { Badge } from "@/components/ui/badge";
|
|
7
|
+
import { Button } from "@/components/ui/button";
|
|
8
|
+
import type { FieldDefinition, FieldType } from "@/hooks/use-custom-fields";
|
|
9
|
+
|
|
10
|
+
const FIELD_TYPE_LABELS: Record<FieldType, string> = {
|
|
11
|
+
text: "Text",
|
|
12
|
+
rich_text: "Rich text",
|
|
13
|
+
number: "Number",
|
|
14
|
+
percent: "Percent",
|
|
15
|
+
currency: "Currency",
|
|
16
|
+
single_select: "Single-select",
|
|
17
|
+
multi_select: "Multi-select",
|
|
18
|
+
date: "Date",
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
function fieldTypeLabel(type: FieldType) {
|
|
22
|
+
return FIELD_TYPE_LABELS[type] ?? type;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function fieldDescription(field: FieldDefinition) {
|
|
26
|
+
if (field.type === "currency") return `Currency ${field.config.symbol}`;
|
|
27
|
+
if (field.type === "number") {
|
|
28
|
+
const parts: string[] = [];
|
|
29
|
+
parts.push(`${field.config.precision ?? 0} decimals`);
|
|
30
|
+
if (field.config.positiveOnly) parts.push("positive only");
|
|
31
|
+
return parts.join(" · ");
|
|
32
|
+
}
|
|
33
|
+
if (field.type === "percent") {
|
|
34
|
+
return `${field.config.precision ?? 0} decimals`;
|
|
35
|
+
}
|
|
36
|
+
if (field.type === "single_select" || field.type === "multi_select") {
|
|
37
|
+
const options = "options" in field.config ? field.config.options : [];
|
|
38
|
+
return `${options.length} options`;
|
|
39
|
+
}
|
|
40
|
+
return fieldTypeLabel(field.type);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function FieldRowMetadata({ field }: { field: FieldDefinition }) {
|
|
44
|
+
return (
|
|
45
|
+
<div className="flex min-w-0 flex-wrap items-center justify-end gap-1.5">
|
|
46
|
+
<Badge variant="secondary" className="px-1.5 py-0 text-xs font-normal">
|
|
47
|
+
{fieldTypeLabel(field.type)}
|
|
48
|
+
</Badge>
|
|
49
|
+
<span className="truncate text-xs text-muted-foreground">
|
|
50
|
+
{fieldDescription(field)}
|
|
51
|
+
</span>
|
|
52
|
+
</div>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface FieldListRowProps {
|
|
57
|
+
sortable: SortableItemRenderProps;
|
|
58
|
+
item: FieldDefinition;
|
|
59
|
+
highlighted?: boolean;
|
|
60
|
+
onOpenDetails: () => void;
|
|
61
|
+
onRequestDelete: () => void;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function FieldListRow({
|
|
65
|
+
sortable,
|
|
66
|
+
item,
|
|
67
|
+
highlighted = false,
|
|
68
|
+
onOpenDetails,
|
|
69
|
+
onRequestDelete,
|
|
70
|
+
}: FieldListRowProps) {
|
|
71
|
+
return (
|
|
72
|
+
<ListRow
|
|
73
|
+
sortable={sortable}
|
|
74
|
+
item={item}
|
|
75
|
+
itemLabel={item.title}
|
|
76
|
+
highlighted={highlighted}
|
|
77
|
+
onActivate={onOpenDetails}
|
|
78
|
+
dataAttributes={{ "data-field-id": item.id }}
|
|
79
|
+
>
|
|
80
|
+
{({ rowDrag, rowSelection }) => (
|
|
81
|
+
<>
|
|
82
|
+
<ListRowDragHandle
|
|
83
|
+
rowDrag={rowDrag}
|
|
84
|
+
rowSelection={rowSelection}
|
|
85
|
+
displayTitle={item.title}
|
|
86
|
+
/>
|
|
87
|
+
|
|
88
|
+
<div className="min-w-0 flex-1">
|
|
89
|
+
<div className="flex h-8 min-w-0 items-center truncate text-sm font-medium">
|
|
90
|
+
{item.title}
|
|
91
|
+
</div>
|
|
92
|
+
</div>
|
|
93
|
+
|
|
94
|
+
<div className="min-w-0 shrink-0">
|
|
95
|
+
<FieldRowMetadata field={item} />
|
|
96
|
+
</div>
|
|
97
|
+
|
|
98
|
+
<Button
|
|
99
|
+
type="button"
|
|
100
|
+
variant="ghost"
|
|
101
|
+
size="icon"
|
|
102
|
+
aria-label={`Delete ${item.title}`}
|
|
103
|
+
onPointerDown={(event) => event.stopPropagation()}
|
|
104
|
+
onClick={(event) => {
|
|
105
|
+
event.stopPropagation();
|
|
106
|
+
onRequestDelete();
|
|
107
|
+
}}
|
|
108
|
+
className="relative z-10 size-8 text-muted-foreground hover:bg-destructive/10 hover:text-destructive"
|
|
109
|
+
>
|
|
110
|
+
<IconTrash />
|
|
111
|
+
</Button>
|
|
112
|
+
</>
|
|
113
|
+
)}
|
|
114
|
+
</ListRow>
|
|
115
|
+
);
|
|
116
|
+
}
|