ynotsoft-dynamic-form 1.0.53 → 1.0.55
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/dynamic-form.js
CHANGED
|
@@ -7948,8 +7948,7 @@ function fp({
|
|
|
7948
7948
|
"/",
|
|
7949
7949
|
e.maxLength,
|
|
7950
7950
|
" characters"
|
|
7951
|
-
] }) })
|
|
7952
|
-
r && /* @__PURE__ */ u("p", { className: "mt-1 text-sm text-red-500", children: r })
|
|
7951
|
+
] }) })
|
|
7953
7952
|
] });
|
|
7954
7953
|
}
|
|
7955
7954
|
function pp({ field: e, formValues: t, handleChange: n, handleBlur: o, error: r }) {
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
// Ensure focus styling is handled correctly for the button element
|
|
75
75
|
focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-opacity-50
|
|
76
76
|
${d?"bg-gray-50 border-gray-300 text-gray-400 cursor-not-allowed opacity-70":w?"bg-blue-50 border-blue-500 text-blue-600":"bg-white border-gray-300 hover:border-blue-400 hover:bg-gray-50 cursor-pointer"}
|
|
77
|
-
`;return l.jsx("div",{className:`mb-4 ${e.fieldClass||"col-span-full"}`,children:l.jsxs("div",{className:"space-y-3",children:[l.jsxs("button",{type:"button",className:X,onClick:()=>{d||r?.current?.[e.name]?.click()},onDragOver:P,onDragEnter:P,onDragLeave:N,onDrop:j,disabled:d,children:[l.jsx("div",{className:"border-gray-400 border p-1 mb-3 rounded-md bg-gray-100 shadow-md ",children:l.jsx(eu,{size:24,className:"m-1"})}),l.jsxs("p",{className:"text-sm font-normal",children:[l.jsxs("span",{className:d?"text-gray-400":"text-blue-600 hover:text-blue-700 underline",children:["Upload ",f?"Files":"a file"]}),l.jsx("span",{className:"font-light",children:" or drag and drop"})]}),l.jsxs("p",{className:"text-xs mt-1 text-gray-500",children:[K,V,f&&e.maxFiles&&`, Max ${e.maxFiles} files`]})]}),l.jsx("input",{ref:k=>{k&&r&&r.current&&(r.current[e.name]=k)},id:e.name,type:"file",accept:e.accept,multiple:f,className:"sr-only",onChange:k=>E(e.name,k.target.files),disabled:d}),m.length>0&&l.jsx("div",{className:"space-y-2 pt-2 border-t border-gray-200",children:m.map((k,F)=>{const W=k.original_name||k.name||"File",M=k.size||null;return l.jsxs("div",{className:"flex items-center justify-between p-2 bg-gray-50 rounded",children:[l.jsxs("div",{className:"flex items-center space-x-2 min-w-0",children:[l.jsx("span",{className:"text-sm truncate",children:W}),M&&l.jsxs("span",{className:"text-xs text-gray-500 flex-shrink-0",children:["(",x(M),")"]})]}),l.jsx("button",{type:"button",onClick:()=>$(e.name,k),className:`text-red-500 hover:text-red-700 ml-3 flex-shrink-0 ${d?"cursor-not-allowed opacity-50":""}`,disabled:d,children:"Remove"})]},k.url||k.original_name||F)})}),Object.entries(p).map(([k,F])=>F.status==="uploading"?l.jsxs("div",{className:"relative pt-1",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("span",{className:"text-xs font-semibold inline-block text-blue-600",children:["Uploading ",k]}),l.jsxs("span",{className:"text-xs font-semibold inline-block text-blue-600",children:[F.progress,"%"]})]}),l.jsx("div",{className:"overflow-hidden h-2 mt-1 text-xs flex rounded bg-blue-200",children:l.jsx("div",{className:"shadow-none flex flex-col text-center whitespace-nowrap text-white justify-center bg-blue-500",style:{width:`${F.progress}%`}})})]},k):null)]})},e.name)}function Uf({field:e,formValues:t,handleChange:n,handleBlur:o,error:r,charCount:s,setCharCounts:a}){const i=ee.useRef(null),c=t[e.name]||"",d=typeof e.disabled=="function"?e.disabled(t):e.disabled||e.readOnly,f=()=>{const g=i.current;g&&(g.style.height="auto",g.style.height=`${g.scrollHeight+2}px`)};ee.useEffect(()=>{f()},[c]);const p=g=>{n(e.name,g.target.value),f(),a&&a(m=>({...m,[e.name]:g.target.value.length}))};return l.jsxs("div",{className:"space-y-2",children:[l.jsx("textarea",{...e.props,ref:i,id:e.name,name:e.name,placeholder:e.placeholder||"",value:c,onChange:p,onBlur:()=>o(e.name),disabled:d,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 ${r?"border-red-500 focus-visible:ring-red-500":"border-input focus-visible:ring-blue-500"} ${d?"bg-gray-50 text-gray-500":"bg-background"}`,style:{minHeight:"80px",maxHeight:"400px"}}),l.jsx("div",{className:"flex justify-between items-center",children:e.maxLength&&!e.readOnly&&l.jsxs("span",{className:"text-xs text-gray-500",children:[s||0,"/",e.maxLength," characters"]})})
|
|
77
|
+
`;return l.jsx("div",{className:`mb-4 ${e.fieldClass||"col-span-full"}`,children:l.jsxs("div",{className:"space-y-3",children:[l.jsxs("button",{type:"button",className:X,onClick:()=>{d||r?.current?.[e.name]?.click()},onDragOver:P,onDragEnter:P,onDragLeave:N,onDrop:j,disabled:d,children:[l.jsx("div",{className:"border-gray-400 border p-1 mb-3 rounded-md bg-gray-100 shadow-md ",children:l.jsx(eu,{size:24,className:"m-1"})}),l.jsxs("p",{className:"text-sm font-normal",children:[l.jsxs("span",{className:d?"text-gray-400":"text-blue-600 hover:text-blue-700 underline",children:["Upload ",f?"Files":"a file"]}),l.jsx("span",{className:"font-light",children:" or drag and drop"})]}),l.jsxs("p",{className:"text-xs mt-1 text-gray-500",children:[K,V,f&&e.maxFiles&&`, Max ${e.maxFiles} files`]})]}),l.jsx("input",{ref:k=>{k&&r&&r.current&&(r.current[e.name]=k)},id:e.name,type:"file",accept:e.accept,multiple:f,className:"sr-only",onChange:k=>E(e.name,k.target.files),disabled:d}),m.length>0&&l.jsx("div",{className:"space-y-2 pt-2 border-t border-gray-200",children:m.map((k,F)=>{const W=k.original_name||k.name||"File",M=k.size||null;return l.jsxs("div",{className:"flex items-center justify-between p-2 bg-gray-50 rounded",children:[l.jsxs("div",{className:"flex items-center space-x-2 min-w-0",children:[l.jsx("span",{className:"text-sm truncate",children:W}),M&&l.jsxs("span",{className:"text-xs text-gray-500 flex-shrink-0",children:["(",x(M),")"]})]}),l.jsx("button",{type:"button",onClick:()=>$(e.name,k),className:`text-red-500 hover:text-red-700 ml-3 flex-shrink-0 ${d?"cursor-not-allowed opacity-50":""}`,disabled:d,children:"Remove"})]},k.url||k.original_name||F)})}),Object.entries(p).map(([k,F])=>F.status==="uploading"?l.jsxs("div",{className:"relative pt-1",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("span",{className:"text-xs font-semibold inline-block text-blue-600",children:["Uploading ",k]}),l.jsxs("span",{className:"text-xs font-semibold inline-block text-blue-600",children:[F.progress,"%"]})]}),l.jsx("div",{className:"overflow-hidden h-2 mt-1 text-xs flex rounded bg-blue-200",children:l.jsx("div",{className:"shadow-none flex flex-col text-center whitespace-nowrap text-white justify-center bg-blue-500",style:{width:`${F.progress}%`}})})]},k):null)]})},e.name)}function Uf({field:e,formValues:t,handleChange:n,handleBlur:o,error:r,charCount:s,setCharCounts:a}){const i=ee.useRef(null),c=t[e.name]||"",d=typeof e.disabled=="function"?e.disabled(t):e.disabled||e.readOnly,f=()=>{const g=i.current;g&&(g.style.height="auto",g.style.height=`${g.scrollHeight+2}px`)};ee.useEffect(()=>{f()},[c]);const p=g=>{n(e.name,g.target.value),f(),a&&a(m=>({...m,[e.name]:g.target.value.length}))};return l.jsxs("div",{className:"space-y-2",children:[l.jsx("textarea",{...e.props,ref:i,id:e.name,name:e.name,placeholder:e.placeholder||"",value:c,onChange:p,onBlur:()=>o(e.name),disabled:d,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 ${r?"border-red-500 focus-visible:ring-red-500":"border-input focus-visible:ring-blue-500"} ${d?"bg-gray-50 text-gray-500":"bg-background"}`,style:{minHeight:"80px",maxHeight:"400px"}}),l.jsx("div",{className:"flex justify-between items-center",children:e.maxLength&&!e.readOnly&&l.jsxs("span",{className:"text-xs text-gray-500",children:[s||0,"/",e.maxLength," characters"]})})]})}function Wf({field:e,formValues:t,handleChange:n,handleBlur:o,error:r}){const[s,a]=ee.useState(!1),i=t[e.name],c=i?new Date(i):null,d=c?(c.getHours()%12||12).toString().padStart(2,"0"):"12",f=c?c.getMinutes().toString().padStart(2,"0"):"00",p=c?c.getHours()>=12?"PM":"AM":"PM",g=y=>{if(!y){n(e.name,null);return}const E=new Date(y);c?(E.setHours(c.getHours()),E.setMinutes(c.getMinutes())):(E.setHours(12),E.setMinutes(0)),n(e.name,E)},m=(y,E,$)=>{const P=c?new Date(c):new Date;let N=parseInt(y);$==="PM"&&N!==12&&(N+=12),$==="AM"&&N===12&&(N=0),P.setHours(N),P.setMinutes(parseInt(E)),n(e.name,P)},w=()=>{let y=parseInt(d);y=y%12+1,m(y.toString(),f,p)},h=()=>{let y=parseInt(d);y=y===1?12:y-1,m(y.toString(),f,p)},v=()=>{let y=parseInt(f);y=(y+5)%60,m(d,y.toString(),p)},x=()=>{let y=parseInt(f);y=y===0?55:y-5,m(d,y.toString(),p)},S=()=>{m(d,f,p==="AM"?"PM":"AM")},C=()=>n(e.name,null);return l.jsxs("div",{className:"relative",children:[l.jsxs(En,{open:s,onOpenChange:a,children:[l.jsx(An,{asChild:!0,children:l.jsxs("button",{type:"button",id:e.name,"aria-haspopup":"dialog","aria-expanded":s,onClick:()=>a(!0),onKeyDown:y=>y.key==="Enter"&&a(!0),className:`
|
|
78
78
|
group inline-flex items-center justify-between gap-2
|
|
79
79
|
w-full h-10 rounded-lg border bg-white
|
|
80
80
|
px-3 py-2 text-sm font-normal shadow-sm transition-all
|