@opennsw/jsonforms-renderers 0.0.1 → 0.0.2

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
@@ -8,6 +8,10 @@ import { RankedTester } from '@jsonforms/core';
8
8
  import { TesterContext } from '@jsonforms/core';
9
9
  import { UISchemaElement } from '@jsonforms/core';
10
10
 
11
+ export declare const ArrayControl: ComponentType<OwnPropsOfControl>;
12
+
13
+ export declare const ArrayControlTester: (uischema: UISchemaElement, schema: JsonSchema, context: TesterContext) => number;
14
+
11
15
  export declare const BooleanControl: ({ data, handleChange, path, label, required, errors, schema, enabled }: ControlProps) => JSX.Element;
12
16
 
13
17
  export declare const BooleanControlTester: RankedTester;
@@ -1,6 +1,6 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("@jsonforms/core"),C=require("@jsonforms/react"),r=require("@radix-ui/themes"),v=require("react"),F=require("@radix-ui/react-icons"),N=({data:s,handleChange:u,path:t,label:g,required:p,errors:n,uischema:c,schema:l,enabled:x})=>{var m;const d=n.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:[g," ",p&&e.jsx(r.Text,{color:"red",children:"*"})]}),e.jsx(r.TextField.Root,{value:s||"",onChange:b=>u(t,b.target.value),disabled:!x,placeholder:(m=c.options)==null?void 0:m.placeholder,color:d?void 0:"red",id:t}),!d&&n!=="is a required property"&&e.jsx(r.Text,{color:"red",size:"1",children:n}),l.description&&e.jsx(r.Text,{size:"1",color:"gray",children:l.description})]})})},R=a.rankWith(1,a.isStringControl),ne=C.withJsonFormsControlProps(N),S=({data:s,handleChange:u,path:t,label:g,required:p,errors:n,uischema:c,schema:l,enabled:x})=>{var b;const d=n.length===0,m=h=>{if(h===""){u(t,void 0);return}const i=Number(h);isNaN(i)||u(t,i)};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:[g," ",p&&e.jsx(r.Text,{color:"red",children:"*"})]}),e.jsx(r.TextField.Root,{type:"number",value:s??"",onChange:h=>m(h.target.value),disabled:!x,placeholder:(b=c.options)==null?void 0:b.placeholder,color:d?void 0:"red",id:t}),!d&&n!=="is a required property"&&e.jsx(r.Text,{color:"red",size:"1",children:n}),l.description&&e.jsx(r.Text,{size:"1",color:"gray",children:l.description})]})})},$=a.rankWith(2,a.or(a.isNumberControl,a.isIntegerControl)),se=C.withJsonFormsControlProps(S),B=({data:s,handleChange:u,path:t,label:g,required:p,errors:n,schema:c,enabled:l})=>{const x=n.length===0;return e.jsxs(r.Box,{mb:"4",children:[e.jsxs(r.Flex,{gap:"2",align:"center",children:[e.jsx(r.Checkbox,{checked:!!s,onCheckedChange:d=>u(t,d===!0),disabled:!l,id:t}),e.jsxs(r.Text,{as:"label",size:"2",htmlFor:t,children:[g," ",p&&"*"]})]}),!x&&e.jsx(r.Text,{color:"red",size:"1",className:"block mt-1",children:n}),c.description&&e.jsx(r.Text,{size:"1",color:"gray",className:"block mt-1",children:c.description})]})},I=a.rankWith(2,a.isBooleanControl),le=C.withJsonFormsControlProps(B),W=({data:s,handleChange:u,path:t,label:g,required:p,errors:n,schema:c,uischema:l,enabled:x})=>{var h;const d=n.length===0;let m=[];c.enum?m=c.enum.map(i=>({value:String(i),label:String(i)})):c.oneOf&&(m=c.oneOf.map(i=>({value:String(i.const),label:i.title||String(i.const)})));const b=s!==void 0?String(s):"";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:[g," ",p&&e.jsx(r.Text,{color:"red",children:"*"})]}),e.jsxs(r.Select.Root,{value:b,onValueChange:i=>u(t,i),disabled:!x,children:[e.jsx(r.Select.Trigger,{placeholder:((h=l.options)==null?void 0:h.placeholder)||"Select an option",color:d?void 0:"red",id:t}),e.jsx(r.Select.Content,{children:m.map(i=>e.jsx(r.Select.Item,{value:i.value,children:i.label},i.value))})]}),!d&&n!=="is a required property"&&e.jsx(r.Text,{color:"red",size:"1",children:n}),c.description&&e.jsx(r.Text,{size:"1",color:"gray",children:c.description})]})})},V=a.rankWith(2,a.or(a.isEnumControl,a.isOneOfControl)),ie=C.withJsonFormsControlProps(W),P=({data:s,handleChange:u,path:t,label:g,required:p,errors:n,schema:c,enabled:l})=>{const x=n.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:[g," ",p&&e.jsx(r.Text,{color:"red",children:"*"})]}),e.jsx(r.TextField.Root,{type:"date",value:s||"",onChange:d=>u(t,d.target.value),disabled:!l,color:x?void 0:"red",id:t}),!x&&n!=="is a required property"&&e.jsx(r.Text,{color:"red",size:"1",children:n}),c.description&&e.jsx(r.Text,{size:"1",color:"gray",children:c.description})]})})},q=a.rankWith(2,a.isDateControl),ae=C.withJsonFormsControlProps(P),J=({uischema:s,schema:u,path:t,renderers:g,cells:p,enabled:n})=>{const l=s.elements;return e.jsx(r.Flex,{direction:"column",gap:"4",children:l.map((x,d)=>e.jsx(C.JsonFormsDispatch,{uischema:x,schema:u,path:t,renderers:g,cells:p,enabled:n},`${t}-${d}`))})},E=a.rankWith(1,a.uiTypeIs("VerticalLayout")),H=({uischema:s,schema:u,path:t,renderers:g,cells:p,enabled:n})=>{const l=s.elements;return e.jsx(r.Flex,{direction:"row",gap:"4",children:l.map((x,d)=>e.jsx(r.Box,{style:{flex:1},children:e.jsx(C.JsonFormsDispatch,{uischema:x,schema:u,path:t,renderers:g,cells:p,enabled:n})},`${t}-${d}`))})},A=a.rankWith(1,a.uiTypeIs("HorizontalLayout")),M=({uischema:s,schema:u,path:t,renderers:g,cells:p,enabled:n})=>{const c=s,l=c.elements;return e.jsxs(r.Card,{mb:"4",children:[c.label&&e.jsx(r.Heading,{size:"4",mb:"4",children:c.label}),e.jsx(r.Flex,{direction:"column",gap:"4",children:l.map((x,d)=>e.jsx(C.JsonFormsDispatch,{uischema:x,schema:u,path:t,renderers:g,cells:p,enabled:n},`${t}-${d}`))})]})},O=a.rankWith(1,a.uiTypeIs("Group")),G=({uischema:s,schema:u,path:t,renderers:g,cells:p,enabled:n})=>{var b;const l=s.elements.filter(h=>h.type==="Category"),[x,d]=v.useState(((b=l[0])==null?void 0:b.label)||"");if(!l.length)return null;const m=l.find(h=>h.label===x)?x:l[0].label;return e.jsxs(r.Tabs.Root,{value:m,onValueChange:d,children:[e.jsx(r.Tabs.List,{children:l.map((h,i)=>e.jsx(r.Tabs.Trigger,{value:h.label,children:h.label},`${t}-${i}`))}),e.jsx(r.Box,{pt:"3",children:l.map((h,i)=>e.jsx(r.Tabs.Content,{value:h.label,children:e.jsx(r.Flex,{direction:"column",gap:"4",children:h.elements.map((z,y)=>e.jsx(C.JsonFormsDispatch,{uischema:z,schema:u,path:t,renderers:g,cells:p,enabled:n},`${t}-${i}-${y}`))})},`${t}-${i}`))})]})},U=a.rankWith(1,a.uiTypeIs("Categorization")),ce=({data:s,handleChange:u,path:t,label:g,required:p,uischema:n,enabled:c})=>{const[l,x]=v.useState(!1),[d,m]=v.useState(null),[b,h]=v.useState(null),i=v.useRef(null),z=(n==null?void 0:n.options)||{},y=z.maxSize||5*1024*1024,f=z.accept||"image/*,application/pdf",T=c!==!1,Z=()=>b||(s?"Uploaded File":null),D=o=>{if(o.size>y){const j=(y/1048576).toFixed(0);m(`File size exceeds ${j}MB limit.`);return}const oe=f.split(",").map(j=>j.trim()).some(j=>j.endsWith("/*")?o.type.startsWith(j.slice(0,-1)):j.startsWith(".")?o.name.toLowerCase().endsWith(j.toLowerCase()):o.type===j);if(f!=="*"&&!oe&&!f.includes("*/*")){m(`Invalid file type. Accepted types: ${f}`);return}const k=new FileReader;k.onload=()=>{const j=k.result;u(t,j),h(o.name),m(null)},k.onerror=()=>{m("Failed to read file")},k.readAsDataURL(o)},w=o=>{o.preventDefault(),o.stopPropagation(),!(!T||s)&&(o.type==="dragenter"||o.type==="dragover"?x(!0):o.type==="dragleave"&&x(!1))},_=o=>{o.preventDefault(),o.stopPropagation(),x(!1),!(!T||s)&&o.dataTransfer.files&&o.dataTransfer.files[0]&&D(o.dataTransfer.files[0])},ee=o=>{o.target.files&&o.target.files[0]&&D(o.target.files[0])},re=()=>{T&&(u(t,null),h(null),m(null),i.current&&(i.current.value=""))},te=o=>{var L;T&&(o.key==="Enter"||o.key===" ")&&(o.preventDefault(),(L=i.current)==null||L.click())};return e.jsxs(r.Box,{mb:"4",children:[e.jsxs(r.Text,{as:"label",size:"2",weight:"bold",mb:"1",className:"block",children:[g," ",p&&"*"]}),s?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(F.FileTextIcon,{width:"20",height:"20"})}),e.jsxs(r.Box,{style:{flex:1,overflow:"hidden"},children:[e.jsx(r.Text,{size:"2",weight:"bold",className:"block truncate",children:Z()}),T?e.jsx(r.Text,{size:"1",color:"gray",children:"Ready to submit"}):e.jsx("a",{href:s,download:b||"document",className:"text-xs text-blue-600 hover:underline cursor-pointer",onClick:o=>o.stopPropagation(),children:"Download"})]}),e.jsxs(r.Flex,{align:"center",gap:"2",children:[e.jsx(F.CheckCircledIcon,{className:"text-green-600 w-5 h-5"}),T&&e.jsx(r.IconButton,{variant:"ghost",color:"gray",onClick:re,className:"hover:text-red-600 transition-colors",children:e.jsx(F.Cross2Icon,{})})]})]})}):e.jsxs("div",{className:`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("@jsonforms/core"),T=require("@jsonforms/react"),r=require("@radix-ui/themes"),z=require("react"),v=require("@radix-ui/react-icons"),B=({data:l,handleChange:u,path:t,label:p,required:h,errors:o,uischema:c,schema:i,enabled:x})=>{var g;const a=o.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:[p," ",h&&e.jsx(r.Text,{color:"red",children:"*"})]}),e.jsx(r.TextField.Root,{value:l||"",onChange:j=>u(t,j.target.value),disabled:!x,placeholder:(g=c.options)==null?void 0:g.placeholder,color:a?void 0:"red",id:t}),!a&&o!=="is a required property"&&e.jsx(r.Text,{color:"red",size:"1",children:o}),i.description&&e.jsx(r.Text,{size:"1",color:"gray",children:i.description})]})})},D=s.rankWith(1,s.isStringControl),le=T.withJsonFormsControlProps(B),I=({data:l,handleChange:u,path:t,label:p,required:h,errors:o,uischema:c,schema:i,enabled:x})=>{var j;const a=o.length===0,g=m=>{if(m===""){u(t,void 0);return}const d=Number(m);isNaN(d)||u(t,d)};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:[p," ",h&&e.jsx(r.Text,{color:"red",children:"*"})]}),e.jsx(r.TextField.Root,{type:"number",value:l??"",onChange:m=>g(m.target.value),disabled:!x,placeholder:(j=c.options)==null?void 0:j.placeholder,color:a?void 0:"red",id:t}),!a&&o!=="is a required property"&&e.jsx(r.Text,{color:"red",size:"1",children:o}),i.description&&e.jsx(r.Text,{size:"1",color:"gray",children:i.description})]})})},N=s.rankWith(2,s.or(s.isNumberControl,s.isIntegerControl)),ie=T.withJsonFormsControlProps(I),S=({data:l,handleChange:u,path:t,label:p,required:h,errors:o,schema:c,enabled:i})=>{const x=o.length===0;return e.jsxs(r.Box,{mb:"4",children:[e.jsxs(r.Flex,{gap:"2",align:"center",children:[e.jsx(r.Checkbox,{checked:!!l,onCheckedChange:a=>u(t,a===!0),disabled:!i,id:t}),e.jsxs(r.Text,{as:"label",size:"2",htmlFor:t,children:[p," ",h&&"*"]})]}),!x&&e.jsx(r.Text,{color:"red",size:"1",className:"block mt-1",children:o}),c.description&&e.jsx(r.Text,{size:"1",color:"gray",className:"block mt-1",children:c.description})]})},A=s.rankWith(2,s.isBooleanControl),ae=T.withJsonFormsControlProps(S),W=({data:l,handleChange:u,path:t,label:p,required:h,errors:o,schema:c,uischema:i,enabled:x})=>{var m;const a=o.length===0;let g=[];c.enum?g=c.enum.map(d=>({value:String(d),label:String(d)})):c.oneOf&&(g=c.oneOf.map(d=>({value:String(d.const),label:d.title||String(d.const)})));const j=l!==void 0?String(l):"";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:[p," ",h&&e.jsx(r.Text,{color:"red",children:"*"})]}),e.jsxs(r.Select.Root,{value:j,onValueChange:d=>u(t,d),disabled:!x,children:[e.jsx(r.Select.Trigger,{placeholder:((m=i.options)==null?void 0:m.placeholder)||"Select an option",color:a?void 0:"red",id:t}),e.jsx(r.Select.Content,{children:g.map(d=>e.jsx(r.Select.Item,{value:d.value,children:d.label},d.value))})]}),!a&&o!=="is a required property"&&e.jsx(r.Text,{color:"red",size:"1",children:o}),c.description&&e.jsx(r.Text,{size:"1",color:"gray",children:c.description})]})})},P=s.rankWith(2,s.or(s.isEnumControl,s.isOneOfControl)),ce=T.withJsonFormsControlProps(W),V=({data:l,handleChange:u,path:t,label:p,required:h,errors:o,schema:c,enabled:i})=>{const x=o.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:[p," ",h&&e.jsx(r.Text,{color:"red",children:"*"})]}),e.jsx(r.TextField.Root,{type:"date",value:l||"",onChange:a=>u(t,a.target.value),disabled:!i,color:x?void 0:"red",id:t}),!x&&o!=="is a required property"&&e.jsx(r.Text,{color:"red",size:"1",children:o}),c.description&&e.jsx(r.Text,{size:"1",color:"gray",children:c.description})]})})},J=s.rankWith(2,s.isDateControl),de=T.withJsonFormsControlProps(V),q=({uischema:l,schema:u,path:t,renderers:p,cells:h,enabled:o})=>{const i=l.elements;return e.jsx(r.Flex,{direction:"column",gap:"4",children:i.map((x,a)=>e.jsx(T.JsonFormsDispatch,{uischema:x,schema:u,path:t,renderers:p,cells:h,enabled:o},`${t}-${a}`))})},E=s.rankWith(1,s.uiTypeIs("VerticalLayout")),H=({uischema:l,schema:u,path:t,renderers:p,cells:h,enabled:o})=>{const i=l.elements;return e.jsx(r.Flex,{direction:"row",gap:"4",children:i.map((x,a)=>e.jsx(r.Box,{style:{flex:1},children:e.jsx(T.JsonFormsDispatch,{uischema:x,schema:u,path:t,renderers:p,cells:h,enabled:o})},`${t}-${a}`))})},O=s.rankWith(1,s.uiTypeIs("HorizontalLayout")),M=({uischema:l,schema:u,path:t,renderers:p,cells:h,enabled:o})=>{const c=l,i=c.elements;return e.jsxs(r.Card,{mb:"4",children:[c.label&&e.jsx(r.Heading,{size:"4",mb:"4",children:c.label}),e.jsx(r.Flex,{direction:"column",gap:"4",children:i.map((x,a)=>e.jsx(T.JsonFormsDispatch,{uischema:x,schema:u,path:t,renderers:p,cells:h,enabled:o},`${t}-${a}`))})]})},G=s.rankWith(1,s.uiTypeIs("Group")),U=({uischema:l,schema:u,path:t,renderers:p,cells:h,enabled:o})=>{var j;const i=l.elements.filter(m=>m.type==="Category"),[x,a]=z.useState(((j=i[0])==null?void 0:j.label)||"");if(!i.length)return null;const g=i.find(m=>m.label===x)?x:i[0].label;return e.jsxs(r.Tabs.Root,{value:g,onValueChange:a,children:[e.jsx(r.Tabs.List,{children:i.map((m,d)=>e.jsx(r.Tabs.Trigger,{value:m.label,children:m.label},`${t}-${d}`))}),e.jsx(r.Box,{pt:"3",children:i.map((m,d)=>e.jsx(r.Tabs.Content,{value:m.label,children:e.jsx(r.Flex,{direction:"column",gap:"4",children:m.elements.map((F,f)=>e.jsx(T.JsonFormsDispatch,{uischema:F,schema:u,path:t,renderers:p,cells:h,enabled:o},`${t}-${d}-${f}`))})},`${t}-${d}`))})]})},K=s.rankWith(1,s.uiTypeIs("Categorization")),ue=({data:l,handleChange:u,path:t,label:p,required:h,uischema:o,enabled:c})=>{const[i,x]=z.useState(!1),[a,g]=z.useState(null),[j,m]=z.useState(null),d=z.useRef(null),F=(o==null?void 0:o.options)||{},f=F.maxSize||5*1024*1024,y=F.accept||"image/*,application/pdf",b=c!==!1,k=()=>j||(l?"Uploaded File":null),w=n=>{if(n.size>f){const C=(f/1048576).toFixed(0);g(`File size exceeds ${C}MB limit.`);return}const se=y.split(",").map(C=>C.trim()).some(C=>C.endsWith("/*")?n.type.startsWith(C.slice(0,-1)):C.startsWith(".")?n.name.toLowerCase().endsWith(C.toLowerCase()):n.type===C);if(y!=="*"&&!se&&!y.includes("*/*")){g(`Invalid file type. Accepted types: ${y}`);return}const L=new FileReader;L.onload=()=>{const C=L.result;u(t,C),m(n.name),g(null)},L.onerror=()=>{g("Failed to read file")},L.readAsDataURL(n)},R=n=>{n.preventDefault(),n.stopPropagation(),!(!b||l)&&(n.type==="dragenter"||n.type==="dragover"?x(!0):n.type==="dragleave"&&x(!1))},re=n=>{n.preventDefault(),n.stopPropagation(),x(!1),!(!b||l)&&n.dataTransfer.files&&n.dataTransfer.files[0]&&w(n.dataTransfer.files[0])},te=n=>{n.target.files&&n.target.files[0]&&w(n.target.files[0])},oe=()=>{b&&(u(t,null),m(null),g(null),d.current&&(d.current.value=""))},ne=n=>{var $;b&&(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),($=d.current)==null||$.click())};return e.jsxs(r.Box,{mb:"4",children:[e.jsxs(r.Text,{as:"label",size:"2",weight:"bold",mb:"1",className:"block",children:[p," ",h&&"*"]}),l?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(v.FileTextIcon,{width:"20",height:"20"})}),e.jsxs(r.Box,{style:{flex:1,overflow:"hidden"},children:[e.jsx(r.Text,{size:"2",weight:"bold",className:"block truncate",children:k()}),b?e.jsx(r.Text,{size:"1",color:"gray",children:"Ready to submit"}):e.jsx("a",{href:l,download:j||"document",className:"text-xs text-blue-600 hover:underline cursor-pointer",onClick:n=>n.stopPropagation(),children:"Download"})]}),e.jsxs(r.Flex,{align:"center",gap:"2",children:[e.jsx(v.CheckCircledIcon,{className:"text-green-600 w-5 h-5"}),b&&e.jsx(r.IconButton,{variant:"ghost",color:"gray",onClick:oe,className:"hover:text-red-600 transition-colors",children:e.jsx(v.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
- ${l?"border-blue-500 bg-blue-50":"border-gray-300 hover:border-blue-400 hover:bg-gray-50"}
4
- ${d?"border-red-300 bg-red-50":""}
5
- ${T?"cursor-pointer":"opacity-60 cursor-not-allowed pointer-events-none"}
6
- `,onDragEnter:w,onDragLeave:w,onDragOver:w,onDrop:_,onClick:()=>{var o;return T&&((o=i.current)==null?void 0:o.click())},onKeyDown:te,role:"button",tabIndex:T?0:-1,children:[e.jsx("input",{ref:i,type:"file",className:"hidden",accept:f,onChange:ee,disabled:!T}),e.jsx(r.Flex,{direction:"column",align:"center",gap:"2",children:d?e.jsxs(e.Fragment,{children:[e.jsx(F.ExclamationTriangleIcon,{className:"w-8 h-8 text-red-500"}),e.jsx(r.Text,{size:"2",color:"red",weight:"medium",children:d}),e.jsx(r.Text,{size:"1",color:"gray",children:"Click to try again"})]}):e.jsxs(e.Fragment,{children:[e.jsx(F.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(y/(1024*1024)),"MB"]})]})})]})]})},K=C.withJsonFormsControlProps(ce),Q=a.rankWith(3,a.formatIs("data-url")),X=({uischema:s,visible:u})=>{const t=s;return u===!1?null:e.jsx(r.Box,{mb:"4",children:e.jsx(r.Heading,{size:"4",children:t.text})})},Y=a.rankWith(1,a.uiTypeIs("Label")),de=[{tester:R,renderer:ne},{tester:$,renderer:se},{tester:I,renderer:le},{tester:V,renderer:ie},{tester:q,renderer:ae},{tester:E,renderer:J},{tester:A,renderer:H},{tester:O,renderer:M},{tester:U,renderer:G},{tester:Q,renderer:K},{tester:Y,renderer:X}];exports.BooleanControl=B;exports.BooleanControlTester=I;exports.CategorizationLayoutRenderer=G;exports.CategorizationLayoutTester=U;exports.DateControl=P;exports.DateControlTester=q;exports.FileControl=K;exports.FileControlTester=Q;exports.GroupLayoutRenderer=M;exports.GroupLayoutTester=O;exports.HorizontalLayoutRenderer=H;exports.HorizontalLayoutTester=A;exports.LabelRenderer=X;exports.LabelTester=Y;exports.NumberControl=S;exports.NumberControlTester=$;exports.SelectControl=W;exports.SelectControlTester=V;exports.TextControl=N;exports.TextControlTester=R;exports.VerticalLayoutRenderer=J;exports.VerticalLayoutTester=E;exports.radixRenderers=de;
3
+ ${i?"border-blue-500 bg-blue-50":"border-gray-300 hover:border-blue-400 hover:bg-gray-50"}
4
+ ${a?"border-red-300 bg-red-50":""}
5
+ ${b?"cursor-pointer":"opacity-60 cursor-not-allowed pointer-events-none"}
6
+ `,onDragEnter:R,onDragLeave:R,onDragOver:R,onDrop:re,onClick:()=>{var n;return b&&((n=d.current)==null?void 0:n.click())},onKeyDown:ne,role:"button",tabIndex:b?0:-1,children:[e.jsx("input",{ref:d,type:"file",className:"hidden",accept:y,onChange:te,disabled:!b}),e.jsx(r.Flex,{direction:"column",align:"center",gap:"2",children:a?e.jsxs(e.Fragment,{children:[e.jsx(v.ExclamationTriangleIcon,{className:"w-8 h-8 text-red-500"}),e.jsx(r.Text,{size:"2",color:"red",weight:"medium",children:a}),e.jsx(r.Text,{size:"1",color:"gray",children:"Click to try again"})]}):e.jsxs(e.Fragment,{children:[e.jsx(v.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(f/(1024*1024)),"MB"]})]})})]})]})},_=T.withJsonFormsControlProps(ue),Q=s.rankWith(3,s.formatIs("data-url")),xe=({data:l,path:u,schema:t,uischema:p,enabled:h,visible:o,addItem:c,removeItems:i,rootSchema:x})=>{const a=t.items;if(o===!1||!a||typeof a!="object"||Array.isArray(a))return null;const g=a,j=Array.isArray(l)?l:[],m=t.title||"Array Items",d=()=>{const f=s.createDefaultValue(g,x);c&&c(u,f)},F=f=>{if(i){const y=i(u,[f]);y&&y()}};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:m}),j.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."})}),j.map((f,y)=>{var k;const b=`${u}.${y}`;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 ",y+1]}),h&&e.jsxs(r.Button,{color:"red",variant:"soft",onClick:()=>F(y),title:"Remove item",children:[e.jsx(v.TrashIcon,{}),"Remove"]})]}),e.jsx(r.Box,{children:e.jsx(T.JsonFormsDispatch,{schema:g,uischema:((k=p.options)==null?void 0:k.detail)||{type:"VerticalLayout",elements:Object.keys(g.properties||{}).map(w=>({type:"Control",scope:`#/properties/${w}`}))},path:b,enabled:h,renderers:void 0,cells:void 0})})]})},b)}),h&&e.jsx(r.Box,{mt:"2",children:e.jsxs(r.Button,{variant:"surface",onClick:d,children:[e.jsx(v.PlusIcon,{}),"Add Item"]})})]})})},X=T.withJsonFormsArrayControlProps(xe),Y=s.rankWith(2,s.and(s.uiTypeIs("Control"),s.schemaTypeIs("array"))),Z=({uischema:l,visible:u})=>{const t=l;return u===!1?null:e.jsx(r.Box,{mb:"4",children:e.jsx(r.Heading,{size:"4",children:t.text})})},ee=s.rankWith(1,s.uiTypeIs("Label")),he=[{tester:D,renderer:le},{tester:N,renderer:ie},{tester:A,renderer:ae},{tester:P,renderer:ce},{tester:J,renderer:de},{tester:E,renderer:q},{tester:O,renderer:H},{tester:G,renderer:M},{tester:K,renderer:U},{tester:Q,renderer:_},{tester:Y,renderer:X},{tester:ee,renderer:Z}];exports.ArrayControl=X;exports.ArrayControlTester=Y;exports.BooleanControl=S;exports.BooleanControlTester=A;exports.CategorizationLayoutRenderer=U;exports.CategorizationLayoutTester=K;exports.DateControl=V;exports.DateControlTester=J;exports.FileControl=_;exports.FileControlTester=Q;exports.GroupLayoutRenderer=M;exports.GroupLayoutTester=G;exports.HorizontalLayoutRenderer=H;exports.HorizontalLayoutTester=O;exports.LabelRenderer=Z;exports.LabelTester=ee;exports.NumberControl=I;exports.NumberControlTester=N;exports.SelectControl=W;exports.SelectControlTester=P;exports.TextControl=B;exports.TextControlTester=D;exports.VerticalLayoutRenderer=q;exports.VerticalLayoutTester=E;exports.radixRenderers=he;
@@ -1,328 +1,328 @@
1
- import { jsx as e, jsxs as h, Fragment as A } from "react/jsx-runtime";
2
- import { rankWith as z, isStringControl as U, or as W, isNumberControl as j, isIntegerControl as J, isBooleanControl as Q, isEnumControl as X, isOneOfControl as Y, isDateControl as Z, uiTypeIs as N, formatIs as _ } from "@jsonforms/core";
3
- import { withJsonFormsControlProps as T, JsonFormsDispatch as S } from "@jsonforms/react";
4
- import { Box as v, Flex as C, Text as c, TextField as B, Checkbox as ee, Select as k, Tabs as L, Card as M, Heading as O, IconButton as re } from "@radix-ui/themes";
5
- import { useState as R, useRef as te } from "react";
6
- import { FileTextIcon as oe, CheckCircledIcon as ne, Cross2Icon as le, ExclamationTriangleIcon as ie, UploadIcon as ce } from "@radix-ui/react-icons";
7
- const se = ({ data: n, handleChange: d, path: r, label: p, required: m, errors: o, uischema: s, schema: l, enabled: u }) => {
1
+ import { jsx as e, jsxs as c, Fragment as O } from "react/jsx-runtime";
2
+ import { rankWith as T, isStringControl as K, or as j, isNumberControl as U, isIntegerControl as _, isBooleanControl as Q, isEnumControl as X, isOneOfControl as Y, isDateControl as Z, uiTypeIs as F, formatIs as ee, createDefaultValue as re, and as te, schemaTypeIs as oe } from "@jsonforms/core";
3
+ import { withJsonFormsControlProps as N, JsonFormsDispatch as k, withJsonFormsArrayControlProps as ne } from "@jsonforms/react";
4
+ import { Box as f, Flex as C, Text as s, TextField as P, Checkbox as le, Select as L, Tabs as A, Card as E, Heading as M, IconButton as ie, Button as W } from "@radix-ui/themes";
5
+ import { useState as S, useRef as ce } from "react";
6
+ import { FileTextIcon as se, CheckCircledIcon as ae, Cross2Icon as de, ExclamationTriangleIcon as ue, UploadIcon as he, TrashIcon as me, PlusIcon as pe } from "@radix-ui/react-icons";
7
+ const ge = ({ data: n, handleChange: u, path: r, label: g, required: m, errors: t, uischema: a, schema: l, enabled: h }) => {
8
8
  var b;
9
- const a = o.length === 0;
10
- return /* @__PURE__ */ e(v, { mb: "4", children: /* @__PURE__ */ h(C, { direction: "column", gap: "1", children: [
11
- /* @__PURE__ */ h(c, { as: "label", size: "2", weight: "bold", htmlFor: r, children: [
12
- p,
9
+ const i = t.length === 0;
10
+ return /* @__PURE__ */ e(f, { mb: "4", children: /* @__PURE__ */ c(C, { direction: "column", gap: "1", children: [
11
+ /* @__PURE__ */ c(s, { as: "label", size: "2", weight: "bold", htmlFor: r, children: [
12
+ g,
13
13
  " ",
14
- m && /* @__PURE__ */ e(c, { color: "red", children: "*" })
14
+ m && /* @__PURE__ */ e(s, { color: "red", children: "*" })
15
15
  ] }),
16
16
  /* @__PURE__ */ e(
17
- B.Root,
17
+ P.Root,
18
18
  {
19
19
  value: n || "",
20
- onChange: (f) => d(r, f.target.value),
21
- disabled: !u,
22
- placeholder: (b = s.options) == null ? void 0 : b.placeholder,
23
- color: a ? void 0 : "red",
20
+ onChange: (y) => u(r, y.target.value),
21
+ disabled: !h,
22
+ placeholder: (b = a.options) == null ? void 0 : b.placeholder,
23
+ color: i ? void 0 : "red",
24
24
  id: r
25
25
  }
26
26
  ),
27
- !a && o !== "is a required property" && /* @__PURE__ */ e(c, { color: "red", size: "1", children: o }),
28
- l.description && /* @__PURE__ */ e(c, { size: "1", color: "gray", children: l.description })
27
+ !i && t !== "is a required property" && /* @__PURE__ */ e(s, { color: "red", size: "1", children: t }),
28
+ l.description && /* @__PURE__ */ e(s, { size: "1", color: "gray", children: l.description })
29
29
  ] }) });
30
- }, ae = z(
30
+ }, be = T(
31
31
  1,
32
- U
33
- ), de = T(se), ue = ({ data: n, handleChange: d, path: r, label: p, required: m, errors: o, uischema: s, schema: l, enabled: u }) => {
34
- var f;
35
- const a = o.length === 0, b = (g) => {
36
- if (g === "") {
37
- d(r, void 0);
32
+ K
33
+ ), ye = N(ge), fe = ({ data: n, handleChange: u, path: r, label: g, required: m, errors: t, uischema: a, schema: l, enabled: h }) => {
34
+ var y;
35
+ const i = t.length === 0, b = (p) => {
36
+ if (p === "") {
37
+ u(r, void 0);
38
38
  return;
39
39
  }
40
- const i = Number(g);
41
- isNaN(i) || d(r, i);
40
+ const d = Number(p);
41
+ isNaN(d) || u(r, d);
42
42
  };
43
- return /* @__PURE__ */ e(v, { mb: "4", children: /* @__PURE__ */ h(C, { direction: "column", gap: "1", children: [
44
- /* @__PURE__ */ h(c, { as: "label", size: "2", weight: "bold", htmlFor: r, children: [
45
- p,
43
+ return /* @__PURE__ */ e(f, { mb: "4", children: /* @__PURE__ */ c(C, { direction: "column", gap: "1", children: [
44
+ /* @__PURE__ */ c(s, { as: "label", size: "2", weight: "bold", htmlFor: r, children: [
45
+ g,
46
46
  " ",
47
- m && /* @__PURE__ */ e(c, { color: "red", children: "*" })
47
+ m && /* @__PURE__ */ e(s, { color: "red", children: "*" })
48
48
  ] }),
49
49
  /* @__PURE__ */ e(
50
- B.Root,
50
+ P.Root,
51
51
  {
52
52
  type: "number",
53
53
  value: n ?? "",
54
- onChange: (g) => b(g.target.value),
55
- disabled: !u,
56
- placeholder: (f = s.options) == null ? void 0 : f.placeholder,
57
- color: a ? void 0 : "red",
54
+ onChange: (p) => b(p.target.value),
55
+ disabled: !h,
56
+ placeholder: (y = a.options) == null ? void 0 : y.placeholder,
57
+ color: i ? void 0 : "red",
58
58
  id: r
59
59
  }
60
60
  ),
61
- !a && o !== "is a required property" && /* @__PURE__ */ e(c, { color: "red", size: "1", children: o }),
62
- l.description && /* @__PURE__ */ e(c, { size: "1", color: "gray", children: l.description })
61
+ !i && t !== "is a required property" && /* @__PURE__ */ e(s, { color: "red", size: "1", children: t }),
62
+ l.description && /* @__PURE__ */ e(s, { size: "1", color: "gray", children: l.description })
63
63
  ] }) });
64
- }, he = z(
64
+ }, Ce = T(
65
65
  2,
66
- W(j, J)
67
- ), ge = T(ue), pe = ({ data: n, handleChange: d, path: r, label: p, required: m, errors: o, schema: s, enabled: l }) => {
68
- const u = o.length === 0;
69
- return /* @__PURE__ */ h(v, { mb: "4", children: [
70
- /* @__PURE__ */ h(C, { gap: "2", align: "center", children: [
66
+ j(U, _)
67
+ ), ve = N(fe), ze = ({ data: n, handleChange: u, path: r, label: g, required: m, errors: t, schema: a, enabled: l }) => {
68
+ const h = t.length === 0;
69
+ return /* @__PURE__ */ c(f, { mb: "4", children: [
70
+ /* @__PURE__ */ c(C, { gap: "2", align: "center", children: [
71
71
  /* @__PURE__ */ e(
72
- ee,
72
+ le,
73
73
  {
74
74
  checked: !!n,
75
- onCheckedChange: (a) => d(r, a === !0),
75
+ onCheckedChange: (i) => u(r, i === !0),
76
76
  disabled: !l,
77
77
  id: r
78
78
  }
79
79
  ),
80
- /* @__PURE__ */ h(c, { as: "label", size: "2", htmlFor: r, children: [
81
- p,
80
+ /* @__PURE__ */ c(s, { as: "label", size: "2", htmlFor: r, children: [
81
+ g,
82
82
  " ",
83
83
  m && "*"
84
84
  ] })
85
85
  ] }),
86
- !u && /* @__PURE__ */ e(c, { color: "red", size: "1", className: "block mt-1", children: o }),
87
- s.description && /* @__PURE__ */ e(c, { size: "1", color: "gray", className: "block mt-1", children: s.description })
86
+ !h && /* @__PURE__ */ e(s, { color: "red", size: "1", className: "block mt-1", children: t }),
87
+ a.description && /* @__PURE__ */ e(s, { size: "1", color: "gray", className: "block mt-1", children: a.description })
88
88
  ] });
89
- }, me = z(
89
+ }, Te = T(
90
90
  2,
91
91
  Q
92
- ), be = T(pe), fe = ({ data: n, handleChange: d, path: r, label: p, required: m, errors: o, schema: s, uischema: l, enabled: u }) => {
93
- var g;
94
- const a = o.length === 0;
92
+ ), xe = N(ze), we = ({ data: n, handleChange: u, path: r, label: g, required: m, errors: t, schema: a, uischema: l, enabled: h }) => {
93
+ var p;
94
+ const i = t.length === 0;
95
95
  let b = [];
96
- s.enum ? b = s.enum.map((i) => ({ value: String(i), label: String(i) })) : s.oneOf && (b = s.oneOf.map((i) => ({
97
- value: String(i.const),
98
- label: i.title || String(i.const)
96
+ a.enum ? b = a.enum.map((d) => ({ value: String(d), label: String(d) })) : a.oneOf && (b = a.oneOf.map((d) => ({
97
+ value: String(d.const),
98
+ label: d.title || String(d.const)
99
99
  })));
100
- const f = n !== void 0 ? String(n) : "";
101
- return /* @__PURE__ */ e(v, { mb: "4", children: /* @__PURE__ */ h(C, { direction: "column", gap: "1", children: [
102
- /* @__PURE__ */ h(c, { as: "label", size: "2", weight: "bold", htmlFor: r, children: [
103
- p,
100
+ const y = n !== void 0 ? String(n) : "";
101
+ return /* @__PURE__ */ e(f, { mb: "4", children: /* @__PURE__ */ c(C, { direction: "column", gap: "1", children: [
102
+ /* @__PURE__ */ c(s, { as: "label", size: "2", weight: "bold", htmlFor: r, children: [
103
+ g,
104
104
  " ",
105
- m && /* @__PURE__ */ e(c, { color: "red", children: "*" })
105
+ m && /* @__PURE__ */ e(s, { color: "red", children: "*" })
106
106
  ] }),
107
- /* @__PURE__ */ h(
108
- k.Root,
107
+ /* @__PURE__ */ c(
108
+ L.Root,
109
109
  {
110
- value: f,
111
- onValueChange: (i) => d(r, i),
112
- disabled: !u,
110
+ value: y,
111
+ onValueChange: (d) => u(r, d),
112
+ disabled: !h,
113
113
  children: [
114
114
  /* @__PURE__ */ e(
115
- k.Trigger,
115
+ L.Trigger,
116
116
  {
117
- placeholder: ((g = l.options) == null ? void 0 : g.placeholder) || "Select an option",
118
- color: a ? void 0 : "red",
117
+ placeholder: ((p = l.options) == null ? void 0 : p.placeholder) || "Select an option",
118
+ color: i ? void 0 : "red",
119
119
  id: r
120
120
  }
121
121
  ),
122
- /* @__PURE__ */ e(k.Content, { children: b.map((i) => /* @__PURE__ */ e(k.Item, { value: i.value, children: i.label }, i.value)) })
122
+ /* @__PURE__ */ e(L.Content, { children: b.map((d) => /* @__PURE__ */ e(L.Item, { value: d.value, children: d.label }, d.value)) })
123
123
  ]
124
124
  }
125
125
  ),
126
- !a && o !== "is a required property" && /* @__PURE__ */ e(c, { color: "red", size: "1", children: o }),
127
- s.description && /* @__PURE__ */ e(c, { size: "1", color: "gray", children: s.description })
126
+ !i && t !== "is a required property" && /* @__PURE__ */ e(s, { color: "red", size: "1", children: t }),
127
+ a.description && /* @__PURE__ */ e(s, { size: "1", color: "gray", children: a.description })
128
128
  ] }) });
129
- }, Ce = z(
129
+ }, $e = T(
130
130
  2,
131
- W(X, Y)
132
- ), ye = T(fe), ve = ({ data: n, handleChange: d, path: r, label: p, required: m, errors: o, schema: s, enabled: l }) => {
133
- const u = o.length === 0;
134
- return /* @__PURE__ */ e(v, { mb: "4", children: /* @__PURE__ */ h(C, { direction: "column", gap: "1", children: [
135
- /* @__PURE__ */ h(c, { as: "label", size: "2", weight: "bold", htmlFor: r, children: [
136
- p,
131
+ j(X, Y)
132
+ ), Fe = N(we), Ne = ({ data: n, handleChange: u, path: r, label: g, required: m, errors: t, schema: a, enabled: l }) => {
133
+ const h = t.length === 0;
134
+ return /* @__PURE__ */ e(f, { mb: "4", children: /* @__PURE__ */ c(C, { direction: "column", gap: "1", children: [
135
+ /* @__PURE__ */ c(s, { as: "label", size: "2", weight: "bold", htmlFor: r, children: [
136
+ g,
137
137
  " ",
138
- m && /* @__PURE__ */ e(c, { color: "red", children: "*" })
138
+ m && /* @__PURE__ */ e(s, { color: "red", children: "*" })
139
139
  ] }),
140
140
  /* @__PURE__ */ e(
141
- B.Root,
141
+ P.Root,
142
142
  {
143
143
  type: "date",
144
144
  value: n || "",
145
- onChange: (a) => d(r, a.target.value),
145
+ onChange: (i) => u(r, i.target.value),
146
146
  disabled: !l,
147
- color: u ? void 0 : "red",
147
+ color: h ? void 0 : "red",
148
148
  id: r
149
149
  }
150
150
  ),
151
- !u && o !== "is a required property" && /* @__PURE__ */ e(c, { color: "red", size: "1", children: o }),
152
- s.description && /* @__PURE__ */ e(c, { size: "1", color: "gray", children: s.description })
151
+ !h && t !== "is a required property" && /* @__PURE__ */ e(s, { color: "red", size: "1", children: t }),
152
+ a.description && /* @__PURE__ */ e(s, { size: "1", color: "gray", children: a.description })
153
153
  ] }) });
154
- }, ze = z(
154
+ }, ke = T(
155
155
  2,
156
156
  Z
157
- ), xe = T(ve), Te = ({ uischema: n, schema: d, path: r, renderers: p, cells: m, enabled: o }) => {
157
+ ), De = N(Ne), Ie = ({ uischema: n, schema: u, path: r, renderers: g, cells: m, enabled: t }) => {
158
158
  const l = n.elements;
159
- return /* @__PURE__ */ e(C, { direction: "column", gap: "4", children: l.map((u, a) => /* @__PURE__ */ e(
160
- S,
159
+ return /* @__PURE__ */ e(C, { direction: "column", gap: "4", children: l.map((h, i) => /* @__PURE__ */ e(
160
+ k,
161
161
  {
162
- uischema: u,
163
- schema: d,
162
+ uischema: h,
163
+ schema: u,
164
164
  path: r,
165
- renderers: p,
165
+ renderers: g,
166
166
  cells: m,
167
- enabled: o
167
+ enabled: t
168
168
  },
169
- `${r}-${a}`
169
+ `${r}-${i}`
170
170
  )) });
171
- }, we = z(1, N("VerticalLayout")), Fe = ({ uischema: n, schema: d, path: r, renderers: p, cells: m, enabled: o }) => {
171
+ }, Re = T(1, F("VerticalLayout")), Le = ({ uischema: n, schema: u, path: r, renderers: g, cells: m, enabled: t }) => {
172
172
  const l = n.elements;
173
- return /* @__PURE__ */ e(C, { direction: "row", gap: "4", children: l.map((u, a) => /* @__PURE__ */ e(v, { style: { flex: 1 }, children: /* @__PURE__ */ e(
174
- S,
173
+ return /* @__PURE__ */ e(C, { direction: "row", gap: "4", children: l.map((h, i) => /* @__PURE__ */ e(f, { style: { flex: 1 }, children: /* @__PURE__ */ e(
174
+ k,
175
175
  {
176
- uischema: u,
177
- schema: d,
176
+ uischema: h,
177
+ schema: u,
178
178
  path: r,
179
- renderers: p,
179
+ renderers: g,
180
180
  cells: m,
181
- enabled: o
181
+ enabled: t
182
182
  }
183
- ) }, `${r}-${a}`)) });
184
- }, Ne = z(1, N("HorizontalLayout")), $e = ({ uischema: n, schema: d, path: r, renderers: p, cells: m, enabled: o }) => {
185
- const s = n, l = s.elements;
186
- return /* @__PURE__ */ h(M, { mb: "4", children: [
187
- s.label && /* @__PURE__ */ e(O, { size: "4", mb: "4", children: s.label }),
188
- /* @__PURE__ */ e(C, { direction: "column", gap: "4", children: l.map((u, a) => /* @__PURE__ */ e(
189
- S,
183
+ ) }, `${r}-${i}`)) });
184
+ }, Ae = T(1, F("HorizontalLayout")), Se = ({ uischema: n, schema: u, path: r, renderers: g, cells: m, enabled: t }) => {
185
+ const a = n, l = a.elements;
186
+ return /* @__PURE__ */ c(E, { mb: "4", children: [
187
+ a.label && /* @__PURE__ */ e(M, { size: "4", mb: "4", children: a.label }),
188
+ /* @__PURE__ */ e(C, { direction: "column", gap: "4", children: l.map((h, i) => /* @__PURE__ */ e(
189
+ k,
190
190
  {
191
- uischema: u,
192
- schema: d,
191
+ uischema: h,
192
+ schema: u,
193
193
  path: r,
194
- renderers: p,
194
+ renderers: g,
195
195
  cells: m,
196
- enabled: o
196
+ enabled: t
197
197
  },
198
- `${r}-${a}`
198
+ `${r}-${i}`
199
199
  )) })
200
200
  ] });
201
- }, De = z(1, N("Group")), ke = ({ uischema: n, schema: d, path: r, renderers: p, cells: m, enabled: o }) => {
202
- var f;
203
- const l = n.elements.filter((g) => g.type === "Category"), [u, a] = R(((f = l[0]) == null ? void 0 : f.label) || "");
201
+ }, Ve = T(1, F("Group")), Be = ({ uischema: n, schema: u, path: r, renderers: g, cells: m, enabled: t }) => {
202
+ var y;
203
+ const l = n.elements.filter((p) => p.type === "Category"), [h, i] = S(((y = l[0]) == null ? void 0 : y.label) || "");
204
204
  if (!l.length) return null;
205
- const b = l.find((g) => g.label === u) ? u : l[0].label;
206
- return /* @__PURE__ */ h(L.Root, { value: b, onValueChange: a, children: [
207
- /* @__PURE__ */ e(L.List, { children: l.map((g, i) => /* @__PURE__ */ e(L.Trigger, { value: g.label, children: g.label }, `${r}-${i}`)) }),
208
- /* @__PURE__ */ e(v, { pt: "3", children: l.map((g, i) => /* @__PURE__ */ e(L.Content, { value: g.label, children: /* @__PURE__ */ e(C, { direction: "column", gap: "4", children: g.elements.map(($, w) => /* @__PURE__ */ e(
209
- S,
205
+ const b = l.find((p) => p.label === h) ? h : l[0].label;
206
+ return /* @__PURE__ */ c(A.Root, { value: b, onValueChange: i, children: [
207
+ /* @__PURE__ */ e(A.List, { children: l.map((p, d) => /* @__PURE__ */ e(A.Trigger, { value: p.label, children: p.label }, `${r}-${d}`)) }),
208
+ /* @__PURE__ */ e(f, { pt: "3", children: l.map((p, d) => /* @__PURE__ */ e(A.Content, { value: p.label, children: /* @__PURE__ */ e(C, { direction: "column", gap: "4", children: p.elements.map(($, w) => /* @__PURE__ */ e(
209
+ k,
210
210
  {
211
211
  uischema: $,
212
- schema: d,
212
+ schema: u,
213
213
  path: r,
214
- renderers: p,
214
+ renderers: g,
215
215
  cells: m,
216
- enabled: o
216
+ enabled: t
217
217
  },
218
- `${r}-${i}-${w}`
219
- )) }) }, `${r}-${i}`)) })
218
+ `${r}-${d}-${w}`
219
+ )) }) }, `${r}-${d}`)) })
220
220
  ] });
221
- }, Le = z(1, N("Categorization")), Re = ({ data: n, handleChange: d, path: r, label: p, required: m, uischema: o, enabled: s }) => {
222
- const [l, u] = R(!1), [a, b] = R(null), [f, g] = R(null), i = te(null), $ = (o == null ? void 0 : o.options) || {}, w = $.maxSize || 5 * 1024 * 1024, F = $.accept || "image/*,application/pdf", x = s !== !1, P = () => f || (n ? "Uploaded File" : null), E = (t) => {
223
- if (t.size > w) {
224
- const y = (w / 1048576).toFixed(0);
225
- b(`File size exceeds ${y}MB limit.`);
221
+ }, Pe = T(1, F("Categorization")), Ee = ({ data: n, handleChange: u, path: r, label: g, required: m, uischema: t, enabled: a }) => {
222
+ const [l, h] = S(!1), [i, b] = S(null), [y, p] = S(null), d = ce(null), $ = (t == null ? void 0 : t.options) || {}, w = $.maxSize || 5 * 1024 * 1024, z = $.accept || "image/*,application/pdf", v = a !== !1, D = () => y || (n ? "Uploaded File" : null), I = (o) => {
223
+ if (o.size > w) {
224
+ const x = (w / 1048576).toFixed(0);
225
+ b(`File size exceeds ${x}MB limit.`);
226
226
  return;
227
227
  }
228
- const K = F.split(",").map((y) => y.trim()).some((y) => y.endsWith("/*") ? t.type.startsWith(y.slice(0, -1)) : y.startsWith(".") ? t.name.toLowerCase().endsWith(y.toLowerCase()) : t.type === y);
229
- if (F !== "*" && !K && !F.includes("*/*")) {
230
- b(`Invalid file type. Accepted types: ${F}`);
228
+ const J = z.split(",").map((x) => x.trim()).some((x) => x.endsWith("/*") ? o.type.startsWith(x.slice(0, -1)) : x.startsWith(".") ? o.name.toLowerCase().endsWith(x.toLowerCase()) : o.type === x);
229
+ if (z !== "*" && !J && !z.includes("*/*")) {
230
+ b(`Invalid file type. Accepted types: ${z}`);
231
231
  return;
232
232
  }
233
- const D = new FileReader();
234
- D.onload = () => {
235
- const y = D.result;
236
- d(r, y), g(t.name), b(null);
237
- }, D.onerror = () => {
233
+ const R = new FileReader();
234
+ R.onload = () => {
235
+ const x = R.result;
236
+ u(r, x), p(o.name), b(null);
237
+ }, R.onerror = () => {
238
238
  b("Failed to read file");
239
- }, D.readAsDataURL(t);
240
- }, I = (t) => {
241
- t.preventDefault(), t.stopPropagation(), !(!x || n) && (t.type === "dragenter" || t.type === "dragover" ? u(!0) : t.type === "dragleave" && u(!1));
242
- }, q = (t) => {
243
- t.preventDefault(), t.stopPropagation(), u(!1), !(!x || n) && t.dataTransfer.files && t.dataTransfer.files[0] && E(t.dataTransfer.files[0]);
244
- }, H = (t) => {
245
- t.target.files && t.target.files[0] && E(t.target.files[0]);
239
+ }, R.readAsDataURL(o);
240
+ }, V = (o) => {
241
+ o.preventDefault(), o.stopPropagation(), !(!v || n) && (o.type === "dragenter" || o.type === "dragover" ? h(!0) : o.type === "dragleave" && h(!1));
242
+ }, q = (o) => {
243
+ o.preventDefault(), o.stopPropagation(), h(!1), !(!v || n) && o.dataTransfer.files && o.dataTransfer.files[0] && I(o.dataTransfer.files[0]);
244
+ }, H = (o) => {
245
+ o.target.files && o.target.files[0] && I(o.target.files[0]);
246
246
  }, G = () => {
247
- x && (d(r, null), g(null), b(null), i.current && (i.current.value = ""));
247
+ v && (u(r, null), p(null), b(null), d.current && (d.current.value = ""));
248
248
  };
249
- return /* @__PURE__ */ h(v, { mb: "4", children: [
250
- /* @__PURE__ */ h(c, { as: "label", size: "2", weight: "bold", mb: "1", className: "block", children: [
251
- p,
249
+ return /* @__PURE__ */ c(f, { mb: "4", children: [
250
+ /* @__PURE__ */ c(s, { as: "label", size: "2", weight: "bold", mb: "1", className: "block", children: [
251
+ g,
252
252
  " ",
253
253
  m && "*"
254
254
  ] }),
255
- n ? /* @__PURE__ */ e(M, { size: "2", variant: "surface", className: "relative group", children: /* @__PURE__ */ h(C, { align: "center", gap: "3", children: [
256
- /* @__PURE__ */ e(v, { className: "bg-blue-100 p-2 rounded text-blue-600", children: /* @__PURE__ */ e(oe, { width: "20", height: "20" }) }),
257
- /* @__PURE__ */ h(v, { style: { flex: 1, overflow: "hidden" }, children: [
258
- /* @__PURE__ */ e(c, { size: "2", weight: "bold", className: "block truncate", children: P() }),
259
- x ? /* @__PURE__ */ e(c, { size: "1", color: "gray", children: "Ready to submit" }) : /* @__PURE__ */ e(
255
+ n ? /* @__PURE__ */ e(E, { size: "2", variant: "surface", className: "relative group", children: /* @__PURE__ */ c(C, { align: "center", gap: "3", children: [
256
+ /* @__PURE__ */ e(f, { className: "bg-blue-100 p-2 rounded text-blue-600", children: /* @__PURE__ */ e(se, { width: "20", height: "20" }) }),
257
+ /* @__PURE__ */ c(f, { style: { flex: 1, overflow: "hidden" }, children: [
258
+ /* @__PURE__ */ e(s, { size: "2", weight: "bold", className: "block truncate", children: D() }),
259
+ v ? /* @__PURE__ */ e(s, { size: "1", color: "gray", children: "Ready to submit" }) : /* @__PURE__ */ e(
260
260
  "a",
261
261
  {
262
262
  href: n,
263
- download: f || "document",
263
+ download: y || "document",
264
264
  className: "text-xs text-blue-600 hover:underline cursor-pointer",
265
- onClick: (t) => t.stopPropagation(),
265
+ onClick: (o) => o.stopPropagation(),
266
266
  children: "Download"
267
267
  }
268
268
  )
269
269
  ] }),
270
- /* @__PURE__ */ h(C, { align: "center", gap: "2", children: [
271
- /* @__PURE__ */ e(ne, { className: "text-green-600 w-5 h-5" }),
272
- x && /* @__PURE__ */ e(
273
- re,
270
+ /* @__PURE__ */ c(C, { align: "center", gap: "2", children: [
271
+ /* @__PURE__ */ e(ae, { className: "text-green-600 w-5 h-5" }),
272
+ v && /* @__PURE__ */ e(
273
+ ie,
274
274
  {
275
275
  variant: "ghost",
276
276
  color: "gray",
277
277
  onClick: G,
278
278
  className: "hover:text-red-600 transition-colors",
279
- children: /* @__PURE__ */ e(le, {})
279
+ children: /* @__PURE__ */ e(de, {})
280
280
  }
281
281
  )
282
282
  ] })
283
- ] }) }) : /* @__PURE__ */ h(
283
+ ] }) }) : /* @__PURE__ */ c(
284
284
  "div",
285
285
  {
286
286
  className: `
287
287
  border-2 border-dashed rounded-lg p-6 text-center transition-all duration-200 ease-in-out
288
288
  ${l ? "border-blue-500 bg-blue-50" : "border-gray-300 hover:border-blue-400 hover:bg-gray-50"}
289
- ${a ? "border-red-300 bg-red-50" : ""}
290
- ${x ? "cursor-pointer" : "opacity-60 cursor-not-allowed pointer-events-none"}
289
+ ${i ? "border-red-300 bg-red-50" : ""}
290
+ ${v ? "cursor-pointer" : "opacity-60 cursor-not-allowed pointer-events-none"}
291
291
  `,
292
- onDragEnter: I,
293
- onDragLeave: I,
294
- onDragOver: I,
292
+ onDragEnter: V,
293
+ onDragLeave: V,
294
+ onDragOver: V,
295
295
  onDrop: q,
296
296
  onClick: () => {
297
- var t;
298
- return x && ((t = i.current) == null ? void 0 : t.click());
297
+ var o;
298
+ return v && ((o = d.current) == null ? void 0 : o.click());
299
299
  },
300
- onKeyDown: (t) => {
301
- var V;
302
- x && (t.key === "Enter" || t.key === " ") && (t.preventDefault(), (V = i.current) == null || V.click());
300
+ onKeyDown: (o) => {
301
+ var B;
302
+ v && (o.key === "Enter" || o.key === " ") && (o.preventDefault(), (B = d.current) == null || B.click());
303
303
  },
304
304
  role: "button",
305
- tabIndex: x ? 0 : -1,
305
+ tabIndex: v ? 0 : -1,
306
306
  children: [
307
307
  /* @__PURE__ */ e(
308
308
  "input",
309
309
  {
310
- ref: i,
310
+ ref: d,
311
311
  type: "file",
312
312
  className: "hidden",
313
- accept: F,
313
+ accept: z,
314
314
  onChange: H,
315
- disabled: !x
315
+ disabled: !v
316
316
  }
317
317
  ),
318
- /* @__PURE__ */ e(C, { direction: "column", align: "center", gap: "2", children: a ? /* @__PURE__ */ h(A, { children: [
319
- /* @__PURE__ */ e(ie, { className: "w-8 h-8 text-red-500" }),
320
- /* @__PURE__ */ e(c, { size: "2", color: "red", weight: "medium", children: a }),
321
- /* @__PURE__ */ e(c, { size: "1", color: "gray", children: "Click to try again" })
322
- ] }) : /* @__PURE__ */ h(A, { children: [
323
- /* @__PURE__ */ e(ce, { className: "w-8 h-8 text-gray-400" }),
324
- /* @__PURE__ */ e(c, { size: "2", weight: "medium", children: "Click to upload or drag and drop" }),
325
- /* @__PURE__ */ h(c, { size: "1", color: "gray", children: [
318
+ /* @__PURE__ */ e(C, { direction: "column", align: "center", gap: "2", children: i ? /* @__PURE__ */ c(O, { children: [
319
+ /* @__PURE__ */ e(ue, { className: "w-8 h-8 text-red-500" }),
320
+ /* @__PURE__ */ e(s, { size: "2", color: "red", weight: "medium", children: i }),
321
+ /* @__PURE__ */ e(s, { size: "1", color: "gray", children: "Click to try again" })
322
+ ] }) : /* @__PURE__ */ c(O, { children: [
323
+ /* @__PURE__ */ e(he, { className: "w-8 h-8 text-gray-400" }),
324
+ /* @__PURE__ */ e(s, { size: "2", weight: "medium", children: "Click to upload or drag and drop" }),
325
+ /* @__PURE__ */ c(s, { size: "1", color: "gray", children: [
326
326
  "Max ",
327
327
  Math.round(w / (1024 * 1024)),
328
328
  "MB"
@@ -332,48 +332,136 @@ const se = ({ data: n, handleChange: d, path: r, label: p, required: m, errors:
332
332
  }
333
333
  )
334
334
  ] });
335
- }, Se = T(Re), Ie = z(
335
+ }, Oe = N(Ee), We = T(
336
336
  3,
337
337
  // Rank
338
- _("data-url")
339
- ), Ve = ({ uischema: n, visible: d }) => {
338
+ ee("data-url")
339
+ ), je = ({
340
+ data: n,
341
+ path: u,
342
+ schema: r,
343
+ uischema: g,
344
+ enabled: m,
345
+ visible: t,
346
+ addItem: a,
347
+ removeItems: l,
348
+ rootSchema: h
349
+ }) => {
350
+ const i = r.items;
351
+ if (t === !1 || !i || typeof i != "object" || Array.isArray(i))
352
+ return null;
353
+ const b = i, y = Array.isArray(n) ? n : [], p = r.title || "Array Items", d = () => {
354
+ const w = re(b, h);
355
+ a && a(u, w);
356
+ }, $ = (w) => {
357
+ if (l) {
358
+ const z = l(u, [w]);
359
+ z && z();
360
+ }
361
+ };
362
+ return /* @__PURE__ */ e(f, { mb: "6", children: /* @__PURE__ */ c(C, { direction: "column", gap: "4", children: [
363
+ /* @__PURE__ */ e(s, { as: "div", size: "4", weight: "bold", children: p }),
364
+ y.length === 0 && /* @__PURE__ */ e(f, { py: "4", px: "4", style: { backgroundColor: "var(--gray-3)", borderRadius: "var(--radius-3)" }, children: /* @__PURE__ */ e(s, { size: "2", color: "gray", children: "No items have been added yet." }) }),
365
+ y.map((w, z) => {
366
+ var D;
367
+ const v = `${u}.${z}`;
368
+ return /* @__PURE__ */ e(E, { size: "3", variant: "surface", children: /* @__PURE__ */ c(C, { direction: "column", gap: "4", children: [
369
+ /* @__PURE__ */ c(C, { justify: "between", align: "center", children: [
370
+ /* @__PURE__ */ c(s, { size: "3", weight: "bold", children: [
371
+ "Item ",
372
+ z + 1
373
+ ] }),
374
+ m && /* @__PURE__ */ c(
375
+ W,
376
+ {
377
+ color: "red",
378
+ variant: "soft",
379
+ onClick: () => $(z),
380
+ title: "Remove item",
381
+ children: [
382
+ /* @__PURE__ */ e(me, {}),
383
+ "Remove"
384
+ ]
385
+ }
386
+ )
387
+ ] }),
388
+ /* @__PURE__ */ e(f, { children: /* @__PURE__ */ e(
389
+ k,
390
+ {
391
+ schema: b,
392
+ uischema: ((D = g.options) == null ? void 0 : D.detail) || {
393
+ type: "VerticalLayout",
394
+ elements: Object.keys(
395
+ b.properties || {}
396
+ ).map((I) => ({
397
+ type: "Control",
398
+ scope: `#/properties/${I}`
399
+ }))
400
+ },
401
+ path: v,
402
+ enabled: m,
403
+ renderers: void 0,
404
+ cells: void 0
405
+ }
406
+ ) })
407
+ ] }) }, v);
408
+ }),
409
+ m && /* @__PURE__ */ e(f, { mt: "2", children: /* @__PURE__ */ c(
410
+ W,
411
+ {
412
+ variant: "surface",
413
+ onClick: d,
414
+ children: [
415
+ /* @__PURE__ */ e(pe, {}),
416
+ "Add Item"
417
+ ]
418
+ }
419
+ ) })
420
+ ] }) });
421
+ }, Me = ne(je), qe = T(
422
+ 2,
423
+ te(F("Control"), oe("array"))
424
+ ), He = ({ uischema: n, visible: u }) => {
340
425
  const r = n;
341
- return d === !1 ? null : /* @__PURE__ */ e(v, { mb: "4", children: /* @__PURE__ */ e(O, { size: "4", children: r.text }) });
342
- }, Be = z(1, N("Label")), He = [
343
- { tester: ae, renderer: de },
344
- { tester: he, renderer: ge },
345
- { tester: me, renderer: be },
346
- { tester: Ce, renderer: ye },
347
- { tester: ze, renderer: xe },
348
- { tester: we, renderer: Te },
349
- { tester: Ne, renderer: Fe },
350
- { tester: De, renderer: $e },
351
- { tester: Le, renderer: ke },
352
- { tester: Ie, renderer: Se },
353
- { tester: Be, renderer: Ve }
426
+ return u === !1 ? null : /* @__PURE__ */ e(f, { mb: "4", children: /* @__PURE__ */ e(M, { size: "4", children: r.text }) });
427
+ }, Ge = T(1, F("Label")), Ze = [
428
+ { tester: be, renderer: ye },
429
+ { tester: Ce, renderer: ve },
430
+ { tester: Te, renderer: xe },
431
+ { tester: $e, renderer: Fe },
432
+ { tester: ke, renderer: De },
433
+ { tester: Re, renderer: Ie },
434
+ { tester: Ae, renderer: Le },
435
+ { tester: Ve, renderer: Se },
436
+ { tester: Pe, renderer: Be },
437
+ { tester: We, renderer: Oe },
438
+ { tester: qe, renderer: Me },
439
+ { tester: Ge, renderer: He }
354
440
  ];
355
441
  export {
356
- pe as BooleanControl,
357
- me as BooleanControlTester,
358
- ke as CategorizationLayoutRenderer,
359
- Le as CategorizationLayoutTester,
360
- ve as DateControl,
361
- ze as DateControlTester,
362
- Se as FileControl,
363
- Ie as FileControlTester,
364
- $e as GroupLayoutRenderer,
365
- De as GroupLayoutTester,
366
- Fe as HorizontalLayoutRenderer,
367
- Ne as HorizontalLayoutTester,
368
- Ve as LabelRenderer,
369
- Be as LabelTester,
370
- ue as NumberControl,
371
- he as NumberControlTester,
372
- fe as SelectControl,
373
- Ce as SelectControlTester,
374
- se as TextControl,
375
- ae as TextControlTester,
376
- Te as VerticalLayoutRenderer,
377
- we as VerticalLayoutTester,
378
- He as radixRenderers
442
+ Me as ArrayControl,
443
+ qe as ArrayControlTester,
444
+ ze as BooleanControl,
445
+ Te as BooleanControlTester,
446
+ Be as CategorizationLayoutRenderer,
447
+ Pe as CategorizationLayoutTester,
448
+ Ne as DateControl,
449
+ ke as DateControlTester,
450
+ Oe as FileControl,
451
+ We as FileControlTester,
452
+ Se as GroupLayoutRenderer,
453
+ Ve as GroupLayoutTester,
454
+ Le as HorizontalLayoutRenderer,
455
+ Ae as HorizontalLayoutTester,
456
+ He as LabelRenderer,
457
+ Ge as LabelTester,
458
+ fe as NumberControl,
459
+ Ce as NumberControlTester,
460
+ we as SelectControl,
461
+ $e as SelectControlTester,
462
+ ge as TextControl,
463
+ be as TextControlTester,
464
+ Ie as VerticalLayoutRenderer,
465
+ Re as VerticalLayoutTester,
466
+ Ze as radixRenderers
379
467
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opennsw/jsonforms-renderers",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "type": "module",
5
5
  "main": "dist/renderers.cjs.js",
6
6
  "module": "dist/renderers.es.js",