json-schema-builder-react 1.0.0 → 1.0.1
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/dist-lib/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),y=require("react"),be=require("@radix-ui/react-slot"),le=require("class-variance-authority"),Ne=require("clsx"),we=require("tailwind-merge"),f=require("lucide-react"),Ce=require("@radix-ui/react-tooltip"),ke=require("@radix-ui/react-select"),Se=require("@radix-ui/react-dialog"),Ie=require("@radix-ui/react-label"),Te=require("@radix-ui/react-checkbox");function z(t){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const s in t)if(s!=="default"){const n=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(a,s,n.get?n:{enumerable:!0,get:()=>t[s]})}}return a.default=t,Object.freeze(a)}const v=z(y),F=z(Ce),N=z(ke),P=z(Se),de=z(Ie),X=z(Te);function x(...t){return we.twMerge(Ne.clsx(t))}const De=le.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-full text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-full px-3 text-xs",lg:"h-10 rounded-full px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),T=v.forwardRef(({className:t,variant:a,size:s,asChild:n=!1,...i},r)=>{const l=n?be.Slot:"button";return e.jsx(l,{className:x(De({variant:a,size:s,className:t})),ref:r,...i})});T.displayName="Button";const q=v.forwardRef(({className:t,type:a,...s},n)=>e.jsx("input",{type:a,className:x("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),ref:n,...s}));q.displayName="Input";const qe=F.Provider,Re=F.Root,Ee=F.Trigger,oe=v.forwardRef(({className:t,sideOffset:a=4,...s},n)=>e.jsx(F.Portal,{children:e.jsx(F.Content,{ref:n,sideOffset:a,className:x("z-50 overflow-hidden rounded-md bg-popover px-3 py-1.5 text-xs text-popover-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-tooltip-content-transform-origin]",t),...s})}));oe.displayName=F.Content.displayName;const G=N.Root,Q=N.Value,J=v.forwardRef(({className:t,children:a,...s},n)=>e.jsxs(N.Trigger,{ref:n,className:x("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",t),...s,children:[a,e.jsx(N.Icon,{asChild:!0,children:e.jsx(f.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));J.displayName=N.Trigger.displayName;const ce=v.forwardRef(({className:t,...a},s)=>e.jsx(N.ScrollUpButton,{ref:s,className:x("flex cursor-default items-center justify-center py-1",t),...a,children:e.jsx(f.ChevronUp,{className:"h-4 w-4"})}));ce.displayName=N.ScrollUpButton.displayName;const me=v.forwardRef(({className:t,...a},s)=>e.jsx(N.ScrollDownButton,{ref:s,className:x("flex cursor-default items-center justify-center py-1",t),...a,children:e.jsx(f.ChevronDown,{className:"h-4 w-4"})}));me.displayName=N.ScrollDownButton.displayName;const V=v.forwardRef(({className:t,children:a,position:s="popper",...n},i)=>e.jsx(N.Portal,{children:e.jsxs(N.Content,{ref:i,className:x("relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-select-content-transform-origin]",s==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:s,...n,children:[e.jsx(ce,{}),e.jsx(N.Viewport,{className:x("p-1",s==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:a}),e.jsx(me,{})]})}));V.displayName=N.Content.displayName;const Pe=v.forwardRef(({className:t,...a},s)=>e.jsx(N.Label,{ref:s,className:x("px-2 py-1.5 text-sm font-semibold",t),...a}));Pe.displayName=N.Label.displayName;const I=v.forwardRef(({className:t,children:a,...s},n)=>e.jsxs(N.Item,{ref:n,className:x("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...s,children:[e.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(N.ItemIndicator,{children:e.jsx(f.Check,{className:"h-4 w-4"})})}),e.jsx(N.ItemText,{children:a})]}));I.displayName=N.Item.displayName;const Le=v.forwardRef(({className:t,...a},s)=>e.jsx(N.Separator,{ref:s,className:x("-mx-1 my-1 h-px bg-muted",t),...a}));Le.displayName=N.Separator.displayName;const Oe=P.Root,Fe=P.Portal,ue=v.forwardRef(({className:t,...a},s)=>e.jsx(P.Overlay,{ref:s,className:x("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...a}));ue.displayName=P.Overlay.displayName;const he=v.forwardRef(({className:t,children:a,...s},n)=>e.jsxs(Fe,{children:[e.jsx(ue,{}),e.jsxs(P.Content,{ref:n,className:x("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t),...s,children:[a,e.jsxs(P.Close,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[e.jsx(f.X,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));he.displayName=P.Content.displayName;const xe=({className:t,...a})=>e.jsx("div",{className:x("flex flex-col space-y-1.5 text-center sm:text-left",t),...a});xe.displayName="DialogHeader";const fe=({className:t,...a})=>e.jsx("div",{className:x("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...a});fe.displayName="DialogFooter";const pe=v.forwardRef(({className:t,...a},s)=>e.jsx(P.Title,{ref:s,className:x("text-lg font-semibold leading-none tracking-tight",t),...a}));pe.displayName=P.Title.displayName;const ze=v.forwardRef(({className:t,...a},s)=>e.jsx(P.Description,{ref:s,className:x("text-sm text-muted-foreground",t),...a}));ze.displayName=P.Description.displayName;const Be=le.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),b=v.forwardRef(({className:t,...a},s)=>e.jsx(de.Root,{ref:s,className:x(Be(),t),...a}));b.displayName=de.Root.displayName;const W=v.forwardRef(({className:t,...a},s)=>e.jsx(X.Root,{ref:s,className:x("grid place-content-center peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",t),...a,children:e.jsx(X.Indicator,{className:x("grid place-content-center text-current"),children:e.jsx(f.Check,{className:"h-4 w-4"})})}));W.displayName=X.Root.displayName;const se=v.forwardRef(({className:t,...a},s)=>e.jsx("textarea",{className:x("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),ref:s,...a}));se.displayName="Textarea";const Ae=t=>t.trim().toLowerCase().replace(/[^\w\s]/g,"").replace(/\s+/g,"_"),Me=(t,a,s=!1,n=!1)=>{const i=(u,g)=>{a({...t,[u]:g})};return{handleTitleChange:u=>{i("title",u)},handleTitleBlur:()=>{if(s&&t.title){const u=Ae(t.title);i("key",u)}},handleKeyChange:u=>{(s||n)&&i("key",u)},handleFieldChange:i,handleConstraintChange:(u,g)=>{a({...t,[u]:g})}}},Y={string:"String",number:"Number",integer:"Integer",boolean:"Boolean",object:"Object",array:"Array",null:"Null",file:"File"},M={getTypeLabel:t=>Y[t],typeLabels:Y,propertyLabel:{singular:"property",plural:"properties"},showRegex:!1,keyEditable:!1,readonly:!1},ge=y.createContext(M);function _e({children:t,config:a={}}){const s={...Y,...a.typeLabels},n=a.propertyLabel||M.propertyLabel,i=a.showRegex??M.showRegex,r=a.keyEditable??M.keyEditable,l=a.readonly??M.readonly,o=C=>s[C]||C;return e.jsx(ge.Provider,{value:{getTypeLabel:o,typeLabels:s,propertyLabel:n,showRegex:i,keyEditable:r,readonly:l},children:t})}function je(){return y.useContext(ge)}function H({property:t,open:a,onOpenChange:s,onSave:n,isArrayItem:i=!1,isNewProperty:r=!1,propertyLabel:l,showRegex:o,keyEditable:C,typeLabels:u}){const g=je(),h=u||g.typeLabels,j=l||g.propertyLabel,w=o??g.showRegex,c=C??g.keyEditable,[d,k]=y.useState(t);y.useEffect(()=>{a&&k(t)},[t,a]);const{handleTitleChange:E,handleTitleBlur:O,handleKeyChange:D,handleFieldChange:p,handleConstraintChange:R}=Me(d,k,r,c),L=()=>{d.title?.trim()&&(n(d),s(!1))},U=()=>{k(t),s(!1)};return e.jsx(Oe,{open:a,onOpenChange:s,children:e.jsxs(he,{className:"max-w-2xl max-h-[80vh] flex flex-col gap-0 p-0","data-testid":"dialog-edit-property",children:[e.jsx(xe,{className:"px-6 pt-6 pb-4 shrink-0",children:e.jsx(pe,{children:r?`Add ${j.singular}`:`Edit ${j.singular}`})}),e.jsxs("div",{className:"space-y-6 px-6 pb-4 overflow-y-auto flex-1 min-h-0",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(b,{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-red-500"}),"Type"]}),e.jsxs(G,{value:d.type,onValueChange:m=>p("type",m),"data-testid":"select-type-dialog",children:[e.jsx(J,{children:e.jsx(Q,{})}),e.jsxs(V,{children:[e.jsx(I,{value:"string",children:h.string}),e.jsx(I,{value:"number",children:h.number}),e.jsx(I,{value:"integer",children:h.integer}),e.jsx(I,{value:"boolean",children:h.boolean}),e.jsx(I,{value:"object",children:h.object}),e.jsx(I,{value:"array",children:h.array}),e.jsx(I,{value:"file",children:h.file}),e.jsx(I,{value:"null",children:h.null})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(b,{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-red-500"}),"Title"]}),e.jsx(q,{value:d.title||"",onChange:m=>E(m.target.value),onBlur:O,placeholder:"Property Title","data-testid":"input-title-dialog",required:!0}),!r&&d.key&&e.jsxs("p",{className:"text-xs text-muted-foreground font-mono",children:["Key: ",d.key]})]}),(r||c)&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"Key"}),e.jsx(q,{value:d.key,onChange:m=>D(m.target.value),placeholder:"property_key","data-testid":"input-key-dialog"}),!r&&e.jsx("p",{className:"text-xs text-yellow-600 dark:text-yellow-500",children:"⚠️ Changing the key may break existing references to this property"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"Description"}),e.jsx(se,{placeholder:"Optional description",value:d.description||"",onChange:m=>p("description",m.target.value),rows:2,"data-testid":"input-edit-description"})]}),d.type==="array"&&e.jsxs("div",{className:"space-y-2 border-l-2 border-border pl-4 mt-2",children:[e.jsxs(b,{className:"font-semibold text-xs text-muted-foreground",children:[h.array," Items"]}),d.items?e.jsxs("div",{className:"bg-muted/40 p-2 rounded",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"Item Type"}),e.jsxs(G,{value:d.items.type,onValueChange:m=>k({...d,items:{...d.items,type:m}}),children:[e.jsx(J,{children:e.jsx(Q,{})}),e.jsxs(V,{children:[e.jsx(I,{value:"string",children:h.string}),e.jsx(I,{value:"number",children:h.number}),e.jsx(I,{value:"integer",children:h.integer}),e.jsx(I,{value:"boolean",children:h.boolean}),e.jsx(I,{value:"object",children:h.object}),e.jsx(I,{value:"array",children:h.array}),e.jsx(I,{value:"file",children:h.file}),e.jsx(I,{value:"null",children:h.null})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"Item Title"}),e.jsx(q,{value:d.items.title||"",onChange:m=>k({...d,items:{...d.items,title:m.target.value}}),placeholder:"Item Title"})]}),e.jsxs(T,{variant:"ghost",size:"sm",className:"mt-2",onClick:()=>k({...d,items:void 0}),children:["Remove ",h.array," Item Schema"]})]}):e.jsxs(T,{variant:"outline",size:"sm",onClick:()=>{k({...d,items:{id:Date.now().toString()+Math.random(),key:"item",type:"string",required:!1}})},children:["Add ",h.array," Item Schema"]})]}),!i&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(W,{id:"prop-required",checked:d.required,onCheckedChange:m=>p("required",m),"data-testid":"checkbox-edit-required"}),e.jsx(b,{htmlFor:"prop-required",className:"cursor-pointer",children:"Required field"})]}),d.type==="string"&&e.jsxs("details",{className:"border rounded-md",children:[e.jsx("summary",{className:"p-4 cursor-pointer hover:bg-accent/50 transition-colors",children:e.jsxs("h4",{className:"text-sm font-medium inline",children:[h.string," Constraints"]})}),e.jsxs("div",{className:"space-y-4 p-4 pt-0",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"min-length",children:"Minimum Length"}),e.jsx(q,{id:"min-length",type:"number",placeholder:"0",value:d.minLength||"",onChange:m=>R("minLength",m.target.value?parseInt(m.target.value):void 0),"data-testid":"input-edit-minlength"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"max-length",children:"Maximum Length"}),e.jsx(q,{id:"max-length",type:"number",placeholder:"∞",value:d.maxLength||"",onChange:m=>R("maxLength",m.target.value?parseInt(m.target.value):void 0),"data-testid":"input-edit-maxlength"})]})]}),w&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"pattern",children:"Pattern (regex)"}),e.jsx(q,{id:"pattern",placeholder:"^[a-z]+$",value:d.pattern||"",onChange:m=>R("pattern",m.target.value),className:"font-mono text-sm","data-testid":"input-edit-pattern"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"Enum Values"}),e.jsx("div",{className:"space-y-2",children:[...d.enum||[],""].map((m,S)=>e.jsx(q,{placeholder:S===(d.enum?.length||0)?"Add new value...":"Enum value",value:m,onChange:B=>{const _=B.target.value,$=d.enum||[];if(S===$.length)_.trim()&&R("enum",[...$,_.trim()]);else if(_.trim()){const A=[...$];A[S]=_.trim(),R("enum",A)}else{const A=$.filter((st,ve)=>ve!==S);R("enum",A.length>0?A:void 0)}},"data-testid":`input-edit-enum-${S}`},S))}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Enter allowed values (empty fields will be removed)"})]})]})]}),(d.type==="number"||d.type==="integer")&&e.jsxs("details",{className:"border rounded-md",children:[e.jsx("summary",{className:"p-4 cursor-pointer hover:bg-accent/50 transition-colors",children:e.jsx("h4",{className:"text-sm font-medium inline",children:"Numeric Constraints"})}),e.jsx("div",{className:"space-y-4 p-4 pt-0",children:e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"minimum",children:"Minimum Value"}),e.jsx(q,{id:"minimum",type:"number",placeholder:"-∞",value:d.minimum??"",onChange:m=>R("minimum",m.target.value?parseFloat(m.target.value):void 0),"data-testid":"input-edit-minimum"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"maximum",children:"Maximum Value"}),e.jsx(q,{id:"maximum",type:"number",placeholder:"∞",value:d.maximum??"",onChange:m=>R("maximum",m.target.value?parseFloat(m.target.value):void 0),"data-testid":"input-edit-maximum"})]})]})})]}),d.type==="array"&&e.jsxs("details",{className:"border rounded-md",children:[e.jsx("summary",{className:"p-4 cursor-pointer hover:bg-accent/50 transition-colors",children:e.jsxs("h4",{className:"text-sm font-medium inline",children:[h.array," Constraints"]})}),e.jsxs("div",{className:"space-y-4 p-4 pt-0",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"min-items",children:"Minimum Items"}),e.jsx(q,{id:"min-items",type:"number",placeholder:"0",value:d.minItems||"",onChange:m=>R("minItems",m.target.value?parseInt(m.target.value):void 0),"data-testid":"input-edit-minitems"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"max-items",children:"Maximum Items"}),e.jsx(q,{id:"max-items",type:"number",placeholder:"∞",value:d.maxItems||"",onChange:m=>R("maxItems",m.target.value?parseInt(m.target.value):void 0),"data-testid":"input-edit-maxitems"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(W,{id:"unique-items",checked:d.uniqueItems||!1,onCheckedChange:m=>R("uniqueItems",m),"data-testid":"checkbox-edit-unique"}),e.jsx(b,{htmlFor:"unique-items",className:"cursor-pointer",children:"All items must be unique"})]})]})]})]}),e.jsxs(fe,{className:"px-6 py-4 border-t bg-background shrink-0",children:[e.jsx(T,{variant:"outline",onClick:U,"data-testid":"button-cancel",children:"Cancel"}),e.jsx(T,{onClick:L,"data-testid":"button-save",disabled:!d.title?.trim(),children:"Save Changes"})]})]})})}function re(t,a,s={}){const{allowEmpty:n=!1,onEditStart:i,onEditCancel:r}=s,[l,o]=y.useState(!1),[C,u]=y.useState(t);y.useEffect(()=>{l||u(t)},[t,l]);const g=()=>{u(t),o(!0),i?.()},h=c=>{u(c)},j=()=>{const c=C.trim();if(!n&&!c){u(t),o(!1);return}c!==t&&a(c),o(!1)};return{isEditing:l,value:C,startEdit:g,handleChange:h,handleBlur:j,handleKeyDown:c=>{c.key==="Enter"?j():c.key==="Escape"&&(u(t),o(!1),r?.())}}}function $e(t,a){const[s,n]=y.useState(!1);return{isChangingType:s,setIsChangingType:n,handleTypeChange:l=>{const o={...t,type:l};l!=="string"&&(delete o.minLength,delete o.maxLength,delete o.pattern,delete o.enum),l!=="number"&&l!=="integer"&&(delete o.minimum,delete o.maximum),l!=="array"&&(delete o.minItems,delete o.maxItems,delete o.uniqueItems,delete o.items),l!=="object"&&delete o.children,a(o),n(!1)},availableTypes:["string","number","integer","boolean","object","array","file"]}}const ae=()=>`${Date.now()}-${Math.random()}`;function ie(t={}){const{onConfirm:a,onCancel:s,createInitialData:n}=t,[i,r]=y.useState(!1),[l,o]=y.useState(null),C=j=>{const w=j??(n?n():null);o(w),r(!0)},u=()=>{r(!1),o(null),s?.()};return{isOpen:i,data:l,open:C,close:u,confirm:j=>{a?.(j),r(!1),o(null)},setIsOpen:j=>{j?r(!0):u()}}}function Ke(t,a){const s=ie({createInitialData:()=>({id:ae(),key:"",type:"string",required:!1}),onConfirm:r=>{a({...t,children:[...t.children||[],r]})}});return{addChild:()=>s.open(),updateChild:(r,l)=>{const o=t.children.map(C=>C.id===r?l:C);a({...t,children:o})},deleteChild:r=>{const l=t.children.filter(o=>o.id!==r);a({...t,children:l})},addChildDialog:{isOpen:s.isOpen,data:s.data,setIsOpen:s.setIsOpen,confirm:s.confirm}}}function Z({property:t,onUpdate:a,onDelete:s,level:n=1,isArrayItem:i=!1}){const{getTypeLabel:r,typeLabels:l,showRegex:o,keyEditable:C,readonly:u}=je(),g=ie(),h=re(t.title||t.key||"",p=>a({...t,title:p}),{allowEmpty:!1}),j=re(t.description||"",p=>a({...t,description:p||void 0}),{allowEmpty:!0}),w=$e(t,a),c=Ke(t,a),d=`h${Math.min(n,6)}`,k=t.type==="object",E=k&&t.children&&t.children.length>0,O={1:"text-lg font-semibold",2:"text-base",3:"text-base",4:"text-base",5:"text-sm",6:"text-sm"}[n]||"text-sm",D={1:"h-5 w-5",2:"h-4 w-4",3:"h-4 w-4",4:"h-4 w-4",5:"h-4 w-4",6:"h-4 w-4"}[n]||"h-5 w-5";return e.jsxs("div",{className:"group",children:[e.jsxs("div",{className:"flex gap-4 items-center rounded-md -mx-2 px-2 py-1 transition-colors hover:bg-accent/50",children:[e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("div",{className:"flex items-start gap-3",children:[!i&&e.jsx("button",{onClick:()=>!u&&a({...t,required:!t.required}),className:u?"shrink-0 -mt-[3px] cursor-default":"shrink-0 transition-all hover:scale-110 -mt-[3px]",title:u?t.required?"Required field":"Optional field":t.required?"Required field - click to make optional":"Optional field - click to make required",children:t.required?e.jsx(f.Asterisk,{className:"w-6 h-6 text-primary"}):e.jsx(f.Asterisk,{className:"w-6 h-6 text-border"})}),h.isEditing?e.jsx(q,{value:h.value,onChange:p=>h.handleChange(p.target.value),onBlur:h.handleBlur,onKeyDown:h.handleKeyDown,autoFocus:!0,className:O,placeholder:"Enter title"}):e.jsxs("div",{className:"flex gap-2 flex-wrap flex-1",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(d,{className:u?`${O} leading-none`:`${O} cursor-pointer hover:text-primary transition-colors leading-none`,onClick:u?void 0:h.startEdit,children:t.title||t.key||e.jsx("span",{className:"text-muted-foreground italic",children:"unnamed"})}),w.isChangingType?e.jsxs(G,{value:t.type,onValueChange:p=>w.handleTypeChange(p),open:w.isChangingType,onOpenChange:w.setIsChangingType,children:[e.jsx(J,{className:"w-[140px] h-7",children:e.jsx(Q,{})}),e.jsx(V,{children:w.availableTypes.map(p=>e.jsx(I,{value:p,children:l[p]},p))})]}):e.jsx(qe,{children:e.jsxs(Re,{children:[e.jsx(Ee,{asChild:!0,children:e.jsxs("button",{onClick:()=>!u&&w.setIsChangingType(!0),className:u?"rounded p-0.5 -mt-0.5 cursor-default":"cursor-pointer hover:bg-accent rounded p-0.5 -mt-0.5 transition-colors",children:[t.type==="string"&&e.jsx(f.Type,{className:x(D,"text-muted-foreground")}),t.type==="number"&&e.jsx(f.Hash,{className:x(D,"text-muted-foreground")}),t.type==="integer"&&e.jsx(f.Hash,{className:x(D,"text-muted-foreground")}),t.type==="boolean"&&e.jsx(f.CheckSquare,{className:x(D,"text-muted-foreground")}),t.type==="object"&&e.jsx(f.Braces,{className:x(D,"text-muted-foreground")}),t.type==="array"&&e.jsx(f.List,{className:x(D,"text-muted-foreground")}),t.type==="file"&&e.jsx(f.FileText,{className:x(D,"text-muted-foreground")})]})}),e.jsxs(oe,{children:[r(t.type),t.type==="array"&&t.items?` of ${r(t.items.type)}`:"",!u&&e.jsx("div",{className:"text-xs text-muted-foreground mt-1",children:"Click to change type"})]})]})}),t.type==="object"&&!u&&e.jsx(T,{variant:"ghost",size:"icon",className:"h-4 w-4",onClick:c.addChild,"data-testid":`button-add-child-${t.id}`,children:e.jsx(f.Plus,{})})]}),e.jsx("div",{className:"flex-1",children:j.isEditing?e.jsx(q,{value:j.value,onChange:p=>j.handleChange(p.target.value),onBlur:j.handleBlur,onKeyDown:j.handleKeyDown,autoFocus:!0,className:"text-sm flex-1",placeholder:"Enter description"}):e.jsx(e.Fragment,{children:t.description?e.jsx("p",{className:u?"text-sm text-muted-foreground flex-1 min-w-[200px]":"text-sm text-muted-foreground flex-1 min-w-[200px] cursor-pointer hover:text-foreground transition-colors","data-testid":`text-description-${t.id}`,onClick:u?void 0:j.startEdit,children:t.description}):!u&&e.jsx("p",{className:"text-sm text-muted-foreground/50 flex-1 min-w-[200px] cursor-pointer hover:text-muted-foreground italic transition-colors",onClick:j.startEdit,children:"Add description..."})})})]})]})}),!u&&e.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity shrink-0",children:[e.jsx(T,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>g.open(t),"data-testid":`button-edit-${t.id}`,children:e.jsx(f.Pencil,{className:"w-3 h-3"})}),k&&t.type!=="object"&&e.jsx(T,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:c.addChild,"data-testid":`button-add-child-${t.id}`,children:e.jsx(f.Plus,{className:"w-3 h-3"})}),e.jsx(T,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive",onClick:s,"data-testid":`button-delete-${t.id}`,children:e.jsx(f.Trash2,{className:"w-3 h-3"})})]})]}),E&&e.jsx("div",{className:n===1?"ml-6 mt-1 border-l-2 border-border pl-6":"ml-4 mt-1 border-l border-border pl-4",children:t.children.map(p=>e.jsx(Z,{property:p,onUpdate:R=>c.updateChild(p.id,R),onDelete:()=>c.deleteChild(p.id),level:n+1},p.id))}),t.type==="array"&&t.items&&e.jsxs("div",{className:n===1?"ml-6 mt-1 border-l-2 border-border pl-6":"ml-4 mt-1 border-l border-border pl-4",children:[e.jsxs("div",{className:"mb-2 text-xs text-muted-foreground font-semibold uppercase",children:[r("array")," Items"]}),e.jsx(Z,{property:t.items,onUpdate:p=>a({...t,items:p}),onDelete:()=>a({...t,items:void 0}),level:n+1,isArrayItem:!0})]}),e.jsx(H,{property:g.data||t,open:g.isOpen,onOpenChange:g.setIsOpen,onSave:p=>{a(p),g.close()},isArrayItem:i,isNewProperty:!1}),c.addChildDialog.isOpen&&c.addChildDialog.data&&e.jsx(H,{property:c.addChildDialog.data,open:c.addChildDialog.isOpen,isNewProperty:!0,onOpenChange:c.addChildDialog.setIsOpen,onSave:c.addChildDialog.confirm})]})}const ne=v.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:x("rounded-xl border bg-card text-card-foreground",t),...a}));ne.displayName="Card";const Je=v.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:x("flex flex-col space-y-1.5 p-6",t),...a}));Je.displayName="CardHeader";const Ve=v.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:x("font-semibold leading-none tracking-tight",t),...a}));Ve.displayName="CardTitle";const He=v.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:x("text-sm text-muted-foreground",t),...a}));He.displayName="CardDescription";const Ue=v.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:x("p-6 pt-0",t),...a}));Ue.displayName="CardContent";const Xe=v.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:x("flex items-center p-6 pt-0",t),...a}));Xe.displayName="CardFooter";const Ge=()=>new Promise((t,a)=>{const s=document.createElement("input");s.type="file",s.accept=".json",s.onchange=n=>{const i=n.target.files?.[0];if(!i){a(new Error("No file selected"));return}const r=new FileReader;r.onload=l=>{try{const o=JSON.parse(l.target?.result);t(o)}catch{a(new Error("Invalid JSON file"))}},r.onerror=()=>a(new Error("Failed to read file")),r.readAsText(i)},s.click()}),ye=(t,a="schema.json")=>{const s=JSON.stringify(t,null,2),n=new Blob([s],{type:"application/json"}),i=URL.createObjectURL(n),r=document.createElement("a");r.href=i,r.download=a,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(i)};function Qe({schema:t}){const[a,s]=y.useState(!1),n=JSON.stringify(t,null,2),i=async()=>{await navigator.clipboard.writeText(n),s(!0),setTimeout(()=>s(!1),2e3)},r=()=>{ye(t,"schema.json")};return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[e.jsx("h2",{className:"text-sm font-medium",children:"JSON Schema Output"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(T,{variant:"outline",size:"sm",onClick:i,"data-testid":"button-copy",children:a?e.jsx(f.CheckCircle2,{className:"w-4 h-4"}):e.jsx(f.Copy,{className:"w-4 h-4"})}),e.jsx(T,{variant:"outline",size:"sm",onClick:r,"data-testid":"button-download",children:e.jsx(f.Download,{className:"w-4 h-4"})})]})]}),e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsx(ne,{className:"m-4 bg-muted/30",children:e.jsx("pre",{className:"p-6 text-xs font-mono overflow-auto","data-testid":"text-json-output",children:e.jsx("code",{children:n})})})})]})}function We({title:t,description:a,version:s,onUpdate:n,readonly:i=!1}){const[r,l]=y.useState(!1);return e.jsxs(ne,{className:"p-4",children:[e.jsxs(T,{variant:"ghost",onClick:()=>l(!r),className:"w-full justify-between px-2 h-auto hover:bg-transparent","data-testid":"button-toggle-metadata",children:[e.jsx("h3",{className:"text-sm font-medium",children:"Schema Metadata"}),r?e.jsx(f.ChevronDown,{className:"w-4 h-4"}):e.jsx(f.ChevronRight,{className:"w-4 h-4"})]}),r&&e.jsxs("div",{className:"mt-4 space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"schema-title",className:"text-xs text-muted-foreground",children:"Title"}),e.jsx(q,{id:"schema-title",placeholder:"My Schema",value:t,onChange:o=>n("title",o.target.value),"data-testid":"input-title",disabled:i})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"schema-description",className:"text-xs text-muted-foreground",children:"Description"}),e.jsx(se,{id:"schema-description",placeholder:"Describe your schema...",value:a,onChange:o=>n("description",o.target.value),className:"resize-none",rows:3,"data-testid":"input-schema-description",disabled:i})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"schema-version",className:"text-xs text-muted-foreground",children:"Version"}),e.jsx(q,{id:"schema-version",placeholder:"1.0.0",value:s,onChange:o=>n("version",o.target.value),"data-testid":"input-version",disabled:i})]})]})]})}const K=(t,a,s=!0)=>{const n={type:"object"};s&&a&&(a.title&&(n.title=a.title),a.description&&(n.description=a.description));const i=ee(t);Object.keys(i).length>0&&(n.properties=i);const r=t.filter(l=>l.required&&l.key).map(l=>l.key);return r.length>0&&(n.required=r),n},ee=t=>{const a={};return t.forEach(s=>{if(!s.key)return;const i={type:s.type==="file"?"string":s.type};if(s.title&&(i.title=s.title),s.description&&(i.description=s.description),s.type==="file"&&(i.format="filename"),s.type==="string"&&(s.minLength!==void 0&&(i.minLength=s.minLength),s.maxLength!==void 0&&(i.maxLength=s.maxLength),s.pattern&&(i.pattern=s.pattern),s.enum&&s.enum.length>0&&(i.enum=s.enum)),(s.type==="number"||s.type==="integer")&&(s.minimum!==void 0&&(i.minimum=s.minimum),s.maximum!==void 0&&(i.maximum=s.maximum)),s.type==="array"&&(s.minItems!==void 0&&(i.minItems=s.minItems),s.maxItems!==void 0&&(i.maxItems=s.maxItems),s.uniqueItems&&(i.uniqueItems=s.uniqueItems),s.items&&(i.items=ee([s.items])[s.items.key]||{type:s.items.type})),s.type==="object"&&s.children&&s.children.length>0){i.properties=ee(s.children);const r=s.children.filter(l=>l.required&&l.key).map(l=>l.key);r.length>0&&(i.required=r)}a[s.key]=i}),a},Ye=t=>{const a={properties:[]};return(t.title||t.description)&&(a.metadata={title:typeof t.title=="string"?t.title:"",description:typeof t.description=="string"?t.description:"",version:"1.0.0"}),t.properties&&typeof t.properties=="object"&&(a.properties=te(t.properties,Array.isArray(t.required)?t.required:[])),a},te=(t,a=[])=>t?Object.entries(t).filter(([,s])=>typeof s=="object").map(([s,n])=>{const i=n;let r=typeof i.type=="string"?i.type:"string";r==="string"&&i.format==="filename"&&(r="file");const l={id:ae(),key:s,title:typeof i.title=="string"?i.title:void 0,type:r,description:typeof i.description=="string"?i.description:void 0,required:a.includes(s)};return i.minLength!==void 0&&(l.minLength=i.minLength),i.maxLength!==void 0&&(l.maxLength=i.maxLength),i.pattern&&(l.pattern=i.pattern),i.enum&&Array.isArray(i.enum)&&(l.enum=i.enum),i.minimum!==void 0&&(l.minimum=i.minimum),i.maximum!==void 0&&(l.maximum=i.maximum),i.minItems!==void 0&&(l.minItems=i.minItems),i.maxItems!==void 0&&(l.maxItems=i.maxItems),i.uniqueItems&&(l.uniqueItems=i.uniqueItems),l.type==="array"&&i.items&&typeof i.items=="object"&&!Array.isArray(i.items)&&(l.items=te({item:i.items},[]).find(o=>o.key==="item")),i.properties&&typeof i.properties=="object"&&(l.children=te(i.properties,Array.isArray(i.required)?i.required:[])),l}):[],Ze=({schema:t,onChange:a,includeMetadata:s=!0})=>{const{properties:n,metadata:i}=y.useMemo(()=>Ye(t),[t]),r=n,l=i||{title:"",description:"",version:""},o=y.useCallback(()=>({id:ae(),key:"",type:"string",required:!1}),[]),C=y.useCallback((c,d)=>{const k=r.some(D=>D.id===c);let E;k?E=r.map(D=>D.id===c?d:D):E=[...r,d];const O=K(E,l,s);a(O)},[r,l,s,a]),u=y.useCallback(c=>{const d=r.filter(E=>E.id!==c),k=K(d,l,s);a(k)},[r,l,s,a]),g=y.useCallback(()=>{const d=K([],{title:"",description:""},s);a(d)},[s,a]),h=y.useCallback((c,d)=>{const k={...l,[c]:d},E=K(r,k,s);a(E)},[r,l,s,a]),j=y.useCallback(async()=>{const c=await Ge();a(c)},[a]),w=y.useCallback(()=>{ye(t,"schema.json")},[t]);return{properties:r,metadata:l,addProperty:o,updateProperty:C,deleteProperty:u,clearAll:g,updateMetadata:h,importSchema:j,downloadSchema:w}};function et(){const[t,a]=y.useState("light");y.useEffect(()=>{const i=localStorage.getItem("theme")||(window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light");a(i),document.documentElement.classList.toggle("dark",i==="dark")},[]);const s=()=>{const n=t==="light"?"dark":"light";a(n),localStorage.setItem("theme",n),document.documentElement.classList.toggle("dark",n==="dark")};return e.jsx(T,{variant:"ghost",size:"icon",onClick:s,"data-testid":"button-theme-toggle",children:t==="light"?e.jsx(f.Moon,{className:"w-4 h-4"}):e.jsx(f.Sun,{className:"w-4 h-4"})})}function tt({schema:t,onChange:a,showMetadata:s=!1,showImport:n=!0,showClear:i=!0,showOutput:r=!0,showHeader:l=!0,className:o="",showSummary:C=!1,typeLabels:u,propertyLabel:g={singular:"property",plural:"properties"},showRegex:h=!1,keyEditable:j=!1,readonly:w=!1}){const{properties:c,metadata:d,addProperty:k,updateProperty:E,deleteProperty:O,clearAll:D,updateMetadata:p,importSchema:R}=Ze({schema:t,onChange:a,includeMetadata:s}),L=ie({createInitialData:()=>k(),onConfirm:S=>{E(S.id,S)}}),U=()=>{D()},m=async()=>{await R()};return e.jsx(_e,{config:{typeLabels:u,propertyLabel:g,showRegex:h,keyEditable:j,readonly:w},children:e.jsxs("div",{className:`${o} flex flex-col json-schema-builder-react`,children:[l&&e.jsx("header",{className:"h-16 border-b flex items-center justify-between px-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[!w&&n&&e.jsx(T,{variant:"outline",size:"sm",onClick:m,"data-testid":"button-import",children:e.jsx(f.Upload,{className:"w-4 h-4"})}),!w&&i&&e.jsx(T,{variant:"outline",size:"sm",onClick:U,disabled:c.length===0,"data-testid":"button-clear",children:e.jsx(f.Trash2,{className:"w-4 h-4"})}),e.jsx(et,{})]})}),e.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[e.jsx("div",{className:r?"w-3/5 border-r":"w-full",children:e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"flex-1 overflow-auto p-2 space-y-4",children:[s&&e.jsx(We,{title:d.title,description:d.description,version:d.version,onUpdate:(S,B)=>p(S,B),readonly:w}),c.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-muted flex items-center justify-center mb-4",children:e.jsx(f.Plus,{className:"w-8 h-8 text-muted-foreground"})}),e.jsxs("h2",{className:"text-lg font-medium mb-2",children:["No ",g.plural," yet"]}),!w&&e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"text-sm text-muted-foreground mb-6 max-w-sm",children:["Start building your JSON schema by adding your first"," ",g.singular]}),e.jsxs(T,{onClick:()=>L.open(),"data-testid":"button-add-first",children:[e.jsx(f.Plus,{className:"w-4 h-4 mr-2"}),"Add ",g.singular]})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"space-y-1",children:c.map(S=>e.jsx(Z,{property:S,onUpdate:B=>E(S.id,B),onDelete:()=>O(S.id)},S.id))}),C&&e.jsxs("div",{className:"pt-4 border-t flex items-center justify-between text-sm text-muted-foreground",children:[e.jsxs("span",{children:[c.length," ",c.length===1?g.singular:g.plural]}),e.jsxs("span",{children:[c.filter(S=>S.required).length," required"]})]})]})]}),c.length>0&&!w&&e.jsx("div",{className:"border-t p-2 pt-4 bg-background",children:e.jsxs(T,{onClick:()=>L.open(),className:"w-full",variant:"outline","data-testid":"button-add-property",children:[e.jsx(f.Plus,{className:"w-4 h-4"}),"Add ",g.singular]})})]})}),r&&e.jsx("div",{className:"w-2/5",children:e.jsx(Qe,{schema:t})})]}),L.isOpen&&L.data&&e.jsx(H,{property:L.data,open:L.isOpen,isNewProperty:!0,onOpenChange:L.setIsOpen,onSave:L.confirm})]})})}exports.JsonSchemaBuilder=tt;exports.PropertyEditDialog=H;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),y=require("react"),be=require("@radix-ui/react-slot"),le=require("class-variance-authority"),Ne=require("clsx"),we=require("tailwind-merge"),f=require("lucide-react"),Ce=require("@radix-ui/react-tooltip"),ke=require("@radix-ui/react-select"),Se=require("@radix-ui/react-dialog"),Ie=require("@radix-ui/react-label"),Te=require("@radix-ui/react-checkbox");function z(t){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const s in t)if(s!=="default"){const n=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(a,s,n.get?n:{enumerable:!0,get:()=>t[s]})}}return a.default=t,Object.freeze(a)}const v=z(y),F=z(Ce),w=z(ke),P=z(Se),de=z(Ie),X=z(Te);function x(...t){return we.twMerge(Ne.clsx(t))}const De=le.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-full text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-full px-3 text-xs",lg:"h-10 rounded-full px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),T=v.forwardRef(({className:t,variant:a,size:s,asChild:n=!1,...i},r)=>{const l=n?be.Slot:"button";return e.jsx(l,{className:x(De({variant:a,size:s,className:t})),ref:r,...i})});T.displayName="Button";const q=v.forwardRef(({className:t,type:a,...s},n)=>e.jsx("input",{type:a,className:x("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),ref:n,...s}));q.displayName="Input";const qe=F.Provider,Re=F.Root,Ee=F.Trigger,oe=v.forwardRef(({className:t,sideOffset:a=4,...s},n)=>e.jsx(F.Portal,{children:e.jsx(F.Content,{ref:n,sideOffset:a,className:x("z-50 overflow-hidden rounded-md bg-popover px-3 py-1.5 text-xs text-popover-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-tooltip-content-transform-origin]",t),...s})}));oe.displayName=F.Content.displayName;const G=w.Root,Q=w.Value,J=v.forwardRef(({className:t,children:a,...s},n)=>e.jsxs(w.Trigger,{ref:n,className:x("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",t),...s,children:[a,e.jsx(w.Icon,{asChild:!0,children:e.jsx(f.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));J.displayName=w.Trigger.displayName;const ce=v.forwardRef(({className:t,...a},s)=>e.jsx(w.ScrollUpButton,{ref:s,className:x("flex cursor-default items-center justify-center py-1",t),...a,children:e.jsx(f.ChevronUp,{className:"h-4 w-4"})}));ce.displayName=w.ScrollUpButton.displayName;const me=v.forwardRef(({className:t,...a},s)=>e.jsx(w.ScrollDownButton,{ref:s,className:x("flex cursor-default items-center justify-center py-1",t),...a,children:e.jsx(f.ChevronDown,{className:"h-4 w-4"})}));me.displayName=w.ScrollDownButton.displayName;const V=v.forwardRef(({className:t,children:a,position:s="popper",...n},i)=>e.jsx(w.Portal,{children:e.jsxs(w.Content,{ref:i,className:x("relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-select-content-transform-origin]",s==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:s,...n,children:[e.jsx(ce,{}),e.jsx(w.Viewport,{className:x("p-1",s==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:a}),e.jsx(me,{})]})}));V.displayName=w.Content.displayName;const Pe=v.forwardRef(({className:t,...a},s)=>e.jsx(w.Label,{ref:s,className:x("px-2 py-1.5 text-sm font-semibold",t),...a}));Pe.displayName=w.Label.displayName;const I=v.forwardRef(({className:t,children:a,...s},n)=>e.jsxs(w.Item,{ref:n,className:x("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...s,children:[e.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(w.ItemIndicator,{children:e.jsx(f.Check,{className:"h-4 w-4"})})}),e.jsx(w.ItemText,{children:a})]}));I.displayName=w.Item.displayName;const Le=v.forwardRef(({className:t,...a},s)=>e.jsx(w.Separator,{ref:s,className:x("-mx-1 my-1 h-px bg-muted",t),...a}));Le.displayName=w.Separator.displayName;const Oe=P.Root,Fe=P.Portal,ue=v.forwardRef(({className:t,...a},s)=>e.jsx(P.Overlay,{ref:s,className:x("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...a}));ue.displayName=P.Overlay.displayName;const he=v.forwardRef(({className:t,children:a,...s},n)=>e.jsxs(Fe,{children:[e.jsx(ue,{}),e.jsxs(P.Content,{ref:n,className:x("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t),...s,children:[a,e.jsxs(P.Close,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[e.jsx(f.X,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));he.displayName=P.Content.displayName;const xe=({className:t,...a})=>e.jsx("div",{className:x("flex flex-col space-y-1.5 text-center sm:text-left",t),...a});xe.displayName="DialogHeader";const fe=({className:t,...a})=>e.jsx("div",{className:x("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...a});fe.displayName="DialogFooter";const pe=v.forwardRef(({className:t,...a},s)=>e.jsx(P.Title,{ref:s,className:x("text-lg font-semibold leading-none tracking-tight",t),...a}));pe.displayName=P.Title.displayName;const ze=v.forwardRef(({className:t,...a},s)=>e.jsx(P.Description,{ref:s,className:x("text-sm text-muted-foreground",t),...a}));ze.displayName=P.Description.displayName;const Be=le.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),N=v.forwardRef(({className:t,...a},s)=>e.jsx(de.Root,{ref:s,className:x(Be(),t),...a}));N.displayName=de.Root.displayName;const W=v.forwardRef(({className:t,...a},s)=>e.jsx(X.Root,{ref:s,className:x("grid place-content-center peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",t),...a,children:e.jsx(X.Indicator,{className:x("grid place-content-center text-current"),children:e.jsx(f.Check,{className:"h-4 w-4"})})}));W.displayName=X.Root.displayName;const se=v.forwardRef(({className:t,...a},s)=>e.jsx("textarea",{className:x("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),ref:s,...a}));se.displayName="Textarea";const Ae=t=>t.trim().toLowerCase().replace(/[^\w\s]/g,"").replace(/\s+/g,"_"),Me=(t,a,s=!1,n=!1)=>{const i=(u,g)=>{a({...t,[u]:g})};return{handleTitleChange:u=>{i("title",u)},handleTitleBlur:()=>{if(s&&t.title){const u=Ae(t.title);i("key",u)}},handleKeyChange:u=>{(s||n)&&i("key",u)},handleFieldChange:i,handleConstraintChange:(u,g)=>{a({...t,[u]:g})}}},Y={string:"String",number:"Number",integer:"Integer",boolean:"Boolean",object:"Object",array:"Array",null:"Null",file:"File"},M={getTypeLabel:t=>Y[t],typeLabels:Y,propertyLabel:{singular:"property",plural:"properties"},showRegex:!1,keyEditable:!1,readonly:!1},ge=y.createContext(M);function _e({children:t,config:a={}}){const s={...Y,...a.typeLabels},n=a.propertyLabel||M.propertyLabel,i=a.showRegex??M.showRegex,r=a.keyEditable??M.keyEditable,l=a.readonly??M.readonly,o=C=>s[C]||C;return e.jsx(ge.Provider,{value:{getTypeLabel:o,typeLabels:s,propertyLabel:n,showRegex:i,keyEditable:r,readonly:l},children:t})}function je(){return y.useContext(ge)}function H({property:t,open:a,onOpenChange:s,onSave:n,isArrayItem:i=!1,isNewProperty:r=!1,propertyLabel:l,showRegex:o,keyEditable:C,typeLabels:u}){const g=je(),h=u||g.typeLabels,j=l||g.propertyLabel,b=o??g.showRegex,c=C??g.keyEditable,[d,k]=y.useState(t);y.useEffect(()=>{a&&k(t)},[t,a]);const{handleTitleChange:E,handleTitleBlur:O,handleKeyChange:D,handleFieldChange:p,handleConstraintChange:R}=Me(d,k,r,c),L=()=>{d.title?.trim()&&(n(d),s(!1))},U=()=>{k(t),s(!1)};return e.jsx(Oe,{open:a,onOpenChange:s,children:e.jsxs(he,{className:"max-w-2xl max-h-[80vh] flex flex-col gap-0 p-0","data-testid":"dialog-edit-property",children:[e.jsx(xe,{className:"px-6 pt-6 pb-4 shrink-0",children:e.jsx(pe,{children:r?`Add ${j.singular}`:`Edit ${j.singular}`})}),e.jsxs("div",{className:"space-y-6 px-6 pb-4 overflow-y-auto flex-1 min-h-0",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(N,{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-red-500"}),"Type"]}),e.jsxs(G,{value:d.type,onValueChange:m=>p("type",m),"data-testid":"select-type-dialog",children:[e.jsx(J,{children:e.jsx(Q,{})}),e.jsxs(V,{children:[e.jsx(I,{value:"string",children:h.string}),e.jsx(I,{value:"number",children:h.number}),e.jsx(I,{value:"integer",children:h.integer}),e.jsx(I,{value:"boolean",children:h.boolean}),e.jsx(I,{value:"object",children:h.object}),e.jsx(I,{value:"array",children:h.array}),e.jsx(I,{value:"file",children:h.file}),e.jsx(I,{value:"null",children:h.null})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(N,{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-red-500"}),"Title"]}),e.jsx(q,{value:d.title||"",onChange:m=>E(m.target.value),onBlur:O,placeholder:"Property Title","data-testid":"input-title-dialog",required:!0}),!r&&d.key&&e.jsxs("p",{className:"text-xs text-muted-foreground font-mono",children:["Key: ",d.key]})]}),(r||c)&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{children:"Key"}),e.jsx(q,{value:d.key,onChange:m=>D(m.target.value),placeholder:"property_key","data-testid":"input-key-dialog"}),!r&&e.jsx("p",{className:"text-xs text-yellow-600 dark:text-yellow-500",children:"⚠️ Changing the key may break existing references to this property"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{children:"Description"}),e.jsx(se,{placeholder:"Optional description",value:d.description||"",onChange:m=>p("description",m.target.value),rows:2,"data-testid":"input-edit-description"})]}),d.type==="array"&&e.jsxs("div",{className:"space-y-2 border-l-2 border-border pl-4 mt-2",children:[e.jsxs(N,{className:"font-semibold text-xs text-muted-foreground",children:[h.array," Items"]}),d.items?e.jsxs("div",{className:"bg-muted/40 p-2 rounded",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{children:"Item Type"}),e.jsxs(G,{value:d.items.type,onValueChange:m=>k({...d,items:{...d.items,type:m}}),children:[e.jsx(J,{children:e.jsx(Q,{})}),e.jsxs(V,{children:[e.jsx(I,{value:"string",children:h.string}),e.jsx(I,{value:"number",children:h.number}),e.jsx(I,{value:"integer",children:h.integer}),e.jsx(I,{value:"boolean",children:h.boolean}),e.jsx(I,{value:"object",children:h.object}),e.jsx(I,{value:"array",children:h.array}),e.jsx(I,{value:"file",children:h.file}),e.jsx(I,{value:"null",children:h.null})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{children:"Item Title"}),e.jsx(q,{value:d.items.title||"",onChange:m=>k({...d,items:{...d.items,title:m.target.value}}),placeholder:"Item Title"})]}),e.jsxs(T,{variant:"ghost",size:"sm",className:"mt-2",onClick:()=>k({...d,items:void 0}),children:["Remove ",h.array," Item Schema"]})]}):e.jsxs(T,{variant:"outline",size:"sm",onClick:()=>{k({...d,items:{id:Date.now().toString()+Math.random(),key:"item",type:"string",required:!1}})},children:["Add ",h.array," Item Schema"]})]}),!i&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(W,{id:"prop-required",checked:d.required,onCheckedChange:m=>p("required",m),"data-testid":"checkbox-edit-required"}),e.jsx(N,{htmlFor:"prop-required",className:"cursor-pointer",children:"Required field"})]}),d.type==="string"&&e.jsxs("details",{className:"border rounded-md",children:[e.jsx("summary",{className:"p-4 cursor-pointer hover:bg-accent/50 transition-colors",children:e.jsxs("h4",{className:"text-sm font-medium inline",children:[h.string," Constraints"]})}),e.jsxs("div",{className:"space-y-4 p-4 pt-0",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{htmlFor:"min-length",children:"Minimum Length"}),e.jsx(q,{id:"min-length",type:"number",placeholder:"0",value:d.minLength||"",onChange:m=>R("minLength",m.target.value?parseInt(m.target.value):void 0),"data-testid":"input-edit-minlength"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{htmlFor:"max-length",children:"Maximum Length"}),e.jsx(q,{id:"max-length",type:"number",placeholder:"∞",value:d.maxLength||"",onChange:m=>R("maxLength",m.target.value?parseInt(m.target.value):void 0),"data-testid":"input-edit-maxlength"})]})]}),b&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{htmlFor:"pattern",children:"Pattern (regex)"}),e.jsx(q,{id:"pattern",placeholder:"^[a-z]+$",value:d.pattern||"",onChange:m=>R("pattern",m.target.value),className:"font-mono text-sm","data-testid":"input-edit-pattern"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{children:"Enum Values"}),e.jsx("div",{className:"space-y-2",children:[...d.enum||[],""].map((m,S)=>e.jsx(q,{placeholder:S===(d.enum?.length||0)?"Add new value...":"Enum value",value:m,onChange:B=>{const _=B.target.value,$=d.enum||[];if(S===$.length)_.trim()&&R("enum",[...$,_.trim()]);else if(_.trim()){const A=[...$];A[S]=_.trim(),R("enum",A)}else{const A=$.filter((st,ve)=>ve!==S);R("enum",A.length>0?A:void 0)}},"data-testid":`input-edit-enum-${S}`},S))}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Enter allowed values (empty fields will be removed)"})]})]})]}),(d.type==="number"||d.type==="integer")&&e.jsxs("details",{className:"border rounded-md",children:[e.jsx("summary",{className:"p-4 cursor-pointer hover:bg-accent/50 transition-colors",children:e.jsx("h4",{className:"text-sm font-medium inline",children:"Numeric Constraints"})}),e.jsx("div",{className:"space-y-4 p-4 pt-0",children:e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{htmlFor:"minimum",children:"Minimum Value"}),e.jsx(q,{id:"minimum",type:"number",placeholder:"-∞",value:d.minimum??"",onChange:m=>R("minimum",m.target.value?parseFloat(m.target.value):void 0),"data-testid":"input-edit-minimum"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{htmlFor:"maximum",children:"Maximum Value"}),e.jsx(q,{id:"maximum",type:"number",placeholder:"∞",value:d.maximum??"",onChange:m=>R("maximum",m.target.value?parseFloat(m.target.value):void 0),"data-testid":"input-edit-maximum"})]})]})})]}),d.type==="array"&&e.jsxs("details",{className:"border rounded-md",children:[e.jsx("summary",{className:"p-4 cursor-pointer hover:bg-accent/50 transition-colors",children:e.jsxs("h4",{className:"text-sm font-medium inline",children:[h.array," Constraints"]})}),e.jsxs("div",{className:"space-y-4 p-4 pt-0",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{htmlFor:"min-items",children:"Minimum Items"}),e.jsx(q,{id:"min-items",type:"number",placeholder:"0",value:d.minItems||"",onChange:m=>R("minItems",m.target.value?parseInt(m.target.value):void 0),"data-testid":"input-edit-minitems"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{htmlFor:"max-items",children:"Maximum Items"}),e.jsx(q,{id:"max-items",type:"number",placeholder:"∞",value:d.maxItems||"",onChange:m=>R("maxItems",m.target.value?parseInt(m.target.value):void 0),"data-testid":"input-edit-maxitems"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(W,{id:"unique-items",checked:d.uniqueItems||!1,onCheckedChange:m=>R("uniqueItems",m),"data-testid":"checkbox-edit-unique"}),e.jsx(N,{htmlFor:"unique-items",className:"cursor-pointer",children:"All items must be unique"})]})]})]})]}),e.jsxs(fe,{className:"px-6 py-4 border-t bg-background shrink-0",children:[e.jsx(T,{variant:"outline",onClick:U,"data-testid":"button-cancel",children:"Cancel"}),e.jsx(T,{onClick:L,"data-testid":"button-save",disabled:!d.title?.trim(),children:"Save Changes"})]})]})})}function re(t,a,s={}){const{allowEmpty:n=!1,onEditStart:i,onEditCancel:r}=s,[l,o]=y.useState(!1),[C,u]=y.useState(t);y.useEffect(()=>{l||u(t)},[t,l]);const g=()=>{u(t),o(!0),i?.()},h=c=>{u(c)},j=()=>{const c=C.trim();if(!n&&!c){u(t),o(!1);return}c!==t&&a(c),o(!1)};return{isEditing:l,value:C,startEdit:g,handleChange:h,handleBlur:j,handleKeyDown:c=>{c.key==="Enter"?j():c.key==="Escape"&&(u(t),o(!1),r?.())}}}function $e(t,a){const[s,n]=y.useState(!1);return{isChangingType:s,setIsChangingType:n,handleTypeChange:l=>{const o={...t,type:l};l!=="string"&&(delete o.minLength,delete o.maxLength,delete o.pattern,delete o.enum),l!=="number"&&l!=="integer"&&(delete o.minimum,delete o.maximum),l!=="array"&&(delete o.minItems,delete o.maxItems,delete o.uniqueItems,delete o.items),l!=="object"&&delete o.children,a(o),n(!1)},availableTypes:["string","number","integer","boolean","object","array","file"]}}const ae=()=>`${Date.now()}-${Math.random()}`;function ie(t={}){const{onConfirm:a,onCancel:s,createInitialData:n}=t,[i,r]=y.useState(!1),[l,o]=y.useState(null),C=j=>{const b=j??(n?n():null);o(b),r(!0)},u=()=>{r(!1),o(null),s?.()};return{isOpen:i,data:l,open:C,close:u,confirm:j=>{a?.(j),r(!1),o(null)},setIsOpen:j=>{j?r(!0):u()}}}function Ke(t,a){const s=ie({createInitialData:()=>({id:ae(),key:"",type:"string",required:!1}),onConfirm:r=>{a({...t,children:[...t.children||[],r]})}});return{addChild:()=>s.open(),updateChild:(r,l)=>{const o=t.children.map(C=>C.id===r?l:C);a({...t,children:o})},deleteChild:r=>{const l=t.children.filter(o=>o.id!==r);a({...t,children:l})},addChildDialog:{isOpen:s.isOpen,data:s.data,setIsOpen:s.setIsOpen,confirm:s.confirm}}}function Z({property:t,onUpdate:a,onDelete:s,level:n=1,isArrayItem:i=!1}){const{getTypeLabel:r,typeLabels:l,showRegex:o,keyEditable:C,readonly:u}=je(),g=ie(),h=re(t.title||t.key||"",p=>a({...t,title:p}),{allowEmpty:!1}),j=re(t.description||"",p=>a({...t,description:p||void 0}),{allowEmpty:!0}),b=$e(t,a),c=Ke(t,a),d=`h${Math.min(n,6)}`,k=t.type==="object",E=k&&t.children&&t.children.length>0,O={1:"text-lg font-semibold",2:"text-base",3:"text-base",4:"text-base",5:"text-sm",6:"text-sm"}[n]||"text-sm",D={1:"h-5 w-5",2:"h-4 w-4",3:"h-4 w-4",4:"h-4 w-4",5:"h-4 w-4",6:"h-4 w-4"}[n]||"h-5 w-5";return e.jsxs("div",{className:"group",children:[e.jsxs("div",{className:"flex gap-4 items-center rounded-md -mx-2 px-2 py-1 transition-colors hover:bg-accent/50",children:[e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("div",{className:"flex items-start gap-3",children:[!i&&e.jsx("button",{onClick:()=>!u&&a({...t,required:!t.required}),className:u?"shrink-0 -mt-[3px] cursor-default":"shrink-0 transition-all hover:scale-110 -mt-[3px]",title:u?t.required?"Required field":"Optional field":t.required?"Required field - click to make optional":"Optional field - click to make required",children:t.required?e.jsx(f.Asterisk,{className:"w-6 h-6 text-primary"}):e.jsx(f.Asterisk,{className:"w-6 h-6 text-border"})}),h.isEditing?e.jsx(q,{value:h.value,onChange:p=>h.handleChange(p.target.value),onBlur:h.handleBlur,onKeyDown:h.handleKeyDown,autoFocus:!0,className:O,placeholder:"Enter title"}):e.jsxs("div",{className:"flex gap-2 flex-wrap flex-1",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(d,{className:u?`${O} leading-none`:`${O} cursor-pointer hover:text-primary transition-colors leading-none`,onClick:u?void 0:h.startEdit,children:t.title||t.key||e.jsx("span",{className:"text-muted-foreground italic",children:"unnamed"})}),b.isChangingType?e.jsxs(G,{value:t.type,onValueChange:p=>b.handleTypeChange(p),open:b.isChangingType,onOpenChange:b.setIsChangingType,children:[e.jsx(J,{className:"w-[140px] h-7",children:e.jsx(Q,{})}),e.jsx(V,{children:b.availableTypes.map(p=>e.jsx(I,{value:p,children:l[p]},p))})]}):e.jsx(qe,{children:e.jsxs(Re,{children:[e.jsx(Ee,{asChild:!0,children:e.jsxs("button",{onClick:()=>!u&&b.setIsChangingType(!0),className:u?"rounded p-0.5 -mt-0.5 cursor-default":"cursor-pointer hover:bg-accent rounded p-0.5 -mt-0.5 transition-colors",children:[t.type==="string"&&e.jsx(f.Type,{className:x(D,"text-muted-foreground")}),t.type==="number"&&e.jsx(f.Hash,{className:x(D,"text-muted-foreground")}),t.type==="integer"&&e.jsx(f.Hash,{className:x(D,"text-muted-foreground")}),t.type==="boolean"&&e.jsx(f.CheckSquare,{className:x(D,"text-muted-foreground")}),t.type==="object"&&e.jsx(f.Braces,{className:x(D,"text-muted-foreground")}),t.type==="array"&&e.jsx(f.List,{className:x(D,"text-muted-foreground")}),t.type==="file"&&e.jsx(f.FileText,{className:x(D,"text-muted-foreground")})]})}),e.jsxs(oe,{children:[r(t.type),t.type==="array"&&t.items?` of ${r(t.items.type)}`:"",!u&&e.jsx("div",{className:"text-xs text-muted-foreground mt-1",children:"Click to change type"})]})]})}),t.type==="object"&&!u&&e.jsx(T,{variant:"ghost",size:"icon",className:"h-4 w-4",onClick:c.addChild,"data-testid":`button-add-child-${t.id}`,children:e.jsx(f.Plus,{})})]}),e.jsx("div",{className:"flex-1",children:j.isEditing?e.jsx(q,{value:j.value,onChange:p=>j.handleChange(p.target.value),onBlur:j.handleBlur,onKeyDown:j.handleKeyDown,autoFocus:!0,className:"text-sm flex-1",placeholder:"Enter description"}):e.jsx(e.Fragment,{children:t.description?e.jsx("p",{className:u?"text-sm text-muted-foreground flex-1 min-w-[200px]":"text-sm text-muted-foreground flex-1 min-w-[200px] cursor-pointer hover:text-foreground transition-colors","data-testid":`text-description-${t.id}`,onClick:u?void 0:j.startEdit,children:t.description}):!u&&e.jsx("p",{className:"text-sm text-muted-foreground/50 flex-1 min-w-[200px] cursor-pointer hover:text-muted-foreground italic transition-colors",onClick:j.startEdit,children:"Add description..."})})})]})]})}),!u&&e.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity shrink-0",children:[e.jsx(T,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>g.open(t),"data-testid":`button-edit-${t.id}`,children:e.jsx(f.Pencil,{className:"w-3 h-3"})}),k&&t.type!=="object"&&e.jsx(T,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:c.addChild,"data-testid":`button-add-child-${t.id}`,children:e.jsx(f.Plus,{className:"w-3 h-3"})}),e.jsx(T,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive",onClick:s,"data-testid":`button-delete-${t.id}`,children:e.jsx(f.Trash2,{className:"w-3 h-3"})})]})]}),E&&e.jsx("div",{className:n===1?"ml-6 mt-1 border-l-2 border-border pl-6":"ml-4 mt-1 border-l border-border pl-4",children:t.children.map(p=>e.jsx(Z,{property:p,onUpdate:R=>c.updateChild(p.id,R),onDelete:()=>c.deleteChild(p.id),level:n+1},p.id))}),t.type==="array"&&t.items&&e.jsxs("div",{className:n===1?"ml-6 mt-1 border-l-2 border-border pl-6":"ml-4 mt-1 border-l border-border pl-4",children:[e.jsxs("div",{className:"mb-2 text-xs text-muted-foreground font-semibold uppercase",children:[r("array")," Items"]}),e.jsx(Z,{property:t.items,onUpdate:p=>a({...t,items:p}),onDelete:()=>a({...t,items:void 0}),level:n+1,isArrayItem:!0})]}),e.jsx(H,{property:g.data||t,open:g.isOpen,onOpenChange:g.setIsOpen,onSave:p=>{a(p),g.close()},isArrayItem:i,isNewProperty:!1}),c.addChildDialog.isOpen&&c.addChildDialog.data&&e.jsx(H,{property:c.addChildDialog.data,open:c.addChildDialog.isOpen,isNewProperty:!0,onOpenChange:c.addChildDialog.setIsOpen,onSave:c.addChildDialog.confirm})]})}const ne=v.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:x("rounded-xl border bg-card text-card-foreground",t),...a}));ne.displayName="Card";const Je=v.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:x("flex flex-col space-y-1.5 p-6",t),...a}));Je.displayName="CardHeader";const Ve=v.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:x("font-semibold leading-none tracking-tight",t),...a}));Ve.displayName="CardTitle";const He=v.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:x("text-sm text-muted-foreground",t),...a}));He.displayName="CardDescription";const Ue=v.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:x("p-6 pt-0",t),...a}));Ue.displayName="CardContent";const Xe=v.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:x("flex items-center p-6 pt-0",t),...a}));Xe.displayName="CardFooter";const Ge=()=>new Promise((t,a)=>{const s=document.createElement("input");s.type="file",s.accept=".json",s.onchange=n=>{const i=n.target.files?.[0];if(!i){a(new Error("No file selected"));return}const r=new FileReader;r.onload=l=>{try{const o=JSON.parse(l.target?.result);t(o)}catch{a(new Error("Invalid JSON file"))}},r.onerror=()=>a(new Error("Failed to read file")),r.readAsText(i)},s.click()}),ye=(t,a="schema.json")=>{const s=JSON.stringify(t,null,2),n=new Blob([s],{type:"application/json"}),i=URL.createObjectURL(n),r=document.createElement("a");r.href=i,r.download=a,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(i)};function Qe({schema:t}){const[a,s]=y.useState(!1),n=JSON.stringify(t,null,2),i=async()=>{await navigator.clipboard.writeText(n),s(!0),setTimeout(()=>s(!1),2e3)},r=()=>{ye(t,"schema.json")};return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[e.jsx("h2",{className:"text-sm font-medium",children:"JSON Schema Output"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(T,{variant:"outline",size:"sm",onClick:i,"data-testid":"button-copy",children:a?e.jsx(f.CheckCircle2,{className:"w-4 h-4"}):e.jsx(f.Copy,{className:"w-4 h-4"})}),e.jsx(T,{variant:"outline",size:"sm",onClick:r,"data-testid":"button-download",children:e.jsx(f.Download,{className:"w-4 h-4"})})]})]}),e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsx(ne,{className:"m-4 bg-muted/30",children:e.jsx("pre",{className:"p-6 text-xs font-mono overflow-auto","data-testid":"text-json-output",children:e.jsx("code",{children:n})})})})]})}function We({title:t,description:a,version:s,onUpdate:n,readonly:i=!1}){const[r,l]=y.useState(!1);return e.jsxs(ne,{className:"p-4",children:[e.jsxs(T,{variant:"ghost",onClick:()=>l(!r),className:"w-full justify-between px-2 h-auto hover:bg-transparent","data-testid":"button-toggle-metadata",children:[e.jsx("h3",{className:"text-sm font-medium",children:"Schema Metadata"}),r?e.jsx(f.ChevronDown,{className:"w-4 h-4"}):e.jsx(f.ChevronRight,{className:"w-4 h-4"})]}),r&&e.jsxs("div",{className:"mt-4 space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{htmlFor:"schema-title",className:"text-xs text-muted-foreground",children:"Title"}),e.jsx(q,{id:"schema-title",placeholder:"My Schema",value:t,onChange:o=>n("title",o.target.value),"data-testid":"input-title",disabled:i})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{htmlFor:"schema-description",className:"text-xs text-muted-foreground",children:"Description"}),e.jsx(se,{id:"schema-description",placeholder:"Describe your schema...",value:a,onChange:o=>n("description",o.target.value),className:"resize-none",rows:3,"data-testid":"input-schema-description",disabled:i})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{htmlFor:"schema-version",className:"text-xs text-muted-foreground",children:"Version"}),e.jsx(q,{id:"schema-version",placeholder:"1.0.0",value:s,onChange:o=>n("version",o.target.value),"data-testid":"input-version",disabled:i})]})]})]})}const K=(t,a,s=!0)=>{const n={type:"object"};s&&a&&(a.title&&(n.title=a.title),a.description&&(n.description=a.description));const i=ee(t);Object.keys(i).length>0&&(n.properties=i);const r=t.filter(l=>l.required&&l.key).map(l=>l.key);return r.length>0&&(n.required=r),n},ee=t=>{const a={};return t.forEach(s=>{if(!s.key)return;const i={type:s.type==="file"?"string":s.type};if(s.title&&(i.title=s.title),s.description&&(i.description=s.description),s.type==="file"&&(i.format="filename"),s.type==="string"&&(s.minLength!==void 0&&(i.minLength=s.minLength),s.maxLength!==void 0&&(i.maxLength=s.maxLength),s.pattern&&(i.pattern=s.pattern),s.enum&&s.enum.length>0&&(i.enum=s.enum)),(s.type==="number"||s.type==="integer")&&(s.minimum!==void 0&&(i.minimum=s.minimum),s.maximum!==void 0&&(i.maximum=s.maximum)),s.type==="array"&&(s.minItems!==void 0&&(i.minItems=s.minItems),s.maxItems!==void 0&&(i.maxItems=s.maxItems),s.uniqueItems&&(i.uniqueItems=s.uniqueItems),s.items&&(i.items=ee([s.items])[s.items.key]||{type:s.items.type})),s.type==="object"&&s.children&&s.children.length>0){i.properties=ee(s.children);const r=s.children.filter(l=>l.required&&l.key).map(l=>l.key);r.length>0&&(i.required=r)}a[s.key]=i}),a},Ye=t=>{const a={properties:[]};return(t.title||t.description)&&(a.metadata={title:typeof t.title=="string"?t.title:"",description:typeof t.description=="string"?t.description:"",version:"1.0.0"}),t.properties&&typeof t.properties=="object"&&(a.properties=te(t.properties,Array.isArray(t.required)?t.required:[])),a},te=(t,a=[])=>t?Object.entries(t).filter(([,s])=>typeof s=="object").map(([s,n])=>{const i=n;let r=typeof i.type=="string"?i.type:"string";r==="string"&&i.format==="filename"&&(r="file");const l={id:ae(),key:s,title:typeof i.title=="string"?i.title:void 0,type:r,description:typeof i.description=="string"?i.description:void 0,required:a.includes(s)};return i.minLength!==void 0&&(l.minLength=i.minLength),i.maxLength!==void 0&&(l.maxLength=i.maxLength),i.pattern&&(l.pattern=i.pattern),i.enum&&Array.isArray(i.enum)&&(l.enum=i.enum),i.minimum!==void 0&&(l.minimum=i.minimum),i.maximum!==void 0&&(l.maximum=i.maximum),i.minItems!==void 0&&(l.minItems=i.minItems),i.maxItems!==void 0&&(l.maxItems=i.maxItems),i.uniqueItems&&(l.uniqueItems=i.uniqueItems),l.type==="array"&&i.items&&typeof i.items=="object"&&!Array.isArray(i.items)&&(l.items=te({item:i.items},[]).find(o=>o.key==="item")),i.properties&&typeof i.properties=="object"&&(l.children=te(i.properties,Array.isArray(i.required)?i.required:[])),l}):[],Ze=({schema:t,onChange:a,includeMetadata:s=!0})=>{const{properties:n,metadata:i}=y.useMemo(()=>Ye(t),[t]),r=n,l=i||{title:"",description:"",version:""},o=y.useCallback(()=>({id:ae(),key:"",type:"string",required:!1}),[]),C=y.useCallback((c,d)=>{const k=r.some(D=>D.id===c);let E;k?E=r.map(D=>D.id===c?d:D):E=[...r,d];const O=K(E,l,s);a(O)},[r,l,s,a]),u=y.useCallback(c=>{const d=r.filter(E=>E.id!==c),k=K(d,l,s);a(k)},[r,l,s,a]),g=y.useCallback(()=>{const d=K([],{title:"",description:""},s);a(d)},[s,a]),h=y.useCallback((c,d)=>{const k={...l,[c]:d},E=K(r,k,s);a(E)},[r,l,s,a]),j=y.useCallback(async()=>{const c=await Ge();a(c)},[a]),b=y.useCallback(()=>{ye(t,"schema.json")},[t]);return{properties:r,metadata:l,addProperty:o,updateProperty:C,deleteProperty:u,clearAll:g,updateMetadata:h,importSchema:j,downloadSchema:b}};function et(){const[t,a]=y.useState("light");y.useEffect(()=>{const i=localStorage.getItem("theme")||(window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light");a(i),document.documentElement.classList.toggle("dark",i==="dark")},[]);const s=()=>{const n=t==="light"?"dark":"light";a(n),localStorage.setItem("theme",n),document.documentElement.classList.toggle("dark",n==="dark")};return e.jsx(T,{variant:"ghost",size:"icon",onClick:s,"data-testid":"button-theme-toggle",children:t==="light"?e.jsx(f.Moon,{className:"w-4 h-4"}):e.jsx(f.Sun,{className:"w-4 h-4"})})}function tt({schema:t,onChange:a,showMetadata:s=!1,showImport:n=!0,showClear:i=!0,showOutput:r=!0,showHeader:l=!0,className:o="",showSummary:C=!1,typeLabels:u,propertyLabel:g={singular:"property",plural:"properties"},showRegex:h=!1,keyEditable:j=!1,readonly:b=!1}){const{properties:c,metadata:d,addProperty:k,updateProperty:E,deleteProperty:O,clearAll:D,updateMetadata:p,importSchema:R}=Ze({schema:t,onChange:a??(()=>{}),includeMetadata:s}),L=ie({createInitialData:()=>k(),onConfirm:S=>{E(S.id,S)}}),U=()=>{D()},m=async()=>{await R()};return e.jsx(_e,{config:{typeLabels:u,propertyLabel:g,showRegex:h,keyEditable:j,readonly:b},children:e.jsxs("div",{className:`${o} flex flex-col json-schema-builder-react`,children:[l&&e.jsx("header",{className:"h-16 border-b flex items-center justify-between px-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[!b&&n&&e.jsx(T,{variant:"outline",size:"sm",onClick:m,"data-testid":"button-import",children:e.jsx(f.Upload,{className:"w-4 h-4"})}),!b&&i&&e.jsx(T,{variant:"outline",size:"sm",onClick:U,disabled:c.length===0,"data-testid":"button-clear",children:e.jsx(f.Trash2,{className:"w-4 h-4"})}),e.jsx(et,{})]})}),e.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[e.jsx("div",{className:r?"w-3/5 border-r":"w-full",children:e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"flex-1 overflow-auto p-2 space-y-4",children:[s&&e.jsx(We,{title:d.title,description:d.description,version:d.version,onUpdate:(S,B)=>p(S,B),readonly:b}),c.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-4 text-center",children:[!b&&e.jsx("div",{className:"w-16 h-16 rounded-full bg-muted flex items-center justify-center mb-4",children:e.jsx(f.Plus,{className:"w-8 h-8 text-muted-foreground"})}),e.jsxs("h2",{className:"text-lg font-medium mb-2",children:["No ",g.plural," yet"]}),!b&&e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"text-sm text-muted-foreground mb-6 max-w-sm",children:["Start building your JSON schema by adding your first"," ",g.singular]}),e.jsxs(T,{onClick:()=>L.open(),"data-testid":"button-add-first",children:[e.jsx(f.Plus,{className:"w-4 h-4 mr-2"}),"Add ",g.singular]})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"space-y-1",children:c.map(S=>e.jsx(Z,{property:S,onUpdate:B=>E(S.id,B),onDelete:()=>O(S.id)},S.id))}),C&&e.jsxs("div",{className:"pt-4 border-t flex items-center justify-between text-sm text-muted-foreground",children:[e.jsxs("span",{children:[c.length," ",c.length===1?g.singular:g.plural]}),e.jsxs("span",{children:[c.filter(S=>S.required).length," required"]})]})]})]}),c.length>0&&!b&&e.jsx("div",{className:"border-t p-2 pt-4 bg-background",children:e.jsxs(T,{onClick:()=>L.open(),className:"w-full",variant:"outline","data-testid":"button-add-property",children:[e.jsx(f.Plus,{className:"w-4 h-4"}),"Add ",g.singular]})})]})}),r&&e.jsx("div",{className:"w-2/5",children:e.jsx(Qe,{schema:t})})]}),L.isOpen&&L.data&&e.jsx(H,{property:L.data,open:L.isOpen,isNewProperty:!0,onOpenChange:L.setIsOpen,onSave:L.confirm})]})})}exports.JsonSchemaBuilder=tt;exports.PropertyEditDialog=H;
|
package/dist-lib/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import { clsx as je } from "clsx";
|
|
|
7
7
|
import { twMerge as Oe } from "tailwind-merge";
|
|
8
8
|
import { ChevronDown as se, Check as fe, ChevronUp as Pe, X as Fe, Asterisk as ce, Type as ze, Hash as me, CheckSquare as Be, Braces as Ae, List as Me, FileText as $e, Plus as $, Pencil as Ke, Trash2 as pe, CheckCircle2 as Je, Copy as Ve, Download as He, ChevronRight as _e, Moon as Ue, Sun as Xe, Upload as Ge } from "lucide-react";
|
|
9
9
|
import * as z from "@radix-ui/react-tooltip";
|
|
10
|
-
import * as
|
|
10
|
+
import * as w from "@radix-ui/react-select";
|
|
11
11
|
import * as q from "@radix-ui/react-dialog";
|
|
12
12
|
import * as ge from "@radix-ui/react-label";
|
|
13
13
|
import * as G from "@radix-ui/react-checkbox";
|
|
@@ -77,8 +77,8 @@ const We = z.Provider, Ye = z.Root, Ze = z.Trigger, ye = x.forwardRef(({ classNa
|
|
|
77
77
|
}
|
|
78
78
|
) }));
|
|
79
79
|
ye.displayName = z.Content.displayName;
|
|
80
|
-
const Q =
|
|
81
|
-
|
|
80
|
+
const Q = w.Root, W = w.Value, H = x.forwardRef(({ className: t, children: i, ...a }, l) => /* @__PURE__ */ s(
|
|
81
|
+
w.Trigger,
|
|
82
82
|
{
|
|
83
83
|
ref: l,
|
|
84
84
|
className: p(
|
|
@@ -88,13 +88,13 @@ const Q = N.Root, W = N.Value, H = x.forwardRef(({ className: t, children: i, ..
|
|
|
88
88
|
...a,
|
|
89
89
|
children: [
|
|
90
90
|
i,
|
|
91
|
-
/* @__PURE__ */ e(
|
|
91
|
+
/* @__PURE__ */ e(w.Icon, { asChild: !0, children: /* @__PURE__ */ e(se, { className: "h-4 w-4 opacity-50" }) })
|
|
92
92
|
]
|
|
93
93
|
}
|
|
94
94
|
));
|
|
95
|
-
H.displayName =
|
|
95
|
+
H.displayName = w.Trigger.displayName;
|
|
96
96
|
const ve = x.forwardRef(({ className: t, ...i }, a) => /* @__PURE__ */ e(
|
|
97
|
-
|
|
97
|
+
w.ScrollUpButton,
|
|
98
98
|
{
|
|
99
99
|
ref: a,
|
|
100
100
|
className: p(
|
|
@@ -105,9 +105,9 @@ const ve = x.forwardRef(({ className: t, ...i }, a) => /* @__PURE__ */ e(
|
|
|
105
105
|
children: /* @__PURE__ */ e(Pe, { className: "h-4 w-4" })
|
|
106
106
|
}
|
|
107
107
|
));
|
|
108
|
-
ve.displayName =
|
|
108
|
+
ve.displayName = w.ScrollUpButton.displayName;
|
|
109
109
|
const xe = x.forwardRef(({ className: t, ...i }, a) => /* @__PURE__ */ e(
|
|
110
|
-
|
|
110
|
+
w.ScrollDownButton,
|
|
111
111
|
{
|
|
112
112
|
ref: a,
|
|
113
113
|
className: p(
|
|
@@ -118,9 +118,9 @@ const xe = x.forwardRef(({ className: t, ...i }, a) => /* @__PURE__ */ e(
|
|
|
118
118
|
children: /* @__PURE__ */ e(se, { className: "h-4 w-4" })
|
|
119
119
|
}
|
|
120
120
|
));
|
|
121
|
-
xe.displayName =
|
|
122
|
-
const _ = x.forwardRef(({ className: t, children: i, position: a = "popper", ...l }, n) => /* @__PURE__ */ e(
|
|
123
|
-
|
|
121
|
+
xe.displayName = w.ScrollDownButton.displayName;
|
|
122
|
+
const _ = x.forwardRef(({ className: t, children: i, position: a = "popper", ...l }, n) => /* @__PURE__ */ e(w.Portal, { children: /* @__PURE__ */ s(
|
|
123
|
+
w.Content,
|
|
124
124
|
{
|
|
125
125
|
ref: n,
|
|
126
126
|
className: p(
|
|
@@ -133,7 +133,7 @@ const _ = x.forwardRef(({ className: t, children: i, position: a = "popper", ...
|
|
|
133
133
|
children: [
|
|
134
134
|
/* @__PURE__ */ e(ve, {}),
|
|
135
135
|
/* @__PURE__ */ e(
|
|
136
|
-
|
|
136
|
+
w.Viewport,
|
|
137
137
|
{
|
|
138
138
|
className: p(
|
|
139
139
|
"p-1",
|
|
@@ -146,18 +146,18 @@ const _ = x.forwardRef(({ className: t, children: i, position: a = "popper", ...
|
|
|
146
146
|
]
|
|
147
147
|
}
|
|
148
148
|
) }));
|
|
149
|
-
_.displayName =
|
|
149
|
+
_.displayName = w.Content.displayName;
|
|
150
150
|
const et = x.forwardRef(({ className: t, ...i }, a) => /* @__PURE__ */ e(
|
|
151
|
-
|
|
151
|
+
w.Label,
|
|
152
152
|
{
|
|
153
153
|
ref: a,
|
|
154
154
|
className: p("px-2 py-1.5 text-sm font-semibold", t),
|
|
155
155
|
...i
|
|
156
156
|
}
|
|
157
157
|
));
|
|
158
|
-
et.displayName =
|
|
158
|
+
et.displayName = w.Label.displayName;
|
|
159
159
|
const S = x.forwardRef(({ className: t, children: i, ...a }, l) => /* @__PURE__ */ s(
|
|
160
|
-
|
|
160
|
+
w.Item,
|
|
161
161
|
{
|
|
162
162
|
ref: l,
|
|
163
163
|
className: p(
|
|
@@ -166,21 +166,21 @@ const S = x.forwardRef(({ className: t, children: i, ...a }, l) => /* @__PURE__
|
|
|
166
166
|
),
|
|
167
167
|
...a,
|
|
168
168
|
children: [
|
|
169
|
-
/* @__PURE__ */ e("span", { className: "absolute right-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ e(
|
|
170
|
-
/* @__PURE__ */ e(
|
|
169
|
+
/* @__PURE__ */ e("span", { className: "absolute right-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ e(w.ItemIndicator, { children: /* @__PURE__ */ e(fe, { className: "h-4 w-4" }) }) }),
|
|
170
|
+
/* @__PURE__ */ e(w.ItemText, { children: i })
|
|
171
171
|
]
|
|
172
172
|
}
|
|
173
173
|
));
|
|
174
|
-
S.displayName =
|
|
174
|
+
S.displayName = w.Item.displayName;
|
|
175
175
|
const tt = x.forwardRef(({ className: t, ...i }, a) => /* @__PURE__ */ e(
|
|
176
|
-
|
|
176
|
+
w.Separator,
|
|
177
177
|
{
|
|
178
178
|
ref: a,
|
|
179
179
|
className: p("-mx-1 my-1 h-px bg-muted", t),
|
|
180
180
|
...i
|
|
181
181
|
}
|
|
182
182
|
));
|
|
183
|
-
tt.displayName =
|
|
183
|
+
tt.displayName = w.Separator.displayName;
|
|
184
184
|
const at = q.Root, it = q.Portal, be = x.forwardRef(({ className: t, ...i }, a) => /* @__PURE__ */ e(
|
|
185
185
|
q.Overlay,
|
|
186
186
|
{
|
|
@@ -266,7 +266,7 @@ const nt = x.forwardRef(({ className: t, ...i }, a) => /* @__PURE__ */ e(
|
|
|
266
266
|
nt.displayName = q.Description.displayName;
|
|
267
267
|
const st = he(
|
|
268
268
|
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
|
|
269
|
-
),
|
|
269
|
+
), N = x.forwardRef(({ className: t, ...i }, a) => /* @__PURE__ */ e(
|
|
270
270
|
ge.Root,
|
|
271
271
|
{
|
|
272
272
|
ref: a,
|
|
@@ -274,7 +274,7 @@ const st = he(
|
|
|
274
274
|
...i
|
|
275
275
|
}
|
|
276
276
|
));
|
|
277
|
-
|
|
277
|
+
N.displayName = ge.Root.displayName;
|
|
278
278
|
const Y = x.forwardRef(({ className: t, ...i }, a) => /* @__PURE__ */ e(
|
|
279
279
|
G.Root,
|
|
280
280
|
{
|
|
@@ -376,7 +376,7 @@ function ee({
|
|
|
376
376
|
keyEditable: C,
|
|
377
377
|
typeLabels: h
|
|
378
378
|
}) {
|
|
379
|
-
const y = Se(), f = h || y.typeLabels, v = d || y.propertyLabel,
|
|
379
|
+
const y = Se(), f = h || y.typeLabels, v = d || y.propertyLabel, b = c ?? y.showRegex, m = C ?? y.keyEditable, [o, k] = P(t);
|
|
380
380
|
ne(() => {
|
|
381
381
|
i && k(t);
|
|
382
382
|
}, [t, i]);
|
|
@@ -405,7 +405,7 @@ function ee({
|
|
|
405
405
|
/* @__PURE__ */ e(we, { className: "px-6 pt-6 pb-4 shrink-0", children: /* @__PURE__ */ e(ke, { children: r ? `Add ${v.singular}` : `Edit ${v.singular}` }) }),
|
|
406
406
|
/* @__PURE__ */ s("div", { className: "space-y-6 px-6 pb-4 overflow-y-auto flex-1 min-h-0", children: [
|
|
407
407
|
/* @__PURE__ */ s("div", { className: "space-y-2", children: [
|
|
408
|
-
/* @__PURE__ */ s(
|
|
408
|
+
/* @__PURE__ */ s(N, { className: "flex items-center gap-1.5", children: [
|
|
409
409
|
/* @__PURE__ */ e("span", { className: "w-1.5 h-1.5 rounded-full bg-red-500" }),
|
|
410
410
|
"Type"
|
|
411
411
|
] }),
|
|
@@ -432,7 +432,7 @@ function ee({
|
|
|
432
432
|
)
|
|
433
433
|
] }),
|
|
434
434
|
/* @__PURE__ */ s("div", { className: "space-y-2", children: [
|
|
435
|
-
/* @__PURE__ */ s(
|
|
435
|
+
/* @__PURE__ */ s(N, { className: "flex items-center gap-1.5", children: [
|
|
436
436
|
/* @__PURE__ */ e("span", { className: "w-1.5 h-1.5 rounded-full bg-red-500" }),
|
|
437
437
|
"Title"
|
|
438
438
|
] }),
|
|
@@ -453,7 +453,7 @@ function ee({
|
|
|
453
453
|
] })
|
|
454
454
|
] }),
|
|
455
455
|
(r || m) && /* @__PURE__ */ s("div", { className: "space-y-2", children: [
|
|
456
|
-
/* @__PURE__ */ e(
|
|
456
|
+
/* @__PURE__ */ e(N, { children: "Key" }),
|
|
457
457
|
/* @__PURE__ */ e(
|
|
458
458
|
R,
|
|
459
459
|
{
|
|
@@ -466,7 +466,7 @@ function ee({
|
|
|
466
466
|
!r && /* @__PURE__ */ e("p", { className: "text-xs text-yellow-600 dark:text-yellow-500", children: "⚠️ Changing the key may break existing references to this property" })
|
|
467
467
|
] }),
|
|
468
468
|
/* @__PURE__ */ s("div", { className: "space-y-2", children: [
|
|
469
|
-
/* @__PURE__ */ e(
|
|
469
|
+
/* @__PURE__ */ e(N, { children: "Description" }),
|
|
470
470
|
/* @__PURE__ */ e(
|
|
471
471
|
re,
|
|
472
472
|
{
|
|
@@ -479,13 +479,13 @@ function ee({
|
|
|
479
479
|
)
|
|
480
480
|
] }),
|
|
481
481
|
o.type === "array" && /* @__PURE__ */ s("div", { className: "space-y-2 border-l-2 border-border pl-4 mt-2", children: [
|
|
482
|
-
/* @__PURE__ */ s(
|
|
482
|
+
/* @__PURE__ */ s(N, { className: "font-semibold text-xs text-muted-foreground", children: [
|
|
483
483
|
f.array,
|
|
484
484
|
" Items"
|
|
485
485
|
] }),
|
|
486
486
|
o.items ? /* @__PURE__ */ s("div", { className: "bg-muted/40 p-2 rounded", children: [
|
|
487
487
|
/* @__PURE__ */ s("div", { className: "space-y-2", children: [
|
|
488
|
-
/* @__PURE__ */ e(
|
|
488
|
+
/* @__PURE__ */ e(N, { children: "Item Type" }),
|
|
489
489
|
/* @__PURE__ */ s(
|
|
490
490
|
Q,
|
|
491
491
|
{
|
|
@@ -514,7 +514,7 @@ function ee({
|
|
|
514
514
|
)
|
|
515
515
|
] }),
|
|
516
516
|
/* @__PURE__ */ s("div", { className: "space-y-2", children: [
|
|
517
|
-
/* @__PURE__ */ e(
|
|
517
|
+
/* @__PURE__ */ e(N, { children: "Item Title" }),
|
|
518
518
|
/* @__PURE__ */ e(
|
|
519
519
|
R,
|
|
520
520
|
{
|
|
@@ -578,7 +578,7 @@ function ee({
|
|
|
578
578
|
"data-testid": "checkbox-edit-required"
|
|
579
579
|
}
|
|
580
580
|
),
|
|
581
|
-
/* @__PURE__ */ e(
|
|
581
|
+
/* @__PURE__ */ e(N, { htmlFor: "prop-required", className: "cursor-pointer", children: "Required field" })
|
|
582
582
|
] }),
|
|
583
583
|
o.type === "string" && /* @__PURE__ */ s("details", { className: "border rounded-md", children: [
|
|
584
584
|
/* @__PURE__ */ e("summary", { className: "p-4 cursor-pointer hover:bg-accent/50 transition-colors", children: /* @__PURE__ */ s("h4", { className: "text-sm font-medium inline", children: [
|
|
@@ -588,7 +588,7 @@ function ee({
|
|
|
588
588
|
/* @__PURE__ */ s("div", { className: "space-y-4 p-4 pt-0", children: [
|
|
589
589
|
/* @__PURE__ */ s("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
590
590
|
/* @__PURE__ */ s("div", { className: "space-y-2", children: [
|
|
591
|
-
/* @__PURE__ */ e(
|
|
591
|
+
/* @__PURE__ */ e(N, { htmlFor: "min-length", children: "Minimum Length" }),
|
|
592
592
|
/* @__PURE__ */ e(
|
|
593
593
|
R,
|
|
594
594
|
{
|
|
@@ -605,7 +605,7 @@ function ee({
|
|
|
605
605
|
)
|
|
606
606
|
] }),
|
|
607
607
|
/* @__PURE__ */ s("div", { className: "space-y-2", children: [
|
|
608
|
-
/* @__PURE__ */ e(
|
|
608
|
+
/* @__PURE__ */ e(N, { htmlFor: "max-length", children: "Maximum Length" }),
|
|
609
609
|
/* @__PURE__ */ e(
|
|
610
610
|
R,
|
|
611
611
|
{
|
|
@@ -622,8 +622,8 @@ function ee({
|
|
|
622
622
|
)
|
|
623
623
|
] })
|
|
624
624
|
] }),
|
|
625
|
-
|
|
626
|
-
/* @__PURE__ */ e(
|
|
625
|
+
b && /* @__PURE__ */ s("div", { className: "space-y-2", children: [
|
|
626
|
+
/* @__PURE__ */ e(N, { htmlFor: "pattern", children: "Pattern (regex)" }),
|
|
627
627
|
/* @__PURE__ */ e(
|
|
628
628
|
R,
|
|
629
629
|
{
|
|
@@ -637,7 +637,7 @@ function ee({
|
|
|
637
637
|
)
|
|
638
638
|
] }),
|
|
639
639
|
/* @__PURE__ */ s("div", { className: "space-y-2", children: [
|
|
640
|
-
/* @__PURE__ */ e(
|
|
640
|
+
/* @__PURE__ */ e(N, { children: "Enum Values" }),
|
|
641
641
|
/* @__PURE__ */ e("div", { className: "space-y-2", children: [...o.enum || [], ""].map((u, I) => /* @__PURE__ */ e(
|
|
642
642
|
R,
|
|
643
643
|
{
|
|
@@ -675,7 +675,7 @@ function ee({
|
|
|
675
675
|
/* @__PURE__ */ e("summary", { className: "p-4 cursor-pointer hover:bg-accent/50 transition-colors", children: /* @__PURE__ */ e("h4", { className: "text-sm font-medium inline", children: "Numeric Constraints" }) }),
|
|
676
676
|
/* @__PURE__ */ e("div", { className: "space-y-4 p-4 pt-0", children: /* @__PURE__ */ s("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
677
677
|
/* @__PURE__ */ s("div", { className: "space-y-2", children: [
|
|
678
|
-
/* @__PURE__ */ e(
|
|
678
|
+
/* @__PURE__ */ e(N, { htmlFor: "minimum", children: "Minimum Value" }),
|
|
679
679
|
/* @__PURE__ */ e(
|
|
680
680
|
R,
|
|
681
681
|
{
|
|
@@ -692,7 +692,7 @@ function ee({
|
|
|
692
692
|
)
|
|
693
693
|
] }),
|
|
694
694
|
/* @__PURE__ */ s("div", { className: "space-y-2", children: [
|
|
695
|
-
/* @__PURE__ */ e(
|
|
695
|
+
/* @__PURE__ */ e(N, { htmlFor: "maximum", children: "Maximum Value" }),
|
|
696
696
|
/* @__PURE__ */ e(
|
|
697
697
|
R,
|
|
698
698
|
{
|
|
@@ -718,7 +718,7 @@ function ee({
|
|
|
718
718
|
/* @__PURE__ */ s("div", { className: "space-y-4 p-4 pt-0", children: [
|
|
719
719
|
/* @__PURE__ */ s("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
720
720
|
/* @__PURE__ */ s("div", { className: "space-y-2", children: [
|
|
721
|
-
/* @__PURE__ */ e(
|
|
721
|
+
/* @__PURE__ */ e(N, { htmlFor: "min-items", children: "Minimum Items" }),
|
|
722
722
|
/* @__PURE__ */ e(
|
|
723
723
|
R,
|
|
724
724
|
{
|
|
@@ -735,7 +735,7 @@ function ee({
|
|
|
735
735
|
)
|
|
736
736
|
] }),
|
|
737
737
|
/* @__PURE__ */ s("div", { className: "space-y-2", children: [
|
|
738
|
-
/* @__PURE__ */ e(
|
|
738
|
+
/* @__PURE__ */ e(N, { htmlFor: "max-items", children: "Maximum Items" }),
|
|
739
739
|
/* @__PURE__ */ e(
|
|
740
740
|
R,
|
|
741
741
|
{
|
|
@@ -762,7 +762,7 @@ function ee({
|
|
|
762
762
|
"data-testid": "checkbox-edit-unique"
|
|
763
763
|
}
|
|
764
764
|
),
|
|
765
|
-
/* @__PURE__ */ e(
|
|
765
|
+
/* @__PURE__ */ e(N, { htmlFor: "unique-items", className: "cursor-pointer", children: "All items must be unique" })
|
|
766
766
|
] })
|
|
767
767
|
] })
|
|
768
768
|
] })
|
|
@@ -842,8 +842,8 @@ function ot(t, i) {
|
|
|
842
842
|
const le = () => `${Date.now()}-${Math.random()}`;
|
|
843
843
|
function de(t = {}) {
|
|
844
844
|
const { onConfirm: i, onCancel: a, createInitialData: l } = t, [n, r] = P(!1), [d, c] = P(null), C = (v) => {
|
|
845
|
-
const
|
|
846
|
-
c(
|
|
845
|
+
const b = v ?? (l ? l() : null);
|
|
846
|
+
c(b), r(!0);
|
|
847
847
|
}, h = () => {
|
|
848
848
|
r(!1), c(null), a?.();
|
|
849
849
|
};
|
|
@@ -910,7 +910,7 @@ function te({
|
|
|
910
910
|
t.description || "",
|
|
911
911
|
(g) => i({ ...t, description: g || void 0 }),
|
|
912
912
|
{ allowEmpty: !0 }
|
|
913
|
-
),
|
|
913
|
+
), b = ot(t, i), m = ct(t, i), o = `h${Math.min(l, 6)}`, k = t.type === "object", L = k && t.children && t.children.length > 0, O = {
|
|
914
914
|
1: "text-lg font-semibold",
|
|
915
915
|
2: "text-base",
|
|
916
916
|
3: "text-base",
|
|
@@ -964,23 +964,23 @@ function te({
|
|
|
964
964
|
children: t.title || t.key || /* @__PURE__ */ e("span", { className: "text-muted-foreground italic", children: "unnamed" })
|
|
965
965
|
}
|
|
966
966
|
),
|
|
967
|
-
|
|
967
|
+
b.isChangingType ? /* @__PURE__ */ s(
|
|
968
968
|
Q,
|
|
969
969
|
{
|
|
970
970
|
value: t.type,
|
|
971
|
-
onValueChange: (g) =>
|
|
972
|
-
open:
|
|
973
|
-
onOpenChange:
|
|
971
|
+
onValueChange: (g) => b.handleTypeChange(g),
|
|
972
|
+
open: b.isChangingType,
|
|
973
|
+
onOpenChange: b.setIsChangingType,
|
|
974
974
|
children: [
|
|
975
975
|
/* @__PURE__ */ e(H, { className: "w-[140px] h-7", children: /* @__PURE__ */ e(W, {}) }),
|
|
976
|
-
/* @__PURE__ */ e(_, { children:
|
|
976
|
+
/* @__PURE__ */ e(_, { children: b.availableTypes.map((g) => /* @__PURE__ */ e(S, { value: g, children: d[g] }, g)) })
|
|
977
977
|
]
|
|
978
978
|
}
|
|
979
979
|
) : /* @__PURE__ */ e(We, { children: /* @__PURE__ */ s(Ye, { children: [
|
|
980
980
|
/* @__PURE__ */ e(Ze, { asChild: !0, children: /* @__PURE__ */ s(
|
|
981
981
|
"button",
|
|
982
982
|
{
|
|
983
|
-
onClick: () => !h &&
|
|
983
|
+
onClick: () => !h && b.setIsChangingType(!0),
|
|
984
984
|
className: h ? "rounded p-0.5 -mt-0.5 cursor-default" : "cursor-pointer hover:bg-accent rounded p-0.5 -mt-0.5 transition-colors",
|
|
985
985
|
children: [
|
|
986
986
|
t.type === "string" && /* @__PURE__ */ e(
|
|
@@ -1331,7 +1331,7 @@ function vt({
|
|
|
1331
1331
|
r && /* @__PURE__ */ s("div", { className: "mt-4 space-y-4", children: [
|
|
1332
1332
|
/* @__PURE__ */ s("div", { className: "space-y-2", children: [
|
|
1333
1333
|
/* @__PURE__ */ e(
|
|
1334
|
-
|
|
1334
|
+
N,
|
|
1335
1335
|
{
|
|
1336
1336
|
htmlFor: "schema-title",
|
|
1337
1337
|
className: "text-xs text-muted-foreground",
|
|
@@ -1352,7 +1352,7 @@ function vt({
|
|
|
1352
1352
|
] }),
|
|
1353
1353
|
/* @__PURE__ */ s("div", { className: "space-y-2", children: [
|
|
1354
1354
|
/* @__PURE__ */ e(
|
|
1355
|
-
|
|
1355
|
+
N,
|
|
1356
1356
|
{
|
|
1357
1357
|
htmlFor: "schema-description",
|
|
1358
1358
|
className: "text-xs text-muted-foreground",
|
|
@@ -1375,7 +1375,7 @@ function vt({
|
|
|
1375
1375
|
] }),
|
|
1376
1376
|
/* @__PURE__ */ s("div", { className: "space-y-2", children: [
|
|
1377
1377
|
/* @__PURE__ */ e(
|
|
1378
|
-
|
|
1378
|
+
N,
|
|
1379
1379
|
{
|
|
1380
1380
|
htmlFor: "schema-version",
|
|
1381
1381
|
className: "text-xs text-muted-foreground",
|
|
@@ -1508,7 +1508,7 @@ const V = (t, i, a = !0) => {
|
|
|
1508
1508
|
), v = F(async () => {
|
|
1509
1509
|
const m = await gt();
|
|
1510
1510
|
i(m);
|
|
1511
|
-
}, [i]),
|
|
1511
|
+
}, [i]), b = F(() => {
|
|
1512
1512
|
Te(t, "schema.json");
|
|
1513
1513
|
}, [t]);
|
|
1514
1514
|
return {
|
|
@@ -1520,7 +1520,7 @@ const V = (t, i, a = !0) => {
|
|
|
1520
1520
|
clearAll: y,
|
|
1521
1521
|
updateMetadata: f,
|
|
1522
1522
|
importSchema: v,
|
|
1523
|
-
downloadSchema:
|
|
1523
|
+
downloadSchema: b
|
|
1524
1524
|
};
|
|
1525
1525
|
};
|
|
1526
1526
|
function Nt() {
|
|
@@ -1556,7 +1556,7 @@ function Et({
|
|
|
1556
1556
|
propertyLabel: y = { singular: "property", plural: "properties" },
|
|
1557
1557
|
showRegex: f = !1,
|
|
1558
1558
|
keyEditable: v = !1,
|
|
1559
|
-
readonly:
|
|
1559
|
+
readonly: b = !1
|
|
1560
1560
|
}) {
|
|
1561
1561
|
const {
|
|
1562
1562
|
properties: m,
|
|
@@ -1569,7 +1569,8 @@ function Et({
|
|
|
1569
1569
|
importSchema: E
|
|
1570
1570
|
} = bt({
|
|
1571
1571
|
schema: t,
|
|
1572
|
-
onChange: i
|
|
1572
|
+
onChange: i ?? (() => {
|
|
1573
|
+
}),
|
|
1573
1574
|
includeMetadata: a
|
|
1574
1575
|
}), j = de({
|
|
1575
1576
|
createInitialData: () => k(),
|
|
@@ -1589,11 +1590,11 @@ function Et({
|
|
|
1589
1590
|
propertyLabel: y,
|
|
1590
1591
|
showRegex: f,
|
|
1591
1592
|
keyEditable: v,
|
|
1592
|
-
readonly:
|
|
1593
|
+
readonly: b
|
|
1593
1594
|
},
|
|
1594
1595
|
children: /* @__PURE__ */ s("div", { className: `${c} flex flex-col json-schema-builder-react`, children: [
|
|
1595
1596
|
d && /* @__PURE__ */ e("header", { className: "h-16 border-b flex items-center justify-between px-6", children: /* @__PURE__ */ s("div", { className: "flex items-center gap-3", children: [
|
|
1596
|
-
!
|
|
1597
|
+
!b && l && /* @__PURE__ */ e(
|
|
1597
1598
|
T,
|
|
1598
1599
|
{
|
|
1599
1600
|
variant: "outline",
|
|
@@ -1603,7 +1604,7 @@ function Et({
|
|
|
1603
1604
|
children: /* @__PURE__ */ e(Ge, { className: "w-4 h-4" })
|
|
1604
1605
|
}
|
|
1605
1606
|
),
|
|
1606
|
-
!
|
|
1607
|
+
!b && n && /* @__PURE__ */ e(
|
|
1607
1608
|
T,
|
|
1608
1609
|
{
|
|
1609
1610
|
variant: "outline",
|
|
@@ -1626,17 +1627,17 @@ function Et({
|
|
|
1626
1627
|
description: o.description,
|
|
1627
1628
|
version: o.version,
|
|
1628
1629
|
onUpdate: (I, B) => g(I, B),
|
|
1629
|
-
readonly:
|
|
1630
|
+
readonly: b
|
|
1630
1631
|
}
|
|
1631
1632
|
),
|
|
1632
|
-
m.length === 0 ? /* @__PURE__ */ s("div", { className: "flex flex-col items-center justify-center py-
|
|
1633
|
-
/* @__PURE__ */ e("div", { className: "w-16 h-16 rounded-full bg-muted flex items-center justify-center mb-4", children: /* @__PURE__ */ e($, { className: "w-8 h-8 text-muted-foreground" }) }),
|
|
1633
|
+
m.length === 0 ? /* @__PURE__ */ s("div", { className: "flex flex-col items-center justify-center py-4 text-center", children: [
|
|
1634
|
+
!b && /* @__PURE__ */ e("div", { className: "w-16 h-16 rounded-full bg-muted flex items-center justify-center mb-4", children: /* @__PURE__ */ e($, { className: "w-8 h-8 text-muted-foreground" }) }),
|
|
1634
1635
|
/* @__PURE__ */ s("h2", { className: "text-lg font-medium mb-2", children: [
|
|
1635
1636
|
"No ",
|
|
1636
1637
|
y.plural,
|
|
1637
1638
|
" yet"
|
|
1638
1639
|
] }),
|
|
1639
|
-
!
|
|
1640
|
+
!b && /* @__PURE__ */ s(X, { children: [
|
|
1640
1641
|
/* @__PURE__ */ s("p", { className: "text-sm text-muted-foreground mb-6 max-w-sm", children: [
|
|
1641
1642
|
"Start building your JSON schema by adding your first",
|
|
1642
1643
|
" ",
|
|
@@ -1678,7 +1679,7 @@ function Et({
|
|
|
1678
1679
|
] })
|
|
1679
1680
|
] })
|
|
1680
1681
|
] }),
|
|
1681
|
-
m.length > 0 && !
|
|
1682
|
+
m.length > 0 && !b && /* @__PURE__ */ e("div", { className: "border-t p-2 pt-4 bg-background", children: /* @__PURE__ */ s(
|
|
1682
1683
|
T,
|
|
1683
1684
|
{
|
|
1684
1685
|
onClick: () => j.open(),
|