ynotsoft-dynamic-form 1.0.13 → 1.0.15

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.js CHANGED
@@ -1,47 +1,48 @@
1
- import{jsx as Ue}from"react/jsx-runtime";function te({children:e,onClick:n}){return Ue("button",{onClick:n,children:e})}import{useState as Z,useEffect as ze,useMemo as Rt}from"react";import{toast as $t}from"react-hot-toast";import Oe from"dayjs";import _e from"axios";import oe from"react-hot-toast";var V={REACT_API_URL:"http://localhost:5000/"};var ce=_e.create({baseURL:V.REACT_API_URL,headers:{"Content-Type":"application/json"}});ce.interceptors.response.use(e=>e.data,e=>{var n;if(e.response&&e.response.status===403)return oe.error("You are not authorized to access this resource."),Promise.reject("You are not authorized to access this resource.");if(e.response)return oe.error("An error occurred"),Promise.reject(((n=e.response.data)==null?void 0:n.message)||"An error occurred");oe.error(e.message)});var de=ce;import{jsx as je}from"react/jsx-runtime";function He(e){return je("input",{type:"hidden",name:e.name,value:e.value},e.name)}var me=He;import Ge from"react-select";import We from"react-select/animated";import{jsx as Ye}from"react/jsx-runtime";function Ve({field:e,formValues:n,handleChange:d,touched:g,errors:u,handleBlur:r}){let l=e.disabled&&e.disabled(n),m=e.options||[],a=We(),p=n[e.name]||[];return Ye(Ge,{components:a,isMulti:!0,isDisabled:l,name:e.label,value:p,onChange:f=>d(e.name,f),options:m,placeholder:e.placeholder,closeMenuOnSelect:!1})}var ue=Ve;import*as b from"@radix-ui/react-select";import"react";import{ChevronDownIcon as qe}from"@heroicons/react/20/solid";import{jsx as F,jsxs as Y}from"react/jsx-runtime";function Ke({field:e,formValues:n,handleChange:d,handleBlur:g}){var m;let u=n[e.name]||"",r=typeof e.disabled=="function"?e.disabled(n):e.disabled,l=e.options||[];return Y(b.Root,{value:u,onValueChange:a=>d(e.name,a),disabled:r,children:[Y(b.Trigger,{id:e.name,onBlur:()=>g(e.name),className:`inline-flex items-center justify-between w-full px-3 py-2 border rounded-md text-sm transition-all
2
- ${r?"bg-gray-100 text-gray-500 cursor-not-allowed":"border-gray-300 hover:border-gray-400 focus:ring-2 focus:ring-blue-500"}
3
- `,children:[F(b.Value,{placeholder:e.placeholder||`Select ${((m=e.label)==null?void 0:m.toLowerCase())||""}`}),F(b.Icon,{className:"ml-2 text-gray-500",children:F(qe,{className:"w-4 h-4"})})]}),F(b.Portal,{children:Y(b.Content,{className:"bg-white border border-gray-200 rounded-md shadow-lg z-50 min-w-[var(--radix-select-trigger-width)]",position:"popper",sideOffset:5,children:[F(b.ScrollUpButton,{className:"flex items-center justify-center h-6 text-gray-500 bg-gray-50",children:F(b.Arrow,{className:"fill-white stroke-gray-200"})}),Y(b.Viewport,{className:"p-1",children:[e.groupLabel&&F(b.Group,{children:F(b.Label,{className:"px-2 py-1 text-xs text-gray-500 uppercase tracking-wide",children:e.groupLabel})}),l.map(a=>F(b.Item,{value:a.value,className:`relative flex items-center px-3 py-2 text-sm rounded cursor-pointer select-none
1
+ function te(e,{insertAt:c}={}){if(!e||typeof document>"u")return;let o=document.head||document.getElementsByTagName("head")[0],g=document.createElement("style");g.type="text/css",c==="top"&&o.firstChild?o.insertBefore(g,o.firstChild):o.appendChild(g),g.styleSheet?g.styleSheet.cssText=e:g.appendChild(document.createTextNode(e))}te(`/*! tailwindcss v4.1.15 | MIT License | https://tailwindcss.com */@layer properties;@layer theme,base,components,utilities;@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-100: oklch(93.6% .032 17.717);--color-red-500: oklch(63.7% .237 25.331);--color-red-700: oklch(50.5% .213 27.518);--color-red-900: oklch(39.6% .141 25.723);--color-orange-50: oklch(98% .016 73.684);--color-orange-500: oklch(70.5% .213 47.604);--color-amber-50: oklch(98.7% .022 95.277);--color-amber-100: oklch(96.2% .059 95.617);--color-amber-600: oklch(66.6% .179 58.318);--color-amber-900: oklch(41.4% .112 45.904);--color-yellow-50: oklch(98.7% .026 102.212);--color-yellow-500: oklch(79.5% .184 86.047);--color-green-50: oklch(98.2% .018 155.826);--color-green-100: oklch(96.2% .044 156.743);--color-green-500: oklch(72.3% .219 149.579);--color-green-600: oklch(62.7% .194 149.214);--color-green-900: oklch(39.3% .095 152.535);--color-blue-50: oklch(97% .014 254.604);--color-blue-100: oklch(93.2% .032 255.585);--color-blue-200: oklch(88.2% .059 254.128);--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-blue-700: oklch(48.8% .243 264.376);--color-blue-900: oklch(37.9% .146 265.522);--color-indigo-50: oklch(96.2% .018 272.314);--color-indigo-500: oklch(58.5% .233 277.117);--color-purple-50: oklch(97.7% .014 308.299);--color-purple-500: oklch(62.7% .265 303.9);--color-pink-50: oklch(97.1% .014 343.198);--color-pink-500: oklch(65.6% .241 354.308);--color-gray-50: oklch(98.5% .002 247.839);--color-gray-100: oklch(96.7% .003 264.542);--color-gray-200: oklch(92.8% .006 264.531);--color-gray-300: oklch(87.2% .01 258.338);--color-gray-400: oklch(70.7% .022 261.325);--color-gray-500: oklch(55.1% .027 264.364);--color-gray-600: oklch(44.6% .03 256.802);--color-gray-700: oklch(37.3% .034 259.733);--color-gray-900: oklch(21% .034 264.665);--color-black: #000;--color-white: #fff;--spacing: .25rem;--container-2xl: 42rem;--container-4xl: 56rem;--text-xs: .75rem;--text-xs--line-height: calc(1 / .75);--text-sm: .875rem;--text-sm--line-height: calc(1.25 / .875);--text-base: 1rem;--text-base--line-height: 1.5 ;--text-lg: 1.125rem;--text-lg--line-height: calc(1.75 / 1.125);--text-xl: 1.25rem;--text-xl--line-height: calc(1.75 / 1.25);--text-2xl: 1.5rem;--text-2xl--line-height: calc(2 / 1.5);--text-3xl: 1.875rem;--text-3xl--line-height: 1.2 ;--text-4xl: 2.25rem;--text-4xl--line-height: calc(2.5 / 2.25);--text-5xl: 3rem;--text-5xl--line-height: 1;--font-weight-normal: 400;--font-weight-medium: 500;--font-weight-semibold: 600;--font-weight-bold: 700;--tracking-wide: .025em;--radius-md: .375rem;--radius-lg: .5rem;--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,::file-selector-button{box-sizing:border-box;margin:0;padding:0;border:0 solid}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;tab-size:4;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{font-size:75%;line-height:0;position:relative;vertical-align:baseline}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{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea,::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;border-radius:0;background-color:transparent;opacity:1}: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)){&{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,::-webkit-datetime-edit-year-field,::-webkit-datetime-edit-month-field,::-webkit-datetime-edit-day-field,::-webkit-datetime-edit-hour-field,::-webkit-datetime-edit-minute-field,::-webkit-datetime-edit-second-field,::-webkit-datetime-edit-millisecond-field,::-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]),::file-selector-button{appearance:button}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer utilities{.fixed{position:fixed}.relative{position:relative}.inset-0{inset:calc(var(--spacing) * 0)}.z-50{z-index:50}.col-span-8{grid-column:span 8 / span 8}.col-span-full{grid-column:1 / -1}.container{width:100%;@media(width>=40rem){max-width:40rem}@media(width>=48rem){max-width:48rem}@media(width>=64rem){max-width:64rem}@media(width>=80rem){max-width:80rem}@media(width>=96rem){max-width:96rem}}.mx-auto{margin-inline:auto}.my-1{margin-block:calc(var(--spacing) * 1)}.my-4{margin-block:calc(var(--spacing) * 4)}.mt-1{margin-top:calc(var(--spacing) * 1)}.mt-6{margin-top:calc(var(--spacing) * 6)}.mb-1{margin-bottom:calc(var(--spacing) * 1)}.mb-4{margin-bottom:calc(var(--spacing) * 4)}.ml-1{margin-left:calc(var(--spacing) * 1)}.ml-2{margin-left:calc(var(--spacing) * 2)}.ml-3{margin-left:calc(var(--spacing) * 3)}.block{display:block}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline{display:inline}.inline-block{display:inline-block}.inline-flex{display:inline-flex}.table{display:table}.size-4{width:calc(var(--spacing) * 4);height:calc(var(--spacing) * 4)}.size-5{width:calc(var(--spacing) * 5);height:calc(var(--spacing) * 5)}.h-2{height:calc(var(--spacing) * 2)}.h-4{height:calc(var(--spacing) * 4)}.h-6{height:calc(var(--spacing) * 6)}.h-9{height:calc(var(--spacing) * 9)}.h-10{height:calc(var(--spacing) * 10)}.h-full{height:100%}.h-px{height:1px}.max-h-40{max-height:calc(var(--spacing) * 40)}.max-h-\\[70vh\\]{max-height:70vh}.w-4{width:calc(var(--spacing) * 4)}.w-6{width:calc(var(--spacing) * 6)}.w-14{width:calc(var(--spacing) * 14)}.w-64{width:calc(var(--spacing) * 64)}.w-auto{width:auto}.w-full{width:100%}.max-w-2xl{max-width:var(--container-2xl)}.max-w-4xl{max-width:var(--container-4xl)}.max-w-none{max-width:none}.min-w-\\[var\\(--radix-select-trigger-width\\)\\]{min-width:var(--radix-select-trigger-width)}.flex-1{flex:1}.shrink-0{flex-shrink:0}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.resize-none{resize:none}.grid-cols-12{grid-template-columns:repeat(12,minmax(0,1fr))}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.items-start{align-items:flex-start}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.gap-1{gap:calc(var(--spacing) * 1)}.gap-2{gap:calc(var(--spacing) * 2)}.gap-3{gap:calc(var(--spacing) * 3)}.gap-4{gap:calc(var(--spacing) * 4)}.space-y-2{:where(&>:not(:last-child)){--tw-space-y-reverse: 0;margin-block-start:calc(calc(var(--spacing) * 2) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 2) * calc(1 - var(--tw-space-y-reverse)))}}.space-y-3{:where(&>:not(:last-child)){--tw-space-y-reverse: 0;margin-block-start:calc(calc(var(--spacing) * 3) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 3) * calc(1 - var(--tw-space-y-reverse)))}}.gap-x-4{column-gap:calc(var(--spacing) * 4)}.space-x-2{:where(&>:not(:last-child)){--tw-space-x-reverse: 0;margin-inline-start:calc(calc(var(--spacing) * 2) * var(--tw-space-x-reverse));margin-inline-end:calc(calc(var(--spacing) * 2) * calc(1 - var(--tw-space-x-reverse)))}}.overflow-hidden{overflow:hidden}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:.25rem}.rounded-full{border-radius:calc(infinity * 1px)}.rounded-lg{border-radius:var(--radius-lg)}.rounded-md{border-radius:var(--radius-md)}.border{border-style:var(--tw-border-style);border-width:1px}.border-0{border-style:var(--tw-border-style);border-width:0px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-b-2{border-bottom-style:var(--tw-border-style);border-bottom-width:2px}.border-amber-100{border-color:var(--color-amber-100)}.border-blue-100{border-color:var(--color-blue-100)}.border-blue-500{border-color:var(--color-blue-500)}.border-gray-200{border-color:var(--color-gray-200)}.border-gray-300{border-color:var(--color-gray-300)}.border-gray-500{border-color:var(--color-gray-500)}.border-green-100{border-color:var(--color-green-100)}.border-green-500{border-color:var(--color-green-500)}.border-indigo-500{border-color:var(--color-indigo-500)}.border-orange-500{border-color:var(--color-orange-500)}.border-pink-500{border-color:var(--color-pink-500)}.border-purple-500{border-color:var(--color-purple-500)}.border-red-100{border-color:var(--color-red-100)}.border-red-500{border-color:var(--color-red-500)}.border-yellow-500{border-color:var(--color-yellow-500)}.bg-amber-50{background-color:var(--color-amber-50)}.bg-black\\/30{background-color:color-mix(in srgb,#000 30%,transparent);@supports (color: color-mix(in lab,red,red)){background-color:color-mix(in oklab,var(--color-black) 30%,transparent)}}.bg-blue-50{background-color:var(--color-blue-50)}.bg-blue-200{background-color:var(--color-blue-200)}.bg-blue-500{background-color:var(--color-blue-500)}.bg-blue-600{background-color:var(--color-blue-600)}.bg-gray-50{background-color:var(--color-gray-50)}.bg-gray-100{background-color:var(--color-gray-100)}.bg-gray-200{background-color:var(--color-gray-200)}.bg-gray-300{background-color:var(--color-gray-300)}.bg-green-50{background-color:var(--color-green-50)}.bg-indigo-50{background-color:var(--color-indigo-50)}.bg-orange-50{background-color:var(--color-orange-50)}.bg-pink-50{background-color:var(--color-pink-50)}.bg-purple-50{background-color:var(--color-purple-50)}.bg-red-50{background-color:var(--color-red-50)}.bg-white{background-color:var(--color-white)}.bg-yellow-50{background-color:var(--color-yellow-50)}.fill-white{fill:var(--color-white)}.stroke-gray-200{stroke:var(--color-gray-200)}.p-0{padding:calc(var(--spacing) * 0)}.p-1{padding:calc(var(--spacing) * 1)}.p-2{padding:calc(var(--spacing) * 2)}.p-3{padding:calc(var(--spacing) * 3)}.p-4{padding:calc(var(--spacing) * 4)}.px-2{padding-inline:calc(var(--spacing) * 2)}.px-3{padding-inline:calc(var(--spacing) * 3)}.px-4{padding-inline:calc(var(--spacing) * 4)}.px-6{padding-inline:calc(var(--spacing) * 6)}.py-1{padding-block:calc(var(--spacing) * 1)}.py-2{padding-block:calc(var(--spacing) * 2)}.py-4{padding-block:calc(var(--spacing) * 4)}.py-6{padding-block:calc(var(--spacing) * 6)}.py-8{padding-block:calc(var(--spacing) * 8)}.pt-1{padding-top:calc(var(--spacing) * 1)}.pt-3{padding-top:calc(var(--spacing) * 3)}.pb-2{padding-bottom:calc(var(--spacing) * 2)}.text-center{text-align:center}.text-left{text-align:left}.text-right{text-align:right}.text-2xl{font-size:var(--text-2xl);line-height:var(--tw-leading, var(--text-2xl--line-height))}.text-3xl{font-size:var(--text-3xl);line-height:var(--tw-leading, var(--text-3xl--line-height))}.text-4xl{font-size:var(--text-4xl);line-height:var(--tw-leading, var(--text-4xl--line-height))}.text-5xl{font-size:var(--text-5xl);line-height:var(--tw-leading, var(--text-5xl--line-height))}.text-base{font-size:var(--text-base);line-height:var(--tw-leading, var(--text-base--line-height))}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading, var(--text-lg--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading, var(--text-sm--line-height))}.text-xl{font-size:var(--text-xl);line-height:var(--tw-leading, var(--text-xl--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading, var(--text-xs--line-height))}.font-bold{--tw-font-weight: var(--font-weight-bold);font-weight:var(--font-weight-bold)}.font-medium{--tw-font-weight: var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-normal{--tw-font-weight: var(--font-weight-normal);font-weight:var(--font-weight-normal)}.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)}.whitespace-nowrap{white-space:nowrap}.text-amber-600{color:var(--color-amber-600)}.text-amber-900{color:var(--color-amber-900)}.text-blue-600{color:var(--color-blue-600)}.text-blue-900{color:var(--color-blue-900)}.text-gray-400{color:var(--color-gray-400)}.text-gray-500{color:var(--color-gray-500)}.text-gray-600{color:var(--color-gray-600)}.text-gray-700{color:var(--color-gray-700)}.text-gray-900{color:var(--color-gray-900)}.text-green-600{color:var(--color-green-600)}.text-green-900{color:var(--color-green-900)}.text-red-500{color:var(--color-red-500)}.text-red-900{color:var(--color-red-900)}.text-white{color:var(--color-white)}.uppercase{text-transform:uppercase}.underline{text-decoration-line:underline}.opacity-50{opacity:50%}.opacity-70{opacity:70%}.shadow{--tw-shadow: 0 1px 3px 0 var(--tw-shadow-color, rgb(0 0 0 / .1)), 0 1px 2px -1px var(--tw-shadow-color, rgb(0 0 0 / .1));box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-lg{--tw-shadow: 0 10px 15px -3px var(--tw-shadow-color, rgb(0 0 0 / .1)), 0 4px 6px -4px var(--tw-shadow-color, rgb(0 0 0 / .1));box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-md{--tw-shadow: 0 4px 6px -1px var(--tw-shadow-color, rgb(0 0 0 / .1)), 0 2px 4px -2px var(--tw-shadow-color, rgb(0 0 0 / .1));box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-none{--tw-shadow: 0 0 #0000;box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-sm{--tw-shadow: 0 1px 3px 0 var(--tw-shadow-color, rgb(0 0 0 / .1)), 0 1px 2px -1px var(--tw-shadow-color, rgb(0 0 0 / .1));box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-xl{--tw-shadow: 0 20px 25px -5px var(--tw-shadow-color, rgb(0 0 0 / .1)), 0 8px 10px -6px var(--tw-shadow-color, rgb(0 0 0 / .1));box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.blur{--tw-blur: blur(8px);filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}.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))}.select-none{-webkit-user-select:none;user-select:none}.file\\:border-0{&::file-selector-button{border-style:var(--tw-border-style);border-width:0px}}.file\\:bg-transparent{&::file-selector-button{background-color:transparent}}.file\\:text-sm{&::file-selector-button{font-size:var(--text-sm);line-height:var(--tw-leading, var(--text-sm--line-height))}}.file\\:font-medium{&::file-selector-button{--tw-font-weight: var(--font-weight-medium);font-weight:var(--font-weight-medium)}}.after\\:block{&:after{content:var(--tw-content);display:block}}.after\\:h-1\\.5{&:after{content:var(--tw-content);height:calc(var(--spacing) * 1.5)}}.after\\:w-1\\.5{&:after{content:var(--tw-content);width:calc(var(--spacing) * 1.5)}}.after\\:rounded-full{&:after{content:var(--tw-content);border-radius:calc(infinity * 1px)}}.after\\:bg-white{&:after{content:var(--tw-content);background-color:var(--color-white)}}.after\\:content-\\[\\'\\'\\]{&:after{--tw-content: "";content:var(--tw-content)}}.hover\\:border-blue-400{&:hover{@media(hover:hover){border-color:var(--color-blue-400)}}}.hover\\:border-gray-400{&:hover{@media(hover:hover){border-color:var(--color-gray-400)}}}.hover\\:bg-blue-700{&:hover{@media(hover:hover){background-color:var(--color-blue-700)}}}.hover\\:bg-gray-50{&:hover{@media(hover:hover){background-color:var(--color-gray-50)}}}.hover\\:bg-gray-100{&:hover{@media(hover:hover){background-color:var(--color-gray-100)}}}.hover\\:bg-gray-200{&:hover{@media(hover:hover){background-color:var(--color-gray-200)}}}.hover\\:text-gray-500{&:hover{@media(hover:hover){color:var(--color-gray-500)}}}.hover\\:text-gray-900{&:hover{@media(hover:hover){color:var(--color-gray-900)}}}.hover\\:text-red-700{&:hover{@media(hover:hover){color:var(--color-red-700)}}}.focus\\:ring-2{&:focus{--tw-ring-shadow: var(--tw-ring-inset,) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color, currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}}.focus\\:ring-blue-500{&:focus{--tw-ring-color: var(--color-blue-500)}}.focus\\:ring-offset-2{&:focus{--tw-ring-offset-width: 2px;--tw-ring-offset-shadow: var(--tw-ring-inset,) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color)}}.focus\\:outline-none{&:focus{--tw-outline-style: none;outline-style:none}}.focus-visible\\:ring-2{&:focus-visible{--tw-ring-shadow: var(--tw-ring-inset,) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color, currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}}.focus-visible\\:ring-blue-500{&:focus-visible{--tw-ring-color: var(--color-blue-500)}}.focus-visible\\:ring-red-500{&:focus-visible{--tw-ring-color: var(--color-red-500)}}.focus-visible\\:ring-offset-2{&:focus-visible{--tw-ring-offset-width: 2px;--tw-ring-offset-shadow: var(--tw-ring-inset,) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color)}}.focus-visible\\:outline-none{&:focus-visible{--tw-outline-style: none;outline-style:none}}.disabled\\:pointer-events-none{&:disabled{pointer-events:none}}.disabled\\:cursor-not-allowed{&:disabled{cursor:not-allowed}}.disabled\\:opacity-50{&:disabled{opacity:50%}}.data-\\[state\\=checked\\]\\:border-blue-600{&[data-state=checked]{border-color:var(--color-blue-600)}}.data-\\[state\\=checked\\]\\:bg-blue-50{&[data-state=checked]{background-color:var(--color-blue-50)}}.data-\\[state\\=checked\\]\\:bg-blue-600{&[data-state=checked]{background-color:var(--color-blue-600)}}.data-\\[state\\=checked\\]\\:text-blue-600{&[data-state=checked]{color:var(--color-blue-600)}}}@property --tw-space-y-reverse{syntax: "*"; inherits: false; initial-value: 0;}@property --tw-space-x-reverse{syntax: "*"; inherits: false; initial-value: 0;}@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-shadow{syntax: "*"; inherits: false; initial-value: 0 0 #0000;}@property --tw-shadow-color{syntax: "*"; inherits: false;}@property --tw-shadow-alpha{syntax: "<percentage>"; inherits: false; initial-value: 100%;}@property --tw-inset-shadow{syntax: "*"; inherits: false; initial-value: 0 0 #0000;}@property --tw-inset-shadow-color{syntax: "*"; inherits: false;}@property --tw-inset-shadow-alpha{syntax: "<percentage>"; inherits: false; initial-value: 100%;}@property --tw-ring-color{syntax: "*"; inherits: false;}@property --tw-ring-shadow{syntax: "*"; inherits: false; initial-value: 0 0 #0000;}@property --tw-inset-ring-color{syntax: "*"; inherits: false;}@property --tw-inset-ring-shadow{syntax: "*"; inherits: false; initial-value: 0 0 #0000;}@property --tw-ring-inset{syntax: "*"; inherits: false;}@property --tw-ring-offset-width{syntax: "<length>"; inherits: false; initial-value: 0px;}@property --tw-ring-offset-color{syntax: "*"; inherits: false; initial-value: #fff;}@property --tw-ring-offset-shadow{syntax: "*"; inherits: false; initial-value: 0 0 #0000;}@property --tw-blur{syntax: "*"; inherits: false;}@property --tw-brightness{syntax: "*"; inherits: false;}@property --tw-contrast{syntax: "*"; inherits: false;}@property --tw-grayscale{syntax: "*"; inherits: false;}@property --tw-hue-rotate{syntax: "*"; inherits: false;}@property --tw-invert{syntax: "*"; inherits: false;}@property --tw-opacity{syntax: "*"; inherits: false;}@property --tw-saturate{syntax: "*"; inherits: false;}@property --tw-sepia{syntax: "*"; inherits: false;}@property --tw-drop-shadow{syntax: "*"; inherits: false;}@property --tw-drop-shadow-color{syntax: "*"; inherits: false;}@property --tw-drop-shadow-alpha{syntax: "<percentage>"; inherits: false; initial-value: 100%;}@property --tw-drop-shadow-size{syntax: "*"; inherits: false;}@property --tw-content{syntax: "*"; initial-value: ""; inherits: false;}@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-space-y-reverse: 0;--tw-space-x-reverse: 0;--tw-border-style: solid;--tw-font-weight: initial;--tw-tracking: initial;--tw-shadow: 0 0 #0000;--tw-shadow-color: initial;--tw-shadow-alpha: 100%;--tw-inset-shadow: 0 0 #0000;--tw-inset-shadow-color: initial;--tw-inset-shadow-alpha: 100%;--tw-ring-color: initial;--tw-ring-shadow: 0 0 #0000;--tw-inset-ring-color: initial;--tw-inset-ring-shadow: 0 0 #0000;--tw-ring-inset: initial;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-offset-shadow: 0 0 #0000;--tw-blur: initial;--tw-brightness: initial;--tw-contrast: initial;--tw-grayscale: initial;--tw-hue-rotate: initial;--tw-invert: initial;--tw-opacity: initial;--tw-saturate: initial;--tw-sepia: initial;--tw-drop-shadow: initial;--tw-drop-shadow-color: initial;--tw-drop-shadow-alpha: 100%;--tw-drop-shadow-size: initial;--tw-content: ""}}}
2
+ `);import{useState as Q,useEffect as Be,useMemo as Nt}from"react";import{toast as De}from"react-hot-toast";import je from"dayjs";import{jsx as Oe}from"react/jsx-runtime";function Te(e){return Oe("input",{type:"hidden",name:e.name,value:e.value},e.name)}var le=Te;import Ue from"react-select";import Ae from"react-select/animated";import{jsx as Ge}from"react/jsx-runtime";function He({field:e,formValues:c,handleChange:o,touched:g,errors:u,handleBlur:d}){let i=e.disabled&&e.disabled(c),s=e.options||[],n=Ae(),m=c[e.name]||[];return Ge(Ue,{components:n,isMulti:!0,isDisabled:i,name:e.label,value:m,onChange:f=>o(e.name,f),options:s,placeholder:e.placeholder,closeMenuOnSelect:!1})}var ce=He;import*as h from"@radix-ui/react-select";import"react";import{ChevronDownIcon as _e}from"@heroicons/react/20/solid";import{jsx as F,jsxs as q}from"react/jsx-runtime";function We({field:e,formValues:c,handleChange:o,handleBlur:g}){var s;let u=c[e.name]||"",d=typeof e.disabled=="function"?e.disabled(c):e.disabled,i=e.options||[];return q(h.Root,{value:u,onValueChange:n=>o(e.name,n),disabled:d,children:[q(h.Trigger,{id:e.name,onBlur:()=>g(e.name),className:`inline-flex items-center justify-between w-full px-3 py-2 border rounded-md text-sm transition-all
3
+ ${d?"bg-gray-100 text-gray-500 cursor-not-allowed":"border-gray-300 hover:border-gray-400 focus:ring-2 focus:ring-blue-500"}
4
+ `,children:[F(h.Value,{placeholder:e.placeholder||`Select ${((s=e.label)==null?void 0:s.toLowerCase())||""}`}),F(h.Icon,{className:"ml-2 text-gray-500",children:F(_e,{className:"w-4 h-4"})})]}),F(h.Portal,{children:q(h.Content,{className:"bg-white border border-gray-200 rounded-md shadow-lg z-50 min-w-[var(--radix-select-trigger-width)]",position:"popper",sideOffset:5,children:[F(h.ScrollUpButton,{className:"flex items-center justify-center h-6 text-gray-500 bg-gray-50",children:F(h.Arrow,{className:"fill-white stroke-gray-200"})}),q(h.Viewport,{className:"p-1",children:[e.groupLabel&&F(h.Group,{children:F(h.Label,{className:"px-2 py-1 text-xs text-gray-500 uppercase tracking-wide",children:e.groupLabel})}),i.map(n=>F(h.Item,{value:n.value,className:`relative flex items-center px-3 py-2 text-sm rounded cursor-pointer select-none
4
5
  data-[state=checked]:bg-blue-50
5
6
  data-[state=checked]:text-blue-600
6
- `,children:F(b.ItemText,{children:a.label})},a.value)),e.separator&&F(b.Separator,{className:"my-1 h-px bg-gray-200"})]}),F(b.Arrow,{className:"fill-white stroke-gray-200"})]})})]})}var pe=Ke;import"react";import{jsx as Je}from"react/jsx-runtime";function Xe({field:e,formValues:n,handleChange:d,handleBlur:g,touched:u,errors:r}){let l=e.readOnly&&e.disabled;return Je("input",{...e.props,type:"email",value:n[e.name]||"",onChange:a=>d(e.name,a.target.value),onBlur:()=>g(e.name),disabled:l,name:e.name,placeholder:e.placeholder,className:`w-full px-3 py-2 border rounded-md ${!1?"border-red-500":"border-gray-300"} ${l?"bg-gray-100 text-gray-500 cursor-not-allowed":""}`})}var be=Xe;import"react";import{jsx as Ze}from"react/jsx-runtime";function Qe({field:e,formValues:n,handleChange:d,handleBlur:g,touched:u,errors:r}){console.log("Rendering InputField for",e);let l=e.readOnly||e.disabled;return Ze("input",{...e.props,id:e.name,type:e.type||"text",value:n[e.name]||"",onChange:a=>d(e.name,a.target.value),onBlur:()=>g(e.name),disabled:l,name:e.name,placeholder:e.placeholder,min:e.minLength,max:e.maxLength,className:`flex h-10 w-full rounded-md border px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 ${!1?"border-red-500 focus-visible:ring-red-500":"border-input focus-visible:ring-blue-500"} ${l?"bg-gray-50 text-gray-500":"bg-background"}`})}var re=Qe;import"react";import{jsx as ge}from"react/jsx-runtime";function et({field:e,formValues:n}){let d=n[e.name]||e.content||"";return ge("div",{className:`mb-4 ${e.fieldClass?e.fieldClass:"col-span-full"}`,id:e.name.toLowerCase()+"_id",children:ge("div",{className:"w-full px-3 py-2 border rounded-md overflow-y-auto max-h-40 prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:d}})},e.name)}var he=et;import{jsx as ae,jsxs as xe}from"react/jsx-runtime";function tt({field:e,formValues:n,handleChange:d,handleBlur:g,touched:u,errors:r}){let l=e.disabled&&e.disabled(n),m=!1;return xe("div",{className:"mt-1 space-x-2",children:[ae("input",{...e.props,id:"id_"+e.name,type:"checkbox",checked:n[e.name]||!1,onChange:a=>d(e.name,a.target.checked),onBlur:()=>g(e.name),disabled:l,className:`rounded border-gray-300 ${l?"opacity-50 cursor-not-allowed":""}`}),xe("label",{className:"",htmlFor:"id_"+e.name,children:[e.label,e.required&&ae("span",{className:"text-red-500",children:"*"})]}),m&&ae("p",{className:"mt-1 text-sm text-red-500",children:m})]})}var ye=tt;import*as A from"@radix-ui/react-popover";import{useState as ot}from"react";import{DayPicker as rt}from"react-day-picker";import"react-day-picker/dist/style.css";import{jsx as P,jsxs as G}from"react/jsx-runtime";function at({field:e,formValues:n,handleChange:d,handleBlur:g}){let[u,r]=ot(!1),l=n[e.name]??{from:null,to:null},m=p=>d(e.name,p),a=()=>d(e.name,{from:null,to:null});return P("div",{children:G(A.Root,{open:u,onOpenChange:r,children:[P(A.Trigger,{asChild:!0,children:G("button",{type:"button",id:e.name,"aria-haspopup":"dialog","aria-expanded":u,onClick:()=>r(!0),onKeyDown:p=>p.key==="Enter"&&r(!0),className:`
7
+ `,children:F(h.ItemText,{children:n.label})},n.value)),e.separator&&F(h.Separator,{className:"my-1 h-px bg-gray-200"})]}),F(h.Arrow,{className:"fill-white stroke-gray-200"})]})})]})}var de=We;import"react";import{jsx as Ve}from"react/jsx-runtime";function qe({field:e,formValues:c,handleChange:o,handleBlur:g,touched:u,errors:d}){let i=e.readOnly&&e.disabled;return Ve("input",{...e.props,type:"email",value:c[e.name]||"",onChange:n=>o(e.name,n.target.value),onBlur:()=>g(e.name),disabled:i,name:e.name,placeholder:e.placeholder,className:`w-full px-3 py-2 border rounded-md ${!1?"border-red-500":"border-gray-300"} ${i?"bg-gray-100 text-gray-500 cursor-not-allowed":""}`})}var pe=qe;import"react";import{jsx as Ke}from"react/jsx-runtime";function Ye({field:e,formValues:c,handleChange:o,handleBlur:g,touched:u,errors:d}){let i=e.readOnly||e.disabled;return Ke("input",{...e.props,id:e.name,type:e.type||"text",value:c[e.name]||"",onChange:n=>o(e.name,n.target.value),onBlur:()=>g(e.name),disabled:i,name:e.name,placeholder:e.placeholder,min:e.minLength,max:e.maxLength,className:`flex h-10 w-full rounded-md border px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 ${!1?"border-red-500 focus-visible:ring-red-500":"border-input focus-visible:ring-blue-500"} ${i?"bg-gray-50 text-gray-500":"bg-background"}`})}var re=Ye;import"react";import{jsx as ge}from"react/jsx-runtime";function Xe({field:e,formValues:c}){let o=c[e.name]||e.content||"";return ge("div",{className:`mb-4 ${e.fieldClass?e.fieldClass:"col-span-full"}`,id:e.name.toLowerCase()+"_id",children:ge("div",{className:"w-full px-3 py-2 border rounded-md overflow-y-auto max-h-40 prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:o}})},e.name)}var ue=Xe;import{jsx as oe,jsxs as me}from"react/jsx-runtime";function Je({field:e,formValues:c,handleChange:o,handleBlur:g,touched:u,errors:d}){let i=e.disabled&&e.disabled(c),s=!1;return me("div",{className:"mt-1 space-x-2",children:[oe("input",{...e.props,id:"id_"+e.name,type:"checkbox",checked:c[e.name]||!1,onChange:n=>o(e.name,n.target.checked),onBlur:()=>g(e.name),disabled:i,className:`rounded border-gray-300 ${i?"opacity-50 cursor-not-allowed":""}`}),me("label",{className:"",htmlFor:"id_"+e.name,children:[e.label,e.required&&oe("span",{className:"text-red-500",children:"*"})]}),s&&oe("p",{className:"mt-1 text-sm text-red-500",children:s})]})}var he=Je;import*as j from"@radix-ui/react-popover";import{useState as Qe}from"react";import{DayPicker as Ze}from"react-day-picker";import"react-day-picker/dist/style.css";import{jsx as R,jsxs as _}from"react/jsx-runtime";function et({field:e,formValues:c,handleChange:o,handleBlur:g}){let[u,d]=Qe(!1),i=c[e.name]??{from:null,to:null},s=m=>o(e.name,m),n=()=>o(e.name,{from:null,to:null});return R("div",{children:_(j.Root,{open:u,onOpenChange:d,children:[R(j.Trigger,{asChild:!0,children:_("button",{type:"button",id:e.name,"aria-haspopup":"dialog","aria-expanded":u,onClick:()=>d(!0),onKeyDown:m=>m.key==="Enter"&&d(!0),className:`
7
8
  inline-flex items-center justify-between gap-2
8
9
  w-full h-9 rounded-md border border-gray-300 bg-white
9
10
  px-3 py-2 text-sm font-normal shadow-sm
10
11
  hover:bg-gray-50 hover:text-gray-900
11
12
  focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2
12
13
  disabled:cursor-not-allowed disabled:opacity-50
13
- `,children:[l.from?l.to?G("span",{children:[l.from.toLocaleDateString()," \u2013 ",l.to.toLocaleDateString()]}):P("span",{children:l.from.toLocaleDateString()}):P("span",{className:"text-muted-foreground",children:e.placeholder||"Select date range"}),P("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-chevron-down opacity-70",children:P("path",{d:"m6 9 6 6 6-6"})})]})}),G(A.Content,{align:"start",sideOffset:2,className:"z-50 rounded-md border border-gray-200 bg-white p-0 shadow-md w-auto",children:[P(rt,{mode:"range",selected:l,onSelect:m,showOutsideDays:!0,className:"rounded-md bg-white p-3 text-xs"}),G("div",{className:"flex items-center justify-between gap-2 border-t border-gray-200 p-3",children:[P("button",{type:"button",onClick:a,className:"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 border border-gray-300 bg-white hover:bg-gray-100 hover:text-gray-900 h-9 px-4 py-2",children:"Clear"}),P("button",{type:"button",onClick:()=>r(!1),className:"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 bg-blue-600 text-white hover:bg-blue-700 h-9 px-4 py-2",children:"Done"})]})]})]})})}var fe=at;import"react";import{toast as ve}from"react-hot-toast";import{Fragment as nt,jsx as L,jsxs as C}from"react/jsx-runtime";function st({field:e,formValues:n,touched:d,errors:g,fileUploads:u,setFileUploads:r,fileInputRefs:l,handleChange:m,onFieldsChange:a}){let p=d[e.name]&&g[e.name],f=e.type==="multifile",N=u[e.name]||{},w=n[e.name],$=f?w||[]:[w].filter(Boolean),k=e.disabled&&e.disabled(n),D=`px-4 py-2 bg-gray-100 border rounded hover:bg-gray-200 ${k?"cursor-not-allowed":""}`,H=`${V.REACT_API_URL}uploads`,E=i=>{if(i===0)return"0 Bytes";let t=1024,o=["Bytes","KB","MB","GB"],s=Math.floor(Math.log(i)/Math.log(t));return parseFloat((i/Math.pow(t,s)).toFixed(2))+" "+o[s]},T=async(i,t)=>{let o=new FormData;o.append("file",i);let s=await fetch(`${H}`,{method:"POST",body:o});if(!s.ok)throw ve.error("Upload failed"),new Error("Upload failed");return await s.json()},x=async(i,t)=>{if(!t)return;if(i.maxSize&&t.size>i.maxSize)throw new Error(`File size must not exceed ${E(i.maxSize)}`);let o=await T(t,i.name),s={...n,[i.name]:o};m(i.name,o),a(s)},S=async(i,t)=>{let o=n[i.name]||[];if(o.length+t.length>i.maxFiles)throw new Error(`Maximum ${i.maxFiles} files allowed`);t.forEach(v=>{if(i.maxSize&&v.size>i.maxSize)throw new Error(`Each file must not exceed ${E(i.maxSize)}`)});let s=await Promise.all(t.map(v=>T(v,i.name))),c=[...o,...s];m(i.name,c),a({...n,[i.name]:c})},W=async(i,t)=>{let o=Array.from(t);try{e.type==="file"?await x(e,o[0]):e.type==="multifile"&&await S(e,o),l.current[i]&&(l.current[i].value="")}catch(s){ve.error(`Upload failed: ${s.message}`)}},ee=async(i,t)=>{let o;e.type==="file"?o="":o=(n[i]||[]).filter(c=>c!==t),m(i,o),a({...n,[i]:o}),l.current[i]&&(l.current[i].value="")};return C("div",{className:`mb-4 ${e.fieldClass||"col-span-full"}`,children:[C("label",{className:"block font-medium mb-1",children:[e.label,e.required&&L("span",{className:"text-red-500",children:"*"})]}),C("div",{className:"space-y-2",children:[C("div",{className:"items-center space-x-2",children:[C("button",{type:"button",disabled:k,onClick:()=>l.current[e.name].click(),className:D,children:["Choose ",f?"Files":"File"]}),f&&$.length>0&&C("span",{className:"text-sm text-gray-600",children:[$.length," of ",e.maxFiles," files uploaded"]})]}),L("input",{ref:i=>l.current[e.name]=i,type:"file",accept:e.accept,multiple:f,className:"hidden",onChange:i=>W(e.name,i.target.files)}),L("div",{className:"space-y-2",children:$.map((i,t)=>{let o=Object.values(N).find(s=>s.file===i);return C("div",{className:"flex items-center justify-between p-2 bg-gray-50 rounded",children:[C("div",{className:"flex items-center space-x-2",children:[o&&C(nt,{children:[L("span",{className:"text-sm",children:o.fileName}),C("span",{className:"text-xs text-gray-500",children:["(",E(o.fileSize),")"]})]}),!o&&L("span",{className:"text-sm",children:i.original_name})]}),L("button",{type:"button",onClick:()=>ee(e.name,i),className:"text-red-500 hover:text-red-700 ml-3",children:"Remove"})]},i)})}),Object.entries(N).map(([i,t])=>t.status==="uploading"?C("div",{className:"relative pt-1",children:[C("div",{className:"flex items-center justify-between",children:[C("span",{className:"text-xs font-semibold inline-block text-blue-600",children:["Uploading ",i]}),C("span",{className:"text-xs font-semibold inline-block text-blue-600",children:[t.progress,"%"]})]}),L("div",{className:"overflow-hidden h-2 mt-1 text-xs flex rounded bg-blue-200",children:L("div",{className:"shadow-none flex flex-col text-center whitespace-nowrap text-white justify-center bg-blue-500",style:{width:`${t.progress}%`}})})]},i):null)]}),p&&L("p",{className:"mt-1 text-sm text-red-500",children:p})]},e.name)}var se=st;import{useRef as lt,useEffect as it}from"react";import{jsx as we,jsxs as Ne}from"react/jsx-runtime";function ct({field:e,formValues:n,handleChange:d,handleBlur:g,touched:u,errors:r,charCount:l,setCharCounts:m}){let a=lt(null),p=n[e.name]||"",f=typeof e.disabled=="function"?e.disabled(n):e.disabled||e.readOnly,N=u!=null&&u[e.name]&&(r!=null&&r[e.name])?r[e.name]:null,w=()=>{let k=a.current;k&&(k.style.height="auto",k.style.height=`${k.scrollHeight+2}px`)};it(()=>{w()},[p]);let $=k=>{d(e.name,k.target.value),w(),m&&m(D=>({...D,[e.name]:k.target.value.length}))};return Ne("div",{className:"space-y-2",children:[we("textarea",{...e.props,ref:a,id:e.name,name:e.name,placeholder:e.placeholder||"",value:p,onChange:$,onBlur:()=>g(e.name),disabled:f,maxLength:e.maxLength,rows:e.rows||3,className:`flex w-full rounded-md border px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 resize-none overflow-y-auto ${N?"border-red-500 focus-visible:ring-red-500":"border-input focus-visible:ring-blue-500"} ${f?"bg-gray-50 text-gray-500":"bg-background"}`,style:{minHeight:"80px",maxHeight:"400px"}}),we("div",{className:"flex justify-between items-center",children:e.maxLength&&!e.readOnly&&Ne("span",{className:"text-xs text-gray-500",children:[l||0,"/",e.maxLength," characters"]})})]})}var ke=ct;import"react";import{jsx as Ce,jsxs as mt}from"react/jsx-runtime";function dt({field:e,formValues:n,handleChange:d,handleBlur:g,touched:u,errors:r}){return mt("div",{children:[Ce("input",{type:"datetime-local",value:e.value||"",onChange:l=>d(e.name,l.target.value),onBlur:g,className:"border rounded px-3 py-2 w-full",placeholder:"Select date and time"}),Ce("p",{className:"text-sm text-gray-500 mt-1",children:"Note: Install @mui/x-date-pickers for enhanced date picker functionality"})]})}var Se=dt;import{Separator as ne}from"@radix-ui/react-separator";import{jsx as q,jsxs as pt}from"react/jsx-runtime";function ut({field:e}){return e!=null&&e.label?pt("div",{className:"relative flex items-center py-4",children:[q(ne,{className:"flex-1 h-px bg-gray-300"}),q("span",{className:"px-3 font-medium text-gray-600 bg-white",children:e.label}),q(ne,{className:"flex-1 h-px bg-gray-300"})]}):q(ne,{className:"my-4 h-px bg-gray-300"})}var Fe=ut;import"react";import*as O from"@radix-ui/react-radio-group";import{jsx as z,jsxs as Re}from"react/jsx-runtime";function bt({field:e,formValues:n,handleChange:d,handleBlur:g}){let u=n[e.name]||"",r=typeof e.disabled=="function"?e.disabled(n):e.disabled,l=e.options||[],m=e.inline||!1;return z(O.Root,{value:u,onValueChange:a=>d(e.name,a),onBlur:()=>g(e.name),disabled:r,className:m?"flex flex-wrap gap-4":"space-y-3","aria-label":e.label||e.name,children:l.map(a=>{let p=typeof a=="object"?a.value:a,f=typeof a=="object"?a.label:a,N=typeof a=="object"?a.description:null,w=`${e.name}-${p}`;return Re("div",{className:"relative flex items-start",children:[z("div",{className:"flex h-6 items-center",children:z(O.Item,{value:p,id:w,disabled:r,className:`
14
+ `,children:[i.from?i.to?_("span",{children:[i.from.toLocaleDateString()," \u2013 ",i.to.toLocaleDateString()]}):R("span",{children:i.from.toLocaleDateString()}):R("span",{className:"text-muted-foreground",children:e.placeholder||"Select date range"}),R("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-chevron-down opacity-70",children:R("path",{d:"m6 9 6 6 6-6"})})]})}),_(j.Content,{align:"start",sideOffset:2,className:"z-50 rounded-md border border-gray-200 bg-white p-0 shadow-md w-auto",children:[R(Ze,{mode:"range",selected:i,onSelect:s,showOutsideDays:!0,className:"rounded-md bg-white p-3 text-xs"}),_("div",{className:"flex items-center justify-between gap-2 border-t border-gray-200 p-3",children:[R("button",{type:"button",onClick:n,className:"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 border border-gray-300 bg-white hover:bg-gray-100 hover:text-gray-900 h-9 px-4 py-2",children:"Clear"}),R("button",{type:"button",onClick:()=>d(!1),className:"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 bg-blue-600 text-white hover:bg-blue-700 h-9 px-4 py-2",children:"Done"})]})]})]})})}var be=et;import"react";import{toast as we}from"react-hot-toast";import{Fragment as rt,jsx as $,jsxs as C}from"react/jsx-runtime";function tt({field:e,formValues:c,touched:o,errors:g,fileUploads:u,setFileUploads:d,fileInputRefs:i,handleChange:s,onFieldsChange:n,api_URL:m}){let f=o[e.name]&&g[e.name],x=e.type==="multifile",y=u[e.name]||{},M=c[e.name],N=x?M||[]:[M].filter(Boolean),P=e.disabled&&e.disabled(c),H=`px-4 py-2 bg-gray-100 border rounded hover:bg-gray-200 ${P?"cursor-not-allowed":""}`,D=m?`${m}uploads`:null;!D&&e.uploadEndpoint&&console.error(`api_URL prop is required when using FileField with upload functionality for field "${e.name}"`);let E=l=>{if(l===0)return"0 Bytes";let t=1024,r=["Bytes","KB","MB","GB"],a=Math.floor(Math.log(l)/Math.log(t));return parseFloat((l/Math.pow(t,a)).toFixed(2))+" "+r[a]},w=async(l,t)=>{let r=new FormData;r.append("file",l);let a=await fetch(`${D}`,{method:"POST",body:r});if(!a.ok)throw we.error("Upload failed"),new Error("Upload failed");return await a.json()},S=async(l,t)=>{if(!t)return;if(l.maxSize&&t.size>l.maxSize)throw new Error(`File size must not exceed ${E(l.maxSize)}`);let r=await w(t,l.name),a={...c,[l.name]:r};s(l.name,r),n(a)},Z=async(l,t)=>{let r=c[l.name]||[];if(r.length+t.length>l.maxFiles)throw new Error(`Maximum ${l.maxFiles} files allowed`);t.forEach(k=>{if(l.maxSize&&k.size>l.maxSize)throw new Error(`Each file must not exceed ${E(l.maxSize)}`)});let a=await Promise.all(t.map(k=>w(k,l.name))),p=[...r,...a];s(l.name,p),n({...c,[l.name]:p})},W=async(l,t)=>{let r=Array.from(t);try{e.type==="file"?await S(e,r[0]):e.type==="multifile"&&await Z(e,r),i.current[l]&&(i.current[l].value="")}catch(a){we.error(`Upload failed: ${a.message}`)}},ee=async(l,t)=>{let r;e.type==="file"?r="":r=(c[l]||[]).filter(p=>p!==t),s(l,r),n({...c,[l]:r}),i.current[l]&&(i.current[l].value="")};return C("div",{className:`mb-4 ${e.fieldClass||"col-span-full"}`,children:[C("label",{className:"block font-medium mb-1",children:[e.label,e.required&&$("span",{className:"text-red-500",children:"*"})]}),C("div",{className:"space-y-2",children:[C("div",{className:"items-center space-x-2",children:[C("button",{type:"button",disabled:P,onClick:()=>i.current[e.name].click(),className:H,children:["Choose ",x?"Files":"File"]}),x&&N.length>0&&C("span",{className:"text-sm text-gray-600",children:[N.length," of ",e.maxFiles," files uploaded"]})]}),$("input",{ref:l=>i.current[e.name]=l,type:"file",accept:e.accept,multiple:x,className:"hidden",onChange:l=>W(e.name,l.target.files)}),$("div",{className:"space-y-2",children:N.map((l,t)=>{let r=Object.values(y).find(a=>a.file===l);return C("div",{className:"flex items-center justify-between p-2 bg-gray-50 rounded",children:[C("div",{className:"flex items-center space-x-2",children:[r&&C(rt,{children:[$("span",{className:"text-sm",children:r.fileName}),C("span",{className:"text-xs text-gray-500",children:["(",E(r.fileSize),")"]})]}),!r&&$("span",{className:"text-sm",children:l.original_name})]}),$("button",{type:"button",onClick:()=>ee(e.name,l),className:"text-red-500 hover:text-red-700 ml-3",children:"Remove"})]},l)})}),Object.entries(y).map(([l,t])=>t.status==="uploading"?C("div",{className:"relative pt-1",children:[C("div",{className:"flex items-center justify-between",children:[C("span",{className:"text-xs font-semibold inline-block text-blue-600",children:["Uploading ",l]}),C("span",{className:"text-xs font-semibold inline-block text-blue-600",children:[t.progress,"%"]})]}),$("div",{className:"overflow-hidden h-2 mt-1 text-xs flex rounded bg-blue-200",children:$("div",{className:"shadow-none flex flex-col text-center whitespace-nowrap text-white justify-center bg-blue-500",style:{width:`${t.progress}%`}})})]},l):null)]}),f&&$("p",{className:"mt-1 text-sm text-red-500",children:f})]},e.name)}var ae=tt;import{useRef as ot,useEffect as at}from"react";import{jsx as ve,jsxs as fe}from"react/jsx-runtime";function nt({field:e,formValues:c,handleChange:o,handleBlur:g,touched:u,errors:d,charCount:i,setCharCounts:s}){let n=ot(null),m=c[e.name]||"",f=typeof e.disabled=="function"?e.disabled(c):e.disabled||e.readOnly,x=u!=null&&u[e.name]&&(d!=null&&d[e.name])?d[e.name]:null,y=()=>{let N=n.current;N&&(N.style.height="auto",N.style.height=`${N.scrollHeight+2}px`)};at(()=>{y()},[m]);let M=N=>{o(e.name,N.target.value),y(),s&&s(P=>({...P,[e.name]:N.target.value.length}))};return fe("div",{className:"space-y-2",children:[ve("textarea",{...e.props,ref:n,id:e.name,name:e.name,placeholder:e.placeholder||"",value:m,onChange:M,onBlur:()=>g(e.name),disabled:f,maxLength:e.maxLength,rows:e.rows||3,className:`flex w-full rounded-md border px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 resize-none overflow-y-auto ${x?"border-red-500 focus-visible:ring-red-500":"border-input focus-visible:ring-blue-500"} ${f?"bg-gray-50 text-gray-500":"bg-background"}`,style:{minHeight:"80px",maxHeight:"400px"}}),ve("div",{className:"flex justify-between items-center",children:e.maxLength&&!e.readOnly&&fe("span",{className:"text-xs text-gray-500",children:[i||0,"/",e.maxLength," characters"]})})]})}var xe=nt;import"react";import{jsx as ye,jsxs as st}from"react/jsx-runtime";function it({field:e,formValues:c,handleChange:o,handleBlur:g,touched:u,errors:d}){return st("div",{children:[ye("input",{type:"datetime-local",value:e.value||"",onChange:i=>o(e.name,i.target.value),onBlur:g,className:"border rounded px-3 py-2 w-full",placeholder:"Select date and time"}),ye("p",{className:"text-sm text-gray-500 mt-1",children:"Note: Install @mui/x-date-pickers for enhanced date picker functionality"})]})}var ke=it;import{Separator as ne}from"@radix-ui/react-separator";import{jsx as V,jsxs as ct}from"react/jsx-runtime";function lt({field:e}){return e!=null&&e.label?ct("div",{className:"relative flex items-center py-4",children:[V(ne,{className:"flex-1 h-px bg-gray-300"}),V("span",{className:"px-3 font-medium text-gray-600 bg-white",children:e.label}),V(ne,{className:"flex-1 h-px bg-gray-300"})]}):V(ne,{className:"my-4 h-px bg-gray-300"})}var Ne=lt;import"react";import*as O from"@radix-ui/react-radio-group";import{jsx as T,jsxs as Ce}from"react/jsx-runtime";function dt({field:e,formValues:c,handleChange:o,handleBlur:g}){let u=c[e.name]||"",d=typeof e.disabled=="function"?e.disabled(c):e.disabled,i=e.options||[],s=e.inline||!1;return T(O.Root,{value:u,onValueChange:n=>o(e.name,n),onBlur:()=>g(e.name),disabled:d,className:s?"flex flex-wrap gap-4":"space-y-3","aria-label":e.label||e.name,children:i.map(n=>{let m=typeof n=="object"?n.value:n,f=typeof n=="object"?n.label:n,x=typeof n=="object"?n.description:null,y=`${e.name}-${m}`;return Ce("div",{className:"relative flex items-start",children:[T("div",{className:"flex h-6 items-center",children:T(O.Item,{value:m,id:y,disabled:d,className:`
14
15
  relative size-4 rounded-full border transition-all
15
- ${r?"border-gray-300 bg-gray-100 cursor-not-allowed":"border-gray-300 bg-white hover:border-blue-400 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2"}
16
+ ${d?"border-gray-300 bg-gray-100 cursor-not-allowed":"border-gray-300 bg-white hover:border-blue-400 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2"}
16
17
  data-[state=checked]:border-blue-600 data-[state=checked]:bg-blue-600
17
- `,children:z(O.Indicator,{className:"flex items-center justify-center w-full h-full relative after:content-[''] after:block after:w-1.5 after:h-1.5 after:rounded-full after:bg-white"})})}),Re("div",{className:"ml-3 text-sm",children:[z("label",{htmlFor:w,className:`font-medium ${r?"text-gray-500":"text-gray-900 cursor-pointer"}`,children:f}),N&&!m&&z("p",{className:`text-sm ${r?"text-gray-400":"text-gray-500"}`,children:N})]})]},p)})})}var $e=bt;import"react";import{jsx as Pe,jsxs as ht}from"react/jsx-runtime";function gt({field:e}){let n=e.text||e.label||"",d=e.description||"",g=e.size||"lg",u=e.underline||!1,r=e.align||"left",l=e.className||"",m={sm:"text-base font-semibold",md:"text-lg font-semibold",lg:"text-xl font-bold",xl:"text-2xl font-bold","2xl":"text-3xl font-bold","3xl":"text-4xl font-bold","4xl":"text-5xl font-bold"},a={left:"text-left",center:"text-center",right:"text-right"},p=`
18
- ${m[g]||m.lg}
19
- ${a[r]||a.left}
18
+ `,children:T(O.Indicator,{className:"flex items-center justify-center w-full h-full relative after:content-[''] after:block after:w-1.5 after:h-1.5 after:rounded-full after:bg-white"})})}),Ce("div",{className:"ml-3 text-sm",children:[T("label",{htmlFor:y,className:`font-medium ${d?"text-gray-500":"text-gray-900 cursor-pointer"}`,children:f}),x&&!s&&T("p",{className:`text-sm ${d?"text-gray-400":"text-gray-500"}`,children:x})]})]},m)})})}var Se=dt;import"react";import{jsx as Fe,jsxs as gt}from"react/jsx-runtime";function pt({field:e}){let c=e.text||e.label||"",o=e.description||"",g=e.size||"lg",u=e.underline||!1,d=e.align||"left",i=e.className||"",s={sm:"text-base font-semibold",md:"text-lg font-semibold",lg:"text-xl font-bold",xl:"text-2xl font-bold","2xl":"text-3xl font-bold","3xl":"text-4xl font-bold","4xl":"text-5xl font-bold"},n={left:"text-left",center:"text-center",right:"text-right"},m=`
19
+ ${s[g]||s.lg}
20
+ ${n[d]||n.left}
20
21
  ${u?"border-b-2 border-gray-300 pb-2":""}
21
- ${l}
22
+ ${i}
22
23
  text-gray-900
23
24
  `.trim(),f=`
24
25
  mt-1 text-sm text-gray-600
25
- ${a[r]||a.left}
26
- `.trim();return ht("div",{className:"my-4",children:[Pe("h2",{className:p,children:n}),d&&Pe("p",{className:f,children:d})]})}var Le=gt;import*as U from"@radix-ui/react-popover";import{useState as xt}from"react";import{DayPicker as yt}from"react-day-picker";import"react-day-picker/dist/style.css";import{jsx as I,jsxs as K}from"react/jsx-runtime";function ft({field:e,formValues:n,handleChange:d,handleBlur:g}){let[u,r]=xt(!1),l=n[e.name]??null,m=p=>d(e.name,p),a=()=>d(e.name,null);return I("div",{children:K(U.Root,{open:u,onOpenChange:r,children:[I(U.Trigger,{asChild:!0,children:K("button",{type:"button",id:e.name,"aria-haspopup":"dialog","aria-expanded":u,onClick:()=>r(!0),onKeyDown:p=>p.key==="Enter"&&r(!0),className:`
26
+ ${n[d]||n.left}
27
+ `.trim();return gt("div",{className:"my-4",children:[Fe("h2",{className:m,children:c}),o&&Fe("p",{className:f,children:o})]})}var ze=pt;import*as U from"@radix-ui/react-popover";import{useState as ut}from"react";import{DayPicker as mt}from"react-day-picker";import"react-day-picker/dist/style.css";import{jsx as I,jsxs as Y}from"react/jsx-runtime";function ht({field:e,formValues:c,handleChange:o,handleBlur:g}){let[u,d]=ut(!1),i=c[e.name]??null,s=m=>o(e.name,m),n=()=>o(e.name,null);return I("div",{children:Y(U.Root,{open:u,onOpenChange:d,children:[I(U.Trigger,{asChild:!0,children:Y("button",{type:"button",id:e.name,"aria-haspopup":"dialog","aria-expanded":u,onClick:()=>d(!0),onKeyDown:m=>m.key==="Enter"&&d(!0),className:`
27
28
  inline-flex items-center justify-between gap-2
28
29
  w-full h-9 rounded-md border border-gray-300 bg-white
29
30
  px-3 py-2 text-sm font-normal shadow-sm
30
31
  hover:bg-gray-50 hover:text-gray-900
31
32
  focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2
32
33
  disabled:cursor-not-allowed disabled:opacity-50
33
- `,children:[l?I("span",{children:l.toLocaleDateString()}):I("span",{className:"text-muted-foreground",children:e.placeholder||"Select date"}),I("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-chevron-down opacity-70",children:I("path",{d:"m6 9 6 6 6-6"})})]})}),K(U.Content,{align:"start",sideOffset:2,className:"z-50 rounded-md border border-gray-200 bg-white p-0 shadow-md w-auto",children:[I(yt,{mode:"single",selected:l,onSelect:m,showOutsideDays:!0,className:"rounded-md bg-white p-3 text-xs"}),K("div",{className:"flex items-center justify-between gap-2 border-t border-gray-200 p-3",children:[I("button",{type:"button",onClick:a,className:"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 border border-gray-300 bg-white hover:bg-gray-100 hover:text-gray-900 h-9 px-4 py-2",children:"Clear"}),I("button",{type:"button",onClick:()=>r(!1),className:"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 bg-blue-600 text-white hover:bg-blue-700 h-9 px-4 py-2",children:"Done"})]})]})]})})}var Ie=ft;import vt,{useState as X}from"react";import*as _ from"@radix-ui/react-popover";import{jsx as h,jsxs as M}from"react/jsx-runtime";function wt({field:e,formValues:n,handleChange:d,handleBlur:g}){let[u,r]=X(!1),[l,m]=X("12"),[a,p]=X("00"),[f,N]=X("PM"),w=n[e.name]||"";vt.useEffect(()=>{if(w){let x=w.match(/(\d{1,2}):(\d{2})\s*(AM|PM)/i);x&&(m(x[1].padStart(2,"0")),p(x[2]),N(x[3].toUpperCase()))}},[w]);let $=()=>{let x=`${l}:${a} ${f}`;d(e.name,x),r(!1)},k=()=>{d(e.name,""),m("12"),p("00"),N("PM")},D=()=>{let x=parseInt(l);m((x%12+1).toString().padStart(2,"0"))},H=()=>{let x=parseInt(l);m((x===1?12:x-1).toString().padStart(2,"0"))},E=()=>{let x=parseInt(a);p(((x+5)%60).toString().padStart(2,"0"))},T=()=>{let x=parseInt(a);p((x===0?55:x-5).toString().padStart(2,"0"))};return h("div",{children:M(_.Root,{open:u,onOpenChange:r,children:[h(_.Trigger,{asChild:!0,children:M("button",{type:"button",id:e.name,"aria-haspopup":"dialog","aria-expanded":u,onClick:()=>r(!0),className:`
34
+ `,children:[i?I("span",{children:i.toLocaleDateString()}):I("span",{className:"text-muted-foreground",children:e.placeholder||"Select date"}),I("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-chevron-down opacity-70",children:I("path",{d:"m6 9 6 6 6-6"})})]})}),Y(U.Content,{align:"start",sideOffset:2,className:"z-50 rounded-md border border-gray-200 bg-white p-0 shadow-md w-auto",children:[I(mt,{mode:"single",selected:i,onSelect:s,showOutsideDays:!0,className:"rounded-md bg-white p-3 text-xs"}),Y("div",{className:"flex items-center justify-between gap-2 border-t border-gray-200 p-3",children:[I("button",{type:"button",onClick:n,className:"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 border border-gray-300 bg-white hover:bg-gray-100 hover:text-gray-900 h-9 px-4 py-2",children:"Clear"}),I("button",{type:"button",onClick:()=>d(!1),className:"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 bg-blue-600 text-white hover:bg-blue-700 h-9 px-4 py-2",children:"Done"})]})]})]})})}var Re=ht;import bt,{useState as K}from"react";import*as A from"@radix-ui/react-popover";import{jsx as b,jsxs as L}from"react/jsx-runtime";function wt({field:e,formValues:c,handleChange:o,handleBlur:g}){let[u,d]=K(!1),[i,s]=K("12"),[n,m]=K("00"),[f,x]=K("PM"),y=c[e.name]||"";bt.useEffect(()=>{if(y){let w=y.match(/(\d{1,2}):(\d{2})\s*(AM|PM)/i);w&&(s(w[1].padStart(2,"0")),m(w[2]),x(w[3].toUpperCase()))}},[y]);let M=()=>{let w=`${i}:${n} ${f}`;o(e.name,w),d(!1)},N=()=>{o(e.name,""),s("12"),m("00"),x("PM")},P=()=>{let w=parseInt(i);s((w%12+1).toString().padStart(2,"0"))},H=()=>{let w=parseInt(i);s((w===1?12:w-1).toString().padStart(2,"0"))},D=()=>{let w=parseInt(n);m(((w+5)%60).toString().padStart(2,"0"))},E=()=>{let w=parseInt(n);m((w===0?55:w-5).toString().padStart(2,"0"))};return b("div",{children:L(A.Root,{open:u,onOpenChange:d,children:[b(A.Trigger,{asChild:!0,children:L("button",{type:"button",id:e.name,"aria-haspopup":"dialog","aria-expanded":u,onClick:()=>d(!0),className:`
34
35
  inline-flex items-center justify-between gap-2
35
36
  w-full h-9 rounded-md border border-gray-300 bg-white
36
37
  px-3 py-2 text-sm font-normal shadow-sm
37
38
  hover:bg-gray-50 hover:text-gray-900
38
39
  focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2
39
40
  disabled:cursor-not-allowed disabled:opacity-50
40
- `,children:[w?h("span",{children:w}):h("span",{className:"text-gray-400",children:e.placeholder||"Select time"}),M("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-clock opacity-70",children:[h("circle",{cx:"12",cy:"12",r:"10"}),h("polyline",{points:"12 6 12 12 16 14"})]})]})}),h(_.Content,{align:"start",sideOffset:2,className:"z-50 rounded-md border border-gray-200 bg-white p-4 shadow-md w-64",children:M("div",{className:"flex flex-col gap-4",children:[M("div",{className:"flex items-center justify-center gap-2",children:[M("div",{className:"flex flex-col items-center",children:[h("button",{type:"button",onClick:D,className:"p-1 hover:bg-gray-100 rounded",children:h("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:h("polyline",{points:"18 15 12 9 6 15"})})}),h("input",{type:"text",value:l,onChange:x=>{let S=x.target.value.replace(/\D/g,"");(S===""||parseInt(S)>=1&&parseInt(S)<=12)&&m(S.padStart(2,"0"))},className:"w-14 text-center text-2xl font-semibold border-0 focus:outline-none focus:ring-2 focus:ring-blue-500 rounded py-2",maxLength:"2"}),h("button",{type:"button",onClick:H,className:"p-1 hover:bg-gray-100 rounded",children:h("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:h("polyline",{points:"6 9 12 15 18 9"})})})]}),h("span",{className:"text-2xl font-semibold",children:":"}),M("div",{className:"flex flex-col items-center",children:[h("button",{type:"button",onClick:E,className:"p-1 hover:bg-gray-100 rounded",children:h("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:h("polyline",{points:"18 15 12 9 6 15"})})}),h("input",{type:"text",value:a,onChange:x=>{let S=x.target.value.replace(/\D/g,"");(S===""||parseInt(S)>=0&&parseInt(S)<=59)&&p(S.padStart(2,"0"))},className:"w-14 text-center text-2xl font-semibold border-0 focus:outline-none focus:ring-2 focus:ring-blue-500 rounded py-2",maxLength:"2"}),h("button",{type:"button",onClick:T,className:"p-1 hover:bg-gray-100 rounded",children:h("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:h("polyline",{points:"6 9 12 15 18 9"})})})]}),M("div",{className:"flex flex-col gap-1 ml-2",children:[h("button",{type:"button",onClick:()=>N("AM"),className:`
41
+ `,children:[y?b("span",{children:y}):b("span",{className:"text-gray-400",children:e.placeholder||"Select time"}),L("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-clock opacity-70",children:[b("circle",{cx:"12",cy:"12",r:"10"}),b("polyline",{points:"12 6 12 12 16 14"})]})]})}),b(A.Content,{align:"start",sideOffset:2,className:"z-50 rounded-md border border-gray-200 bg-white p-4 shadow-md w-64",children:L("div",{className:"flex flex-col gap-4",children:[L("div",{className:"flex items-center justify-center gap-2",children:[L("div",{className:"flex flex-col items-center",children:[b("button",{type:"button",onClick:P,className:"p-1 hover:bg-gray-100 rounded",children:b("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:b("polyline",{points:"18 15 12 9 6 15"})})}),b("input",{type:"text",value:i,onChange:w=>{let S=w.target.value.replace(/\D/g,"");(S===""||parseInt(S)>=1&&parseInt(S)<=12)&&s(S.padStart(2,"0"))},className:"w-14 text-center text-2xl font-semibold border-0 focus:outline-none focus:ring-2 focus:ring-blue-500 rounded py-2",maxLength:"2"}),b("button",{type:"button",onClick:H,className:"p-1 hover:bg-gray-100 rounded",children:b("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:b("polyline",{points:"6 9 12 15 18 9"})})})]}),b("span",{className:"text-2xl font-semibold",children:":"}),L("div",{className:"flex flex-col items-center",children:[b("button",{type:"button",onClick:D,className:"p-1 hover:bg-gray-100 rounded",children:b("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:b("polyline",{points:"18 15 12 9 6 15"})})}),b("input",{type:"text",value:n,onChange:w=>{let S=w.target.value.replace(/\D/g,"");(S===""||parseInt(S)>=0&&parseInt(S)<=59)&&m(S.padStart(2,"0"))},className:"w-14 text-center text-2xl font-semibold border-0 focus:outline-none focus:ring-2 focus:ring-blue-500 rounded py-2",maxLength:"2"}),b("button",{type:"button",onClick:E,className:"p-1 hover:bg-gray-100 rounded",children:b("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:b("polyline",{points:"6 9 12 15 18 9"})})})]}),L("div",{className:"flex flex-col gap-1 ml-2",children:[b("button",{type:"button",onClick:()=>x("AM"),className:`
41
42
  px-3 py-1 text-sm font-medium rounded
42
43
  ${f==="AM"?"bg-blue-600 text-white":"bg-gray-100 text-gray-700 hover:bg-gray-200"}
43
- `,children:"AM"}),h("button",{type:"button",onClick:()=>N("PM"),className:`
44
+ `,children:"AM"}),b("button",{type:"button",onClick:()=>x("PM"),className:`
44
45
  px-3 py-1 text-sm font-medium rounded
45
46
  ${f==="PM"?"bg-blue-600 text-white":"bg-gray-100 text-gray-700 hover:bg-gray-200"}
46
- `,children:"PM"})]})]}),M("div",{className:"flex items-center justify-between gap-2 border-t border-gray-200 pt-3",children:[h("button",{type:"button",onClick:k,className:"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 border border-gray-300 bg-white hover:bg-gray-100 hover:text-gray-900 h-9 px-4 py-2",children:"Clear"}),h("button",{type:"button",onClick:$,className:"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 bg-blue-600 text-white hover:bg-blue-700 h-9 px-4 py-2",children:"Done"})]})]})})]})})}var Me=wt;import"react";import{InformationCircleIcon as Nt,XCircleIcon as kt}from"@heroicons/react/20/solid";import{CheckCircleIcon as Ct}from"@heroicons/react/20/solid";import{ExclamationCircleIcon as St}from"@heroicons/react/24/outline";import{jsx as R,jsxs as J}from"react/jsx-runtime";function Ee({message:e}){return R("div",{className:"rounded-lg bg-red-50 border border-red-100 p-4 shadow-sm",children:J("div",{className:"flex items-center gap-3",children:[R(kt,{"aria-hidden":"true",className:"size-5 text-red-500 shrink-0"}),R("span",{className:"text-sm font-medium text-red-900",children:e})]})})}function Be({message:e}){return R("div",{className:"rounded-lg bg-amber-50 border border-amber-100 p-4 shadow-sm",children:J("div",{className:"flex items-center gap-3",children:[R(St,{"aria-hidden":"true",className:"size-5 text-amber-600 shrink-0"}),R("span",{className:"text-sm font-medium text-amber-900",children:e})]})})}function De({message:e}){return R("div",{className:"rounded-lg bg-green-50 border border-green-100 p-4 shadow-sm",children:J("div",{className:"flex items-center gap-3",children:[R(Ct,{"aria-hidden":"true",className:"size-5 text-green-600 shrink-0"}),R("span",{className:"text-sm font-medium text-green-900",children:e})]})})}function Te({message:e}){return R("div",{className:"rounded-lg bg-blue-50 border border-blue-100 p-4 shadow-sm",children:J("div",{className:"flex items-center gap-3",children:[R(Nt,{"aria-hidden":"true",className:"size-5 text-blue-600 shrink-0"}),R("span",{className:"text-sm font-medium text-blue-900",children:e})]})})}import{jsx as Q}from"react/jsx-runtime";function Ft({field:e}){let{variant:n="info",message:d,content:g}=e,u=d||g||"";switch(n.toLowerCase()){case"error":case"danger":return Q(Ee,{message:u});case"success":return Q(De,{message:u});case"warning":case"warn":return Q(Be,{message:u});case"info":case"information":default:return Q(Te,{message:u})}}var Ae=Ft;import{Label as Pt}from"@radix-ui/react-label";import{Fragment as It,jsx as B,jsxs as le}from"react/jsx-runtime";var Lt=({formDefinition:e,sendFormValues:n,children:d,defaultValues:g={},onFieldsChange:u=()=>{}})=>{let[r,l]=Z({...g}),[m,a]=Z({}),[p,f]=Z({}),[N,w]=Z({}),$=["hidden","html","linebreak","header","alert"],k=Rt(()=>({file:se,multifile:se,dateRange:fe,date:Ie,dayTimePicker:Se,time:Me,hidden:me,multiselect:ue,select:pe,email:be,litertext:he,checkbox:ye,radiogroup:$e,input:re,textarea:ke,header:Le,alert:Ae,linebreak:Fe}),[]),D={},H=async(t,o=null)=>{try{let s=await de(`/${t.optionsUrl}`);console.log(s);let c=[];t.type==="select"?c=[{value:"",label:`Select ${t.label.toLowerCase()}`},...s.data]:c=[...s.data.map(v=>({value:v.value,label:v.label}))],e.fields.forEach(v=>{v.name===t.name&&(v.options=c)})}catch(s){console.error(`Failed to load options for ${t.name}:`,s)}finally{}};ze(()=>{if(e!=null&&e.fields&&e.fields.length>0){if(!e.fields.some(s=>s.value))return;e.fields.forEach(s=>{s.optionsUrl&&H(s)});let o={};e.fields.forEach(s=>{o[s.name]=g[s.name]??s.value??(s.type==="multiselect"?[]:"")}),l(o)}},[e]);let E=(t,o,s)=>{if(t.disabled&&t.disabled(s))return null;if(t.required){if(!o)return`${t.label} is required`;if(Array.isArray(o)&&o.length===0)return`Please select at least one ${t.label.toLowerCase()}`}if(t.validate){let c=t.validate(o,s);if(c)return c}if(t.type==="email"&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o))return"Please enter a valid email address";if(t.type==="number"){if(t.min!==void 0&&o<t.min)return`${t.label} must be at least ${t.min}`;if(t.max!==void 0&&o>t.max)return`${t.label} must be no more than ${t.max}`}return t.type==="date"&&!Oe(o).isValid()?`${t.label} must be a valid date`:t.maxLength&&o&&o.length>t.maxLength?`${t.label} must not exceed ${t.maxLength} characters`:null},T=(t,o)=>{let s=e.fields.find(y=>y.name===t);if(!s)return;let c={...r};console.log(o),s.type==="multiselect"?c[t]=Array.isArray(o)?o:Array.from(o.target.selectedOptions).map(y=>y.value):s.type==="dateRange"?(console.log(o),c[t]=[{startDate:o[0].from,endDate:o[0].to,key:"selection"}]):s.type==="dayTimePicker"?c[t]=o?Oe(o).format("YYYY-MM-DD HH:mm:ss"):"":c[t]=o,s.type==="select"&&e.fields.forEach(y=>{y.showIf&&!y.showIf(c)&&(c[y.name]=y.type==="multiselect"?[]:"")}),e.fields.forEach(y=>{y.disabled&&y.disabled(c)&&(c[y.name]=y.type==="multiselect"?[]:"")}),l(c);let v={};e.fields.forEach(y=>{if(!y.showIf||y.showIf(c)){let j=E(y,c[y.name],c);j&&(v[y.name]=j)}}),a(v)},x=t=>{f({...p,[t]:!0})},S=t=>{t.preventDefault();let o={};e.fields.forEach(c=>{o[c.name]=!0}),f(o);let s={};e.fields.forEach(c=>{if((!c.showIf||c.showIf(r))&&(!c.disabled||!c.disabled(r))){let v=E(c,r[c.name],r);v&&(s[c.name]=v)}}),a(s),Object.keys(s).length===0?n(r):$t.error("Please correct the errors in the form")};ze(()=>{u(r)},[r,u]);let W={green:"border-green-500 bg-green-50",blue:"border-blue-500 bg-blue-50",red:"border-red-500 bg-red-50",yellow:"border-yellow-500 bg-yellow-50",purple:"border-purple-500 bg-purple-50",indigo:"border-indigo-500 bg-indigo-50",gray:"border-gray-500 bg-gray-50",pink:"border-pink-500 bg-pink-50",orange:"border-orange-500 bg-orange-50"};function ee(t,o,s){if($.includes(o.type))return B("div",{className:o.fieldClass||"col-span-8",children:t});let c=o.containerStyle,v=o.color||"blue",y=c==="card"?`rounded-lg border text-card-foreground shadow-sm p-4 ${o.containerClassName||W[v]||W.blue}`:"",j=le(It,{children:[o.label&&le(Pt,{htmlFor:o.name,className:"block text-sm font-medium mb-1",children:[o.label,o.required&&B("span",{className:"text-red-500 ml-1",children:"*"})]}),B("div",{children:t}),s&&B("p",{className:"mt-1 text-sm text-red-500",children:s})]});return B("div",{className:`mb-4 ${o.fieldClass||"col-span-8"}`,children:c==="card"?B("div",{className:y,children:j}):j})}let i=t=>{if(t.showIf&&!t.showIf(r))return null;let o=k[t.type]||re;r[t.name]===void 0&&(r[t.name]=t.value!==void 0?t.value:t.type==="multiselect"?[]:"");let s=p[t.name]&&m[t.name]?m[t.name]:null;return ee(B(o,{field:t,formValues:r,handleChange:T,handleBlur:()=>x(t.name),setCharCounts:w,charCount:N[t.name]||0}),t)};return le("form",{onSubmit:S,className:"grid grid-cols-12 gap-x-4 mx-auto",children:[e?e.fields.map(i):B("div",{children:"Loading..."}),d]})},ie=Lt;var Mr=ie;export{ie as DynamicForm,ie as DynamicFormComponent,te as MyButton,te as MyButtonComponent,Mr as default};
47
+ `,children:"PM"})]})]}),L("div",{className:"flex items-center justify-between gap-2 border-t border-gray-200 pt-3",children:[b("button",{type:"button",onClick:N,className:"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 border border-gray-300 bg-white hover:bg-gray-100 hover:text-gray-900 h-9 px-4 py-2",children:"Clear"}),b("button",{type:"button",onClick:M,className:"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 bg-blue-600 text-white hover:bg-blue-700 h-9 px-4 py-2",children:"Done"})]})]})})]})})}var $e=wt;import"react";import{InformationCircleIcon as vt,XCircleIcon as ft}from"@heroicons/react/20/solid";import{CheckCircleIcon as xt}from"@heroicons/react/20/solid";import{ExclamationCircleIcon as yt}from"@heroicons/react/24/outline";import{jsx as z,jsxs as X}from"react/jsx-runtime";function Ie({message:e}){return z("div",{className:"rounded-lg bg-red-50 border border-red-100 p-4 shadow-sm",children:X("div",{className:"flex items-center gap-3",children:[z(ft,{"aria-hidden":"true",className:"size-5 text-red-500 shrink-0"}),z("span",{className:"text-sm font-medium text-red-900",children:e})]})})}function Le({message:e}){return z("div",{className:"rounded-lg bg-amber-50 border border-amber-100 p-4 shadow-sm",children:X("div",{className:"flex items-center gap-3",children:[z(yt,{"aria-hidden":"true",className:"size-5 text-amber-600 shrink-0"}),z("span",{className:"text-sm font-medium text-amber-900",children:e})]})})}function Me({message:e}){return z("div",{className:"rounded-lg bg-green-50 border border-green-100 p-4 shadow-sm",children:X("div",{className:"flex items-center gap-3",children:[z(xt,{"aria-hidden":"true",className:"size-5 text-green-600 shrink-0"}),z("span",{className:"text-sm font-medium text-green-900",children:e})]})})}function Pe({message:e}){return z("div",{className:"rounded-lg bg-blue-50 border border-blue-100 p-4 shadow-sm",children:X("div",{className:"flex items-center gap-3",children:[z(vt,{"aria-hidden":"true",className:"size-5 text-blue-600 shrink-0"}),z("span",{className:"text-sm font-medium text-blue-900",children:e})]})})}import{jsx as J}from"react/jsx-runtime";function kt({field:e}){let{variant:c="info",message:o,content:g}=e,u=o||g||"";switch(c.toLowerCase()){case"error":case"danger":return J(Ie,{message:u});case"success":return J(Me,{message:u});case"warning":case"warn":return J(Le,{message:u});case"info":case"information":default:return J(Pe,{message:u})}}var Ee=kt;import{Label as Ct}from"@radix-ui/react-label";import{Fragment as Ft,jsx as B,jsxs as ie}from"react/jsx-runtime";var St=({apiClient:e,api_URL:c,formDefinition:o,sendFormValues:g,children:u,defaultValues:d={},onFieldsChange:i=()=>{}})=>{let[s,n]=Q({...d}),[m,f]=Q({}),[x,y]=Q({}),[M,N]=Q({}),P=["hidden","html","linebreak","header","alert"],H=Nt(()=>({file:ae,multifile:ae,dateRange:be,date:Re,dayTimePicker:ke,time:$e,hidden:le,multiselect:ce,select:de,email:pe,litertext:ue,checkbox:he,radiogroup:Se,input:re,textarea:xe,header:ze,alert:Ee,linebreak:Ne}),[]),D=async(t,r=null)=>{if(!e){let a=`apiClient prop is required when using fields with optionsUrl. Field "${t.name}" requires optionsUrl but no apiClient was provided.`;console.error(a),De.error(a);return}try{let a=await e(`/${t.optionsUrl}`),p=[];t.type==="select"?p=[{value:"",label:`Select ${t.label.toLowerCase()}`},...a.data]:p=[...a.data.map(k=>({value:k.value,label:k.label}))],o.fields.forEach(k=>{k.name===t.name&&(k.options=p)})}catch(a){console.error(`Failed to load options for ${t.name}:`,a)}finally{}};Be(()=>{if(o!=null&&o.fields&&o.fields.length>0){if(!o.fields.some(a=>a.value))return;o.fields.forEach(a=>{a.optionsUrl&&D(a)});let r={};o.fields.forEach(a=>{r[a.name]=d[a.name]??a.value??(a.type==="multiselect"?[]:"")}),n(r)}},[o]);let E=(t,r,a)=>{if(t.disabled&&t.disabled(a))return null;if(t.required){if(!r)return`${t.label} is required`;if(Array.isArray(r)&&r.length===0)return`Please select at least one ${t.label.toLowerCase()}`}if(t.validate){let p=t.validate(r,a);if(p)return p}if(t.type==="email"&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(r))return"Please enter a valid email address";if(t.type==="number"){if(t.min!==void 0&&r<t.min)return`${t.label} must be at least ${t.min}`;if(t.max!==void 0&&r>t.max)return`${t.label} must be no more than ${t.max}`}return t.type==="date"&&!je(r).isValid()?`${t.label} must be a valid date`:t.maxLength&&r&&r.length>t.maxLength?`${t.label} must not exceed ${t.maxLength} characters`:null},w=(t,r)=>{let a=o.fields.find(v=>v.name===t);if(!a)return;let p={...s};a.type==="multiselect"?p[t]=Array.isArray(r)?r:Array.from(r.target.selectedOptions).map(v=>v.value):a.type==="dateRange"?p[t]=[{startDate:r[0].from,endDate:r[0].to,key:"selection"}]:a.type==="dayTimePicker"?p[t]=r?je(r).format("YYYY-MM-DD HH:mm:ss"):"":p[t]=r,a.type==="select"&&o.fields.forEach(v=>{v.showIf&&!v.showIf(p)&&(p[v.name]=v.type==="multiselect"?[]:"")}),o.fields.forEach(v=>{v.disabled&&v.disabled(p)&&(p[v.name]=v.type==="multiselect"?[]:"")}),n(p);let k={};o.fields.forEach(v=>{if(!v.showIf||v.showIf(p)){let G=E(v,p[v.name],p);G&&(k[v.name]=G)}}),f(k)},S=t=>{y({...x,[t]:!0})},Z=t=>{t.preventDefault();let r={};o.fields.forEach(p=>{r[p.name]=!0}),y(r);let a={};o.fields.forEach(p=>{if((!p.showIf||p.showIf(s))&&(!p.disabled||!p.disabled(s))){let k=E(p,s[p.name],s);k&&(a[p.name]=k)}}),f(a),Object.keys(a).length===0?g(s):De.error("Please correct the errors in the form")};Be(()=>{i(s)},[s,i]);let W={green:"border-green-500 bg-green-50",blue:"border-blue-500 bg-blue-50",red:"border-red-500 bg-red-50",yellow:"border-yellow-500 bg-yellow-50",purple:"border-purple-500 bg-purple-50",indigo:"border-indigo-500 bg-indigo-50",gray:"border-gray-500 bg-gray-50",pink:"border-pink-500 bg-pink-50",orange:"border-orange-500 bg-orange-50"};function ee(t,r,a){if(P.includes(r.type))return B("div",{className:r.fieldClass||"col-span-8",children:t});let p=r.containerStyle,k=r.color||"blue",v=p==="card"?`rounded-lg border text-card-foreground shadow-sm p-4 ${r.containerClassName||W[k]||W.blue}`:"",G=ie(Ft,{children:[r.label&&ie(Ct,{htmlFor:r.name,className:"block text-sm font-medium mb-1",children:[r.label,r.required&&B("span",{className:"text-red-500 ml-1",children:"*"})]}),B("div",{children:t}),a&&B("p",{className:"mt-1 text-sm text-red-500",children:a})]});return B("div",{className:`mb-4 ${r.fieldClass||"col-span-8"}`,children:p==="card"?B("div",{className:v,children:G}):G})}let l=t=>{if(t.showIf&&!t.showIf(s))return null;let r=H[t.type]||re;s[t.name]===void 0&&(s[t.name]=t.value!==void 0?t.value:t.type==="multiselect"?[]:"");let a=x[t.name]&&m[t.name]?m[t.name]:null;return ee(B(r,{field:t,formValues:s,handleChange:w,handleBlur:()=>S(t.name),setCharCounts:N,charCount:M[t.name]||0,api_URL:c}),t)};return ie("form",{onSubmit:Z,className:"grid grid-cols-12 gap-x-4 mx-auto",children:[o?o.fields.map(l):B("div",{children:"Loading..."}),u]})},se=St;var xo=se;export{se as DynamicForm,se as DynamicFormComponent,xo as default};
47
48
  //# sourceMappingURL=index.js.map