@opennsw/jsonforms-renderers 0.0.1 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -5,9 +5,14 @@ import { JSX } from 'react/jsx-runtime';
5
5
  import { LayoutProps } from '@jsonforms/core';
6
6
  import { OwnPropsOfControl } from '@jsonforms/core';
7
7
  import { RankedTester } from '@jsonforms/core';
8
+ import { ReactNode } from 'react';
8
9
  import { TesterContext } from '@jsonforms/core';
9
10
  import { UISchemaElement } from '@jsonforms/core';
10
11
 
12
+ export declare const ArrayControl: ComponentType<OwnPropsOfControl>;
13
+
14
+ export declare const ArrayControlTester: (uischema: UISchemaElement, schema: JsonSchema, context: TesterContext) => number;
15
+
11
16
  export declare const BooleanControl: ({ data, handleChange, path, label, required, errors, schema, enabled }: ControlProps) => JSX.Element;
12
17
 
13
18
  export declare const BooleanControlTester: RankedTester;
@@ -28,6 +33,8 @@ export declare const FileControl: ComponentType<OwnPropsOfControl>;
28
33
 
29
34
  export declare const FileControlTester: (uischema: UISchemaElement, schema: JsonSchema, context: TesterContext) => number;
30
35
 
36
+ export declare type GetDownloadUrl = (key: string) => Promise<string>;
37
+
31
38
  export declare const GroupLayoutRenderer: ({ uischema, schema, path, renderers, cells, enabled }: LayoutProps) => JSX.Element;
32
39
 
33
40
  export declare const GroupLayoutTester: RankedTester;
@@ -60,6 +67,31 @@ export declare const TextControl: ({ data, handleChange, path, label, required,
60
67
 
61
68
  export declare const TextControlTester: RankedTester;
62
69
 
70
+ export declare interface UploadContextValue {
71
+ onUpload?: UploadHandler;
72
+ getDownloadUrl?: GetDownloadUrl;
73
+ }
74
+
75
+ export declare type UploadHandler = (file: File) => Promise<UploadResponse>;
76
+
77
+ export declare function UploadProvider({ children, onUpload, getDownloadUrl, }: {
78
+ children: ReactNode;
79
+ onUpload?: UploadHandler;
80
+ getDownloadUrl?: GetDownloadUrl;
81
+ }): JSX.Element;
82
+
83
+ /**
84
+ * Contract for upload: applications provide the implementation; the renderer
85
+ * only calls these callbacks. Keeps the package backend-agnostic (IoC) so e.g.
86
+ * OGA can move to a separate repo with its own backend/endpoints.
87
+ */
88
+ export declare interface UploadResponse {
89
+ key: string;
90
+ name?: string;
91
+ }
92
+
93
+ export declare function useUpload(): UploadContextValue | null;
94
+
63
95
  export declare const VerticalLayoutRenderer: ({ uischema, schema, path, renderers, cells, enabled }: LayoutProps) => JSX.Element;
64
96
 
65
97
  export declare const VerticalLayoutTester: RankedTester;
@@ -1 +1 @@
1
- /*! tailwindcss v4.1.18 | MIT License | https://tailwindcss.com */@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-border-style:solid;--tw-duration:initial;--tw-ease:initial}}}@layer theme{:root,:host{--font-sans:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--color-red-50:oklch(97.1% .013 17.38);--color-red-300:oklch(80.8% .114 19.571);--color-red-500:oklch(63.7% .237 25.331);--color-red-600:oklch(57.7% .245 27.325);--color-green-600:oklch(62.7% .194 149.214);--color-blue-50:oklch(97% .014 254.604);--color-blue-100:oklch(93.2% .032 255.585);--color-blue-400:oklch(70.7% .165 254.624);--color-blue-500:oklch(62.3% .214 259.815);--color-blue-600:oklch(54.6% .245 262.881);--color-gray-50:oklch(98.5% .002 247.839);--color-gray-300:oklch(87.2% .01 258.338);--color-gray-400:oklch(70.7% .022 261.325);--spacing:.25rem;--text-xs:.75rem;--text-xs--line-height:calc(1/.75);--radius-lg:.5rem;--ease-in-out:cubic-bezier(.4,0,.2,1);--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4,0,.2,1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;-moz-tab-size:4;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){-webkit-appearance:button;-moz-appearance:button;appearance:button}::file-selector-button{-webkit-appearance:button;-moz-appearance:button;appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.pointer-events-none{pointer-events:none}.visible{visibility:visible}.relative{position:relative}.mt-1{margin-top:calc(var(--spacing)*1)}.block{display:block}.flex{display:flex}.hidden{display:none}.h-5{height:calc(var(--spacing)*5)}.h-8{height:calc(var(--spacing)*8)}.w-5{width:calc(var(--spacing)*5)}.w-8{width:calc(var(--spacing)*8)}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.rounded{border-radius:.25rem}.rounded-lg{border-radius:var(--radius-lg)}.border-2{border-style:var(--tw-border-style);border-width:2px}.border-dashed{--tw-border-style:dashed;border-style:dashed}.border-blue-500{border-color:var(--color-blue-500)}.border-gray-300{border-color:var(--color-gray-300)}.border-red-300{border-color:var(--color-red-300)}.bg-blue-50{background-color:var(--color-blue-50)}.bg-blue-100{background-color:var(--color-blue-100)}.bg-red-50{background-color:var(--color-red-50)}.p-2{padding:calc(var(--spacing)*2)}.p-6{padding:calc(var(--spacing)*6)}.text-center{text-align:center}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-blue-600{color:var(--color-blue-600)}.text-gray-400{color:var(--color-gray-400)}.text-green-600{color:var(--color-green-600)}.text-red-500{color:var(--color-red-500)}.opacity-60{opacity:.6}.transition-all{transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.duration-200{--tw-duration:.2s;transition-duration:.2s}.ease-in-out{--tw-ease:var(--ease-in-out);transition-timing-function:var(--ease-in-out)}@media(hover:hover){.hover\:border-blue-400:hover{border-color:var(--color-blue-400)}.hover\:bg-gray-50:hover{background-color:var(--color-gray-50)}.hover\:text-red-600:hover{color:var(--color-red-600)}.hover\:underline:hover{text-decoration-line:underline}}}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-duration{syntax:"*";inherits:false}@property --tw-ease{syntax:"*";inherits:false}
1
+ /*! tailwindcss v4.1.18 | MIT License | https://tailwindcss.com */@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-border-style:solid;--tw-duration:initial;--tw-ease:initial}}}@layer theme{:root,:host{--font-sans:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--color-red-50:oklch(97.1% .013 17.38);--color-red-300:oklch(80.8% .114 19.571);--color-red-500:oklch(63.7% .237 25.331);--color-red-600:oklch(57.7% .245 27.325);--color-green-600:oklch(62.7% .194 149.214);--color-blue-50:oklch(97% .014 254.604);--color-blue-100:oklch(93.2% .032 255.585);--color-blue-400:oklch(70.7% .165 254.624);--color-blue-500:oklch(62.3% .214 259.815);--color-blue-600:oklch(54.6% .245 262.881);--color-gray-50:oklch(98.5% .002 247.839);--color-gray-300:oklch(87.2% .01 258.338);--color-gray-400:oklch(70.7% .022 261.325);--spacing:.25rem;--radius-lg:.5rem;--ease-in-out:cubic-bezier(.4,0,.2,1);--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4,0,.2,1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;-moz-tab-size:4;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){-webkit-appearance:button;-moz-appearance:button;appearance:button}::file-selector-button{-webkit-appearance:button;-moz-appearance:button;appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.pointer-events-none{pointer-events:none}.visible{visibility:visible}.relative{position:relative}.mt-1{margin-top:calc(var(--spacing)*1)}.block{display:block}.flex{display:flex}.hidden{display:none}.h-5{height:calc(var(--spacing)*5)}.h-8{height:calc(var(--spacing)*8)}.w-5{width:calc(var(--spacing)*5)}.w-8{width:calc(var(--spacing)*8)}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.rounded{border-radius:.25rem}.rounded-lg{border-radius:var(--radius-lg)}.border-2{border-style:var(--tw-border-style);border-width:2px}.border-dashed{--tw-border-style:dashed;border-style:dashed}.border-blue-500{border-color:var(--color-blue-500)}.border-gray-300{border-color:var(--color-gray-300)}.border-red-300{border-color:var(--color-red-300)}.bg-blue-50{background-color:var(--color-blue-50)}.bg-blue-100{background-color:var(--color-blue-100)}.bg-red-50{background-color:var(--color-red-50)}.p-2{padding:calc(var(--spacing)*2)}.p-6{padding:calc(var(--spacing)*6)}.text-center{text-align:center}.text-blue-600{color:var(--color-blue-600)}.text-gray-400{color:var(--color-gray-400)}.text-green-600{color:var(--color-green-600)}.text-red-500{color:var(--color-red-500)}.opacity-60{opacity:.6}.transition-all{transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.duration-200{--tw-duration:.2s;transition-duration:.2s}.ease-in-out{--tw-ease:var(--ease-in-out);transition-timing-function:var(--ease-in-out)}@media(hover:hover){.hover\:border-blue-400:hover{border-color:var(--color-blue-400)}.hover\:bg-gray-50:hover{background-color:var(--color-gray-50)}.hover\:text-red-600:hover{color:var(--color-red-600)}}}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-duration{syntax:"*";inherits:false}@property --tw-ease{syntax:"*";inherits:false}
@@ -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"),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:`
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":""}
3
+ ${m?"border-blue-500 bg-blue-50":"border-gray-300 hover:border-blue-400 hover:bg-gray-50"}
4
+ ${b?"border-red-300 bg-red-50":""}
5
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;
6
+ `,onDragEnter:P,onDragLeave:P,onDragOver:P,onDrop:Te,onClick:()=>{var n;return T&&((n=F.current)==null?void 0:n.click())},onKeyDown:we,role:"button",tabIndex:T?0:-1,children:[e.jsx("input",{ref:F,type:"file",style:{display:"none"},accept:S,onChange:ve,disabled:!T}),e.jsx(r.Flex,{direction:"column",align:"center",gap:"2",children:b?e.jsxs(e.Fragment,{children:[e.jsx(L.ExclamationTriangleIcon,{className:"w-8 h-8 text-red-500"}),e.jsx(r.Text,{size:"2",color:"red",weight:"medium",children:b}),e.jsx(r.Text,{size:"1",color:"gray",children:"Click to try again"})]}):e.jsxs(e.Fragment,{children:[e.jsx(L.UploadIcon,{className:"w-8 h-8 text-gray-400"}),e.jsx(r.Text,{size:"2",weight:"medium",children:"Click to upload or drag and drop"}),e.jsxs(r.Text,{size:"1",color:"gray",children:["Max ",Math.round(U/(1024*1024)),"MB"]})]})})]})]})},me=C.withJsonFormsControlProps(Ie),be=i.rankWith(3,i.or(i.formatIs("data-url"),i.formatIs("file"))),Ne=({data:o,path:l,schema:t,uischema:u,enabled:p,visible:c,addItem:a,removeItems:s,rootSchema:m,arraySchema:d})=>{const b=d?t:t.items,g=d||t;if(c===!1||!b||typeof b!="object"||Array.isArray(b))return null;const x=b,h=Array.isArray(o)?o:[],B=g.title||"Array Items",w=()=>{const z=i.createDefaultValue(x,m);a&&a(l,z)()},I=z=>{if(s){const v=s(l,[z]);v&&v()}};return e.jsx(r.Box,{mb:"6",children:e.jsxs(r.Flex,{direction:"column",gap:"4",children:[e.jsx(r.Text,{as:"div",size:"4",weight:"bold",children:B}),h.length===0&&e.jsx(r.Box,{py:"4",px:"4",style:{backgroundColor:"var(--gray-3)",borderRadius:"var(--radius-3)"},children:e.jsx(r.Text,{size:"2",color:"gray",children:"No items have been added yet."})}),h.map((z,v)=>{var F;const k=`${l}.${v}`;return e.jsx(r.Card,{size:"3",variant:"surface",children:e.jsxs(r.Flex,{direction:"column",gap:"4",children:[e.jsxs(r.Flex,{justify:"between",align:"center",children:[e.jsxs(r.Text,{size:"3",weight:"bold",children:["Item ",v+1]}),p&&e.jsxs(r.Button,{type:"button",color:"red",variant:"soft",onClick:()=>I(v),title:"Remove item",children:[e.jsx(L.TrashIcon,{}),"Remove"]})]}),e.jsx(r.Box,{children:e.jsx(C.JsonFormsDispatch,{schema:x,uischema:((F=u.options)==null?void 0:F.detail)||(x.type==="object"||x.properties?{type:"VerticalLayout",elements:Object.keys(x.properties||{}).map(R=>({type:"Control",scope:`#/properties/${R}`}))}:{type:"Control",scope:"#"}),path:k,enabled:p,renderers:void 0,cells:void 0})})]})},k)}),p&&e.jsx(r.Box,{mt:"2",children:e.jsxs(r.Button,{type:"button",variant:"surface",onClick:w,children:[e.jsx(L.PlusIcon,{}),"Add Item"]})})]})})},V=C.withJsonFormsArrayControlProps(Ne),ge=i.rankWith(3,i.isObjectArrayControl),je=({uischema:o,visible:l})=>{const t=o;return l===!1?null:e.jsx(r.Box,{mb:"4",children:e.jsx(r.Heading,{size:"4",children:t.text})})},ye=i.rankWith(1,i.uiTypeIs("Label")),Pe=i.rankWith(3,i.isPrimitiveArrayControl),We=[{tester:X,renderer:Le},{tester:Q,renderer:Ae},{tester:ee,renderer:Se},{tester:te,renderer:Be},{tester:ne,renderer:Re},{tester:le,renderer:se},{tester:ce,renderer:ie},{tester:de,renderer:ae},{tester:xe,renderer:ue},{tester:be,renderer:me},{tester:ge,renderer:V},{tester:Pe,renderer:V},{tester:ye,renderer:je}];exports.ArrayControl=V;exports.ArrayControlTester=ge;exports.BooleanControl=Y;exports.BooleanControlTester=ee;exports.CategorizationLayoutRenderer=ue;exports.CategorizationLayoutTester=xe;exports.DateControl=oe;exports.DateControlTester=ne;exports.FileControl=me;exports.FileControlTester=be;exports.GroupLayoutRenderer=ae;exports.GroupLayoutTester=de;exports.HorizontalLayoutRenderer=ie;exports.HorizontalLayoutTester=ce;exports.LabelRenderer=je;exports.LabelTester=ye;exports.NumberControl=Z;exports.NumberControlTester=Q;exports.SelectControl=re;exports.SelectControlTester=te;exports.TextControl=K;exports.TextControlTester=X;exports.UploadProvider=De;exports.VerticalLayoutRenderer=se;exports.VerticalLayoutTester=le;exports.radixRenderers=We;exports.useUpload=G;
@@ -1,330 +1,409 @@
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 }) => {
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,
1
+ import { jsx as e, jsxs as s, Fragment as te } from "react/jsx-runtime";
2
+ import { createContext as ye, useContext as Ce, useState as A, useRef as ve, useCallback as oe, useEffect as ne } from "react";
3
+ import { rankWith as z, isStringControl as we, or as J, isNumberControl as ze, isIntegerControl as Te, isBooleanControl as De, isEnumControl as xe, isOneOfControl as Ae, isDateControl as ke, uiTypeIs as S, formatIs as le, createDefaultValue as Fe, isObjectArrayControl as Le, isPrimitiveArrayControl as $e } from "@jsonforms/core";
4
+ import { withJsonFormsControlProps as N, JsonFormsDispatch as E, withJsonFormsArrayControlProps as Ue } from "@jsonforms/react";
5
+ import { Box as w, Flex as v, Text as c, TextField as K, Checkbox as Re, Select as j, Tabs as O, Card as X, Heading as ce, Button as G, IconButton as Ne } from "@radix-ui/themes";
6
+ import { FileTextIcon as Ie, CheckCircledIcon as Se, Cross2Icon as Ee, ExclamationTriangleIcon as Be, UploadIcon as Ve, TrashIcon as Pe, PlusIcon as je } from "@radix-ui/react-icons";
7
+ const se = ye(null);
8
+ function Fr({
9
+ children: t,
10
+ onUpload: l,
11
+ getDownloadUrl: r
12
+ }) {
13
+ const u = { onUpload: l, getDownloadUrl: r };
14
+ return /* @__PURE__ */ e(se.Provider, { value: u, children: t });
15
+ }
16
+ function Oe() {
17
+ return Ce(se);
18
+ }
19
+ const Me = ({ data: t, handleChange: l, path: r, label: u, required: m, errors: i, uischema: a, schema: n, enabled: b }) => {
20
+ var g;
21
+ const d = i.length === 0;
22
+ return /* @__PURE__ */ e(w, { mb: "4", children: /* @__PURE__ */ s(v, { direction: "column", gap: "1", children: [
23
+ /* @__PURE__ */ s(c, { as: "label", size: "2", weight: "bold", htmlFor: r, children: [
24
+ u,
13
25
  " ",
14
26
  m && /* @__PURE__ */ e(c, { color: "red", children: "*" })
15
27
  ] }),
16
28
  /* @__PURE__ */ e(
17
- B.Root,
29
+ K.Root,
18
30
  {
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",
31
+ value: t || "",
32
+ onChange: (f) => l(r, f.target.value),
33
+ disabled: !b,
34
+ placeholder: (g = a.options) == null ? void 0 : g.placeholder,
35
+ color: d ? void 0 : "red",
24
36
  id: r
25
37
  }
26
38
  ),
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 })
39
+ !d && i !== "is a required property" && /* @__PURE__ */ e(c, { color: "red", size: "1", children: i }),
40
+ n.description && /* @__PURE__ */ e(c, { size: "1", color: "gray", children: n.description })
29
41
  ] }) });
30
- }, ae = z(
42
+ }, He = z(
31
43
  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 }) => {
44
+ we
45
+ ), We = N(Me), _e = ({ data: t, handleChange: l, path: r, label: u, required: m, errors: i, uischema: a, schema: n, enabled: b }) => {
34
46
  var f;
35
- const a = o.length === 0, b = (g) => {
36
- if (g === "") {
37
- d(r, void 0);
47
+ const d = i.length === 0, g = (h) => {
48
+ if (h === "") {
49
+ l(r, void 0);
38
50
  return;
39
51
  }
40
- const i = Number(g);
41
- isNaN(i) || d(r, i);
52
+ const p = Number(h);
53
+ isNaN(p) || l(r, p);
42
54
  };
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,
55
+ return /* @__PURE__ */ e(w, { mb: "4", children: /* @__PURE__ */ s(v, { direction: "column", gap: "1", children: [
56
+ /* @__PURE__ */ s(c, { as: "label", size: "2", weight: "bold", htmlFor: r, children: [
57
+ u,
46
58
  " ",
47
59
  m && /* @__PURE__ */ e(c, { color: "red", children: "*" })
48
60
  ] }),
49
61
  /* @__PURE__ */ e(
50
- B.Root,
62
+ K.Root,
51
63
  {
52
64
  type: "number",
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",
65
+ value: t ?? "",
66
+ onChange: (h) => g(h.target.value),
67
+ disabled: !b,
68
+ placeholder: (f = a.options) == null ? void 0 : f.placeholder,
69
+ color: d ? void 0 : "red",
58
70
  id: r
59
71
  }
60
72
  ),
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 })
73
+ !d && i !== "is a required property" && /* @__PURE__ */ e(c, { color: "red", size: "1", children: i }),
74
+ n.description && /* @__PURE__ */ e(c, { size: "1", color: "gray", children: n.description })
63
75
  ] }) });
64
- }, he = z(
76
+ }, qe = z(
65
77
  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: [
78
+ J(ze, Te)
79
+ ), Ge = N(_e), Je = ({ data: t, handleChange: l, path: r, label: u, required: m, errors: i, schema: a, enabled: n }) => {
80
+ const b = i.length === 0;
81
+ return /* @__PURE__ */ s(w, { mb: "4", children: [
82
+ /* @__PURE__ */ s(v, { gap: "2", align: "center", children: [
71
83
  /* @__PURE__ */ e(
72
- ee,
84
+ Re,
73
85
  {
74
- checked: !!n,
75
- onCheckedChange: (a) => d(r, a === !0),
76
- disabled: !l,
86
+ checked: !!t,
87
+ onCheckedChange: (d) => l(r, d === !0),
88
+ disabled: !n,
77
89
  id: r
78
90
  }
79
91
  ),
80
- /* @__PURE__ */ h(c, { as: "label", size: "2", htmlFor: r, children: [
81
- p,
92
+ /* @__PURE__ */ s(c, { as: "label", size: "2", htmlFor: r, children: [
93
+ u,
82
94
  " ",
83
95
  m && "*"
84
96
  ] })
85
97
  ] }),
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 })
98
+ !b && /* @__PURE__ */ e(c, { color: "red", size: "1", className: "block mt-1", children: i }),
99
+ a.description && /* @__PURE__ */ e(c, { size: "1", color: "gray", className: "block mt-1", children: a.description })
88
100
  ] });
89
- }, me = z(
101
+ }, Ke = z(
90
102
  2,
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;
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)
103
+ De
104
+ ), Xe = N(Je), Ze = ({ data: t, handleChange: l, path: r, label: u, required: m, errors: i, schema: a, uischema: n, enabled: b }) => {
105
+ var h;
106
+ const d = i.length === 0;
107
+ let g = [];
108
+ a.enum ? g = a.enum.map((p) => ({ value: String(p), label: String(p) })) : a.oneOf && (g = a.oneOf.map((p) => ({
109
+ value: String(p.const),
110
+ label: p.title || String(p.const)
99
111
  })));
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,
112
+ const f = t !== void 0 ? String(t) : "";
113
+ return /* @__PURE__ */ e(w, { mb: "4", children: /* @__PURE__ */ s(v, { direction: "column", gap: "1", children: [
114
+ /* @__PURE__ */ s(c, { as: "label", size: "2", weight: "bold", htmlFor: r, children: [
115
+ u,
104
116
  " ",
105
117
  m && /* @__PURE__ */ e(c, { color: "red", children: "*" })
106
118
  ] }),
107
- /* @__PURE__ */ h(
108
- k.Root,
119
+ /* @__PURE__ */ s(
120
+ j.Root,
109
121
  {
110
122
  value: f,
111
- onValueChange: (i) => d(r, i),
112
- disabled: !u,
123
+ onValueChange: (p) => l(r, p),
124
+ disabled: !b,
113
125
  children: [
114
126
  /* @__PURE__ */ e(
115
- k.Trigger,
127
+ j.Trigger,
116
128
  {
117
- placeholder: ((g = l.options) == null ? void 0 : g.placeholder) || "Select an option",
118
- color: a ? void 0 : "red",
129
+ placeholder: ((h = n.options) == null ? void 0 : h.placeholder) || "Select an option",
130
+ color: d ? void 0 : "red",
119
131
  id: r
120
132
  }
121
133
  ),
122
- /* @__PURE__ */ e(k.Content, { children: b.map((i) => /* @__PURE__ */ e(k.Item, { value: i.value, children: i.label }, i.value)) })
134
+ /* @__PURE__ */ e(j.Content, { children: g.map((p) => /* @__PURE__ */ e(j.Item, { value: p.value, children: p.label }, p.value)) })
123
135
  ]
124
136
  }
125
137
  ),
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 })
138
+ !d && i !== "is a required property" && /* @__PURE__ */ e(c, { color: "red", size: "1", children: i }),
139
+ a.description && /* @__PURE__ */ e(c, { size: "1", color: "gray", children: a.description })
128
140
  ] }) });
129
- }, Ce = z(
141
+ }, Qe = z(
130
142
  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,
143
+ J(xe, Ae)
144
+ ), Ye = N(Ze), er = ({ data: t, handleChange: l, path: r, label: u, required: m, errors: i, schema: a, enabled: n }) => {
145
+ const b = i.length === 0;
146
+ return /* @__PURE__ */ e(w, { mb: "4", children: /* @__PURE__ */ s(v, { direction: "column", gap: "1", children: [
147
+ /* @__PURE__ */ s(c, { as: "label", size: "2", weight: "bold", htmlFor: r, children: [
148
+ u,
137
149
  " ",
138
150
  m && /* @__PURE__ */ e(c, { color: "red", children: "*" })
139
151
  ] }),
140
152
  /* @__PURE__ */ e(
141
- B.Root,
153
+ K.Root,
142
154
  {
143
155
  type: "date",
144
- value: n || "",
145
- onChange: (a) => d(r, a.target.value),
146
- disabled: !l,
147
- color: u ? void 0 : "red",
156
+ value: t || "",
157
+ onChange: (d) => l(r, d.target.value),
158
+ disabled: !n,
159
+ color: b ? void 0 : "red",
148
160
  id: r
149
161
  }
150
162
  ),
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 })
163
+ !b && i !== "is a required property" && /* @__PURE__ */ e(c, { color: "red", size: "1", children: i }),
164
+ a.description && /* @__PURE__ */ e(c, { size: "1", color: "gray", children: a.description })
153
165
  ] }) });
154
- }, ze = z(
166
+ }, rr = z(
155
167
  2,
156
- Z
157
- ), xe = T(ve), Te = ({ uischema: n, schema: d, path: r, renderers: p, cells: m, enabled: o }) => {
158
- const l = n.elements;
159
- return /* @__PURE__ */ e(C, { direction: "column", gap: "4", children: l.map((u, a) => /* @__PURE__ */ e(
160
- S,
168
+ ke
169
+ ), tr = N(er), or = ({ uischema: t, schema: l, path: r, renderers: u, cells: m, enabled: i }) => {
170
+ const n = t.elements;
171
+ return /* @__PURE__ */ e(v, { direction: "column", gap: "4", children: n.map((b, d) => /* @__PURE__ */ e(
172
+ E,
161
173
  {
162
- uischema: u,
163
- schema: d,
174
+ uischema: b,
175
+ schema: l,
164
176
  path: r,
165
- renderers: p,
177
+ renderers: u,
166
178
  cells: m,
167
- enabled: o
179
+ enabled: i
168
180
  },
169
- `${r}-${a}`
181
+ `${r}-${d}`
170
182
  )) });
171
- }, we = z(1, N("VerticalLayout")), Fe = ({ uischema: n, schema: d, path: r, renderers: p, cells: m, enabled: o }) => {
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,
183
+ }, nr = z(1, S("VerticalLayout")), lr = ({ uischema: t, schema: l, path: r, renderers: u, cells: m, enabled: i }) => {
184
+ const n = t.elements;
185
+ return /* @__PURE__ */ e(v, { direction: "row", gap: "4", children: n.map((b, d) => /* @__PURE__ */ e(w, { style: { flex: 1 }, children: /* @__PURE__ */ e(
186
+ E,
175
187
  {
176
- uischema: u,
177
- schema: d,
188
+ uischema: b,
189
+ schema: l,
178
190
  path: r,
179
- renderers: p,
191
+ renderers: u,
180
192
  cells: m,
181
- enabled: o
193
+ enabled: i
182
194
  }
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,
195
+ ) }, `${r}-${d}`)) });
196
+ }, ir = z(1, S("HorizontalLayout")), cr = ({ uischema: t, schema: l, path: r, renderers: u, cells: m, enabled: i }) => {
197
+ const a = t, n = a.elements;
198
+ return /* @__PURE__ */ s(X, { mb: "4", children: [
199
+ a.label && /* @__PURE__ */ e(ce, { size: "4", mb: "4", children: a.label }),
200
+ /* @__PURE__ */ e(v, { direction: "column", gap: "4", children: n.map((b, d) => /* @__PURE__ */ e(
201
+ E,
190
202
  {
191
- uischema: u,
192
- schema: d,
203
+ uischema: b,
204
+ schema: l,
193
205
  path: r,
194
- renderers: p,
206
+ renderers: u,
195
207
  cells: m,
196
- enabled: o
208
+ enabled: i
197
209
  },
198
- `${r}-${a}`
210
+ `${r}-${d}`
199
211
  )) })
200
212
  ] });
201
- }, De = z(1, N("Group")), ke = ({ uischema: n, schema: d, path: r, renderers: p, cells: m, enabled: o }) => {
213
+ }, sr = z(1, S("Group")), ar = ({ uischema: t, schema: l, path: r, renderers: u, cells: m, enabled: i }) => {
202
214
  var f;
203
- const l = n.elements.filter((g) => g.type === "Category"), [u, a] = R(((f = l[0]) == null ? void 0 : f.label) || "");
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,
215
+ const n = t.elements.filter((h) => h.type === "Category"), [b, d] = A(((f = n[0]) == null ? void 0 : f.label) || "");
216
+ if (!n.length) return null;
217
+ const g = n.find((h) => h.label === b) ? b : n[0].label;
218
+ return /* @__PURE__ */ s(O.Root, { value: g, onValueChange: d, children: [
219
+ /* @__PURE__ */ e(O.List, { children: n.map((h, p) => /* @__PURE__ */ e(O.Trigger, { value: h.label, children: h.label }, `${r}-${p}`)) }),
220
+ /* @__PURE__ */ e(w, { pt: "3", children: n.map((h, p) => /* @__PURE__ */ e(O.Content, { value: h.label, children: /* @__PURE__ */ e(v, { direction: "column", gap: "4", children: h.elements.map((I, k) => /* @__PURE__ */ e(
221
+ E,
210
222
  {
211
- uischema: $,
212
- schema: d,
223
+ uischema: I,
224
+ schema: l,
213
225
  path: r,
214
- renderers: p,
226
+ renderers: u,
215
227
  cells: m,
216
- enabled: o
228
+ enabled: i
217
229
  },
218
- `${r}-${i}-${w}`
219
- )) }) }, `${r}-${i}`)) })
230
+ `${r}-${p}-${k}`
231
+ )) }) }, `${r}-${p}`)) })
220
232
  ] });
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.`);
233
+ }, dr = z(1, S("Categorization")), ur = 50, ae = 60, U = /* @__PURE__ */ new Map();
234
+ function de() {
235
+ const t = Date.now() / 1e3;
236
+ for (const [l, r] of U.entries())
237
+ r.expiresAt <= t + ae && U.delete(l);
238
+ }
239
+ function hr(t, l, r) {
240
+ if (de(), U.size >= ur) {
241
+ const u = U.keys().next().value;
242
+ u != null && U.delete(u);
243
+ }
244
+ U.set(t, { url: l, expiresAt: r });
245
+ }
246
+ function q(t) {
247
+ return !t.startsWith("data:");
248
+ }
249
+ const pr = ({ data: t, handleChange: l, path: r, label: u, required: m, uischema: i, enabled: a }) => {
250
+ const n = Oe(), [b, d] = A(!1), [g, f] = A(null), [h, p] = A(null), [I, k] = A(null), [M, F] = A(!1), [D, L] = A(null), x = ve(null), B = (i == null ? void 0 : i.options) || {}, V = B.maxSize || 5 * 1024 * 1024, R = B.accept || "image/*,application/pdf", T = a !== !1, Z = oe(async (o, y) => {
251
+ de();
252
+ const $ = U.get(o);
253
+ if ($ && $.expiresAt > Date.now() / 1e3 + ae) {
254
+ k($.url);
255
+ return;
256
+ }
257
+ if (!(n != null && n.getDownloadUrl)) {
258
+ L("Download not configured for this application.");
226
259
  return;
227
260
  }
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}`);
261
+ F(!0), L(null);
262
+ try {
263
+ const C = await n.getDownloadUrl(o);
264
+ if (y != null && y.aborted) return;
265
+ k(C), hr(o, C, Math.floor(Date.now() / 1e3) + 900);
266
+ } catch {
267
+ if (y != null && y.aborted) return;
268
+ L("Unable to reach the server.");
269
+ } finally {
270
+ y != null && y.aborted || F(!1);
271
+ }
272
+ }, [n]);
273
+ ne(() => {
274
+ if (t && q(t)) {
275
+ const o = new AbortController();
276
+ return Z(t, o.signal), () => o.abort();
277
+ }
278
+ k(null), L(null);
279
+ }, [t, Z]);
280
+ const ue = () => h || (t ? "Uploaded File" : null), [he, H] = A(null);
281
+ ne(() => {
282
+ var o;
283
+ if (t && !q(t))
284
+ try {
285
+ const y = t.split(","), $ = ((o = y[0].match(/:(.*?);/)) == null ? void 0 : o[1]) || "application/octet-stream", C = y[1], _ = atob(C), ee = new Array(_.length);
286
+ for (let P = 0; P < _.length; P++)
287
+ ee[P] = _.charCodeAt(P);
288
+ const ge = new Uint8Array(ee), fe = new Blob([ge], { type: $ }), re = URL.createObjectURL(fe);
289
+ return H(re), () => URL.revokeObjectURL(re);
290
+ } catch (y) {
291
+ console.error("Failed to create blob URL:", y), H(null);
292
+ }
293
+ else
294
+ H(null);
295
+ }, [t]);
296
+ const Q = t && q(t) ? I : he, Y = oe(async (o) => {
297
+ if (o.size > V) {
298
+ const C = (V / 1048576).toFixed(0);
299
+ f(`File size exceeds ${C}MB limit.`);
231
300
  return;
232
301
  }
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 = () => {
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]);
246
- }, G = () => {
247
- x && (d(r, null), g(null), b(null), i.current && (i.current.value = ""));
302
+ const $ = R.split(",").map((C) => C.trim()).some((C) => C.endsWith("/*") ? o.type.startsWith(C.slice(0, -1)) : C.startsWith(".") ? o.name.toLowerCase().endsWith(C.toLowerCase()) : o.type === C);
303
+ if (R !== "*" && !$ && !R.includes("*/*")) {
304
+ f(`Invalid file type. Accepted types: ${R}`);
305
+ return;
306
+ }
307
+ if (n != null && n.onUpload) {
308
+ try {
309
+ const C = await n.onUpload(o);
310
+ l(r, C.key), p(C.name ?? o.name), f(null);
311
+ } catch {
312
+ f("Upload failed.");
313
+ }
314
+ return;
315
+ }
316
+ f("Upload service not configured for this application.");
317
+ }, [R, n, V, r, l]), W = (o) => {
318
+ o.preventDefault(), o.stopPropagation(), !(!T || t) && (o.type === "dragenter" || o.type === "dragover" ? d(!0) : o.type === "dragleave" && d(!1));
319
+ }, pe = (o) => {
320
+ o.preventDefault(), o.stopPropagation(), d(!1), !(!T || t) && o.dataTransfer.files && o.dataTransfer.files[0] && Y(o.dataTransfer.files[0]);
321
+ }, me = (o) => {
322
+ o.target.files && o.target.files[0] && Y(o.target.files[0]);
323
+ }, be = () => {
324
+ T && (l(r, null), p(null), f(null), x.current && (x.current.value = ""));
248
325
  };
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,
326
+ return /* @__PURE__ */ s(w, { mb: "4", children: [
327
+ /* @__PURE__ */ s(c, { as: "label", size: "2", weight: "bold", mb: "1", className: "block", children: [
328
+ u,
252
329
  " ",
253
330
  m && "*"
254
331
  ] }),
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(
332
+ t ? /* @__PURE__ */ e(X, { size: "2", variant: "surface", className: "relative group", children: /* @__PURE__ */ s(v, { align: "center", gap: "3", children: [
333
+ /* @__PURE__ */ e(w, { className: "bg-blue-100 p-2 rounded text-blue-600", children: /* @__PURE__ */ e(Ie, { width: "20", height: "20" }) }),
334
+ /* @__PURE__ */ e(w, { style: { flex: 1, overflow: "hidden" }, children: /* @__PURE__ */ e(c, { size: "2", weight: "bold", className: "block truncate", children: ue() }) }),
335
+ /* @__PURE__ */ s(v, { align: "center", gap: "3", children: [
336
+ M ? /* @__PURE__ */ e(c, { size: "1", color: "gray", children: "Loading..." }) : D ? /* @__PURE__ */ e(c, { size: "1", color: "red", children: "Error" }) : /* @__PURE__ */ e(G, { variant: "soft", color: "blue", size: "1", asChild: !0, children: /* @__PURE__ */ e(
260
337
  "a",
261
338
  {
262
- href: n,
263
- download: f || "document",
264
- className: "text-xs text-blue-600 hover:underline cursor-pointer",
265
- onClick: (t) => t.stopPropagation(),
266
- children: "Download"
339
+ href: Q || "#",
340
+ target: "_blank",
341
+ rel: "noopener noreferrer",
342
+ onClick: (o) => {
343
+ o.stopPropagation(), Q || o.preventDefault();
344
+ },
345
+ children: "View"
267
346
  }
268
- )
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,
274
- {
275
- variant: "ghost",
276
- color: "gray",
277
- onClick: G,
278
- className: "hover:text-red-600 transition-colors",
279
- children: /* @__PURE__ */ e(le, {})
280
- }
281
- )
347
+ ) }),
348
+ /* @__PURE__ */ s(v, { align: "center", gap: "2", children: [
349
+ /* @__PURE__ */ e(Se, { className: "text-green-600 w-5 h-5" }),
350
+ T && /* @__PURE__ */ e(
351
+ Ne,
352
+ {
353
+ variant: "ghost",
354
+ color: "gray",
355
+ onClick: be,
356
+ className: "hover:text-red-600 transition-colors",
357
+ children: /* @__PURE__ */ e(Ee, {})
358
+ }
359
+ )
360
+ ] })
282
361
  ] })
283
- ] }) }) : /* @__PURE__ */ h(
362
+ ] }) }) : /* @__PURE__ */ s(
284
363
  "div",
285
364
  {
286
365
  className: `
287
366
  border-2 border-dashed rounded-lg p-6 text-center transition-all duration-200 ease-in-out
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"}
367
+ ${b ? "border-blue-500 bg-blue-50" : "border-gray-300 hover:border-blue-400 hover:bg-gray-50"}
368
+ ${g ? "border-red-300 bg-red-50" : ""}
369
+ ${T ? "cursor-pointer" : "opacity-60 cursor-not-allowed pointer-events-none"}
291
370
  `,
292
- onDragEnter: I,
293
- onDragLeave: I,
294
- onDragOver: I,
295
- onDrop: q,
371
+ onDragEnter: W,
372
+ onDragLeave: W,
373
+ onDragOver: W,
374
+ onDrop: pe,
296
375
  onClick: () => {
297
- var t;
298
- return x && ((t = i.current) == null ? void 0 : t.click());
376
+ var o;
377
+ return T && ((o = x.current) == null ? void 0 : o.click());
299
378
  },
300
- onKeyDown: (t) => {
301
- var V;
302
- x && (t.key === "Enter" || t.key === " ") && (t.preventDefault(), (V = i.current) == null || V.click());
379
+ onKeyDown: (o) => {
380
+ var y;
381
+ T && (o.key === "Enter" || o.key === " ") && (o.preventDefault(), (y = x.current) == null || y.click());
303
382
  },
304
383
  role: "button",
305
- tabIndex: x ? 0 : -1,
384
+ tabIndex: T ? 0 : -1,
306
385
  children: [
307
386
  /* @__PURE__ */ e(
308
387
  "input",
309
388
  {
310
- ref: i,
389
+ ref: x,
311
390
  type: "file",
312
- className: "hidden",
313
- accept: F,
314
- onChange: H,
315
- disabled: !x
391
+ style: { display: "none" },
392
+ accept: R,
393
+ onChange: me,
394
+ disabled: !T
316
395
  }
317
396
  ),
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 }),
397
+ /* @__PURE__ */ e(v, { direction: "column", align: "center", gap: "2", children: g ? /* @__PURE__ */ s(te, { children: [
398
+ /* @__PURE__ */ e(Be, { className: "w-8 h-8 text-red-500" }),
399
+ /* @__PURE__ */ e(c, { size: "2", color: "red", weight: "medium", children: g }),
321
400
  /* @__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" }),
401
+ ] }) : /* @__PURE__ */ s(te, { children: [
402
+ /* @__PURE__ */ e(Ve, { className: "w-8 h-8 text-gray-400" }),
324
403
  /* @__PURE__ */ e(c, { size: "2", weight: "medium", children: "Click to upload or drag and drop" }),
325
- /* @__PURE__ */ h(c, { size: "1", color: "gray", children: [
404
+ /* @__PURE__ */ s(c, { size: "1", color: "gray", children: [
326
405
  "Max ",
327
- Math.round(w / (1024 * 1024)),
406
+ Math.round(V / (1024 * 1024)),
328
407
  "MB"
329
408
  ] })
330
409
  ] }) })
@@ -332,48 +411,148 @@ const se = ({ data: n, handleChange: d, path: r, label: p, required: m, errors:
332
411
  }
333
412
  )
334
413
  ] });
335
- }, Se = T(Re), Ie = z(
414
+ }, mr = N(pr), br = z(
336
415
  3,
337
416
  // Rank
338
- _("data-url")
339
- ), Ve = ({ uischema: n, visible: d }) => {
340
- 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 }
417
+ J(le("data-url"), le("file"))
418
+ ), gr = ({
419
+ data: t,
420
+ path: l,
421
+ schema: r,
422
+ uischema: u,
423
+ enabled: m,
424
+ visible: i,
425
+ addItem: a,
426
+ removeItems: n,
427
+ rootSchema: b,
428
+ arraySchema: d
429
+ }) => {
430
+ const g = d ? r : r.items, f = d || r;
431
+ if (i === !1 || !g || typeof g != "object" || Array.isArray(g))
432
+ return null;
433
+ const h = g, p = Array.isArray(t) ? t : [], I = f.title || "Array Items", k = () => {
434
+ const F = Fe(h, b);
435
+ a && a(l, F)();
436
+ }, M = (F) => {
437
+ if (n) {
438
+ const D = n(l, [F]);
439
+ D && D();
440
+ }
441
+ };
442
+ return /* @__PURE__ */ e(w, { mb: "6", children: /* @__PURE__ */ s(v, { direction: "column", gap: "4", children: [
443
+ /* @__PURE__ */ e(c, { as: "div", size: "4", weight: "bold", children: I }),
444
+ p.length === 0 && /* @__PURE__ */ e(w, { py: "4", px: "4", style: { backgroundColor: "var(--gray-3)", borderRadius: "var(--radius-3)" }, children: /* @__PURE__ */ e(c, { size: "2", color: "gray", children: "No items have been added yet." }) }),
445
+ p.map((F, D) => {
446
+ var x;
447
+ const L = `${l}.${D}`;
448
+ return /* @__PURE__ */ e(X, { size: "3", variant: "surface", children: /* @__PURE__ */ s(v, { direction: "column", gap: "4", children: [
449
+ /* @__PURE__ */ s(v, { justify: "between", align: "center", children: [
450
+ /* @__PURE__ */ s(c, { size: "3", weight: "bold", children: [
451
+ "Item ",
452
+ D + 1
453
+ ] }),
454
+ m && /* @__PURE__ */ s(
455
+ G,
456
+ {
457
+ type: "button",
458
+ color: "red",
459
+ variant: "soft",
460
+ onClick: () => M(D),
461
+ title: "Remove item",
462
+ children: [
463
+ /* @__PURE__ */ e(Pe, {}),
464
+ "Remove"
465
+ ]
466
+ }
467
+ )
468
+ ] }),
469
+ /* @__PURE__ */ e(w, { children: /* @__PURE__ */ e(
470
+ E,
471
+ {
472
+ schema: h,
473
+ uischema: ((x = u.options) == null ? void 0 : x.detail) || (h.type === "object" || h.properties ? {
474
+ type: "VerticalLayout",
475
+ elements: Object.keys(
476
+ h.properties || {}
477
+ ).map((B) => ({
478
+ type: "Control",
479
+ scope: `#/properties/${B}`
480
+ }))
481
+ } : {
482
+ type: "Control",
483
+ scope: "#"
484
+ }),
485
+ path: L,
486
+ enabled: m,
487
+ renderers: void 0,
488
+ cells: void 0
489
+ }
490
+ ) })
491
+ ] }) }, L);
492
+ }),
493
+ m && /* @__PURE__ */ e(w, { mt: "2", children: /* @__PURE__ */ s(
494
+ G,
495
+ {
496
+ type: "button",
497
+ variant: "surface",
498
+ onClick: k,
499
+ children: [
500
+ /* @__PURE__ */ e(je, {}),
501
+ "Add Item"
502
+ ]
503
+ }
504
+ ) })
505
+ ] }) });
506
+ }, ie = Ue(gr), fr = z(
507
+ 3,
508
+ Le
509
+ ), yr = ({ uischema: t, visible: l }) => {
510
+ const r = t;
511
+ return l === !1 ? null : /* @__PURE__ */ e(w, { mb: "4", children: /* @__PURE__ */ e(ce, { size: "4", children: r.text }) });
512
+ }, Cr = z(1, S("Label")), vr = z(
513
+ 3,
514
+ $e
515
+ ), Lr = [
516
+ { tester: He, renderer: We },
517
+ { tester: qe, renderer: Ge },
518
+ { tester: Ke, renderer: Xe },
519
+ { tester: Qe, renderer: Ye },
520
+ { tester: rr, renderer: tr },
521
+ { tester: nr, renderer: or },
522
+ { tester: ir, renderer: lr },
523
+ { tester: sr, renderer: cr },
524
+ { tester: dr, renderer: ar },
525
+ { tester: br, renderer: mr },
526
+ { tester: fr, renderer: ie },
527
+ { tester: vr, renderer: ie },
528
+ { tester: Cr, renderer: yr }
354
529
  ];
355
530
  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
531
+ ie as ArrayControl,
532
+ fr as ArrayControlTester,
533
+ Je as BooleanControl,
534
+ Ke as BooleanControlTester,
535
+ ar as CategorizationLayoutRenderer,
536
+ dr as CategorizationLayoutTester,
537
+ er as DateControl,
538
+ rr as DateControlTester,
539
+ mr as FileControl,
540
+ br as FileControlTester,
541
+ cr as GroupLayoutRenderer,
542
+ sr as GroupLayoutTester,
543
+ lr as HorizontalLayoutRenderer,
544
+ ir as HorizontalLayoutTester,
545
+ yr as LabelRenderer,
546
+ Cr as LabelTester,
547
+ _e as NumberControl,
548
+ qe as NumberControlTester,
549
+ Ze as SelectControl,
550
+ Qe as SelectControlTester,
551
+ Me as TextControl,
552
+ He as TextControlTester,
553
+ Fr as UploadProvider,
554
+ or as VerticalLayoutRenderer,
555
+ nr as VerticalLayoutTester,
556
+ Lr as radixRenderers,
557
+ Oe as useUpload
379
558
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opennsw/jsonforms-renderers",
3
- "version": "0.0.1",
3
+ "version": "0.1.0",
4
4
  "type": "module",
5
5
  "main": "dist/renderers.cjs.js",
6
6
  "module": "dist/renderers.es.js",