uhuu-components 0.2.51 → 0.2.52
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/uhuu-components.umd.js
CHANGED
|
@@ -875,7 +875,7 @@ ${d}`}const u=af(()=>{if(!i.current||!o.current){console.warn("Container or page
|
|
|
875
875
|
|
|
876
876
|
If you want to hide the \`${e.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
877
877
|
|
|
878
|
-
For more information, see https://radix-ui.com/primitives/docs/components/${e.docsSlug}`;return T.useEffect(()=>{t&&(document.getElementById(t)||console.error(r))},[r,t]),null},QT="DialogDescriptionWarning",JT=({contentRef:t,descriptionId:e})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Cg(QT).contentName}}.`;return T.useEffect(()=>{const a=t.current?.getAttribute("aria-describedby");e&&a&&(document.getElementById(e)||console.warn(n))},[n,t,e]),null},kg=cg,eA=ug,Eg=fg,Ll=mg,jl=hg,Wl=vg,Bl=bg,ql=xg;const Tg=kg,tA=Eg,Ag=T.forwardRef(({className:t,...e},r)=>y.jsx(Ll,{className:pe("fixed inset-0 z-50 bg-black/50 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...e,ref:r}));Ag.displayName=Ll.displayName;const Rl=T.forwardRef(({side:t="right",className:e,children:r,...n},a)=>{const{portalContainer:i}=zs();return y.jsxs(tA,{container:i||void 0,children:[y.jsx(Ag,{}),y.jsxs(jl,{ref:a,className:pe("fixed z-50 gap-4 bg-white p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",t==="top"&&"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",t==="bottom"&&"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",t==="left"&&"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",t==="right"&&"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm",e),...n,children:[r,y.jsxs(ql,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-white transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-gray-400 focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-gray-100",children:[y.jsx(hf,{className:"h-4 w-4"}),y.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});Rl.displayName=jl.displayName;const Fl=({className:t,...e})=>y.jsx("div",{className:pe("flex flex-col space-y-2 text-center sm:text-left",t),...e});Fl.displayName="SheetHeader";const _g=({className:t,...e})=>y.jsx("div",{className:pe("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...e});_g.displayName="SheetFooter";const $l=T.forwardRef(({className:t,...e},r)=>y.jsx(Wl,{ref:r,className:pe("text-lg font-medium text-gray-900",t),...e}));$l.displayName=Wl.displayName;const Gl=T.forwardRef(({className:t,...e},r)=>y.jsx(Bl,{ref:r,className:pe("text-sm text-gray-500",t),...e}));Gl.displayName=Bl.displayName;function Vl(t){const{pageComponents:e,payload:r,setup:n={width:210,height:297},thumbnailWidth:a=200,thumbnailHeight:i}=t,o=n.width||210,s=n.height||297,l=o/s,c=a,d=i??Math.round(c/l),u=o*3.779527559,p=s*3.779527559;return(f,v,m)=>{const g=f.strictPosition,w=g==="start"||g==="end";if(f.kind==="group"){const x=f.firstPageId,h=f.firstPageComponentKey??x,b=jn(r,{id:x,componentKey:h}),S=f.firstPageComponent||(h?e[h]:null),E=r?.integrations?.[f.id];return y.jsxs("div",{className:`relative bg-white border transition-all ${m?"border-blue-400 shadow-2xl scale-105":w?"border-gray-300 bg-gray-50":"border-gray-200 hover:border-gray-300 hover:shadow-lg"}`,style:{width:`${c}px`,height:`${d}px`},title:f.id,children:[S?y.jsx("div",{className:"w-full h-full flex items-center justify-center bg-gray-50 overflow-hidden relative pointer-events-none",children:y.jsx("div",{style:{transform:`scale(${Math.min(c/u,d/p)})`,transformOrigin:"center"},children:y.jsx("div",{className:"!shrink-0",style:{width:`${u}px`,height:`${p}px`,backgroundColor:"white",pointerEvents:"none"},children:y.jsx(S,{payload:r,pageId:x,templateId:h,pagePayload:b,componentKey:h,integration:E})})})}):y.jsx("div",{className:"w-full h-full flex items-center justify-center bg-gray-50 pointer-events-none",children:y.jsxs("div",{className:"text-center p-4",children:[y.jsxs("div",{className:"text-sm font-medium text-gray-700",children:["Group ",f.id]}),y.jsx("div",{className:"text-xs text-gray-500 mt-1",children:x||"No preview"})]})}),y.jsxs("div",{className:"absolute top-2 right-2 px-2 py-1 bg-blue-600/80 backdrop-blur-sm text-white text-xs font-medium rounded shadow-lg pointer-events-none",children:["Group (",f.pageCount," pages)"]}),w&&y.jsxs("div",{className:"absolute top-2 left-2 px-2 py-1 bg-gray-600/80 backdrop-blur-sm text-white text-xs font-medium rounded shadow-lg pointer-events-none flex items-center gap-1",children:[y.jsx(Ds,{className:"size-3"}),y.jsx("span",{children:g==="start"?"Start":"End"})]}),y.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-black/40 backdrop-blur-sm p-3 pointer-events-none",children:y.jsx("div",{className:"flex items-center justify-between gap-2 text-white",children:y.jsx("div",{className:"flex-1 min-w-0",children:y.jsx("div",{className:"text-sm font-medium truncate",children:f.label||f.id})})})}),m&&y.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-blue-500/10 pointer-events-none",children:y.jsx("div",{className:"text-blue-600 font-medium text-sm bg-white/90 px-3 py-1 rounded-full shadow-lg",children:"Dragging Group..."})})]})}else{const x=f.pageId,h=f.pageComponentKey??x,b=jn(r,{id:x,componentKey:h}),S=f.pageComponent||(h?e[h]:null),E=x?ag(r,{id:x}):void 0;return y.jsxs("div",{className:`relative bg-white border transition-all ${m?"border-blue-400 shadow-2xl scale-105":w?"border-gray-300 bg-gray-50":"border-gray-200 hover:border-gray-300 hover:shadow-lg"}`,style:{width:`${c}px`,height:`${d}px`},title:f.pageId,children:[S?y.jsx("div",{className:"w-full h-full flex items-center justify-center bg-gray-50 overflow-hidden relative pointer-events-none",children:y.jsx("div",{className:"flex items-center justify-center pointer-events-none",style:{transform:`scale(${Math.min(c/u,d/p)})`,transformOrigin:"center"},children:y.jsx("div",{className:"!shrink-0",style:{width:`${u}px`,height:`${p}px`,backgroundColor:"white",pointerEvents:"none"},children:y.jsx(S,{payload:r,pageId:x,templateId:h,pagePayload:b,componentKey:h,integration:E})})})}):y.jsx("div",{className:"w-full h-full flex items-center justify-center bg-gray-50 pointer-events-none",children:y.jsxs("div",{className:"text-center p-4",children:[y.jsxs("div",{className:"text-sm font-medium text-gray-700",children:["Page ",f.pageNum]}),y.jsx("div",{className:"text-xs text-gray-500 mt-1",children:x||"No preview"})]})}),w&&y.jsxs("div",{className:"absolute top-2 left-2 px-2 py-1 bg-gray-600/80 backdrop-blur-sm text-white text-xs font-medium rounded shadow-lg pointer-events-none flex items-center gap-1",children:[y.jsx(Ds,{className:"size-3"}),y.jsx("span",{children:g==="start"?"Start":"End"})]}),y.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-black/40 backdrop-blur-sm p-3 pointer-events-none",children:y.jsx("div",{className:"flex items-center justify-between gap-2 text-white",children:y.jsx("div",{className:"flex-1 min-w-0",children:y.jsx("div",{className:"text-sm font-medium truncate",children:f.pageLabel||`Page ${f.pageNum}`})})})}),m&&y.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-blue-500/10 pointer-events-none",children:y.jsx("div",{className:"text-blue-600 font-medium text-sm bg-white/90 px-3 py-1 rounded-full shadow-lg",children:"Dragging..."})})]})}}}function rA({open:t,onOpenChange:e,availableItems:r,onSelectItem:n,pageComponents:a,payload:i,setup:o={width:210,height:297},gridColsClass:s="page-order-grid-cols"}){const[l,c]=T.useState(""),d=T.useMemo(()=>{if(!l.trim())return r;const b=l.toLowerCase();return r.filter(S=>(S.label||"").toLowerCase().includes(b)||S.id.toLowerCase().includes(b))},[r,l]),u=b=>{e(!1),n(b)},p=o.width||210,f=o.height||297,v=p/f,m=200,g=Math.round(m/v),w=T.useMemo(()=>a?Vl({pageComponents:a,payload:i,setup:o,thumbnailWidth:m,thumbnailHeight:g}):null,[a,i,o,m,g]),x=(b,S)=>{if(!b)return[];if(Array.isArray(b))return b;try{const E=b(S);if(!Array.isArray(E))return console.error("[uhuu-components] pageComponentKeys function must return an array, got:",typeof E),[];const k=E.filter(C=>typeof C=="string");return k.length!==E.length&&console.warn("[uhuu-components] pageComponentKeys returned non-string values, filtering them out"),k}catch(E){return console.error("[uhuu-components] Error evaluating pageComponentKeys function:",E),[]}},h=(b,S)=>{if(b.kind==="group"){const C=b,A={payload:i,item:void 0,parent:void 0},_=x(C.pageComponentKeys,A),I=_[0];return{kind:"group",id:b.id,label:b.label,pageCount:_.length,firstPageId:I,firstPageComponentKey:I}}const E=b,k=E.componentKey??E.id;return{kind:"page",id:E.id,pageId:E.id,pageComponentKey:k,pageLabel:E.label,pageNum:S+1}};return y.jsx(Tg,{open:t,onOpenChange:e,children:y.jsxs(Rl,{side:"bottom",className:"h-[90vh] p-0 gap-0 w-full max-w-none bg-gray-50","data-uhuu-editor":!0,children:[y.jsx(Fl,{className:"border-b border-gray-200 p-4 bg-white",children:y.jsxs("div",{className:"flex items-end gap-3",children:[y.jsx("div",{className:"w-8 h-8 bg-gray-100 rounded-full flex items-center justify-center shrink-0 mb-0.5",children:y.jsx(mt,{className:"w-4 h-4"})}),y.jsxs("div",{className:"flex-1",children:[y.jsx($l,{className:"text-base font-medium text-gray-900 leading-tight",children:"Add Page or Group"}),y.jsx(Gl,{className:"text-xs text-gray-400 mt-0.5",children:"Select a page or group to add to your document."})]}),y.jsxs("div",{className:"flex items-center gap-1.5 text-gray-400 mb-0.5 mr-8",children:[y.jsx(cw,{className:"w-3.5 h-3.5 shrink-0"}),y.jsx("input",{type:"text",placeholder:"Filter…",value:l,onChange:b=>c(b.target.value),tabIndex:-1,className:"w-24 bg-transparent border-0 focus:outline-none text-sm text-gray-600 placeholder:text-gray-400 focus:w-40 transition-all duration-150"})]})]})}),y.jsx("div",{className:"flex-1 overflow-hidden",children:y.jsx("div",{className:"h-full max-h-[calc(90vh-100px)] overflow-auto p-6",children:d.length===0?y.jsxs("div",{className:"text-center py-16",children:[y.jsx("div",{className:"w-16 h-16 bg-gray-100 rounded-full flex items-center justify-center mx-auto mb-4",children:y.jsx(mt,{className:"w-8 h-8 text-gray-400"})}),y.jsx("div",{className:"text-lg font-medium text-gray-900 mb-2",children:"No items available"}),y.jsx("p",{className:"text-gray-500 mb-4",children:l.trim()?"No pages or groups match your search.":"All pages and groups have been added."})]}):y.jsx("div",{className:s,children:d.map((b,S)=>{const E=b.kind==="group",k=b.id,C=E?b.label||`Group ${S+1}`:b.label||`Page ${b.id}`,A={payload:i,item:void 0,parent:void 0},_=E?x(b.pageComponentKeys,A).length:1,I=!!w;return y.jsxs("div",{onClick:()=>u(b),className:["relative w-full h-[280px] cursor-pointer transition-all group",!I&&"bg-white border-2 border-gray-200"].filter(Boolean).join(" "),children:[y.jsx("div",{className:"w-full h-full relative",children:b.thumbnail?y.jsx("div",{className:"absolute inset-0 bg-gray-100 hover:bg-white",children:y.jsx("img",{src:b.thumbnail,className:"w-full h-full object-contain pointer-events-none object-top border border-gray-200 p-4",alt:C})}):w?y.jsx("div",{className:"absolute inset-0 flex items-center pointer-events-none",children:w(h(b,S),S,!1)}):y.jsx(y.Fragment,{children:E?y.jsxs("div",{className:"p-4",children:[y.jsx("div",{className:"w-16 h-16 bg-blue-100 rounded-full flex items-center justify-center mx-auto mb-3",children:y.jsx(mt,{className:"w-8 h-8 text-blue-600"})}),y.jsx("div",{className:"text-sm font-medium text-gray-700",children:C}),y.jsxs("div",{className:"text-xs text-gray-500 mt-1",children:[_," ",_===1?"page":"pages"]})]}):y.jsxs("div",{className:"p-4",children:[y.jsx("div",{className:"w-16 h-16 bg-gray-100 rounded-full flex items-center justify-center mx-auto mb-3",children:y.jsx(mt,{className:"w-8 h-8 text-gray-400"})}),y.jsx("div",{className:"text-sm font-medium text-gray-700",children:C}),y.jsx("div",{className:"text-xs text-gray-500 mt-1",children:k})]})})}),(!w||b?.thumbnail)&&y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:"absolute top-2 right-2 px-2 py-1 bg-blue-600/80 backdrop-blur-sm text-white text-xs font-medium rounded shadow-lg pointer-events-none",children:["Group (",_," ",_===1?"page":"pages",")"]}),y.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-black/40 backdrop-blur-sm p-3 pointer-events-none","data-item-id":k,children:y.jsx("div",{className:"flex items-center justify-between gap-2 text-white",children:y.jsx("div",{className:"flex-1 min-w-0",children:y.jsx("div",{className:"text-sm font-medium truncate",children:C})})})})]}),y.jsx("div",{className:"absolute top-3 left-3 w-8 h-8 bg-black rounded-full flex items-center justify-center shadow-lg opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none z-10",children:y.jsx(mt,{className:"w-4 h-4 text-white"})})]},k)})})})})]})})}function nA(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return O.useMemo(()=>n=>{e.forEach(a=>a(n))},e)}const Fn=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function ar(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function Hl(t){return"nodeType"in t}function Pe(t){var e,r;return t?ar(t)?t:Hl(t)&&(e=(r=t.ownerDocument)==null?void 0:r.defaultView)!=null?e:window:window}function Ul(t){const{Document:e}=Pe(t);return t instanceof e}function Mr(t){return ar(t)?!1:t instanceof Pe(t).HTMLElement}function Og(t){return t instanceof Pe(t).SVGElement}function ir(t){return t?ar(t)?t.document:Hl(t)?Ul(t)?t:Mr(t)||Og(t)?t.ownerDocument:document:document:document}const Ue=Fn?O.useLayoutEffect:O.useEffect;function $n(t){const e=O.useRef(t);return Ue(()=>{e.current=t}),O.useCallback(function(){for(var r=arguments.length,n=new Array(r),a=0;a<r;a++)n[a]=arguments[a];return e.current==null?void 0:e.current(...n)},[])}function aA(){const t=O.useRef(null),e=O.useCallback((n,a)=>{t.current=setInterval(n,a)},[]),r=O.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[e,r]}function Dr(t,e){e===void 0&&(e=[t]);const r=O.useRef(t);return Ue(()=>{r.current!==t&&(r.current=t)},e),r}function zr(t,e){const r=O.useRef();return O.useMemo(()=>{const n=t(r.current);return r.current=n,n},[...e])}function Gn(t){const e=$n(t),r=O.useRef(null),n=O.useCallback(a=>{a!==r.current&&e?.(a,r.current),r.current=a},[]);return[r,n]}function Vn(t){const e=O.useRef();return O.useEffect(()=>{e.current=t},[t]),e.current}let Kl={};function Lr(t,e){return O.useMemo(()=>{if(e)return e;const r=Kl[t]==null?0:Kl[t]+1;return Kl[t]=r,t+"-"+r},[t,e])}function Pg(t){return function(e){for(var r=arguments.length,n=new Array(r>1?r-1:0),a=1;a<r;a++)n[a-1]=arguments[a];return n.reduce((i,o)=>{const s=Object.entries(o);for(const[l,c]of s){const d=i[l];d!=null&&(i[l]=d+t*c)}return i},{...e})}}const or=Pg(1),jr=Pg(-1);function iA(t){return"clientX"in t&&"clientY"in t}function Hn(t){if(!t)return!1;const{KeyboardEvent:e}=Pe(t.target);return e&&t instanceof e}function oA(t){if(!t)return!1;const{TouchEvent:e}=Pe(t.target);return e&&t instanceof e}function Un(t){if(oA(t)){if(t.touches&&t.touches.length){const{clientX:e,clientY:r}=t.touches[0];return{x:e,y:r}}else if(t.changedTouches&&t.changedTouches.length){const{clientX:e,clientY:r}=t.changedTouches[0];return{x:e,y:r}}}return iA(t)?{x:t.clientX,y:t.clientY}:null}const kt=Object.freeze({Translate:{toString(t){if(!t)return;const{x:e,y:r}=t;return"translate3d("+(e?Math.round(e):0)+"px, "+(r?Math.round(r):0)+"px, 0)"}},Scale:{toString(t){if(!t)return;const{scaleX:e,scaleY:r}=t;return"scaleX("+e+") scaleY("+r+")"}},Transform:{toString(t){if(t)return[kt.Translate.toString(t),kt.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:r,easing:n}=t;return e+" "+r+"ms "+n}}}),Ig="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function sA(t){return t.matches(Ig)?t:t.querySelector(Ig)}const lA={display:"none"};function cA(t){let{id:e,value:r}=t;return O.createElement("div",{id:e,style:lA},r)}function dA(t){let{id:e,announcement:r,ariaLiveType:n="assertive"}=t;const a={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return O.createElement("div",{id:e,style:a,role:"status","aria-live":n,"aria-atomic":!0},r)}function uA(){const[t,e]=O.useState("");return{announce:O.useCallback(n=>{n!=null&&e(n)},[]),announcement:t}}const Ng=O.createContext(null);function pA(t){const e=O.useContext(Ng);O.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(t)},[t,e])}function fA(){const[t]=O.useState(()=>new Set),e=O.useCallback(n=>(t.add(n),()=>t.delete(n)),[t]);return[O.useCallback(n=>{let{type:a,event:i}=n;t.forEach(o=>{var s;return(s=o[a])==null?void 0:s.call(o,i)})},[t]),e]}const mA={draggable:`
|
|
878
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${e.docsSlug}`;return T.useEffect(()=>{t&&(document.getElementById(t)||console.error(r))},[r,t]),null},QT="DialogDescriptionWarning",JT=({contentRef:t,descriptionId:e})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Cg(QT).contentName}}.`;return T.useEffect(()=>{const a=t.current?.getAttribute("aria-describedby");e&&a&&(document.getElementById(e)||console.warn(n))},[n,t,e]),null},kg=cg,eA=ug,Eg=fg,Ll=mg,jl=hg,Wl=vg,Bl=bg,ql=xg;const Tg=kg,tA=Eg,Ag=T.forwardRef(({className:t,...e},r)=>y.jsx(Ll,{className:pe("fixed inset-0 z-50 bg-black/50 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...e,ref:r}));Ag.displayName=Ll.displayName;const Rl=T.forwardRef(({side:t="right",className:e,children:r,...n},a)=>{const{portalContainer:i}=zs();return y.jsxs(tA,{container:i||void 0,children:[y.jsx(Ag,{}),y.jsxs(jl,{ref:a,className:pe("fixed z-50 gap-4 bg-white p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",t==="top"&&"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",t==="bottom"&&"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",t==="left"&&"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",t==="right"&&"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm",e),...n,children:[r,y.jsxs(ql,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-white transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-gray-400 focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-gray-100",children:[y.jsx(hf,{className:"h-4 w-4"}),y.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});Rl.displayName=jl.displayName;const Fl=({className:t,...e})=>y.jsx("div",{className:pe("flex flex-col space-y-2 text-center sm:text-left",t),...e});Fl.displayName="SheetHeader";const _g=({className:t,...e})=>y.jsx("div",{className:pe("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...e});_g.displayName="SheetFooter";const $l=T.forwardRef(({className:t,...e},r)=>y.jsx(Wl,{ref:r,className:pe("text-lg font-medium text-gray-900",t),...e}));$l.displayName=Wl.displayName;const Gl=T.forwardRef(({className:t,...e},r)=>y.jsx(Bl,{ref:r,className:pe("text-sm text-gray-500",t),...e}));Gl.displayName=Bl.displayName;function Vl(t){const{pageComponents:e,payload:r,setup:n={width:210,height:297},thumbnailWidth:a=200,thumbnailHeight:i}=t,o=n.width||210,s=n.height||297,l=o/s,c=a,d=i??Math.round(c/l),u=o*3.779527559,p=s*3.779527559;return(f,v,m)=>{const g=f.strictPosition,w=g==="start"||g==="end";if(f.kind==="group"){const x=f.firstPageId,h=f.firstPageComponentKey??x,b=jn(r,{id:x,componentKey:h}),S=f.firstPageComponent||(h?e[h]:null),E=r?.integrations?.[f.id];return y.jsxs("div",{className:`relative bg-white border transition-all ${m?"border-blue-400 shadow-2xl scale-105":w?"border-gray-300 bg-gray-50":"border-gray-200 hover:border-gray-300 hover:shadow-lg"}`,style:{width:`${c}px`,height:`${d}px`},title:f.id,children:[S?y.jsx("div",{className:"w-full h-full flex items-center justify-center bg-gray-50 overflow-hidden relative pointer-events-none",children:y.jsx("div",{style:{transform:`scale(${Math.min(c/u,d/p)})`,transformOrigin:"center"},children:y.jsx("div",{className:"!shrink-0",style:{width:`${u}px`,height:`${p}px`,backgroundColor:"white",pointerEvents:"none"},children:y.jsx(S,{payload:r,pageId:x,templateId:h,pagePayload:b,componentKey:h,integration:E,parentGroup:f})})})}):y.jsx("div",{className:"w-full h-full flex items-center justify-center bg-gray-50 pointer-events-none",children:y.jsxs("div",{className:"text-center p-4",children:[y.jsxs("div",{className:"text-sm font-medium text-gray-700",children:["Group ",f.id]}),y.jsx("div",{className:"text-xs text-gray-500 mt-1",children:x||"No preview"})]})}),y.jsxs("div",{className:"absolute top-2 right-2 px-2 py-1 bg-blue-600/80 backdrop-blur-sm text-white text-xs font-medium rounded shadow-lg pointer-events-none",children:["Group (",f.pageCount," pages)"]}),w&&y.jsxs("div",{className:"absolute top-2 left-2 px-2 py-1 bg-gray-600/80 backdrop-blur-sm text-white text-xs font-medium rounded shadow-lg pointer-events-none flex items-center gap-1",children:[y.jsx(Ds,{className:"size-3"}),y.jsx("span",{children:g==="start"?"Start":"End"})]}),y.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-black/40 backdrop-blur-sm p-3 pointer-events-none",children:y.jsx("div",{className:"flex items-center justify-between gap-2 text-white",children:y.jsx("div",{className:"flex-1 min-w-0",children:y.jsx("div",{className:"text-sm font-medium truncate",children:f.label||f.id})})})}),m&&y.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-blue-500/10 pointer-events-none",children:y.jsx("div",{className:"text-blue-600 font-medium text-sm bg-white/90 px-3 py-1 rounded-full shadow-lg",children:"Dragging Group..."})})]})}else{const x=f.pageId,h=f.pageComponentKey??x,b=jn(r,{id:x,componentKey:h}),S=f.pageComponent||(h?e[h]:null),E=x?ag(r,{id:x}):void 0;return y.jsxs("div",{className:`relative bg-white border transition-all ${m?"border-blue-400 shadow-2xl scale-105":w?"border-gray-300 bg-gray-50":"border-gray-200 hover:border-gray-300 hover:shadow-lg"}`,style:{width:`${c}px`,height:`${d}px`},title:f.pageId,children:[S?y.jsx("div",{className:"w-full h-full flex items-center justify-center bg-gray-50 overflow-hidden relative pointer-events-none",children:y.jsx("div",{className:"flex items-center justify-center pointer-events-none",style:{transform:`scale(${Math.min(c/u,d/p)})`,transformOrigin:"center"},children:y.jsx("div",{className:"!shrink-0",style:{width:`${u}px`,height:`${p}px`,backgroundColor:"white",pointerEvents:"none"},children:y.jsx(S,{payload:r,pageId:x,templateId:h,pagePayload:b,componentKey:h,integration:E})})})}):y.jsx("div",{className:"w-full h-full flex items-center justify-center bg-gray-50 pointer-events-none",children:y.jsxs("div",{className:"text-center p-4",children:[y.jsxs("div",{className:"text-sm font-medium text-gray-700",children:["Page ",f.pageNum]}),y.jsx("div",{className:"text-xs text-gray-500 mt-1",children:x||"No preview"})]})}),w&&y.jsxs("div",{className:"absolute top-2 left-2 px-2 py-1 bg-gray-600/80 backdrop-blur-sm text-white text-xs font-medium rounded shadow-lg pointer-events-none flex items-center gap-1",children:[y.jsx(Ds,{className:"size-3"}),y.jsx("span",{children:g==="start"?"Start":"End"})]}),y.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-black/40 backdrop-blur-sm p-3 pointer-events-none",children:y.jsx("div",{className:"flex items-center justify-between gap-2 text-white",children:y.jsx("div",{className:"flex-1 min-w-0",children:y.jsx("div",{className:"text-sm font-medium truncate",children:f.pageLabel||`Page ${f.pageNum}`})})})}),m&&y.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-blue-500/10 pointer-events-none",children:y.jsx("div",{className:"text-blue-600 font-medium text-sm bg-white/90 px-3 py-1 rounded-full shadow-lg",children:"Dragging..."})})]})}}}function rA({open:t,onOpenChange:e,availableItems:r,onSelectItem:n,pageComponents:a,payload:i,setup:o={width:210,height:297},gridColsClass:s="page-order-grid-cols"}){const[l,c]=T.useState(""),d=T.useMemo(()=>{if(!l.trim())return r;const b=l.toLowerCase();return r.filter(S=>(S.label||"").toLowerCase().includes(b)||S.id.toLowerCase().includes(b))},[r,l]),u=b=>{e(!1),n(b)},p=o.width||210,f=o.height||297,v=p/f,m=200,g=Math.round(m/v),w=T.useMemo(()=>a?Vl({pageComponents:a,payload:i,setup:o,thumbnailWidth:m,thumbnailHeight:g}):null,[a,i,o,m,g]),x=(b,S)=>{if(!b)return[];if(Array.isArray(b))return b;try{const E=b(S);if(!Array.isArray(E))return console.error("[uhuu-components] pageComponentKeys function must return an array, got:",typeof E),[];const k=E.filter(C=>typeof C=="string");return k.length!==E.length&&console.warn("[uhuu-components] pageComponentKeys returned non-string values, filtering them out"),k}catch(E){return console.error("[uhuu-components] Error evaluating pageComponentKeys function:",E),[]}},h=(b,S)=>{if(b.kind==="group"){const C=b,A={payload:i,item:void 0,parent:void 0},_=x(C.pageComponentKeys,A),I=_[0];return{kind:"group",id:b.id,label:b.label,pageCount:_.length,firstPageId:I,firstPageComponentKey:I}}const E=b,k=E.componentKey??E.id;return{kind:"page",id:E.id,pageId:E.id,pageComponentKey:k,pageLabel:E.label,pageNum:S+1}};return y.jsx(Tg,{open:t,onOpenChange:e,children:y.jsxs(Rl,{side:"bottom",className:"h-[90vh] p-0 gap-0 w-full max-w-none bg-gray-50","data-uhuu-editor":!0,children:[y.jsx(Fl,{className:"border-b border-gray-200 p-4 bg-white",children:y.jsxs("div",{className:"flex items-end gap-3",children:[y.jsx("div",{className:"w-8 h-8 bg-gray-100 rounded-full flex items-center justify-center shrink-0 mb-0.5",children:y.jsx(mt,{className:"w-4 h-4"})}),y.jsxs("div",{className:"flex-1",children:[y.jsx($l,{className:"text-base font-medium text-gray-900 leading-tight",children:"Add Page or Group"}),y.jsx(Gl,{className:"text-xs text-gray-400 mt-0.5",children:"Select a page or group to add to your document."})]}),y.jsxs("div",{className:"flex items-center gap-1.5 text-gray-400 mb-0.5 mr-8",children:[y.jsx(cw,{className:"w-3.5 h-3.5 shrink-0"}),y.jsx("input",{type:"text",placeholder:"Filter…",value:l,onChange:b=>c(b.target.value),tabIndex:-1,className:"w-24 bg-transparent border-0 focus:outline-none text-sm text-gray-600 placeholder:text-gray-400 focus:w-40 transition-all duration-150"})]})]})}),y.jsx("div",{className:"flex-1 overflow-hidden",children:y.jsx("div",{className:"h-full max-h-[calc(90vh-100px)] overflow-auto p-6",children:d.length===0?y.jsxs("div",{className:"text-center py-16",children:[y.jsx("div",{className:"w-16 h-16 bg-gray-100 rounded-full flex items-center justify-center mx-auto mb-4",children:y.jsx(mt,{className:"w-8 h-8 text-gray-400"})}),y.jsx("div",{className:"text-lg font-medium text-gray-900 mb-2",children:"No items available"}),y.jsx("p",{className:"text-gray-500 mb-4",children:l.trim()?"No pages or groups match your search.":"All pages and groups have been added."})]}):y.jsx("div",{className:s,children:d.map((b,S)=>{const E=b.kind==="group",k=b.id,C=E?b.label||`Group ${S+1}`:b.label||`Page ${b.id}`,A={payload:i,item:void 0,parent:void 0},_=E?x(b.pageComponentKeys,A).length:1,I=!!w;return y.jsxs("div",{onClick:()=>u(b),className:["relative w-full h-[280px] cursor-pointer transition-all group",!I&&"bg-white border-2 border-gray-200"].filter(Boolean).join(" "),children:[y.jsx("div",{className:"w-full h-full relative",children:b.thumbnail?y.jsx("div",{className:"absolute inset-0 bg-gray-100 hover:bg-white",children:y.jsx("img",{src:b.thumbnail,className:"w-full h-full object-contain pointer-events-none object-top border border-gray-200 p-4",alt:C})}):w?y.jsx("div",{className:"absolute inset-0 flex items-center pointer-events-none",children:w(h(b,S),S,!1)}):y.jsx(y.Fragment,{children:E?y.jsxs("div",{className:"p-4",children:[y.jsx("div",{className:"w-16 h-16 bg-blue-100 rounded-full flex items-center justify-center mx-auto mb-3",children:y.jsx(mt,{className:"w-8 h-8 text-blue-600"})}),y.jsx("div",{className:"text-sm font-medium text-gray-700",children:C}),y.jsxs("div",{className:"text-xs text-gray-500 mt-1",children:[_," ",_===1?"page":"pages"]})]}):y.jsxs("div",{className:"p-4",children:[y.jsx("div",{className:"w-16 h-16 bg-gray-100 rounded-full flex items-center justify-center mx-auto mb-3",children:y.jsx(mt,{className:"w-8 h-8 text-gray-400"})}),y.jsx("div",{className:"text-sm font-medium text-gray-700",children:C}),y.jsx("div",{className:"text-xs text-gray-500 mt-1",children:k})]})})}),(!w||b?.thumbnail)&&y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:"absolute top-2 right-2 px-2 py-1 bg-blue-600/80 backdrop-blur-sm text-white text-xs font-medium rounded shadow-lg pointer-events-none",children:["Group (",_," ",_===1?"page":"pages",")"]}),y.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-black/40 backdrop-blur-sm p-3 pointer-events-none","data-item-id":k,children:y.jsx("div",{className:"flex items-center justify-between gap-2 text-white",children:y.jsx("div",{className:"flex-1 min-w-0",children:y.jsx("div",{className:"text-sm font-medium truncate",children:C})})})})]}),y.jsx("div",{className:"absolute top-3 left-3 w-8 h-8 bg-black rounded-full flex items-center justify-center shadow-lg opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none z-10",children:y.jsx(mt,{className:"w-4 h-4 text-white"})})]},k)})})})})]})})}function nA(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return O.useMemo(()=>n=>{e.forEach(a=>a(n))},e)}const Fn=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function ar(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function Hl(t){return"nodeType"in t}function Pe(t){var e,r;return t?ar(t)?t:Hl(t)&&(e=(r=t.ownerDocument)==null?void 0:r.defaultView)!=null?e:window:window}function Ul(t){const{Document:e}=Pe(t);return t instanceof e}function Mr(t){return ar(t)?!1:t instanceof Pe(t).HTMLElement}function Og(t){return t instanceof Pe(t).SVGElement}function ir(t){return t?ar(t)?t.document:Hl(t)?Ul(t)?t:Mr(t)||Og(t)?t.ownerDocument:document:document:document}const Ue=Fn?O.useLayoutEffect:O.useEffect;function $n(t){const e=O.useRef(t);return Ue(()=>{e.current=t}),O.useCallback(function(){for(var r=arguments.length,n=new Array(r),a=0;a<r;a++)n[a]=arguments[a];return e.current==null?void 0:e.current(...n)},[])}function aA(){const t=O.useRef(null),e=O.useCallback((n,a)=>{t.current=setInterval(n,a)},[]),r=O.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[e,r]}function Dr(t,e){e===void 0&&(e=[t]);const r=O.useRef(t);return Ue(()=>{r.current!==t&&(r.current=t)},e),r}function zr(t,e){const r=O.useRef();return O.useMemo(()=>{const n=t(r.current);return r.current=n,n},[...e])}function Gn(t){const e=$n(t),r=O.useRef(null),n=O.useCallback(a=>{a!==r.current&&e?.(a,r.current),r.current=a},[]);return[r,n]}function Vn(t){const e=O.useRef();return O.useEffect(()=>{e.current=t},[t]),e.current}let Kl={};function Lr(t,e){return O.useMemo(()=>{if(e)return e;const r=Kl[t]==null?0:Kl[t]+1;return Kl[t]=r,t+"-"+r},[t,e])}function Pg(t){return function(e){for(var r=arguments.length,n=new Array(r>1?r-1:0),a=1;a<r;a++)n[a-1]=arguments[a];return n.reduce((i,o)=>{const s=Object.entries(o);for(const[l,c]of s){const d=i[l];d!=null&&(i[l]=d+t*c)}return i},{...e})}}const or=Pg(1),jr=Pg(-1);function iA(t){return"clientX"in t&&"clientY"in t}function Hn(t){if(!t)return!1;const{KeyboardEvent:e}=Pe(t.target);return e&&t instanceof e}function oA(t){if(!t)return!1;const{TouchEvent:e}=Pe(t.target);return e&&t instanceof e}function Un(t){if(oA(t)){if(t.touches&&t.touches.length){const{clientX:e,clientY:r}=t.touches[0];return{x:e,y:r}}else if(t.changedTouches&&t.changedTouches.length){const{clientX:e,clientY:r}=t.changedTouches[0];return{x:e,y:r}}}return iA(t)?{x:t.clientX,y:t.clientY}:null}const kt=Object.freeze({Translate:{toString(t){if(!t)return;const{x:e,y:r}=t;return"translate3d("+(e?Math.round(e):0)+"px, "+(r?Math.round(r):0)+"px, 0)"}},Scale:{toString(t){if(!t)return;const{scaleX:e,scaleY:r}=t;return"scaleX("+e+") scaleY("+r+")"}},Transform:{toString(t){if(t)return[kt.Translate.toString(t),kt.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:r,easing:n}=t;return e+" "+r+"ms "+n}}}),Ig="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function sA(t){return t.matches(Ig)?t:t.querySelector(Ig)}const lA={display:"none"};function cA(t){let{id:e,value:r}=t;return O.createElement("div",{id:e,style:lA},r)}function dA(t){let{id:e,announcement:r,ariaLiveType:n="assertive"}=t;const a={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return O.createElement("div",{id:e,style:a,role:"status","aria-live":n,"aria-atomic":!0},r)}function uA(){const[t,e]=O.useState("");return{announce:O.useCallback(n=>{n!=null&&e(n)},[]),announcement:t}}const Ng=O.createContext(null);function pA(t){const e=O.useContext(Ng);O.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(t)},[t,e])}function fA(){const[t]=O.useState(()=>new Set),e=O.useCallback(n=>(t.add(n),()=>t.delete(n)),[t]);return[O.useCallback(n=>{let{type:a,event:i}=n;t.forEach(o=>{var s;return(s=o[a])==null?void 0:s.call(o,i)})},[t]),e]}const mA={draggable:`
|
|
879
879
|
To pick up a draggable item, press the space bar.
|
|
880
880
|
While dragging, use the arrow keys to move the item.
|
|
881
881
|
Press space again to drop the item in its new position, or press escape to cancel.
|