@kidecms/core 0.14.2 → 0.15.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/README.md ADDED
@@ -0,0 +1,26 @@
1
+ # @kidecms/core
2
+
3
+ The runtime behind [Kide CMS](https://github.com/mhernesniemi/kide-cms) — a code-first CMS built for Astro. Define collections in TypeScript, get a generated admin UI and typed content API.
4
+
5
+ You normally don't install this package directly. Scaffold a project with:
6
+
7
+ ```bash
8
+ pnpx create-kide-app
9
+ ```
10
+
11
+ and choose **Package** mode when asked how you want the CMS runtime — `create-kide-app` adds `@kidecms/core` as a dependency and wires everything up. **Embedded** mode vendors this same source into your project instead, no npm dependency involved.
12
+
13
+ ## Links
14
+
15
+ - [Docs](https://docs.kide.dev/)
16
+ - [Live demo](https://demo.kide.dev/admin)
17
+ - [Source & issues](https://github.com/mhernesniemi/kide-cms)
18
+ - [Changelog](https://github.com/mhernesniemi/kide-cms/blob/main/CHANGELOG.md)
19
+
20
+ ## What's in the box
21
+
22
+ Admin UI, typed local API, auth, assets, search, webhooks, background tasks, collaboration workflow, and the `kide` CLI (`kide generate|push|seed|admin|upgrade|eject|mcp`). See the [full feature list and quick start](https://github.com/mhernesniemi/kide-cms#readme) in the main repo.
23
+
24
+ ## License
25
+
26
+ MIT
@@ -1,6 +1,7 @@
1
1
  "use client";
2
2
 
3
3
  import { useState, useCallback, useRef, useMemo, useEffect } from "react";
4
+ import type { CSSProperties } from "react";
4
5
  import {
5
6
  ChevronLeft,
6
7
  ChevronRight,
@@ -10,6 +11,7 @@ import {
10
11
  Images,
11
12
  ImagePlus,
12
13
  Inbox,
14
+ Loader2,
13
15
  MoreHorizontal,
14
16
  Pencil,
15
17
  Search,
@@ -50,6 +52,8 @@ type AssetItem = {
50
52
  mimeType: string;
51
53
  url: string;
52
54
  alt: string | null;
55
+ focalX: number | null;
56
+ focalY: number | null;
53
57
  _createdAt: string;
54
58
  };
55
59
 
@@ -78,6 +82,13 @@ type Props = {
78
82
  pageSize: number;
79
83
  };
80
84
 
85
+ // object-cover crops around the CSS center by default — steer it to the asset's
86
+ // focal point instead, when one is set.
87
+ function focalPointStyle(asset: Pick<AssetItem, "focalX" | "focalY">): CSSProperties | undefined {
88
+ if (asset.focalX == null || asset.focalY == null) return undefined;
89
+ return { objectPosition: `${asset.focalX}% ${asset.focalY}%` };
90
+ }
91
+
81
92
  // Build a "/admin/assets" URL for a sidebar scope ("all" | "unfiled" | folderId).
82
93
  // "all" is the bare route; "unfiled" and folder ids ride on the `folder` param.
83
94
  function assetsUrl(opts: { scope?: string; q?: string; page?: number }) {
@@ -114,7 +125,12 @@ function DraggableAssetCard({
114
125
  <div className="relative">
115
126
  {asset.mimeType.startsWith("image/") ? (
116
127
  <div className="bg-muted/30 aspect-square w-full overflow-hidden">
117
- <img src={thumbnail(asset.url)} alt={asset.alt ?? asset.filename} className="size-full object-cover" />
128
+ <img
129
+ src={thumbnail(asset.url)}
130
+ alt={asset.alt ?? asset.filename}
131
+ className="size-full object-cover"
132
+ style={focalPointStyle(asset)}
133
+ />
118
134
  </div>
119
135
  ) : (
120
136
  <div className="bg-muted/30 flex aspect-square items-center justify-center">
@@ -134,7 +150,9 @@ function DraggableAssetCard({
134
150
  <label
135
151
  className={cn(
136
152
  "border-foreground/40 hover:border-foreground/80 bg-background/80 absolute top-2.5 right-2.5 z-10 flex size-5 cursor-default items-center justify-center rounded border backdrop-blur-sm transition-[opacity,border-color]",
137
- selected ? "border-foreground! opacity-100" : "opacity-0 group-hover:opacity-100",
153
+ selected
154
+ ? "border-foreground! opacity-100"
155
+ : "opacity-0 group-hover:opacity-100 has-[:focus-visible]:opacity-100",
138
156
  )}
139
157
  onClick={(e) => e.stopPropagation()}
140
158
  >
@@ -162,7 +180,7 @@ function DraggableAssetCard({
162
180
  {/* Drag handle */}
163
181
  <div
164
182
  ref={setActivatorNodeRef}
165
- className="bg-background/80 border-foreground/40 hover:border-foreground/80 text-muted-foreground absolute top-2.5 left-2.5 z-10 flex size-5 cursor-grab items-center justify-center rounded border opacity-0 backdrop-blur-sm transition-opacity group-hover:opacity-100 active:cursor-grabbing"
183
+ className="bg-background/80 border-foreground/40 hover:border-foreground/80 text-muted-foreground absolute top-2.5 left-2.5 z-10 flex size-5 cursor-grab items-center justify-center rounded border opacity-0 backdrop-blur-sm transition-opacity group-hover:opacity-100 focus-visible:opacity-100 active:cursor-grabbing"
166
184
  {...attributes}
167
185
  {...listeners}
168
186
  >
@@ -255,7 +273,12 @@ function AssetDragOverlay({ asset }: { asset: AssetItem }) {
255
273
  <div className="relative">
256
274
  {asset.mimeType.startsWith("image/") ? (
257
275
  <div className="bg-muted/30 aspect-square w-full overflow-hidden">
258
- <img src={thumbnail(asset.url)} alt={asset.alt ?? asset.filename} className="size-full object-cover" />
276
+ <img
277
+ src={thumbnail(asset.url)}
278
+ alt={asset.alt ?? asset.filename}
279
+ className="size-full object-cover"
280
+ style={focalPointStyle(asset)}
281
+ />
259
282
  </div>
260
283
  ) : (
261
284
  <div className="bg-muted/30 flex aspect-square items-center justify-center">
@@ -320,7 +343,13 @@ export default function AssetsGrid({
320
343
  const [menuOpen, setMenuOpen] = useState(false);
321
344
  const [menuPos, setMenuPos] = useState({ top: 0, left: 0 });
322
345
 
323
- const uploadFormRef = useRef<HTMLFormElement>(null);
346
+ const [uploading, setUploading] = useState(false);
347
+ const [uploadCount, setUploadCount] = useState(0);
348
+ const [uploadProgress, setUploadProgress] = useState(0);
349
+ const [uploadError, setUploadError] = useState<string | null>(null);
350
+ const [uploadNotice, setUploadNotice] = useState<string | null>(null);
351
+ const [isDraggingFile, setIsDraggingFile] = useState(false);
352
+ const dragDepthRef = useRef(0);
324
353
 
325
354
  const sensors = useSensors(useSensor(PointerSensor, { activationConstraint: { distance: 5 } }));
326
355
 
@@ -398,6 +427,95 @@ export default function AssetsGrid({
398
427
  [pageSize, scopeFolderParam],
399
428
  );
400
429
 
430
+ // Upload via XHR (not fetch) so real byte-level progress is available for
431
+ // xhr.upload.onprogress — the point of this handler for bulk uploads. The
432
+ // server validates every file before storing any (see upload.ts), so this
433
+ // stays a single request for the whole batch rather than one per file.
434
+ const handleFilesSelected = useCallback(
435
+ (files: FileList) => {
436
+ if (files.length === 0) return;
437
+ setUploadError(null);
438
+ setUploadNotice(null);
439
+ setUploading(true);
440
+ setUploadCount(files.length);
441
+ setUploadProgress(0);
442
+
443
+ const formData = new FormData();
444
+ for (const file of Array.from(files)) formData.append("file", file);
445
+ if (currentFolderId) formData.append("folder", currentFolderId);
446
+
447
+ const xhr = new XMLHttpRequest();
448
+ xhr.open("POST", "/api/cms/assets/upload");
449
+ xhr.upload.onprogress = (e) => {
450
+ if (e.lengthComputable) setUploadProgress(Math.round((e.loaded / e.total) * 100));
451
+ };
452
+ xhr.onload = () => {
453
+ if (xhr.status >= 200 && xhr.status < 300) {
454
+ let uploaded: unknown = null;
455
+ try {
456
+ uploaded = JSON.parse(xhr.responseText);
457
+ } catch {
458
+ /* fall through to list refresh */
459
+ }
460
+ // Single upload → its detail view (matches the old form-flow redirect).
461
+ if (uploaded && !Array.isArray(uploaded)) {
462
+ window.location.assign(
463
+ `/admin/assets/${(uploaded as { _id: string })._id}?_toast=success&_msg=Asset+uploaded`,
464
+ );
465
+ return; // keep the busy state until navigation
466
+ }
467
+ setUploading(false);
468
+ setUploadNotice(`${Array.isArray(uploaded) ? uploaded.length : files.length} assets uploaded`);
469
+ setTimeout(() => setUploadNotice(null), 4000);
470
+ fetchPage(1, query);
471
+ } else {
472
+ setUploading(false);
473
+ try {
474
+ setUploadError(JSON.parse(xhr.responseText).error ?? "Upload failed.");
475
+ } catch {
476
+ setUploadError("Upload failed.");
477
+ }
478
+ }
479
+ };
480
+ xhr.onerror = () => {
481
+ setUploading(false);
482
+ setUploadError("Upload failed. Check your connection and try again.");
483
+ };
484
+ xhr.send(formData);
485
+ },
486
+ [currentFolderId, fetchPage, query],
487
+ );
488
+
489
+ // OS-level file drag onto the page. Guarded on the "Files" drag type so this never
490
+ // fires for dnd-kit's own pointer-based asset-card dragging (no DataTransfer involved
491
+ // there) or for dragging text/selections. A depth counter avoids overlay flicker as
492
+ // the pointer crosses child element boundaries while dragging over the page.
493
+ const handleDragEnter = useCallback((e: React.DragEvent) => {
494
+ if (!e.dataTransfer.types.includes("Files")) return;
495
+ e.preventDefault();
496
+ dragDepthRef.current += 1;
497
+ setIsDraggingFile(true);
498
+ }, []);
499
+ const handleDragOver = useCallback((e: React.DragEvent) => {
500
+ if (!e.dataTransfer.types.includes("Files")) return;
501
+ e.preventDefault();
502
+ }, []);
503
+ const handleDragLeave = useCallback((e: React.DragEvent) => {
504
+ if (!e.dataTransfer.types.includes("Files")) return;
505
+ dragDepthRef.current = Math.max(0, dragDepthRef.current - 1);
506
+ if (dragDepthRef.current === 0) setIsDraggingFile(false);
507
+ }, []);
508
+ const handleDrop = useCallback(
509
+ (e: React.DragEvent) => {
510
+ if (!e.dataTransfer.types.includes("Files")) return;
511
+ e.preventDefault();
512
+ dragDepthRef.current = 0;
513
+ setIsDraggingFile(false);
514
+ if (e.dataTransfer.files.length > 0) handleFilesSelected(e.dataTransfer.files);
515
+ },
516
+ [handleFilesSelected],
517
+ );
518
+
401
519
  // Debounce the filter box: re-query from page 1 on every keystroke. Skip the
402
520
  // initial mount — the SSR render already reflects the URL's `search`.
403
521
  const didMount = useRef(false);
@@ -533,6 +651,14 @@ export default function AssetsGrid({
533
651
  location.reload();
534
652
  }
535
653
 
654
+ const emptyStateMessage = query.trim()
655
+ ? `No assets match “${query.trim()}”.`
656
+ : scope === "unfiled"
657
+ ? "No unfiled assets."
658
+ : scope === "all"
659
+ ? "No assets uploaded yet."
660
+ : "This folder is empty.";
661
+
536
662
  return (
537
663
  <DndContext
538
664
  sensors={sensors}
@@ -542,7 +668,19 @@ export default function AssetsGrid({
542
668
  onDragEnd={handleDragEnd}
543
669
  onDragCancel={handleDragCancel}
544
670
  >
545
- <section className="px-4 py-6 lg:py-8 lg:pr-8 lg:pl-12">
671
+ <section
672
+ className="relative px-4 py-6 lg:py-8 lg:pr-8 lg:pl-12"
673
+ onDragEnter={handleDragEnter}
674
+ onDragOver={handleDragOver}
675
+ onDragLeave={handleDragLeave}
676
+ onDrop={handleDrop}
677
+ >
678
+ {isDraggingFile && (
679
+ <div className="border-primary bg-background/90 pointer-events-none absolute inset-0 z-50 m-2 flex flex-col items-center justify-center gap-3 rounded-lg border-2 border-dashed backdrop-blur-sm">
680
+ <Upload className="text-primary size-10" />
681
+ <p className="text-foreground text-sm font-medium">Drop to upload</p>
682
+ </div>
683
+ )}
546
684
  <h1 className="mb-6 text-2xl font-semibold tracking-tight">Assets</h1>
547
685
 
548
686
  <div className="grid gap-8 lg:grid-cols-[230px_minmax(0,1fr)] lg:gap-0">
@@ -615,31 +753,56 @@ export default function AssetsGrid({
615
753
  className="pl-9 text-sm"
616
754
  />
617
755
  </div>
618
- <label className={cn(buttonVariants(), "shrink-0 cursor-pointer")}>
619
- <Upload className="size-4" />
620
- Upload
621
- <form
622
- ref={uploadFormRef}
623
- method="post"
624
- action="/api/cms/assets/upload"
625
- encType="multipart/form-data"
756
+ <label
757
+ className={cn(
758
+ buttonVariants(),
759
+ "shrink-0",
760
+ uploading ? "pointer-events-none opacity-70" : "cursor-pointer",
761
+ )}
762
+ >
763
+ {uploading ? (
764
+ <>
765
+ <Loader2 className="size-4 animate-spin" />
766
+ {uploadProgress < 100
767
+ ? `Uploading ${uploadCount > 1 ? `${uploadCount} files` : "file"}… ${uploadProgress}%`
768
+ : "Processing…"}
769
+ </>
770
+ ) : (
771
+ <>
772
+ <Upload className="size-4" />
773
+ Upload
774
+ </>
775
+ )}
776
+ <input
777
+ type="file"
778
+ name="file"
779
+ accept="image/*,video/*,audio/*,.pdf,.doc,.docx"
780
+ multiple
781
+ disabled={uploading}
626
782
  className="hidden"
627
- >
628
- <input type="hidden" name="redirectTo" value={assetsUrl({ scope })} />
629
- {currentFolderId && <input type="hidden" name="folder" value={currentFolderId} />}
630
- <input
631
- type="file"
632
- name="file"
633
- accept="image/*,video/*,audio/*,.pdf,.doc,.docx"
634
- multiple
635
- required
636
- onChange={(e) => {
637
- if (e.target.value) uploadFormRef.current?.submit();
638
- }}
639
- />
640
- </form>
783
+ onChange={(e) => {
784
+ if (e.target.files?.length) handleFilesSelected(e.target.files);
785
+ e.target.value = "";
786
+ }}
787
+ />
641
788
  </label>
642
789
  </div>
790
+ {uploading && (
791
+ <div
792
+ role="progressbar"
793
+ aria-valuenow={uploadProgress}
794
+ aria-valuemin={0}
795
+ aria-valuemax={100}
796
+ className="bg-muted h-1 w-full overflow-hidden rounded-full"
797
+ >
798
+ <div
799
+ className="bg-primary h-full rounded-full transition-[width]"
800
+ style={{ width: `${uploadProgress}%` }}
801
+ />
802
+ </div>
803
+ )}
804
+ {uploadError && <p className="text-destructive text-sm">{uploadError}</p>}
805
+ {uploadNotice && <p className="text-muted-foreground text-sm">{uploadNotice}</p>}
643
806
 
644
807
  {/* Selection toolbar */}
645
808
  {selectedIds.size > 0 && (
@@ -687,22 +850,10 @@ export default function AssetsGrid({
687
850
  <CardContent className="text-muted-foreground py-12 text-center text-sm">Searching…</CardContent>
688
851
  </Card>
689
852
  ) : (
690
- <Card>
691
- <CardContent className="py-12">
692
- <div className="text-center">
693
- <ImagePlus className="text-muted-foreground/30 mx-auto size-12" />
694
- <p className="text-muted-foreground mt-3 text-sm">
695
- {query.trim()
696
- ? `No assets match “${query.trim()}”.`
697
- : scope === "unfiled"
698
- ? "No unfiled assets."
699
- : scope === "all"
700
- ? "No assets uploaded yet."
701
- : "This folder is empty."}
702
- </p>
703
- </div>
704
- </CardContent>
705
- </Card>
853
+ <div className="bg-muted/20 flex h-40 flex-col items-center justify-center gap-3 rounded-lg border border-dashed">
854
+ <ImagePlus className="text-muted-foreground/30 size-12" />
855
+ <p className="text-muted-foreground text-sm">{emptyStateMessage}</p>
856
+ </div>
706
857
  )}
707
858
 
708
859
  {/* Pagination (client-side — keeps the active filter without a reload) */}
@@ -339,7 +339,7 @@ const ToolbarButton = ({
339
339
  title={title}
340
340
  className={cn(
341
341
  "disabled:hover:text-muted-foreground inline-flex size-8 items-center justify-center rounded-md transition-colors outline-none disabled:opacity-50 disabled:hover:bg-transparent",
342
- active ? "bg-accent text-accent-foreground" : "text-muted-foreground hover:bg-accent/60 hover:text-foreground",
342
+ active ? "bg-accent text-accent-foreground" : "text-muted-foreground hover:bg-muted-strong hover:text-foreground",
343
343
  )}
344
344
  >
345
345
  {children}
@@ -17,6 +17,7 @@ import {
17
17
  ArrowDown,
18
18
  ArrowUp,
19
19
  ArrowUpDown,
20
+ ArrowUpRight,
20
21
  ChevronDown,
21
22
  ChevronLeft,
22
23
  ChevronRight,
@@ -65,6 +66,8 @@ type DataTableRow = {
65
66
  locales: string[];
66
67
  searchText: string;
67
68
  values: Record<string, string>;
69
+ /** Live URL for the "__page" column (e.g. Singles), rendered as an external link. */
70
+ pageHref?: string;
68
71
  };
69
72
 
70
73
  type ServerPaginationConfig = {
@@ -81,6 +84,8 @@ type DocumentsDataTableProps = {
81
84
  collectionSlug: string;
82
85
  draftsEnabled?: boolean;
83
86
  duplicateEnabled?: boolean;
87
+ /** Show the Locales column. Defaults to true for callers (e.g. Recent) that mix collections. */
88
+ showLocalesColumn?: boolean;
84
89
  defaultLocale?: string;
85
90
  labelField?: string;
86
91
  newHref?: string;
@@ -113,6 +118,16 @@ const getVisualStatus = (d: Record<string, unknown>): string => {
113
118
  return status;
114
119
  };
115
120
 
121
+ // Rebuilds row values after a client-side re-fetch (sort/search/page change). The
122
+ // "__page"/"__usage" values are pre-computed server-side (see the collection GET route)
123
+ // since they aren't stored fields — this just reads them back.
124
+ const formatRowValue = (columnKey: string, entry: Record<string, unknown>): string => {
125
+ if (columnKey === "_status") return getVisualStatus(entry);
126
+ if (columnKey === "__usage") return `${Number(entry.__usage ?? 0)} places`;
127
+ if (columnKey === "_updatedAt" || columnKey === "_createdAt") return formatDateClient(entry[columnKey]);
128
+ return String(entry[columnKey] ?? "—");
129
+ };
130
+
116
131
  function DataTableColumnHeader({ column, title }: { column: Column<DataTableRow, unknown>; title: string }) {
117
132
  if (!column.getCanSort()) {
118
133
  return <span>{title}</span>;
@@ -138,6 +153,7 @@ export default function DocumentsDataTable({
138
153
  collectionSlug,
139
154
  draftsEnabled = false,
140
155
  duplicateEnabled = true,
156
+ showLocalesColumn = true,
141
157
  defaultLocale,
142
158
  labelField = "title",
143
159
  newHref,
@@ -235,18 +251,8 @@ export default function DocumentsDataTable({
235
251
  : []),
236
252
  ],
237
253
  searchText: String(entry[labelField] ?? entry.slug ?? entry._id ?? ""),
238
- values: Object.fromEntries(
239
- columns.map((column) => [
240
- column.key,
241
- column.key === "_status"
242
- ? getVisualStatus(entry)
243
- : column.key === "__usage"
244
- ? `${Number(entry.__usage ?? 0)} places`
245
- : column.key === "_updatedAt" || column.key === "_createdAt"
246
- ? formatDateClient(entry[column.key])
247
- : String(entry[column.key] ?? "\u2014"),
248
- ]),
249
- ),
254
+ pageHref: entry._pageHref as string | undefined,
255
+ values: Object.fromEntries(columns.map((column) => [column.key, formatRowValue(column.key, entry)])),
250
256
  })),
251
257
  );
252
258
  setServerTotalDocs(result.totalDocs);
@@ -500,6 +506,23 @@ export default function DocumentsDataTable({
500
506
  />
501
507
  );
502
508
  }
509
+ if (column.key === "__page") {
510
+ return row.original.pageHref ? (
511
+ <a
512
+ href={row.original.pageHref}
513
+ target="_blank"
514
+ rel="noreferrer"
515
+ title={value}
516
+ onClick={(e) => e.stopPropagation()}
517
+ className="text-muted-foreground hover:text-foreground inline-flex max-w-64 min-w-0 items-center gap-1 underline-offset-2 hover:underline"
518
+ >
519
+ <span className="truncate">{value}</span>
520
+ <ArrowUpRight className="size-3.5 shrink-0" />
521
+ </a>
522
+ ) : (
523
+ <div className="text-muted-foreground max-w-64 truncate">{value}</div>
524
+ );
525
+ }
503
526
  const isPrimary = column.key === primaryColumnKey;
504
527
  return (
505
528
  <>
@@ -517,25 +540,35 @@ export default function DocumentsDataTable({
517
540
  );
518
541
  },
519
542
  })),
520
- {
521
- accessorFn: (row) => row.locales.join(", "),
522
- id: "locales",
523
- header: ({ column }) => <DataTableColumnHeader column={column} title="Locales" />,
524
- cell: ({ row }) => (
525
- <div className="flex flex-wrap gap-1.5">
526
- {row.original.locales.map((locale) => (
527
- <a key={locale} href={`${row.original.editHref}?locale=${locale}`} onClick={(e) => e.stopPropagation()}>
528
- <Badge
529
- variant="outline"
530
- className="text-muted-foreground hover:border-foreground/50 hover:text-foreground uppercase transition-colors"
531
- >
532
- {locale}
533
- </Badge>
534
- </a>
535
- ))}
536
- </div>
537
- ),
538
- },
543
+ ...(showLocalesColumn
544
+ ? [
545
+ {
546
+ accessorFn: (row: DataTableRow) => row.locales.join(", "),
547
+ id: "locales",
548
+ header: ({ column }: { column: Column<DataTableRow, unknown> }) => (
549
+ <DataTableColumnHeader column={column} title="Locales" />
550
+ ),
551
+ cell: ({ row }: { row: { original: DataTableRow } }) => (
552
+ <div className="flex flex-wrap gap-1.5">
553
+ {row.original.locales.map((locale) => (
554
+ <a
555
+ key={locale}
556
+ href={`${row.original.editHref}?locale=${locale}`}
557
+ onClick={(e) => e.stopPropagation()}
558
+ >
559
+ <Badge
560
+ variant="outline"
561
+ className="text-muted-foreground hover:border-foreground/50 hover:text-foreground uppercase transition-colors"
562
+ >
563
+ {locale}
564
+ </Badge>
565
+ </a>
566
+ ))}
567
+ </div>
568
+ ),
569
+ } as ColumnDef<DataTableRow>,
570
+ ]
571
+ : []),
539
572
  {
540
573
  id: "actions",
541
574
  enableSorting: false,
@@ -605,7 +638,7 @@ export default function DocumentsDataTable({
605
638
  ),
606
639
  },
607
640
  ],
608
- [columns, draftsEnabled, duplicateEnabled, isPending, primaryColumnKey, isServerMode, runAction],
641
+ [columns, draftsEnabled, duplicateEnabled, showLocalesColumn, isPending, primaryColumnKey, isServerMode, runAction],
609
642
  );
610
643
 
611
644
  const table = useReactTable({
@@ -77,15 +77,8 @@ const {
77
77
  const label = field.label ?? humanize(name);
78
78
  const placeholder = field.admin?.placeholder ?? "";
79
79
  const serializedValue = serializeFieldValue(field, value);
80
- const rows =
81
- field.admin?.rows ??
82
- (field.type === "richText" || field.type === "content"
83
- ? field.type === "content"
84
- ? 14
85
- : 10
86
- : field.type === "json" || field.type === "blocks"
87
- ? 12
88
- : 5);
80
+ const DEFAULT_ROWS: Record<string, number> = { content: 14, richText: 10, json: 12, blocks: 12 };
81
+ const rows = field.admin?.rows ?? DEFAULT_ROWS[field.type] ?? 5;
89
82
  const inputMode = field.type === "number" ? "decimal" : undefined;
90
83
  const controlClass = cn("w-full shadow-none", readOnly && "cursor-not-allowed bg-muted text-muted-foreground");
91
84
  const isTreeEditor =
@@ -162,7 +162,7 @@ export default function ImageBrowseDialog({ open, onOpenChange, onSelect }: Prop
162
162
  </div>
163
163
  ) : (
164
164
  browse.folders.length === 0 && (
165
- <div className="text-muted-foreground flex h-48 items-center justify-center text-sm">
165
+ <div className="bg-muted/20 text-muted-foreground flex h-48 items-center justify-center rounded-lg border border-dashed text-sm">
166
166
  {browse.folderId ? "This folder is empty." : "No images uploaded yet."}
167
167
  </div>
168
168
  )
@@ -108,7 +108,7 @@ export default function ImagePicker({ name, value: initialValue, onChange: onCha
108
108
  setAssetId(null);
109
109
  onChangeProp?.("");
110
110
  }}
111
- className="border-foreground/25 hover:border-foreground bg-background/80 absolute top-2 right-2 flex size-5 items-center justify-center rounded border opacity-0 backdrop-blur-sm transition-[opacity,border-color] group-hover:opacity-100"
111
+ className="border-foreground/25 hover:border-foreground bg-background/80 absolute top-2 right-2 flex size-5 items-center justify-center rounded border opacity-0 backdrop-blur-sm transition-[opacity,border-color] group-hover:opacity-100 focus-visible:opacity-100"
112
112
  >
113
113
  <X className="size-3" />
114
114
  </button>
@@ -41,8 +41,8 @@ export default function InternalLinkPicker({
41
41
  variant="input"
42
42
  role="combobox"
43
43
  aria-expanded={open}
44
- size="lg"
45
- className="w-full justify-between text-sm font-normal"
44
+ size="sm"
45
+ className="bg-background w-full justify-between text-sm font-normal"
46
46
  >
47
47
  <span className={cn("truncate", !selectedLabel && "text-muted-foreground")}>
48
48
  {selectedLabel || "Search documents..."}
@@ -182,7 +182,9 @@ const ToolbarButton = ({
182
182
  title={title}
183
183
  className={cn(
184
184
  "disabled:hover:text-muted-foreground inline-flex size-8 items-center justify-center rounded-md transition-colors outline-none disabled:opacity-50 disabled:hover:bg-transparent",
185
- active ? "bg-accent text-accent-foreground" : "text-muted-foreground hover:bg-accent/60 hover:text-foreground",
185
+ active
186
+ ? "bg-muted-strong text-accent-foreground"
187
+ : "text-muted-foreground hover:bg-muted-strong hover:text-foreground",
186
188
  )}
187
189
  >
188
190
  {children}
@@ -434,7 +434,7 @@ export default function TreeItemsEditor({ name, value, variant, label, linkOptio
434
434
  value={editing.label}
435
435
  onChange={(e) => updateEditing({ label: e.target.value })}
436
436
  placeholder="Label"
437
- className="h-7 min-w-0 flex-3 text-sm"
437
+ className="bg-background h-7 min-w-0 flex-3 text-sm"
438
438
  autoFocus
439
439
  onKeyDown={editKeyHandler}
440
440
  />
@@ -449,7 +449,7 @@ export default function TreeItemsEditor({ name, value, variant, label, linkOptio
449
449
  updateEditing({ linkType: newType, ...(newType === "internal" ? { href: "" } : {}) });
450
450
  }}
451
451
  >
452
- <SelectTrigger className="h-7! min-w-0 flex-2 text-sm">
452
+ <SelectTrigger className="bg-background h-7! min-w-0 flex-2 text-sm">
453
453
  <SelectValue placeholder="Link type" />
454
454
  </SelectTrigger>
455
455
  <SelectContent>
@@ -464,7 +464,7 @@ export default function TreeItemsEditor({ name, value, variant, label, linkOptio
464
464
  value={editing.href}
465
465
  onChange={(e) => updateEditing({ href: e.target.value })}
466
466
  placeholder="https://..."
467
- className="h-7 min-w-0 flex-3 text-sm"
467
+ className="bg-background h-7 min-w-0 flex-3 text-sm"
468
468
  onKeyDown={editKeyHandler}
469
469
  />
470
470
  ) : (
@@ -488,7 +488,7 @@ export default function TreeItemsEditor({ name, value, variant, label, linkOptio
488
488
  updateEditing({ name, ...(editing.autoSlug ? { slug: slugify(name) } : {}) });
489
489
  }}
490
490
  placeholder="Name"
491
- className="h-7 flex-1 text-sm"
491
+ className="bg-background h-7 flex-1 text-sm"
492
492
  autoFocus
493
493
  onKeyDown={editKeyHandler}
494
494
  />
@@ -496,7 +496,7 @@ export default function TreeItemsEditor({ name, value, variant, label, linkOptio
496
496
  value={editing.slug}
497
497
  onChange={(e) => updateEditing({ slug: e.target.value, autoSlug: false })}
498
498
  placeholder="slug"
499
- className="h-7 w-36 text-sm"
499
+ className="bg-background h-7 w-36 text-sm"
500
500
  onKeyDown={editKeyHandler}
501
501
  />
502
502
  </>
@@ -757,13 +757,19 @@ export default function TreeItemsEditor({ name, value, variant, label, linkOptio
757
757
  onDragEnd={handleDragEnd}
758
758
  onDragCancel={handleDragCancel}
759
759
  >
760
- <div className="bg-muted-strong/50 rounded-lg border">
760
+ <div
761
+ className={
762
+ items.length > 0
763
+ ? "bg-muted-strong/50 rounded-lg border"
764
+ : "bg-muted/20 flex h-20 items-center justify-center rounded-lg border border-dashed"
765
+ }
766
+ >
761
767
  {items.length > 0 ? (
762
768
  <SortableContext items={items.map((item) => item.id)} strategy={verticalListSortingStrategy}>
763
769
  {items.map((item) => renderItem(item, 0))}
764
770
  </SortableContext>
765
771
  ) : (
766
- <div className="text-muted-foreground py-8 text-center text-sm">{emptyLabel}</div>
772
+ <p className="text-muted-foreground text-sm">{emptyLabel}</p>
767
773
  )}
768
774
  </div>
769
775
  <DragOverlay dropAnimation={null}>