@conloca/cms-spa 0.1.13 → 0.1.15

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.
@@ -1,13 +1,260 @@
1
- import { BlockTypeSelect, BoldItalicUnderlineToggles, CreateLink, DiffSourceToggleWrapper, InsertCodeBlock, InsertImage, InsertTable, InsertThematicBreak, ListsToggle, MDXEditor, Separator, UndoRedo, closeImageDialog$, codeBlockPlugin, codeMirrorPlugin, diffSourcePlugin, frontmatterPlugin, headingsPlugin, imageDialogState$, imagePlugin, insertImage$, jsxPlugin, linkDialogPlugin, linkPlugin, listsPlugin, markdownShortcutPlugin, quotePlugin, tablePlugin, thematicBreakPlugin, toolbarPlugin, useCellValue, usePublisher } from "@mdxeditor/editor";
2
- import React, { useCallback, useEffect, useMemo, useRef, useState } from "react";
3
- import "@mdxeditor/editor/style.css";
4
- import { Folder, FolderPlus, Search, Upload, X } from "lucide-react";
5
- import { useAssetFolders, useAssetUsage, useCreateFolder, useDeleteAsset, useFolderTree as useFolderTree$1, useImportAssetUrl, useMoveAssets, useUpdateAssetMetadata, useUploadAsset } from "@conloca/content-api-client";
1
+ import { BaseMDXEditor, BaseMDXEditorModal, useMDXEvaluation } from "@conloca/mdx";
2
+ import React, { createContext, forwardRef, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
3
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
4
  import { clsx } from "clsx";
7
5
  import { twMerge } from "tailwind-merge";
8
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
9
- import { useMDXEvaluation } from "@conloca/mdx";
6
+ import { AlertTriangle, Check, Folder, FolderPlus, Loader2, Search, Upload, X } from "lucide-react";
7
+ import { closeImageDialog$, imageDialogState$, insertImage$, useCellValue, usePublisher } from "@mdxeditor/editor";
8
+ import { useAssetFolders, useAssetUsage, useBulkDeleteAssets, useCompileMDX, useCreateFolder, useDeleteAsset, useFolderTree as useFolderTree$1, useImportAssetUrl, useMoveAssets, useUpdateAssetMetadata, useUploadAsset } from "@conloca/content-api-client";
9
+
10
+ //#region src/hooks/useTheme.tsx
11
+ const STORAGE_KEY = "conloca-theme";
12
+ const ThemeContext = createContext(null);
13
+ function getSystemTheme() {
14
+ if (typeof window === "undefined") return "light";
15
+ return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
16
+ }
17
+ function getStoredTheme() {
18
+ if (typeof window === "undefined") return "system";
19
+ const stored = localStorage.getItem(STORAGE_KEY);
20
+ if (stored === "light" || stored === "dark" || stored === "system") return stored;
21
+ return "system";
22
+ }
23
+ function applyTheme(resolved) {
24
+ const root = document.documentElement;
25
+ if (resolved === "dark") root.classList.add("dark");
26
+ else root.classList.remove("dark");
27
+ }
28
+ function ThemeProvider({ children }) {
29
+ const [theme, setThemeState] = useState(getStoredTheme);
30
+ const [systemTheme, setSystemTheme] = useState(getSystemTheme);
31
+ const resolvedTheme = theme === "system" ? systemTheme : theme;
32
+ const setTheme = useCallback((newTheme) => {
33
+ setThemeState(newTheme);
34
+ localStorage.setItem(STORAGE_KEY, newTheme);
35
+ }, []);
36
+ useEffect(() => {
37
+ applyTheme(resolvedTheme);
38
+ }, [resolvedTheme]);
39
+ useEffect(() => {
40
+ const mq = window.matchMedia("(prefers-color-scheme: dark)");
41
+ const handler = (e) => {
42
+ setSystemTheme(e.matches ? "dark" : "light");
43
+ };
44
+ mq.addEventListener("change", handler);
45
+ return () => mq.removeEventListener("change", handler);
46
+ }, []);
47
+ return /* @__PURE__ */ jsx(ThemeContext.Provider, {
48
+ value: {
49
+ theme,
50
+ resolvedTheme,
51
+ setTheme
52
+ },
53
+ children
54
+ });
55
+ }
56
+ const NOOP_THEME = {
57
+ theme: "system",
58
+ resolvedTheme: "light",
59
+ setTheme: () => {}
60
+ };
61
+ function useTheme() {
62
+ return useContext(ThemeContext) ?? NOOP_THEME;
63
+ }
64
+
65
+ //#endregion
66
+ //#region src/utils/cn.ts
67
+ function cn(...inputs) {
68
+ return twMerge(clsx(inputs));
69
+ }
70
+
71
+ //#endregion
72
+ //#region src/components/ui/Button.tsx
73
+ function Button({ variant = "primary", size = "default", type = "button", className, ref, ...props }) {
74
+ return /* @__PURE__ */ jsx("button", {
75
+ ref,
76
+ type,
77
+ className: cn("rounded-md transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed", {
78
+ default: "px-4 py-2",
79
+ sm: "px-3 py-1.5 text-sm"
80
+ }[size], {
81
+ primary: "bg-azure-04 text-white hover:bg-azure-03",
82
+ outline: "border border-line bg-panel text-grey-04 dark:text-grey-07 hover:bg-hover hover:text-grey-01 dark:hover:text-grey-12",
83
+ ghost: "text-grey-04 dark:text-grey-07 hover:bg-hover hover:text-grey-01 dark:hover:text-grey-12",
84
+ destructive: "bg-red-04 text-white hover:bg-red-03"
85
+ }[variant], className),
86
+ ...props
87
+ });
88
+ }
89
+
90
+ //#endregion
91
+ //#region src/components/ui/IconButton.tsx
92
+ function IconButton({ icon: Icon, onClick, ariaLabel, title, className, iconSize = "h-4 w-4", variant = "default" }) {
93
+ return /* @__PURE__ */ jsx("button", {
94
+ onClick,
95
+ className: cn("p-2 rounded-md transition-all duration-150 cursor-pointer", {
96
+ default: "text-grey-03 dark:text-grey-09 hover:bg-hover hover:text-grey-01 dark:hover:text-grey-12",
97
+ ghost: "text-grey-04 dark:text-grey-07 hover:bg-hover hover:text-grey-01 dark:hover:text-grey-12"
98
+ }[variant], className),
99
+ "aria-label": ariaLabel,
100
+ title: title || ariaLabel,
101
+ children: /* @__PURE__ */ jsx(Icon, { className: iconSize })
102
+ });
103
+ }
104
+
105
+ //#endregion
106
+ //#region src/components/ui/Input.tsx
107
+ function Input({ size = "default", error, className, ref, ...props }) {
108
+ return /* @__PURE__ */ jsx("input", {
109
+ ref,
110
+ className: cn("w-full rounded-md border bg-panel text-grey-01 dark:text-grey-12", "focus:outline-none focus:ring-2 focus:ring-azure-04", size === "sm" ? "px-3 py-2 text-sm" : "px-3 py-2", error ? "border-red-04 focus:ring-red-04" : "border-line", className),
111
+ ...props
112
+ });
113
+ }
114
+
115
+ //#endregion
116
+ //#region src/components/ui/Select.tsx
117
+ function Select({ size = "default", className, children, ref, ...props }) {
118
+ return /* @__PURE__ */ jsx("select", {
119
+ ref,
120
+ className: cn("w-full rounded-md border bg-panel border-line text-grey-01 dark:text-grey-12", "focus:outline-none focus:ring-2 focus:ring-azure-04", size === "sm" ? "px-3 py-2 text-sm" : "px-3 py-2", className),
121
+ ...props,
122
+ children
123
+ });
124
+ }
125
+
126
+ //#endregion
127
+ //#region src/components/ui/Separator.tsx
128
+ function Separator({ className, orientation = "vertical" }) {
129
+ if (orientation === "horizontal") return /* @__PURE__ */ jsx("div", {
130
+ className: cn("w-full h-px bg-grey-09 dark:bg-grey-04", className),
131
+ role: "separator",
132
+ "aria-orientation": "horizontal"
133
+ });
134
+ return /* @__PURE__ */ jsx("div", {
135
+ className: cn("h-5 w-px bg-grey-09 dark:bg-grey-04", className),
136
+ role: "separator",
137
+ "aria-orientation": "vertical"
138
+ });
139
+ }
140
+
141
+ //#endregion
142
+ //#region src/components/ui/Textarea.tsx
143
+ function Textarea({ error, className, ref, ...props }) {
144
+ return /* @__PURE__ */ jsx("textarea", {
145
+ ref,
146
+ className: cn("w-full px-3 py-2 rounded-md border bg-panel text-grey-01 dark:text-grey-12", "focus:outline-none focus:ring-2 focus:ring-azure-04", error ? "border-red-04 focus:ring-red-04" : "border-line", className),
147
+ ...props
148
+ });
149
+ }
150
+
151
+ //#endregion
152
+ //#region src/components/ui/Tooltip.tsx
153
+ function Tooltip({ content, children, className = "" }) {
154
+ const [isVisible, setIsVisible] = useState(false);
155
+ return /* @__PURE__ */ jsxs("div", {
156
+ className: "relative inline-block",
157
+ children: [/* @__PURE__ */ jsx("div", {
158
+ onMouseEnter: () => setIsVisible(true),
159
+ onMouseLeave: () => setIsVisible(false),
160
+ children
161
+ }), isVisible && /* @__PURE__ */ jsxs("div", {
162
+ className: `absolute z-10 px-3 py-2 text-sm text-white bg-grey-01 rounded-lg shadow-sm
163
+ bottom-full left-1/2 transform -translate-x-1/2 mb-2 whitespace-nowrap ${className}`,
164
+ children: [content, /* @__PURE__ */ jsx("div", {
165
+ className: "absolute top-full left-1/2 transform -translate-x-1/2 -mt-1",
166
+ children: /* @__PURE__ */ jsx("div", { className: "w-0 h-0 border-l-4 border-r-4 border-t-4 border-l-transparent border-r-transparent border-t-grey-01" })
167
+ })]
168
+ })]
169
+ });
170
+ }
171
+
172
+ //#endregion
173
+ //#region src/components/editor/content-block-templates.ts
174
+ const contentBlockTemplates = [
175
+ {
176
+ id: "long-form",
177
+ label: "Long-Form Text",
178
+ description: "Article-style prose for deep explanations, narrative sections, and documentation-style content.",
179
+ category: "content",
180
+ content: "# {{title}}\n\nLead with the most important point in 2-3 sentences. Explain why it matters before diving into the details.\n\n> Editors should understand the value of this section before they finish the first paragraph.\n\n## Key idea\n\nAdd the main explanation here. Use short paragraphs and one list if it helps the reader scan faster.\n\n- First takeaway\n- Second takeaway\n- Third takeaway\n\n## What changes for the team\n\nDescribe the before and after. Focus on clarity, speed, ownership, or workflow quality.\n"
181
+ },
182
+ {
183
+ id: "feature-narrative",
184
+ label: "Feature Narrative",
185
+ description: "A polished feature story that introduces a capability, explains the workflow, and lands on the user benefit.",
186
+ category: "features",
187
+ content: "# {{title}}\n\nStart with the user problem this block solves and the moment when it becomes obvious they need it.\n\n## Why teams hit this wall\n\nDescribe the friction or limitation in the current workflow. Keep it grounded in real editorial behavior.\n\n## What Conloca changes\n\nExplain the workflow in plain language. Focus on what changes for the editor, not implementation details.\n\n## What it unlocks\n\nClose with the outcome: faster publishing, clearer content operations, fewer bottlenecks, or better site quality.\n\n| Before | After |\n| --- | --- |\n| Manual handoffs | Shared visual workflow |\n| Hidden content state | Git-visible changes |\n"
188
+ },
189
+ {
190
+ id: "callout-note",
191
+ label: "Callout Note",
192
+ description: "Compact supporting content for tips, clarifications, or key reminders inside a larger landing page.",
193
+ category: "callouts",
194
+ content: "## {{title}}\n\n> Lead with a concise note, recommendation, or point of emphasis.\n\nAdd one short paragraph that gives the reader extra context, guidance, or a best practice.\n\n- Keep the point crisp\n- Explain why it matters\n- Point to the next action\n"
195
+ },
196
+ {
197
+ id: "comparison-narrative",
198
+ label: "Comparison Narrative",
199
+ description: "Structured prose for explaining tradeoffs between Conloca and another category of CMS or workflow.",
200
+ category: "comparison",
201
+ content: "# {{title}}\n\nFrame the choice clearly. What are teams actually choosing between here?\n\n## Where the usual approach breaks\n\nExplain the operational cost, not just the missing feature list.\n\n## Why Conloca feels different\n\nUse this section to connect architecture to daily editing experience.\n\n| Concern | Typical setup | Conloca |\n| --- | --- | --- |\n| Content ownership | External service | Lives in your repo |\n| Editorial UX | Form-heavy | Visual + reusable blocks |\n| Change history | Separate tools | Git-native |\n"
202
+ },
203
+ {
204
+ id: "founder-note",
205
+ label: "Founder Note",
206
+ description: "A more personal voice for opinionated product philosophy, launch notes, or roadmap framing.",
207
+ category: "story",
208
+ content: "# {{title}}\n\nStart with a direct statement of belief. This should sound like a human, not a feature checklist.\n\n## What we kept seeing\n\nDescribe the repeated pattern that convinced you the problem was real.\n\n## What we decided to build instead\n\nExplain the product choice and the philosophy behind it.\n\n> The best CMS should make editors faster without taking the codebase away from developers.\n"
209
+ }
210
+ ];
211
+ const contentBlockSnippets = [
212
+ {
213
+ id: "section-heading",
214
+ label: "Section Heading",
215
+ content: "## Section title\n\nWrite the opening paragraph for this section here.\n"
216
+ },
217
+ {
218
+ id: "callout-quote",
219
+ label: "Callout Quote",
220
+ content: "> A short, sharp takeaway or highlighted recommendation.\n"
221
+ },
222
+ {
223
+ id: "proof-points",
224
+ label: "Proof Points",
225
+ content: "- Clear editorial workflow\n- Reusable narrative blocks\n- Git-native publishing history\n"
226
+ },
227
+ {
228
+ id: "comparison-table",
229
+ label: "Comparison Table",
230
+ content: "| Option | Best for | Tradeoff |\n| --- | --- | --- |\n| Option A | Teams that want speed | Less flexibility |\n| Option B | Teams that need control | More setup |\n"
231
+ },
232
+ {
233
+ id: "before-after",
234
+ label: "Before / After Table",
235
+ content: "| Before | After |\n| --- | --- |\n| Editors wait on developers | Editors publish with reusable blocks |\n| Content lives in tools | Content lives in the repo |\n"
236
+ },
237
+ {
238
+ id: "next-steps",
239
+ label: "Next Steps List",
240
+ content: "## Next steps\n\n1. First action\n2. Second action\n3. Third action\n"
241
+ },
242
+ {
243
+ id: "code-callout",
244
+ label: "Code Callout",
245
+ content: "```ts\nconlocaCMS({\n contentRoot: \"./content\",\n puckConfigPath: \"./src/puck.config.tsx\",\n})\n```\n"
246
+ }
247
+ ];
248
+ function getContentBlockTemplate(templateId) {
249
+ return contentBlockTemplates.find((template) => template.id === templateId);
250
+ }
251
+ function renderContentBlockTemplate(templateId, title) {
252
+ const template = getContentBlockTemplate(templateId);
253
+ if (!template) return `# ${title}\n\nWrite your content here.\n`;
254
+ return template.content.split("{{title}}").join(title || "Untitled Block");
255
+ }
10
256
 
257
+ //#endregion
11
258
  //#region src/hooks/useClickOutside.ts
12
259
  /**
13
260
  * Hook that triggers a callback when clicking outside the referenced element.
@@ -240,9 +487,150 @@ async function buildUploadFormData(file, alt, folder) {
240
487
  }
241
488
 
242
489
  //#endregion
243
- //#region src/utils/cn.ts
244
- function cn$1(...inputs) {
245
- return twMerge(clsx(inputs));
490
+ //#region src/hooks/useUploadFlow.ts
491
+ const ACCEPTED_TYPES = "image/jpeg,image/png,image/gif,image/webp,image/svg+xml,image/avif";
492
+ function useUploadFlow({ folder, onUploadComplete, onSuccess }) {
493
+ const [isDragOver, setIsDragOver] = useState(false);
494
+ const [altText, setAltText] = useState("");
495
+ const [pendingFile, setPendingFile] = useState(null);
496
+ const [activeTab, setActiveTab] = useState("file");
497
+ const [importUrl, setImportUrl] = useState("");
498
+ const [uploadProgress, setUploadProgress] = useState(null);
499
+ const fileInputRef = useRef(null);
500
+ const uploadMutation = useUploadAsset();
501
+ const importMutation = useImportAssetUrl();
502
+ const previewUrl = useMemo(() => {
503
+ if (!pendingFile) return null;
504
+ return URL.createObjectURL(pendingFile);
505
+ }, [pendingFile]);
506
+ useEffect(() => {
507
+ return () => {
508
+ if (previewUrl) URL.revokeObjectURL(previewUrl);
509
+ };
510
+ }, [previewUrl]);
511
+ const isUploading = uploadMutation.isPending || importMutation.isPending || (uploadProgress?.inProgress ?? false);
512
+ const error = uploadMutation.error || importMutation.error;
513
+ const reset = useCallback(() => {
514
+ setPendingFile(null);
515
+ setAltText("");
516
+ setImportUrl("");
517
+ setUploadProgress(null);
518
+ setActiveTab("file");
519
+ setIsDragOver(false);
520
+ if (fileInputRef.current) fileInputRef.current.value = "";
521
+ }, []);
522
+ const handleSingleFile = useCallback((file) => {
523
+ setPendingFile(file);
524
+ setAltText("");
525
+ }, []);
526
+ const handleMultipleFiles = useCallback(async (files) => {
527
+ if (files.length === 0) return;
528
+ if (files.length === 1) {
529
+ handleSingleFile(files[0]);
530
+ return;
531
+ }
532
+ setUploadProgress({
533
+ total: files.length,
534
+ completed: 0,
535
+ failed: 0,
536
+ inProgress: true
537
+ });
538
+ const uploadPromises = files.map(async (file) => {
539
+ const formData = await buildUploadFormData(file, void 0, folder);
540
+ return uploadMutation.mutateAsync(formData);
541
+ });
542
+ const results = await Promise.allSettled(uploadPromises);
543
+ const completed = results.filter((r) => r.status === "fulfilled").length;
544
+ const failed = results.filter((r) => r.status === "rejected").length;
545
+ setUploadProgress({
546
+ total: files.length,
547
+ completed,
548
+ failed,
549
+ inProgress: false
550
+ });
551
+ setTimeout(() => {
552
+ setUploadProgress(null);
553
+ if (completed > 0) onUploadComplete?.();
554
+ onSuccess?.();
555
+ }, 2e3);
556
+ }, [
557
+ folder,
558
+ uploadMutation,
559
+ handleSingleFile,
560
+ onUploadComplete,
561
+ onSuccess
562
+ ]);
563
+ const handleFiles = useCallback((fileList) => {
564
+ if (!fileList || fileList.length === 0) return;
565
+ handleMultipleFiles(Array.from(fileList));
566
+ }, [handleMultipleFiles]);
567
+ const handleDragOver = useCallback((e) => {
568
+ e.preventDefault();
569
+ setIsDragOver(true);
570
+ }, []);
571
+ const handleDragLeave = useCallback((e) => {
572
+ e.preventDefault();
573
+ setIsDragOver(false);
574
+ }, []);
575
+ const handleDrop = useCallback((e) => {
576
+ e.preventDefault();
577
+ setIsDragOver(false);
578
+ handleFiles(e.dataTransfer.files);
579
+ }, [handleFiles]);
580
+ const handleUpload = async () => {
581
+ if (!pendingFile) return;
582
+ const formData = await buildUploadFormData(pendingFile, altText || void 0, folder);
583
+ uploadMutation.mutate(formData, { onSuccess: () => {
584
+ setPendingFile(null);
585
+ setAltText("");
586
+ if (fileInputRef.current) fileInputRef.current.value = "";
587
+ onUploadComplete?.();
588
+ onSuccess?.();
589
+ } });
590
+ };
591
+ const handleImportUrl = () => {
592
+ if (!importUrl.trim()) return;
593
+ importMutation.mutate({
594
+ url: importUrl.trim(),
595
+ alt: altText || void 0,
596
+ folder
597
+ }, { onSuccess: () => {
598
+ setImportUrl("");
599
+ setAltText("");
600
+ onUploadComplete?.();
601
+ onSuccess?.();
602
+ } });
603
+ };
604
+ const handleCancel = () => {
605
+ setPendingFile(null);
606
+ setAltText("");
607
+ if (fileInputRef.current) fileInputRef.current.value = "";
608
+ };
609
+ return {
610
+ isDragOver,
611
+ altText,
612
+ setAltText,
613
+ pendingFile,
614
+ activeTab,
615
+ setActiveTab,
616
+ importUrl,
617
+ setImportUrl,
618
+ uploadProgress,
619
+ fileInputRef,
620
+ previewUrl,
621
+ isUploading,
622
+ error,
623
+ uploadMutationIsPending: uploadMutation.isPending,
624
+ importMutationIsPending: importMutation.isPending,
625
+ handleFiles,
626
+ handleDragOver,
627
+ handleDragLeave,
628
+ handleDrop,
629
+ handleUpload,
630
+ handleImportUrl,
631
+ handleCancel,
632
+ reset
633
+ };
246
634
  }
247
635
 
248
636
  //#endregion
@@ -268,46 +656,43 @@ function CreateFolderDialog({ open, isPending, onClose, onCreate }) {
268
656
  if (!open) return null;
269
657
  const isValid = folderName.trim().length > 0;
270
658
  return /* @__PURE__ */ jsx("div", {
271
- className: "fixed inset-0 bg-black/50 flex items-center justify-center z-50",
659
+ className: "fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-50",
272
660
  role: "dialog",
273
661
  onKeyDown: handleKeyDown,
274
662
  children: /* @__PURE__ */ jsxs("div", {
275
- className: "bg-white rounded-lg p-6 w-full max-w-md",
663
+ className: "bg-overlay rounded-lg p-6 w-full max-w-md",
276
664
  "data-testid": "create-folder-dialog",
277
665
  children: [
278
666
  /* @__PURE__ */ jsx("h2", {
279
- className: "text-xl font-semibold text-grey-01 mb-4",
667
+ className: "text-xl font-semibold text-grey-01 dark:text-grey-12 mb-4",
280
668
  children: "Create New Folder"
281
669
  }),
282
670
  /* @__PURE__ */ jsxs("div", {
283
671
  className: "mb-4",
284
672
  children: [/* @__PURE__ */ jsx("label", {
285
673
  htmlFor: "folder-name",
286
- className: "block text-sm font-medium text-grey-01 mb-2",
674
+ className: "block text-sm font-medium text-grey-01 dark:text-grey-12 mb-2",
287
675
  children: "Folder Name"
288
- }), /* @__PURE__ */ jsx("input", {
676
+ }), /* @__PURE__ */ jsx(Input, {
289
677
  ref: inputRef,
290
678
  id: "folder-name",
291
679
  type: "text",
292
680
  value: folderName,
293
681
  onChange: (e) => setFolderName(e.target.value),
294
682
  placeholder: "Enter folder name",
295
- className: "w-full px-3 py-2 border border-grey-09 rounded focus:outline-none focus:ring-2 focus:ring-azure-04",
296
683
  "data-testid": "folder-name-input"
297
684
  })]
298
685
  }),
299
686
  /* @__PURE__ */ jsxs("div", {
300
687
  className: "flex justify-end gap-3",
301
- children: [/* @__PURE__ */ jsx("button", {
302
- type: "button",
688
+ children: [/* @__PURE__ */ jsx(Button, {
689
+ variant: "outline",
303
690
  onClick: onClose,
304
- className: "px-4 py-2 border border-grey-09 rounded hover:bg-grey-11 transition-colors",
305
691
  children: "Cancel"
306
- }), /* @__PURE__ */ jsx("button", {
307
- type: "button",
692
+ }), /* @__PURE__ */ jsx(Button, {
693
+ variant: "primary",
308
694
  onClick: handleCreate,
309
695
  disabled: !isValid || isPending,
310
- className: "px-4 py-2 bg-azure-04 text-white rounded hover:bg-azure-03 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",
311
696
  "data-testid": "create-folder-submit",
312
697
  children: isPending ? "Creating..." : "Create"
313
698
  })]
@@ -325,9 +710,9 @@ function FolderNode({ node, depth, currentFolder, dropTargetFolder, onFolderSele
325
710
  return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("button", {
326
711
  type: "button",
327
712
  onClick: () => onFolderSelect(node.path),
328
- className: cn$1("w-full flex items-center gap-2 py-1.5 px-3 rounded text-sm transition-colors text-left", {
329
- "bg-azure-11 text-azure-01": isActive,
330
- "hover:bg-grey-11": !isActive,
713
+ className: cn("w-full flex items-center gap-2 py-1.5 px-3 rounded-md text-sm transition-colors text-left", {
714
+ "bg-azure-11 dark:bg-azure-03 text-azure-01 dark:text-azure-11": isActive,
715
+ "hover:bg-grey-11 dark:hover:bg-grey-03": !isActive,
331
716
  "ring-2 ring-azure-04": isDropTarget
332
717
  }),
333
718
  style: { paddingLeft: `${depth * 16 + 12}px` },
@@ -338,7 +723,7 @@ function FolderNode({ node, depth, currentFolder, dropTargetFolder, onFolderSele
338
723
  children: node.name
339
724
  }),
340
725
  /* @__PURE__ */ jsxs("span", {
341
- className: "text-grey-05 text-xs",
726
+ className: "text-grey-05 dark:text-grey-06 text-xs",
342
727
  children: [
343
728
  "(",
344
729
  node.assetCount,
@@ -368,33 +753,33 @@ function FolderTreeSidebar({ currentFolder, onFolderSelect, dropTargetFolder })
368
753
  };
369
754
  const rootAssetCount = rawTree.length === 1 && rawTree[0].path === "/" ? rawTree[0].assetCount : tree.reduce((sum, node) => sum + node.assetCount, 0);
370
755
  return /* @__PURE__ */ jsxs("div", {
371
- className: "w-56 flex-shrink-0 border-r border-grey-09 bg-white",
756
+ className: "w-56 flex-shrink-0 border-r border-grey-09 dark:border-grey-03 bg-white dark:bg-grey-02",
372
757
  children: [
373
758
  /* @__PURE__ */ jsxs("div", {
374
- className: "flex items-center justify-between px-4 py-3 border-b border-grey-09",
759
+ className: "flex items-center justify-between px-4 py-3 border-b border-grey-09 dark:border-grey-03",
375
760
  children: [/* @__PURE__ */ jsx("h3", {
376
- className: "font-semibold text-grey-01",
761
+ className: "font-semibold text-grey-01 dark:text-grey-12",
377
762
  children: "Folders"
378
763
  }), /* @__PURE__ */ jsx("button", {
379
764
  type: "button",
380
765
  onClick: () => setShowCreateFolderDialog(true),
381
- className: "p-1.5 rounded hover:bg-grey-11 transition-colors",
766
+ className: "p-1.5 rounded-md hover:bg-grey-11 dark:hover:bg-grey-03 transition-colors",
382
767
  title: "New Folder",
383
- children: /* @__PURE__ */ jsx(FolderPlus, { className: "w-4 h-4 text-grey-04" })
768
+ children: /* @__PURE__ */ jsx(FolderPlus, { className: "w-4 h-4 text-grey-04 dark:text-grey-07" })
384
769
  })]
385
770
  }),
386
771
  /* @__PURE__ */ jsx("div", {
387
772
  className: "p-2 overflow-y-auto",
388
773
  style: { maxHeight: "calc(100vh - 200px)" },
389
774
  children: isLoading ? /* @__PURE__ */ jsx("div", {
390
- className: "text-sm text-grey-05 px-3 py-2",
775
+ className: "text-sm text-grey-05 dark:text-grey-06 px-3 py-2",
391
776
  children: "Loading..."
392
777
  }) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("button", {
393
778
  type: "button",
394
779
  onClick: () => onFolderSelect("/"),
395
- className: cn$1("w-full flex items-center gap-2 py-1.5 px-3 rounded text-sm transition-colors text-left", {
396
- "bg-azure-11 text-azure-01": currentFolder === "/",
397
- "hover:bg-grey-11": currentFolder !== "/",
780
+ className: cn("w-full flex items-center gap-2 py-1.5 px-3 rounded-md text-sm transition-colors text-left", {
781
+ "bg-azure-11 dark:bg-azure-03 text-azure-01 dark:text-azure-11": currentFolder === "/",
782
+ "hover:bg-grey-11 dark:hover:bg-grey-03": currentFolder !== "/",
398
783
  "ring-2 ring-azure-04": dropTargetFolder === "/"
399
784
  }),
400
785
  children: [
@@ -404,7 +789,7 @@ function FolderTreeSidebar({ currentFolder, onFolderSelect, dropTargetFolder })
404
789
  children: "Root"
405
790
  }),
406
791
  /* @__PURE__ */ jsxs("span", {
407
- className: "text-grey-05 text-xs",
792
+ className: "text-grey-05 dark:text-grey-06 text-xs",
408
793
  children: [
409
794
  "(",
410
795
  rootAssetCount,
@@ -419,7 +804,7 @@ function FolderTreeSidebar({ currentFolder, onFolderSelect, dropTargetFolder })
419
804
  dropTargetFolder,
420
805
  onFolderSelect
421
806
  }, node.path)) : /* @__PURE__ */ jsx("div", {
422
- className: "text-sm text-grey-05 px-3 py-2",
807
+ className: "text-sm text-grey-05 dark:text-grey-06 px-3 py-2",
423
808
  children: "No folders yet"
424
809
  })] })
425
810
  }),
@@ -461,9 +846,9 @@ function AssetCard({ asset, isSelected, onClick, onDoubleClick, assetsBasePath =
461
846
  },
462
847
  role: "button",
463
848
  tabIndex: 0,
464
- className: cn$1("group relative rounded overflow-hidden cursor-pointer transition-colors", "bg-white hover:border-azure-04", isSelected ? "border-2 border-azure-04" : "border border-grey-09"),
849
+ className: cn("group relative rounded-md overflow-hidden cursor-pointer transition-colors", "bg-white dark:bg-grey-02 hover:border-azure-04", isSelected ? "border-2 border-azure-04" : "border border-grey-09 dark:border-grey-03"),
465
850
  children: [/* @__PURE__ */ jsx("div", {
466
- className: "aspect-square bg-grey-11 flex items-center justify-center overflow-hidden",
851
+ className: "aspect-square bg-grey-11 dark:bg-grey-03 flex items-center justify-center overflow-hidden",
467
852
  children: /* @__PURE__ */ jsx("img", {
468
853
  src: buildAssetServeUrl(assetsBasePath, asset.folder, asset.filename),
469
854
  alt: asset.alt || asset.originalName,
@@ -473,7 +858,7 @@ function AssetCard({ asset, isSelected, onClick, onDoubleClick, assetsBasePath =
473
858
  }), /* @__PURE__ */ jsx("div", {
474
859
  className: "px-2 py-1.5",
475
860
  children: /* @__PURE__ */ jsx("p", {
476
- className: "text-xs text-grey-01 truncate",
861
+ className: "text-xs text-grey-01 dark:text-grey-12 truncate",
477
862
  title: asset.originalName,
478
863
  children: asset.originalName
479
864
  })
@@ -488,19 +873,21 @@ function MediaToolbar({ search, onSearchChange, fileType, onFileTypeChange, sort
488
873
  className: "flex items-center gap-3 flex-wrap",
489
874
  children: [
490
875
  /* @__PURE__ */ jsxs("div", {
491
- className: "relative flex-1 min-w-[200px]",
492
- children: [/* @__PURE__ */ jsx(Search, { className: "absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-grey-04" }), /* @__PURE__ */ jsx("input", {
876
+ className: "relative flex-1 min-w-[150px]",
877
+ children: [/* @__PURE__ */ jsx(Search, { className: "absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-grey-04 dark:text-grey-07 z-10" }), /* @__PURE__ */ jsx(Input, {
878
+ size: "sm",
493
879
  type: "text",
494
880
  value: search,
495
881
  onChange: (e) => onSearchChange(e.target.value),
496
882
  placeholder: "Search files...",
497
- className: "w-full pl-9 pr-3 py-2 border border-grey-09 rounded text-sm focus:outline-none focus:ring-2 focus:ring-azure-04 focus:border-azure-04"
883
+ className: "pl-9"
498
884
  })]
499
885
  }),
500
- /* @__PURE__ */ jsxs("select", {
886
+ /* @__PURE__ */ jsxs(Select, {
887
+ size: "sm",
501
888
  value: fileType,
502
889
  onChange: (e) => onFileTypeChange(e.target.value),
503
- className: "px-3 py-2 border border-grey-09 rounded text-sm bg-white hover:bg-grey-11 transition-colors",
890
+ className: "w-auto shrink-0",
504
891
  children: [
505
892
  /* @__PURE__ */ jsx("option", {
506
893
  value: "all",
@@ -516,10 +903,11 @@ function MediaToolbar({ search, onSearchChange, fileType, onFileTypeChange, sort
516
903
  })
517
904
  ]
518
905
  }),
519
- /* @__PURE__ */ jsxs("select", {
906
+ /* @__PURE__ */ jsxs(Select, {
907
+ size: "sm",
520
908
  value: sort,
521
909
  onChange: (e) => onSortChange(e.target.value),
522
- className: "px-3 py-2 border border-grey-09 rounded text-sm bg-white hover:bg-grey-11 transition-colors",
910
+ className: "w-auto shrink-0",
523
911
  children: [
524
912
  /* @__PURE__ */ jsx("option", {
525
913
  value: "date-newest",
@@ -547,21 +935,22 @@ function MediaToolbar({ search, onSearchChange, fileType, onFileTypeChange, sort
547
935
  })
548
936
  ]
549
937
  }),
550
- isSelectMode ? /* @__PURE__ */ jsx("button", {
551
- type: "button",
938
+ isSelectMode ? /* @__PURE__ */ jsx(Button, {
939
+ variant: "primary",
940
+ size: "sm",
552
941
  onClick: onExitSelectMode,
553
- className: "px-3 py-2 bg-azure-04 text-white rounded text-sm hover:bg-azure-03 transition-colors",
554
942
  children: "Done"
555
- }) : onEnterSelectMode && /* @__PURE__ */ jsx("button", {
556
- type: "button",
943
+ }) : onEnterSelectMode && /* @__PURE__ */ jsx(Button, {
944
+ variant: "outline",
945
+ size: "sm",
557
946
  onClick: onEnterSelectMode,
558
- className: "px-3 py-2 border border-grey-09 rounded text-sm bg-white hover:bg-grey-11 transition-colors",
559
947
  children: "Select"
560
948
  }),
561
- onUploadClick && /* @__PURE__ */ jsxs("button", {
562
- type: "button",
949
+ onUploadClick && /* @__PURE__ */ jsxs(Button, {
950
+ variant: "primary",
951
+ size: "sm",
563
952
  onClick: onUploadClick,
564
- className: "flex items-center gap-2 px-3 py-2 bg-azure-04 text-white rounded text-sm hover:bg-azure-03 transition-colors",
953
+ className: "flex items-center gap-2",
565
954
  children: [/* @__PURE__ */ jsx(Upload, { className: "w-4 h-4" }), "Upload"]
566
955
  })
567
956
  ]
@@ -676,39 +1065,12 @@ function MediaLibrary({ folder: initialFolder = "/", onFolderChange, showToolbar
676
1065
 
677
1066
  //#endregion
678
1067
  //#region src/components/media/UploadModal.tsx
679
- const ACCEPTED_TYPES = "image/jpeg,image/png,image/gif,image/webp,image/svg+xml,image/avif";
680
1068
  function UploadModal({ isOpen, onClose, folder, onUploadComplete }) {
681
- const [activeTab, setActiveTab] = useState("file");
682
- const [isDragOver, setIsDragOver] = useState(false);
683
- const [pendingFile, setPendingFile] = useState(null);
684
- const [altText, setAltText] = useState("");
685
- const [customName, setCustomName] = useState("");
686
- const [importUrl, setImportUrl] = useState("");
687
- const [uploadProgress, setUploadProgress] = useState(null);
688
- const fileInputRef = useRef(null);
689
- const uploadMutation = useUploadAsset();
690
- const importMutation = useImportAssetUrl();
691
- const previewUrl = useMemo(() => {
692
- if (!pendingFile) return null;
693
- return URL.createObjectURL(pendingFile);
694
- }, [pendingFile]);
695
- useEffect(() => {
696
- return () => {
697
- if (previewUrl) URL.revokeObjectURL(previewUrl);
698
- };
699
- }, [previewUrl]);
700
- const isUploading = uploadMutation.isPending || importMutation.isPending || (uploadProgress?.inProgress ?? false);
701
- const error = uploadMutation.error || importMutation.error;
702
- const resetState = useCallback(() => {
703
- setPendingFile(null);
704
- setAltText("");
705
- setCustomName("");
706
- setImportUrl("");
707
- setUploadProgress(null);
708
- setActiveTab("file");
709
- setIsDragOver(false);
710
- if (fileInputRef.current) fileInputRef.current.value = "";
711
- }, []);
1069
+ const { activeTab, setActiveTab, isDragOver, pendingFile, altText, setAltText, importUrl, setImportUrl, uploadProgress, fileInputRef, previewUrl, isUploading, error, uploadMutationIsPending, importMutationIsPending, handleFiles, handleDragOver, handleDragLeave, handleDrop, handleUpload, handleImportUrl, handleCancel, reset } = useUploadFlow({
1070
+ folder,
1071
+ onUploadComplete,
1072
+ onSuccess: onClose
1073
+ });
712
1074
  useEffect(() => {
713
1075
  if (!isOpen) return;
714
1076
  const handleKeyDown = (e) => {
@@ -718,110 +1080,27 @@ function UploadModal({ isOpen, onClose, folder, onUploadComplete }) {
718
1080
  return () => document.removeEventListener("keydown", handleKeyDown);
719
1081
  }, [isOpen, onClose]);
720
1082
  useEffect(() => {
721
- if (!isOpen) resetState();
722
- }, [isOpen, resetState]);
723
- const handleSingleFile = useCallback((file) => {
724
- setPendingFile(file);
725
- setAltText("");
726
- setCustomName("");
727
- }, []);
728
- const handleMultipleFiles = useCallback(async (files) => {
729
- if (files.length === 0) return;
730
- if (files.length === 1) {
731
- handleSingleFile(files[0]);
732
- return;
733
- }
734
- setUploadProgress({
735
- total: files.length,
736
- completed: 0,
737
- failed: 0,
738
- inProgress: true
739
- });
740
- const uploadPromises = files.map(async (file) => {
741
- const formData = await buildUploadFormData(file, void 0, folder);
742
- return uploadMutation.mutateAsync(formData);
743
- });
744
- const results = await Promise.allSettled(uploadPromises);
745
- const completed = results.filter((r) => r.status === "fulfilled").length;
746
- const failed = results.filter((r) => r.status === "rejected").length;
747
- setUploadProgress({
748
- total: files.length,
749
- completed,
750
- failed,
751
- inProgress: false
752
- });
753
- setTimeout(() => {
754
- if (completed > 0) onUploadComplete?.();
755
- onClose();
756
- }, 2e3);
757
- }, [
758
- folder,
759
- uploadMutation,
760
- handleSingleFile,
761
- onUploadComplete,
762
- onClose
763
- ]);
764
- const handleFiles = useCallback((fileList) => {
765
- if (!fileList || fileList.length === 0) return;
766
- handleMultipleFiles(Array.from(fileList));
767
- }, [handleMultipleFiles]);
768
- const handleDragOver = useCallback((e) => {
769
- e.preventDefault();
770
- setIsDragOver(true);
771
- }, []);
772
- const handleDragLeave = useCallback((e) => {
773
- e.preventDefault();
774
- setIsDragOver(false);
775
- }, []);
776
- const handleDrop = useCallback((e) => {
777
- e.preventDefault();
778
- setIsDragOver(false);
779
- handleFiles(e.dataTransfer.files);
780
- }, [handleFiles]);
781
- const handleUpload = async () => {
782
- if (!pendingFile) return;
783
- const formData = await buildUploadFormData(pendingFile, altText || void 0, folder);
784
- uploadMutation.mutate(formData, { onSuccess: () => {
785
- onUploadComplete?.();
786
- onClose();
787
- } });
788
- };
789
- const handleImportUrl = () => {
790
- if (!importUrl.trim()) return;
791
- importMutation.mutate({
792
- url: importUrl.trim(),
793
- alt: altText || void 0,
794
- folder
795
- }, { onSuccess: () => {
796
- onUploadComplete?.();
797
- onClose();
798
- } });
799
- };
800
- const handleCancel = () => {
801
- setPendingFile(null);
802
- setAltText("");
803
- setCustomName("");
804
- if (fileInputRef.current) fileInputRef.current.value = "";
805
- };
1083
+ if (!isOpen) reset();
1084
+ }, [isOpen, reset]);
806
1085
  if (!isOpen) return null;
807
1086
  return /* @__PURE__ */ jsx("div", {
808
- className: "fixed inset-0 bg-black/50 flex items-center justify-center z-50",
1087
+ className: "fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-50",
809
1088
  onClick: (e) => {
810
1089
  if (e.target === e.currentTarget) onClose();
811
1090
  },
812
1091
  children: /* @__PURE__ */ jsxs("div", {
813
- className: "bg-white rounded-lg w-full max-w-md mx-4 shadow-xl",
1092
+ className: "bg-overlay rounded-lg w-full max-w-md mx-4 shadow-xl",
814
1093
  children: [
815
1094
  /* @__PURE__ */ jsxs("div", {
816
- className: "flex items-center justify-between px-6 py-4 border-b border-grey-09",
1095
+ className: "flex items-center justify-between px-6 py-4 border-b border-line",
817
1096
  children: [/* @__PURE__ */ jsx("h2", {
818
- className: "text-lg font-semibold text-grey-01",
1097
+ className: "text-lg font-semibold text-grey-01 dark:text-grey-12",
819
1098
  children: "Upload Assets"
820
- }), /* @__PURE__ */ jsx("button", {
821
- type: "button",
1099
+ }), /* @__PURE__ */ jsx(IconButton, {
1100
+ icon: X,
1101
+ ariaLabel: "Close",
822
1102
  onClick: onClose,
823
- className: "p-1 text-grey-04 hover:text-grey-01 transition-colors rounded hover:bg-grey-11",
824
- children: /* @__PURE__ */ jsx(X, { className: "w-5 h-5" })
1103
+ variant: "ghost"
825
1104
  })]
826
1105
  }),
827
1106
  /* @__PURE__ */ jsxs("div", {
@@ -829,23 +1108,23 @@ function UploadModal({ isOpen, onClose, folder, onUploadComplete }) {
829
1108
  children: [
830
1109
  /* @__PURE__ */ jsxs("div", {
831
1110
  className: "flex gap-2 mb-4",
832
- children: [/* @__PURE__ */ jsx("button", {
833
- type: "button",
1111
+ children: [/* @__PURE__ */ jsx(Button, {
1112
+ variant: activeTab === "file" ? "primary" : "outline",
1113
+ size: "sm",
834
1114
  onClick: () => setActiveTab("file"),
835
- className: cn$1("px-3 py-1.5 text-sm rounded transition-colors", activeTab === "file" ? "bg-azure-04 text-white" : "bg-white border border-grey-09 text-grey-04 hover:bg-grey-11"),
836
1115
  children: "Upload File"
837
- }), /* @__PURE__ */ jsx("button", {
838
- type: "button",
1116
+ }), /* @__PURE__ */ jsx(Button, {
1117
+ variant: activeTab === "url" ? "primary" : "outline",
1118
+ size: "sm",
839
1119
  onClick: () => setActiveTab("url"),
840
- className: cn$1("px-3 py-1.5 text-sm rounded transition-colors", activeTab === "url" ? "bg-azure-04 text-white" : "bg-white border border-grey-09 text-grey-04 hover:bg-grey-11"),
841
1120
  children: "Import URL"
842
1121
  })]
843
1122
  }),
844
1123
  activeTab === "file" && /* @__PURE__ */ jsxs(Fragment, { children: [uploadProgress && /* @__PURE__ */ jsxs("div", {
845
- className: "mb-4 p-3 bg-grey-11 rounded border border-grey-09",
1124
+ className: "mb-4 p-3 bg-subtle rounded-md border border-line",
846
1125
  children: [
847
1126
  /* @__PURE__ */ jsx("p", {
848
- className: "text-sm font-medium text-grey-01",
1127
+ className: "text-sm font-medium text-grey-01 dark:text-grey-12",
849
1128
  children: uploadProgress.inProgress ? `Uploading ${uploadProgress.total} files...` : `Upload complete: ${uploadProgress.completed}/${uploadProgress.total} succeeded`
850
1129
  }),
851
1130
  uploadProgress.failed > 0 && /* @__PURE__ */ jsxs("p", {
@@ -853,73 +1132,51 @@ function UploadModal({ isOpen, onClose, folder, onUploadComplete }) {
853
1132
  children: [uploadProgress.failed, " file(s) failed to upload"]
854
1133
  }),
855
1134
  /* @__PURE__ */ jsx("div", {
856
- className: "mt-2 h-2 bg-grey-09 rounded overflow-hidden",
1135
+ className: "mt-2 h-2 bg-grey-09 rounded-md overflow-hidden",
857
1136
  children: /* @__PURE__ */ jsx("div", {
858
- className: cn$1("h-full transition-all", uploadProgress.failed > 0 ? "bg-yellow-06" : "bg-azure-04"),
1137
+ className: cn("h-full transition-all", uploadProgress.failed > 0 ? "bg-yellow-06" : "bg-azure-04"),
859
1138
  style: { width: `${(uploadProgress.completed + uploadProgress.failed) / uploadProgress.total * 100}%` }
860
1139
  })
861
1140
  })
862
1141
  ]
863
1142
  }), pendingFile ? /* @__PURE__ */ jsxs("div", {
864
1143
  className: "space-y-4",
865
- children: [
866
- /* @__PURE__ */ jsxs("div", {
867
- className: "flex items-center gap-3",
868
- children: [/* @__PURE__ */ jsx("div", {
869
- className: "w-16 h-16 bg-grey-09 rounded overflow-hidden flex-shrink-0",
870
- children: /* @__PURE__ */ jsx("img", {
871
- src: previewUrl,
872
- alt: "Preview",
873
- className: "w-full h-full object-contain"
874
- })
875
- }), /* @__PURE__ */ jsxs("div", {
876
- className: "flex-1 min-w-0",
877
- children: [/* @__PURE__ */ jsx("p", {
878
- className: "text-sm font-medium text-grey-01 truncate",
879
- children: pendingFile.name
880
- }), /* @__PURE__ */ jsxs("p", {
881
- className: "text-xs text-grey-04",
882
- children: [(pendingFile.size / 1024).toFixed(1), " KB"]
883
- })]
884
- })]
885
- }),
886
- /* @__PURE__ */ jsxs("div", { children: [
887
- /* @__PURE__ */ jsx("label", {
888
- htmlFor: "custom-name",
889
- className: "block text-xs text-grey-04 uppercase tracking-wide mb-1",
890
- children: "Asset Name (optional)"
891
- }),
892
- /* @__PURE__ */ jsx("input", {
893
- id: "custom-name",
894
- type: "text",
895
- value: customName,
896
- onChange: (e) => setCustomName(e.target.value),
897
- placeholder: pendingFile.name,
898
- className: "w-full px-3 py-2 border border-grey-09 rounded text-sm focus:outline-none focus:ring-2 focus:ring-azure-04 focus:border-azure-04"
899
- }),
900
- /* @__PURE__ */ jsx("p", {
901
- className: "mt-1 text-xs text-grey-07",
902
- children: "Leave blank to use original filename"
1144
+ children: [/* @__PURE__ */ jsxs("div", {
1145
+ className: "flex items-center gap-3",
1146
+ children: [/* @__PURE__ */ jsx("div", {
1147
+ className: "w-16 h-16 bg-grey-09 rounded-md overflow-hidden flex-shrink-0",
1148
+ children: /* @__PURE__ */ jsx("img", {
1149
+ src: previewUrl,
1150
+ alt: "Preview",
1151
+ className: "w-full h-full object-contain"
903
1152
  })
904
- ] }),
905
- /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("label", {
906
- htmlFor: "alt-text",
907
- className: "block text-xs text-grey-04 uppercase tracking-wide mb-1",
908
- children: "Alt Text"
909
- }), /* @__PURE__ */ jsx("input", {
910
- id: "alt-text",
911
- type: "text",
912
- value: altText,
913
- onChange: (e) => setAltText(e.target.value),
914
- placeholder: "Describe the image for accessibility",
915
- className: "w-full px-3 py-2 border border-grey-09 rounded text-sm focus:outline-none focus:ring-2 focus:ring-azure-04 focus:border-azure-04"
916
- })] })
917
- ]
1153
+ }), /* @__PURE__ */ jsxs("div", {
1154
+ className: "flex-1 min-w-0",
1155
+ children: [/* @__PURE__ */ jsx("p", {
1156
+ className: "text-sm font-medium text-grey-01 dark:text-grey-12 truncate",
1157
+ children: pendingFile.name
1158
+ }), /* @__PURE__ */ jsxs("p", {
1159
+ className: "text-xs text-grey-04 dark:text-grey-07",
1160
+ children: [(pendingFile.size / 1024).toFixed(1), " KB"]
1161
+ })]
1162
+ })]
1163
+ }), /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("label", {
1164
+ htmlFor: "alt-text",
1165
+ className: "block text-xs text-grey-04 dark:text-grey-07 uppercase tracking-wide mb-1",
1166
+ children: "Alt Text"
1167
+ }), /* @__PURE__ */ jsx(Input, {
1168
+ size: "sm",
1169
+ id: "alt-text",
1170
+ type: "text",
1171
+ value: altText,
1172
+ onChange: (e) => setAltText(e.target.value),
1173
+ placeholder: "Describe the image for accessibility"
1174
+ })] })]
918
1175
  }) : /* @__PURE__ */ jsxs("div", {
919
1176
  onDragOver: handleDragOver,
920
1177
  onDragLeave: handleDragLeave,
921
1178
  onDrop: handleDrop,
922
- className: cn$1("border-2 border-dashed rounded-lg p-8 text-center cursor-pointer transition-colors bg-grey-11", isDragOver ? "border-azure-04 bg-azure-11" : "border-grey-09 hover:border-grey-07"),
1179
+ className: cn("border-2 border-dashed rounded-lg p-8 text-center cursor-pointer transition-colors bg-subtle", isDragOver ? "border-azure-04 bg-azure-11 dark:bg-azure-02" : "border-line hover:border-grey-07"),
923
1180
  onClick: () => fileInputRef.current?.click(),
924
1181
  onKeyDown: (e) => {
925
1182
  if (e.key === "Enter" || e.key === " ") {
@@ -930,9 +1187,9 @@ function UploadModal({ isOpen, onClose, folder, onUploadComplete }) {
930
1187
  role: "button",
931
1188
  tabIndex: 0,
932
1189
  children: [
933
- /* @__PURE__ */ jsx(Upload, { className: "mx-auto h-10 w-10 text-grey-04" }),
1190
+ /* @__PURE__ */ jsx(Upload, { className: "mx-auto h-10 w-10 text-grey-04 dark:text-grey-07" }),
934
1191
  /* @__PURE__ */ jsx("p", {
935
- className: "mt-2 text-sm text-grey-04",
1192
+ className: "mt-2 text-sm text-grey-04 dark:text-grey-07",
936
1193
  children: "Drag and drop images here, or click to browse"
937
1194
  }),
938
1195
  /* @__PURE__ */ jsx("p", {
@@ -953,26 +1210,26 @@ function UploadModal({ isOpen, onClose, folder, onUploadComplete }) {
953
1210
  className: "space-y-4",
954
1211
  children: [/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("label", {
955
1212
  htmlFor: "import-url",
956
- className: "block text-xs text-grey-04 uppercase tracking-wide mb-1",
1213
+ className: "block text-xs text-grey-04 dark:text-grey-07 uppercase tracking-wide mb-1",
957
1214
  children: "Image URL"
958
- }), /* @__PURE__ */ jsx("input", {
1215
+ }), /* @__PURE__ */ jsx(Input, {
1216
+ size: "sm",
959
1217
  id: "import-url",
960
1218
  type: "url",
961
1219
  value: importUrl,
962
1220
  onChange: (e) => setImportUrl(e.target.value),
963
- placeholder: "https://example.com/image.jpg",
964
- className: "w-full px-3 py-2 border border-grey-09 rounded text-sm focus:outline-none focus:ring-2 focus:ring-azure-04 focus:border-azure-04"
1221
+ placeholder: "https://example.com/image.jpg"
965
1222
  })] }), /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("label", {
966
1223
  htmlFor: "url-alt-text",
967
- className: "block text-xs text-grey-04 uppercase tracking-wide mb-1",
1224
+ className: "block text-xs text-grey-04 dark:text-grey-07 uppercase tracking-wide mb-1",
968
1225
  children: "Alt Text"
969
- }), /* @__PURE__ */ jsx("input", {
1226
+ }), /* @__PURE__ */ jsx(Input, {
1227
+ size: "sm",
970
1228
  id: "url-alt-text",
971
1229
  type: "text",
972
1230
  value: altText,
973
1231
  onChange: (e) => setAltText(e.target.value),
974
- placeholder: "Describe the image for accessibility",
975
- className: "w-full px-3 py-2 border border-grey-09 rounded text-sm focus:outline-none focus:ring-2 focus:ring-azure-04 focus:border-azure-04"
1232
+ placeholder: "Describe the image for accessibility"
976
1233
  })] })]
977
1234
  }),
978
1235
  error && /* @__PURE__ */ jsx("p", {
@@ -982,25 +1239,27 @@ function UploadModal({ isOpen, onClose, folder, onUploadComplete }) {
982
1239
  ]
983
1240
  }),
984
1241
  /* @__PURE__ */ jsxs("div", {
985
- className: "flex items-center justify-end gap-3 px-6 py-4 border-t border-grey-09 bg-grey-11 rounded-b-lg",
986
- children: [/* @__PURE__ */ jsx("button", {
987
- type: "button",
1242
+ className: "flex items-center justify-end gap-3 px-6 py-4 border-t border-line bg-subtle rounded-b-lg",
1243
+ children: [/* @__PURE__ */ jsx(Button, {
1244
+ variant: "outline",
1245
+ size: "sm",
988
1246
  onClick: pendingFile ? handleCancel : onClose,
989
1247
  disabled: isUploading,
990
- className: "px-4 py-2 bg-white border border-grey-09 text-grey-04 text-sm rounded hover:bg-grey-11 disabled:opacity-50 transition-colors",
991
1248
  children: pendingFile ? "Clear" : "Cancel"
992
- }), activeTab === "file" ? /* @__PURE__ */ jsxs("button", {
993
- type: "button",
1249
+ }), activeTab === "file" ? /* @__PURE__ */ jsxs(Button, {
1250
+ variant: "primary",
1251
+ size: "sm",
994
1252
  onClick: handleUpload,
995
1253
  disabled: isUploading || !pendingFile,
996
- className: "flex items-center gap-2 px-4 py-2 bg-azure-04 text-white text-sm rounded hover:bg-azure-03 disabled:opacity-50 transition-colors",
997
- children: [/* @__PURE__ */ jsx(Upload, { className: "w-4 h-4" }), uploadMutation.isPending ? "Uploading..." : "Upload"]
998
- }) : /* @__PURE__ */ jsxs("button", {
999
- type: "button",
1254
+ className: "flex items-center gap-2",
1255
+ children: [/* @__PURE__ */ jsx(Upload, { className: "w-4 h-4" }), uploadMutationIsPending ? "Uploading..." : "Upload"]
1256
+ }) : /* @__PURE__ */ jsxs(Button, {
1257
+ variant: "primary",
1258
+ size: "sm",
1000
1259
  onClick: handleImportUrl,
1001
1260
  disabled: isUploading || !importUrl.trim(),
1002
- className: "flex items-center gap-2 px-4 py-2 bg-azure-04 text-white text-sm rounded hover:bg-azure-03 disabled:opacity-50 transition-colors",
1003
- children: [/* @__PURE__ */ jsx(Upload, { className: "w-4 h-4" }), importMutation.isPending ? "Importing..." : "Import"]
1261
+ className: "flex items-center gap-2",
1262
+ children: [/* @__PURE__ */ jsx(Upload, { className: "w-4 h-4" }), importMutationIsPending ? "Importing..." : "Import"]
1004
1263
  })]
1005
1264
  })
1006
1265
  ]
@@ -1034,28 +1293,28 @@ function ImagePicker({ isOpen, onSelect, onClose }) {
1034
1293
  if (e.target === e.currentTarget) onClose();
1035
1294
  };
1036
1295
  return /* @__PURE__ */ jsxs("div", {
1037
- className: "fixed inset-0 z-50 flex items-center justify-center bg-black/50",
1296
+ className: "fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",
1038
1297
  onClick: handleBackdropClick,
1039
1298
  children: [/* @__PURE__ */ jsxs("div", {
1040
- className: "bg-white rounded-lg shadow-xl w-full max-w-5xl max-h-[85vh] mx-4 flex flex-col overflow-hidden",
1299
+ className: "bg-overlay rounded-lg shadow-xl w-full max-w-5xl max-h-[85vh] mx-4 flex flex-col overflow-hidden",
1041
1300
  children: [/* @__PURE__ */ jsxs("div", {
1042
- className: "flex items-center justify-between px-6 py-4 border-b border-grey-09 flex-shrink-0",
1301
+ className: "flex items-center justify-between px-6 py-4 border-b border-line flex-shrink-0",
1043
1302
  children: [/* @__PURE__ */ jsx("h2", {
1044
- className: "text-lg font-semibold text-grey-01",
1303
+ className: "text-lg font-semibold text-grey-01 dark:text-grey-12",
1045
1304
  children: "Select Image"
1046
1305
  }), /* @__PURE__ */ jsxs("div", {
1047
1306
  className: "flex items-center gap-2",
1048
- children: [/* @__PURE__ */ jsxs("button", {
1049
- type: "button",
1307
+ children: [/* @__PURE__ */ jsxs(Button, {
1308
+ variant: "primary",
1309
+ size: "sm",
1050
1310
  onClick: () => setShowUpload(true),
1051
- className: "flex items-center gap-2 px-3 py-1.5 text-sm bg-azure-04 text-white rounded hover:bg-azure-03 transition-colors",
1311
+ className: "flex items-center gap-2",
1052
1312
  children: [/* @__PURE__ */ jsx(Upload, { className: "w-4 h-4" }), "Upload"]
1053
- }), /* @__PURE__ */ jsx("button", {
1054
- type: "button",
1313
+ }), /* @__PURE__ */ jsx(IconButton, {
1314
+ icon: X,
1315
+ ariaLabel: "Close",
1055
1316
  onClick: onClose,
1056
- className: "p-1.5 text-grey-04 hover:text-grey-01 transition-colors rounded hover:bg-grey-11",
1057
- "aria-label": "Close",
1058
- children: /* @__PURE__ */ jsx(X, { className: "w-5 h-5" })
1317
+ variant: "ghost"
1059
1318
  })]
1060
1319
  })]
1061
1320
  }), /* @__PURE__ */ jsxs("div", {
@@ -1108,281 +1367,85 @@ function ImagePickerDialog() {
1108
1367
 
1109
1368
  //#endregion
1110
1369
  //#region src/components/editor/CMSMDXEditor.tsx
1111
- /**
1112
- * Error Boundary for catching React errors in MDXEditor.
1113
- * Prevents editor crashes from breaking the entire CMS.
1114
- */
1115
- var MDXEditorErrorBoundary = class extends React.Component {
1116
- constructor(props) {
1117
- super(props);
1118
- this.state = { hasError: false };
1119
- }
1120
- static getDerivedStateFromError(error) {
1121
- return {
1122
- hasError: true,
1123
- error
1124
- };
1125
- }
1126
- componentDidCatch(error, errorInfo) {
1127
- console.error("[CMSMDXEditor] Error boundary caught:", error, errorInfo);
1128
- }
1129
- render() {
1130
- if (this.state.hasError) return /* @__PURE__ */ jsxs("div", {
1131
- className: "p-4 bg-red-50 border border-red-200 rounded text-red-600",
1132
- children: [
1133
- /* @__PURE__ */ jsx("p", {
1134
- className: "font-semibold mb-2",
1135
- children: "MDXEditor Error"
1136
- }),
1137
- /* @__PURE__ */ jsx("p", {
1138
- className: "text-sm mb-2",
1139
- children: this.state.error?.message || "Unknown error occurred"
1140
- }),
1141
- /* @__PURE__ */ jsxs("details", {
1142
- className: "text-xs",
1143
- children: [/* @__PURE__ */ jsx("summary", {
1144
- className: "cursor-pointer font-medium",
1145
- children: "Stack Trace"
1146
- }), /* @__PURE__ */ jsx("pre", {
1147
- className: "mt-2 p-2 bg-red-100 rounded overflow-auto whitespace-pre-wrap",
1148
- children: this.state.error?.stack
1149
- })]
1150
- })
1151
- ]
1152
- });
1153
- return this.props.children;
1154
- }
1155
- };
1156
- /**
1157
- * CMS-integrated MDX Editor with Media Library image picker.
1158
- * This component wraps MDXEditor with ImagePickerDialog and keyboard shortcuts.
1159
- */
1160
- const CMSMDXEditor = React.forwardRef(({ value, onChange, onSave, readOnly = false }, ref) => {
1161
- useEffect(() => {
1162
- const handleKeyDown = (e) => {
1163
- if ((e.ctrlKey || e.metaKey) && e.key === "s") {
1164
- e.preventDefault();
1165
- if (onSave) onSave(value);
1166
- }
1167
- if ((e.ctrlKey || e.metaKey) && e.shiftKey && e.key.toLowerCase() === "i") {
1168
- e.preventDefault();
1169
- document.querySelector("[aria-label=\"Insert image\"]")?.click();
1170
- }
1171
- };
1172
- document.addEventListener("keydown", handleKeyDown);
1173
- return () => document.removeEventListener("keydown", handleKeyDown);
1174
- }, [value, onSave]);
1175
- return /* @__PURE__ */ jsx(MDXEditor, {
1370
+ const CMSMDXEditor = forwardRef((props, ref) => {
1371
+ const insertImageRef = useRef(null);
1372
+ return /* @__PURE__ */ jsx(BaseMDXEditor, {
1176
1373
  ref,
1177
- markdown: value,
1178
- onChange,
1179
- readOnly,
1180
- contentEditableClassName: "prose max-w-none",
1181
- plugins: [
1182
- headingsPlugin(),
1183
- listsPlugin(),
1184
- quotePlugin(),
1185
- linkPlugin(),
1186
- linkDialogPlugin(),
1187
- tablePlugin(),
1188
- thematicBreakPlugin(),
1189
- frontmatterPlugin(),
1190
- codeBlockPlugin({ defaultCodeBlockLanguage: "ts" }),
1191
- codeMirrorPlugin({ codeBlockLanguages: {
1192
- text: "Plain Text",
1193
- js: "JavaScript",
1194
- jsx: "JavaScript (React)",
1195
- ts: "TypeScript",
1196
- tsx: "TypeScript (React)",
1197
- css: "CSS",
1198
- html: "HTML",
1199
- json: "JSON",
1200
- md: "Markdown",
1201
- mdx: "MDX",
1202
- bash: "Bash",
1203
- python: "Python"
1204
- } }),
1205
- diffSourcePlugin({ viewMode: "rich-text" }),
1206
- markdownShortcutPlugin(),
1207
- jsxPlugin(),
1208
- imagePlugin({
1209
- ImageDialog: ImagePickerDialog,
1210
- disableImageSettingsButton: true
1211
- }),
1212
- toolbarPlugin({ toolbarContents: () => /* @__PURE__ */ jsxs(DiffSourceToggleWrapper, { children: [
1213
- /* @__PURE__ */ jsx(UndoRedo, {}),
1214
- /* @__PURE__ */ jsx(Separator, {}),
1215
- /* @__PURE__ */ jsx(BoldItalicUnderlineToggles, {}),
1216
- /* @__PURE__ */ jsx(Separator, {}),
1217
- /* @__PURE__ */ jsx(ListsToggle, {}),
1218
- /* @__PURE__ */ jsx(Separator, {}),
1219
- /* @__PURE__ */ jsx(BlockTypeSelect, {}),
1220
- /* @__PURE__ */ jsx(Separator, {}),
1221
- /* @__PURE__ */ jsx(CreateLink, {}),
1222
- /* @__PURE__ */ jsx(InsertImage, {}),
1223
- /* @__PURE__ */ jsx(InsertTable, {}),
1224
- /* @__PURE__ */ jsx(InsertThematicBreak, {}),
1225
- /* @__PURE__ */ jsx(Separator, {}),
1226
- /* @__PURE__ */ jsx(InsertCodeBlock, {})
1227
- ] }) })
1228
- ]
1374
+ ...props,
1375
+ imageDialog: ImagePickerDialog,
1376
+ disableImageSettingsButton: true,
1377
+ imageButtonRef: insertImageRef,
1378
+ onImageShortcut: () => {
1379
+ if (insertImageRef.current) {
1380
+ insertImageRef.current.click();
1381
+ return;
1382
+ }
1383
+ console.warn("[CMSMDXEditor] InsertImage ref not attached - toolbar may not be rendered");
1384
+ }
1229
1385
  });
1230
1386
  });
1231
1387
  CMSMDXEditor.displayName = "CMSMDXEditor";
1232
- /**
1233
- * DeferredCMSMDXEditor - A wrapper component that defers CMSMDXEditor initialization
1234
- * to avoid React 19 render-phase state updates.
1235
- *
1236
- * See the original DeferredMDXEditor in @conloca/mdx for detailed documentation.
1237
- */
1238
- const DeferredCMSMDXEditor = ({ value, onChange, onSave, readOnly }) => {
1239
- const editorRef = React.useRef(null);
1240
- const [isReady, setIsReady] = useState(false);
1241
- useEffect(() => {
1242
- const timer = setTimeout(() => {
1243
- setIsReady(true);
1244
- }, 10);
1245
- return () => clearTimeout(timer);
1246
- }, []);
1247
- if (!isReady) return /* @__PURE__ */ jsx("div", {
1248
- className: "flex items-center justify-center h-full text-gray-500",
1249
- "data-testid": "deferred-editor-loading",
1250
- children: "Initializing editor..."
1251
- });
1252
- return /* @__PURE__ */ jsx("div", {
1253
- "data-testid": "deferred-editor-ready",
1254
- children: /* @__PURE__ */ jsx(CMSMDXEditor, {
1255
- ref: editorRef,
1256
- value,
1257
- onChange,
1258
- onSave,
1259
- readOnly
1260
- })
1261
- });
1262
- };
1263
- const Dialog = ({ open, onOpenChange, children }) => {
1264
- if (!open) return null;
1265
- return /* @__PURE__ */ jsxs("div", {
1266
- className: "fixed inset-0 z-50 flex items-center justify-center",
1267
- children: [/* @__PURE__ */ jsx("div", {
1268
- className: "fixed inset-0 bg-black/50",
1269
- onClick: () => onOpenChange(false)
1270
- }), /* @__PURE__ */ jsx("div", {
1271
- className: "relative z-50 bg-white rounded-lg shadow-lg max-w-[90vw] max-h-[90vh] overflow-hidden",
1272
- children
1273
- })]
1274
- });
1275
- };
1276
- const DialogContent = ({ children, className = "" }) => {
1277
- return /* @__PURE__ */ jsx("div", {
1278
- className: `p-6 ${className}`,
1279
- children
1280
- });
1281
- };
1282
- const DialogHeader = ({ children }) => {
1283
- return /* @__PURE__ */ jsx("div", {
1284
- className: "mb-4",
1285
- children
1286
- });
1287
- };
1288
- const DialogTitle = ({ children }) => {
1289
- return /* @__PURE__ */ jsx("h2", {
1290
- className: "text-xl font-semibold",
1291
- children
1292
- });
1293
- };
1294
- /**
1295
- * Modal wrapper for CMSMDXEditor with integrated Media Library image picker.
1296
- * Use this instead of MDXEditorModal from @conloca/mdx when you need the image picker.
1297
- */
1298
- const CMSMDXEditorModal = ({ isOpen, onClose, filePath, initialContent, onSave, headerExtra, onBeforeClose }) => {
1299
- const [content, setContent] = useState(initialContent);
1300
- const [isEditorReady, setIsEditorReady] = useState(false);
1301
- const [isSaving, setIsSaving] = useState(false);
1302
- useEffect(() => {
1303
- setContent(initialContent);
1304
- }, [initialContent]);
1305
- const handleClose = () => {
1306
- if (onBeforeClose && !onBeforeClose()) return;
1307
- onClose();
1308
- };
1309
- useEffect(() => {
1310
- if (isOpen) {
1311
- const timer = setTimeout(() => {
1312
- setIsEditorReady(true);
1313
- }, 0);
1314
- return () => clearTimeout(timer);
1315
- }
1316
- setIsEditorReady(false);
1317
- }, [isOpen]);
1318
- const handleSave = async () => {
1319
- setIsSaving(true);
1320
- try {
1321
- await onSave(content);
1322
- handleClose();
1323
- } catch (error) {
1324
- console.error("Save failed:", error);
1325
- } finally {
1326
- setIsSaving(false);
1327
- }
1388
+ function CMSMDXHeaderTools({ setContent, editorRef, filePath, initialTemplateId }) {
1389
+ const [selectedSnippetId, setSelectedSnippetId] = useState(contentBlockSnippets[0]?.id || "");
1390
+ const selectedTemplate = useMemo(() => getContentBlockTemplate(initialTemplateId), [initialTemplateId]);
1391
+ const handleInsertSnippet = () => {
1392
+ const snippet = contentBlockSnippets.find((item) => item.id === selectedSnippetId);
1393
+ if (!snippet) return;
1394
+ setContent((current) => {
1395
+ const trimmed = current.trimEnd();
1396
+ const newContent = trimmed ? `${trimmed}\n\n${snippet.content}` : snippet.content;
1397
+ editorRef.current?.setMarkdown(newContent);
1398
+ return newContent;
1399
+ });
1328
1400
  };
1329
- if (!isOpen) return null;
1330
- return /* @__PURE__ */ jsx(Dialog, {
1331
- open: isOpen,
1332
- onOpenChange: handleClose,
1333
- children: /* @__PURE__ */ jsxs(DialogContent, {
1334
- className: "w-[90vw] h-[90vh] flex flex-col",
1335
- "data-testid": "mdx-editor-modal",
1336
- children: [
1337
- /* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsxs("div", {
1338
- className: "flex items-center justify-between gap-4",
1339
- children: [
1340
- /* @__PURE__ */ jsx(DialogTitle, { children: filePath ? `Edit: ${filePath}` : "New MDX File" }),
1341
- headerExtra && /* @__PURE__ */ jsx("div", {
1342
- className: "flex items-center gap-2",
1343
- children: headerExtra
1344
- }),
1345
- /* @__PURE__ */ jsx("button", {
1346
- onClick: handleClose,
1347
- className: "p-2 hover:bg-gray-100 rounded",
1348
- "aria-label": "Close",
1349
- children: "✕"
1350
- })
1351
- ]
1352
- }) }),
1353
- /* @__PURE__ */ jsx("div", {
1354
- className: "flex-1 overflow-hidden",
1355
- children: isEditorReady ? /* @__PURE__ */ jsx(MDXEditorErrorBoundary, { children: /* @__PURE__ */ jsx(DeferredCMSMDXEditor, {
1356
- value: content,
1357
- onChange: setContent,
1358
- onSave: handleSave
1359
- }) }) : /* @__PURE__ */ jsx("div", {
1360
- className: "flex items-center justify-center h-full",
1361
- children: /* @__PURE__ */ jsx("div", {
1362
- className: "text-gray-500",
1363
- "data-testid": "modal-editor-loading",
1364
- children: "Loading editor..."
1365
- })
1366
- })
1367
- }),
1368
- /* @__PURE__ */ jsxs("div", {
1369
- className: "flex justify-end gap-2 mt-4",
1370
- children: [/* @__PURE__ */ jsx("button", {
1371
- onClick: handleClose,
1372
- className: "px-4 py-2 border border-gray-300 rounded hover:bg-gray-50",
1373
- disabled: isSaving,
1374
- children: "Cancel"
1375
- }), /* @__PURE__ */ jsx("button", {
1376
- onClick: handleSave,
1377
- className: "px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600 disabled:opacity-50 disabled:cursor-not-allowed",
1378
- disabled: isSaving,
1379
- children: isSaving ? "Saving..." : "Save"
1380
- })]
1381
- })
1382
- ]
1401
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1402
+ /* @__PURE__ */ jsx("span", {
1403
+ className: "hidden text-xs text-grey-04 xl:inline",
1404
+ children: "Cmd/Ctrl+S to save"
1405
+ }),
1406
+ /* @__PURE__ */ jsx(Select, {
1407
+ size: "sm",
1408
+ value: selectedSnippetId,
1409
+ onChange: (event) => setSelectedSnippetId(event.target.value),
1410
+ className: "w-auto",
1411
+ children: contentBlockSnippets.map((snippet) => /* @__PURE__ */ jsx("option", {
1412
+ value: snippet.id,
1413
+ children: snippet.label
1414
+ }, snippet.id))
1415
+ }),
1416
+ /* @__PURE__ */ jsx(Button, {
1417
+ variant: "outline",
1418
+ size: "sm",
1419
+ onClick: handleInsertSnippet,
1420
+ children: "Insert Pattern"
1421
+ }),
1422
+ selectedTemplate ? /* @__PURE__ */ jsx(Button, {
1423
+ variant: "outline",
1424
+ size: "sm",
1425
+ onClick: () => {
1426
+ const newContent = renderContentBlockTemplate(initialTemplateId, filePath || "Untitled Block");
1427
+ setContent(newContent);
1428
+ editorRef.current?.setMarkdown(newContent);
1429
+ },
1430
+ children: "Reset Template"
1431
+ }) : null
1432
+ ] });
1433
+ }
1434
+ function CMSMDXEditorModal(props) {
1435
+ const { initialTemplateId, ...modalProps } = props;
1436
+ const { resolvedTheme } = useTheme();
1437
+ return /* @__PURE__ */ jsx(BaseMDXEditorModal, {
1438
+ ...modalProps,
1439
+ EditorComponent: CMSMDXEditor,
1440
+ editorClassName: resolvedTheme === "dark" ? "dark-theme" : void 0,
1441
+ headerTools: ({ setContent, editorRef }) => /* @__PURE__ */ jsx(CMSMDXHeaderTools, {
1442
+ setContent,
1443
+ editorRef,
1444
+ filePath: modalProps.filePath,
1445
+ initialTemplateId
1383
1446
  })
1384
1447
  });
1385
- };
1448
+ }
1386
1449
 
1387
1450
  //#endregion
1388
1451
  //#region src/components/puck/MDXContent.tsx
@@ -1405,7 +1468,7 @@ var MDXContentErrorBoundary = class extends React.Component {
1405
1468
  }
1406
1469
  render() {
1407
1470
  if (this.state.hasError) return /* @__PURE__ */ jsxs("div", {
1408
- className: "p-4 bg-red-50 border border-red-200 rounded text-red-600",
1471
+ className: "p-4 bg-red-11 dark:bg-red-02 border border-red-08 dark:border-red-03 rounded-md text-red-04 dark:text-red-08",
1409
1472
  children: [
1410
1473
  /* @__PURE__ */ jsx("p", {
1411
1474
  className: "font-semibold mb-2",
@@ -1416,7 +1479,7 @@ var MDXContentErrorBoundary = class extends React.Component {
1416
1479
  children: this.state.error?.message || "Unknown error occurred"
1417
1480
  }),
1418
1481
  /* @__PURE__ */ jsxs("p", {
1419
- className: "text-xs text-red-500 mb-2",
1482
+ className: "text-xs text-red-04 dark:text-red-08 mb-2",
1420
1483
  children: ["Block ID: ", this.props.contentId]
1421
1484
  }),
1422
1485
  /* @__PURE__ */ jsxs("details", {
@@ -1425,7 +1488,7 @@ var MDXContentErrorBoundary = class extends React.Component {
1425
1488
  className: "cursor-pointer font-medium",
1426
1489
  children: "Stack Trace"
1427
1490
  }), /* @__PURE__ */ jsx("pre", {
1428
- className: "mt-2 p-2 bg-red-100 rounded overflow-auto whitespace-pre-wrap",
1491
+ className: "mt-2 p-2 bg-red-08 dark:bg-red-03 rounded-md text-red-01 dark:text-red-11 overflow-auto whitespace-pre-wrap",
1429
1492
  children: this.state.error?.stack
1430
1493
  })]
1431
1494
  })
@@ -1448,16 +1511,25 @@ function MDXContentInner({ entry }) {
1448
1511
  if (!entry?.localized?.content) return null;
1449
1512
  return entry.localized.content.mdx || null;
1450
1513
  }, [entry]);
1451
- const { Component, error: compileError, isLoading: isCompiling, retry } = useMDXEvaluation({
1514
+ const cacheKey = entry.localized.etag;
1515
+ const { data: compiledResult, error: compileError, isLoading: isCompiling, refetch: retryCompile } = useCompileMDX({
1452
1516
  mdxContent: actualMdxContent,
1453
- cacheKey: entry.localized.etag
1517
+ cacheKey
1454
1518
  });
1455
- if (isCompiling) return /* @__PURE__ */ jsxs("div", {
1456
- className: "flex items-center justify-center p-8 text-grey-04",
1519
+ const { Component, error: evaluationError, isLoading: isEvaluating, retry: retryEvaluation } = useMDXEvaluation({
1520
+ compiledCode: compiledResult?.code || null,
1521
+ cacheKey
1522
+ });
1523
+ const retry = () => {
1524
+ retryEvaluation();
1525
+ retryCompile();
1526
+ };
1527
+ if (isCompiling || isEvaluating) return /* @__PURE__ */ jsxs("div", {
1528
+ className: "flex items-center justify-center p-8 text-grey-04 dark:text-grey-07",
1457
1529
  children: [/* @__PURE__ */ jsx("div", { className: "animate-spin rounded-full h-6 w-6 border-b-2 border-azure-04 mr-3" }), "Loading content..."]
1458
1530
  });
1459
- if (compileError) return /* @__PURE__ */ jsxs("div", {
1460
- className: "p-4 bg-red-50 border border-red-200 rounded text-red-600",
1531
+ if (compileError || evaluationError) return /* @__PURE__ */ jsxs("div", {
1532
+ className: "p-4 bg-red-11 dark:bg-red-02 border border-red-08 dark:border-red-03 rounded-md text-red-04 dark:text-red-08",
1461
1533
  children: [
1462
1534
  /* @__PURE__ */ jsx("p", {
1463
1535
  className: "font-semibold mb-2",
@@ -1465,21 +1537,22 @@ function MDXContentInner({ entry }) {
1465
1537
  }),
1466
1538
  /* @__PURE__ */ jsx("p", {
1467
1539
  className: "text-sm mb-2",
1468
- children: compileError.message
1540
+ children: (compileError || evaluationError)?.message
1469
1541
  }),
1470
1542
  /* @__PURE__ */ jsx("p", {
1471
- className: "text-xs text-red-500 mb-3",
1543
+ className: "text-xs text-red-04 dark:text-red-08 mb-3",
1472
1544
  children: "The block content contains invalid MDX syntax. Please edit the block to fix any syntax errors."
1473
1545
  }),
1474
1546
  /* @__PURE__ */ jsx("button", {
1547
+ type: "button",
1475
1548
  onClick: retry,
1476
- className: "px-3 py-1 text-sm bg-red-600 text-white rounded hover:bg-red-700 transition-colors",
1549
+ className: "px-3 py-1 text-sm bg-red-04 text-white rounded-md hover:bg-red-03 transition-colors",
1477
1550
  children: "Retry"
1478
1551
  })
1479
1552
  ]
1480
1553
  });
1481
1554
  if (!actualMdxContent) return /* @__PURE__ */ jsxs("div", {
1482
- className: "p-4 bg-yellow-50 border border-yellow-200 rounded text-yellow-700",
1555
+ className: "p-4 bg-yellow-11 dark:bg-yellow-02 border border-yellow-08 dark:border-yellow-03 rounded-md text-yellow-02 dark:text-yellow-09",
1483
1556
  children: [/* @__PURE__ */ jsx("p", {
1484
1557
  className: "font-semibold mb-1",
1485
1558
  children: "Empty Block Content"
@@ -1493,11 +1566,11 @@ function MDXContentInner({ entry }) {
1493
1566
  })]
1494
1567
  });
1495
1568
  if (!Component) return /* @__PURE__ */ jsxs("div", {
1496
- className: "flex items-center justify-center p-8 text-grey-04",
1569
+ className: "flex items-center justify-center p-8 text-grey-04 dark:text-grey-07",
1497
1570
  children: [/* @__PURE__ */ jsx("div", { className: "animate-spin rounded-full h-6 w-6 border-b-2 border-azure-04 mr-3" }), "Loading MDX..."]
1498
1571
  });
1499
1572
  return /* @__PURE__ */ jsx("div", {
1500
- className: "mdx-content prose prose-sm max-w-none",
1573
+ className: "mdx-content conloca-prose max-w-none",
1501
1574
  children: /* @__PURE__ */ jsx(Component, {})
1502
1575
  });
1503
1576
  }
@@ -1512,5 +1585,5 @@ function MDXContent(props) {
1512
1585
  }
1513
1586
 
1514
1587
  //#endregion
1515
- export { getUIConfig as _, MediaLibrary as a, useClickOutside as b, FolderTreeSidebar as c, useDeleteAsset as d, useFolderTree$1 as f, configureUI as g, useSiteBaseUrl as h, UploadModal as i, cn$1 as l, useUpdateAssetMetadata as m, CMSMDXEditorModal as n, MediaToolbar as o, useMoveAssets as p, ImagePicker as r, buildAssetServeUrl as s, MDXContent as t, useAssetUsage as u, useErrorModal as v, useDialogState as y };
1516
- //# sourceMappingURL=puck-DjVdP1zb.mjs.map
1588
+ export { Button as A, renderContentBlockTemplate as C, Select as D, Separator as E, ThemeProvider as M, useTheme as N, Input as O, getContentBlockTemplate as S, Textarea as T, getUIConfig as _, MediaLibrary as a, useClickOutside as b, FolderTreeSidebar as c, useDeleteAsset as d, useFolderTree$1 as f, configureUI as g, useSiteBaseUrl as h, UploadModal as i, cn as j, IconButton as k, useAssetUsage as l, useUpdateAssetMetadata as m, CMSMDXEditorModal as n, MediaToolbar as o, useMoveAssets as p, ImagePicker as r, buildAssetServeUrl as s, MDXContent as t, useBulkDeleteAssets as u, useErrorModal as v, Tooltip as w, contentBlockTemplates as x, useDialogState as y };
1589
+ //# sourceMappingURL=puck-C9_F3_cJ.mjs.map