@kidecms/core 0.17.1 → 0.18.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.
@@ -34,15 +34,14 @@ export default function InternalLinkPicker({
34
34
  }, [editHref, linkOptions]);
35
35
 
36
36
  return (
37
- <div className="min-w-0 flex-3">
37
+ <div className="min-w-0 flex-1">
38
38
  <Popover open={open} onOpenChange={setOpen}>
39
39
  <PopoverTrigger asChild>
40
40
  <Button
41
41
  variant="input"
42
42
  role="combobox"
43
43
  aria-expanded={open}
44
- size="sm"
45
- className="bg-background w-full justify-between text-sm font-normal"
44
+ className="h-9 w-full min-w-0 justify-between rounded-lg px-3 text-sm font-normal"
46
45
  >
47
46
  <span className={cn("truncate", !selectedLabel && "text-muted-foreground")}>
48
47
  {selectedLabel || "Search documents..."}
@@ -8,10 +8,12 @@ import { Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectVa
8
8
  import InternalLinkPicker, { type LinkOptionGroup } from "./InternalLinkPicker";
9
9
 
10
10
  // A structured link control: URL + label + open-in-new-tab, stored as
11
- // { type, url, label, newTab }. A leading "/" is treated as an internal link.
12
- // When linkOptions are provided, internal links are chosen with a document
11
+ // { type, url, label, title, newTab }. A leading "/" is treated as an internal
12
+ // link. When linkOptions are provided, internal links are chosen with a document
13
13
  // picker instead of a hand-typed path (which silently breaks on slug edits).
14
- type LinkValue = { type?: string; url?: string; label?: string; newTab?: boolean };
14
+ // `title` is the picked document's title — renderers use it as the link text
15
+ // when `label` is left empty.
16
+ type LinkValue = { type?: string; url?: string; label?: string; title?: string; newTab?: boolean };
15
17
 
16
18
  type Props = {
17
19
  name?: string;
@@ -64,53 +66,59 @@ export default function LinkField({ name, value: initial, onChange, linkOptions
64
66
  return (
65
67
  <div className="space-y-2 rounded-md border p-3">
66
68
  {name && <input type="hidden" name={name} value={value.url ? JSON.stringify(value) : ""} ref={hiddenRef} />}
67
- <div className="grid gap-1">
68
- <Label className="text-xs">{hasPicker ? "Link" : "URL"}</Label>
69
- {hasPicker ? (
70
- <div className="flex items-center gap-2">
71
- <Select
72
- items={[
73
- { value: "internal", label: "Internal" },
74
- { value: "external", label: "External" },
75
- ]}
76
- value={linkType}
77
- onValueChange={(v) => setLinkType((v as "internal" | "external") ?? "internal")}
78
- >
79
- <SelectTrigger className="w-28 shrink-0 text-sm">
80
- <SelectValue />
81
- </SelectTrigger>
82
- <SelectContent>
83
- <SelectGroup>
84
- <SelectItem value="internal">Internal</SelectItem>
85
- <SelectItem value="external">External</SelectItem>
86
- </SelectGroup>
87
- </SelectContent>
88
- </Select>
89
- {linkType === "internal" ? (
90
- <InternalLinkPicker
91
- editHref={value.url ?? ""}
92
- linkOptions={linkOptions}
93
- onSelect={(item) => set({ url: item.href, ...(value.label ? {} : { label: item.label }) })}
94
- />
95
- ) : (
96
- <Input
97
- value={value.url ?? ""}
98
- placeholder="https://example.com"
99
- onChange={(e) => set({ url: e.target.value })}
100
- />
101
- )}
102
- </div>
103
- ) : (
69
+ <div className="grid gap-2 sm:grid-cols-[minmax(0,3fr)_minmax(0,2fr)]">
70
+ <div className="grid gap-1">
71
+ <Label className="text-xs">{hasPicker ? "Link" : "URL"}</Label>
72
+ {hasPicker ? (
73
+ <div className="flex min-w-0 items-center gap-2">
74
+ <Select
75
+ items={[
76
+ { value: "internal", label: "Internal" },
77
+ { value: "external", label: "External" },
78
+ ]}
79
+ value={linkType}
80
+ onValueChange={(v) => setLinkType((v as "internal" | "external") ?? "internal")}
81
+ >
82
+ <SelectTrigger className="w-28 shrink-0 text-sm">
83
+ <SelectValue />
84
+ </SelectTrigger>
85
+ <SelectContent>
86
+ <SelectGroup>
87
+ <SelectItem value="internal">Internal</SelectItem>
88
+ <SelectItem value="external">External</SelectItem>
89
+ </SelectGroup>
90
+ </SelectContent>
91
+ </Select>
92
+ {linkType === "internal" ? (
93
+ <InternalLinkPicker
94
+ editHref={value.url ?? ""}
95
+ linkOptions={linkOptions}
96
+ onSelect={(item) => set({ url: item.href, title: item.label })}
97
+ />
98
+ ) : (
99
+ <Input
100
+ value={value.url ?? ""}
101
+ placeholder="https://example.com"
102
+ onChange={(e) => set({ url: e.target.value, title: undefined })}
103
+ />
104
+ )}
105
+ </div>
106
+ ) : (
107
+ <Input
108
+ value={value.url ?? ""}
109
+ placeholder="https://example.com or /about"
110
+ onChange={(e) => set({ url: e.target.value, title: undefined })}
111
+ />
112
+ )}
113
+ </div>
114
+ <div className="grid gap-1">
115
+ <Label className="text-xs">Label</Label>
104
116
  <Input
105
- value={value.url ?? ""}
106
- placeholder="https://example.com or /about"
107
- onChange={(e) => set({ url: e.target.value })}
117
+ value={value.label ?? ""}
118
+ placeholder={value.title || "Link text"}
119
+ onChange={(e) => set({ label: e.target.value })}
108
120
  />
109
- )}
110
- </div>
111
- <div className="grid gap-1">
112
- <Label className="text-xs">Label</Label>
113
- <Input value={value.label ?? ""} placeholder="Link text" onChange={(e) => set({ label: e.target.value })} />
121
+ </div>
114
122
  </div>
115
123
  <label className="text-muted-foreground group inline-flex cursor-pointer items-center gap-2 text-sm">
116
124
  <Checkbox
@@ -119,7 +127,6 @@ export default function LinkField({ name, value: initial, onChange, linkOptions
119
127
  onCheckedChange={(checked) => set({ newTab: Boolean(checked) })}
120
128
  />
121
129
  Open in new tab
122
- {value.url && <span className="ml-auto text-xs">({value.type})</span>}
123
130
  </label>
124
131
  </div>
125
132
  );
@@ -1,5 +1,5 @@
1
1
  ---
2
- import { ArrowLeft, ArrowUpRight, Dot, Lock } from "lucide-react";
2
+ import { Archive, ArrowLeft, ArrowUpRight, Dot, Lock } from "lucide-react";
3
3
 
4
4
  import AdminCard from "../components/AdminCard.astro";
5
5
  import AiGenerateButton from "../components/AiGenerateButton";
@@ -122,6 +122,12 @@ const formTab = "edit" as "edit" | "submissions";
122
122
 
123
123
  // --- Form-submissions-specific: custom read-only view ---
124
124
  const isSubmissionView = collection.slug === "form-submissions" && mode === "edit";
125
+ // Opening a new submission marks it read, like email. System write: the
126
+ // read-only `data` field's access rule must not block the status flip.
127
+ if (isSubmissionView && doc && documentId && doc.status === "new") {
128
+ await collectionApi.update(documentId, { status: "read" }, { _system: true });
129
+ doc.status = "read";
130
+ }
125
131
  const parentFormTitle =
126
132
  isSubmissionView && doc?.form ? await loadParentFormTitle(String(doc.form), cmsRuntime, runtimeContext) : null;
127
133
  const submissionData = (isSubmissionView && doc?.data ? doc.data : {}) as Record<string, unknown>;
@@ -284,6 +290,16 @@ const publishBlocked =
284
290
  >
285
291
  Save translation
286
292
  </button>
293
+ ) : isSubmissionView && documentId ? (
294
+ <form method="post" action={getFormAction(collection.slug, documentId)}>
295
+ <input type="hidden" name="_action" value="update" />
296
+ <input type="hidden" name="status" value={doc?.status === "archived" ? "read" : "archived"} />
297
+ <input type="hidden" name="redirectTo" value={`/admin/${collection.slug}`} />
298
+ <button class={buttonVariants({ variant: "outline" })} type="submit">
299
+ <Archive className="size-3.5" />
300
+ {doc?.status === "archived" ? "Unarchive" : "Archive"}
301
+ </button>
302
+ </form>
287
303
  ) : (
288
304
  <>
289
305
  <button
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kidecms/core",
3
- "version": "0.17.1",
3
+ "version": "0.18.0",
4
4
  "description": "Kide CMS runtime — core library, admin UI, routes, and middleware for Astro. Shipped as TypeScript source.",
5
5
  "keywords": [
6
6
  "cms",