daply-ui 1.0.0 → 1.1.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.
@@ -1,5 +1,15 @@
1
- (function(i,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],r):(i=typeof globalThis<"u"?globalThis:i||self,r(i["daply-ui"]={},i["react/jsx-runtime"],i.React))})(this,(function(i,r,x){"use strict";const P=({children:l})=>r.jsx("button",{children:l}),E=({name:l,value:S,onChange:w,error:n,schema:v,theme:F="auto"})=>{const{type:j="text",required:u=!1,placeholder:m="",label:f,className:y=""}=v,a=F==="dark"||F==="auto"&&typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches,d={width:"100%",boxSizing:"border-box",padding:"16px",borderRadius:"8px",outline:"none",transition:"all 0.2s ease",fontSize:"16px",fontFamily:"inherit",border:n?`2px solid ${a?"#f87171":"#ef4444"}`:`1px solid ${a?"#374151":"#d1d5db"}`,backgroundColor:n?a?"rgba(153, 27, 27, 0.1)":"rgba(254, 226, 226, 1)":a?"#2a2a2a":"#ffffff",color:a?"#ffffff":"#111827"},k={...d,borderColor:n?a?"#f87171":"#ef4444":"#3b82f6",boxShadow:n?`0 0 0 3px ${a?"rgba(248, 113, 113, 0.2)":"rgba(239, 68, 68, 0.2)"}`:"0 0 0 3px rgba(59, 130, 246, 0.2)"},T={display:"block",fontWeight:"500",marginBottom:"8px",color:a?"#ffffff":"#111827",fontSize:"14px"},$={marginTop:"4px",fontSize:"14px",color:a?"#f87171":"#dc2626"},B={color:a?"#f87171":"#ef4444",marginLeft:"4px"},b={marginBottom:"24px",display:"flex",flexDirection:"column",alignItems:"flex-start",width:"100%"},g=a?"#6b7280":"#9ca3af";return j==="textarea"?r.jsxs("div",{style:b,children:[f?r.jsxs("label",{htmlFor:l,style:T,children:[f,u?r.jsx("span",{style:B,children:"*"}):null]}):null,r.jsx("textarea",{id:l,name:l,value:S,onChange:w,required:u,placeholder:m,rows:v.rows||4,style:d,onFocus:s=>{Object.assign(s.target.style,k)},onBlur:s=>{Object.assign(s.target.style,d)},className:y}),n?r.jsx("p",{style:$,children:n}):null,r.jsx("style",{children:`
2
- textarea::placeholder { color: ${g}; }
3
- `})]}):r.jsxs("div",{style:b,children:[f?r.jsxs("label",{htmlFor:l,style:T,children:[f,u?r.jsx("span",{style:B,children:"*"}):null]}):null,r.jsx("input",{id:l,name:l,type:j,value:S,onChange:w,required:u,placeholder:m,style:d,onFocus:s=>{Object.assign(s.target.style,k)},onBlur:s=>{Object.assign(s.target.style,d)},className:y}),n?r.jsx("p",{style:$,children:n}):null,r.jsx("style",{children:`
4
- input::placeholder { color: ${g}; }
5
- `})]})},L=l=>{const{formId:S,siteId:w,fields:n,baseUrl:v,apiToken:F,encryptedDbName:j,pageUrl:u,pageId:m,sessionId:f,metadata:y,onSuccess:a,onError:d,submitButtonText:k="Submit",submitButtonClassName:T="",formClassName:$="",loadingText:B="Submitting...",theme:b="auto"}=l,g=n.reduce((t,e)=>(t[e.name]=e.defaultValue||"",t),{}),[s,O]=x.useState(g),[N,I]=x.useState({}),[p,z]=x.useState(!1),[U,M]=x.useState(!1),q=b==="dark"||b==="auto"&&typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches,H=t=>{const{name:e,value:h}=t.target;O(o=>({...o,[e]:h})),N[e]&&I(o=>{const c={...o};return delete c[e],c})},W=()=>{const t={};return n.forEach(e=>{const h=s[e.name],o=String(h||"");if(e.required&&!o.trim()){t[e.name]=`${e.label||e.name} is required`;return}if(e.type==="email"&&o&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o)){t[e.name]="Please enter a valid email address";return}if(e.type==="url"&&o)try{new URL(o)}catch{t[e.name]="Please enter a valid URL";return}if(e.validation&&o){const c=e.validation(o);if(c){t[e.name]=c;return}}}),I(t),Object.keys(t).length===0},V=async t=>{if(t.preventDefault(),!!W()){z(!0);try{const e=n.reduce((D,C)=>(D[C.name]={type:C.type,required:C.required},D),{}),h={formId:S,siteId:w,formData:s,formSchema:e,...u&&{pageUrl:u},...m&&{pageId:m},...f&&{sessionId:f},...y&&{metadata:y}},o=await fetch(`${v}/api/v1/form-submissions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${F}`,"x-encrypted-db-name":j},body:JSON.stringify(h)});if(!o.ok){const D=await o.json().catch(()=>({}));throw new Error(D.message||`HTTP error! status: ${o.status}`)}const c=await o.json();O(g),I({}),a&&a(c)}catch(e){console.error("Form submission error:",e),d&&d(e)}finally{z(!1)}}},A={maxWidth:"612px",margin:"0 auto",padding:"32px",backgroundColor:q?"#1a1a1a":"#ffffff",borderRadius:"12px",boxShadow:q?"0 25px 50px -12px rgba(0, 0, 0, 0.5)":"0 10px 15px -3px rgba(0, 0, 0, 0.1)",border:`1px solid ${q?"#1f2937":"#e5e7eb"}`},J={width:"100%",padding:"16px 24px",background:p?"linear-gradient(to right, #4b5563, #4b5563)":U?"linear-gradient(to right, #1d4ed8, #1e40af)":"linear-gradient(to right, #2563eb, #1d4ed8)",color:"#ffffff",fontWeight:"bold",fontSize:"18px",textTransform:"uppercase",letterSpacing:"0.05em",borderRadius:"8px",border:"none",cursor:p?"not-allowed":"pointer",opacity:p?.5:1,transition:"all 0.2s ease",outline:"none",fontFamily:"inherit"};return r.jsxs("form",{onSubmit:V,style:A,className:$,children:[n.map(t=>r.jsx(E,{name:t.name,value:String(s[t.name]||""),onChange:H,error:N[t.name],schema:t,theme:b},t.name)),r.jsx("button",{type:"submit",disabled:p,style:J,onMouseEnter:()=>!p&&M(!0),onMouseLeave:()=>M(!1),onFocus:t=>{p||(t.target.style.boxShadow="0 0 0 3px rgba(59, 130, 246, 0.3)")},onBlur:t=>{t.target.style.boxShadow="none"},className:T,children:p?B:k})]})};i.Button=P,i.Form=L,i.InputField=E,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(B,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],e):(B=typeof globalThis<"u"?globalThis:B||self,e(B["daply-ui"]={},B["react/jsx-runtime"],B.React))})(this,(function(B,e,k){"use strict";const oe={small:{fontSize:"14px",padding:"8px 16px"},default:{fontSize:"16px",padding:"12px 24px"},large:{fontSize:"18px",padding:"16px 32px"}},ne=({label:o,disabled:s=!1,color:i="blue-900",icon:n,className:C="",style:L={},type:h="button",iconPosition:b="right",isNoLabelForSm:I=!1,size:m="default",onClick:j=()=>{},children:d,variant:S="primary",theme:z="auto"})=>{const u=z==="dark"||z==="auto"&&typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches,w=oe[m]||oe.default,F=d||e.jsxs(e.Fragment,{children:[b==="left"&&n&&e.jsx("span",{style:{display:"flex",alignItems:"center"},children:n}),!I&&o&&e.jsx("span",{style:{display:"flex",alignItems:"center"},children:o}),b==="right"&&n&&e.jsx("span",{style:{display:"flex",alignItems:"center"},children:n})]}),v=S==="primary"||i.includes("blue-700")||i.includes("blue-600")||i.includes("blue-500"),c=S==="secondary",p={position:"relative",display:"inline-block",width:"100%"},D={position:"absolute",inset:0,backgroundColor:s?"#374151":v?"#1d4ed8":c?u?"#1f2937":"#e5e7eb":"#1e3a8a",borderRadius:"8px",transform:"translateY(4px)",transition:"all 0.3s ease"},H={...w,color:c?u?"#ffffff":"#1f2937":"#ffffff",borderRadius:"8px",backgroundColor:c?u?"#000000":"#f3f4f6":v?"#3b82f6":"#000000",position:"relative",border:c?u?"1px solid #1e3a8a":"1px solid #e5e7eb":v?"1px solid #1e3a8a":s?"1px solid #374151":"1px solid #1e3a8a",display:"flex",width:"100%",justifyContent:"center",alignItems:"center",fontWeight:"800",gap:"8px",transition:"all 0.3s ease",cursor:s?"not-allowed":"pointer",opacity:s?.5:1,outline:"none",fontFamily:"inherit",...L},[E,y]=k.useState(!1),g=()=>{s||y(!0)},N=()=>{y(!1)},$=E&&!s?{transform:"translateY(4px)",color:c?u?"#ffffff":"#1f2937":"#93c5fd",backgroundColor:c?u?"#111827":"#e5e7eb":void 0}:{};return e.jsxs("div",{style:p,className:C,children:[e.jsx("div",{style:D}),e.jsx("button",{type:h,style:{...H,...$},disabled:s,onClick:j,onMouseEnter:g,onMouseLeave:N,children:F})]})},Q=({name:o,value:s,onChange:i,error:n,schema:C,theme:L="auto"})=>{const{type:h="text",required:b=!1,placeholder:I="",label:m,className:j=""}=C,d=L==="dark"||L==="auto"&&typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches,S={width:"100%",boxSizing:"border-box",padding:"16px",borderRadius:"8px",outline:"none",transition:"all 0.2s ease",fontSize:"16px",fontFamily:"inherit",border:n?`2px solid ${d?"#f87171":"#ef4444"}`:`1px solid ${d?"#374151":"#d1d5db"}`,backgroundColor:n?d?"rgba(153, 27, 27, 0.1)":"rgba(254, 226, 226, 1)":d?"#2a2a2a":"#ffffff",color:d?"#ffffff":"#111827"},z={...S,borderColor:n?d?"#f87171":"#ef4444":"#3b82f6",boxShadow:n?`0 0 0 3px ${d?"rgba(248, 113, 113, 0.2)":"rgba(239, 68, 68, 0.2)"}`:"0 0 0 3px rgba(59, 130, 246, 0.2)"},u={display:"block",fontWeight:"500",marginBottom:"8px",color:d?"#ffffff":"#111827",fontSize:"14px"},w={marginTop:"4px",fontSize:"14px",color:d?"#f87171":"#dc2626"},F={color:d?"#f87171":"#ef4444",marginLeft:"4px"},v={marginBottom:"24px",display:"flex",flexDirection:"column",alignItems:"flex-start",width:"100%"},c=d?"#6b7280":"#9ca3af";return h==="textarea"?e.jsxs("div",{style:v,children:[m?e.jsxs("label",{htmlFor:o,style:u,children:[m,b?e.jsx("span",{style:F,children:"*"}):null]}):null,e.jsx("textarea",{id:o,name:o,value:s,onChange:i,required:b,placeholder:I,rows:C.rows||4,style:S,onFocus:p=>{Object.assign(p.target.style,z)},onBlur:p=>{Object.assign(p.target.style,S)},className:j}),n?e.jsx("p",{style:w,children:n}):null,e.jsx("style",{children:`
2
+ textarea::placeholder { color: ${c}; }
3
+ `})]}):e.jsxs("div",{style:v,children:[m?e.jsxs("label",{htmlFor:o,style:u,children:[m,b?e.jsx("span",{style:F,children:"*"}):null]}):null,e.jsx("input",{id:o,name:o,type:h,value:s,onChange:i,required:b,placeholder:I,style:S,onFocus:p=>{Object.assign(p.target.style,z)},onBlur:p=>{Object.assign(p.target.style,S)},className:j}),n?e.jsx("p",{style:w,children:n}):null,e.jsx("style",{children:`
4
+ input::placeholder { color: ${c}; }
5
+ `})]})},ae=o=>{const{formId:s,siteId:i,fields:n,baseUrl:C,apiToken:L,encryptedDbName:h,pageUrl:b,pageId:I,sessionId:m,metadata:j,onSuccess:d,onError:S,submitButtonText:z="Submit",submitButtonClassName:u="",formClassName:w="",loadingText:F="Submitting...",theme:v="auto"}=o,c=n.reduce((t,r)=>(t[r.name]=r.defaultValue||"",t),{}),[p,D]=k.useState(c),[H,E]=k.useState({}),[y,g]=k.useState(!1),[N,$]=k.useState(!1),O=v==="dark"||v==="auto"&&typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches,J=t=>{const{name:r,value:W}=t.target;D(f=>({...f,[r]:W})),H[r]&&E(f=>{const T={...f};return delete T[r],T})},A=()=>{const t={};return n.forEach(r=>{const W=p[r.name],f=String(W||"");if(r.required&&!f.trim()){t[r.name]=`${r.label||r.name} is required`;return}if(r.type==="email"&&f&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(f)){t[r.name]="Please enter a valid email address";return}if(r.type==="url"&&f)try{new URL(f)}catch{t[r.name]="Please enter a valid URL";return}if(r.validation&&f){const T=r.validation(f);if(T){t[r.name]=T;return}}}),E(t),Object.keys(t).length===0},P=async t=>{if(t.preventDefault(),!!A()){g(!0);try{const r=n.reduce((q,_)=>(q[_.name]={type:_.type,required:_.required},q),{}),W={formId:s,siteId:i,formData:p,formSchema:r,...b&&{pageUrl:b},...I&&{pageId:I},...m&&{sessionId:m},...j&&{metadata:j}},f=await fetch(`${C}/api/v1/form-submissions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${L}`,"x-encrypted-db-name":h},body:JSON.stringify(W)});if(!f.ok){const q=await f.json().catch(()=>({}));throw new Error(q.message||`HTTP error! status: ${f.status}`)}const T=await f.json();D(c),E({}),d&&d(T)}catch(r){console.error("Form submission error:",r),S&&S(r)}finally{g(!1)}}},X={maxWidth:"612px",margin:"0 auto",padding:"32px",backgroundColor:O?"#1a1a1a":"#ffffff",borderRadius:"12px",boxShadow:O?"0 25px 50px -12px rgba(0, 0, 0, 0.5)":"0 10px 15px -3px rgba(0, 0, 0, 0.1)",border:`1px solid ${O?"#1f2937":"#e5e7eb"}`},Y={width:"100%",padding:"16px 24px",background:y?"linear-gradient(to right, #4b5563, #4b5563)":N?"linear-gradient(to right, #1d4ed8, #1e40af)":"linear-gradient(to right, #2563eb, #1d4ed8)",color:"#ffffff",fontWeight:"bold",fontSize:"18px",textTransform:"uppercase",letterSpacing:"0.05em",borderRadius:"8px",border:"none",cursor:y?"not-allowed":"pointer",opacity:y?.5:1,transition:"all 0.2s ease",outline:"none",fontFamily:"inherit"};return e.jsxs("form",{onSubmit:P,style:X,className:w,children:[n.map(t=>e.jsx(Q,{name:t.name,value:String(p[t.name]||""),onChange:J,error:H[t.name],schema:t,theme:v},t.name)),e.jsx("button",{type:"submit",disabled:y,style:Y,onMouseEnter:()=>!y&&$(!0),onMouseLeave:()=>$(!1),onFocus:t=>{y||(t.target.style.boxShadow="0 0 0 3px rgba(59, 130, 246, 0.3)")},onBlur:t=>{t.target.style.boxShadow="none"},className:u,children:y?F:z})]})},se=({steps:o,formId:s,siteId:i,baseUrl:n,apiToken:C,encryptedDbName:L,pageUrl:h,pageId:b,sessionId:I,metadata:m,onSuccess:j,onError:d,submitButtonText:S="Submit",submitButtonClassName:z="",formClassName:u="",loadingText:w="Submitting...",theme:F="auto",showStepIndicator:v=!0})=>{const[c,p]=k.useState(0),[D,H]=k.useState({}),[E,y]=k.useState({}),[g,N]=k.useState(!1),[$,O]=k.useState(!1),[J,A]=k.useState(!1),P=o[c],X=c===0,Y=c===o.length-1,t=F==="dark"||F==="auto"&&typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches,r=a=>{const{name:l,value:Z}=a.target;H(x=>({...x,[l]:Z})),E[l]&&y(x=>{const V={...x};return delete V[l],V})},W=()=>{const a={};return P.fields.forEach(l=>{const Z=D[l.name],x=String(Z||"");if(l.required&&!x.trim()){a[l.name]=`${l.label||l.name} is required`;return}if(l.type==="email"&&x&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(x)){a[l.name]="Please enter a valid email address";return}if(l.type==="url"&&x)try{new URL(x)}catch{a[l.name]="Please enter a valid URL";return}if(l.validation&&x){const V=l.validation(x);if(V){a[l.name]=V;return}}}),y(a),Object.keys(a).length===0},f=()=>{W()&&(p(a=>Math.min(a+1,o.length-1)),window.scrollTo({top:0,behavior:"smooth"}))},T=()=>{p(a=>Math.max(a-1,0)),window.scrollTo({top:0,behavior:"smooth"})},q=async a=>{if(a.preventDefault(),!Y){f();return}if(W()){N(!0);try{const l=o.reduce((K,xe)=>(xe.fields.forEach(te=>{K[te.name]={type:te.type,required:te.required}}),K),{}),Z={formId:s,siteId:i,formData:D,formSchema:l,...h&&{pageUrl:h},...b&&{pageId:b},...I&&{sessionId:I},...m&&{metadata:m}},x=await fetch(`${n}/api/v1/form-submissions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${C}`,"x-encrypted-db-name":L},body:JSON.stringify(Z)});if(!x.ok){const K=await x.json().catch(()=>({}));throw new Error(K.message||`HTTP error! status: ${x.status}`)}const V=await x.json();H({}),y({}),p(0),j&&j(V)}catch(l){console.error("Form submission error:",l),d&&d(l)}finally{N(!1)}}},_={maxWidth:"612px",margin:"0 auto",padding:"32px",backgroundColor:t?"#1a1a1a":"#ffffff",borderRadius:"12px",boxShadow:t?"0 25px 50px -12px rgba(0, 0, 0, 0.5)":"0 10px 15px -3px rgba(0, 0, 0, 0.1)",border:`1px solid ${t?"#1f2937":"#e5e7eb"}`},G={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"32px",gap:"8px"},U=a=>({flex:1,height:"4px",borderRadius:"2px",backgroundColor:a<=c?"#2563eb":t?"#374151":"#e5e7eb",transition:"background-color 0.3s ease"}),R={fontSize:"24px",fontWeight:"bold",color:t?"#ffffff":"#111827",marginBottom:"8px"},ee={fontSize:"14px",color:t?"#9ca3af":"#6b7280",marginBottom:"24px"},M={fontSize:"14px",fontWeight:"500",color:t?"#9ca3af":"#6b7280",marginBottom:"16px"},he={position:"fixed",bottom:"1rem",left:"50%",transform:"translateX(-50%)",width:"calc(100% - 2rem)",maxWidth:"500px",zIndex:50},ue={background:t?"rgba(255, 255, 255, 0.1)":"rgba(0, 0, 0, 0.05)",backdropFilter:"blur(20px) saturate(120%)",WebkitBackdropFilter:"blur(20px) saturate(120%)",border:t?"1px solid rgba(255, 255, 255, 0.2)":"1px solid rgba(0, 0, 0, 0.1)",borderRadius:"16px",padding:"16px",boxShadow:t?"0 25px 50px -12px rgba(0, 0, 0, 0.8)":"0 25px 50px -12px rgba(0, 0, 0, 0.25)",display:"flex",justifyContent:"space-between",alignItems:"center",gap:"16px",transition:"all 0.3s ease-in-out"},ge={width:"64px",minWidth:"64px",height:"64px",padding:"0",background:t?"#e2e8f0":"#f1f5f9",color:t?"#111827":"#475569",borderRadius:"12px",border:"none",cursor:"pointer",transition:"all 0.3s ease",outline:"none",fontFamily:"inherit",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1)",transform:J?"scale(1.03)":"scale(1)"},re={flex:1,height:"64px",padding:"16px 24px",background:g?t?"#4b5563":"#94a3b8":$?t?"#1e40af":"#1d4ed8":t?"#2563eb":"#3b82f6",color:"#ffffff",fontWeight:"bold",fontSize:"20px",textTransform:"uppercase",letterSpacing:"0.05em",borderRadius:"12px",border:"none",cursor:g?"not-allowed":"pointer",opacity:g?.5:1,transition:"all 0.3s ease",outline:"none",fontFamily:"inherit",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)",transform:$&&!g?"scale(1.03)":"scale(1)"},be={...re,background:g?"#4b5563":$?"#15803d":"#16a34a"},ye={marginBottom:"160px"};return e.jsxs("form",{onSubmit:q,style:_,className:u,children:[v&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:M,children:["Step ",c+1," of ",o.length]}),e.jsx("div",{style:G,children:o.map((a,l)=>e.jsx("div",{style:U(l)},l))})]}),P.title&&e.jsx("h2",{style:R,children:P.title}),P.description&&e.jsx("p",{style:ee,children:P.description}),e.jsx("div",{style:ye,children:P.fields.map(a=>e.jsx(Q,{name:a.name,value:String(D[a.name]||""),onChange:r,error:E[a.name],schema:a,theme:F},a.name))}),e.jsx("div",{style:he,children:e.jsxs("div",{style:ue,children:[!X&&e.jsx("button",{type:"button",onClick:T,style:ge,onMouseEnter:()=>A(!0),onMouseLeave:()=>A(!1),disabled:g,"aria-label":"Previous step",children:e.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"m15 18-6-6 6-6"})})}),e.jsx("button",{type:"submit",disabled:g,style:Y?be:re,onMouseEnter:()=>!g&&O(!0),onMouseLeave:()=>O(!1),onFocus:a=>{g||(a.target.style.boxShadow="0 0 0 3px rgba(59, 130, 246, 0.3)")},onBlur:a=>{a.target.style.boxShadow="0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)"},className:z,children:g?e.jsxs(e.Fragment,{children:[e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{animation:"spin 1s linear infinite"},children:e.jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),e.jsx("style",{children:`
6
+ @keyframes spin {
7
+ from { transform: rotate(0deg); }
8
+ to { transform: rotate(360deg); }
9
+ }
10
+ `}),w]}):Y?e.jsxs(e.Fragment,{children:[S,e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"m22 2-7 20-4-9-9-4Z"}),e.jsx("path",{d:"M22 2 11 13"})]})]}):e.jsxs(e.Fragment,{children:["Next",e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"m9 18 6-6-6-6"})})]})})]})})]})},ie=o=>{const s=/^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=)([^#&?]*).*/,i=o.match(s);return i&&i[2].length===11?i[2]:null},le=(o,s=!0)=>{const i=ie(o);if(!i)return o;const n=new URLSearchParams({autoplay:s?"1":"0",rel:"0",modestbranding:"1",showinfo:"0",fs:"1",enablejsapi:"1",playsinline:"1",controls:"1",disablekb:"0",iv_load_policy:"3",cc_load_policy:"0",start:"0",origin:typeof window<"u"?window.location.origin:""});return`https://www.youtube.com/embed/${i}?${n.toString()}`},de=(o,s,i,n,C)=>{const L="https://app.daply.ai/embed/video",h=new URLSearchParams({src:o,title:s,author:i||"",date:n||new Date().toISOString()});return C&&h.append("autoplay","1"),`${L}?${h.toString()}`},ce=o=>o.includes("storage.googleapis.com/daply-transcoder-storage")&&o.includes("manifest.m3u8"),pe=o=>o.includes(".m3u8")||o.includes("/manifest.m3u8"),fe=({videoUrl:o,youtubeUrl:s,title:i,author:n="Daply",date:C=new Date().toISOString(),thumbnailUrl:L,autoplay:h=!1,className:b="",onVideoClick:I,theme:m="auto"})=>{const[j,d]=k.useState(h),[S,z]=k.useState(!h),[u,w]=k.useState(!1),F=m==="dark"||m==="auto"&&typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches,v=!!s,c=o&&ce(o),p=o&&pe(o),D=!!(o||s),H=()=>{w(!0),d(!0),z(!1),I&&I(),setTimeout(()=>w(!1),1e3)},E=()=>{const M=s||o;M&&window.open(M,"_blank")},y={position:"relative",aspectRatio:"16 / 9",backgroundColor:"#000000",borderRadius:"8px",overflow:"hidden"},g={position:"relative",width:"100%",height:"100%"},N={width:"100%",height:"100%",objectFit:"cover"},$={width:"100%",height:"100%",background:"linear-gradient(135deg, #1f2937 0%, #111827 100%)",display:"flex",alignItems:"center",justifyContent:"center"},O={position:"absolute",inset:0,backgroundColor:"rgba(0, 0, 0, 0.4)"},J={position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center"},A={width:"64px",height:"64px",borderRadius:"50%",backgroundColor:"rgba(255, 255, 255, 0.2)",backdropFilter:"blur(10px)",border:"2px solid rgba(255, 255, 255, 0.2)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.3s ease"},P={position:"absolute",bottom:0,left:0,right:0,background:"linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent)",padding:"16px"},X={display:"flex",alignItems:"center",justifyContent:"space-between"},Y={flex:1},t={color:"#ffffff",fontWeight:"500",fontSize:"14px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},r={color:"rgba(255, 255, 255, 0.8)",fontSize:"12px"},W={position:"absolute",top:"12px",right:"12px",padding:"4px 8px",backgroundColor:"rgba(0, 0, 0, 0.6)",backdropFilter:"blur(10px)",borderRadius:"9999px",fontSize:"12px",color:"#ffffff"},f={width:"32px",height:"32px",padding:0,backgroundColor:"rgba(255, 255, 255, 0.2)",backdropFilter:"blur(10px)",borderRadius:"4px",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"background-color 0.3s ease"},T={position:"absolute",inset:0,backgroundColor:"rgba(0, 0, 0, 0.7)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:10},q={width:"32px",height:"32px",border:"2px solid transparent",borderTopColor:"rgba(255, 255, 255, 0.8)",borderRadius:"50%",animation:"spin 1s linear infinite"},_={width:"100%",height:"100%",position:"relative"},G={width:"100%",height:"100%",borderRadius:"8px",backgroundColor:"#000000"},U={width:"100%",height:"100%",objectFit:"cover",borderRadius:"8px",backgroundColor:"#000000"},R={aspectRatio:"16 / 9",backgroundColor:F?"#111827":"#f3f4f6",borderRadius:"8px",display:"flex",alignItems:"center",justifyContent:"center"},ee={textAlign:"center",color:F?"#9ca3af":"#6b7280"};return D?e.jsxs(e.Fragment,{children:[e.jsx("style",{children:`
11
+ @keyframes spin {
12
+ from { transform: rotate(0deg); }
13
+ to { transform: rotate(360deg); }
14
+ }
15
+ `}),e.jsx("div",{style:y,className:b,children:S&&!j?e.jsxs("div",{style:g,children:[L?e.jsx("img",{src:L,alt:i,style:N,loading:"lazy"}):e.jsx("div",{style:$,children:e.jsxs("div",{style:{textAlign:"center",color:"#ffffff"},children:[e.jsx("div",{style:{width:"48px",height:"48px",backgroundColor:"rgba(255, 255, 255, 0.2)",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",margin:"0 auto",backdropFilter:"blur(10px)"},children:e.jsx("svg",{style:{width:"24px",height:"24px",marginLeft:"4px"},fill:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{d:"M8 5v14l11-7z"})})}),e.jsx("p",{style:{fontSize:"14px",fontWeight:"500",marginTop:"8px"},children:i})]})}),e.jsx("div",{style:O}),e.jsx("div",{style:J,children:e.jsx("button",{onClick:H,style:A,onMouseEnter:M=>{M.currentTarget.style.backgroundColor="rgba(255, 255, 255, 0.3)"},onMouseLeave:M=>{M.currentTarget.style.backgroundColor="rgba(255, 255, 255, 0.2)"},children:e.jsx("svg",{style:{width:"32px",height:"32px",color:"#ffffff",marginLeft:"4px"},fill:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{d:"M8 5v14l11-7z"})})})}),e.jsx("div",{style:P,children:e.jsxs("div",{style:X,children:[e.jsxs("div",{style:Y,children:[e.jsx("h4",{style:t,children:i}),e.jsxs("p",{style:r,children:[n," • ",new Date(C).toLocaleDateString()]})]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:e.jsx("button",{onClick:E,style:f,onMouseEnter:M=>{M.currentTarget.style.backgroundColor="rgba(255, 255, 255, 0.3)"},onMouseLeave:M=>{M.currentTarget.style.backgroundColor="rgba(255, 255, 255, 0.2)"},children:e.jsx("svg",{style:{width:"16px",height:"16px",color:"#ffffff"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})})})]})}),e.jsx("div",{style:W,children:v?"YouTube":c?"HLS Stream":p?"Live Stream":"Video"})]}):e.jsxs("div",{style:_,children:[u&&e.jsx("div",{style:T,children:e.jsx("div",{style:q})}),v&&s?e.jsx("iframe",{src:le(s,h),width:"100%",height:"100%",frameBorder:"0",allowFullScreen:!0,allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",title:i,style:G,loading:"lazy",onLoad:()=>w(!1),onError:()=>w(!1)}):c||p?e.jsx("iframe",{src:de(o,i,n,C,h),width:"100%",height:"100%",frameBorder:"0",allowFullScreen:!0,allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",title:`${i} - Video Player`,style:G,onLoad:()=>w(!1)}):e.jsx("video",{src:o??void 0,controls:!0,autoPlay:h,preload:"metadata",controlsList:"nodownload",style:U,onLoadStart:()=>w(!1),children:"Your browser does not support the video tag."})]})})]}):e.jsx("div",{style:R,className:b,children:e.jsxs("div",{style:ee,children:[e.jsxs("svg",{style:{width:"48px",height:"48px",margin:"0 auto 8px",opacity:.5},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M14.752 11.168l-3.197-2.132A1 1 0 0010 9.87v4.263a1 1 0 001.555.832l3.197-2.132a1 1 0 000-1.664z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})]}),e.jsx("p",{children:"No video available"})]})})};B.Button=ne,B.Form=ae,B.InputField=Q,B.MultiStepForm=se,B.VideoPlayer=fe,Object.defineProperty(B,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "daply-ui",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"