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.cjs +21 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +17 -16
- package/dist/index.js.map +1 -1
- package/package.json +19 -16
package/dist/index.cjs
CHANGED
|
@@ -1,47 +1,48 @@
|
|
|
1
|
-
var Je=Object.create;var Q=Object.defineProperty;var Qe=Object.getOwnPropertyDescriptor;var Ze=Object.getOwnPropertyNames;var et=Object.getPrototypeOf,tt=Object.prototype.hasOwnProperty;var ot=(e,r)=>{for(var c in r)Q(e,c,{get:r[c],enumerable:!0})},ue=(e,r,c,g)=>{if(r&&typeof r=="object"||typeof r=="function")for(let d of Ze(r))!tt.call(e,d)&&d!==c&&Q(e,d,{get:()=>r[d],enumerable:!(g=Qe(r,d))||g.enumerable});return e};var I=(e,r,c)=>(c=e!=null?Je(et(e)):{},ue(r||!e||!e.__esModule?Q(c,"default",{value:e,enumerable:!0}):c,e)),rt=e=>ue(Q({},"__esModule",{value:!0}),e);var kt={};ot(kt,{DynamicForm:()=>se,DynamicFormComponent:()=>se,MyButton:()=>Z,MyButtonComponent:()=>Z,default:()=>Nt});module.exports=rt(kt);var pe=require("react/jsx-runtime");function Z({children:e,onClick:r}){return(0,pe.jsx)("button",{onClick:r,children:e})}var E=require("react"),Ke=require("react-hot-toast"),me=I(require("dayjs"),1);var be=I(require("axios"),1),te=I(require("react-hot-toast"),1);var ee={REACT_API_URL:"http://localhost:5000/"};var ge=be.default.create({baseURL:ee.REACT_API_URL,headers:{"Content-Type":"application/json"}});ge.interceptors.response.use(e=>e.data,e=>{var r;if(e.response&&e.response.status===403)return te.default.error("You are not authorized to access this resource."),Promise.reject("You are not authorized to access this resource.");if(e.response)return te.default.error("An error occurred"),Promise.reject(((r=e.response.data)==null?void 0:r.message)||"An error occurred");te.default.error(e.message)});var he=ge;var ye=require("react/jsx-runtime");function at(e){return(0,ye.jsx)("input",{type:"hidden",name:e.name,value:e.value},e.name)}var xe=at;var fe=I(require("react-select"),1),ve=I(require("react-select/animated"),1),Ne=require("react/jsx-runtime");function st({field:e,formValues:r,handleChange:c,touched:g,errors:d,handleBlur:a}){let l=e.disabled&&e.disabled(r),p=e.options||[],s=(0,ve.default)(),b=r[e.name]||[];return(0,Ne.jsx)(fe.default,{components:s,isMulti:!0,isDisabled:l,name:e.label,value:b,onChange:v=>c(e.name,v),options:p,placeholder:e.placeholder,closeMenuOnSelect:!1})}var we=st;var h=I(require("@radix-ui/react-select"),1),It=require("react"),ke=require("@heroicons/react/20/solid"),w=require("react/jsx-runtime");function nt({field:e,formValues:r,handleChange:c,handleBlur:g}){var p;let d=r[e.name]||"",a=typeof e.disabled=="function"?e.disabled(r):e.disabled,l=e.options||[];return(0,w.jsxs)(h.Root,{value:d,onValueChange:s=>c(e.name,s),disabled:a,children:[(0,w.jsxs)(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
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
var qe=Object.create;var Q=Object.defineProperty;var Ve=Object.getOwnPropertyDescriptor;var Ye=Object.getOwnPropertyNames;var Ke=Object.getPrototypeOf,Xe=Object.prototype.hasOwnProperty;var Je=(e,a)=>{for(var r in a)Q(e,r,{get:a[r],enumerable:!0})},ge=(e,a,r,m)=>{if(a&&typeof a=="object"||typeof a=="function")for(let g of Ye(a))!Xe.call(e,g)&&g!==r&&Q(e,g,{get:()=>a[g],enumerable:!(m=Ve(a,g))||m.enumerable});return e};var P=(e,a,r)=>(r=e!=null?qe(Ke(e)):{},ge(a||!e||!e.__esModule?Q(r,"default",{value:e,enumerable:!0}):r,e)),Qe=e=>ge(Q({},"__esModule",{value:!0}),e);var vt={};Je(vt,{DynamicForm:()=>re,DynamicFormComponent:()=>re,default:()=>wt});module.exports=Qe(vt);function ne(e,{insertAt:a}={}){if(!e||typeof document>"u")return;let r=document.head||document.getElementsByTagName("head")[0],m=document.createElement("style");m.type="text/css",a==="top"&&r.firstChild?r.insertBefore(m,r.firstChild):r.appendChild(m),m.styleSheet?m.styleSheet.cssText=e:m.appendChild(document.createTextNode(e))}ne(`/*! 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
|
+
`);var M=require("react"),de=require("react-hot-toast"),pe=P(require("dayjs"),1);var me=require("react/jsx-runtime");function Ze(e){return(0,me.jsx)("input",{type:"hidden",name:e.name,value:e.value},e.name)}var ue=Ze;var he=P(require("react-select"),1),be=P(require("react-select/animated"),1),ve=require("react/jsx-runtime");function et({field:e,formValues:a,handleChange:r,touched:m,errors:g,handleBlur:d}){let s=e.disabled&&e.disabled(a),l=e.options||[],i=(0,be.default)(),h=a[e.name]||[];return(0,ve.jsx)(he.default,{components:i,isMulti:!0,isDisabled:s,name:e.label,value:h,onChange:x=>r(e.name,x),options:l,placeholder:e.placeholder,closeMenuOnSelect:!1})}var we=et;var b=P(require("@radix-ui/react-select"),1),Ct=require("react"),fe=require("@heroicons/react/20/solid"),y=require("react/jsx-runtime");function tt({field:e,formValues:a,handleChange:r,handleBlur:m}){var l;let g=a[e.name]||"",d=typeof e.disabled=="function"?e.disabled(a):e.disabled,s=e.options||[];return(0,y.jsxs)(b.Root,{value:g,onValueChange:i=>r(e.name,i),disabled:d,children:[(0,y.jsxs)(b.Trigger,{id:e.name,onBlur:()=>m(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:[(0,y.jsx)(b.Value,{placeholder:e.placeholder||`Select ${((l=e.label)==null?void 0:l.toLowerCase())||""}`}),(0,y.jsx)(b.Icon,{className:"ml-2 text-gray-500",children:(0,y.jsx)(fe.ChevronDownIcon,{className:"w-4 h-4"})})]}),(0,y.jsx)(b.Portal,{children:(0,y.jsxs)(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:[(0,y.jsx)(b.ScrollUpButton,{className:"flex items-center justify-center h-6 text-gray-500 bg-gray-50",children:(0,y.jsx)(b.Arrow,{className:"fill-white stroke-gray-200"})}),(0,y.jsxs)(b.Viewport,{className:"p-1",children:[e.groupLabel&&(0,y.jsx)(b.Group,{children:(0,y.jsx)(b.Label,{className:"px-2 py-1 text-xs text-gray-500 uppercase tracking-wide",children:e.groupLabel})}),s.map(i=>(0,y.jsx)(b.Item,{value:i.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:(0,
|
|
7
|
+
`,children:(0,y.jsx)(b.ItemText,{children:i.label})},i.value)),e.separator&&(0,y.jsx)(b.Separator,{className:"my-1 h-px bg-gray-200"})]}),(0,y.jsx)(b.Arrow,{className:"fill-white stroke-gray-200"})]})})]})}var xe=tt;var zt=require("react"),ke=require("react/jsx-runtime");function rt({field:e,formValues:a,handleChange:r,handleBlur:m,touched:g,errors:d}){let s=e.readOnly&&e.disabled;return(0,ke.jsx)("input",{...e.props,type:"email",value:a[e.name]||"",onChange:i=>r(e.name,i.target.value),onBlur:()=>m(e.name),disabled:s,name:e.name,placeholder:e.placeholder,className:`w-full px-3 py-2 border rounded-md ${!1?"border-red-500":"border-gray-300"} ${s?"bg-gray-100 text-gray-500 cursor-not-allowed":""}`})}var ye=rt;var It=require("react"),Ne=require("react/jsx-runtime");function ot({field:e,formValues:a,handleChange:r,handleBlur:m,touched:g,errors:d}){let s=e.readOnly||e.disabled;return(0,Ne.jsx)("input",{...e.props,id:e.name,type:e.type||"text",value:a[e.name]||"",onChange:i=>r(e.name,i.target.value),onBlur:()=>m(e.name),disabled:s,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"} ${s?"bg-gray-50 text-gray-500":"bg-background"}`})}var ie=ot;var Pt=require("react"),se=require("react/jsx-runtime");function at({field:e,formValues:a}){let r=a[e.name]||e.content||"";return(0,se.jsx)("div",{className:`mb-4 ${e.fieldClass?e.fieldClass:"col-span-full"}`,id:e.name.toLowerCase()+"_id",children:(0,se.jsx)("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:r}})},e.name)}var Ce=at;var j=require("react/jsx-runtime");function nt({field:e,formValues:a,handleChange:r,handleBlur:m,touched:g,errors:d}){let s=e.disabled&&e.disabled(a),l=!1;return(0,j.jsxs)("div",{className:"mt-1 space-x-2",children:[(0,j.jsx)("input",{...e.props,id:"id_"+e.name,type:"checkbox",checked:a[e.name]||!1,onChange:i=>r(e.name,i.target.checked),onBlur:()=>m(e.name),disabled:s,className:`rounded border-gray-300 ${s?"opacity-50 cursor-not-allowed":""}`}),(0,j.jsxs)("label",{className:"",htmlFor:"id_"+e.name,children:[e.label,e.required&&(0,j.jsx)("span",{className:"text-red-500",children:"*"})]}),l&&(0,j.jsx)("p",{className:"mt-1 text-sm text-red-500",children:l})]})}var Se=nt;var A=P(require("@radix-ui/react-popover"),1),Fe=require("react"),ze=require("react-day-picker"),jt=require("react-day-picker/dist/style.css"),F=require("react/jsx-runtime");function it({field:e,formValues:a,handleChange:r,handleBlur:m}){let[g,d]=(0,Fe.useState)(!1),s=a[e.name]??{from:null,to:null},l=h=>r(e.name,h),i=()=>r(e.name,{from:null,to:null});return(0,F.jsx)("div",{children:(0,F.jsxs)(A.Root,{open:g,onOpenChange:d,children:[(0,F.jsx)(A.Trigger,{asChild:!0,children:(0,F.jsxs)("button",{type:"button",id:e.name,"aria-haspopup":"dialog","aria-expanded":g,onClick:()=>d(!0),onKeyDown:h=>h.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:[
|
|
14
|
+
`,children:[s.from?s.to?(0,F.jsxs)("span",{children:[s.from.toLocaleDateString()," \u2013 ",s.to.toLocaleDateString()]}):(0,F.jsx)("span",{children:s.from.toLocaleDateString()}):(0,F.jsx)("span",{className:"text-muted-foreground",children:e.placeholder||"Select date range"}),(0,F.jsx)("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:(0,F.jsx)("path",{d:"m6 9 6 6 6-6"})})]})}),(0,F.jsxs)(A.Content,{align:"start",sideOffset:2,className:"z-50 rounded-md border border-gray-200 bg-white p-0 shadow-md w-auto",children:[(0,F.jsx)(ze.DayPicker,{mode:"range",selected:s,onSelect:l,showOutsideDays:!0,className:"rounded-md bg-white p-3 text-xs"}),(0,F.jsxs)("div",{className:"flex items-center justify-between gap-2 border-t border-gray-200 p-3",children:[(0,F.jsx)("button",{type:"button",onClick:i,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"}),(0,F.jsx)("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=it;var Ot=require("react"),le=require("react-hot-toast"),w=require("react/jsx-runtime");function st({field:e,formValues:a,touched:r,errors:m,fileUploads:g,setFileUploads:d,fileInputRefs:s,handleChange:l,onFieldsChange:i,api_URL:h}){let x=r[e.name]&&m[e.name],N=e.type==="multifile",C=g[e.name]||{},E=a[e.name],z=N?E||[]:[E].filter(Boolean),B=e.disabled&&e.disabled(a),q=`px-4 py-2 bg-gray-100 border rounded hover:bg-gray-200 ${B?"cursor-not-allowed":""}`,U=h?`${h}uploads`:null;!U&&e.uploadEndpoint&&console.error(`api_URL prop is required when using FileField with upload functionality for field "${e.name}"`);let D=c=>{if(c===0)return"0 Bytes";let t=1024,o=["Bytes","KB","MB","GB"],n=Math.floor(Math.log(c)/Math.log(t));return parseFloat((c/Math.pow(t,n)).toFixed(2))+" "+o[n]},v=async(c,t)=>{let o=new FormData;o.append("file",c);let n=await fetch(`${U}`,{method:"POST",body:o});if(!n.ok)throw le.toast.error("Upload failed"),new Error("Upload failed");return await n.json()},I=async(c,t)=>{if(!t)return;if(c.maxSize&&t.size>c.maxSize)throw new Error(`File size must not exceed ${D(c.maxSize)}`);let o=await v(t,c.name),n={...a,[c.name]:o};l(c.name,o),i(n)},oe=async(c,t)=>{let o=a[c.name]||[];if(o.length+t.length>c.maxFiles)throw new Error(`Maximum ${c.maxFiles} files allowed`);t.forEach(S=>{if(c.maxSize&&S.size>c.maxSize)throw new Error(`Each file must not exceed ${D(c.maxSize)}`)});let n=await Promise.all(t.map(S=>v(S,c.name))),p=[...o,...n];l(c.name,p),i({...a,[c.name]:p})},J=async(c,t)=>{let o=Array.from(t);try{e.type==="file"?await I(e,o[0]):e.type==="multifile"&&await oe(e,o),s.current[c]&&(s.current[c].value="")}catch(n){le.toast.error(`Upload failed: ${n.message}`)}},ae=async(c,t)=>{let o;e.type==="file"?o="":o=(a[c]||[]).filter(p=>p!==t),l(c,o),i({...a,[c]:o}),s.current[c]&&(s.current[c].value="")};return(0,w.jsxs)("div",{className:`mb-4 ${e.fieldClass||"col-span-full"}`,children:[(0,w.jsxs)("label",{className:"block font-medium mb-1",children:[e.label,e.required&&(0,w.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,w.jsxs)("div",{className:"space-y-2",children:[(0,w.jsxs)("div",{className:"items-center space-x-2",children:[(0,w.jsxs)("button",{type:"button",disabled:B,onClick:()=>s.current[e.name].click(),className:q,children:["Choose ",N?"Files":"File"]}),N&&z.length>0&&(0,w.jsxs)("span",{className:"text-sm text-gray-600",children:[z.length," of ",e.maxFiles," files uploaded"]})]}),(0,w.jsx)("input",{ref:c=>s.current[e.name]=c,type:"file",accept:e.accept,multiple:N,className:"hidden",onChange:c=>J(e.name,c.target.files)}),(0,w.jsx)("div",{className:"space-y-2",children:z.map((c,t)=>{let o=Object.values(C).find(n=>n.file===c);return(0,w.jsxs)("div",{className:"flex items-center justify-between p-2 bg-gray-50 rounded",children:[(0,w.jsxs)("div",{className:"flex items-center space-x-2",children:[o&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)("span",{className:"text-sm",children:o.fileName}),(0,w.jsxs)("span",{className:"text-xs text-gray-500",children:["(",D(o.fileSize),")"]})]}),!o&&(0,w.jsx)("span",{className:"text-sm",children:c.original_name})]}),(0,w.jsx)("button",{type:"button",onClick:()=>ae(e.name,c),className:"text-red-500 hover:text-red-700 ml-3",children:"Remove"})]},c)})}),Object.entries(C).map(([c,t])=>t.status==="uploading"?(0,w.jsxs)("div",{className:"relative pt-1",children:[(0,w.jsxs)("div",{className:"flex items-center justify-between",children:[(0,w.jsxs)("span",{className:"text-xs font-semibold inline-block text-blue-600",children:["Uploading ",c]}),(0,w.jsxs)("span",{className:"text-xs font-semibold inline-block text-blue-600",children:[t.progress,"%"]})]}),(0,w.jsx)("div",{className:"overflow-hidden h-2 mt-1 text-xs flex rounded bg-blue-200",children:(0,w.jsx)("div",{className:"shadow-none flex flex-col text-center whitespace-nowrap text-white justify-center bg-blue-500",style:{width:`${t.progress}%`}})})]},c):null)]}),x&&(0,w.jsx)("p",{className:"mt-1 text-sm text-red-500",children:x})]},e.name)}var ce=st;var Z=require("react"),H=require("react/jsx-runtime");function lt({field:e,formValues:a,handleChange:r,handleBlur:m,touched:g,errors:d,charCount:s,setCharCounts:l}){let i=(0,Z.useRef)(null),h=a[e.name]||"",x=typeof e.disabled=="function"?e.disabled(a):e.disabled||e.readOnly,N=g!=null&&g[e.name]&&(d!=null&&d[e.name])?d[e.name]:null,C=()=>{let z=i.current;z&&(z.style.height="auto",z.style.height=`${z.scrollHeight+2}px`)};(0,Z.useEffect)(()=>{C()},[h]);let E=z=>{r(e.name,z.target.value),C(),l&&l(B=>({...B,[e.name]:z.target.value.length}))};return(0,H.jsxs)("div",{className:"space-y-2",children:[(0,H.jsx)("textarea",{...e.props,ref:i,id:e.name,name:e.name,placeholder:e.placeholder||"",value:h,onChange:E,onBlur:()=>m(e.name),disabled:x,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"} ${x?"bg-gray-50 text-gray-500":"bg-background"}`,style:{minHeight:"80px",maxHeight:"400px"}}),(0,H.jsx)("div",{className:"flex justify-between items-center",children:e.maxLength&&!e.readOnly&&(0,H.jsxs)("span",{className:"text-xs text-gray-500",children:[s||0,"/",e.maxLength," characters"]})})]})}var $e=lt;var _t=require("react"),Y=require("react/jsx-runtime");function ct({field:e,formValues:a,handleChange:r,handleBlur:m,touched:g,errors:d}){return(0,Y.jsxs)("div",{children:[(0,Y.jsx)("input",{type:"datetime-local",value:e.value||"",onChange:s=>r(e.name,s.target.value),onBlur:m,className:"border rounded px-3 py-2 w-full",placeholder:"Select date and time"}),(0,Y.jsx)("p",{className:"text-sm text-gray-500 mt-1",children:"Note: Install @mui/x-date-pickers for enhanced date picker functionality"})]})}var Ie=ct;var ee=require("@radix-ui/react-separator"),T=require("react/jsx-runtime");function dt({field:e}){return e!=null&&e.label?(0,T.jsxs)("div",{className:"relative flex items-center py-4",children:[(0,T.jsx)(ee.Separator,{className:"flex-1 h-px bg-gray-300"}),(0,T.jsx)("span",{className:"px-3 font-medium text-gray-600 bg-white",children:e.label}),(0,T.jsx)(ee.Separator,{className:"flex-1 h-px bg-gray-300"})]}):(0,T.jsx)(ee.Separator,{className:"my-4 h-px bg-gray-300"})}var Le=dt;var Yt=require("react"),G=P(require("@radix-ui/react-radio-group"),1),L=require("react/jsx-runtime");function pt({field:e,formValues:a,handleChange:r,handleBlur:m}){let g=a[e.name]||"",d=typeof e.disabled=="function"?e.disabled(a):e.disabled,s=e.options||[],l=e.inline||!1;return(0,L.jsx)(G.Root,{value:g,onValueChange:i=>r(e.name,i),onBlur:()=>m(e.name),disabled:d,className:l?"flex flex-wrap gap-4":"space-y-3","aria-label":e.label||e.name,children:s.map(i=>{let h=typeof i=="object"?i.value:i,x=typeof i=="object"?i.label:i,N=typeof i=="object"?i.description:null,C=`${e.name}-${h}`;return(0,L.jsxs)("div",{className:"relative flex items-start",children:[(0,L.jsx)("div",{className:"flex h-6 items-center",children:(0,L.jsx)(G.Item,{value:h,id:C,disabled:d,className:`
|
|
14
15
|
relative size-4 rounded-full border transition-all
|
|
15
|
-
${
|
|
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:(0,
|
|
18
|
-
${
|
|
19
|
-
${
|
|
20
|
-
${
|
|
21
|
-
${
|
|
18
|
+
`,children:(0,L.jsx)(G.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"})})}),(0,L.jsxs)("div",{className:"ml-3 text-sm",children:[(0,L.jsx)("label",{htmlFor:C,className:`font-medium ${d?"text-gray-500":"text-gray-900 cursor-pointer"}`,children:x}),N&&!l&&(0,L.jsx)("p",{className:`text-sm ${d?"text-gray-400":"text-gray-500"}`,children:N})]})]},h)})})}var Me=pt;var Jt=require("react"),K=require("react/jsx-runtime");function gt({field:e}){let a=e.text||e.label||"",r=e.description||"",m=e.size||"lg",g=e.underline||!1,d=e.align||"left",s=e.className||"",l={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"},i={left:"text-left",center:"text-center",right:"text-right"},h=`
|
|
19
|
+
${l[m]||l.lg}
|
|
20
|
+
${i[d]||i.left}
|
|
21
|
+
${g?"border-b-2 border-gray-300 pb-2":""}
|
|
22
|
+
${s}
|
|
22
23
|
text-gray-900
|
|
23
|
-
`.trim(),
|
|
24
|
+
`.trim(),x=`
|
|
24
25
|
mt-1 text-sm text-gray-600
|
|
25
|
-
${
|
|
26
|
-
`.trim();return(0,K.jsxs)("div",{className:"my-4",children:[(0,K.jsx)("h2",{className:
|
|
26
|
+
${i[d]||i.left}
|
|
27
|
+
`.trim();return(0,K.jsxs)("div",{className:"my-4",children:[(0,K.jsx)("h2",{className:h,children:a}),r&&(0,K.jsx)("p",{className:x,children:r})]})}var Pe=gt;var _=P(require("@radix-ui/react-popover"),1),Ee=require("react"),Be=require("react-day-picker"),er=require("react-day-picker/dist/style.css"),R=require("react/jsx-runtime");function ut({field:e,formValues:a,handleChange:r,handleBlur:m}){let[g,d]=(0,Ee.useState)(!1),s=a[e.name]??null,l=h=>r(e.name,h),i=()=>r(e.name,null);return(0,R.jsx)("div",{children:(0,R.jsxs)(_.Root,{open:g,onOpenChange:d,children:[(0,R.jsx)(_.Trigger,{asChild:!0,children:(0,R.jsxs)("button",{type:"button",id:e.name,"aria-haspopup":"dialog","aria-expanded":g,onClick:()=>d(!0),onKeyDown:h=>h.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:[
|
|
34
|
+
`,children:[s?(0,R.jsx)("span",{children:s.toLocaleDateString()}):(0,R.jsx)("span",{className:"text-muted-foreground",children:e.placeholder||"Select date"}),(0,R.jsx)("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:(0,R.jsx)("path",{d:"m6 9 6 6 6-6"})})]})}),(0,R.jsxs)(_.Content,{align:"start",sideOffset:2,className:"z-50 rounded-md border border-gray-200 bg-white p-0 shadow-md w-auto",children:[(0,R.jsx)(Be.DayPicker,{mode:"single",selected:s,onSelect:l,showOutsideDays:!0,className:"rounded-md bg-white p-3 text-xs"}),(0,R.jsxs)("div",{className:"flex items-center justify-between gap-2 border-t border-gray-200 p-3",children:[(0,R.jsx)("button",{type:"button",onClick:i,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"}),(0,R.jsx)("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 De=ut;var O=P(require("react"),1),W=P(require("@radix-ui/react-popover"),1),u=require("react/jsx-runtime");function mt({field:e,formValues:a,handleChange:r,handleBlur:m}){let[g,d]=(0,O.useState)(!1),[s,l]=(0,O.useState)("12"),[i,h]=(0,O.useState)("00"),[x,N]=(0,O.useState)("PM"),C=a[e.name]||"";O.default.useEffect(()=>{if(C){let v=C.match(/(\d{1,2}):(\d{2})\s*(AM|PM)/i);v&&(l(v[1].padStart(2,"0")),h(v[2]),N(v[3].toUpperCase()))}},[C]);let E=()=>{let v=`${s}:${i} ${x}`;r(e.name,v),d(!1)},z=()=>{r(e.name,""),l("12"),h("00"),N("PM")},B=()=>{let v=parseInt(s);l((v%12+1).toString().padStart(2,"0"))},q=()=>{let v=parseInt(s);l((v===1?12:v-1).toString().padStart(2,"0"))},U=()=>{let v=parseInt(i);h(((v+5)%60).toString().padStart(2,"0"))},D=()=>{let v=parseInt(i);h((v===0?55:v-5).toString().padStart(2,"0"))};return(0,u.jsx)("div",{children:(0,u.jsxs)(W.Root,{open:g,onOpenChange:d,children:[(0,u.jsx)(W.Trigger,{asChild:!0,children:(0,u.jsxs)("button",{type:"button",id:e.name,"aria-haspopup":"dialog","aria-expanded":g,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:[C?(0,u.jsx)("span",{children:C}):(0,u.jsx)("span",{className:"text-gray-400",children:e.placeholder||"Select time"}),(0,u.jsxs)("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:[(0,u.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,u.jsx)("polyline",{points:"12 6 12 12 16 14"})]})]})}),(0,u.jsx)(W.Content,{align:"start",sideOffset:2,className:"z-50 rounded-md border border-gray-200 bg-white p-4 shadow-md w-64",children:(0,u.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,u.jsxs)("div",{className:"flex items-center justify-center gap-2",children:[(0,u.jsxs)("div",{className:"flex flex-col items-center",children:[(0,u.jsx)("button",{type:"button",onClick:
|
|
41
|
+
`,children:[C?(0,u.jsx)("span",{children:C}):(0,u.jsx)("span",{className:"text-gray-400",children:e.placeholder||"Select time"}),(0,u.jsxs)("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:[(0,u.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,u.jsx)("polyline",{points:"12 6 12 12 16 14"})]})]})}),(0,u.jsx)(W.Content,{align:"start",sideOffset:2,className:"z-50 rounded-md border border-gray-200 bg-white p-4 shadow-md w-64",children:(0,u.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,u.jsxs)("div",{className:"flex items-center justify-center gap-2",children:[(0,u.jsxs)("div",{className:"flex flex-col items-center",children:[(0,u.jsx)("button",{type:"button",onClick:B,className:"p-1 hover:bg-gray-100 rounded",children:(0,u.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,u.jsx)("polyline",{points:"18 15 12 9 6 15"})})}),(0,u.jsx)("input",{type:"text",value:s,onChange:v=>{let I=v.target.value.replace(/\D/g,"");(I===""||parseInt(I)>=1&&parseInt(I)<=12)&&l(I.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"}),(0,u.jsx)("button",{type:"button",onClick:q,className:"p-1 hover:bg-gray-100 rounded",children:(0,u.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,u.jsx)("polyline",{points:"6 9 12 15 18 9"})})})]}),(0,u.jsx)("span",{className:"text-2xl font-semibold",children:":"}),(0,u.jsxs)("div",{className:"flex flex-col items-center",children:[(0,u.jsx)("button",{type:"button",onClick:U,className:"p-1 hover:bg-gray-100 rounded",children:(0,u.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,u.jsx)("polyline",{points:"18 15 12 9 6 15"})})}),(0,u.jsx)("input",{type:"text",value:i,onChange:v=>{let I=v.target.value.replace(/\D/g,"");(I===""||parseInt(I)>=0&&parseInt(I)<=59)&&h(I.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"}),(0,u.jsx)("button",{type:"button",onClick:D,className:"p-1 hover:bg-gray-100 rounded",children:(0,u.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,u.jsx)("polyline",{points:"6 9 12 15 18 9"})})})]}),(0,u.jsxs)("div",{className:"flex flex-col gap-1 ml-2",children:[(0,u.jsx)("button",{type:"button",onClick:()=>N("AM"),className:`
|
|
41
42
|
px-3 py-1 text-sm font-medium rounded
|
|
42
|
-
${
|
|
43
|
-
`,children:"AM"}),(0,u.jsx)("button",{type:"button",onClick:()
|
|
43
|
+
${x==="AM"?"bg-blue-600 text-white":"bg-gray-100 text-gray-700 hover:bg-gray-200"}
|
|
44
|
+
`,children:"AM"}),(0,u.jsx)("button",{type:"button",onClick:()=>N("PM"),className:`
|
|
44
45
|
px-3 py-1 text-sm font-medium rounded
|
|
45
|
-
${
|
|
46
|
-
`,children:"PM"})]})]}),(0,u.jsxs)("div",{className:"flex items-center justify-between gap-2 border-t border-gray-200 pt-3",children:[(0,u.jsx)("button",{type:"button",onClick:
|
|
46
|
+
${x==="PM"?"bg-blue-600 text-white":"bg-gray-100 text-gray-700 hover:bg-gray-200"}
|
|
47
|
+
`,children:"PM"})]})]}),(0,u.jsxs)("div",{className:"flex items-center justify-between gap-2 border-t border-gray-200 pt-3",children:[(0,u.jsx)("button",{type:"button",onClick:z,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"}),(0,u.jsx)("button",{type:"button",onClick:E,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 je=mt;var ar=require("react");var te=require("@heroicons/react/20/solid"),Te=require("@heroicons/react/20/solid"),Oe=require("@heroicons/react/24/outline");var k=require("react/jsx-runtime");function Ue({message:e}){return(0,k.jsx)("div",{className:"rounded-lg bg-red-50 border border-red-100 p-4 shadow-sm",children:(0,k.jsxs)("div",{className:"flex items-center gap-3",children:[(0,k.jsx)(te.XCircleIcon,{"aria-hidden":"true",className:"size-5 text-red-500 shrink-0"}),(0,k.jsx)("span",{className:"text-sm font-medium text-red-900",children:e})]})})}function Ae({message:e}){return(0,k.jsx)("div",{className:"rounded-lg bg-amber-50 border border-amber-100 p-4 shadow-sm",children:(0,k.jsxs)("div",{className:"flex items-center gap-3",children:[(0,k.jsx)(Oe.ExclamationCircleIcon,{"aria-hidden":"true",className:"size-5 text-amber-600 shrink-0"}),(0,k.jsx)("span",{className:"text-sm font-medium text-amber-900",children:e})]})})}function He({message:e}){return(0,k.jsx)("div",{className:"rounded-lg bg-green-50 border border-green-100 p-4 shadow-sm",children:(0,k.jsxs)("div",{className:"flex items-center gap-3",children:[(0,k.jsx)(Te.CheckCircleIcon,{"aria-hidden":"true",className:"size-5 text-green-600 shrink-0"}),(0,k.jsx)("span",{className:"text-sm font-medium text-green-900",children:e})]})})}function Ge({message:e}){return(0,k.jsx)("div",{className:"rounded-lg bg-blue-50 border border-blue-100 p-4 shadow-sm",children:(0,k.jsxs)("div",{className:"flex items-center gap-3",children:[(0,k.jsx)(te.InformationCircleIcon,{"aria-hidden":"true",className:"size-5 text-blue-600 shrink-0"}),(0,k.jsx)("span",{className:"text-sm font-medium text-blue-900",children:e})]})})}var X=require("react/jsx-runtime");function ht({field:e}){let{variant:a="info",message:r,content:m}=e,g=r||m||"";switch(a.toLowerCase()){case"error":case"danger":return(0,X.jsx)(Ue,{message:g});case"success":return(0,X.jsx)(He,{message:g});case"warning":case"warn":return(0,X.jsx)(Ae,{message:g});case"info":case"information":default:return(0,X.jsx)(Ge,{message:g})}}var _e=ht;var We=require("@radix-ui/react-label"),$=require("react/jsx-runtime"),bt=({apiClient:e,api_URL:a,formDefinition:r,sendFormValues:m,children:g,defaultValues:d={},onFieldsChange:s=()=>{}})=>{let[l,i]=(0,M.useState)({...d}),[h,x]=(0,M.useState)({}),[N,C]=(0,M.useState)({}),[E,z]=(0,M.useState)({}),B=["hidden","html","linebreak","header","alert"],q=(0,M.useMemo)(()=>({file:ce,multifile:ce,dateRange:Re,date:De,dayTimePicker:Ie,time:je,hidden:ue,multiselect:we,select:xe,email:ye,litertext:Ce,checkbox:Se,radiogroup:Me,input:ie,textarea:$e,header:Pe,alert:_e,linebreak:Le}),[]),U=async(t,o=null)=>{if(!e){let n=`apiClient prop is required when using fields with optionsUrl. Field "${t.name}" requires optionsUrl but no apiClient was provided.`;console.error(n),de.toast.error(n);return}try{let n=await e(`/${t.optionsUrl}`),p=[];t.type==="select"?p=[{value:"",label:`Select ${t.label.toLowerCase()}`},...n.data]:p=[...n.data.map(S=>({value:S.value,label:S.label}))],r.fields.forEach(S=>{S.name===t.name&&(S.options=p)})}catch(n){console.error(`Failed to load options for ${t.name}:`,n)}finally{}};(0,M.useEffect)(()=>{if(r!=null&&r.fields&&r.fields.length>0){if(!r.fields.some(n=>n.value))return;r.fields.forEach(n=>{n.optionsUrl&&U(n)});let o={};r.fields.forEach(n=>{o[n.name]=d[n.name]??n.value??(n.type==="multiselect"?[]:"")}),i(o)}},[r]);let D=(t,o,n)=>{if(t.disabled&&t.disabled(n))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 p=t.validate(o,n);if(p)return p}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"&&!(0,pe.default)(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},v=(t,o)=>{let n=r.fields.find(f=>f.name===t);if(!n)return;let p={...l};n.type==="multiselect"?p[t]=Array.isArray(o)?o:Array.from(o.target.selectedOptions).map(f=>f.value):n.type==="dateRange"?p[t]=[{startDate:o[0].from,endDate:o[0].to,key:"selection"}]:n.type==="dayTimePicker"?p[t]=o?(0,pe.default)(o).format("YYYY-MM-DD HH:mm:ss"):"":p[t]=o,n.type==="select"&&r.fields.forEach(f=>{f.showIf&&!f.showIf(p)&&(p[f.name]=f.type==="multiselect"?[]:"")}),r.fields.forEach(f=>{f.disabled&&f.disabled(p)&&(p[f.name]=f.type==="multiselect"?[]:"")}),i(p);let S={};r.fields.forEach(f=>{if(!f.showIf||f.showIf(p)){let V=D(f,p[f.name],p);V&&(S[f.name]=V)}}),x(S)},I=t=>{C({...N,[t]:!0})},oe=t=>{t.preventDefault();let o={};r.fields.forEach(p=>{o[p.name]=!0}),C(o);let n={};r.fields.forEach(p=>{if((!p.showIf||p.showIf(l))&&(!p.disabled||!p.disabled(l))){let S=D(p,l[p.name],l);S&&(n[p.name]=S)}}),x(n),Object.keys(n).length===0?m(l):de.toast.error("Please correct the errors in the form")};(0,M.useEffect)(()=>{s(l)},[l,s]);let J={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 ae(t,o,n){if(B.includes(o.type))return(0,$.jsx)("div",{className:o.fieldClass||"col-span-8",children:t});let p=o.containerStyle,S=o.color||"blue",f=p==="card"?`rounded-lg border text-card-foreground shadow-sm p-4 ${o.containerClassName||J[S]||J.blue}`:"",V=(0,$.jsxs)($.Fragment,{children:[o.label&&(0,$.jsxs)(We.Label,{htmlFor:o.name,className:"block text-sm font-medium mb-1",children:[o.label,o.required&&(0,$.jsx)("span",{className:"text-red-500 ml-1",children:"*"})]}),(0,$.jsx)("div",{children:t}),n&&(0,$.jsx)("p",{className:"mt-1 text-sm text-red-500",children:n})]});return(0,$.jsx)("div",{className:`mb-4 ${o.fieldClass||"col-span-8"}`,children:p==="card"?(0,$.jsx)("div",{className:f,children:V}):V})}let c=t=>{if(t.showIf&&!t.showIf(l))return null;let o=q[t.type]||ie;l[t.name]===void 0&&(l[t.name]=t.value!==void 0?t.value:t.type==="multiselect"?[]:"");let n=N[t.name]&&h[t.name]?h[t.name]:null;return ae((0,$.jsx)(o,{field:t,formValues:l,handleChange:v,handleBlur:()=>I(t.name),setCharCounts:z,charCount:E[t.name]||0,api_URL:a}),t)};return(0,$.jsxs)("form",{onSubmit:oe,className:"grid grid-cols-12 gap-x-4 mx-auto",children:[r?r.fields.map(c):(0,$.jsx)("div",{children:"Loading..."}),g]})},re=bt;var wt=re;0&&(module.exports={DynamicForm,DynamicFormComponent});
|
|
47
48
|
//# sourceMappingURL=index.cjs.map
|