@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 +13 -5
- package/dist/renderers.cjs.js +5 -5
- package/dist/renderers.es.js +246 -228
- package/package.json +40 -40
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<
|
|
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;
|
|
85
|
-
* only calls these callbacks
|
|
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;
|
package/dist/renderers.cjs.js
CHANGED
|
@@ -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
|
-
${
|
|
4
|
-
${
|
|
5
|
-
${
|
|
6
|
-
`,onDragEnter:
|
|
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;
|
package/dist/renderers.es.js
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
import { jsx as e, jsxs as s, Fragment as
|
|
2
|
-
import { createContext as
|
|
3
|
-
import { rankWith as z, isStringControl as
|
|
4
|
-
import { withJsonFormsControlProps as
|
|
5
|
-
import { Box as w, Flex as v, Text as c, TextField as
|
|
6
|
-
import { FileTextIcon as
|
|
7
|
-
const
|
|
8
|
-
function
|
|
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
|
|
14
|
-
return /* @__PURE__ */ e(
|
|
14
|
+
const m = { onUpload: l, getDownloadUrl: r, openFileInNewTab: u };
|
|
15
|
+
return /* @__PURE__ */ e(he.Provider, { value: m, children: t });
|
|
15
16
|
}
|
|
16
|
-
function
|
|
17
|
-
return
|
|
17
|
+
function _e() {
|
|
18
|
+
return Te(he);
|
|
18
19
|
}
|
|
19
|
-
const
|
|
20
|
-
var
|
|
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
|
-
|
|
30
|
+
Q.Root,
|
|
30
31
|
{
|
|
31
32
|
value: t || "",
|
|
32
|
-
onChange: (
|
|
33
|
+
onChange: (C) => l(r, C.target.value),
|
|
33
34
|
disabled: !b,
|
|
34
|
-
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
|
-
},
|
|
43
|
+
}, Ge = z(
|
|
43
44
|
1,
|
|
44
|
-
|
|
45
|
-
),
|
|
46
|
-
var
|
|
47
|
-
const d = i.length === 0,
|
|
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
|
-
|
|
63
|
+
Q.Root,
|
|
63
64
|
{
|
|
64
65
|
type: "number",
|
|
65
66
|
value: t ?? "",
|
|
66
|
-
onChange: (h) =>
|
|
67
|
+
onChange: (h) => f(h.target.value),
|
|
67
68
|
disabled: !b,
|
|
68
|
-
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
|
-
},
|
|
77
|
+
}, Xe = z(
|
|
77
78
|
2,
|
|
78
|
-
|
|
79
|
-
),
|
|
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
|
-
|
|
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
|
-
},
|
|
102
|
+
}, Ye = z(
|
|
102
103
|
2,
|
|
103
|
-
|
|
104
|
-
),
|
|
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
|
|
108
|
-
a.enum ?
|
|
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
|
|
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
|
-
|
|
121
|
+
H.Root,
|
|
121
122
|
{
|
|
122
|
-
value:
|
|
123
|
+
value: C,
|
|
123
124
|
onValueChange: (p) => l(r, p),
|
|
124
125
|
disabled: !b,
|
|
125
126
|
children: [
|
|
126
127
|
/* @__PURE__ */ e(
|
|
127
|
-
|
|
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(
|
|
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
|
-
},
|
|
142
|
+
}, tr = z(
|
|
142
143
|
2,
|
|
143
|
-
|
|
144
|
-
),
|
|
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
|
-
|
|
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
|
-
},
|
|
167
|
+
}, lr = z(
|
|
167
168
|
2,
|
|
168
|
-
|
|
169
|
-
),
|
|
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
|
-
|
|
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
|
-
},
|
|
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
|
-
|
|
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
|
-
},
|
|
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(
|
|
199
|
-
a.label && /* @__PURE__ */ e(
|
|
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
|
-
|
|
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
|
-
},
|
|
214
|
-
var
|
|
215
|
-
const n = t.elements.filter((h) => h.type === "Category"), [b, d] =
|
|
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
|
|
218
|
-
return /* @__PURE__ */ s(
|
|
219
|
-
/* @__PURE__ */ e(
|
|
220
|
-
/* @__PURE__ */ e(w, { pt: "3", children: n.map((h, p) => /* @__PURE__ */ e(
|
|
221
|
-
|
|
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:
|
|
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}-${
|
|
231
|
+
`${r}-${p}-${D}`
|
|
231
232
|
)) }) }, `${r}-${p}`)) })
|
|
232
233
|
] });
|
|
233
|
-
},
|
|
234
|
-
function
|
|
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
|
|
237
|
-
r.expiresAt <= t +
|
|
237
|
+
for (const [l, r] of $.entries())
|
|
238
|
+
r.expiresAt <= t + pe && $.delete(l);
|
|
238
239
|
}
|
|
239
|
-
function
|
|
240
|
-
if (
|
|
241
|
-
const u =
|
|
242
|
-
u != null &&
|
|
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
|
-
|
|
245
|
+
$.set(t, { url: l, expiresAt: r });
|
|
245
246
|
}
|
|
246
|
-
function
|
|
247
|
+
function W(t) {
|
|
247
248
|
return !t.startsWith("data:");
|
|
248
249
|
}
|
|
249
|
-
const
|
|
250
|
-
const n =
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
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
|
-
|
|
263
|
+
x("Download not configured for this application.");
|
|
259
264
|
return;
|
|
260
265
|
}
|
|
261
|
-
|
|
266
|
+
k(!0), x(null);
|
|
262
267
|
try {
|
|
263
|
-
const
|
|
264
|
-
if (
|
|
265
|
-
|
|
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 (
|
|
268
|
-
|
|
272
|
+
if (g != null && g.aborted) return;
|
|
273
|
+
x("Unable to reach the server.");
|
|
269
274
|
} finally {
|
|
270
|
-
|
|
275
|
+
g != null && g.aborted || k(!1);
|
|
271
276
|
}
|
|
272
277
|
}, [n]);
|
|
273
|
-
|
|
274
|
-
if (t &&
|
|
278
|
+
X(() => {
|
|
279
|
+
if (t && W(t) && !T) {
|
|
275
280
|
const o = new AbortController();
|
|
276
|
-
return
|
|
281
|
+
return te(t, o.signal), () => o.abort();
|
|
277
282
|
}
|
|
278
|
-
|
|
279
|
-
}, [t,
|
|
280
|
-
const
|
|
281
|
-
|
|
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 && !
|
|
288
|
+
if (t && !W(t))
|
|
284
289
|
try {
|
|
285
|
-
const
|
|
286
|
-
for (let
|
|
287
|
-
|
|
288
|
-
const
|
|
289
|
-
return
|
|
290
|
-
} catch (
|
|
291
|
-
console.error("Failed to create blob URL:",
|
|
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
|
-
|
|
299
|
+
G(null);
|
|
295
300
|
}, [t]);
|
|
296
|
-
const
|
|
297
|
-
if (o.size >
|
|
298
|
-
const
|
|
299
|
-
|
|
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
|
|
303
|
-
if (
|
|
304
|
-
|
|
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
|
|
310
|
-
l(r,
|
|
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
|
-
|
|
317
|
+
C("Upload failed."), R.current && (R.current.value = "");
|
|
313
318
|
}
|
|
314
319
|
return;
|
|
315
320
|
}
|
|
316
|
-
|
|
317
|
-
}, [
|
|
318
|
-
o.preventDefault(), o.stopPropagation(), !(!
|
|
319
|
-
},
|
|
320
|
-
o.preventDefault(), o.stopPropagation(), d(!1), !(!
|
|
321
|
-
},
|
|
322
|
-
o.target.files && o.target.files[0] &&
|
|
323
|
-
},
|
|
324
|
-
T && (l(r, null), p(null),
|
|
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(
|
|
333
|
-
/* @__PURE__ */ e(w, { className: "bg-blue-100 p-2 rounded text-blue-600", children: /* @__PURE__ */ e(
|
|
334
|
-
/* @__PURE__ */ e(w, { style: { flex: 1, overflow: "hidden" }, children: /* @__PURE__ */ e(c, { size: "2", weight: "bold", className: "block truncate", children:
|
|
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
|
-
|
|
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:
|
|
357
|
+
href: oe || "#",
|
|
340
358
|
target: "_blank",
|
|
341
359
|
rel: "noopener noreferrer",
|
|
342
360
|
onClick: (o) => {
|
|
343
|
-
o.stopPropagation(),
|
|
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(
|
|
350
|
-
|
|
351
|
-
|
|
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:
|
|
373
|
+
onClick: Ce,
|
|
356
374
|
className: "hover:text-red-600 transition-colors",
|
|
357
|
-
children: /* @__PURE__ */ e(
|
|
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
|
-
${
|
|
369
|
-
${
|
|
386
|
+
${f ? "border-red-300 bg-red-50" : ""}
|
|
387
|
+
${U ? "cursor-pointer" : "opacity-60 cursor-not-allowed pointer-events-none"}
|
|
370
388
|
`,
|
|
371
|
-
onDragEnter:
|
|
372
|
-
onDragLeave:
|
|
373
|
-
onDragOver:
|
|
374
|
-
onDrop:
|
|
389
|
+
onDragEnter: J,
|
|
390
|
+
onDragLeave: J,
|
|
391
|
+
onDragOver: J,
|
|
392
|
+
onDrop: fe,
|
|
375
393
|
onClick: () => {
|
|
376
394
|
var o;
|
|
377
|
-
return
|
|
395
|
+
return U && ((o = R.current) == null ? void 0 : o.click());
|
|
378
396
|
},
|
|
379
397
|
onKeyDown: (o) => {
|
|
380
|
-
var
|
|
381
|
-
|
|
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:
|
|
402
|
+
tabIndex: U ? 0 : -1,
|
|
385
403
|
children: [
|
|
386
404
|
/* @__PURE__ */ e(
|
|
387
405
|
"input",
|
|
388
406
|
{
|
|
389
|
-
ref:
|
|
407
|
+
ref: R,
|
|
390
408
|
type: "file",
|
|
391
409
|
style: { display: "none" },
|
|
392
|
-
accept:
|
|
393
|
-
onChange:
|
|
394
|
-
disabled: !
|
|
410
|
+
accept: N,
|
|
411
|
+
onChange: ye,
|
|
412
|
+
disabled: !U
|
|
395
413
|
}
|
|
396
414
|
),
|
|
397
|
-
/* @__PURE__ */ e(v, { direction: "column", align: "center", gap: "2", children:
|
|
398
|
-
/* @__PURE__ */ e(
|
|
399
|
-
/* @__PURE__ */ e(c, { size: "2", color: "red", weight: "medium", children:
|
|
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(
|
|
402
|
-
/* @__PURE__ */ e(
|
|
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(
|
|
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
|
-
},
|
|
432
|
+
}, yr = I(fr), Cr = z(
|
|
415
433
|
3,
|
|
416
434
|
// Rank
|
|
417
|
-
|
|
418
|
-
),
|
|
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
|
|
431
|
-
if (i === !1 || !
|
|
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 =
|
|
434
|
-
const
|
|
435
|
-
a && a(l,
|
|
436
|
-
},
|
|
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
|
|
439
|
-
|
|
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:
|
|
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((
|
|
446
|
-
var
|
|
447
|
-
const
|
|
448
|
-
return /* @__PURE__ */ e(
|
|
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
|
-
|
|
470
|
+
A + 1
|
|
453
471
|
] }),
|
|
454
472
|
m && /* @__PURE__ */ s(
|
|
455
|
-
|
|
473
|
+
_,
|
|
456
474
|
{
|
|
457
475
|
type: "button",
|
|
458
476
|
color: "red",
|
|
459
477
|
variant: "soft",
|
|
460
|
-
onClick: () =>
|
|
478
|
+
onClick: () => q(A),
|
|
461
479
|
title: "Remove item",
|
|
462
480
|
children: [
|
|
463
|
-
/* @__PURE__ */ e(
|
|
481
|
+
/* @__PURE__ */ e(Me, {}),
|
|
464
482
|
"Remove"
|
|
465
483
|
]
|
|
466
484
|
}
|
|
467
485
|
)
|
|
468
486
|
] }),
|
|
469
487
|
/* @__PURE__ */ e(w, { children: /* @__PURE__ */ e(
|
|
470
|
-
|
|
488
|
+
B,
|
|
471
489
|
{
|
|
472
490
|
schema: h,
|
|
473
|
-
uischema: ((
|
|
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((
|
|
495
|
+
).map((V) => ({
|
|
478
496
|
type: "Control",
|
|
479
|
-
scope: `#/properties/${
|
|
497
|
+
scope: `#/properties/${V}`
|
|
480
498
|
}))
|
|
481
499
|
} : {
|
|
482
500
|
type: "Control",
|
|
483
501
|
scope: "#"
|
|
484
502
|
}),
|
|
485
|
-
path:
|
|
503
|
+
path: x,
|
|
486
504
|
enabled: m,
|
|
487
505
|
renderers: void 0,
|
|
488
506
|
cells: void 0
|
|
489
507
|
}
|
|
490
508
|
) })
|
|
491
|
-
] }) },
|
|
509
|
+
] }) }, x);
|
|
492
510
|
}),
|
|
493
511
|
m && /* @__PURE__ */ e(w, { mt: "2", children: /* @__PURE__ */ s(
|
|
494
|
-
|
|
512
|
+
_,
|
|
495
513
|
{
|
|
496
514
|
type: "button",
|
|
497
515
|
variant: "surface",
|
|
498
|
-
onClick:
|
|
516
|
+
onClick: D,
|
|
499
517
|
children: [
|
|
500
|
-
/* @__PURE__ */ e(
|
|
518
|
+
/* @__PURE__ */ e(We, {}),
|
|
501
519
|
"Add Item"
|
|
502
520
|
]
|
|
503
521
|
}
|
|
504
522
|
) })
|
|
505
523
|
] }) });
|
|
506
|
-
},
|
|
524
|
+
}, de = Se(vr), wr = z(
|
|
507
525
|
3,
|
|
508
|
-
|
|
509
|
-
),
|
|
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(
|
|
512
|
-
},
|
|
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
|
-
|
|
515
|
-
),
|
|
516
|
-
{ tester:
|
|
517
|
-
{ tester:
|
|
518
|
-
{ tester:
|
|
519
|
-
{ tester:
|
|
520
|
-
{ tester:
|
|
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:
|
|
526
|
-
{ tester:
|
|
527
|
-
{ tester:
|
|
528
|
-
{ tester:
|
|
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
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
}
|