@qratilabs/qrati-connect 2.22.2 → 2.22.3
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/element/{CPlVxcfY.js → B1h4rQf7.js} +1 -1
- package/element/web.es.js +2 -2
- package/package.json +1 -1
- package/react/{CPlVxcfY-DpaDwsHR.js → B1h4rQf7-BlCih4CD.js} +1 -1
- package/react/{CPlVxcfY-Bif80UuQ.js → B1h4rQf7-DGwPbWg7.js} +1 -1
- package/react/index.cjs +1 -1
- package/react/index.mjs +2 -2
- package/umd/web.umd.js +1 -1
|
@@ -6,7 +6,7 @@ return p(F,{open:Boolean(t&&e),onOpenChange:t=>!t&&n?.(),children:/* @__PURE__ *
|
|
|
6
6
|
/* @__PURE__ */p("div",{className:"flex flex-col gap-2 p-3",children:[/* @__PURE__ */p(W,{variant:"h4",align:"center",lines:2,children:e?.title}),/* @__PURE__ */p(W,{variant:"body3",color:"secondary",align:"center",lines:4,children:e?.description})]}),s&&/* @__PURE__ */p(st,{fullWidth:!0,className:"rounded-none",onClick:()=>{i?.(e?._id,e?.targetType??V.LINK,e?.targetUrl),n?.()},iconName:_[e?.targetType]??_[V.LINK],children:e?.targetText})]})]})})},Wt=({style:t,content:e,curateLink:n,onAdClick:i})=>{const{captureAdImpression:s,captureAdEngagement:o,captureAdClick:r}=j(),a=Boolean(n&&i),l=e.ctaBg||"#ff4800",c=e.ctaForeground||"#FFFFFF";/* @__PURE__ */
|
|
7
7
|
return p("div",{style:t,className:"group relative mb-1 overflow-hidden rounded",children:[
|
|
8
8
|
/* @__PURE__ */p(P,{className:"size-full",threshold:.8,triggerOnce:!0,onChange:t=>{t&&s(e._id)},onClick:()=>o(e._id),children:/* @__PURE__ */p(tt,{url:e.src||e.imageUrl,thumbnailUrl:e.src||e.imageUrl,blurhash:e.blurhash,alt:e.caption,onClick:a?i:void 0,pswpData:{id:e._id,type:T.AD,hash:e._id,width:e.width,height:e.height,title:e.title,description:e.description,targetType:e.targetType,targetText:e.targetText,targetUrl:e.targetUrl,thumbnailUrl:e.imageUrl,blurhash:e.blurhash}})}),
|
|
9
|
-
/* @__PURE__ */p("span",{className:"bg-background/70 absolute top-1 right-1 rounded px-1 text-xs font-medium",children:"Ad"}),(e.title||e.targetType!==V.NONE)&&/* @__PURE__ */p("div",{className:"absolute bottom-0 flex w-full flex-col lg:opacity-0 lg:transition-opacity lg:group-hover:opacity-100",children:[e.title&&/* @__PURE__ */p("div",{className:"bg-background/60 px-3 py-1",children:/* @__PURE__ */p("h3",{className:"line-clamp-1 text-sm
|
|
9
|
+
/* @__PURE__ */p("span",{className:"bg-background/70 absolute top-1 right-1 rounded px-1 text-xs font-medium",children:"Ad"}),(e.title||e.targetType!==V.NONE)&&/* @__PURE__ */p("div",{className:"absolute bottom-0 flex w-full flex-col lg:opacity-0 lg:transition-opacity lg:group-hover:opacity-100",children:[e.title&&/* @__PURE__ */p("div",{className:"bg-background/60 px-3 py-1",children:/* @__PURE__ */p("h3",{className:"line-clamp-1 text-sm font-medium text-red-500",children:e.title})}),e?.targetType!==V.NONE&&/* @__PURE__ */p("button",{className:"flex w-full items-center justify-center gap-1 rounded-none border-0 py-2 text-nowrap sm:gap-2",style:{backgroundColor:l,color:c},onClick:()=>{a?i?.():r(e._id,e.targetType,e.targetUrl)},children:[/* @__PURE__ */p(ot,{style:{color:c},icon:_[e?.targetType??V.LINK]}),e?.targetText]})]})]})},Gt=({style:t,gamConfig:e,slotIndex:n,eventId:i,organizationId:s})=>{const o=a(null),r=a(null),{trackGamAnalytics:l}=j(),c=`gam-slot-${i??"ev"}-${n}`,d=Math.max(1,Math.round(t?.width||e.sizes[0]?.[0]||300)),h=Math.max(1,Math.round(t?.height||e.sizes[0]?.[1]||250)),u=a({w:d,h:h});return g(()=>{let t=!1,n=null,a=null,d=null,h=null;return(async()=>{await G(),!t&&o.current&&window.googletag.cmd.push(()=>{if(t)return;X(c);const{w:p,h:m}=u.current,g=[[p,m],...e.sizes],f=window.googletag.defineSlot(e.adUnitPath,g,c)?.addService(window.googletag.pubads());if(!f)return;r.current=f,a=window.googletag.pubads(),i?f.setConfig({targeting:{qrati_event:i,...e.categories.length>0?{qrati_category:e.categories}:{}}}):e.categories.length>0&&f.setConfig({targeting:{qrati_category:e.categories}}),d=t=>{t.slot===f&&l({eventId:i,organizationId:s,type:z.GAM_IMPRESSION,creativeId:String(t.creativeId??""),lineItemId:String(t.lineItemId??""),advertiserId:String(t.advertiserId??""),isEmpty:t.isEmpty??!1})},a.addEventListener("slotRenderEnded",d),h=t=>{t.slot===f&&l({eventId:i,organizationId:s,type:z.GAM_VIEWABLE})},a.addEventListener("impressionViewable",h);const w=o.current;w&&(n=U({container:w,onClick:()=>{l({eventId:i,organizationId:s,type:z.GAM_CLICK})}}),Q(),window.googletag.display(c))})})(),()=>{t=!0,n?.(),a&&"function"==typeof a.removeEventListener&&(d&&a.removeEventListener("slotRenderEnded",d),h&&a.removeEventListener("impressionViewable",h));const e=r.current;r.current=null,e&&window.googletag?.cmd?.push(()=>{window.googletag.destroySlots([e])})}},[i,e.adUnitPath,e.categories,s,c]),/* @__PURE__ */p("div",{style:{width:d,height:h},className:"relative overflow-hidden rounded bg-neutral-100 dark:bg-neutral-800","data-gam-slot-index":n,children:/* @__PURE__ */p("div",{id:c,ref:o,style:{width:d,height:h},className:"gam-ad-slot"})})},Kt=t(null),Yt=()=>{const t=e(Kt);if(!t)throw new Error("Popover components must be used within a Popover");return t},Qt=({children:t,className:e,open:n,onOpenChange:i})=>{const[s,o]=w(!1),l="boolean"==typeof n,c=l?n:s,d=r(),h=`popover-trigger-${d}`,u=`popover-content-${d}`,m=a(null);/* @__PURE__ */
|
|
10
10
|
return p(Kt.Provider,{value:{isOpen:c,setIsOpen:t=>{l||o(t),i?.(t)},triggerId:h,contentId:u,triggerRef:m},children:/* @__PURE__ */p("div",{"data-slot":"popover",className:C("relative inline-block",e),children:t})})},Zt=({children:t,asChild:e,className:n,onClick:i,...s})=>{const{isOpen:o,setIsOpen:r,triggerId:a,contentId:l,triggerRef:c}=Yt();if(e){const e=Array.isArray(t)?t[0]:t;if(e&&e.type){const t=e.props?.className;return d(e,{ref:t=>{c.current=t},id:a,className:n?t?`${t} ${n}`:n:t,"aria-haspopup":"dialog","aria-expanded":o,"aria-controls":o?l:void 0,onClick:t=>{r(!o),e.props?.onClick?.(t)},"data-state":o?"open":"closed"})}}/* @__PURE__ */
|
|
11
11
|
return p("button",{ref:c,id:a,type:"button","aria-haspopup":"dialog","aria-expanded":o,"aria-controls":o?l:void 0,"data-slot":"popover-trigger","data-state":o?"open":"closed",className:n,onClick:t=>{r(!o),i?.(t)},...s,children:t})},Jt=({children:t,className:e,align:n="center",side:i="top",sideOffset:s=4,...o})=>{const{isOpen:r,setIsOpen:l,contentId:c,triggerRef:d}=Yt(),{organization:u,portalContainer:f}=A(),y=a(null),[v,b]=w(null);if(m(()=>{if(!r)return;const t=()=>{if(!d.current||!y.current)return;const t=d.current.getBoundingClientRect(),e=y.current.getBoundingClientRect();let o=t.left,r=t.bottom+s;"center"===n&&(o=t.left+t.width/2-e.width/2),"end"===n&&(o=t.right-e.width),"top"===i&&(r=t.top-e.height-s),"left"===i&&(o=t.left-e.width-s,r=t.top+t.height/2-e.height/2),"right"===i&&(o=t.right+s,r=t.top+t.height/2-e.height/2),"bottom"===i&&(r=t.bottom+s),b({top:r,left:o})},e=requestAnimationFrame(t);return window.addEventListener("resize",t),window.addEventListener("scroll",t,!0),()=>{cancelAnimationFrame(e),window.removeEventListener("resize",t),window.removeEventListener("scroll",t,!0)}},[n,r,i,s,d]),g(()=>{if(!r)return;const t=t=>{const e="function"==typeof t.composedPath?t.composedPath():[],n=t.target,i=y.current&&(y.current.contains(n)||e.includes(y.current)),s=d.current&&(d.current.contains(n)||e.includes(d.current));i||s||l(!1)},e=t=>{"Escape"===t.key&&(l(!1),d.current?.focus())},n=window.setTimeout(()=>{document.addEventListener("mousedown",t)},0);return document.addEventListener("keydown",e),()=>{window.clearTimeout(n),document.removeEventListener("mousedown",t),document.removeEventListener("keydown",e)}},[r,l,d]),!r)return null;const T=/* @__PURE__ */p("div",{ref:y,id:c,role:"dialog","aria-modal":"false","data-state":r?"open":"closed",className:C("bg-background text-foreground border-border shadow-outer rounded outline-none",e),style:{position:"fixed",top:v?.top??0,left:v?.left??0,zIndex:2010,...E(u)},...o,children:t});return"undefined"!=typeof document?h(T,f??document.body):T},Xt=({eventId:t,contentId:e,emojis:n=[],counts:i={},userReaction:o})=>{const{user:r,props:l,organization:c}=A(),d=l?.loginUrl,{handleReactionClick:h,isPending:m}=(()=>{const t=k(),{props:e,user:n}=A(),i=e?.organizationId,o=function(t){const e=k(void 0),[n]=w(()=>new rt(e,t));g(()=>{n.setOptions(t)},[n,t]);const i=u(s(t=>n.subscribe(S.batchCalls(t)),[n]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),o=s((t,e)=>{n.mutate(t,e).catch(I)},[n]);if(i.error&&N(n.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:o,mutateAsync:i.mutate}}({mutationFn:async({eventId:t,contentId:e,emoji:s})=>{await B.post(y.UPDATE_REACTION,{json:{eventId:t,contentId:e,reaction:s},headers:{"x-org-id":i,Authorization:`Bearer ${n?.token}`}})},onMutate:async({eventId:e,contentId:n,emoji:i})=>{const s=[v.CONTENTS_BY_EVENT(e)];await t.cancelQueries({queryKey:s});const o=t.getQueriesData({queryKey:s});return t.setQueriesData({queryKey:s},t=>((t,e,n)=>t?.pages&&Array.isArray(t.pages)?{...t,pages:t.pages.map(t=>t.data?{...t,data:t.data.map(t=>{if(t._id!==e)return t;const i={...t.reactionCounts??{}};return t.userReaction&&t.userReaction!==n&&(i[t.userReaction]=Math.max(0,(i[t.userReaction]??1)-1)),t.userReaction===n?(i[n]=Math.max(0,(i[n]??1)-1),{...t,reactionCounts:i,userReaction:void 0}):(i[n]=(i[n]??0)+1,{...t,reactionCounts:i,userReaction:n})})}:t)}:t)(t,n,i)),{previousData:o}},onError:(e,n,i)=>{i?.previousData?.forEach(([e,n])=>{t.setQueryData(e,n)}),K.error("Failed to add reaction"),console.error("Error handling reaction click:",e,n)},onSettled:async(e,n,i)=>{await t.invalidateQueries({queryKey:[v.CONTENTS_BY_EVENT(i.eventId)]})}});return{handleReactionClick:async(t,e,i)=>{if(!t||!e||!i)return!1;if(!n)return K.error("Please login to react"),!1;try{return await o.mutateAsync({eventId:t,contentId:e,emoji:i}),!0}catch(s){return!1}},isPending:o.isPending}})(),[f,b]=w(!1),[T,x]=w(null),_=a(null),E=Object.values(i).reduce((t,e)=>t+e,0);return g(()=>()=>{_.current&&clearTimeout(_.current)},[]),/* @__PURE__ */p(Qt,{open:f,onOpenChange:b,children:[/* @__PURE__ */p(Zt,{asChild:!0,children:/* @__PURE__ */p("button",{type:"button",className:C("bg-background/50 flex items-center gap-1 rounded px-2 py-1 backdrop-blur-sm transition-transform duration-150 ease-out will-change-transform active:scale-95 sm:gap-2 sm:py-0",T&&"scale-[1.03] shadow-sm"),children:[(n||[]).slice().sort((t,e)=>(i[e]||0)-(i[t]||0)).slice(0,1).map(t=>/* @__PURE__ */p("span",{className:C("text-sm transition-transform duration-150 ease-out sm:text-lg",T===(o||t)&&"scale-125"),children:o||t},`${e}-${t}-1`)),E>0&&/* @__PURE__ */p("span",{className:"text-xs font-bold sm:text-sm",children:E||0})]})}),/* @__PURE__ */p(Jt,{side:"top",align:"end",children:[r?null:/* @__PURE__ */p("div",c?.customAuth?{className:"p-2 font-semibold",children:["Please"," ",
|
|
12
12
|
/* @__PURE__ */p("a",{className:"text-info underline",href:d,children:"Login"})," ","to react"]}:{className:"p-2 font-semibold",children:["Please"," ",
|