@sawabona/forms 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/ui/RatingInput.d.ts.map +1 -1
- package/dist/components/ui/SelectInput.d.ts.map +1 -1
- package/dist/components/ui/TextInput.d.ts.map +1 -1
- package/dist/sawabona-forms.css +2 -2
- package/dist/sawabona-forms.es.js +274 -3036
- package/dist/sawabona-forms.umd.js +14 -1
- package/package.json +1 -1
|
@@ -1 +1,14 @@
|
|
|
1
|
-
(function(w,s){typeof exports=="object"&&typeof module!="undefined"?s(exports,require("react/jsx-runtime"),require("react"),require("framer-motion"),require("lucide-react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","framer-motion","lucide-react"],s):(w=typeof globalThis!="undefined"?globalThis:w||self,s(w.SawabonaForms={},w.jsxRuntime,w.React,w.Motion,w.Lucide))})(this,(function(w,s,v,k,Y){"use strict";var Qt=Object.defineProperty,Kt=Object.defineProperties;var Yt=Object.getOwnPropertyDescriptors;var ae=Object.getOwnPropertySymbols;var Qe=Object.prototype.hasOwnProperty,Ke=Object.prototype.propertyIsEnumerable;var He=(w,s,v)=>s in w?Qt(w,s,{enumerable:!0,configurable:!0,writable:!0,value:v}):w[s]=v,T=(w,s)=>{for(var v in s||(s={}))Qe.call(s,v)&&He(w,v,s[v]);if(ae)for(var v of ae(s))Ke.call(s,v)&&He(w,v,s[v]);return w},j=(w,s)=>Kt(w,Yt(s));var Ye=w=>typeof w=="symbol"?w:w+"",Xe=(w,s)=>{var v={};for(var k in w)Qe.call(w,k)&&s.indexOf(k)<0&&(v[k]=w[k]);if(w!=null&&ae)for(var k of ae(w))s.indexOf(k)<0&&Ke.call(w,k)&&(v[k]=w[k]);return v};function Je({schema:e,onSubmit:o}){var N;const[r,t]=v.useState({answers:{},currentStepId:((N=e.questions[0])==null?void 0:N.id)||"",history:[],isSubmitting:!1,errors:{},isCompleted:!1}),n=v.useMemo(()=>e.questions.findIndex(u=>u.id===r.currentStepId),[e.questions,r.currentStepId]),a=e.questions[n],i=v.useCallback((u,y)=>{t(C=>j(T({},C),{answers:j(T({},C.answers),{[u]:y}),errors:j(T({},C.errors),{[u]:""})}))},[]),m=v.useCallback((u,y)=>{t(C=>{if(y===null){const B=C.errors,{[u]:H}=B,V=Xe(B,[Ye(u)]);return j(T({},C),{errors:V})}return j(T({},C),{errors:j(T({},C.errors),{[u]:y})})})},[]),l=v.useCallback(()=>{var C;if(!a)return!0;const u=r.answers[a.id],y=a.validation;return y&&y.required&&(u===void 0||u===""||Array.isArray(u)&&u.length===0)?(m(a.id,((C=e.i18n)==null?void 0:C.required)||"This field is required"),!1):!0},[a,r.answers,m,e.i18n]),f=v.useCallback(u=>{const y=e.questions.findIndex(C=>C.id===u.id);return y<e.questions.length-1?e.questions[y+1].id:"submit"},[e.questions]),g=v.useCallback(()=>{if(!l())return;const u=f(a);u==="submit"?(t(y=>j(T({},y),{isCompleted:!0})),o==null||o(r.answers)):t(y=>j(T({},y),{history:[...y.history,y.currentStepId],currentStepId:u}))},[a,r.answers,l,f,o]),x=v.useCallback(()=>{if(r.history.length===0)return;const u=r.history[r.history.length-1];t(y=>j(T({},y),{history:y.history.slice(0,-1),currentStepId:u}))},[r.history]),S=v.useCallback(u=>{if(!e.questions.some(C=>C.id===u)){console.warn(`Step ${u} does not exist`);return}t(C=>j(T({},C),{history:[...C.history,C.currentStepId],currentStepId:u}))},[e.questions]),A=v.useCallback(()=>{var u;t({answers:{},currentStepId:((u=e.questions[0])==null?void 0:u.id)||"",history:[],isSubmitting:!1,errors:{},isCompleted:!1})},[e.questions]);return j(T({},r),{setAnswer:i,nextStep:g,prevStep:x,jumpToStep:S,submitForm:()=>o==null?void 0:o(r.answers),resetForm:A,registerError:m,progress:n/e.questions.length*100})}const ge=v.createContext(void 0),X=()=>{const e=v.useContext(ge);if(!e)throw new Error("useFormContext must be used within a FormProvider");return e};function Ze({question:e}){const{answers:o,setAnswer:r,nextStep:t}=X(),n=o[e.id],a=n!=null?String(n):"",i=v.useRef(null);v.useEffect(()=>{const g=setTimeout(()=>{var x;(x=i.current)==null||x.focus()},500);return()=>clearTimeout(g)},[e.id]);const m=g=>{var A;let x=g.target.value;const S=((A=e.validation)==null?void 0:A.maxLength)||2048;if(x.length>S&&(x=x.slice(0,S)),e.type==="number"){const N=x===""?"":parseFloat(x);r(e.id,N)}else r(e.id,x)},l=()=>{var g,x,S,A,N;if((g=e.validation)!=null&&g.required&&!a)return!1;if(a){if((x=e.validation)!=null&&x.minLength&&a.length<e.validation.minLength||e.type==="email"&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(a))return!1;if((S=e.validation)!=null&&S.pattern)try{if(!new RegExp(e.validation.pattern).test(a))return!1}catch(u){console.error("Invalid regex pattern in schema",u)}if(e.type==="number"){const u=parseFloat(a);if(!isNaN(u)&&(((A=e.validation)==null?void 0:A.min)!==void 0&&u<e.validation.min||((N=e.validation)==null?void 0:N.max)!==void 0&&u>e.validation.max))return!1}}return!0},f=g=>{if(g.key==="Enter"&&!g.shiftKey){if(g.preventDefault(),!l()){const x=document.querySelector(".sawabona-form-container")||document.body;x.classList.add("shake-animation"),setTimeout(()=>x.classList.remove("shake-animation"),500);return}t()}};return s.jsxs("div",{className:"w-full relative group",children:[s.jsx("input",{ref:i,type:e.type,value:a,onChange:m,onKeyDown:f,placeholder:e.placeholder||"Type your answer...",className:"w-full bg-transparent text-3xl md:text-5xl border-b-2 border-primary/20 focus:border-primary py-4 outline-none transition-all placeholder:text-muted-foreground/20 font-light"}),s.jsx(k.motion.div,{initial:{width:"0%"},animate:{width:a?"100%":"0%"},transition:{duration:.3},className:"absolute bottom-0 left-0 h-[2px] bg-primary"}),s.jsx("div",{className:"mt-4 flex items-center gap-2 opacity-0 animate-in fade-in slide-in-from-top-2 duration-700 delay-300 fill-mode-forwards",children:s.jsxs("div",{className:"flex items-center gap-1.5 text-sm md:text-base font-medium bg-primary/10 text-primary px-3 py-1.5 rounded-md",children:[s.jsx("span",{children:"Pressione"}),s.jsx("span",{className:"font-bold border border-primary/30 rounded px-1 min-w-[20px] text-center",children:"↵"}),s.jsx("span",{children:"Enter"})]})})]})}function be(e){var o,r,t="";if(typeof e=="string"||typeof e=="number")t+=e;else if(typeof e=="object")if(Array.isArray(e)){var n=e.length;for(o=0;o<n;o++)e[o]&&(r=be(e[o]))&&(t&&(t+=" "),t+=r)}else for(r in e)e[r]&&(t&&(t+=" "),t+=r);return t}function qe(){for(var e,o,r=0,t="",n=arguments.length;r<n;r++)(e=arguments[r])&&(o=be(e))&&(t&&(t+=" "),t+=o);return t}const Re=(e,o)=>{const r=new Array(e.length+o.length);for(let t=0;t<e.length;t++)r[t]=e[t];for(let t=0;t<o.length;t++)r[e.length+t]=o[t];return r},et=(e,o)=>({classGroupId:e,validator:o}),he=(e=new Map,o=null,r)=>({nextPart:e,validators:o,classGroupId:r}),q="-",xe=[],tt="arbitrary..",rt=e=>{const o=st(e),{conflictingClassGroups:r,conflictingClassGroupModifiers:t}=e;return{getClassGroupId:i=>{if(i.startsWith("[")&&i.endsWith("]"))return ot(i);const m=i.split(q),l=m[0]===""&&m.length>1?1:0;return ye(m,l,o)},getConflictingClassGroupIds:(i,m)=>{if(m){const l=t[i],f=r[i];return l?f?Re(f,l):l:f||xe}return r[i]||xe}}},ye=(e,o,r)=>{if(e.length-o===0)return r.classGroupId;const n=e[o],a=r.nextPart.get(n);if(a){const f=ye(e,o+1,a);if(f)return f}const i=r.validators;if(i===null)return;const m=o===0?e.join(q):e.slice(o).join(q),l=i.length;for(let f=0;f<l;f++){const g=i[f];if(g.validator(m))return g.classGroupId}},ot=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const o=e.slice(1,-1),r=o.indexOf(":"),t=o.slice(0,r);return t?tt+t:void 0})(),st=e=>{const{theme:o,classGroups:r}=e;return nt(r,o)},nt=(e,o)=>{const r=he();for(const t in e){const n=e[t];ie(n,r,t,o)}return r},ie=(e,o,r,t)=>{const n=e.length;for(let a=0;a<n;a++){const i=e[a];at(i,o,r,t)}},at=(e,o,r,t)=>{if(typeof e=="string"){it(e,o,r);return}if(typeof e=="function"){lt(e,o,r,t);return}ct(e,o,r,t)},it=(e,o,r)=>{const t=e===""?o:we(o,e);t.classGroupId=r},lt=(e,o,r,t)=>{if(dt(e)){ie(e(t),o,r,t);return}o.validators===null&&(o.validators=[]),o.validators.push(et(r,e))},ct=(e,o,r,t)=>{const n=Object.entries(e),a=n.length;for(let i=0;i<a;i++){const[m,l]=n[i];ie(l,we(o,m),r,t)}},we=(e,o)=>{let r=e;const t=o.split(q),n=t.length;for(let a=0;a<n;a++){const i=t[a];let m=r.nextPart.get(i);m||(m=he(),r.nextPart.set(i,m)),r=m}return r},dt=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,mt=e=>{if(e<1)return{get:()=>{},set:()=>{}};let o=0,r=Object.create(null),t=Object.create(null);const n=(a,i)=>{r[a]=i,o++,o>e&&(o=0,t=r,r=Object.create(null))};return{get(a){let i=r[a];if(i!==void 0)return i;if((i=t[a])!==void 0)return n(a,i),i},set(a,i){a in r?r[a]=i:n(a,i)}}},le="!",ve=":",pt=[],ke=(e,o,r,t,n)=>({modifiers:e,hasImportantModifier:o,baseClassName:r,maybePostfixModifierPosition:t,isExternal:n}),ut=e=>{const{prefix:o,experimentalParseClassName:r}=e;let t=n=>{const a=[];let i=0,m=0,l=0,f;const g=n.length;for(let u=0;u<g;u++){const y=n[u];if(i===0&&m===0){if(y===ve){a.push(n.slice(l,u)),l=u+1;continue}if(y==="/"){f=u;continue}}y==="["?i++:y==="]"?i--:y==="("?m++:y===")"&&m--}const x=a.length===0?n:n.slice(l);let S=x,A=!1;x.endsWith(le)?(S=x.slice(0,-1),A=!0):x.startsWith(le)&&(S=x.slice(1),A=!0);const N=f&&f>l?f-l:void 0;return ke(a,A,S,N)};if(o){const n=o+ve,a=t;t=i=>i.startsWith(n)?a(i.slice(n.length)):ke(pt,!1,i,void 0,!0)}if(r){const n=t;t=a=>r({className:a,parseClassName:n})}return t},ft=e=>{const o=new Map;return e.orderSensitiveModifiers.forEach((r,t)=>{o.set(r,1e6+t)}),r=>{const t=[];let n=[];for(let a=0;a<r.length;a++){const i=r[a],m=i[0]==="[",l=o.has(i);m||l?(n.length>0&&(n.sort(),t.push(...n),n=[]),t.push(i)):n.push(i)}return n.length>0&&(n.sort(),t.push(...n)),t}},gt=e=>T({cache:mt(e.cacheSize),parseClassName:ut(e),sortModifiers:ft(e)},rt(e)),bt=/\s+/,ht=(e,o)=>{const{parseClassName:r,getClassGroupId:t,getConflictingClassGroupIds:n,sortModifiers:a}=o,i=[],m=e.trim().split(bt);let l="";for(let f=m.length-1;f>=0;f-=1){const g=m[f],{isExternal:x,modifiers:S,hasImportantModifier:A,baseClassName:N,maybePostfixModifierPosition:u}=r(g);if(x){l=g+(l.length>0?" "+l:l);continue}let y=!!u,C=t(y?N.substring(0,u):N);if(!C){if(!y){l=g+(l.length>0?" "+l:l);continue}if(C=t(N),!C){l=g+(l.length>0?" "+l:l);continue}y=!1}const B=S.length===0?"":S.length===1?S[0]:a(S).join(":"),H=A?B+le:B,V=H+C;if(i.indexOf(V)>-1)continue;i.push(V);const Q=n(C,y);for(let D=0;D<Q.length;++D){const Z=Q[D];i.push(H+Z)}l=g+(l.length>0?" "+l:l)}return l},xt=(...e)=>{let o=0,r,t,n="";for(;o<e.length;)(r=e[o++])&&(t=Ce(r))&&(n&&(n+=" "),n+=t);return n},Ce=e=>{if(typeof e=="string")return e;let o,r="";for(let t=0;t<e.length;t++)e[t]&&(o=Ce(e[t]))&&(r&&(r+=" "),r+=o);return r},yt=(e,...o)=>{let r,t,n,a;const i=l=>{const f=o.reduce((g,x)=>x(g),e());return r=gt(f),t=r.cache.get,n=r.cache.set,a=m,m(l)},m=l=>{const f=t(l);if(f)return f;const g=ht(l,r);return n(l,g),g};return a=i,(...l)=>a(xt(...l))},wt=[],z=e=>{const o=r=>r[e]||wt;return o.isThemeGetter=!0,o},Se=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Ne=/^\((?:(\w[\w-]*):)?(.+)\)$/i,vt=/^\d+\/\d+$/,kt=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Ct=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,St=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Nt=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,zt=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,U=e=>vt.test(e),h=e=>!!e&&!Number.isNaN(Number(e)),O=e=>!!e&&Number.isInteger(Number(e)),ce=e=>e.endsWith("%")&&h(e.slice(0,-1)),F=e=>kt.test(e),ze=()=>!0,At=e=>Ct.test(e)&&!St.test(e),de=()=>!1,It=e=>Nt.test(e),Tt=e=>zt.test(e),Pt=e=>!c(e)&&!d(e),Et=e=>M(e,je,de),c=e=>Se.test(e),W=e=>M(e,Fe,At),Ae=e=>M(e,Wt,h),jt=e=>M(e,Ge,ze),Ft=e=>M(e,Le,de),Ie=e=>M(e,Pe,de),Lt=e=>M(e,Ee,Tt),R=e=>M(e,Oe,It),d=e=>Ne.test(e),J=e=>_(e,Fe),Gt=e=>_(e,Le),Te=e=>_(e,Pe),Ot=e=>_(e,je),Mt=e=>_(e,Ee),ee=e=>_(e,Oe,!0),Vt=e=>_(e,Ge,!0),M=(e,o,r)=>{const t=Se.exec(e);return t?t[1]?o(t[1]):r(t[2]):!1},_=(e,o,r=!1)=>{const t=Ne.exec(e);return t?t[1]?o(t[1]):r:!1},Pe=e=>e==="position"||e==="percentage",Ee=e=>e==="image"||e==="url",je=e=>e==="length"||e==="size"||e==="bg-size",Fe=e=>e==="length",Wt=e=>e==="number",Le=e=>e==="family-name",Ge=e=>e==="number"||e==="weight",Oe=e=>e==="shadow",_t=yt(()=>{const e=z("color"),o=z("font"),r=z("text"),t=z("font-weight"),n=z("tracking"),a=z("leading"),i=z("breakpoint"),m=z("container"),l=z("spacing"),f=z("radius"),g=z("shadow"),x=z("inset-shadow"),S=z("text-shadow"),A=z("drop-shadow"),N=z("blur"),u=z("perspective"),y=z("aspect"),C=z("ease"),B=z("animate"),H=()=>["auto","avoid","all","avoid-page","page","left","right","column"],V=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],Q=()=>[...V(),d,c],D=()=>["auto","hidden","clip","visible","scroll"],Z=()=>["auto","contain","none"],b=()=>[d,c,l],L=()=>[U,"full","auto",...b()],Me=()=>[O,"none","subgrid",d,c],Ve=()=>["auto",{span:["full",O,d,c]},O,d,c],te=()=>[O,"auto",d,c],We=()=>["auto","min","max","fr",d,c],pe=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],K=()=>["start","end","center","stretch","center-safe","end-safe"],G=()=>["auto",...b()],$=()=>[U,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...b()],p=()=>[e,d,c],_e=()=>[...V(),Te,Ie,{position:[d,c]}],Be=()=>["no-repeat",{repeat:["","x","y","space","round"]}],De=()=>["auto","cover","contain",Ot,Et,{size:[d,c]}],ue=()=>[ce,J,W],P=()=>["","none","full",f,d,c],E=()=>["",h,J,W],re=()=>["solid","dashed","dotted","double"],$e=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],I=()=>[h,ce,Te,Ie],Ue=()=>["","none",N,d,c],oe=()=>["none",h,d,c],se=()=>["none",h,d,c],fe=()=>[h,d,c],ne=()=>[U,"full",...b()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[F],breakpoint:[F],color:[ze],container:[F],"drop-shadow":[F],ease:["in","out","in-out"],font:[Pt],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[F],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[F],shadow:[F],spacing:["px",h],text:[F],"text-shadow":[F],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",U,c,d,y]}],container:["container"],columns:[{columns:[h,c,d,m]}],"break-after":[{"break-after":H()}],"break-before":[{"break-before":H()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:Q()}],overflow:[{overflow:D()}],"overflow-x":[{"overflow-x":D()}],"overflow-y":[{"overflow-y":D()}],overscroll:[{overscroll:Z()}],"overscroll-x":[{"overscroll-x":Z()}],"overscroll-y":[{"overscroll-y":Z()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:L()}],"inset-x":[{"inset-x":L()}],"inset-y":[{"inset-y":L()}],start:[{start:L()}],end:[{end:L()}],top:[{top:L()}],right:[{right:L()}],bottom:[{bottom:L()}],left:[{left:L()}],visibility:["visible","invisible","collapse"],z:[{z:[O,"auto",d,c]}],basis:[{basis:[U,"full","auto",m,...b()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[h,U,"auto","initial","none",c]}],grow:[{grow:["",h,d,c]}],shrink:[{shrink:["",h,d,c]}],order:[{order:[O,"first","last","none",d,c]}],"grid-cols":[{"grid-cols":Me()}],"col-start-end":[{col:Ve()}],"col-start":[{"col-start":te()}],"col-end":[{"col-end":te()}],"grid-rows":[{"grid-rows":Me()}],"row-start-end":[{row:Ve()}],"row-start":[{"row-start":te()}],"row-end":[{"row-end":te()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":We()}],"auto-rows":[{"auto-rows":We()}],gap:[{gap:b()}],"gap-x":[{"gap-x":b()}],"gap-y":[{"gap-y":b()}],"justify-content":[{justify:[...pe(),"normal"]}],"justify-items":[{"justify-items":[...K(),"normal"]}],"justify-self":[{"justify-self":["auto",...K()]}],"align-content":[{content:["normal",...pe()]}],"align-items":[{items:[...K(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...K(),{baseline:["","last"]}]}],"place-content":[{"place-content":pe()}],"place-items":[{"place-items":[...K(),"baseline"]}],"place-self":[{"place-self":["auto",...K()]}],p:[{p:b()}],px:[{px:b()}],py:[{py:b()}],ps:[{ps:b()}],pe:[{pe:b()}],pt:[{pt:b()}],pr:[{pr:b()}],pb:[{pb:b()}],pl:[{pl:b()}],m:[{m:G()}],mx:[{mx:G()}],my:[{my:G()}],ms:[{ms:G()}],me:[{me:G()}],mt:[{mt:G()}],mr:[{mr:G()}],mb:[{mb:G()}],ml:[{ml:G()}],"space-x":[{"space-x":b()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":b()}],"space-y-reverse":["space-y-reverse"],size:[{size:$()}],w:[{w:[m,"screen",...$()]}],"min-w":[{"min-w":[m,"screen","none",...$()]}],"max-w":[{"max-w":[m,"screen","none","prose",{screen:[i]},...$()]}],h:[{h:["screen","lh",...$()]}],"min-h":[{"min-h":["screen","lh","none",...$()]}],"max-h":[{"max-h":["screen","lh",...$()]}],"font-size":[{text:["base",r,J,W]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[t,Vt,jt]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",ce,c]}],"font-family":[{font:[Gt,Ft,o]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[n,d,c]}],"line-clamp":[{"line-clamp":[h,"none",d,Ae]}],leading:[{leading:[a,...b()]}],"list-image":[{"list-image":["none",d,c]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",d,c]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:p()}],"text-color":[{text:p()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...re(),"wavy"]}],"text-decoration-thickness":[{decoration:[h,"from-font","auto",d,W]}],"text-decoration-color":[{decoration:p()}],"underline-offset":[{"underline-offset":[h,"auto",d,c]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:b()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",d,c]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",d,c]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:_e()}],"bg-repeat":[{bg:Be()}],"bg-size":[{bg:De()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},O,d,c],radial:["",d,c],conic:[O,d,c]},Mt,Lt]}],"bg-color":[{bg:p()}],"gradient-from-pos":[{from:ue()}],"gradient-via-pos":[{via:ue()}],"gradient-to-pos":[{to:ue()}],"gradient-from":[{from:p()}],"gradient-via":[{via:p()}],"gradient-to":[{to:p()}],rounded:[{rounded:P()}],"rounded-s":[{"rounded-s":P()}],"rounded-e":[{"rounded-e":P()}],"rounded-t":[{"rounded-t":P()}],"rounded-r":[{"rounded-r":P()}],"rounded-b":[{"rounded-b":P()}],"rounded-l":[{"rounded-l":P()}],"rounded-ss":[{"rounded-ss":P()}],"rounded-se":[{"rounded-se":P()}],"rounded-ee":[{"rounded-ee":P()}],"rounded-es":[{"rounded-es":P()}],"rounded-tl":[{"rounded-tl":P()}],"rounded-tr":[{"rounded-tr":P()}],"rounded-br":[{"rounded-br":P()}],"rounded-bl":[{"rounded-bl":P()}],"border-w":[{border:E()}],"border-w-x":[{"border-x":E()}],"border-w-y":[{"border-y":E()}],"border-w-s":[{"border-s":E()}],"border-w-e":[{"border-e":E()}],"border-w-t":[{"border-t":E()}],"border-w-r":[{"border-r":E()}],"border-w-b":[{"border-b":E()}],"border-w-l":[{"border-l":E()}],"divide-x":[{"divide-x":E()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":E()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...re(),"hidden","none"]}],"divide-style":[{divide:[...re(),"hidden","none"]}],"border-color":[{border:p()}],"border-color-x":[{"border-x":p()}],"border-color-y":[{"border-y":p()}],"border-color-s":[{"border-s":p()}],"border-color-e":[{"border-e":p()}],"border-color-t":[{"border-t":p()}],"border-color-r":[{"border-r":p()}],"border-color-b":[{"border-b":p()}],"border-color-l":[{"border-l":p()}],"divide-color":[{divide:p()}],"outline-style":[{outline:[...re(),"none","hidden"]}],"outline-offset":[{"outline-offset":[h,d,c]}],"outline-w":[{outline:["",h,J,W]}],"outline-color":[{outline:p()}],shadow:[{shadow:["","none",g,ee,R]}],"shadow-color":[{shadow:p()}],"inset-shadow":[{"inset-shadow":["none",x,ee,R]}],"inset-shadow-color":[{"inset-shadow":p()}],"ring-w":[{ring:E()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:p()}],"ring-offset-w":[{"ring-offset":[h,W]}],"ring-offset-color":[{"ring-offset":p()}],"inset-ring-w":[{"inset-ring":E()}],"inset-ring-color":[{"inset-ring":p()}],"text-shadow":[{"text-shadow":["none",S,ee,R]}],"text-shadow-color":[{"text-shadow":p()}],opacity:[{opacity:[h,d,c]}],"mix-blend":[{"mix-blend":[...$e(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":$e()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[h]}],"mask-image-linear-from-pos":[{"mask-linear-from":I()}],"mask-image-linear-to-pos":[{"mask-linear-to":I()}],"mask-image-linear-from-color":[{"mask-linear-from":p()}],"mask-image-linear-to-color":[{"mask-linear-to":p()}],"mask-image-t-from-pos":[{"mask-t-from":I()}],"mask-image-t-to-pos":[{"mask-t-to":I()}],"mask-image-t-from-color":[{"mask-t-from":p()}],"mask-image-t-to-color":[{"mask-t-to":p()}],"mask-image-r-from-pos":[{"mask-r-from":I()}],"mask-image-r-to-pos":[{"mask-r-to":I()}],"mask-image-r-from-color":[{"mask-r-from":p()}],"mask-image-r-to-color":[{"mask-r-to":p()}],"mask-image-b-from-pos":[{"mask-b-from":I()}],"mask-image-b-to-pos":[{"mask-b-to":I()}],"mask-image-b-from-color":[{"mask-b-from":p()}],"mask-image-b-to-color":[{"mask-b-to":p()}],"mask-image-l-from-pos":[{"mask-l-from":I()}],"mask-image-l-to-pos":[{"mask-l-to":I()}],"mask-image-l-from-color":[{"mask-l-from":p()}],"mask-image-l-to-color":[{"mask-l-to":p()}],"mask-image-x-from-pos":[{"mask-x-from":I()}],"mask-image-x-to-pos":[{"mask-x-to":I()}],"mask-image-x-from-color":[{"mask-x-from":p()}],"mask-image-x-to-color":[{"mask-x-to":p()}],"mask-image-y-from-pos":[{"mask-y-from":I()}],"mask-image-y-to-pos":[{"mask-y-to":I()}],"mask-image-y-from-color":[{"mask-y-from":p()}],"mask-image-y-to-color":[{"mask-y-to":p()}],"mask-image-radial":[{"mask-radial":[d,c]}],"mask-image-radial-from-pos":[{"mask-radial-from":I()}],"mask-image-radial-to-pos":[{"mask-radial-to":I()}],"mask-image-radial-from-color":[{"mask-radial-from":p()}],"mask-image-radial-to-color":[{"mask-radial-to":p()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":V()}],"mask-image-conic-pos":[{"mask-conic":[h]}],"mask-image-conic-from-pos":[{"mask-conic-from":I()}],"mask-image-conic-to-pos":[{"mask-conic-to":I()}],"mask-image-conic-from-color":[{"mask-conic-from":p()}],"mask-image-conic-to-color":[{"mask-conic-to":p()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:_e()}],"mask-repeat":[{mask:Be()}],"mask-size":[{mask:De()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",d,c]}],filter:[{filter:["","none",d,c]}],blur:[{blur:Ue()}],brightness:[{brightness:[h,d,c]}],contrast:[{contrast:[h,d,c]}],"drop-shadow":[{"drop-shadow":["","none",A,ee,R]}],"drop-shadow-color":[{"drop-shadow":p()}],grayscale:[{grayscale:["",h,d,c]}],"hue-rotate":[{"hue-rotate":[h,d,c]}],invert:[{invert:["",h,d,c]}],saturate:[{saturate:[h,d,c]}],sepia:[{sepia:["",h,d,c]}],"backdrop-filter":[{"backdrop-filter":["","none",d,c]}],"backdrop-blur":[{"backdrop-blur":Ue()}],"backdrop-brightness":[{"backdrop-brightness":[h,d,c]}],"backdrop-contrast":[{"backdrop-contrast":[h,d,c]}],"backdrop-grayscale":[{"backdrop-grayscale":["",h,d,c]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[h,d,c]}],"backdrop-invert":[{"backdrop-invert":["",h,d,c]}],"backdrop-opacity":[{"backdrop-opacity":[h,d,c]}],"backdrop-saturate":[{"backdrop-saturate":[h,d,c]}],"backdrop-sepia":[{"backdrop-sepia":["",h,d,c]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":b()}],"border-spacing-x":[{"border-spacing-x":b()}],"border-spacing-y":[{"border-spacing-y":b()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",d,c]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[h,"initial",d,c]}],ease:[{ease:["linear","initial",C,d,c]}],delay:[{delay:[h,d,c]}],animate:[{animate:["none",B,d,c]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[u,d,c]}],"perspective-origin":[{"perspective-origin":Q()}],rotate:[{rotate:oe()}],"rotate-x":[{"rotate-x":oe()}],"rotate-y":[{"rotate-y":oe()}],"rotate-z":[{"rotate-z":oe()}],scale:[{scale:se()}],"scale-x":[{"scale-x":se()}],"scale-y":[{"scale-y":se()}],"scale-z":[{"scale-z":se()}],"scale-3d":["scale-3d"],skew:[{skew:fe()}],"skew-x":[{"skew-x":fe()}],"skew-y":[{"skew-y":fe()}],transform:[{transform:[d,c,"","none","gpu","cpu"]}],"transform-origin":[{origin:Q()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:ne()}],"translate-x":[{"translate-x":ne()}],"translate-y":[{"translate-y":ne()}],"translate-z":[{"translate-z":ne()}],"translate-none":["translate-none"],accent:[{accent:p()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:p()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",d,c]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":b()}],"scroll-mx":[{"scroll-mx":b()}],"scroll-my":[{"scroll-my":b()}],"scroll-ms":[{"scroll-ms":b()}],"scroll-me":[{"scroll-me":b()}],"scroll-mt":[{"scroll-mt":b()}],"scroll-mr":[{"scroll-mr":b()}],"scroll-mb":[{"scroll-mb":b()}],"scroll-ml":[{"scroll-ml":b()}],"scroll-p":[{"scroll-p":b()}],"scroll-px":[{"scroll-px":b()}],"scroll-py":[{"scroll-py":b()}],"scroll-ps":[{"scroll-ps":b()}],"scroll-pe":[{"scroll-pe":b()}],"scroll-pt":[{"scroll-pt":b()}],"scroll-pr":[{"scroll-pr":b()}],"scroll-pb":[{"scroll-pb":b()}],"scroll-pl":[{"scroll-pl":b()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",d,c]}],fill:[{fill:["none",...p()]}],"stroke-w":[{stroke:[h,J,W,Ae]}],stroke:[{stroke:["none",...p()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}});function me(...e){return _t(qe(e))}function Bt({question:e}){var m;const{answers:o,setAnswer:r,nextStep:t}=X(),n=o[e.id]||"",a=l=>{r(e.id,l),setTimeout(()=>t(),400)},i="ABCDEFGHIJKLMNOPQRSTUVWXYZ";return v.useEffect(()=>{const l=f=>{var S;const g=f.key.toUpperCase(),x=i.indexOf(g);x>=0&&x<(((S=e.options)==null?void 0:S.length)||0)&&a(e.options[x].value)};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[e.options,e.id]),s.jsx("div",{className:"flex flex-col gap-3 w-full max-w-xl",children:(m=e.options)==null?void 0:m.map((l,f)=>{const g=n===l.value;return s.jsxs(k.motion.button,{onClick:()=>a(l.value),initial:{opacity:0,x:-20},animate:{opacity:1,x:0},transition:{delay:f*.1,duration:.4},whileHover:{scale:1.02,x:5,transition:{duration:.2}},whileTap:{scale:.98},className:me("group flex items-center gap-4 p-4 md:p-6 rounded-lg border-2 text-left transition-all duration-200 outline-none",g?"border-primary bg-primary/10 text-primary shadow-lg":"border-muted-foreground/20 hover:border-primary/50 hover:bg-white/5"),children:[s.jsx("div",{className:me("w-8 h-8 md:w-10 md:h-10 flex items-center justify-center rounded border text-sm md:text-base font-bold transition-colors",g?"bg-primary text-secondary border-primary":"border-muted-foreground/30 text-muted-foreground group-hover:border-primary group-hover:text-primary"),children:i[f]}),s.jsx("span",{className:"text-xl md:text-2xl font-medium flex-1",children:l.label}),g&&s.jsx(k.motion.div,{initial:{scale:0},animate:{scale:1},children:s.jsx(Y.Check,{className:"w-6 h-6 md:w-8 md:h-8"})})]},String(l.value))})})}function Dt({question:e}){var a;const{answers:o,setAnswer:r}=X(),t=o[e.id]||0,n=Math.min(((a=e.validation)==null?void 0:a.max)||5,20);return s.jsxs("div",{className:"flex flex-col gap-6",children:[s.jsx("div",{className:"flex gap-4 flex-wrap",children:Array.from({length:n}).map((i,m)=>{const l=m+1,f=l<=t;return s.jsx(k.motion.button,{type:"button",className:"focus:outline-none",onClick:()=>r(e.id,l),whileHover:{scale:1.2,rotate:5},whileTap:{scale:.9},initial:{opacity:0,scale:0},animate:{opacity:1,scale:1},transition:{delay:m*.05},children:s.jsx(Y.Star,{className:me("w-12 h-12 md:w-16 md:h-16 transition-all duration-300",f?"fill-yellow-400 text-yellow-400 drop-shadow-[0_0_15px_rgba(250,204,21,0.4)]":"text-zinc-600 hover:text-yellow-400/50"),strokeWidth:1.5})},m)})}),s.jsxs("div",{className:"flex justify-between w-full max-w-[300px] md:max-w-[400px] px-2 items-center",children:[s.jsx("span",{className:"text-sm md:text-base font-medium text-muted-foreground uppercase tracking-wide",children:e.minLabel||"Poor"}),s.jsx(k.motion.div,{initial:{opacity:0,scale:.8},animate:{opacity:t?1:0,scale:t?1:.8},className:"font-bold text-primary text-xl",children:t?`${t} / ${n}`:""}),s.jsx("span",{className:"text-sm md:text-base font-medium text-muted-foreground uppercase tracking-wide",children:e.maxLabel||"Excellent"})]})]})}function $t({question:e}){const{schema:o}=X(),r=o.questions.findIndex(m=>m.id===e.id)+1,t=o.questions.length,n={hidden:{opacity:0,y:20},visible:{opacity:1,y:0,transition:{duration:.5,ease:[.22,1,.36,1]}}},a=m=>m&&m.replace(/\{\{(\w+)\}\}/g,(l,f)=>{const g=i.answers[f];return g!=null?String(g):""}),i=X();return s.jsxs(k.motion.div,{className:"flex flex-col gap-8 w-full max-w-4xl mx-auto",initial:"hidden",animate:"visible",variants:{visible:{transition:{staggerChildren:.1}}},children:[s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(k.motion.div,{variants:n,className:"flex gap-4 items-baseline",children:s.jsxs("span",{className:"flex items-center gap-2 text-sm md:text-base font-medium text-primary/90 bg-primary/10 px-3 py-1 rounded-full border border-primary/20 backdrop-blur-sm",children:[s.jsx("span",{children:r}),s.jsx("span",{className:"opacity-40 text-xs",children:"/"}),s.jsx("span",{className:"opacity-60",children:t})]})}),s.jsxs(k.motion.h2,{variants:n,className:"text-3xl md:text-4xl lg:text-5xl font-bold leading-tight tracking-tight text-pretty mt-2",children:[a(e.title)," ",s.jsx("span",{className:"text-primary",children:"*"})]}),e.description&&s.jsx(k.motion.p,{variants:n,className:"text-lg md:text-xl text-muted-foreground font-normal leading-relaxed max-w-2xl mt-2",children:a(e.description)})]}),s.jsx(k.motion.div,{variants:n,className:"w-full mt-6",children:e.type==="text"||e.type==="email"||e.type==="number"||e.type==="url"?s.jsx(Ze,{question:e}):e.type==="select"?s.jsx(Bt,{question:e}):e.type==="rating"?s.jsx(Dt,{question:e}):s.jsxs("div",{className:"p-4 bg-yellow-100 dark:bg-yellow-900/30 text-yellow-800 dark:text-yellow-200 rounded",children:["Unsupported question type: ",e.type," (ID: ",e.id,")"]})})]})}const Ut={next:"Next",back:"Back",submit:"Submit",required:"Required",optional:"Optional",stepInfo:"Question {{current}} of {{total}}"};function Ht({schema:e,onSubmit:o}){var A;const r=Je({schema:e,onSubmit:o}),t=e.theme||{backgroundColor:"#ffffff",textColor:"#000000",primaryColor:"#000000",borderRadius:"8px",fontFamily:"sans-serif"},n=T(T({},Ut),e.i18n),a={backgroundColor:t.backgroundColor,color:t.textColor,fontFamily:t.fontFamily},i=t.buttonVariant==="outline",m={backgroundColor:i?"transparent":t.primaryColor,color:i?t.primaryColor:t.textColor,border:i?`2px solid ${t.primaryColor}`:"none",borderRadius:t.borderRadius||"8px",fontWeight:600},l={color:t.primaryColor,borderRadius:t.borderRadius||"8px",fontWeight:600},{autoReload:f,reloadDelay:g=3e3}=e;if(v.useEffect(()=>{if(r.isCompleted&&f){const N=setTimeout(()=>{r.resetForm()},g);return()=>clearTimeout(N)}},[r.isCompleted,f,g,r.resetForm]),r.isCompleted)return s.jsxs("div",{className:"flex flex-col items-center justify-center h-full w-full p-8 text-center relative overflow-hidden",style:a,children:[f&&s.jsx(k.motion.div,{initial:{width:"0%"},animate:{width:"100%"},transition:{duration:g/1e3,ease:"linear"},className:"absolute top-0 left-0 h-1 bg-green-500 z-50"}),s.jsxs(k.motion.div,{initial:{scale:.9,opacity:0,y:20},animate:{scale:1,opacity:1,y:0},transition:{duration:.6,ease:[.22,1,.36,1]},className:"flex flex-col items-center",children:[s.jsx("div",{className:"mb-6 p-4 rounded-full bg-green-500/20 text-green-500 w-24 h-24 flex items-center justify-center",children:s.jsx(Y.Check,{size:48})}),s.jsx("h1",{className:"text-4xl md:text-5xl font-bold mb-4 tracking-tight",children:"Obrigado!"}),s.jsx("p",{className:"text-xl opacity-70 max-w-md leading-relaxed",children:"Suas respostas foram enviadas com sucesso."})]})]});const x=e.questions.find(N=>N.id===r.currentStepId),S=(e.questions.findIndex(N=>N.id===r.currentStepId)+1)/e.questions.length*100;return s.jsx(ge.Provider,{value:j(T({},r),{schema:e}),children:s.jsxs("div",{className:"w-full h-full flex flex-col relative overflow-hidden transition-colors duration-700",style:a,children:[s.jsxs("div",{className:"absolute top-0 left-0 w-full h-1 z-50",children:[s.jsx("div",{className:"absolute top-0 left-0 w-full h-full bg-current opacity-10"}),s.jsx(k.motion.div,{className:"h-full relative z-10",initial:{width:0},animate:{width:`${S}%`},transition:{duration:.5,ease:"easeInOut"},style:{backgroundColor:t.primaryColor}})]}),s.jsx("div",{className:"flex-1 flex flex-col items-center justify-center p-6 md:p-12 w-full max-w-5xl mx-auto z-10",children:s.jsx(k.AnimatePresence,{mode:"wait",children:x&&s.jsx(k.motion.div,{initial:{opacity:0,y:40},animate:{opacity:1,y:0},exit:{opacity:0,y:-40},transition:{duration:.5,ease:[.22,1,.36,1]},className:"w-full",children:s.jsx($t,{question:x})},x.id)})}),s.jsxs("div",{className:"w-full px-6 pt-6 pb-8 md:p-10 flex flex-col md:flex-row justify-between items-center z-20 gap-4",children:[t.showPoweredBy!==!1&&s.jsxs("a",{href:"#",className:"order-3 md:order-1 group flex items-center gap-2 px-3 py-1.5 rounded-md border border-white/10 bg-black/20 hover:border-primary/50 hover:bg-black/40 transition-all duration-300 cursor-pointer no-underline backdrop-blur-sm",children:[s.jsx("span",{className:"text-[10px] md:text-xs font-mono font-medium tracking-[0.2em] uppercase text-muted-foreground group-hover:text-muted-foreground/80 transition-colors",children:"Powered By"}),s.jsx("span",{className:"text-[10px] md:text-xs font-mono font-bold tracking-[0.2em] uppercase transition-colors shadow-primary",style:{color:t.brandColor||t.primaryColor},children:((A=t.poweredBy)==null?void 0:A.replace("Powered by ",""))||"SAWABONA TECH"})]}),s.jsxs("div",{className:"flex items-center gap-4 order-2 md:order-3 ml-auto",children:[s.jsx(k.motion.button,{onClick:r.prevStep,disabled:r.history.length===0,whileHover:{scale:1.05},whileTap:{scale:.95},className:"w-12 h-12 md:w-14 md:h-14 flex items-center justify-center disabled:opacity-0 disabled:pointer-events-none transition-all hover:bg-white/5 rounded-full",style:l,children:s.jsx(Y.ChevronLeft,{size:24})}),s.jsxs(k.motion.button,{onClick:r.nextStep,whileHover:{scale:1.02},whileTap:{scale:.98},className:"px-8 py-3 md:px-10 md:py-4 text-lg font-bold shadow-2xl flex items-center gap-3 transition-all rounded-lg",style:m,children:[s.jsx("span",{children:r.currentStepId===e.questions[e.questions.length-1].id?t.submitText||n.submit:n.next}),r.currentStepId!==e.questions[e.questions.length-1].id&&s.jsx(Y.ChevronRight,{size:20,strokeWidth:3})]})]})]})]})})}w.FormRenderer=Ht,Object.defineProperty(w,Symbol.toStringTag,{value:"Module"})}));
|
|
1
|
+
(function(a,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("react/jsx-runtime"),require("react"),require("framer-motion"),require("lucide-react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","framer-motion","lucide-react"],t):(a=typeof globalThis!="undefined"?globalThis:a||self,t(a.SawabonaForms={},a.jsxRuntime,a.React,a.Motion,a.Lucide))})(this,(function(a,t,o,c,F){"use strict";var W=Object.defineProperty,U=Object.defineProperties;var G=Object.getOwnPropertyDescriptors;var A=Object.getOwnPropertySymbols;var P=Object.prototype.hasOwnProperty,z=Object.prototype.propertyIsEnumerable;var j=(a,t,o)=>t in a?W(a,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):a[t]=o,h=(a,t)=>{for(var o in t||(t={}))P.call(t,o)&&j(a,o,t[o]);if(A)for(var o of A(t))z.call(t,o)&&j(a,o,t[o]);return a},g=(a,t)=>U(a,G(t));var $=a=>typeof a=="symbol"?a:a+"",B=(a,t)=>{var o={};for(var c in a)P.call(a,c)&&t.indexOf(c)<0&&(o[c]=a[c]);if(a!=null&&A)for(var c of A(a))t.indexOf(c)<0&&z.call(a,c)&&(o[c]=a[c]);return o};function O({schema:e,onSubmit:f}){var v;const[s,r]=o.useState({answers:{},currentStepId:((v=e.questions[0])==null?void 0:v.id)||"",history:[],isSubmitting:!1,errors:{},isCompleted:!1}),p=o.useMemo(()=>e.questions.findIndex(i=>i.id===s.currentStepId),[e.questions,s.currentStepId]),d=e.questions[p],w=o.useCallback((i,l)=>{r(n=>g(h({},n),{answers:g(h({},n.answers),{[i]:l}),errors:g(h({},n.errors),{[i]:""})}))},[]),x=o.useCallback((i,l)=>{r(n=>{if(l===null){const C=n.errors,{[i]:S}=C,I=B(C,[$(i)]);return g(h({},n),{errors:I})}return g(h({},n),{errors:g(h({},n.errors),{[i]:l})})})},[]),u=o.useCallback(()=>{var n;if(!d)return!0;const i=s.answers[d.id],l=d.validation;return l&&l.required&&(i===void 0||i===""||Array.isArray(i)&&i.length===0)?(x(d.id,((n=e.i18n)==null?void 0:n.required)||"This field is required"),!1):!0},[d,s.answers,x,e.i18n]),m=o.useCallback(i=>{const l=e.questions.findIndex(n=>n.id===i.id);return l<e.questions.length-1?e.questions[l+1].id:"submit"},[e.questions]),y=o.useCallback(()=>{if(!u())return;const i=m(d);i==="submit"?(r(l=>g(h({},l),{isCompleted:!0})),f==null||f(s.answers)):r(l=>g(h({},l),{history:[...l.history,l.currentStepId],currentStepId:i}))},[d,s.answers,u,m,f]),b=o.useCallback(()=>{if(s.history.length===0)return;const i=s.history[s.history.length-1];r(l=>g(h({},l),{history:l.history.slice(0,-1),currentStepId:i}))},[s.history]),N=o.useCallback(i=>{if(!e.questions.some(n=>n.id===i)){console.warn(`Step ${i} does not exist`);return}r(n=>g(h({},n),{history:[...n.history,n.currentStepId],currentStepId:i}))},[e.questions]),k=o.useCallback(()=>{var i;r({answers:{},currentStepId:((i=e.questions[0])==null?void 0:i.id)||"",history:[],isSubmitting:!1,errors:{},isCompleted:!1})},[e.questions]);return g(h({},s),{setAnswer:w,nextStep:y,prevStep:b,jumpToStep:N,submitForm:()=>f==null?void 0:f(s.answers),resetForm:k,registerError:x,progress:p/e.questions.length*100})}const L=o.createContext(void 0),T=()=>{const e=o.useContext(L);if(!e)throw new Error("useFormContext must be used within a FormProvider");return e};function _({question:e}){var b,N,k,v,i;const{answers:f,setAnswer:s,nextStep:r}=T(),p=f[e.id],d=p!=null?String(p):"",w=o.useRef(null);o.useEffect(()=>{const l=setTimeout(()=>{var n;(n=w.current)==null||n.focus()},500);return()=>clearTimeout(l)},[e.id]);const x=l=>{var S;let n=l.target.value;const C=((S=e.validation)==null?void 0:S.maxLength)||2048;if(n.length>C&&(n=n.slice(0,C)),e.type==="number"){const I=n===""?"":parseFloat(n);s(e.id,I)}else s(e.id,n)},u=()=>{var l,n,C,S,I;if((l=e.validation)!=null&&l.required&&!d)return!1;if(d){if((n=e.validation)!=null&&n.minLength&&d.length<e.validation.minLength||e.type==="email"&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(d))return!1;if((C=e.validation)!=null&&C.pattern)try{if(!new RegExp(e.validation.pattern).test(d))return!1}catch(E){console.error("Invalid regex pattern in schema",E)}if(e.type==="number"){const E=parseFloat(d);if(!isNaN(E)&&(((S=e.validation)==null?void 0:S.min)!==void 0&&E<e.validation.min||((I=e.validation)==null?void 0:I.max)!==void 0&&E>e.validation.max))return!1}}return!0},m=l=>{if(l.key==="Enter"&&!l.shiftKey){if(l.preventDefault(),!u()){const n=document.querySelector(".sawabona-form-container")||document.body;n.classList.add("shake-animation"),setTimeout(()=>n.classList.remove("shake-animation"),500);return}r()}};return t.jsxs("div",{className:"w-full relative group",children:[t.jsx("input",{ref:w,type:e.type,value:typeof d=="string"||typeof d=="number"?d:"",onChange:x,onKeyDown:m,placeholder:e.placeholder,minLength:(b=e.validation)==null?void 0:b.minLength,maxLength:((N=e.validation)==null?void 0:N.maxLength)||2048,min:(k=e.validation)==null?void 0:k.min,max:(v=e.validation)==null?void 0:v.max,pattern:(i=e.validation)==null?void 0:i.pattern,className:`
|
|
2
|
+
w-full bg-transparent border-b-2 border-sw-text-secondary/20
|
|
3
|
+
py-4 text-2xl md:text-3xl font-medium outline-none transition-colors
|
|
4
|
+
placeholder:text-sw-text-secondary/30
|
|
5
|
+
focus:border-sw-primary
|
|
6
|
+
font-sw-heading
|
|
7
|
+
`,autoFocus:!0}),void 0,t.jsxs("p",{className:"text-sm opacity-50 mt-4",children:[e.type==="email"&&"Press Enter to continue",e.type==="text"&&"Press Enter to continue",e.type==="number"&&"Press Enter to continue",e.type==="url"&&"Press Enter to continue"]})]})}function D({question:e}){var x;const{answers:f,setAnswer:s,nextStep:r}=T(),p=f[e.id]||"",d=u=>{s(e.id,u),setTimeout(()=>r(),400)},w="ABCDEFGHIJKLMNOPQRSTUVWXYZ";return o.useEffect(()=>{const u=m=>{var N;const y=m.key.toUpperCase(),b=w.indexOf(y);b>=0&&b<(((N=e.options)==null?void 0:N.length)||0)&&d(e.options[b].value)};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[e.options,e.id]),t.jsx("div",{className:"flex flex-col gap-3 w-full max-w-xl",children:(x=e.options)==null?void 0:x.map((u,m)=>{const y=Array.isArray(p)?p.includes(u.value):p===u.value;return t.jsxs(c.motion.button,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:m*.05},onClick:()=>d(u.value),className:`
|
|
8
|
+
w-full text-left p-4 rounded-lg border-2 transition-all duration-200
|
|
9
|
+
flex items-center justify-between group
|
|
10
|
+
${y?"border-sw-primary bg-sw-primary/5 text-sw-primary":"border-sw-text-secondary/10 hover:border-sw-primary/50 hover:bg-sw-primary/5"}
|
|
11
|
+
`,children:[t.jsxs("span",{className:"text-lg font-medium flex items-center gap-3",children:[t.jsx("span",{className:`
|
|
12
|
+
w-6 h-6 rounded-full border-2 flex items-center justify-center transition-colors
|
|
13
|
+
${y?"border-sw-primary bg-sw-primary":"border-sw-text-secondary/30 group-hover:border-sw-primary/50"}
|
|
14
|
+
`,children:y&&t.jsx(F.Check,{size:14,className:"text-sw-background"})}),u.label]}),t.jsxs("span",{className:"opacity-0 group-hover:opacity-100 transition-opacity text-xs font-mono uppercase tracking-widest text-sw-text-secondary/50",children:["Select ",t.jsxs("span",{className:"hidden md:inline",children:["Key ",m+1]})]})]},String(u.value))})})}function H({question:e}){var d;const{answers:f,setAnswer:s}=T(),r=f[e.id]||0,p=Math.min(((d=e.validation)==null?void 0:d.max)||5,20);return t.jsxs("div",{className:"flex flex-col gap-6",children:[t.jsx("div",{className:"flex gap-4 flex-wrap",children:Array.from({length:p}).map((w,x)=>{const u=x+1,m=u<=r;return t.jsx(c.motion.button,{initial:{opacity:0,scale:0},animate:{opacity:1,scale:1},transition:{delay:x*.05},onClick:()=>s(e.id,u),whileHover:{scale:1.2,rotate:5},whileTap:{scale:.9},className:"focus:outline-none",children:t.jsx(F.Star,{className:`w-12 h-12 md:w-16 md:h-16 transition-all duration-300 ${m?"fill-yellow-400 text-yellow-400 drop-shadow-[0_0_15px_rgba(250,204,21,0.4)]":"text-zinc-600 hover:text-yellow-400/50"}`,strokeWidth:1.5})},x)})}),t.jsxs("div",{className:"flex justify-between w-full max-w-[300px] md:max-w-[400px] px-2 items-center",children:[t.jsx("span",{className:"text-sm md:text-base font-medium text-sw-text-secondary/50 uppercase tracking-wide",children:e.minLabel||"Poor"}),t.jsx(c.motion.div,{initial:{opacity:0,scale:.8},animate:{opacity:r?1:0,scale:r?1:.8},className:"font-bold text-primary text-xl",children:r?`${r} / ${p}`:""}),t.jsx("span",{className:"text-sm md:text-base font-medium text-muted-foreground uppercase tracking-wide",children:e.maxLabel||"Excellent"})]})]})}function K({question:e}){const{schema:f}=T(),s=f.questions.findIndex(x=>x.id===e.id)+1,r=f.questions.length,p={hidden:{opacity:0,y:20},visible:{opacity:1,y:0,transition:{duration:.5,ease:[.22,1,.36,1]}}},d=x=>x&&x.replace(/\{\{(\w+)\}\}/g,(u,m)=>{const y=w.answers[m];return y!=null?String(y):""}),w=T();return t.jsxs(c.motion.div,{className:"flex flex-col gap-8 w-full max-w-4xl mx-auto",initial:"hidden",animate:"visible",variants:{visible:{transition:{staggerChildren:.1}}},children:[t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx(c.motion.div,{variants:p,className:"flex gap-4 items-baseline",children:t.jsxs("span",{className:"flex items-center gap-2 text-sm md:text-base font-medium text-sw-primary/90 bg-sw-primary/10 px-3 py-1 rounded-full border border-sw-primary/20 backdrop-blur-sm",children:[t.jsx("span",{children:s}),t.jsx("span",{className:"opacity-40 text-xs",children:"/"}),t.jsx("span",{className:"opacity-60",children:r})]})}),t.jsxs(c.motion.h2,{variants:p,className:"text-3xl md:text-4xl lg:text-5xl font-bold leading-tight tracking-tight text-pretty mt-2 font-sw-heading",children:[d(e.title)," ",t.jsx("span",{className:"text-sw-primary",children:"*"})]}),e.description&&t.jsx(c.motion.p,{variants:p,className:"text-lg md:text-xl text-muted-foreground font-normal leading-relaxed max-w-2xl mt-2",children:d(e.description)})]}),t.jsx(c.motion.div,{variants:p,className:"w-full mt-6",children:e.type==="text"||e.type==="email"||e.type==="number"||e.type==="url"?t.jsx(_,{question:e}):e.type==="select"?t.jsx(D,{question:e}):e.type==="rating"?t.jsx(H,{question:e}):t.jsxs("div",{className:"p-4 bg-yellow-100 dark:bg-yellow-900/30 text-yellow-800 dark:text-yellow-200 rounded",children:["Unsupported question type: ",e.type," (ID: ",e.id,")"]})})]})}const Q={next:"Next",back:"Back",submit:"Submit",required:"Required",optional:"Optional",stepInfo:"Question {{current}} of {{total}}"};function V({schema:e,onSubmit:f}){var k;const s=O({schema:e,onSubmit:f}),r=e.theme||{backgroundColor:"#ffffff",textColor:"#000000",primaryColor:"#000000",borderRadius:"8px",fontFamily:"sans-serif"},p=h(h({},Q),e.i18n),d={backgroundColor:r.backgroundColor,color:r.textColor,fontFamily:r.fontFamily},w=r.buttonVariant==="outline",x={backgroundColor:w?"transparent":r.primaryColor,color:w?r.primaryColor:r.textColor,border:w?`2px solid ${r.primaryColor}`:"none",borderRadius:r.borderRadius||"8px",fontWeight:600},u={color:r.primaryColor,borderRadius:r.borderRadius||"8px",fontWeight:600},{autoReload:m,reloadDelay:y=3e3}=e;if(o.useEffect(()=>{if(s.isCompleted&&m){const v=setTimeout(()=>{s.resetForm()},y);return()=>clearTimeout(v)}},[s.isCompleted,m,y,s.resetForm]),s.isCompleted)return t.jsxs("div",{className:"flex flex-col items-center justify-center h-full w-full p-8 text-center relative overflow-hidden",style:d,children:[m&&t.jsx(c.motion.div,{initial:{width:"0%"},animate:{width:"100%"},transition:{duration:y/1e3,ease:"linear"},className:"absolute top-0 left-0 h-1 bg-green-500 z-50"}),t.jsxs(c.motion.div,{initial:{scale:.9,opacity:0,y:20},animate:{scale:1,opacity:1,y:0},transition:{duration:.6,ease:[.22,1,.36,1]},className:"flex flex-col items-center",children:[t.jsx("div",{className:"mb-6 p-4 rounded-full bg-green-500/20 text-green-500 w-24 h-24 flex items-center justify-center",children:t.jsx(F.Check,{size:48})}),t.jsx("h1",{className:"text-4xl md:text-5xl font-bold mb-4 tracking-tight",children:"Obrigado!"}),t.jsx("p",{className:"text-xl opacity-70 max-w-md leading-relaxed",children:"Suas respostas foram enviadas com sucesso."})]})]});const b=e.questions.find(v=>v.id===s.currentStepId),N=(e.questions.findIndex(v=>v.id===s.currentStepId)+1)/e.questions.length*100;return t.jsx(L.Provider,{value:g(h({},s),{schema:e}),children:t.jsxs("div",{className:"w-full h-full flex flex-col relative overflow-hidden transition-colors duration-700",style:d,children:[t.jsxs("div",{className:"absolute top-0 left-0 w-full h-1 z-50",children:[t.jsx("div",{className:"absolute top-0 left-0 w-full h-full bg-current opacity-10"}),t.jsx(c.motion.div,{className:"h-full relative z-10",initial:{width:0},animate:{width:`${N}%`},transition:{duration:.5,ease:"easeInOut"},style:{backgroundColor:r.primaryColor}})]}),t.jsx("div",{className:"flex-1 flex flex-col items-center justify-center p-6 md:p-12 w-full max-w-5xl mx-auto z-10",children:t.jsx(c.AnimatePresence,{mode:"wait",children:b&&t.jsx(c.motion.div,{initial:{opacity:0,y:40},animate:{opacity:1,y:0},exit:{opacity:0,y:-40},transition:{duration:.5,ease:[.22,1,.36,1]},className:"w-full",children:t.jsx(K,{question:b})},b.id)})}),t.jsxs("div",{className:"w-full px-6 pt-6 pb-8 md:p-10 flex flex-col md:flex-row justify-between items-center z-20 gap-4",children:[r.showPoweredBy!==!1&&t.jsxs("a",{href:"#",className:"order-3 md:order-1 group flex items-center gap-2 px-3 py-1.5 rounded-md border border-white/10 bg-black/20 hover:border-sw-primary/50 hover:bg-black/40 transition-all duration-300 cursor-pointer no-underline backdrop-blur-sm",children:[t.jsx("span",{className:"text-[10px] md:text-xs font-mono font-medium tracking-[0.2em] uppercase text-muted-foreground group-hover:text-muted-foreground/80 transition-colors",children:"Powered By"}),t.jsx("span",{className:"text-[10px] md:text-xs font-mono font-bold tracking-[0.2em] uppercase transition-colors shadow-sw-primary",style:{color:r.brandColor||r.primaryColor},children:((k=r.poweredBy)==null?void 0:k.replace("Powered by ",""))||"SAWABONA TECH"})]}),t.jsxs("div",{className:"flex items-center gap-4 order-2 md:order-3 ml-auto",children:[t.jsx(c.motion.button,{onClick:s.prevStep,disabled:s.history.length===0,whileHover:{scale:1.05},whileTap:{scale:.95},className:"w-12 h-12 md:w-14 md:h-14 flex items-center justify-center disabled:opacity-0 disabled:pointer-events-none transition-all hover:bg-white/5 rounded-full",style:u,children:t.jsx(F.ChevronLeft,{size:24})}),t.jsxs(c.motion.button,{onClick:s.nextStep,whileHover:{scale:1.02},whileTap:{scale:.98},className:"px-8 py-3 md:px-10 md:py-4 text-lg font-bold shadow-2xl flex items-center gap-3 transition-all rounded-lg",style:x,children:[t.jsx("span",{children:s.currentStepId===e.questions[e.questions.length-1].id?r.submitText||p.submit:p.next}),s.currentStepId!==e.questions[e.questions.length-1].id&&t.jsx(F.ChevronRight,{size:20,strokeWidth:3})]})]})]})]})})}a.FormRenderer=V,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})}));
|