Skip to content

Commit da1810d

Browse files
guitavanoclaude
andcommitted
remove SlugField format support from cms-form
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 8afe6a0 commit da1810d

2 files changed

Lines changed: 0 additions & 93 deletions

File tree

web/tools/file-explorer/cms-form-extras.tsx

Lines changed: 0 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ import {
5656
Train,
5757
Trophy,
5858
Truck,
59-
Unlock,
6059
Upload,
6160
User,
6261
Users,
@@ -173,87 +172,6 @@ export function TagsField({
173172
);
174173
}
175174

176-
// ─── 3. SlugField — auto-generated URL slug with lock ────────────────────────
177-
178-
function slugify(input: string): string {
179-
return input
180-
.toLowerCase()
181-
.normalize("NFKD")
182-
.replace(/[̀-ͯ]/g, "")
183-
.replace(/[^a-z0-9\s-]/g, "")
184-
.trim()
185-
.replace(/\s+/g, "-")
186-
.replace(/-+/g, "-");
187-
}
188-
189-
export function SlugField({
190-
label,
191-
description,
192-
value,
193-
onChange,
194-
prefix = "/",
195-
}: {
196-
label: string;
197-
description?: string;
198-
value: string;
199-
onChange: (v: string) => void;
200-
prefix?: string;
201-
}) {
202-
const [locked, setLocked] = useState(true);
203-
const [draft, setDraft] = useState(value);
204-
205-
useEffect(() => {
206-
setDraft(value);
207-
}, [value]);
208-
209-
return (
210-
<div className="space-y-2">
211-
<FieldLabel label={label} description={description} />
212-
<div className="flex h-10 w-full items-center rounded-md border border-input bg-transparent text-sm shadow-xs focus-within:border-ring focus-within:ring-[3px] focus-within:ring-ring/50">
213-
<span className="flex h-full select-none items-center border-r bg-muted/30 px-3 font-mono text-xs text-muted-foreground">
214-
{prefix}
215-
</span>
216-
<input
217-
value={draft}
218-
disabled={locked}
219-
onChange={(e) => {
220-
const v = slugify(e.target.value);
221-
setDraft(v);
222-
onChange(v);
223-
}}
224-
placeholder="my-awesome-page"
225-
className="flex-1 bg-transparent px-3 font-mono text-sm outline-none placeholder:text-muted-foreground disabled:opacity-60"
226-
/>
227-
<button
228-
type="button"
229-
onClick={() => setLocked((l) => !l)}
230-
className="flex h-full items-center gap-1.5 border-l px-3 text-xs text-muted-foreground transition-colors hover:bg-accent hover:text-foreground"
231-
title={locked ? "Unlock to edit" : "Lock"}
232-
>
233-
{locked ? (
234-
<>
235-
<Lock className="h-3 w-3" />
236-
Locked
237-
</>
238-
) : (
239-
<>
240-
<Unlock className="h-3 w-3" />
241-
Edit
242-
</>
243-
)}
244-
</button>
245-
</div>
246-
<p className="text-xs text-muted-foreground">
247-
Preview:{" "}
248-
<span className="font-mono text-foreground">
249-
{prefix}
250-
{draft || "your-slug"}
251-
</span>
252-
</p>
253-
</div>
254-
);
255-
}
256-
257175
// ─── 4. MultiSelectField — chip selector with enum ───────────────────────────
258176

259177
export function MultiSelectField({

web/tools/file-explorer/cms-form.tsx

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ import {
9191
MultiSelectField,
9292
RangeField,
9393
ReferenceField,
94-
SlugField,
9594
SwitchField,
9695
TagsField,
9796
TimeField,
@@ -2757,16 +2756,6 @@ function FormField({
27572756
);
27582757
}
27592758
// ── format-based widgets ──────────────────────────────────
2760-
if (schemaFormat === "slug") {
2761-
return (
2762-
<SlugField
2763-
label={label}
2764-
description={description}
2765-
value={effectiveValue as string}
2766-
onChange={onChange as (v: string) => void}
2767-
/>
2768-
);
2769-
}
27702759
if (schemaFormat === "url") {
27712760
return (
27722761
<UrlField

0 commit comments

Comments
 (0)