@agent-native/core 0.102.2 → 0.103.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 (206) hide show
  1. package/corpus/README.md +1 -1
  2. package/corpus/core/CHANGELOG.md +6 -0
  3. package/corpus/core/docs/content/local-file-mode.mdx +99 -489
  4. package/corpus/core/docs/content/locales/ar-SA/local-file-mode.mdx +35 -490
  5. package/corpus/core/docs/content/locales/ar-SA/template-content.mdx +10 -24
  6. package/corpus/core/docs/content/locales/de-DE/local-file-mode.mdx +37 -491
  7. package/corpus/core/docs/content/locales/de-DE/template-content.mdx +10 -24
  8. package/corpus/core/docs/content/locales/es-ES/local-file-mode.mdx +35 -493
  9. package/corpus/core/docs/content/locales/es-ES/template-content.mdx +10 -24
  10. package/corpus/core/docs/content/locales/fr-FR/local-file-mode.mdx +38 -491
  11. package/corpus/core/docs/content/locales/fr-FR/template-content.mdx +10 -24
  12. package/corpus/core/docs/content/locales/hi-IN/local-file-mode.mdx +33 -492
  13. package/corpus/core/docs/content/locales/hi-IN/template-content.mdx +10 -24
  14. package/corpus/core/docs/content/locales/ja-JP/local-file-mode.mdx +36 -492
  15. package/corpus/core/docs/content/locales/ja-JP/template-content.mdx +10 -24
  16. package/corpus/core/docs/content/locales/ko-KR/local-file-mode.mdx +35 -490
  17. package/corpus/core/docs/content/locales/ko-KR/template-content.mdx +10 -24
  18. package/corpus/core/docs/content/locales/pt-BR/local-file-mode.mdx +35 -493
  19. package/corpus/core/docs/content/locales/pt-BR/template-content.mdx +10 -24
  20. package/corpus/core/docs/content/locales/zh-CN/local-file-mode.mdx +31 -489
  21. package/corpus/core/docs/content/locales/zh-CN/template-content.mdx +9 -24
  22. package/corpus/core/docs/content/locales/zh-TW/local-file-mode.mdx +31 -489
  23. package/corpus/core/docs/content/locales/zh-TW/template-content.mdx +9 -24
  24. package/corpus/core/docs/content/template-content.mdx +26 -42
  25. package/corpus/core/package.json +1 -1
  26. package/corpus/core/src/cli/content-local.ts +86 -18
  27. package/corpus/core/src/cli/index.ts +2 -2
  28. package/corpus/core/src/cli/skills-content/content-skill.ts +36 -25
  29. package/corpus/core/src/cli/skills.ts +47 -13
  30. package/corpus/core/src/local-artifacts/index.ts +65 -0
  31. package/corpus/templates/assets/app/components/library/GenerationPresetsPanel.tsx +325 -0
  32. package/corpus/templates/assets/app/hooks/use-navigation-state.ts +12 -0
  33. package/corpus/templates/assets/app/i18n/zh-TW.ts +21 -0
  34. package/corpus/templates/assets/app/i18n-data.ts +215 -0
  35. package/corpus/templates/assets/app/routes/brand-kits.$id.tsx +19 -479
  36. package/corpus/templates/assets/app/routes/brand-kits.$id_.presets.$presetId.tsx +1 -1
  37. package/corpus/templates/assets/app/routes/brand-kits.$id_.settings.tsx +446 -0
  38. package/corpus/templates/clips/app/components/editor/editor-layout.tsx +12 -2
  39. package/corpus/templates/clips/app/components/player/settings-panel.tsx +30 -12
  40. package/corpus/templates/clips/app/components/player/video-player.tsx +5 -1
  41. package/corpus/templates/clips/app/components/recorder/microphone-visualizer.tsx +22 -3
  42. package/corpus/templates/clips/app/i18n/ar-SA.ts +3 -2
  43. package/corpus/templates/clips/app/i18n/de-DE.ts +4 -2
  44. package/corpus/templates/clips/app/i18n/en-US.ts +3 -2
  45. package/corpus/templates/clips/app/i18n/es-ES.ts +4 -2
  46. package/corpus/templates/clips/app/i18n/fr-FR.ts +3 -2
  47. package/corpus/templates/clips/app/i18n/hi-IN.ts +3 -2
  48. package/corpus/templates/clips/app/i18n/ja-JP.ts +4 -1
  49. package/corpus/templates/clips/app/i18n/ko-KR.ts +3 -2
  50. package/corpus/templates/clips/app/i18n/pt-BR.ts +4 -2
  51. package/corpus/templates/clips/app/i18n/zh-CN.ts +3 -2
  52. package/corpus/templates/clips/app/i18n/zh-TW.ts +3 -2
  53. package/corpus/templates/clips/app/routes/r.$recordingId.tsx +27 -1
  54. package/corpus/templates/clips/server/lib/share-password.ts +6 -3
  55. package/corpus/templates/content/.agents/skills/content/SKILL.md +26 -39
  56. package/corpus/templates/content/AGENTS.md +25 -30
  57. package/corpus/templates/content/actions/_builder-docs-client.ts +23 -0
  58. package/corpus/templates/content/actions/_content-database-source-adapters.ts +21 -3
  59. package/corpus/templates/content/actions/_content-files.ts +338 -0
  60. package/corpus/templates/content/actions/_content-space-access.ts +135 -0
  61. package/corpus/templates/content/actions/_content-spaces.ts +640 -0
  62. package/corpus/templates/content/actions/_database-source-utils.ts +90 -7
  63. package/corpus/templates/content/actions/_database-utils.ts +7 -1
  64. package/corpus/templates/content/actions/_local-file-documents.ts +0 -9
  65. package/corpus/templates/content/actions/_local-folder-source.ts +53 -0
  66. package/corpus/templates/content/actions/_property-utils.ts +9 -4
  67. package/corpus/templates/content/actions/add-database-item.ts +108 -65
  68. package/corpus/templates/content/actions/backfill-content-files.ts +22 -0
  69. package/corpus/templates/content/actions/connect-local-folder-source.ts +221 -0
  70. package/corpus/templates/content/actions/create-content-database.ts +129 -3
  71. package/corpus/templates/content/actions/create-document.ts +65 -55
  72. package/corpus/templates/content/actions/create-inline-content-database.ts +6 -1
  73. package/corpus/templates/content/actions/delete-content-database.ts +3 -0
  74. package/corpus/templates/content/actions/delete-document.ts +7 -11
  75. package/corpus/templates/content/actions/disconnect-local-folder-source.ts +175 -0
  76. package/corpus/templates/content/actions/duplicate-database-item.ts +10 -0
  77. package/corpus/templates/content/actions/duplicate-database-items.ts +13 -0
  78. package/corpus/templates/content/actions/edit-document.ts +2 -28
  79. package/corpus/templates/content/actions/ensure-content-spaces.ts +26 -0
  80. package/corpus/templates/content/actions/export-content-source.ts +47 -9
  81. package/corpus/templates/content/actions/get-document.ts +0 -14
  82. package/corpus/templates/content/actions/import-content-source.ts +43 -3
  83. package/corpus/templates/content/actions/list-content-spaces.ts +103 -0
  84. package/corpus/templates/content/actions/list-documents.ts +12 -9
  85. package/corpus/templates/content/actions/move-document.ts +3 -14
  86. package/corpus/templates/content/actions/pull-document.ts +0 -23
  87. package/corpus/templates/content/actions/remove-local-file-source.ts +50 -29
  88. package/corpus/templates/content/actions/resolve-local-folder-conflict.ts +442 -0
  89. package/corpus/templates/content/actions/reveal-local-source-file.ts +6 -17
  90. package/corpus/templates/content/actions/search-documents.ts +0 -34
  91. package/corpus/templates/content/actions/share-local-file-document.ts +25 -1
  92. package/corpus/templates/content/actions/submit-content-database-form.ts +12 -0
  93. package/corpus/templates/content/actions/sync-local-folder-source.ts +731 -0
  94. package/corpus/templates/content/actions/sync-manifest-local-folder-source.ts +123 -0
  95. package/corpus/templates/content/actions/update-content-database-view.ts +10 -1
  96. package/corpus/templates/content/actions/update-document.ts +0 -15
  97. package/corpus/templates/content/actions/view-screen.ts +2 -50
  98. package/corpus/templates/content/app/components/editor/SlashCommandMenu.tsx +76 -62
  99. package/corpus/templates/content/app/components/editor/database/DatabaseView.tsx +70 -22
  100. package/corpus/templates/content/app/components/editor/database/grouping.ts +2 -1
  101. package/corpus/templates/content/app/components/editor/database/settings.tsx +23 -20
  102. package/corpus/templates/content/app/components/editor/database/shared.tsx +2 -0
  103. package/corpus/templates/content/app/components/editor/database/sidebar.tsx +330 -0
  104. package/corpus/templates/content/app/components/editor/database/types.ts +1 -0
  105. package/corpus/templates/content/app/components/editor/database/view-config.ts +3 -1
  106. package/corpus/templates/content/app/components/layout/Layout.tsx +25 -1
  107. package/corpus/templates/content/app/components/sidebar/DocumentSidebar.tsx +209 -113
  108. package/corpus/templates/content/app/components/sidebar/select-content-space.ts +31 -0
  109. package/corpus/templates/content/app/hooks/use-content-database.ts +16 -0
  110. package/corpus/templates/content/app/hooks/use-content-spaces.ts +39 -0
  111. package/corpus/templates/content/app/i18n/zh-TW.ts +11 -0
  112. package/corpus/templates/content/app/i18n-data.ts +75 -0
  113. package/corpus/templates/content/app/routes/_app.local-files.tsx +174 -65
  114. package/corpus/templates/content/changelog/2026-07-16-content-callouts-can-now-be-reviewed-and-published-to-builder.md +6 -0
  115. package/corpus/templates/content/changelog/2026-07-16-heading-5-and-heading-6-are-available-from-the-editor-slash-.md +6 -0
  116. package/corpus/templates/content/changelog/2026-07-16-organize-every-workspace-through-a-customizable-files-databa.md +6 -0
  117. package/corpus/templates/content/parity/matrix.md +2 -1
  118. package/corpus/templates/content/parity/matrix.ts +37 -1
  119. package/corpus/templates/content/scripts/dev-database.mjs +7 -5
  120. package/corpus/templates/content/server/db/schema.ts +113 -40
  121. package/corpus/templates/content/server/lib/document-context.ts +15 -1
  122. package/corpus/templates/content/server/lib/notion-sync.ts +6 -0
  123. package/corpus/templates/content/server/plugins/db.ts +153 -0
  124. package/corpus/templates/content/shared/api.ts +17 -3
  125. package/corpus/templates/content/shared/builder-mdx.ts +163 -16
  126. package/corpus/templates/design/.agents/skills/design-templates/SKILL.md +59 -0
  127. package/corpus/templates/design/AGENTS.md +6 -1
  128. package/corpus/templates/design/actions/create-design-from-template.ts +19 -7
  129. package/corpus/templates/design/actions/list-design-templates.ts +69 -21
  130. package/corpus/templates/design/actions/navigate.ts +2 -2
  131. package/corpus/templates/design/actions/view-screen.ts +15 -2
  132. package/corpus/templates/design/agent-native.app-skill.json +5 -0
  133. package/corpus/templates/design/app/components/editor/PromptDialog.tsx +281 -56
  134. package/corpus/templates/design/app/components/templates/TemplatePreview.tsx +14 -2
  135. package/corpus/templates/design/app/hooks/use-navigation-state.ts +3 -2
  136. package/corpus/templates/design/app/i18n/zh-TW.ts +3 -3
  137. package/corpus/templates/design/app/i18n-data.ts +21 -2
  138. package/corpus/templates/design/app/i18n-template-feature.ts +218 -10
  139. package/corpus/templates/design/app/pages/Index.tsx +195 -24
  140. package/corpus/templates/design/app/pages/Templates.tsx +144 -55
  141. package/corpus/templates/design/app/pages/design-editor/generation-prompt-directives.ts +12 -1
  142. package/corpus/templates/design/changelog/2026-07-14-templates-now-appear-in-the-new-design-picker-with-previews-.md +6 -0
  143. package/corpus/templates/design/changelog/2026-07-15-templates-now-open-immediately-after-copying-even-while-the-.md +6 -0
  144. package/corpus/templates/design/server/plugins/agent-chat.ts +1 -1
  145. package/corpus/templates/mail/AGENTS.md +23 -18
  146. package/corpus/templates/mail/actions/bulk-archive.ts +32 -28
  147. package/corpus/templates/mail/actions/mark-read.ts +131 -20
  148. package/corpus/templates/mail/actions/mark-thread-read.ts +1 -1
  149. package/corpus/templates/mail/actions/move-email.ts +30 -24
  150. package/corpus/templates/mail/actions/send-email.ts +73 -68
  151. package/corpus/templates/mail/changelog/2026-07-15-unread-inbox-cleanup-now-completes-reliably.md +6 -0
  152. package/corpus/templates/mail/server/handlers/emails.ts +218 -209
  153. package/corpus/templates/mail/server/lib/bulk-mark-read.ts +30 -0
  154. package/corpus/templates/mail/server/lib/email-state.ts +198 -113
  155. package/corpus/templates/mail/server/lib/google-auth.ts +218 -25
  156. package/corpus/templates/mail/server/lib/jobs.ts +69 -74
  157. package/corpus/templates/mail/server/lib/local-email-store.ts +265 -0
  158. package/corpus/templates/mail/server/plugins/agent-chat.ts +6 -0
  159. package/dist/cli/content-local.d.ts +1 -0
  160. package/dist/cli/content-local.d.ts.map +1 -1
  161. package/dist/cli/content-local.js +75 -17
  162. package/dist/cli/content-local.js.map +1 -1
  163. package/dist/cli/index.js +2 -2
  164. package/dist/cli/index.js.map +1 -1
  165. package/dist/cli/skills-content/content-skill.d.ts +1 -1
  166. package/dist/cli/skills-content/content-skill.d.ts.map +1 -1
  167. package/dist/cli/skills-content/content-skill.js +36 -25
  168. package/dist/cli/skills-content/content-skill.js.map +1 -1
  169. package/dist/cli/skills.d.ts.map +1 -1
  170. package/dist/cli/skills.js +47 -14
  171. package/dist/cli/skills.js.map +1 -1
  172. package/dist/collab/awareness.d.ts +2 -2
  173. package/dist/collab/awareness.d.ts.map +1 -1
  174. package/dist/collab/struct-routes.d.ts +1 -1
  175. package/dist/local-artifacts/index.d.ts +10 -0
  176. package/dist/local-artifacts/index.d.ts.map +1 -1
  177. package/dist/local-artifacts/index.js +39 -0
  178. package/dist/local-artifacts/index.js.map +1 -1
  179. package/dist/notifications/routes.d.ts +1 -1
  180. package/dist/observability/routes.d.ts +5 -5
  181. package/dist/resources/handlers.d.ts +1 -1
  182. package/dist/secrets/routes.d.ts +9 -9
  183. package/docs/content/local-file-mode.mdx +99 -489
  184. package/docs/content/locales/ar-SA/local-file-mode.mdx +35 -490
  185. package/docs/content/locales/ar-SA/template-content.mdx +10 -24
  186. package/docs/content/locales/de-DE/local-file-mode.mdx +37 -491
  187. package/docs/content/locales/de-DE/template-content.mdx +10 -24
  188. package/docs/content/locales/es-ES/local-file-mode.mdx +35 -493
  189. package/docs/content/locales/es-ES/template-content.mdx +10 -24
  190. package/docs/content/locales/fr-FR/local-file-mode.mdx +38 -491
  191. package/docs/content/locales/fr-FR/template-content.mdx +10 -24
  192. package/docs/content/locales/hi-IN/local-file-mode.mdx +33 -492
  193. package/docs/content/locales/hi-IN/template-content.mdx +10 -24
  194. package/docs/content/locales/ja-JP/local-file-mode.mdx +36 -492
  195. package/docs/content/locales/ja-JP/template-content.mdx +10 -24
  196. package/docs/content/locales/ko-KR/local-file-mode.mdx +35 -490
  197. package/docs/content/locales/ko-KR/template-content.mdx +10 -24
  198. package/docs/content/locales/pt-BR/local-file-mode.mdx +35 -493
  199. package/docs/content/locales/pt-BR/template-content.mdx +10 -24
  200. package/docs/content/locales/zh-CN/local-file-mode.mdx +31 -489
  201. package/docs/content/locales/zh-CN/template-content.mdx +9 -24
  202. package/docs/content/locales/zh-TW/local-file-mode.mdx +31 -489
  203. package/docs/content/locales/zh-TW/template-content.mdx +9 -24
  204. package/docs/content/template-content.mdx +26 -42
  205. package/package.json +1 -1
  206. package/corpus/templates/assets/app/components/library/EditLibraryDialog.tsx +0 -126
@@ -91,9 +91,8 @@ When you open the app, you'll see a page tree next to the editor. The agent alwa
91
91
  - **Organize pages in a tree** — nest infinitely, drag to reorder, favorite pages you use often.
92
92
  - **Search across everything** with full-text search across titles and content.
93
93
  - **Edit local Markdown/MDX files like Obsidian.** Use the `/local-files` view
94
- to export your workspace to files, edit them in your own tools, preview
95
- changes, and import them back. In Local File Mode, Content writes straight to
96
- the selected `.md` or `.mdx` file.
94
+ to connect a folder to a space's Files database, edit with your own tools,
95
+ sync changes, and review conflicts without leaving the database-backed app.
97
96
  - **Generate rich interactive custom blocks.** Register local React components,
98
97
  insert them as MDX, and let the agent create or update component files for
99
98
  your docs.
@@ -136,31 +135,23 @@ as the review surface. The hosted app remains the source of truth for sharing,
136
135
  comments, permissions, and live collaboration; the local folder is an explicit
137
136
  sync surface.
138
137
 
139
- Content can also run in **Local File Mode**, where files are the source of
140
- truth instead of SQL documents. Add `agent-native.json` to a repo, set
141
- `mode: "local-files"`, and configure roots such as `docs/`, `blog/`,
142
- `content/`, and `resources/`. The standard Content editor then populates its
143
- left sidebar from those local `.md`/`.mdx` files and writes edits back to the
144
- selected file through the normal document actions. Use this for repo-first docs,
145
- blogs, resource libraries, or an Obsidian-style personal MDX-powered notes vault; switch back to
146
- database mode when you want hosted collaboration and SQL-backed sharing. See [Local File Mode](/docs/local-file-mode) for the
147
- standalone repo layout, configuration, custom MDX components, local
148
- `extensions/` widgets, and production safety guide.
138
+ Local folders now use the same database model as every other page. Each page
139
+ belongs to a space and its system Files database; a folder is a source adapter
140
+ on that database. You can attach a folder to an existing space or create a
141
+ private folder-backed space, then use database properties and saved sidebar
142
+ views on the imported pages. See [Local folder sources](/docs/local-file-mode)
143
+ for configuration, truth policies, conflicts, custom MDX components, and local
144
+ `extensions/` widgets.
149
145
 
150
- To install the Content local-files skill into an existing repo:
146
+ To open Content for an existing repo:
151
147
 
152
148
  ```bash
153
- npx @agent-native/core@latest skills add content --mode local-files --scope project
149
+ npx @agent-native/core@latest content .
154
150
  ```
155
151
 
156
- The installer copies the `content` skill for your coding agent and writes or
157
- updates `agent-native.json` with Content roots for `docs/`, `blog/`, `content/`,
158
- and `resources/`. When a local Content app, Agent Native Desktop, or trusted
159
- local bridge is running, agents should use Content actions such as
160
- `list-documents`, `get-document`, `edit-document`, `update-document`, and
161
- `share-local-file-document` instead of raw filesystem writes. Without that local
162
- bridge, the installed skill still gives the agent the repo-editing contract for
163
- safe Markdown/MDX edits.
152
+ The CLI starts normal database-backed Content, registers an opaque local-folder
153
+ connection in `agent-native.json`, and opens the connection screen. It does not
154
+ set a local-mode environment variable.
164
155
 
165
156
  ## For developers
166
157
 
@@ -189,28 +180,21 @@ Open `http://localhost:8083` and create your first page. Then ask the agent to "
189
180
 
190
181
  **Search and comments.** Full-text search, anchored comments, version history, and restore flows are built into the document surface.
191
182
 
192
- **Sync surfaces.** Documents can sync with Notion or local Markdown/MDX folders, with SQL acting as the collaborative cache/history layer.
183
+ **Sync surfaces.** Documents can sync with Notion or local Markdown/MDX folders, while SQL remains the canonical collaborative data model.
193
184
 
194
185
  ### Local file sync
195
186
 
196
187
  The protected `/local-files` route uses the browser File System Access API, or a
197
- guarded native folder bridge inside Agent Native Desktop, to read and write
198
- Markdown/MDX files from a user-chosen folder. After the folder is linked and
199
- imported, the selected file is treated as the authority: opening the page reads
200
- the file, and normal editor saves write the file first. SQL is then updated as a
201
- cache/history layer for the existing document UI, search, and version panel, not
202
- as the source of truth. The top-right page menu exposes the local source path:
203
- relative path is always available, absolute path is available in true local-file
204
- mode and Agent Native Desktop, and Reveal in Finder is available through the
205
- desktop bridge or server-backed local-file mode.
206
-
207
- The bulk sync route calls:
208
-
209
- - `export-content-source` — reads the accessible document tree and returns a
210
- deterministic `content/` file bundle.
211
- - `import-content-source` — validates files, creates new private documents,
212
- updates documents where the caller has editor access, preserves version
213
- history, and rejects invalid parent cycles.
188
+ guarded native folder bridge inside Agent Native Desktop, to connect a folder to
189
+ a Files database. SQL stores only an opaque connection ID, relative paths,
190
+ hashes, and source metadata. Sync materializes ordinary database pages and
191
+ records concurrent edits as reviewable change sets instead of silently
192
+ overwriting either side. Disconnecting preserves both database pages and files.
193
+
194
+ The folder workflow calls `connect-local-folder-source`,
195
+ `sync-local-folder-source`, `resolve-local-folder-conflict`, and
196
+ `disconnect-local-folder-source`. `export-content-source` can export one source
197
+ using its original relative paths.
214
198
 
215
199
  The source format lives in `shared/content-source.ts`. Keep that file as the
216
200
  single contract for filenames, frontmatter, parsing, and serialization.
@@ -674,6 +658,6 @@ The agent can make all of these changes itself — ask it to "add a tags column
674
658
 
675
659
  - [**Templates**](/docs/cloneable-saas) — the clone-and-own model, and every other domain template to start from
676
660
  - [**Getting Started**](/docs/getting-started) — the framework fundamentals: actions, application state, and live sync
677
- - [**Local File Mode**](/docs/local-file-mode) — the standalone repo layout, config, and production safety guide
661
+ - [**Local folder sources**](/docs/local-file-mode) — spaces, Files databases, folder adapters, migration, and safety
678
662
  - [**Real-Time Collaboration**](/docs/real-time-collaboration) — the Yjs pipeline documents share with other collaborative surfaces
679
663
  - [**Sharing**](/docs/sharing) — the share-grant model documents build on
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-native/core",
3
- "version": "0.102.2",
3
+ "version": "0.103.0",
4
4
  "description": "Framework for agent-native application development — where AI agents and UI share SQL state, actions, and context",
5
5
  "homepage": "https://github.com/BuilderIO/agent-native#readme",
6
6
  "bugs": {
@@ -1,126 +0,0 @@
1
- import { useActionMutation, useT } from "@agent-native/core/client";
2
- import { useEffect, useState } from "react";
3
- import { toast } from "sonner";
4
-
5
- import { Button } from "@/components/ui/button";
6
- import {
7
- Dialog,
8
- DialogContent,
9
- DialogFooter,
10
- DialogHeader,
11
- DialogTitle,
12
- } from "@/components/ui/dialog";
13
- import { Input } from "@/components/ui/input";
14
- import { Label } from "@/components/ui/label";
15
- import { Textarea } from "@/components/ui/textarea";
16
-
17
- type EditableLibrary = {
18
- id: string;
19
- title: string;
20
- description?: string | null;
21
- };
22
-
23
- export function EditLibraryDialog({
24
- library,
25
- open,
26
- onOpenChange,
27
- }: {
28
- library: EditableLibrary | null;
29
- open: boolean;
30
- onOpenChange: (open: boolean) => void;
31
- }) {
32
- const t = useT();
33
- const updateLibrary = useActionMutation("update-library");
34
- const [title, setTitle] = useState("");
35
- const [description, setDescription] = useState("");
36
-
37
- useEffect(() => {
38
- if (open && library) {
39
- setTitle(library.title ?? "");
40
- setDescription(library.description ?? "");
41
- }
42
- }, [open, library]);
43
-
44
- const id = library?.id;
45
- const trimmedTitle = title.trim();
46
- const dirty =
47
- !!library &&
48
- (trimmedTitle !== (library.title ?? "").trim() ||
49
- description.trim() !== (library.description ?? "").trim());
50
-
51
- function submit() {
52
- if (!id || !trimmedTitle) return;
53
- updateLibrary.mutate(
54
- {
55
- id,
56
- title: trimmedTitle,
57
- description: description.trim() || null,
58
- },
59
- {
60
- onSuccess: () => {
61
- toast.success(t("brandKits.updated"));
62
- onOpenChange(false);
63
- },
64
- onError: (err: unknown) => {
65
- toast.error(
66
- err instanceof Error ? err.message : t("brandKits.updateFailed"),
67
- );
68
- },
69
- },
70
- );
71
- }
72
-
73
- return (
74
- <Dialog open={open} onOpenChange={onOpenChange}>
75
- <DialogContent>
76
- <DialogHeader>
77
- <DialogTitle>{t("brandKits.editDialogTitle")}</DialogTitle>
78
- </DialogHeader>
79
- <div className="space-y-4">
80
- <div className="space-y-2">
81
- <Label htmlFor="edit-library-title">
82
- {t("brandKitDetail.name")}
83
- </Label>
84
- <Input
85
- id="edit-library-title"
86
- value={title}
87
- onChange={(event) => setTitle(event.target.value)}
88
- placeholder={t("brandKits.namePlaceholder")}
89
- autoFocus
90
- onKeyDown={(event) => {
91
- if (event.key === "Enter" && !event.shiftKey) {
92
- event.preventDefault();
93
- submit();
94
- }
95
- }}
96
- />
97
- </div>
98
- <div className="space-y-2">
99
- <Label htmlFor="edit-library-description">
100
- {t("assetDetail.description")}
101
- </Label>
102
- <Textarea
103
- id="edit-library-description"
104
- value={description}
105
- onChange={(event) => setDescription(event.target.value)}
106
- placeholder={t("brandKits.editDescriptionPlaceholder")}
107
- />
108
- </div>
109
- </div>
110
- <DialogFooter>
111
- <Button variant="outline" onClick={() => onOpenChange(false)}>
112
- {t("brandKitDetail.cancel")}
113
- </Button>
114
- <Button
115
- onClick={submit}
116
- disabled={!trimmedTitle || !dirty || updateLibrary.isPending}
117
- >
118
- {updateLibrary.isPending
119
- ? t("settings.saving")
120
- : t("brandKitDetail.save")}
121
- </Button>
122
- </DialogFooter>
123
- </DialogContent>
124
- </Dialog>
125
- );
126
- }