@opennsw/jsonforms-renderers 0.1.0 → 0.2.1

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