@@ -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 - z 0 - 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
259177export function MultiSelectField ( {
0 commit comments