@@ -4,36 +4,41 @@ import {
44 Code ,
55 FileJson ,
66 GitBranch ,
7- User ,
87 Package ,
8+ Pencil ,
9+ PencilOff ,
910 RefreshCw ,
11+ User ,
1012} from "lucide-react" ;
1113import React , { useState } from "react" ;
1214import { exampleSchema } from "../../demo/utils/schemaExample.ts" ;
13- import JsonSchemaEditor from "../../src/components/SchemaEditor/JsonSchemaEditor.tsx" ;
1415import { JsonValidator } from "../../src/components/features/JsonValidator.tsx" ;
1516import { SchemaInferencer } from "../../src/components/features/SchemaInferencer.tsx" ;
17+ import JsonSchemaEditor from "../../src/components/SchemaEditor/JsonSchemaEditor.tsx" ;
1618import { Button } from "../../src/components/ui/button.tsx" ;
17- import type { JSONSchema } from "../../src/types/jsonSchema.ts" ;
18- import { en } from "../../src/i18n/locales/en.ts" ;
1919import {
2020 Select ,
2121 SelectContent ,
2222 SelectItem ,
2323 SelectTrigger ,
2424 SelectValue ,
2525} from "../../src/components/ui/select.tsx" ;
26+ import { en } from "../../src/i18n/locales/en.ts" ;
2627import { TranslationContext } from "../../src/i18n/translation-context.ts" ;
28+ import type { JSONSchema } from "../../src/types/jsonSchema.ts" ;
2729
2830const Index = ( ) => {
2931 const [ schema , setSchema ] = useState < JSONSchema > ( exampleSchema ) ;
32+ const [ readOnly , setReadOnly ] = useState < boolean > ( false ) ;
3033 const [ inferDialogOpen , setInferDialogOpen ] = useState ( false ) ;
3134 const [ validateDialogOpen , setValidateDialogOpen ] = useState ( false ) ;
3235 const [ language , setLanguage ] = useState ( "en" ) ;
3336 const [ translation , setTranslation ] = useState ( en ) ;
3437
3538 const handleReset = ( ) => setSchema ( exampleSchema ) ;
3639
40+ const handleReadOnlyToggle = ( ) => setReadOnly ( ! readOnly ) ;
41+
3742 const handleClear = ( ) =>
3843 setSchema ( {
3944 type : "object" ,
@@ -90,42 +95,68 @@ const Index = () => {
9095
9196 { /* Action Buttons */ }
9297 < div className = "flex flex-wrap justify-center gap-4 mb-8 animate-in" >
93- < Button variant = "outline" onClick = { handleReset } className = "gap-2" >
94- < RefreshCw size = { 16 } />
95- Reset to Example
96- </ Button >
97- < Button variant = "outline" onClick = { handleClear } className = "gap-2" >
98- < CirclePlus size = { 16 } />
99- Start from Scratch
100- </ Button >
101- < Button
102- variant = "outline"
103- onClick = { handleInferSchema }
104- className = "gap-2"
105- >
106- < Code size = { 16 } />
107- Infer from JSON
108- </ Button >
109- < Button
110- variant = "outline"
111- onClick = { handleValidateJson }
112- className = "gap-2"
113- >
114- < CheckCircle size = { 16 } />
115- Validate JSON
116- </ Button >
117- < div >
118- < Select value = { language } onValueChange = { handleLanguageChange } >
119- < SelectTrigger className = "h-10 font-medium" >
120- < SelectValue placeholder = "Language" />
121- </ SelectTrigger >
122- < SelectContent >
123- < SelectItem value = "en" > English</ SelectItem >
124- < SelectItem value = "de" > German</ SelectItem >
125- < SelectItem value = "fr" > French</ SelectItem >
126- < SelectItem value = "ru" > Russian</ SelectItem >
127- </ SelectContent >
128- </ Select >
98+ < div className = "flex flex-nowrap gap-4" >
99+ < Button
100+ variant = "outline"
101+ onClick = { handleReset }
102+ className = "gap-2"
103+ >
104+ < RefreshCw size = { 16 } />
105+ Reset to Example
106+ </ Button >
107+ < Button
108+ variant = "outline"
109+ onClick = { handleClear }
110+ className = "gap-2"
111+ >
112+ < CirclePlus size = { 16 } />
113+ Start from Scratch
114+ </ Button >
115+ < Button
116+ variant = "outline"
117+ onClick = { handleInferSchema }
118+ className = "gap-2"
119+ >
120+ < Code size = { 16 } />
121+ Infer from JSON
122+ </ Button >
123+ < Button
124+ variant = "outline"
125+ onClick = { handleValidateJson }
126+ className = "gap-2"
127+ >
128+ < CheckCircle size = { 16 } />
129+ Validate JSON
130+ </ Button >
131+ < Button
132+ variant = "outline"
133+ onClick = { handleReadOnlyToggle }
134+ className = "gap-2"
135+ >
136+ { ! readOnly && (
137+ < >
138+ < PencilOff size = { 16 } /> Read-Only
139+ </ >
140+ ) }
141+ { readOnly && (
142+ < >
143+ < Pencil size = { 16 } /> Writable
144+ </ >
145+ ) }
146+ </ Button >
147+ < div >
148+ < Select value = { language } onValueChange = { handleLanguageChange } >
149+ < SelectTrigger className = "h-10 font-medium" >
150+ < SelectValue placeholder = "Language" />
151+ </ SelectTrigger >
152+ < SelectContent >
153+ < SelectItem value = "en" > English</ SelectItem >
154+ < SelectItem value = "de" > German</ SelectItem >
155+ < SelectItem value = "fr" > French</ SelectItem >
156+ < SelectItem value = "ru" > Russian</ SelectItem >
157+ </ SelectContent >
158+ </ Select >
159+ </ div >
129160 </ div >
130161 </ div >
131162 </ div >
@@ -137,6 +168,7 @@ const Index = () => {
137168 < div className = "max-w-4xl mx-auto lg:max-w-none" >
138169 < JsonSchemaEditor
139170 schema = { schema }
171+ readOnly = { readOnly }
140172 setSchema = { setSchema }
141173 className = "shadow-lg animate-in border-border/50 backdrop-blur-xs"
142174 />
@@ -427,7 +459,9 @@ const Index = () => {
427459 < link . icon size = { 14 } className = "opacity-70" />
428460 < span > { link . text } </ span >
429461 </ a >
430- { index < array . length - 1 && < span className = "mx-1" > •</ span > }
462+ { index < array . length - 1 && (
463+ < span className = "mx-1" > •</ span >
464+ ) }
431465 </ React . Fragment >
432466 ) ) }
433467 </ div >
0 commit comments