@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.
- package/corpus/README.md +1 -1
- package/corpus/core/CHANGELOG.md +6 -0
- package/corpus/core/docs/content/local-file-mode.mdx +99 -489
- package/corpus/core/docs/content/locales/ar-SA/local-file-mode.mdx +35 -490
- package/corpus/core/docs/content/locales/ar-SA/template-content.mdx +10 -24
- package/corpus/core/docs/content/locales/de-DE/local-file-mode.mdx +37 -491
- package/corpus/core/docs/content/locales/de-DE/template-content.mdx +10 -24
- package/corpus/core/docs/content/locales/es-ES/local-file-mode.mdx +35 -493
- package/corpus/core/docs/content/locales/es-ES/template-content.mdx +10 -24
- package/corpus/core/docs/content/locales/fr-FR/local-file-mode.mdx +38 -491
- package/corpus/core/docs/content/locales/fr-FR/template-content.mdx +10 -24
- package/corpus/core/docs/content/locales/hi-IN/local-file-mode.mdx +33 -492
- package/corpus/core/docs/content/locales/hi-IN/template-content.mdx +10 -24
- package/corpus/core/docs/content/locales/ja-JP/local-file-mode.mdx +36 -492
- package/corpus/core/docs/content/locales/ja-JP/template-content.mdx +10 -24
- package/corpus/core/docs/content/locales/ko-KR/local-file-mode.mdx +35 -490
- package/corpus/core/docs/content/locales/ko-KR/template-content.mdx +10 -24
- package/corpus/core/docs/content/locales/pt-BR/local-file-mode.mdx +35 -493
- package/corpus/core/docs/content/locales/pt-BR/template-content.mdx +10 -24
- package/corpus/core/docs/content/locales/zh-CN/local-file-mode.mdx +31 -489
- package/corpus/core/docs/content/locales/zh-CN/template-content.mdx +9 -24
- package/corpus/core/docs/content/locales/zh-TW/local-file-mode.mdx +31 -489
- package/corpus/core/docs/content/locales/zh-TW/template-content.mdx +9 -24
- package/corpus/core/docs/content/template-content.mdx +26 -42
- package/corpus/core/package.json +1 -1
- package/corpus/core/src/cli/content-local.ts +86 -18
- package/corpus/core/src/cli/index.ts +2 -2
- package/corpus/core/src/cli/skills-content/content-skill.ts +36 -25
- package/corpus/core/src/cli/skills.ts +47 -13
- package/corpus/core/src/local-artifacts/index.ts +65 -0
- package/corpus/templates/assets/app/components/library/GenerationPresetsPanel.tsx +325 -0
- package/corpus/templates/assets/app/hooks/use-navigation-state.ts +12 -0
- package/corpus/templates/assets/app/i18n/zh-TW.ts +21 -0
- package/corpus/templates/assets/app/i18n-data.ts +215 -0
- package/corpus/templates/assets/app/routes/brand-kits.$id.tsx +19 -479
- package/corpus/templates/assets/app/routes/brand-kits.$id_.presets.$presetId.tsx +1 -1
- package/corpus/templates/assets/app/routes/brand-kits.$id_.settings.tsx +446 -0
- package/corpus/templates/clips/app/components/editor/editor-layout.tsx +12 -2
- package/corpus/templates/clips/app/components/player/settings-panel.tsx +30 -12
- package/corpus/templates/clips/app/components/player/video-player.tsx +5 -1
- package/corpus/templates/clips/app/components/recorder/microphone-visualizer.tsx +22 -3
- package/corpus/templates/clips/app/i18n/ar-SA.ts +3 -2
- package/corpus/templates/clips/app/i18n/de-DE.ts +4 -2
- package/corpus/templates/clips/app/i18n/en-US.ts +3 -2
- package/corpus/templates/clips/app/i18n/es-ES.ts +4 -2
- package/corpus/templates/clips/app/i18n/fr-FR.ts +3 -2
- package/corpus/templates/clips/app/i18n/hi-IN.ts +3 -2
- package/corpus/templates/clips/app/i18n/ja-JP.ts +4 -1
- package/corpus/templates/clips/app/i18n/ko-KR.ts +3 -2
- package/corpus/templates/clips/app/i18n/pt-BR.ts +4 -2
- package/corpus/templates/clips/app/i18n/zh-CN.ts +3 -2
- package/corpus/templates/clips/app/i18n/zh-TW.ts +3 -2
- package/corpus/templates/clips/app/routes/r.$recordingId.tsx +27 -1
- package/corpus/templates/clips/server/lib/share-password.ts +6 -3
- package/corpus/templates/content/.agents/skills/content/SKILL.md +26 -39
- package/corpus/templates/content/AGENTS.md +25 -30
- package/corpus/templates/content/actions/_builder-docs-client.ts +23 -0
- package/corpus/templates/content/actions/_content-database-source-adapters.ts +21 -3
- package/corpus/templates/content/actions/_content-files.ts +338 -0
- package/corpus/templates/content/actions/_content-space-access.ts +135 -0
- package/corpus/templates/content/actions/_content-spaces.ts +640 -0
- package/corpus/templates/content/actions/_database-source-utils.ts +90 -7
- package/corpus/templates/content/actions/_database-utils.ts +7 -1
- package/corpus/templates/content/actions/_local-file-documents.ts +0 -9
- package/corpus/templates/content/actions/_local-folder-source.ts +53 -0
- package/corpus/templates/content/actions/_property-utils.ts +9 -4
- package/corpus/templates/content/actions/add-database-item.ts +108 -65
- package/corpus/templates/content/actions/backfill-content-files.ts +22 -0
- package/corpus/templates/content/actions/connect-local-folder-source.ts +221 -0
- package/corpus/templates/content/actions/create-content-database.ts +129 -3
- package/corpus/templates/content/actions/create-document.ts +65 -55
- package/corpus/templates/content/actions/create-inline-content-database.ts +6 -1
- package/corpus/templates/content/actions/delete-content-database.ts +3 -0
- package/corpus/templates/content/actions/delete-document.ts +7 -11
- package/corpus/templates/content/actions/disconnect-local-folder-source.ts +175 -0
- package/corpus/templates/content/actions/duplicate-database-item.ts +10 -0
- package/corpus/templates/content/actions/duplicate-database-items.ts +13 -0
- package/corpus/templates/content/actions/edit-document.ts +2 -28
- package/corpus/templates/content/actions/ensure-content-spaces.ts +26 -0
- package/corpus/templates/content/actions/export-content-source.ts +47 -9
- package/corpus/templates/content/actions/get-document.ts +0 -14
- package/corpus/templates/content/actions/import-content-source.ts +43 -3
- package/corpus/templates/content/actions/list-content-spaces.ts +103 -0
- package/corpus/templates/content/actions/list-documents.ts +12 -9
- package/corpus/templates/content/actions/move-document.ts +3 -14
- package/corpus/templates/content/actions/pull-document.ts +0 -23
- package/corpus/templates/content/actions/remove-local-file-source.ts +50 -29
- package/corpus/templates/content/actions/resolve-local-folder-conflict.ts +442 -0
- package/corpus/templates/content/actions/reveal-local-source-file.ts +6 -17
- package/corpus/templates/content/actions/search-documents.ts +0 -34
- package/corpus/templates/content/actions/share-local-file-document.ts +25 -1
- package/corpus/templates/content/actions/submit-content-database-form.ts +12 -0
- package/corpus/templates/content/actions/sync-local-folder-source.ts +731 -0
- package/corpus/templates/content/actions/sync-manifest-local-folder-source.ts +123 -0
- package/corpus/templates/content/actions/update-content-database-view.ts +10 -1
- package/corpus/templates/content/actions/update-document.ts +0 -15
- package/corpus/templates/content/actions/view-screen.ts +2 -50
- package/corpus/templates/content/app/components/editor/SlashCommandMenu.tsx +76 -62
- package/corpus/templates/content/app/components/editor/database/DatabaseView.tsx +70 -22
- package/corpus/templates/content/app/components/editor/database/grouping.ts +2 -1
- package/corpus/templates/content/app/components/editor/database/settings.tsx +23 -20
- package/corpus/templates/content/app/components/editor/database/shared.tsx +2 -0
- package/corpus/templates/content/app/components/editor/database/sidebar.tsx +330 -0
- package/corpus/templates/content/app/components/editor/database/types.ts +1 -0
- package/corpus/templates/content/app/components/editor/database/view-config.ts +3 -1
- package/corpus/templates/content/app/components/layout/Layout.tsx +25 -1
- package/corpus/templates/content/app/components/sidebar/DocumentSidebar.tsx +209 -113
- package/corpus/templates/content/app/components/sidebar/select-content-space.ts +31 -0
- package/corpus/templates/content/app/hooks/use-content-database.ts +16 -0
- package/corpus/templates/content/app/hooks/use-content-spaces.ts +39 -0
- package/corpus/templates/content/app/i18n/zh-TW.ts +11 -0
- package/corpus/templates/content/app/i18n-data.ts +75 -0
- package/corpus/templates/content/app/routes/_app.local-files.tsx +174 -65
- package/corpus/templates/content/changelog/2026-07-16-content-callouts-can-now-be-reviewed-and-published-to-builder.md +6 -0
- package/corpus/templates/content/changelog/2026-07-16-heading-5-and-heading-6-are-available-from-the-editor-slash-.md +6 -0
- package/corpus/templates/content/changelog/2026-07-16-organize-every-workspace-through-a-customizable-files-databa.md +6 -0
- package/corpus/templates/content/parity/matrix.md +2 -1
- package/corpus/templates/content/parity/matrix.ts +37 -1
- package/corpus/templates/content/scripts/dev-database.mjs +7 -5
- package/corpus/templates/content/server/db/schema.ts +113 -40
- package/corpus/templates/content/server/lib/document-context.ts +15 -1
- package/corpus/templates/content/server/lib/notion-sync.ts +6 -0
- package/corpus/templates/content/server/plugins/db.ts +153 -0
- package/corpus/templates/content/shared/api.ts +17 -3
- package/corpus/templates/content/shared/builder-mdx.ts +163 -16
- package/corpus/templates/design/.agents/skills/design-templates/SKILL.md +59 -0
- package/corpus/templates/design/AGENTS.md +6 -1
- package/corpus/templates/design/actions/create-design-from-template.ts +19 -7
- package/corpus/templates/design/actions/list-design-templates.ts +69 -21
- package/corpus/templates/design/actions/navigate.ts +2 -2
- package/corpus/templates/design/actions/view-screen.ts +15 -2
- package/corpus/templates/design/agent-native.app-skill.json +5 -0
- package/corpus/templates/design/app/components/editor/PromptDialog.tsx +281 -56
- package/corpus/templates/design/app/components/templates/TemplatePreview.tsx +14 -2
- package/corpus/templates/design/app/hooks/use-navigation-state.ts +3 -2
- package/corpus/templates/design/app/i18n/zh-TW.ts +3 -3
- package/corpus/templates/design/app/i18n-data.ts +21 -2
- package/corpus/templates/design/app/i18n-template-feature.ts +218 -10
- package/corpus/templates/design/app/pages/Index.tsx +195 -24
- package/corpus/templates/design/app/pages/Templates.tsx +144 -55
- package/corpus/templates/design/app/pages/design-editor/generation-prompt-directives.ts +12 -1
- package/corpus/templates/design/changelog/2026-07-14-templates-now-appear-in-the-new-design-picker-with-previews-.md +6 -0
- package/corpus/templates/design/changelog/2026-07-15-templates-now-open-immediately-after-copying-even-while-the-.md +6 -0
- package/corpus/templates/design/server/plugins/agent-chat.ts +1 -1
- package/corpus/templates/mail/AGENTS.md +23 -18
- package/corpus/templates/mail/actions/bulk-archive.ts +32 -28
- package/corpus/templates/mail/actions/mark-read.ts +131 -20
- package/corpus/templates/mail/actions/mark-thread-read.ts +1 -1
- package/corpus/templates/mail/actions/move-email.ts +30 -24
- package/corpus/templates/mail/actions/send-email.ts +73 -68
- package/corpus/templates/mail/changelog/2026-07-15-unread-inbox-cleanup-now-completes-reliably.md +6 -0
- package/corpus/templates/mail/server/handlers/emails.ts +218 -209
- package/corpus/templates/mail/server/lib/bulk-mark-read.ts +30 -0
- package/corpus/templates/mail/server/lib/email-state.ts +198 -113
- package/corpus/templates/mail/server/lib/google-auth.ts +218 -25
- package/corpus/templates/mail/server/lib/jobs.ts +69 -74
- package/corpus/templates/mail/server/lib/local-email-store.ts +265 -0
- package/corpus/templates/mail/server/plugins/agent-chat.ts +6 -0
- package/dist/cli/content-local.d.ts +1 -0
- package/dist/cli/content-local.d.ts.map +1 -1
- package/dist/cli/content-local.js +75 -17
- package/dist/cli/content-local.js.map +1 -1
- package/dist/cli/index.js +2 -2
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/skills-content/content-skill.d.ts +1 -1
- package/dist/cli/skills-content/content-skill.d.ts.map +1 -1
- package/dist/cli/skills-content/content-skill.js +36 -25
- package/dist/cli/skills-content/content-skill.js.map +1 -1
- package/dist/cli/skills.d.ts.map +1 -1
- package/dist/cli/skills.js +47 -14
- package/dist/cli/skills.js.map +1 -1
- package/dist/collab/awareness.d.ts +2 -2
- package/dist/collab/awareness.d.ts.map +1 -1
- package/dist/collab/struct-routes.d.ts +1 -1
- package/dist/local-artifacts/index.d.ts +10 -0
- package/dist/local-artifacts/index.d.ts.map +1 -1
- package/dist/local-artifacts/index.js +39 -0
- package/dist/local-artifacts/index.js.map +1 -1
- package/dist/notifications/routes.d.ts +1 -1
- package/dist/observability/routes.d.ts +5 -5
- package/dist/resources/handlers.d.ts +1 -1
- package/dist/secrets/routes.d.ts +9 -9
- package/docs/content/local-file-mode.mdx +99 -489
- package/docs/content/locales/ar-SA/local-file-mode.mdx +35 -490
- package/docs/content/locales/ar-SA/template-content.mdx +10 -24
- package/docs/content/locales/de-DE/local-file-mode.mdx +37 -491
- package/docs/content/locales/de-DE/template-content.mdx +10 -24
- package/docs/content/locales/es-ES/local-file-mode.mdx +35 -493
- package/docs/content/locales/es-ES/template-content.mdx +10 -24
- package/docs/content/locales/fr-FR/local-file-mode.mdx +38 -491
- package/docs/content/locales/fr-FR/template-content.mdx +10 -24
- package/docs/content/locales/hi-IN/local-file-mode.mdx +33 -492
- package/docs/content/locales/hi-IN/template-content.mdx +10 -24
- package/docs/content/locales/ja-JP/local-file-mode.mdx +36 -492
- package/docs/content/locales/ja-JP/template-content.mdx +10 -24
- package/docs/content/locales/ko-KR/local-file-mode.mdx +35 -490
- package/docs/content/locales/ko-KR/template-content.mdx +10 -24
- package/docs/content/locales/pt-BR/local-file-mode.mdx +35 -493
- package/docs/content/locales/pt-BR/template-content.mdx +10 -24
- package/docs/content/locales/zh-CN/local-file-mode.mdx +31 -489
- package/docs/content/locales/zh-CN/template-content.mdx +9 -24
- package/docs/content/locales/zh-TW/local-file-mode.mdx +31 -489
- package/docs/content/locales/zh-TW/template-content.mdx +9 -24
- package/docs/content/template-content.mdx +26 -42
- package/package.json +1 -1
- 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
|
|
95
|
-
changes, and
|
|
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
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
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
|
|
146
|
+
To open Content for an existing repo:
|
|
151
147
|
|
|
152
148
|
```bash
|
|
153
|
-
npx @agent-native/core@latest
|
|
149
|
+
npx @agent-native/core@latest content .
|
|
154
150
|
```
|
|
155
151
|
|
|
156
|
-
The
|
|
157
|
-
|
|
158
|
-
|
|
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,
|
|
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
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
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
|
|
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.
|
|
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
|
-
}
|