@opennsw/jsonforms-renderers 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -29,11 +29,16 @@ export declare const DateControl: ({ data, handleChange, path, label, required,
29
29
 
30
30
  export declare const DateControlTester: RankedTester;
31
31
 
32
+ export declare interface DownloadUrlResult {
33
+ url: string;
34
+ expiresAt: number;
35
+ }
36
+
32
37
  export declare const FileControl: ComponentType<OwnPropsOfControl>;
33
38
 
34
39
  export declare const FileControlTester: (uischema: UISchemaElement, schema: JsonSchema, context: TesterContext) => number;
35
40
 
36
- export declare type GetDownloadUrl = (key: string) => Promise<string>;
41
+ export declare type GetDownloadUrl = (key: string) => Promise<DownloadUrlResult>;
37
42
 
38
43
  export declare const GroupLayoutRenderer: ({ uischema, schema, path, renderers, cells, enabled }: LayoutProps) => JSX.Element;
39
44
 
@@ -51,6 +56,8 @@ export declare const NumberControl: ({ data, handleChange, path, label, required
51
56
 
52
57
  export declare const NumberControlTester: RankedTester;
53
58
 
59
+ export declare type OpenFileInNewTab = (key: string) => Promise<void>;
60
+
54
61
  export declare const radixRenderers: ({
55
62
  tester: RankedTester;
56
63
  renderer: ComponentType<OwnPropsOfControl>;
@@ -70,20 +77,21 @@ export declare const TextControlTester: RankedTester;
70
77
  export declare interface UploadContextValue {
71
78
  onUpload?: UploadHandler;
72
79
  getDownloadUrl?: GetDownloadUrl;
80
+ openFileInNewTab?: OpenFileInNewTab;
73
81
  }
74
82
 
75
83
  export declare type UploadHandler = (file: File) => Promise<UploadResponse>;
76
84
 
77
- export declare function UploadProvider({ children, onUpload, getDownloadUrl, }: {
85
+ export declare function UploadProvider({ children, onUpload, getDownloadUrl, openFileInNewTab, }: {
78
86
  children: ReactNode;
79
87
  onUpload?: UploadHandler;
80
88
  getDownloadUrl?: GetDownloadUrl;
89
+ openFileInNewTab?: OpenFileInNewTab;
81
90
  }): JSX.Element;
82
91
 
83
92
  /**
84
- * Contract for upload: applications provide the implementation; the renderer
85
- * only calls these callbacks. Keeps the package backend-agnostic (IoC) so e.g.
86
- * OGA can move to a separate repo with its own backend/endpoints.
93
+ * Contract for upload: applications provide the implementation;
94
+ * the renderer only calls these callbacks
87
95
  */
88
96
  export declare interface UploadResponse {
89
97
  key: string;
@@ -1,6 +1,6 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),f=require("react"),i=require("@jsonforms/core"),C=require("@jsonforms/react"),r=require("@radix-ui/themes"),L=require("@radix-ui/react-icons"),_=f.createContext(null);function De({children:o,onUpload:l,getDownloadUrl:t}){const u={onUpload:l,getDownloadUrl:t};return e.jsx(_.Provider,{value:u,children:o})}function G(){return f.useContext(_)}const K=({data:o,handleChange:l,path:t,label:u,required:p,errors:c,uischema:a,schema:s,enabled:m})=>{var b;const d=c.length===0;return e.jsx(r.Box,{mb:"4",children:e.jsxs(r.Flex,{direction:"column",gap:"1",children:[e.jsxs(r.Text,{as:"label",size:"2",weight:"bold",htmlFor:t,children:[u," ",p&&e.jsx(r.Text,{color:"red",children:"*"})]}),e.jsx(r.TextField.Root,{value:o||"",onChange:g=>l(t,g.target.value),disabled:!m,placeholder:(b=a.options)==null?void 0:b.placeholder,color:d?void 0:"red",id:t}),!d&&c!=="is a required property"&&e.jsx(r.Text,{color:"red",size:"1",children:c}),s.description&&e.jsx(r.Text,{size:"1",color:"gray",children:s.description})]})})},X=i.rankWith(1,i.isStringControl),Le=C.withJsonFormsControlProps(K),Z=({data:o,handleChange:l,path:t,label:u,required:p,errors:c,uischema:a,schema:s,enabled:m})=>{var g;const d=c.length===0,b=x=>{if(x===""){l(t,void 0);return}const h=Number(x);isNaN(h)||l(t,h)};return e.jsx(r.Box,{mb:"4",children:e.jsxs(r.Flex,{direction:"column",gap:"1",children:[e.jsxs(r.Text,{as:"label",size:"2",weight:"bold",htmlFor:t,children:[u," ",p&&e.jsx(r.Text,{color:"red",children:"*"})]}),e.jsx(r.TextField.Root,{type:"number",value:o??"",onChange:x=>b(x.target.value),disabled:!m,placeholder:(g=a.options)==null?void 0:g.placeholder,color:d?void 0:"red",id:t}),!d&&c!=="is a required property"&&e.jsx(r.Text,{color:"red",size:"1",children:c}),s.description&&e.jsx(r.Text,{size:"1",color:"gray",children:s.description})]})})},Q=i.rankWith(2,i.or(i.isNumberControl,i.isIntegerControl)),Ae=C.withJsonFormsControlProps(Z),Y=({data:o,handleChange:l,path:t,label:u,required:p,errors:c,schema:a,enabled:s})=>{const m=c.length===0;return e.jsxs(r.Box,{mb:"4",children:[e.jsxs(r.Flex,{gap:"2",align:"center",children:[e.jsx(r.Checkbox,{checked:!!o,onCheckedChange:d=>l(t,d===!0),disabled:!s,id:t}),e.jsxs(r.Text,{as:"label",size:"2",htmlFor:t,children:[u," ",p&&"*"]})]}),!m&&e.jsx(r.Text,{color:"red",size:"1",className:"block mt-1",children:c}),a.description&&e.jsx(r.Text,{size:"1",color:"gray",className:"block mt-1",children:a.description})]})},ee=i.rankWith(2,i.isBooleanControl),Se=C.withJsonFormsControlProps(Y),re=({data:o,handleChange:l,path:t,label:u,required:p,errors:c,schema:a,uischema:s,enabled:m})=>{var x;const d=c.length===0;let b=[];a.enum?b=a.enum.map(h=>({value:String(h),label:String(h)})):a.oneOf&&(b=a.oneOf.map(h=>({value:String(h.const),label:h.title||String(h.const)})));const g=o!==void 0?String(o):"";return e.jsx(r.Box,{mb:"4",children:e.jsxs(r.Flex,{direction:"column",gap:"1",children:[e.jsxs(r.Text,{as:"label",size:"2",weight:"bold",htmlFor:t,children:[u," ",p&&e.jsx(r.Text,{color:"red",children:"*"})]}),e.jsxs(r.Select.Root,{value:g,onValueChange:h=>l(t,h),disabled:!m,children:[e.jsx(r.Select.Trigger,{placeholder:((x=s.options)==null?void 0:x.placeholder)||"Select an option",color:d?void 0:"red",id:t}),e.jsx(r.Select.Content,{children:b.map(h=>e.jsx(r.Select.Item,{value:h.value,children:h.label},h.value))})]}),!d&&c!=="is a required property"&&e.jsx(r.Text,{color:"red",size:"1",children:c}),a.description&&e.jsx(r.Text,{size:"1",color:"gray",children:a.description})]})})},te=i.rankWith(2,i.or(i.isEnumControl,i.isOneOfControl)),Be=C.withJsonFormsControlProps(re),oe=({data:o,handleChange:l,path:t,label:u,required:p,errors:c,schema:a,enabled:s})=>{const m=c.length===0;return e.jsx(r.Box,{mb:"4",children:e.jsxs(r.Flex,{direction:"column",gap:"1",children:[e.jsxs(r.Text,{as:"label",size:"2",weight:"bold",htmlFor:t,children:[u," ",p&&e.jsx(r.Text,{color:"red",children:"*"})]}),e.jsx(r.TextField.Root,{type:"date",value:o||"",onChange:d=>l(t,d.target.value),disabled:!s,color:m?void 0:"red",id:t}),!m&&c!=="is a required property"&&e.jsx(r.Text,{color:"red",size:"1",children:c}),a.description&&e.jsx(r.Text,{size:"1",color:"gray",children:a.description})]})})},ne=i.rankWith(2,i.isDateControl),Re=C.withJsonFormsControlProps(oe),se=({uischema:o,schema:l,path:t,renderers:u,cells:p,enabled:c})=>{const s=o.elements;return e.jsx(r.Flex,{direction:"column",gap:"4",children:s.map((m,d)=>e.jsx(C.JsonFormsDispatch,{uischema:m,schema:l,path:t,renderers:u,cells:p,enabled:c},`${t}-${d}`))})},le=i.rankWith(1,i.uiTypeIs("VerticalLayout")),ie=({uischema:o,schema:l,path:t,renderers:u,cells:p,enabled:c})=>{const s=o.elements;return e.jsx(r.Flex,{direction:"row",gap:"4",children:s.map((m,d)=>e.jsx(r.Box,{style:{flex:1},children:e.jsx(C.JsonFormsDispatch,{uischema:m,schema:l,path:t,renderers:u,cells:p,enabled:c})},`${t}-${d}`))})},ce=i.rankWith(1,i.uiTypeIs("HorizontalLayout")),ae=({uischema:o,schema:l,path:t,renderers:u,cells:p,enabled:c})=>{const a=o,s=a.elements;return e.jsxs(r.Card,{mb:"4",children:[a.label&&e.jsx(r.Heading,{size:"4",mb:"4",children:a.label}),e.jsx(r.Flex,{direction:"column",gap:"4",children:s.map((m,d)=>e.jsx(C.JsonFormsDispatch,{uischema:m,schema:l,path:t,renderers:u,cells:p,enabled:c},`${t}-${d}`))})]})},de=i.rankWith(1,i.uiTypeIs("Group")),ue=({uischema:o,schema:l,path:t,renderers:u,cells:p,enabled:c})=>{var g;const s=o.elements.filter(x=>x.type==="Category"),[m,d]=f.useState(((g=s[0])==null?void 0:g.label)||"");if(!s.length)return null;const b=s.find(x=>x.label===m)?m:s[0].label;return e.jsxs(r.Tabs.Root,{value:b,onValueChange:d,children:[e.jsx(r.Tabs.List,{children:s.map((x,h)=>e.jsx(r.Tabs.Trigger,{value:x.label,children:x.label},`${t}-${h}`))}),e.jsx(r.Box,{pt:"3",children:s.map((x,h)=>e.jsx(r.Tabs.Content,{value:x.label,children:e.jsx(r.Flex,{direction:"column",gap:"4",children:x.elements.map((B,w)=>e.jsx(C.JsonFormsDispatch,{uischema:B,schema:l,path:t,renderers:u,cells:p,enabled:c},`${t}-${h}-${w}`))})},`${t}-${h}`))})]})},xe=i.rankWith(1,i.uiTypeIs("Categorization")),Ue=50,he=60,A=new Map;function pe(){const o=Date.now()/1e3;for(const[l,t]of A.entries())t.expiresAt<=o+he&&A.delete(l)}function $e(o,l,t){if(pe(),A.size>=Ue){const u=A.keys().next().value;u!=null&&A.delete(u)}A.set(o,{url:l,expiresAt:t})}function E(o){return!o.startsWith("data:")}const Ie=({data:o,handleChange:l,path:t,label:u,required:p,uischema:c,enabled:a})=>{const s=G(),[m,d]=f.useState(!1),[b,g]=f.useState(null),[x,h]=f.useState(null),[B,w]=f.useState(null),[I,z]=f.useState(!1),[v,k]=f.useState(null),F=f.useRef(null),R=(c==null?void 0:c.options)||{},U=R.maxSize||5*1024*1024,S=R.accept||"image/*,application/pdf",T=a!==!1,J=f.useCallback(async(n,j)=>{pe();const D=A.get(n);if(D&&D.expiresAt>Date.now()/1e3+he){w(D.url);return}if(!(s!=null&&s.getDownloadUrl)){k("Download not configured for this application.");return}z(!0),k(null);try{const y=await s.getDownloadUrl(n);if(j!=null&&j.aborted)return;w(y),$e(n,y,Math.floor(Date.now()/1e3)+900)}catch{if(j!=null&&j.aborted)return;k("Unable to reach the server.")}finally{j!=null&&j.aborted||z(!1)}},[s]);f.useEffect(()=>{if(o&&E(o)){const n=new AbortController;return J(o,n.signal),()=>n.abort()}w(null),k(null)},[o,J]);const fe=()=>x||(o?"Uploaded File":null),[Ce,N]=f.useState(null);f.useEffect(()=>{var n;if(o&&!E(o))try{const j=o.split(","),D=((n=j[0].match(/:(.*?);/))==null?void 0:n[1])||"application/octet-stream",y=j[1],W=atob(y),O=new Array(W.length);for(let $=0;$<W.length;$++)O[$]=W.charCodeAt($);const ze=new Uint8Array(O),ke=new Blob([ze],{type:D}),M=URL.createObjectURL(ke);return N(M),()=>URL.revokeObjectURL(M)}catch(j){console.error("Failed to create blob URL:",j),N(null)}else N(null)},[o]);const q=o&&E(o)?B:Ce,H=f.useCallback(async n=>{if(n.size>U){const y=(U/1048576).toFixed(0);g(`File size exceeds ${y}MB limit.`);return}const D=S.split(",").map(y=>y.trim()).some(y=>y.endsWith("/*")?n.type.startsWith(y.slice(0,-1)):y.startsWith(".")?n.name.toLowerCase().endsWith(y.toLowerCase()):n.type===y);if(S!=="*"&&!D&&!S.includes("*/*")){g(`Invalid file type. Accepted types: ${S}`);return}if(s!=null&&s.onUpload){try{const y=await s.onUpload(n);l(t,y.key),h(y.name??n.name),g(null)}catch{g("Upload failed.")}return}g("Upload service not configured for this application.")},[S,s,U,t,l]),P=n=>{n.preventDefault(),n.stopPropagation(),!(!T||o)&&(n.type==="dragenter"||n.type==="dragover"?d(!0):n.type==="dragleave"&&d(!1))},Te=n=>{n.preventDefault(),n.stopPropagation(),d(!1),!(!T||o)&&n.dataTransfer.files&&n.dataTransfer.files[0]&&H(n.dataTransfer.files[0])},ve=n=>{n.target.files&&n.target.files[0]&&H(n.target.files[0])},Fe=()=>{T&&(l(t,null),h(null),g(null),F.current&&(F.current.value=""))},we=n=>{var j;T&&(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),(j=F.current)==null||j.click())};return e.jsxs(r.Box,{mb:"4",children:[e.jsxs(r.Text,{as:"label",size:"2",weight:"bold",mb:"1",className:"block",children:[u," ",p&&"*"]}),o?e.jsx(r.Card,{size:"2",variant:"surface",className:"relative group",children:e.jsxs(r.Flex,{align:"center",gap:"3",children:[e.jsx(r.Box,{className:"bg-blue-100 p-2 rounded text-blue-600",children:e.jsx(L.FileTextIcon,{width:"20",height:"20"})}),e.jsx(r.Box,{style:{flex:1,overflow:"hidden"},children:e.jsx(r.Text,{size:"2",weight:"bold",className:"block truncate",children:fe()})}),e.jsxs(r.Flex,{align:"center",gap:"3",children:[I?e.jsx(r.Text,{size:"1",color:"gray",children:"Loading..."}):v?e.jsx(r.Text,{size:"1",color:"red",children:"Error"}):e.jsx(r.Button,{variant:"soft",color:"blue",size:"1",asChild:!0,children:e.jsx("a",{href:q||"#",target:"_blank",rel:"noopener noreferrer",onClick:n=>{n.stopPropagation(),q||n.preventDefault()},children:"View"})}),e.jsxs(r.Flex,{align:"center",gap:"2",children:[e.jsx(L.CheckCircledIcon,{className:"text-green-600 w-5 h-5"}),T&&e.jsx(r.IconButton,{variant:"ghost",color:"gray",onClick:Fe,className:"hover:text-red-600 transition-colors",children:e.jsx(L.Cross2Icon,{})})]})]})]})}):e.jsxs("div",{className:`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),y=require("react"),i=require("@jsonforms/core"),C=require("@jsonforms/react"),r=require("@radix-ui/themes"),R=require("@radix-ui/react-icons"),Z=y.createContext(null);function Be({children:o,onUpload:l,getDownloadUrl:t,openFileInNewTab:u}){const p={onUpload:l,getDownloadUrl:t,openFileInNewTab:u};return e.jsx(Z.Provider,{value:p,children:o})}function Q(){return y.useContext(Z)}const Y=({data:o,handleChange:l,path:t,label:u,required:p,errors:c,uischema:a,schema:s,enabled:b})=>{var g;const d=c.length===0;return e.jsx(r.Box,{mb:"4",children:e.jsxs(r.Flex,{direction:"column",gap:"1",children:[e.jsxs(r.Text,{as:"label",size:"2",weight:"bold",htmlFor:t,children:[u," ",p&&e.jsx(r.Text,{color:"red",children:"*"})]}),e.jsx(r.TextField.Root,{value:o||"",onChange:f=>l(t,f.target.value),disabled:!b,placeholder:(g=a.options)==null?void 0:g.placeholder,color:d?void 0:"red",id:t}),!d&&c!=="is a required property"&&e.jsx(r.Text,{color:"red",size:"1",children:c}),s.description&&e.jsx(r.Text,{size:"1",color:"gray",children:s.description})]})})},ee=i.rankWith(1,i.isStringControl),Se=C.withJsonFormsControlProps(Y),re=({data:o,handleChange:l,path:t,label:u,required:p,errors:c,uischema:a,schema:s,enabled:b})=>{var f;const d=c.length===0,g=x=>{if(x===""){l(t,void 0);return}const h=Number(x);isNaN(h)||l(t,h)};return e.jsx(r.Box,{mb:"4",children:e.jsxs(r.Flex,{direction:"column",gap:"1",children:[e.jsxs(r.Text,{as:"label",size:"2",weight:"bold",htmlFor:t,children:[u," ",p&&e.jsx(r.Text,{color:"red",children:"*"})]}),e.jsx(r.TextField.Root,{type:"number",value:o??"",onChange:x=>g(x.target.value),disabled:!b,placeholder:(f=a.options)==null?void 0:f.placeholder,color:d?void 0:"red",id:t}),!d&&c!=="is a required property"&&e.jsx(r.Text,{color:"red",size:"1",children:c}),s.description&&e.jsx(r.Text,{size:"1",color:"gray",children:s.description})]})})},te=i.rankWith(2,i.or(i.isNumberControl,i.isIntegerControl)),Ae=C.withJsonFormsControlProps(re),oe=({data:o,handleChange:l,path:t,label:u,required:p,errors:c,schema:a,enabled:s})=>{const b=c.length===0;return e.jsxs(r.Box,{mb:"4",children:[e.jsxs(r.Flex,{gap:"2",align:"center",children:[e.jsx(r.Checkbox,{checked:!!o,onCheckedChange:d=>l(t,d===!0),disabled:!s,id:t}),e.jsxs(r.Text,{as:"label",size:"2",htmlFor:t,children:[u," ",p&&"*"]})]}),!b&&e.jsx(r.Text,{color:"red",size:"1",className:"block mt-1",children:c}),a.description&&e.jsx(r.Text,{size:"1",color:"gray",className:"block mt-1",children:a.description})]})},ne=i.rankWith(2,i.isBooleanControl),Ie=C.withJsonFormsControlProps(oe),se=({data:o,handleChange:l,path:t,label:u,required:p,errors:c,schema:a,uischema:s,enabled:b})=>{var x;const d=c.length===0;let g=[];a.enum?g=a.enum.map(h=>({value:String(h),label:String(h)})):a.oneOf&&(g=a.oneOf.map(h=>({value:String(h.const),label:h.title||String(h.const)})));const f=o!==void 0?String(o):"";return e.jsx(r.Box,{mb:"4",children:e.jsxs(r.Flex,{direction:"column",gap:"1",children:[e.jsxs(r.Text,{as:"label",size:"2",weight:"bold",htmlFor:t,children:[u," ",p&&e.jsx(r.Text,{color:"red",children:"*"})]}),e.jsxs(r.Select.Root,{value:f,onValueChange:h=>l(t,h),disabled:!b,children:[e.jsx(r.Select.Trigger,{placeholder:((x=s.options)==null?void 0:x.placeholder)||"Select an option",color:d?void 0:"red",id:t}),e.jsx(r.Select.Content,{children:g.map(h=>e.jsx(r.Select.Item,{value:h.value,children:h.label},h.value))})]}),!d&&c!=="is a required property"&&e.jsx(r.Text,{color:"red",size:"1",children:c}),a.description&&e.jsx(r.Text,{size:"1",color:"gray",children:a.description})]})})},le=i.rankWith(2,i.or(i.isEnumControl,i.isOneOfControl)),$e=C.withJsonFormsControlProps(se),ie=({data:o,handleChange:l,path:t,label:u,required:p,errors:c,schema:a,enabled:s})=>{const b=c.length===0;return e.jsx(r.Box,{mb:"4",children:e.jsxs(r.Flex,{direction:"column",gap:"1",children:[e.jsxs(r.Text,{as:"label",size:"2",weight:"bold",htmlFor:t,children:[u," ",p&&e.jsx(r.Text,{color:"red",children:"*"})]}),e.jsx(r.TextField.Root,{type:"date",value:o||"",onChange:d=>l(t,d.target.value),disabled:!s,color:b?void 0:"red",id:t}),!b&&c!=="is a required property"&&e.jsx(r.Text,{color:"red",size:"1",children:c}),a.description&&e.jsx(r.Text,{size:"1",color:"gray",children:a.description})]})})},ce=i.rankWith(2,i.isDateControl),Ne=C.withJsonFormsControlProps(ie),ae=({uischema:o,schema:l,path:t,renderers:u,cells:p,enabled:c})=>{const s=o.elements;return e.jsx(r.Flex,{direction:"column",gap:"4",children:s.map((b,d)=>e.jsx(C.JsonFormsDispatch,{uischema:b,schema:l,path:t,renderers:u,cells:p,enabled:c},`${t}-${d}`))})},de=i.rankWith(1,i.uiTypeIs("VerticalLayout")),ue=({uischema:o,schema:l,path:t,renderers:u,cells:p,enabled:c})=>{const s=o.elements;return e.jsx(r.Flex,{direction:"row",gap:"4",children:s.map((b,d)=>e.jsx(r.Box,{style:{flex:1},children:e.jsx(C.JsonFormsDispatch,{uischema:b,schema:l,path:t,renderers:u,cells:p,enabled:c})},`${t}-${d}`))})},xe=i.rankWith(1,i.uiTypeIs("HorizontalLayout")),he=({uischema:o,schema:l,path:t,renderers:u,cells:p,enabled:c})=>{const a=o,s=a.elements;return e.jsxs(r.Card,{mb:"4",children:[a.label&&e.jsx(r.Heading,{size:"4",mb:"4",children:a.label}),e.jsx(r.Flex,{direction:"column",gap:"4",children:s.map((b,d)=>e.jsx(C.JsonFormsDispatch,{uischema:b,schema:l,path:t,renderers:u,cells:p,enabled:c},`${t}-${d}`))})]})},pe=i.rankWith(1,i.uiTypeIs("Group")),be=({uischema:o,schema:l,path:t,renderers:u,cells:p,enabled:c})=>{var f;const s=o.elements.filter(x=>x.type==="Category"),[b,d]=y.useState(((f=s[0])==null?void 0:f.label)||"");if(!s.length)return null;const g=s.find(x=>x.label===b)?b:s[0].label;return e.jsxs(r.Tabs.Root,{value:g,onValueChange:d,children:[e.jsx(r.Tabs.List,{children:s.map((x,h)=>e.jsx(r.Tabs.Trigger,{value:x.label,children:x.label},`${t}-${h}`))}),e.jsx(r.Box,{pt:"3",children:s.map((x,h)=>e.jsx(r.Tabs.Content,{value:x.label,children:e.jsx(r.Flex,{direction:"column",gap:"4",children:x.elements.map((S,F)=>e.jsx(C.JsonFormsDispatch,{uischema:S,schema:l,path:t,renderers:u,cells:p,enabled:c},`${t}-${h}-${F}`))})},`${t}-${h}`))})]})},me=i.rankWith(1,i.uiTypeIs("Categorization")),Pe=50,ge=60,U=new Map;function je(){const o=Date.now()/1e3;for(const[l,t]of U.entries())t.expiresAt<=o+ge&&U.delete(l)}function Ee(o,l,t){if(je(),U.size>=Pe){const u=U.keys().next().value;u!=null&&U.delete(u)}U.set(o,{url:l,expiresAt:t})}function P(o){return!o.startsWith("data:")}const We=({data:o,handleChange:l,path:t,label:u,required:p,uischema:c,enabled:a})=>{const s=Q(),[b,d]=y.useState(!1),[g,f]=y.useState(null),[x,h]=y.useState(null),[S,F]=y.useState(null),[E,z]=y.useState(!1),[w,k]=y.useState(null),[A,I]=y.useState(!1),[T,q]=y.useState(null),L=y.useRef(null);y.useEffect(()=>()=>{T&&URL.revokeObjectURL(T)},[T]);const H=(c==null?void 0:c.options)||{},$=H.maxSize||5*1024*1024,B=H.accept||"image/*,application/pdf",v=a!==!1,M=y.useCallback(async(n,m)=>{je();const D=U.get(n);if(D&&D.expiresAt>Date.now()/1e3+ge){F(D.url);return}if(!(s!=null&&s.getDownloadUrl)){k("Download not configured for this application.");return}z(!0),k(null);try{const j=await s.getDownloadUrl(n);if(m!=null&&m.aborted)return;F(j.url),Ee(n,j.url,j.expiresAt)}catch{if(m!=null&&m.aborted)return;k("Unable to reach the server.")}finally{m!=null&&m.aborted||z(!1)}},[s]);y.useEffect(()=>{if(o&&P(o)&&!T){const n=new AbortController;return M(o,n.signal),()=>n.abort()}T||(F(null),k(null))},[o,M,T]);const we=()=>x||(o?"Uploaded File":null),[Fe,W]=y.useState(null);y.useEffect(()=>{var n;if(o&&!P(o))try{const m=o.split(","),D=((n=m[0].match(/:(.*?);/))==null?void 0:n[1])||"application/octet-stream",j=m[1],O=atob(j),K=new Array(O.length);for(let N=0;N<O.length;N++)K[N]=O.charCodeAt(N);const Re=new Uint8Array(K),Ue=new Blob([Re],{type:D}),X=URL.createObjectURL(Ue);return W(X),()=>URL.revokeObjectURL(X)}catch(m){console.error("Failed to create blob URL:",m),W(null)}else W(null)},[o]);const _=T??(o&&P(o)?S:Fe),G=y.useCallback(async n=>{if(n.size>$){const j=($/1048576).toFixed(0);f(`File size exceeds ${j}MB limit.`);return}const D=B.split(",").map(j=>j.trim()).some(j=>j.endsWith("/*")?n.type.startsWith(j.slice(0,-1)):j.startsWith(".")?n.name.toLowerCase().endsWith(j.toLowerCase()):n.type===j);if(B!=="*"&&!D&&!B.includes("*/*")){f(`Invalid file type. Accepted types: ${B}`);return}if(s!=null&&s.onUpload){try{const j=await s.onUpload(n);q(URL.createObjectURL(n)),l(t,j.key),h(j.name??n.name),f(null)}catch{f("Upload failed."),L.current&&(L.current.value="")}return}f("Upload service not configured for this application.")},[B,s,$,t,l]),V=n=>{n.preventDefault(),n.stopPropagation(),!(!v||o)&&(n.type==="dragenter"||n.type==="dragover"?d(!0):n.type==="dragleave"&&d(!1))},ze=n=>{n.preventDefault(),n.stopPropagation(),d(!1),!(!v||o)&&n.dataTransfer.files&&n.dataTransfer.files[0]&&G(n.dataTransfer.files[0])},ke=n=>{n.target.files&&n.target.files[0]&&G(n.target.files[0])},Le=()=>{v&&(T&&(URL.revokeObjectURL(T),q(null)),l(t,null),h(null),f(null),L.current&&(L.current.value=""))},De=n=>{var m;v&&(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),(m=L.current)==null||m.click())};return e.jsxs(r.Box,{mb:"4",children:[e.jsxs(r.Text,{as:"label",size:"2",weight:"bold",mb:"1",className:"block",children:[u," ",p&&"*"]}),o?e.jsx(r.Card,{size:"2",variant:"surface",className:"relative group",children:e.jsxs(r.Flex,{align:"center",gap:"3",children:[e.jsx(r.Box,{className:"bg-blue-100 p-2 rounded text-blue-600",children:e.jsx(R.FileTextIcon,{width:"20",height:"20"})}),e.jsx(r.Box,{style:{flex:1,overflow:"hidden"},children:e.jsx(r.Text,{size:"2",weight:"bold",className:"block truncate",children:we()})}),e.jsxs(r.Flex,{align:"center",gap:"3",children:[E?e.jsx(r.Text,{size:"1",color:"gray",children:"Loading..."}):w?e.jsx(r.Text,{size:"1",color:"red",children:"Error"}):A?e.jsx(r.Text,{size:"1",color:"gray",children:"Opening…"}):!T&&(s!=null&&s.openFileInNewTab)&&o&&P(o)?e.jsx(r.Button,{variant:"soft",color:"blue",size:"1",onClick:n=>{n.stopPropagation();const m=s.openFileInNewTab;m&&(I(!0),m(o).finally(()=>I(!1)))},children:"View"}):e.jsx(r.Button,{variant:"soft",color:"blue",size:"1",asChild:!0,children:e.jsx("a",{href:_||"#",target:"_blank",rel:"noopener noreferrer",onClick:n=>{n.stopPropagation(),_||n.preventDefault()},children:"View"})}),e.jsxs(r.Flex,{align:"center",gap:"2",children:[e.jsx(R.CheckCircledIcon,{className:"text-green-600 w-5 h-5"}),v&&e.jsx(r.IconButton,{variant:"ghost",color:"gray",onClick:Le,className:"hover:text-red-600 transition-colors",children:e.jsx(R.Cross2Icon,{})})]})]})]})}):e.jsxs("div",{className:`
2
2
  border-2 border-dashed rounded-lg p-6 text-center transition-all duration-200 ease-in-out
3
- ${m?"border-blue-500 bg-blue-50":"border-gray-300 hover:border-blue-400 hover:bg-gray-50"}
4
- ${b?"border-red-300 bg-red-50":""}
5
- ${T?"cursor-pointer":"opacity-60 cursor-not-allowed pointer-events-none"}
6
- `,onDragEnter:P,onDragLeave:P,onDragOver:P,onDrop:Te,onClick:()=>{var n;return T&&((n=F.current)==null?void 0:n.click())},onKeyDown:we,role:"button",tabIndex:T?0:-1,children:[e.jsx("input",{ref:F,type:"file",style:{display:"none"},accept:S,onChange:ve,disabled:!T}),e.jsx(r.Flex,{direction:"column",align:"center",gap:"2",children:b?e.jsxs(e.Fragment,{children:[e.jsx(L.ExclamationTriangleIcon,{className:"w-8 h-8 text-red-500"}),e.jsx(r.Text,{size:"2",color:"red",weight:"medium",children:b}),e.jsx(r.Text,{size:"1",color:"gray",children:"Click to try again"})]}):e.jsxs(e.Fragment,{children:[e.jsx(L.UploadIcon,{className:"w-8 h-8 text-gray-400"}),e.jsx(r.Text,{size:"2",weight:"medium",children:"Click to upload or drag and drop"}),e.jsxs(r.Text,{size:"1",color:"gray",children:["Max ",Math.round(U/(1024*1024)),"MB"]})]})})]})]})},me=C.withJsonFormsControlProps(Ie),be=i.rankWith(3,i.or(i.formatIs("data-url"),i.formatIs("file"))),Ne=({data:o,path:l,schema:t,uischema:u,enabled:p,visible:c,addItem:a,removeItems:s,rootSchema:m,arraySchema:d})=>{const b=d?t:t.items,g=d||t;if(c===!1||!b||typeof b!="object"||Array.isArray(b))return null;const x=b,h=Array.isArray(o)?o:[],B=g.title||"Array Items",w=()=>{const z=i.createDefaultValue(x,m);a&&a(l,z)()},I=z=>{if(s){const v=s(l,[z]);v&&v()}};return e.jsx(r.Box,{mb:"6",children:e.jsxs(r.Flex,{direction:"column",gap:"4",children:[e.jsx(r.Text,{as:"div",size:"4",weight:"bold",children:B}),h.length===0&&e.jsx(r.Box,{py:"4",px:"4",style:{backgroundColor:"var(--gray-3)",borderRadius:"var(--radius-3)"},children:e.jsx(r.Text,{size:"2",color:"gray",children:"No items have been added yet."})}),h.map((z,v)=>{var F;const k=`${l}.${v}`;return e.jsx(r.Card,{size:"3",variant:"surface",children:e.jsxs(r.Flex,{direction:"column",gap:"4",children:[e.jsxs(r.Flex,{justify:"between",align:"center",children:[e.jsxs(r.Text,{size:"3",weight:"bold",children:["Item ",v+1]}),p&&e.jsxs(r.Button,{type:"button",color:"red",variant:"soft",onClick:()=>I(v),title:"Remove item",children:[e.jsx(L.TrashIcon,{}),"Remove"]})]}),e.jsx(r.Box,{children:e.jsx(C.JsonFormsDispatch,{schema:x,uischema:((F=u.options)==null?void 0:F.detail)||(x.type==="object"||x.properties?{type:"VerticalLayout",elements:Object.keys(x.properties||{}).map(R=>({type:"Control",scope:`#/properties/${R}`}))}:{type:"Control",scope:"#"}),path:k,enabled:p,renderers:void 0,cells:void 0})})]})},k)}),p&&e.jsx(r.Box,{mt:"2",children:e.jsxs(r.Button,{type:"button",variant:"surface",onClick:w,children:[e.jsx(L.PlusIcon,{}),"Add Item"]})})]})})},V=C.withJsonFormsArrayControlProps(Ne),ge=i.rankWith(3,i.isObjectArrayControl),je=({uischema:o,visible:l})=>{const t=o;return l===!1?null:e.jsx(r.Box,{mb:"4",children:e.jsx(r.Heading,{size:"4",children:t.text})})},ye=i.rankWith(1,i.uiTypeIs("Label")),Pe=i.rankWith(3,i.isPrimitiveArrayControl),We=[{tester:X,renderer:Le},{tester:Q,renderer:Ae},{tester:ee,renderer:Se},{tester:te,renderer:Be},{tester:ne,renderer:Re},{tester:le,renderer:se},{tester:ce,renderer:ie},{tester:de,renderer:ae},{tester:xe,renderer:ue},{tester:be,renderer:me},{tester:ge,renderer:V},{tester:Pe,renderer:V},{tester:ye,renderer:je}];exports.ArrayControl=V;exports.ArrayControlTester=ge;exports.BooleanControl=Y;exports.BooleanControlTester=ee;exports.CategorizationLayoutRenderer=ue;exports.CategorizationLayoutTester=xe;exports.DateControl=oe;exports.DateControlTester=ne;exports.FileControl=me;exports.FileControlTester=be;exports.GroupLayoutRenderer=ae;exports.GroupLayoutTester=de;exports.HorizontalLayoutRenderer=ie;exports.HorizontalLayoutTester=ce;exports.LabelRenderer=je;exports.LabelTester=ye;exports.NumberControl=Z;exports.NumberControlTester=Q;exports.SelectControl=re;exports.SelectControlTester=te;exports.TextControl=K;exports.TextControlTester=X;exports.UploadProvider=De;exports.VerticalLayoutRenderer=se;exports.VerticalLayoutTester=le;exports.radixRenderers=We;exports.useUpload=G;
3
+ ${b?"border-blue-500 bg-blue-50":"border-gray-300 hover:border-blue-400 hover:bg-gray-50"}
4
+ ${g?"border-red-300 bg-red-50":""}
5
+ ${v?"cursor-pointer":"opacity-60 cursor-not-allowed pointer-events-none"}
6
+ `,onDragEnter:V,onDragLeave:V,onDragOver:V,onDrop:ze,onClick:()=>{var n;return v&&((n=L.current)==null?void 0:n.click())},onKeyDown:De,role:"button",tabIndex:v?0:-1,children:[e.jsx("input",{ref:L,type:"file",style:{display:"none"},accept:B,onChange:ke,disabled:!v}),e.jsx(r.Flex,{direction:"column",align:"center",gap:"2",children:g?e.jsxs(e.Fragment,{children:[e.jsx(R.ExclamationTriangleIcon,{className:"w-8 h-8 text-red-500"}),e.jsx(r.Text,{size:"2",color:"red",weight:"medium",children:g}),e.jsx(r.Text,{size:"1",color:"gray",children:"Click to try again"})]}):e.jsxs(e.Fragment,{children:[e.jsx(R.UploadIcon,{className:"w-8 h-8 text-gray-400"}),e.jsx(r.Text,{size:"2",weight:"medium",children:"Click to upload or drag and drop"}),e.jsxs(r.Text,{size:"1",color:"gray",children:["Max ",Math.round($/(1024*1024)),"MB"]})]})})]})]})},fe=C.withJsonFormsControlProps(We),ye=i.rankWith(3,i.or(i.formatIs("data-url"),i.formatIs("file"))),Ve=({data:o,path:l,schema:t,uischema:u,enabled:p,visible:c,addItem:a,removeItems:s,rootSchema:b,arraySchema:d})=>{const g=d?t:t.items,f=d||t;if(c===!1||!g||typeof g!="object"||Array.isArray(g))return null;const x=g,h=Array.isArray(o)?o:[],S=f.title||"Array Items",F=()=>{const z=i.createDefaultValue(x,b);a&&a(l,z)()},E=z=>{if(s){const w=s(l,[z]);w&&w()}};return e.jsx(r.Box,{mb:"6",children:e.jsxs(r.Flex,{direction:"column",gap:"4",children:[e.jsx(r.Text,{as:"div",size:"4",weight:"bold",children:S}),h.length===0&&e.jsx(r.Box,{py:"4",px:"4",style:{backgroundColor:"var(--gray-3)",borderRadius:"var(--radius-3)"},children:e.jsx(r.Text,{size:"2",color:"gray",children:"No items have been added yet."})}),h.map((z,w)=>{var A;const k=`${l}.${w}`;return e.jsx(r.Card,{size:"3",variant:"surface",children:e.jsxs(r.Flex,{direction:"column",gap:"4",children:[e.jsxs(r.Flex,{justify:"between",align:"center",children:[e.jsxs(r.Text,{size:"3",weight:"bold",children:["Item ",w+1]}),p&&e.jsxs(r.Button,{type:"button",color:"red",variant:"soft",onClick:()=>E(w),title:"Remove item",children:[e.jsx(R.TrashIcon,{}),"Remove"]})]}),e.jsx(r.Box,{children:e.jsx(C.JsonFormsDispatch,{schema:x,uischema:((A=u.options)==null?void 0:A.detail)||(x.type==="object"||x.properties?{type:"VerticalLayout",elements:Object.keys(x.properties||{}).map(I=>({type:"Control",scope:`#/properties/${I}`}))}:{type:"Control",scope:"#"}),path:k,enabled:p,renderers:void 0,cells:void 0})})]})},k)}),p&&e.jsx(r.Box,{mt:"2",children:e.jsxs(r.Button,{type:"button",variant:"surface",onClick:F,children:[e.jsx(R.PlusIcon,{}),"Add Item"]})})]})})},J=C.withJsonFormsArrayControlProps(Ve),Ce=i.rankWith(3,i.isObjectArrayControl),Te=({uischema:o,visible:l})=>{const t=o;return l===!1?null:e.jsx(r.Box,{mb:"4",children:e.jsx(r.Heading,{size:"4",children:t.text})})},ve=i.rankWith(1,i.uiTypeIs("Label")),Oe=i.rankWith(3,i.isPrimitiveArrayControl),Je=[{tester:ee,renderer:Se},{tester:te,renderer:Ae},{tester:ne,renderer:Ie},{tester:le,renderer:$e},{tester:ce,renderer:Ne},{tester:de,renderer:ae},{tester:xe,renderer:ue},{tester:pe,renderer:he},{tester:me,renderer:be},{tester:ye,renderer:fe},{tester:Ce,renderer:J},{tester:Oe,renderer:J},{tester:ve,renderer:Te}];exports.ArrayControl=J;exports.ArrayControlTester=Ce;exports.BooleanControl=oe;exports.BooleanControlTester=ne;exports.CategorizationLayoutRenderer=be;exports.CategorizationLayoutTester=me;exports.DateControl=ie;exports.DateControlTester=ce;exports.FileControl=fe;exports.FileControlTester=ye;exports.GroupLayoutRenderer=he;exports.GroupLayoutTester=pe;exports.HorizontalLayoutRenderer=ue;exports.HorizontalLayoutTester=xe;exports.LabelRenderer=Te;exports.LabelTester=ve;exports.NumberControl=re;exports.NumberControlTester=te;exports.SelectControl=se;exports.SelectControlTester=le;exports.TextControl=Y;exports.TextControlTester=ee;exports.UploadProvider=Be;exports.VerticalLayoutRenderer=ae;exports.VerticalLayoutTester=de;exports.radixRenderers=Je;exports.useUpload=Q;
@@ -1,23 +1,24 @@
1
- import { jsx as e, jsxs as s, Fragment as te } from "react/jsx-runtime";
2
- import { createContext as ye, useContext as Ce, useState as A, useRef as ve, useCallback as oe, useEffect as ne } from "react";
3
- import { rankWith as z, isStringControl as we, or as J, isNumberControl as ze, isIntegerControl as Te, isBooleanControl as De, isEnumControl as xe, isOneOfControl as Ae, isDateControl as ke, uiTypeIs as S, formatIs as le, createDefaultValue as Fe, isObjectArrayControl as Le, isPrimitiveArrayControl as $e } from "@jsonforms/core";
4
- import { withJsonFormsControlProps as N, JsonFormsDispatch as E, withJsonFormsArrayControlProps as Ue } from "@jsonforms/react";
5
- import { Box as w, Flex as v, Text as c, TextField as K, Checkbox as Re, Select as j, Tabs as O, Card as X, Heading as ce, Button as G, IconButton as Ne } from "@radix-ui/themes";
6
- import { FileTextIcon as Ie, CheckCircledIcon as Se, Cross2Icon as Ee, ExclamationTriangleIcon as Be, UploadIcon as Ve, TrashIcon as Pe, PlusIcon as je } from "@radix-ui/react-icons";
7
- const se = ye(null);
8
- function Fr({
1
+ import { jsx as e, jsxs as s, Fragment as ce } from "react/jsx-runtime";
2
+ import { createContext as ze, useContext as Te, useState as L, useRef as Le, useEffect as X, useCallback as se } from "react";
3
+ import { rankWith as z, isStringControl as Ue, or as Z, isNumberControl as Ae, isIntegerControl as De, isBooleanControl as ke, isEnumControl as xe, isOneOfControl as Re, isDateControl as Fe, uiTypeIs as E, formatIs as ae, createDefaultValue as $e, isObjectArrayControl as Ne, isPrimitiveArrayControl as Ie } from "@jsonforms/core";
4
+ import { withJsonFormsControlProps as I, JsonFormsDispatch as B, withJsonFormsArrayControlProps as Se } from "@jsonforms/react";
5
+ import { Box as w, Flex as v, Text as c, TextField as Q, Checkbox as Ee, Select as H, Tabs as M, Card as Y, Heading as ue, Button as _, IconButton as Be } from "@radix-ui/themes";
6
+ import { FileTextIcon as Oe, CheckCircledIcon as Ve, Cross2Icon as Pe, ExclamationTriangleIcon as je, UploadIcon as He, TrashIcon as Me, PlusIcon as We } from "@radix-ui/react-icons";
7
+ const he = ze(null);
8
+ function $r({
9
9
  children: t,
10
10
  onUpload: l,
11
- getDownloadUrl: r
11
+ getDownloadUrl: r,
12
+ openFileInNewTab: u
12
13
  }) {
13
- const u = { onUpload: l, getDownloadUrl: r };
14
- return /* @__PURE__ */ e(se.Provider, { value: u, children: t });
14
+ const m = { onUpload: l, getDownloadUrl: r, openFileInNewTab: u };
15
+ return /* @__PURE__ */ e(he.Provider, { value: m, children: t });
15
16
  }
16
- function Oe() {
17
- return Ce(se);
17
+ function _e() {
18
+ return Te(he);
18
19
  }
19
- const Me = ({ data: t, handleChange: l, path: r, label: u, required: m, errors: i, uischema: a, schema: n, enabled: b }) => {
20
- var g;
20
+ const qe = ({ data: t, handleChange: l, path: r, label: u, required: m, errors: i, uischema: a, schema: n, enabled: b }) => {
21
+ var f;
21
22
  const d = i.length === 0;
22
23
  return /* @__PURE__ */ e(w, { mb: "4", children: /* @__PURE__ */ s(v, { direction: "column", gap: "1", children: [
23
24
  /* @__PURE__ */ s(c, { as: "label", size: "2", weight: "bold", htmlFor: r, children: [
@@ -26,12 +27,12 @@ const Me = ({ data: t, handleChange: l, path: r, label: u, required: m, errors:
26
27
  m && /* @__PURE__ */ e(c, { color: "red", children: "*" })
27
28
  ] }),
28
29
  /* @__PURE__ */ e(
29
- K.Root,
30
+ Q.Root,
30
31
  {
31
32
  value: t || "",
32
- onChange: (f) => l(r, f.target.value),
33
+ onChange: (C) => l(r, C.target.value),
33
34
  disabled: !b,
34
- placeholder: (g = a.options) == null ? void 0 : g.placeholder,
35
+ placeholder: (f = a.options) == null ? void 0 : f.placeholder,
35
36
  color: d ? void 0 : "red",
36
37
  id: r
37
38
  }
@@ -39,12 +40,12 @@ const Me = ({ data: t, handleChange: l, path: r, label: u, required: m, errors:
39
40
  !d && i !== "is a required property" && /* @__PURE__ */ e(c, { color: "red", size: "1", children: i }),
40
41
  n.description && /* @__PURE__ */ e(c, { size: "1", color: "gray", children: n.description })
41
42
  ] }) });
42
- }, He = z(
43
+ }, Ge = z(
43
44
  1,
44
- we
45
- ), We = N(Me), _e = ({ data: t, handleChange: l, path: r, label: u, required: m, errors: i, uischema: a, schema: n, enabled: b }) => {
46
- var f;
47
- const d = i.length === 0, g = (h) => {
45
+ Ue
46
+ ), Je = I(qe), Ke = ({ data: t, handleChange: l, path: r, label: u, required: m, errors: i, uischema: a, schema: n, enabled: b }) => {
47
+ var C;
48
+ const d = i.length === 0, f = (h) => {
48
49
  if (h === "") {
49
50
  l(r, void 0);
50
51
  return;
@@ -59,13 +60,13 @@ const Me = ({ data: t, handleChange: l, path: r, label: u, required: m, errors:
59
60
  m && /* @__PURE__ */ e(c, { color: "red", children: "*" })
60
61
  ] }),
61
62
  /* @__PURE__ */ e(
62
- K.Root,
63
+ Q.Root,
63
64
  {
64
65
  type: "number",
65
66
  value: t ?? "",
66
- onChange: (h) => g(h.target.value),
67
+ onChange: (h) => f(h.target.value),
67
68
  disabled: !b,
68
- placeholder: (f = a.options) == null ? void 0 : f.placeholder,
69
+ placeholder: (C = a.options) == null ? void 0 : C.placeholder,
69
70
  color: d ? void 0 : "red",
70
71
  id: r
71
72
  }
@@ -73,15 +74,15 @@ const Me = ({ data: t, handleChange: l, path: r, label: u, required: m, errors:
73
74
  !d && i !== "is a required property" && /* @__PURE__ */ e(c, { color: "red", size: "1", children: i }),
74
75
  n.description && /* @__PURE__ */ e(c, { size: "1", color: "gray", children: n.description })
75
76
  ] }) });
76
- }, qe = z(
77
+ }, Xe = z(
77
78
  2,
78
- J(ze, Te)
79
- ), Ge = N(_e), Je = ({ data: t, handleChange: l, path: r, label: u, required: m, errors: i, schema: a, enabled: n }) => {
79
+ Z(Ae, De)
80
+ ), Ze = I(Ke), Qe = ({ data: t, handleChange: l, path: r, label: u, required: m, errors: i, schema: a, enabled: n }) => {
80
81
  const b = i.length === 0;
81
82
  return /* @__PURE__ */ s(w, { mb: "4", children: [
82
83
  /* @__PURE__ */ s(v, { gap: "2", align: "center", children: [
83
84
  /* @__PURE__ */ e(
84
- Re,
85
+ Ee,
85
86
  {
86
87
  checked: !!t,
87
88
  onCheckedChange: (d) => l(r, d === !0),
@@ -98,18 +99,18 @@ const Me = ({ data: t, handleChange: l, path: r, label: u, required: m, errors:
98
99
  !b && /* @__PURE__ */ e(c, { color: "red", size: "1", className: "block mt-1", children: i }),
99
100
  a.description && /* @__PURE__ */ e(c, { size: "1", color: "gray", className: "block mt-1", children: a.description })
100
101
  ] });
101
- }, Ke = z(
102
+ }, Ye = z(
102
103
  2,
103
- De
104
- ), Xe = N(Je), Ze = ({ data: t, handleChange: l, path: r, label: u, required: m, errors: i, schema: a, uischema: n, enabled: b }) => {
104
+ ke
105
+ ), er = I(Qe), rr = ({ data: t, handleChange: l, path: r, label: u, required: m, errors: i, schema: a, uischema: n, enabled: b }) => {
105
106
  var h;
106
107
  const d = i.length === 0;
107
- let g = [];
108
- a.enum ? g = a.enum.map((p) => ({ value: String(p), label: String(p) })) : a.oneOf && (g = a.oneOf.map((p) => ({
108
+ let f = [];
109
+ a.enum ? f = a.enum.map((p) => ({ value: String(p), label: String(p) })) : a.oneOf && (f = a.oneOf.map((p) => ({
109
110
  value: String(p.const),
110
111
  label: p.title || String(p.const)
111
112
  })));
112
- const f = t !== void 0 ? String(t) : "";
113
+ const C = t !== void 0 ? String(t) : "";
113
114
  return /* @__PURE__ */ e(w, { mb: "4", children: /* @__PURE__ */ s(v, { direction: "column", gap: "1", children: [
114
115
  /* @__PURE__ */ s(c, { as: "label", size: "2", weight: "bold", htmlFor: r, children: [
115
116
  u,
@@ -117,31 +118,31 @@ const Me = ({ data: t, handleChange: l, path: r, label: u, required: m, errors:
117
118
  m && /* @__PURE__ */ e(c, { color: "red", children: "*" })
118
119
  ] }),
119
120
  /* @__PURE__ */ s(
120
- j.Root,
121
+ H.Root,
121
122
  {
122
- value: f,
123
+ value: C,
123
124
  onValueChange: (p) => l(r, p),
124
125
  disabled: !b,
125
126
  children: [
126
127
  /* @__PURE__ */ e(
127
- j.Trigger,
128
+ H.Trigger,
128
129
  {
129
130
  placeholder: ((h = n.options) == null ? void 0 : h.placeholder) || "Select an option",
130
131
  color: d ? void 0 : "red",
131
132
  id: r
132
133
  }
133
134
  ),
134
- /* @__PURE__ */ e(j.Content, { children: g.map((p) => /* @__PURE__ */ e(j.Item, { value: p.value, children: p.label }, p.value)) })
135
+ /* @__PURE__ */ e(H.Content, { children: f.map((p) => /* @__PURE__ */ e(H.Item, { value: p.value, children: p.label }, p.value)) })
135
136
  ]
136
137
  }
137
138
  ),
138
139
  !d && i !== "is a required property" && /* @__PURE__ */ e(c, { color: "red", size: "1", children: i }),
139
140
  a.description && /* @__PURE__ */ e(c, { size: "1", color: "gray", children: a.description })
140
141
  ] }) });
141
- }, Qe = z(
142
+ }, tr = z(
142
143
  2,
143
- J(xe, Ae)
144
- ), Ye = N(Ze), er = ({ data: t, handleChange: l, path: r, label: u, required: m, errors: i, schema: a, enabled: n }) => {
144
+ Z(xe, Re)
145
+ ), or = I(rr), nr = ({ data: t, handleChange: l, path: r, label: u, required: m, errors: i, schema: a, enabled: n }) => {
145
146
  const b = i.length === 0;
146
147
  return /* @__PURE__ */ e(w, { mb: "4", children: /* @__PURE__ */ s(v, { direction: "column", gap: "1", children: [
147
148
  /* @__PURE__ */ s(c, { as: "label", size: "2", weight: "bold", htmlFor: r, children: [
@@ -150,7 +151,7 @@ const Me = ({ data: t, handleChange: l, path: r, label: u, required: m, errors:
150
151
  m && /* @__PURE__ */ e(c, { color: "red", children: "*" })
151
152
  ] }),
152
153
  /* @__PURE__ */ e(
153
- K.Root,
154
+ Q.Root,
154
155
  {
155
156
  type: "date",
156
157
  value: t || "",
@@ -163,13 +164,13 @@ const Me = ({ data: t, handleChange: l, path: r, label: u, required: m, errors:
163
164
  !b && i !== "is a required property" && /* @__PURE__ */ e(c, { color: "red", size: "1", children: i }),
164
165
  a.description && /* @__PURE__ */ e(c, { size: "1", color: "gray", children: a.description })
165
166
  ] }) });
166
- }, rr = z(
167
+ }, lr = z(
167
168
  2,
168
- ke
169
- ), tr = N(er), or = ({ uischema: t, schema: l, path: r, renderers: u, cells: m, enabled: i }) => {
169
+ Fe
170
+ ), ir = I(nr), cr = ({ uischema: t, schema: l, path: r, renderers: u, cells: m, enabled: i }) => {
170
171
  const n = t.elements;
171
172
  return /* @__PURE__ */ e(v, { direction: "column", gap: "4", children: n.map((b, d) => /* @__PURE__ */ e(
172
- E,
173
+ B,
173
174
  {
174
175
  uischema: b,
175
176
  schema: l,
@@ -180,10 +181,10 @@ const Me = ({ data: t, handleChange: l, path: r, label: u, required: m, errors:
180
181
  },
181
182
  `${r}-${d}`
182
183
  )) });
183
- }, nr = z(1, S("VerticalLayout")), lr = ({ uischema: t, schema: l, path: r, renderers: u, cells: m, enabled: i }) => {
184
+ }, sr = z(1, E("VerticalLayout")), ar = ({ uischema: t, schema: l, path: r, renderers: u, cells: m, enabled: i }) => {
184
185
  const n = t.elements;
185
186
  return /* @__PURE__ */ e(v, { direction: "row", gap: "4", children: n.map((b, d) => /* @__PURE__ */ e(w, { style: { flex: 1 }, children: /* @__PURE__ */ e(
186
- E,
187
+ B,
187
188
  {
188
189
  uischema: b,
189
190
  schema: l,
@@ -193,12 +194,12 @@ const Me = ({ data: t, handleChange: l, path: r, label: u, required: m, errors:
193
194
  enabled: i
194
195
  }
195
196
  ) }, `${r}-${d}`)) });
196
- }, ir = z(1, S("HorizontalLayout")), cr = ({ uischema: t, schema: l, path: r, renderers: u, cells: m, enabled: i }) => {
197
+ }, dr = z(1, E("HorizontalLayout")), ur = ({ uischema: t, schema: l, path: r, renderers: u, cells: m, enabled: i }) => {
197
198
  const a = t, n = a.elements;
198
- return /* @__PURE__ */ s(X, { mb: "4", children: [
199
- a.label && /* @__PURE__ */ e(ce, { size: "4", mb: "4", children: a.label }),
199
+ return /* @__PURE__ */ s(Y, { mb: "4", children: [
200
+ a.label && /* @__PURE__ */ e(ue, { size: "4", mb: "4", children: a.label }),
200
201
  /* @__PURE__ */ e(v, { direction: "column", gap: "4", children: n.map((b, d) => /* @__PURE__ */ e(
201
- E,
202
+ B,
202
203
  {
203
204
  uischema: b,
204
205
  schema: l,
@@ -210,118 +211,122 @@ const Me = ({ data: t, handleChange: l, path: r, label: u, required: m, errors:
210
211
  `${r}-${d}`
211
212
  )) })
212
213
  ] });
213
- }, sr = z(1, S("Group")), ar = ({ uischema: t, schema: l, path: r, renderers: u, cells: m, enabled: i }) => {
214
- var f;
215
- const n = t.elements.filter((h) => h.type === "Category"), [b, d] = A(((f = n[0]) == null ? void 0 : f.label) || "");
214
+ }, hr = z(1, E("Group")), pr = ({ uischema: t, schema: l, path: r, renderers: u, cells: m, enabled: i }) => {
215
+ var C;
216
+ const n = t.elements.filter((h) => h.type === "Category"), [b, d] = L(((C = n[0]) == null ? void 0 : C.label) || "");
216
217
  if (!n.length) return null;
217
- const g = n.find((h) => h.label === b) ? b : n[0].label;
218
- return /* @__PURE__ */ s(O.Root, { value: g, onValueChange: d, children: [
219
- /* @__PURE__ */ e(O.List, { children: n.map((h, p) => /* @__PURE__ */ e(O.Trigger, { value: h.label, children: h.label }, `${r}-${p}`)) }),
220
- /* @__PURE__ */ e(w, { pt: "3", children: n.map((h, p) => /* @__PURE__ */ e(O.Content, { value: h.label, children: /* @__PURE__ */ e(v, { direction: "column", gap: "4", children: h.elements.map((I, k) => /* @__PURE__ */ e(
221
- E,
218
+ const f = n.find((h) => h.label === b) ? b : n[0].label;
219
+ return /* @__PURE__ */ s(M.Root, { value: f, onValueChange: d, children: [
220
+ /* @__PURE__ */ e(M.List, { children: n.map((h, p) => /* @__PURE__ */ e(M.Trigger, { value: h.label, children: h.label }, `${r}-${p}`)) }),
221
+ /* @__PURE__ */ e(w, { pt: "3", children: n.map((h, p) => /* @__PURE__ */ e(M.Content, { value: h.label, children: /* @__PURE__ */ e(v, { direction: "column", gap: "4", children: h.elements.map((S, D) => /* @__PURE__ */ e(
222
+ B,
222
223
  {
223
- uischema: I,
224
+ uischema: S,
224
225
  schema: l,
225
226
  path: r,
226
227
  renderers: u,
227
228
  cells: m,
228
229
  enabled: i
229
230
  },
230
- `${r}-${p}-${k}`
231
+ `${r}-${p}-${D}`
231
232
  )) }) }, `${r}-${p}`)) })
232
233
  ] });
233
- }, dr = z(1, S("Categorization")), ur = 50, ae = 60, U = /* @__PURE__ */ new Map();
234
- function de() {
234
+ }, mr = z(1, E("Categorization")), br = 50, pe = 60, $ = /* @__PURE__ */ new Map();
235
+ function me() {
235
236
  const t = Date.now() / 1e3;
236
- for (const [l, r] of U.entries())
237
- r.expiresAt <= t + ae && U.delete(l);
237
+ for (const [l, r] of $.entries())
238
+ r.expiresAt <= t + pe && $.delete(l);
238
239
  }
239
- function hr(t, l, r) {
240
- if (de(), U.size >= ur) {
241
- const u = U.keys().next().value;
242
- u != null && U.delete(u);
240
+ function gr(t, l, r) {
241
+ if (me(), $.size >= br) {
242
+ const u = $.keys().next().value;
243
+ u != null && $.delete(u);
243
244
  }
244
- U.set(t, { url: l, expiresAt: r });
245
+ $.set(t, { url: l, expiresAt: r });
245
246
  }
246
- function q(t) {
247
+ function W(t) {
247
248
  return !t.startsWith("data:");
248
249
  }
249
- const pr = ({ data: t, handleChange: l, path: r, label: u, required: m, uischema: i, enabled: a }) => {
250
- const n = Oe(), [b, d] = A(!1), [g, f] = A(null), [h, p] = A(null), [I, k] = A(null), [M, F] = A(!1), [D, L] = A(null), x = ve(null), B = (i == null ? void 0 : i.options) || {}, V = B.maxSize || 5 * 1024 * 1024, R = B.accept || "image/*,application/pdf", T = a !== !1, Z = oe(async (o, y) => {
251
- de();
252
- const $ = U.get(o);
253
- if ($ && $.expiresAt > Date.now() / 1e3 + ae) {
254
- k($.url);
250
+ const fr = ({ data: t, handleChange: l, path: r, label: u, required: m, uischema: i, enabled: a }) => {
251
+ const n = _e(), [b, d] = L(!1), [f, C] = L(null), [h, p] = L(null), [S, D] = L(null), [q, k] = L(!1), [A, x] = L(null), [O, V] = L(!1), [T, ee] = L(null), R = Le(null);
252
+ X(() => () => {
253
+ T && URL.revokeObjectURL(T);
254
+ }, [T]);
255
+ const re = (i == null ? void 0 : i.options) || {}, P = re.maxSize || 5 * 1024 * 1024, N = re.accept || "image/*,application/pdf", U = a !== !1, te = se(async (o, g) => {
256
+ me();
257
+ const F = $.get(o);
258
+ if (F && F.expiresAt > Date.now() / 1e3 + pe) {
259
+ D(F.url);
255
260
  return;
256
261
  }
257
262
  if (!(n != null && n.getDownloadUrl)) {
258
- L("Download not configured for this application.");
263
+ x("Download not configured for this application.");
259
264
  return;
260
265
  }
261
- F(!0), L(null);
266
+ k(!0), x(null);
262
267
  try {
263
- const C = await n.getDownloadUrl(o);
264
- if (y != null && y.aborted) return;
265
- k(C), hr(o, C, Math.floor(Date.now() / 1e3) + 900);
268
+ const y = await n.getDownloadUrl(o);
269
+ if (g != null && g.aborted) return;
270
+ D(y.url), gr(o, y.url, y.expiresAt);
266
271
  } catch {
267
- if (y != null && y.aborted) return;
268
- L("Unable to reach the server.");
272
+ if (g != null && g.aborted) return;
273
+ x("Unable to reach the server.");
269
274
  } finally {
270
- y != null && y.aborted || F(!1);
275
+ g != null && g.aborted || k(!1);
271
276
  }
272
277
  }, [n]);
273
- ne(() => {
274
- if (t && q(t)) {
278
+ X(() => {
279
+ if (t && W(t) && !T) {
275
280
  const o = new AbortController();
276
- return Z(t, o.signal), () => o.abort();
281
+ return te(t, o.signal), () => o.abort();
277
282
  }
278
- k(null), L(null);
279
- }, [t, Z]);
280
- const ue = () => h || (t ? "Uploaded File" : null), [he, H] = A(null);
281
- ne(() => {
283
+ T || (D(null), x(null));
284
+ }, [t, te, T]);
285
+ const be = () => h || (t ? "Uploaded File" : null), [ge, G] = L(null);
286
+ X(() => {
282
287
  var o;
283
- if (t && !q(t))
288
+ if (t && !W(t))
284
289
  try {
285
- const y = t.split(","), $ = ((o = y[0].match(/:(.*?);/)) == null ? void 0 : o[1]) || "application/octet-stream", C = y[1], _ = atob(C), ee = new Array(_.length);
286
- for (let P = 0; P < _.length; P++)
287
- ee[P] = _.charCodeAt(P);
288
- const ge = new Uint8Array(ee), fe = new Blob([ge], { type: $ }), re = URL.createObjectURL(fe);
289
- return H(re), () => URL.revokeObjectURL(re);
290
- } catch (y) {
291
- console.error("Failed to create blob URL:", y), H(null);
290
+ const g = t.split(","), F = ((o = g[0].match(/:(.*?);/)) == null ? void 0 : o[1]) || "application/octet-stream", y = g[1], K = atob(y), le = new Array(K.length);
291
+ for (let j = 0; j < K.length; j++)
292
+ le[j] = K.charCodeAt(j);
293
+ const ve = new Uint8Array(le), we = new Blob([ve], { type: F }), ie = URL.createObjectURL(we);
294
+ return G(ie), () => URL.revokeObjectURL(ie);
295
+ } catch (g) {
296
+ console.error("Failed to create blob URL:", g), G(null);
292
297
  }
293
298
  else
294
- H(null);
299
+ G(null);
295
300
  }, [t]);
296
- const Q = t && q(t) ? I : he, Y = oe(async (o) => {
297
- if (o.size > V) {
298
- const C = (V / 1048576).toFixed(0);
299
- f(`File size exceeds ${C}MB limit.`);
301
+ const oe = T ?? (t && W(t) ? S : ge), ne = se(async (o) => {
302
+ if (o.size > P) {
303
+ const y = (P / 1048576).toFixed(0);
304
+ C(`File size exceeds ${y}MB limit.`);
300
305
  return;
301
306
  }
302
- const $ = R.split(",").map((C) => C.trim()).some((C) => C.endsWith("/*") ? o.type.startsWith(C.slice(0, -1)) : C.startsWith(".") ? o.name.toLowerCase().endsWith(C.toLowerCase()) : o.type === C);
303
- if (R !== "*" && !$ && !R.includes("*/*")) {
304
- f(`Invalid file type. Accepted types: ${R}`);
307
+ const F = N.split(",").map((y) => y.trim()).some((y) => y.endsWith("/*") ? o.type.startsWith(y.slice(0, -1)) : y.startsWith(".") ? o.name.toLowerCase().endsWith(y.toLowerCase()) : o.type === y);
308
+ if (N !== "*" && !F && !N.includes("*/*")) {
309
+ C(`Invalid file type. Accepted types: ${N}`);
305
310
  return;
306
311
  }
307
312
  if (n != null && n.onUpload) {
308
313
  try {
309
- const C = await n.onUpload(o);
310
- l(r, C.key), p(C.name ?? o.name), f(null);
314
+ const y = await n.onUpload(o);
315
+ ee(URL.createObjectURL(o)), l(r, y.key), p(y.name ?? o.name), C(null);
311
316
  } catch {
312
- f("Upload failed.");
317
+ C("Upload failed."), R.current && (R.current.value = "");
313
318
  }
314
319
  return;
315
320
  }
316
- f("Upload service not configured for this application.");
317
- }, [R, n, V, r, l]), W = (o) => {
318
- o.preventDefault(), o.stopPropagation(), !(!T || t) && (o.type === "dragenter" || o.type === "dragover" ? d(!0) : o.type === "dragleave" && d(!1));
319
- }, pe = (o) => {
320
- o.preventDefault(), o.stopPropagation(), d(!1), !(!T || t) && o.dataTransfer.files && o.dataTransfer.files[0] && Y(o.dataTransfer.files[0]);
321
- }, me = (o) => {
322
- o.target.files && o.target.files[0] && Y(o.target.files[0]);
323
- }, be = () => {
324
- T && (l(r, null), p(null), f(null), x.current && (x.current.value = ""));
321
+ C("Upload service not configured for this application.");
322
+ }, [N, n, P, r, l]), J = (o) => {
323
+ o.preventDefault(), o.stopPropagation(), !(!U || t) && (o.type === "dragenter" || o.type === "dragover" ? d(!0) : o.type === "dragleave" && d(!1));
324
+ }, fe = (o) => {
325
+ o.preventDefault(), o.stopPropagation(), d(!1), !(!U || t) && o.dataTransfer.files && o.dataTransfer.files[0] && ne(o.dataTransfer.files[0]);
326
+ }, ye = (o) => {
327
+ o.target.files && o.target.files[0] && ne(o.target.files[0]);
328
+ }, Ce = () => {
329
+ U && (T && (URL.revokeObjectURL(T), ee(null)), l(r, null), p(null), C(null), R.current && (R.current.value = ""));
325
330
  };
326
331
  return /* @__PURE__ */ s(w, { mb: "4", children: [
327
332
  /* @__PURE__ */ s(c, { as: "label", size: "2", weight: "bold", mb: "1", className: "block", children: [
@@ -329,32 +334,45 @@ const pr = ({ data: t, handleChange: l, path: r, label: u, required: m, uischema
329
334
  " ",
330
335
  m && "*"
331
336
  ] }),
332
- t ? /* @__PURE__ */ e(X, { size: "2", variant: "surface", className: "relative group", children: /* @__PURE__ */ s(v, { align: "center", gap: "3", children: [
333
- /* @__PURE__ */ e(w, { className: "bg-blue-100 p-2 rounded text-blue-600", children: /* @__PURE__ */ e(Ie, { width: "20", height: "20" }) }),
334
- /* @__PURE__ */ e(w, { style: { flex: 1, overflow: "hidden" }, children: /* @__PURE__ */ e(c, { size: "2", weight: "bold", className: "block truncate", children: ue() }) }),
337
+ t ? /* @__PURE__ */ e(Y, { size: "2", variant: "surface", className: "relative group", children: /* @__PURE__ */ s(v, { align: "center", gap: "3", children: [
338
+ /* @__PURE__ */ e(w, { className: "bg-blue-100 p-2 rounded text-blue-600", children: /* @__PURE__ */ e(Oe, { width: "20", height: "20" }) }),
339
+ /* @__PURE__ */ e(w, { style: { flex: 1, overflow: "hidden" }, children: /* @__PURE__ */ e(c, { size: "2", weight: "bold", className: "block truncate", children: be() }) }),
335
340
  /* @__PURE__ */ s(v, { align: "center", gap: "3", children: [
336
- M ? /* @__PURE__ */ e(c, { size: "1", color: "gray", children: "Loading..." }) : D ? /* @__PURE__ */ e(c, { size: "1", color: "red", children: "Error" }) : /* @__PURE__ */ e(G, { variant: "soft", color: "blue", size: "1", asChild: !0, children: /* @__PURE__ */ e(
341
+ q ? /* @__PURE__ */ e(c, { size: "1", color: "gray", children: "Loading..." }) : A ? /* @__PURE__ */ e(c, { size: "1", color: "red", children: "Error" }) : O ? /* @__PURE__ */ e(c, { size: "1", color: "gray", children: "Opening…" }) : !T && (n != null && n.openFileInNewTab) && t && W(t) ? /* @__PURE__ */ e(
342
+ _,
343
+ {
344
+ variant: "soft",
345
+ color: "blue",
346
+ size: "1",
347
+ onClick: (o) => {
348
+ o.stopPropagation();
349
+ const g = n.openFileInNewTab;
350
+ g && (V(!0), g(t).finally(() => V(!1)));
351
+ },
352
+ children: "View"
353
+ }
354
+ ) : /* @__PURE__ */ e(_, { variant: "soft", color: "blue", size: "1", asChild: !0, children: /* @__PURE__ */ e(
337
355
  "a",
338
356
  {
339
- href: Q || "#",
357
+ href: oe || "#",
340
358
  target: "_blank",
341
359
  rel: "noopener noreferrer",
342
360
  onClick: (o) => {
343
- o.stopPropagation(), Q || o.preventDefault();
361
+ o.stopPropagation(), oe || o.preventDefault();
344
362
  },
345
363
  children: "View"
346
364
  }
347
365
  ) }),
348
366
  /* @__PURE__ */ s(v, { align: "center", gap: "2", children: [
349
- /* @__PURE__ */ e(Se, { className: "text-green-600 w-5 h-5" }),
350
- T && /* @__PURE__ */ e(
351
- Ne,
367
+ /* @__PURE__ */ e(Ve, { className: "text-green-600 w-5 h-5" }),
368
+ U && /* @__PURE__ */ e(
369
+ Be,
352
370
  {
353
371
  variant: "ghost",
354
372
  color: "gray",
355
- onClick: be,
373
+ onClick: Ce,
356
374
  className: "hover:text-red-600 transition-colors",
357
- children: /* @__PURE__ */ e(Ee, {})
375
+ children: /* @__PURE__ */ e(Pe, {})
358
376
  }
359
377
  )
360
378
  ] })
@@ -365,45 +383,45 @@ const pr = ({ data: t, handleChange: l, path: r, label: u, required: m, uischema
365
383
  className: `
366
384
  border-2 border-dashed rounded-lg p-6 text-center transition-all duration-200 ease-in-out
367
385
  ${b ? "border-blue-500 bg-blue-50" : "border-gray-300 hover:border-blue-400 hover:bg-gray-50"}
368
- ${g ? "border-red-300 bg-red-50" : ""}
369
- ${T ? "cursor-pointer" : "opacity-60 cursor-not-allowed pointer-events-none"}
386
+ ${f ? "border-red-300 bg-red-50" : ""}
387
+ ${U ? "cursor-pointer" : "opacity-60 cursor-not-allowed pointer-events-none"}
370
388
  `,
371
- onDragEnter: W,
372
- onDragLeave: W,
373
- onDragOver: W,
374
- onDrop: pe,
389
+ onDragEnter: J,
390
+ onDragLeave: J,
391
+ onDragOver: J,
392
+ onDrop: fe,
375
393
  onClick: () => {
376
394
  var o;
377
- return T && ((o = x.current) == null ? void 0 : o.click());
395
+ return U && ((o = R.current) == null ? void 0 : o.click());
378
396
  },
379
397
  onKeyDown: (o) => {
380
- var y;
381
- T && (o.key === "Enter" || o.key === " ") && (o.preventDefault(), (y = x.current) == null || y.click());
398
+ var g;
399
+ U && (o.key === "Enter" || o.key === " ") && (o.preventDefault(), (g = R.current) == null || g.click());
382
400
  },
383
401
  role: "button",
384
- tabIndex: T ? 0 : -1,
402
+ tabIndex: U ? 0 : -1,
385
403
  children: [
386
404
  /* @__PURE__ */ e(
387
405
  "input",
388
406
  {
389
- ref: x,
407
+ ref: R,
390
408
  type: "file",
391
409
  style: { display: "none" },
392
- accept: R,
393
- onChange: me,
394
- disabled: !T
410
+ accept: N,
411
+ onChange: ye,
412
+ disabled: !U
395
413
  }
396
414
  ),
397
- /* @__PURE__ */ e(v, { direction: "column", align: "center", gap: "2", children: g ? /* @__PURE__ */ s(te, { children: [
398
- /* @__PURE__ */ e(Be, { className: "w-8 h-8 text-red-500" }),
399
- /* @__PURE__ */ e(c, { size: "2", color: "red", weight: "medium", children: g }),
415
+ /* @__PURE__ */ e(v, { direction: "column", align: "center", gap: "2", children: f ? /* @__PURE__ */ s(ce, { children: [
416
+ /* @__PURE__ */ e(je, { className: "w-8 h-8 text-red-500" }),
417
+ /* @__PURE__ */ e(c, { size: "2", color: "red", weight: "medium", children: f }),
400
418
  /* @__PURE__ */ e(c, { size: "1", color: "gray", children: "Click to try again" })
401
- ] }) : /* @__PURE__ */ s(te, { children: [
402
- /* @__PURE__ */ e(Ve, { className: "w-8 h-8 text-gray-400" }),
419
+ ] }) : /* @__PURE__ */ s(ce, { children: [
420
+ /* @__PURE__ */ e(He, { className: "w-8 h-8 text-gray-400" }),
403
421
  /* @__PURE__ */ e(c, { size: "2", weight: "medium", children: "Click to upload or drag and drop" }),
404
422
  /* @__PURE__ */ s(c, { size: "1", color: "gray", children: [
405
423
  "Max ",
406
- Math.round(V / (1024 * 1024)),
424
+ Math.round(P / (1024 * 1024)),
407
425
  "MB"
408
426
  ] })
409
427
  ] }) })
@@ -411,11 +429,11 @@ const pr = ({ data: t, handleChange: l, path: r, label: u, required: m, uischema
411
429
  }
412
430
  )
413
431
  ] });
414
- }, mr = N(pr), br = z(
432
+ }, yr = I(fr), Cr = z(
415
433
  3,
416
434
  // Rank
417
- J(le("data-url"), le("file"))
418
- ), gr = ({
435
+ Z(ae("data-url"), ae("file"))
436
+ ), vr = ({
419
437
  data: t,
420
438
  path: l,
421
439
  schema: r,
@@ -427,132 +445,132 @@ const pr = ({ data: t, handleChange: l, path: r, label: u, required: m, uischema
427
445
  rootSchema: b,
428
446
  arraySchema: d
429
447
  }) => {
430
- const g = d ? r : r.items, f = d || r;
431
- if (i === !1 || !g || typeof g != "object" || Array.isArray(g))
448
+ const f = d ? r : r.items, C = d || r;
449
+ if (i === !1 || !f || typeof f != "object" || Array.isArray(f))
432
450
  return null;
433
- const h = g, p = Array.isArray(t) ? t : [], I = f.title || "Array Items", k = () => {
434
- const F = Fe(h, b);
435
- a && a(l, F)();
436
- }, M = (F) => {
451
+ const h = f, p = Array.isArray(t) ? t : [], S = C.title || "Array Items", D = () => {
452
+ const k = $e(h, b);
453
+ a && a(l, k)();
454
+ }, q = (k) => {
437
455
  if (n) {
438
- const D = n(l, [F]);
439
- D && D();
456
+ const A = n(l, [k]);
457
+ A && A();
440
458
  }
441
459
  };
442
460
  return /* @__PURE__ */ e(w, { mb: "6", children: /* @__PURE__ */ s(v, { direction: "column", gap: "4", children: [
443
- /* @__PURE__ */ e(c, { as: "div", size: "4", weight: "bold", children: I }),
461
+ /* @__PURE__ */ e(c, { as: "div", size: "4", weight: "bold", children: S }),
444
462
  p.length === 0 && /* @__PURE__ */ e(w, { py: "4", px: "4", style: { backgroundColor: "var(--gray-3)", borderRadius: "var(--radius-3)" }, children: /* @__PURE__ */ e(c, { size: "2", color: "gray", children: "No items have been added yet." }) }),
445
- p.map((F, D) => {
446
- var x;
447
- const L = `${l}.${D}`;
448
- return /* @__PURE__ */ e(X, { size: "3", variant: "surface", children: /* @__PURE__ */ s(v, { direction: "column", gap: "4", children: [
463
+ p.map((k, A) => {
464
+ var O;
465
+ const x = `${l}.${A}`;
466
+ return /* @__PURE__ */ e(Y, { size: "3", variant: "surface", children: /* @__PURE__ */ s(v, { direction: "column", gap: "4", children: [
449
467
  /* @__PURE__ */ s(v, { justify: "between", align: "center", children: [
450
468
  /* @__PURE__ */ s(c, { size: "3", weight: "bold", children: [
451
469
  "Item ",
452
- D + 1
470
+ A + 1
453
471
  ] }),
454
472
  m && /* @__PURE__ */ s(
455
- G,
473
+ _,
456
474
  {
457
475
  type: "button",
458
476
  color: "red",
459
477
  variant: "soft",
460
- onClick: () => M(D),
478
+ onClick: () => q(A),
461
479
  title: "Remove item",
462
480
  children: [
463
- /* @__PURE__ */ e(Pe, {}),
481
+ /* @__PURE__ */ e(Me, {}),
464
482
  "Remove"
465
483
  ]
466
484
  }
467
485
  )
468
486
  ] }),
469
487
  /* @__PURE__ */ e(w, { children: /* @__PURE__ */ e(
470
- E,
488
+ B,
471
489
  {
472
490
  schema: h,
473
- uischema: ((x = u.options) == null ? void 0 : x.detail) || (h.type === "object" || h.properties ? {
491
+ uischema: ((O = u.options) == null ? void 0 : O.detail) || (h.type === "object" || h.properties ? {
474
492
  type: "VerticalLayout",
475
493
  elements: Object.keys(
476
494
  h.properties || {}
477
- ).map((B) => ({
495
+ ).map((V) => ({
478
496
  type: "Control",
479
- scope: `#/properties/${B}`
497
+ scope: `#/properties/${V}`
480
498
  }))
481
499
  } : {
482
500
  type: "Control",
483
501
  scope: "#"
484
502
  }),
485
- path: L,
503
+ path: x,
486
504
  enabled: m,
487
505
  renderers: void 0,
488
506
  cells: void 0
489
507
  }
490
508
  ) })
491
- ] }) }, L);
509
+ ] }) }, x);
492
510
  }),
493
511
  m && /* @__PURE__ */ e(w, { mt: "2", children: /* @__PURE__ */ s(
494
- G,
512
+ _,
495
513
  {
496
514
  type: "button",
497
515
  variant: "surface",
498
- onClick: k,
516
+ onClick: D,
499
517
  children: [
500
- /* @__PURE__ */ e(je, {}),
518
+ /* @__PURE__ */ e(We, {}),
501
519
  "Add Item"
502
520
  ]
503
521
  }
504
522
  ) })
505
523
  ] }) });
506
- }, ie = Ue(gr), fr = z(
524
+ }, de = Se(vr), wr = z(
507
525
  3,
508
- Le
509
- ), yr = ({ uischema: t, visible: l }) => {
526
+ Ne
527
+ ), zr = ({ uischema: t, visible: l }) => {
510
528
  const r = t;
511
- return l === !1 ? null : /* @__PURE__ */ e(w, { mb: "4", children: /* @__PURE__ */ e(ce, { size: "4", children: r.text }) });
512
- }, Cr = z(1, S("Label")), vr = z(
529
+ return l === !1 ? null : /* @__PURE__ */ e(w, { mb: "4", children: /* @__PURE__ */ e(ue, { size: "4", children: r.text }) });
530
+ }, Tr = z(1, E("Label")), Lr = z(
513
531
  3,
514
- $e
515
- ), Lr = [
516
- { tester: He, renderer: We },
517
- { tester: qe, renderer: Ge },
518
- { tester: Ke, renderer: Xe },
519
- { tester: Qe, renderer: Ye },
520
- { tester: rr, renderer: tr },
521
- { tester: nr, renderer: or },
522
- { tester: ir, renderer: lr },
532
+ Ie
533
+ ), Nr = [
534
+ { tester: Ge, renderer: Je },
535
+ { tester: Xe, renderer: Ze },
536
+ { tester: Ye, renderer: er },
537
+ { tester: tr, renderer: or },
538
+ { tester: lr, renderer: ir },
523
539
  { tester: sr, renderer: cr },
524
540
  { tester: dr, renderer: ar },
525
- { tester: br, renderer: mr },
526
- { tester: fr, renderer: ie },
527
- { tester: vr, renderer: ie },
528
- { tester: Cr, renderer: yr }
541
+ { tester: hr, renderer: ur },
542
+ { tester: mr, renderer: pr },
543
+ { tester: Cr, renderer: yr },
544
+ { tester: wr, renderer: de },
545
+ { tester: Lr, renderer: de },
546
+ { tester: Tr, renderer: zr }
529
547
  ];
530
548
  export {
531
- ie as ArrayControl,
532
- fr as ArrayControlTester,
533
- Je as BooleanControl,
534
- Ke as BooleanControlTester,
535
- ar as CategorizationLayoutRenderer,
536
- dr as CategorizationLayoutTester,
537
- er as DateControl,
538
- rr as DateControlTester,
539
- mr as FileControl,
540
- br as FileControlTester,
541
- cr as GroupLayoutRenderer,
542
- sr as GroupLayoutTester,
543
- lr as HorizontalLayoutRenderer,
544
- ir as HorizontalLayoutTester,
545
- yr as LabelRenderer,
546
- Cr as LabelTester,
547
- _e as NumberControl,
548
- qe as NumberControlTester,
549
- Ze as SelectControl,
550
- Qe as SelectControlTester,
551
- Me as TextControl,
552
- He as TextControlTester,
553
- Fr as UploadProvider,
554
- or as VerticalLayoutRenderer,
555
- nr as VerticalLayoutTester,
556
- Lr as radixRenderers,
557
- Oe as useUpload
549
+ de as ArrayControl,
550
+ wr as ArrayControlTester,
551
+ Qe as BooleanControl,
552
+ Ye as BooleanControlTester,
553
+ pr as CategorizationLayoutRenderer,
554
+ mr as CategorizationLayoutTester,
555
+ nr as DateControl,
556
+ lr as DateControlTester,
557
+ yr as FileControl,
558
+ Cr as FileControlTester,
559
+ ur as GroupLayoutRenderer,
560
+ hr as GroupLayoutTester,
561
+ ar as HorizontalLayoutRenderer,
562
+ dr as HorizontalLayoutTester,
563
+ zr as LabelRenderer,
564
+ Tr as LabelTester,
565
+ Ke as NumberControl,
566
+ Xe as NumberControlTester,
567
+ rr as SelectControl,
568
+ tr as SelectControlTester,
569
+ qe as TextControl,
570
+ Ge as TextControlTester,
571
+ $r as UploadProvider,
572
+ cr as VerticalLayoutRenderer,
573
+ sr as VerticalLayoutTester,
574
+ Nr as radixRenderers,
575
+ _e as useUpload
558
576
  };
package/package.json CHANGED
@@ -1,43 +1,43 @@
1
1
  {
2
- "name": "@opennsw/jsonforms-renderers",
3
- "version": "0.1.0",
4
- "type": "module",
5
- "main": "dist/renderers.cjs.js",
6
- "module": "dist/renderers.es.js",
7
- "types": "dist/index.d.ts",
8
- "exports": {
9
- ".": {
10
- "types": "./dist/index.d.ts",
11
- "import": "./dist/renderers.es.js",
12
- "require": "./dist/renderers.cjs.js"
2
+ "name": "@opennsw/jsonforms-renderers",
3
+ "version": "0.2.0",
4
+ "type": "module",
5
+ "main": "dist/renderers.cjs.js",
6
+ "module": "dist/renderers.es.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/renderers.es.js",
12
+ "require": "./dist/renderers.cjs.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "README.md"
18
+ ],
19
+ "scripts": {
20
+ "build": "tsc -b && vite build",
21
+ "lint": "eslint .",
22
+ "type-check": "tsc -b --noEmit"
23
+ },
24
+ "peerDependencies": {
25
+ "react": "^19.2.0",
26
+ "react-dom": "^19.2.0",
27
+ "@jsonforms/core": "^3.2.1",
28
+ "@jsonforms/react": "^3.2.1",
29
+ "@radix-ui/themes": "^3.2.1",
30
+ "@radix-ui/react-icons": "^1.3.2"
31
+ },
32
+ "devDependencies": {
33
+ "@types/node": "^22.10.2",
34
+ "@types/react": "^19.2.5",
35
+ "@types/react-dom": "^19.2.3",
36
+ "@vitejs/plugin-react": "^5.1.1",
37
+ "typescript": "~5.7.2",
38
+ "vite": "^6.2.0",
39
+ "vite-plugin-dts": "^4.5.0",
40
+ "tailwindcss": "^4.0.9",
41
+ "@tailwindcss/vite": "^4.0.9"
13
42
  }
14
- },
15
- "files": [
16
- "dist",
17
- "README.md"
18
- ],
19
- "peerDependencies": {
20
- "react": "^19.2.0",
21
- "react-dom": "^19.2.0",
22
- "@jsonforms/core": "^3.2.1",
23
- "@jsonforms/react": "^3.2.1",
24
- "@radix-ui/themes": "^3.2.1",
25
- "@radix-ui/react-icons": "^1.3.2"
26
- },
27
- "devDependencies": {
28
- "@types/node": "^22.10.2",
29
- "@types/react": "^19.2.5",
30
- "@types/react-dom": "^19.2.3",
31
- "@vitejs/plugin-react": "^5.1.1",
32
- "typescript": "~5.7.2",
33
- "vite": "^6.2.0",
34
- "vite-plugin-dts": "^4.5.0",
35
- "tailwindcss": "^4.0.9",
36
- "@tailwindcss/vite": "^4.0.9"
37
- },
38
- "scripts": {
39
- "build": "tsc -b && vite build",
40
- "lint": "eslint .",
41
- "type-check": "tsc -b --noEmit"
42
- }
43
43
  }