@wexio/messenger-widget-react 1.5.3 → 1.6.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/CHANGELOG.md +6 -0
- package/README.md +15 -1
- package/dist/{widget-react-DBqY7BEB.js → widget-react-9oF1qdlF.js} +2 -2
- package/dist/{widget-react-DleQcmXy.js → widget-react-B3jj01Xc.js} +2 -2
- package/dist/{widget-react-Cv42XaBB.js → widget-react-BqKcbGFN.js} +2 -2
- package/dist/{widget-react-YrYT-pD1.js → widget-react-CkDSkBH9.js} +2 -2
- package/dist/{widget-react-COAvUm8D.js → widget-react-DFbFMJOG.js} +2 -2
- package/dist/{widget-react-Bk8_ZpvK.js → widget-react-uIbfBWRJ.js} +2 -2
- package/dist/widget-react.d.ts +16 -0
- package/dist/widget-react.js +18 -18
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
globalThis.process===void 0&&(globalThis.process={env:{},nextTick:function(e){setTimeout(e,0)},emit:function(){return!1}});import"react";import"react-dom";import"react/jsx-runtime";import"react-dom/client";import{_ as e,i as t,n,t as r,y as i}from"./widget-react-FX5W7RyV.js";import{Ct as a,E as o,I as s,O as c,at as l,d as u,g as d,gt as f,h as p,k as m,l as ee,wt as h}from"./widget-react-
|
|
1
|
+
globalThis.process===void 0&&(globalThis.process={env:{},nextTick:function(e){setTimeout(e,0)},emit:function(){return!1}});import"react";import"react-dom";import"react/jsx-runtime";import"react-dom/client";import{_ as e,i as t,n,t as r,y as i}from"./widget-react-FX5W7RyV.js";import{Ct as a,E as o,I as s,O as c,at as l,d as u,g as d,gt as f,h as p,k as m,l as ee,wt as h}from"./widget-react-CkDSkBH9.js";import{c as g}from"./widget-react-C-hnCqBf.js";import{useCallback as _,useEffect as v,useMemo as y,useRef as b,useState as x}from"react";import{Fragment as te,jsx as S,jsxs as C}from"react/jsx-runtime";var w={},T=h`
|
|
2
2
|
query VisitorNewsList($args: VisitorNewsListArgs) {
|
|
3
3
|
visitorNewsList(args: $args) {
|
|
4
4
|
items {
|
|
@@ -137,4 +137,4 @@ globalThis.process===void 0&&(globalThis.process={env:{},nextTick:function(e){se
|
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
`;function N(e){return a(M,{...w,...e})}var P=r(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),F=r(`megaphone`,[[`path`,{d:`M11 6a13 13 0 0 0 8.4-2.8A1 1 0 0 1 21 4v12a1 1 0 0 1-1.6.8A13 13 0 0 0 11 14H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2z`,key:`q8bfy3`}],[`path`,{d:`M6 14a12 12 0 0 0 2.4 7.2 2 2 0 0 0 3.2-2.4A8 8 0 0 1 10 14`,key:`1853fq`}],[`path`,{d:`M8 6v8`,key:`15ugcq`}]]);function I({icon:e,size:t=20,strokeWidth:r=2,className:i,...a}){return S(e,{width:t,height:t,strokeWidth:r,className:n(`shrink-0`,i),...a})}function L({className:e,...t}){return S(`div`,{"data-slot":`skeleton`,className:n(`animate-pulse rounded-wx-sm bg-wx-bg-elevated`,e),...t})}function R(e){if(!Array.isArray(e))return;let t=e.map(e=>{if(!e||typeof e!=`object`)return null;let t=e.name;if(typeof t!=`string`)return null;let n=e._id??e.id,r=e.photo?.url;return{id:String(n??t),name:t,photoUrl:typeof r==`string`?r:null}}).filter(e=>!!e);return t.length>0?t:void 0}function z({authors:e,max:t=3,className:n}){return!e||e.length===0?null:S(`span`,{className:`flex items-center -space-x-1.5 ${n??``}`,children:e.slice(0,t).map(e=>e.photoUrl?S(`img`,{src:e.photoUrl,alt:e.name,title:e.name,className:`h-5 w-5 rounded-full border border-wx-bg object-cover`},e.id):S(`span`,{title:e.name,className:`flex h-5 w-5 items-center justify-center rounded-full border border-wx-bg bg-wx-bg-elevated-2 text-[9px] font-semibold text-wx-fg-muted`,children:e.name.charAt(0).toUpperCase()},e.id))})}function B({value:e,onChange:t,placeholder:r,className:i}){return C(`div`,{className:n(`sticky top-0 z-10 flex items-center gap-2.5 border-wx-border border-b bg-wx-bg px-4`,i),children:[S(g,{size:16,className:`shrink-0 text-wx-fg-muted`}),S(`input`,{type:`search`,value:e,onChange:e=>t(e.target.value),placeholder:r,className:n(`block w-full min-w-0 flex-1 border-0 bg-transparent py-3 text-sm text-wx-fg`,`placeholder:text-wx-fg-muted focus:outline-none focus:ring-0`,`[&::-webkit-search-cancel-button]:appearance-none`)})]})}var V=new Map;function H(e){let t=b(null);return v(()=>{let n=t.current;if(!n)return;let r=V.get(e)??0,i=!1,a=performance.now(),o=()=>{if(i||!t.current)return;let e=t.current;if(e.scrollHeight-e.clientHeight>=r){e.scrollTop=r;return}if(performance.now()-a>500){e.scrollTop=r;return}requestAnimationFrame(o)};requestAnimationFrame(o);let s=()=>{V.set(e,n.scrollTop)};return n.addEventListener(`scroll`,s,{passive:!0}),()=>{i=!0,n.removeEventListener(`scroll`,s)}},[e]),t}function U(e){if(!e.upstreamUpdatedAt)return!1;let t=Date.parse(e.upstreamUpdatedAt),n=Date.parse(e.publishedAt);return Number.isNaN(t)||Number.isNaN(n)?!1:t>n+6e4}function W(e){let t=Date.parse(e);if(Number.isNaN(t))return``;let n=Date.now()-t,r=Math.floor(n/6e4);if(r<1)return`just now`;if(r<60)return`${r}m ago`;let i=Math.floor(r/60);if(i<24)return`${i}h ago`;let a=Math.floor(i/24);return a<7?`${a}d ago`:new Date(t).toLocaleDateString()}var G=10,K=240;function q({isDummy:t,onOpenArticle:n}){let r=e(`news`),a=m(),d=i(),p=o(),[h,g]=x(``),b=Y(h,300),w=b.length>=2,T=p.previewData?.newsPosts,E=!t&&Array.isArray(T)&&T.length>0,[D,O]=x(G),{data:k,error:A,loading:j,fetchMore:M}=ne({variables:{args:{locale:d,limit:G,offset:0,...w?{query:b}:{}}},skip:t||E,notifyOnNetworkStatusChange:!0});v(()=>{O(G)},[b,E]);let N=f().publicKey,P=ee(N&&!t&&!w?s.news(N,d):null,k),R=y(()=>(P?.visitorNewsList?.items??[]).filter(e=>!!e).map(J),[P]),z=E?(T??[]).filter(e=>!!e&&typeof e==`object`).map(J):[],V=_(e=>e.title.toLowerCase().includes(b.toLowerCase())||e.excerpt.toLowerCase().includes(b.toLowerCase()),[b]),U=t?w?l(a).filter(V):l(a):E?w?z.filter(V):z:R,W=E||t?U.slice(0,D):U,q=y(()=>t||E?D<U.length:P?.visitorNewsList?.meta?.hasNextPage??!1,[t,E,D,U.length,P]),[Z,Q]=x(!1),$=_(async()=>{if(!(!q||Z)){if(t||E){O(e=>e+G);return}Q(!0);try{await M({variables:{args:{locale:d,limit:G,offset:k?.visitorNewsList?.items?.length??0,...w?{query:b}:{}}},updateQuery:(e,{fetchMoreResult:t})=>{if(!t)return e;let n=new Set,r=[];for(let i of[...e.visitorNewsList?.items??[],...t.visitorNewsList?.items??[]])i&&!n.has(i._id)&&(n.add(i._id),r.push(i));return{...e,visitorNewsList:{...t.visitorNewsList,items:r}}}})}catch(e){console.warn(`[wexio] news load-more failed:`,e)}finally{Q(!1)}}},[q,Z,t,E,w,b,d,M,k]),re=H(`news`),ie=_(e=>{let t=e.currentTarget;t.scrollHeight-t.clientHeight-t.scrollTop<K&&$()},[$]),ae=U.length>0||w,oe=t&&!c(a)||!t&&!E&&j&&W.length===0;return A&&W.length===0?S(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 px-6 py-12 text-center`,children:S(`p`,{className:`text-sm text-wx-fg-muted`,children:r(`emptyTitle`)})}):C(u,{followDirection:!0,className:`flex-1`,viewportRef:re,onScroll:ie,children:[ae&&S(B,{value:h,onChange:g,placeholder:r(`searchPlaceholder`)}),S(`div`,{className:`flex flex-col gap-3 px-4 pt-4 pb-6`,children:oe?Array.from({length:3}).map((e,t)=>C(`div`,{className:`overflow-hidden rounded-wx-lg bg-wx-bg-elevated`,children:[S(L,{className:`aspect-[16/10] w-full rounded-none`}),C(`div`,{className:`space-y-2 px-5 py-4`,children:[S(L,{className:`h-3 w-3/4`}),S(L,{className:`h-3 w-1/2`}),S(L,{className:`mt-1 h-2 w-1/3`})]})]},t)):W.length===0?C(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 px-6 py-12 text-center`,children:[S(`div`,{className:`flex h-14 w-14 items-center justify-center rounded-full bg-wx-bg-elevated text-wx-fg-muted`,children:S(I,{icon:F,size:28})}),S(`p`,{className:`text-base font-semibold text-wx-fg`,children:r(w?`noResults`:`emptyTitle`)}),!w&&S(`p`,{className:`text-sm text-wx-fg-muted`,children:r(`emptyBody`)})]}):C(te,{children:[W.map((e,t)=>S(X,{item:e,locale:d,delay:t<G?t*.04:0,onClick:()=>n(e.id)},e.id)),Z&&S(`div`,{className:`flex justify-center py-3`,children:S(L,{className:`h-3 w-24`})})]})})]})}function J(e,t=0){let n=e.coverImageUrl?.url,r=e.externalCoverImageUrl,i=typeof n==`string`?n:typeof r==`string`?r:null,a=e=>Array.isArray(e)?e.map(e=>{if(!e||typeof e!=`object`)return null;let t=e.slug,n=e.label;return typeof t!=`string`||typeof n!=`string`?null:{slug:t,label:n}}).filter(e=>!!e):void 0,o=a(e.tags),s=a(e.categories),c=Array.isArray(e.authors)?e.authors.map(e=>{if(!e||typeof e!=`object`)return null;let t=e.name;if(typeof t!=`string`)return null;let n=e._id,r=e.photo?.url;return{_id:String(n??t),name:t,photo:{url:typeof r==`string`?r:``}}}).filter(e=>!!e):void 0;return{id:String(e._id??e.id??`news-${t}`),title:typeof e.title==`string`?e.title:``,excerpt:typeof e.excerpt==`string`?e.excerpt:``,publishedAt:typeof e.publishedAt==`string`?e.publishedAt:new Date().toISOString(),coverGradient:[`#1e1f21`,`#121314`],...i?{coverImageUrl:i}:{},...typeof e.upstreamUpdatedAt==`string`?{upstreamUpdatedAt:e.upstreamUpdatedAt}:{},...o&&o.length>0?{tags:o}:{},...s&&s.length>0?{categories:s}:{},...c&&c.length>0?{authors:c}:{},reactionCounts:e.reactionCounts??null}}function Y(e,t){let[n,r]=x(e);return v(()=>{let n=setTimeout(()=>r(e),t);return()=>clearTimeout(n)},[e,t]),n}function X({item:r,locale:i,delay:a,onClick:o}){let s=e(`news`),c=r.categories??(r.category?[r.category]:[]),l=R(r.authors);return C(t.button,{type:`button`,onClick:o,initial:{opacity:0,y:8},animate:{opacity:1,y:0},whileHover:{y:-2},whileTap:{scale:.985},transition:{duration:.2,delay:a},className:n(`block w-full shrink-0 overflow-hidden rounded-wx-lg bg-wx-bg-elevated text-start [overflow-wrap:anywhere]`,`transition-colors hover:bg-wx-bg-elevated-2`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-wx-primary focus-visible:ring-offset-2 focus-visible:ring-offset-wx-bg`),children:[S(`div`,{className:`aspect-[16/10] w-full bg-cover bg-center`,style:r.coverImageUrl?{backgroundImage:`url(${r.coverImageUrl})`}:{background:`linear-gradient(135deg, ${r.coverGradient[0]}, ${r.coverGradient[1]})`},"aria-hidden":`true`}),C(`div`,{className:`px-5 py-4`,children:[(c.length>0||l!=null)&&C(`div`,{className:`mb-1.5 flex items-center justify-between gap-2`,children:[S(`div`,{className:`flex min-w-0 flex-wrap gap-1.5`,children:c.slice(0,2).map(e=>S(`span`,{className:`text-[10px] font-semibold uppercase tracking-wide text-wx-primary`,children:e.label},e.slug))}),S(z,{authors:l,className:`shrink-0`})]}),S(d,{className:`text-sm`,children:r.title}),r.excerpt&&S(p,{className:`mt-1 text-xs`,children:r.excerpt}),C(`p`,{className:`mt-2 flex items-center gap-2 text-xs text-wx-fg-subtle`,children:[S(`span`,{children:new Date(r.publishedAt).toLocaleDateString(i,{month:`short`,day:`numeric`,year:`numeric`})}),U(r)&&r.upstreamUpdatedAt&&S(`span`,{className:`rounded-full bg-wx-bg-elevated px-1.5 py-0.5 text-[10px] font-medium text-wx-fg-muted`,title:new Date(r.upstreamUpdatedAt).toLocaleString(i),children:s(`editedAt`,{when:W(r.upstreamUpdatedAt)})})]}),r.tags&&r.tags.length>0&&S(`div`,{className:`mt-2.5 flex flex-wrap gap-1`,children:r.tags.slice(0,4).map(e=>S(`span`,{className:`rounded-full bg-wx-bg-elevated px-2 py-0.5 text-[10px] font-medium text-wx-fg-muted`,children:e.label},e.slug))})]})]})}export{B as a,L as c,P as d,T as f,j as g,k as h,H as i,I as l,D as m,W as n,z as o,N as p,U as r,R as s,q as t,F as u};
|
|
140
|
-
//# sourceMappingURL=widget-react-
|
|
140
|
+
//# sourceMappingURL=widget-react-DFbFMJOG.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
globalThis.process===void 0&&(globalThis.process={env:{},nextTick:function(e){setTimeout(e,0)},emit:function(){return!1}});import"react";import"react-dom";import"react/jsx-runtime";import"react-dom/client";import{_ as e,n as t}from"./widget-react-FX5W7RyV.js";import{A as n,D as r,E as i,I as ee,c as a,d as o,gt as te,k as ne,l as re,lt as s,m as c,p as l,u,x as ie}from"./widget-react-
|
|
2
|
-
//# sourceMappingURL=widget-react-
|
|
1
|
+
globalThis.process===void 0&&(globalThis.process={env:{},nextTick:function(e){setTimeout(e,0)},emit:function(){return!1}});import"react";import"react-dom";import"react/jsx-runtime";import"react-dom/client";import{_ as e,n as t}from"./widget-react-FX5W7RyV.js";import{A as n,D as r,E as i,I as ee,c as a,d as o,gt as te,k as ne,l as re,lt as s,m as c,p as l,u,x as ie}from"./widget-react-CkDSkBH9.js";import{i as ae}from"./widget-react-C-hnCqBf.js";import{o as oe,p as se,s as ce,t as le}from"./widget-react-9oF1qdlF.js";import{t as ue}from"./widget-react-BxEMz2N0.js";import{a as d,i as f,n as de,o as p,r as m,s as h,t as g}from"./widget-react-B3jj01Xc.js";import{useEffect as _,useMemo as v,useRef as y,useState as b}from"react";import{jsx as x,jsxs as S}from"react/jsx-runtime";var C=5;function fe(e,t,n=C){let r=e.find(e=>e.slug===t),i=new Set((r?.tags??[]).map(e=>e.slug));return e.filter(e=>e.slug!==t).map(e=>({a:e,score:(r&&e.categoryId===r.categoryId?2:0)+e.tags.filter(e=>i.has(e.slug)).length})).sort((e,t)=>t.score-e.score||t.a.publishedAt.localeCompare(e.a.publishedAt)).slice(0,n).map(({a:e})=>({_id:e.id,title:e.title,slug:e.slug,excerpt:e.excerpt||null}))}function pe(e){let t=e=>Array.isArray(e)?e:[];return{id:String(e._id??``),title:typeof e.title==`string`?e.title:``,excerpt:typeof e.excerpt==`string`?e.excerpt:``,content:typeof e.content==`string`?e.content:``,contentFormat:e.contentFormat===d.HTML?d.HTML:d.MARKDOWN,authors:t(e.authors).filter(e=>!!e&&typeof e==`object`).map(e=>({_id:String(e._id??``),name:typeof e.name==`string`?e.name:null,photo:e.photo})),tags:t(e.tags).filter(e=>!!e&&typeof e==`object`).map(e=>({_id:String(e._id??``),slug:typeof e.slug==`string`?e.slug:``,label:typeof e.label==`string`?e.label:``}))}}function w({slug:t,locale:C,isDummy:w,onHandoff:E,onOpenArticle:D,onOpenTranslation:O,onTitleResolved:k}){let A=e(`help`),j=ne(),M=u(),N=i(),{config:P}=ie(),F=P.messenger?.showRelatedHelpArticles??!0,I=P.messenger?.showReactionCounts??!0,L=ue(),[R,z]=b(C),B=n(R,j),V=v(()=>{if(w)return null;let e=N.previewData?.helpArticles;return Array.isArray(e)?e.find(e=>e&&typeof e==`object`&&e.slug===t)??null:null},[N.previewData,w,t]),H=!!V,{data:U,loading:me}=ce({variables:{args:{slug:t,locale:C}},skip:w||H}),W=te(),G=W.publicKey,K=re(G&&!w&&!H?ee.article(G,t,C):null,U),[q]=oe(),{trackLinkClick:J}=a(),Y=y(null),X=v(()=>w?s(B).find(e=>e.slug===t):null,[w,t,B]),Z=w?X?{id:X.id,title:X.title,excerpt:X.excerpt,content:X.contentMarkdown,contentFormat:d.MARKDOWN,authors:X.authors,tags:X.tags,reactionCounts:null,locale:R,translations:[]}:null:H&&V?{...pe(V),reactionCounts:V.reactionCounts??null,locale:C,translations:[]}:K?.visitorHelpArticle?{id:K.visitorHelpArticle._id,title:K.visitorHelpArticle.title,excerpt:K.visitorHelpArticle.excerpt??``,content:K.visitorHelpArticle.content,contentFormat:K.visitorHelpArticle.contentFormat,authors:K.visitorHelpArticle.authors,tags:K.visitorHelpArticle.tags,reactionCounts:K.visitorHelpArticle.reactionCounts??null,locale:K.visitorHelpArticle.locale,translations:K.visitorHelpArticle.translations}:null,{data:he}=se({variables:{articleId:Z?.id??``,limit:5,locale:C},skip:w||H||!Z?.id||!F}),ge=v(()=>{if(!H||!Z?.id)return[];let e=(N.previewData?.helpArticles??[]).filter(e=>!!e&&typeof e==`object`),t=new Set((Z.tags??[]).map(e=>typeof e==`object`&&e&&`slug`in e?String(e.slug):null).filter(e=>!!e)),n=(()=>{let e=V;if(!e)return null;let t=e.folderId;if(typeof t==`string`)return t;let n=e.folder;if(n&&typeof n==`object`&&`_id`in n){let e=n._id;return typeof e==`string`?e:null}return null})();return e.filter(e=>String(e._id??``)!==Z.id).map(e=>{let r=typeof e.folderId==`string`?e.folderId:e.folder&&typeof e.folder==`object`&&`_id`in e.folder?String(e.folder._id??``):null,i=Array.isArray(e.tags)?e.tags.map(e=>typeof e==`object`&&e&&`slug`in e?String(e.slug):null).filter(e=>!!e):[];return{raw:e,score:(n&&r===n?2:0)+i.filter(e=>t.has(e)).length}}).filter(e=>e.score>0).sort((e,t)=>t.score-e.score).slice(0,5).map(({raw:e})=>({_id:String(e._id??``),title:typeof e.title==`string`?e.title:``,slug:typeof e.slug==`string`?e.slug:``,excerpt:typeof e.excerpt==`string`?e.excerpt:null}))},[H,Z,V,N.previewData]),_e=v(()=>w?fe(s(B),t):[],[w,B,t]),Q=w?_e:H?ge:he?.visitorHelpRelated??[],ve=w||H?null:U?.visitorHelpArticle?.viewerReaction??null,ye=!w&&!H&&U?.visitorHelpArticle?[U.visitorHelpArticle._id,...(U.visitorHelpArticle.translations??[]).map(e=>e._id)]:Z?.id?[Z.id]:[];_(()=>{w||!Z?.id||!W.token||q({variables:{articleId:Z.id}}).catch(()=>{})},[Z?.id,w,q,W]),_(()=>{w||H||!Z?.id||Y.current!==Z.id&&(Y.current=Z.id,J({url:`/help/${t}`,targetType:`HELP_ARTICLE`,targetRefId:Z.id}))},[Z?.id,w,H,t,J]),f(Z?.title,k);let be=()=>E();if(!me&&!Z)return x(`div`,{className:`flex flex-1 flex-col items-center justify-center px-6 py-12`,children:x(l,{children:x(c,{className:`py-8 text-center`,children:x(`p`,{className:`text-sm font-semibold text-wx-fg`,children:A(`articleNotFound`)})})})});let xe=C.split(`-`)[0].toLowerCase(),$=Z?Z.locale.split(`-`)[0].toLowerCase():null;return!w&&!H&&!P.contentLocaleFallback&&$!==null&&$!==xe?x(`div`,{className:`flex flex-1 flex-col items-center justify-center px-6 py-12`,children:x(l,{children:x(c,{className:`py-8 text-center`,children:x(`p`,{className:`text-sm font-semibold text-wx-fg`,children:A(`articleNotTranslated`)})})})}):Z?x(o,{followDirection:!0,className:`flex-1`,viewportRef:M,children:S(`div`,{className:`flex flex-col px-5 pt-5 pb-12 [overflow-wrap:anywhere]`,children:[x(`h2`,{className:`text-xl leading-tight font-bold text-wx-fg`,children:Z.title}),Z.authors.length>0&&S(`p`,{className:`mt-2 flex items-center gap-2 text-xs text-wx-fg-muted`,children:[x(`span`,{className:`flex -space-x-1.5`,children:Z.authors.slice(0,3).map(e=>x(`span`,{className:`h-5 w-5 overflow-hidden rounded-full bg-wx-bg-elevated ring-1 ring-wx-bg`,"aria-hidden":`true`,children:e.photo?.url?x(`img`,{src:e.photo.url,alt:``,className:`h-full w-full object-cover`}):x(`span`,{className:`flex h-full w-full items-center justify-center text-[10px] font-semibold uppercase text-wx-fg-muted`,children:(e.name??`?`).charAt(0)})},e._id))}),x(`span`,{children:A(`writtenBy`,{names:Z.authors.map(e=>e.name??``).filter(Boolean).join(`, `)})})]}),Z.tags.length>0&&x(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:Z.tags.map(e=>x(`span`,{className:`rounded-full bg-wx-bg-elevated px-2 py-0.5 text-[11px] font-medium text-wx-fg-muted`,children:e.label},e._id))}),Z.excerpt&&x(`p`,{className:`mt-2 mb-5 text-sm text-wx-fg-muted`,children:Z.excerpt}),x(m,{content:Z.content,isHtml:Z.contentFormat===d.HTML||h(Z.content),markdownMarginClass:`mt-3`}),S(le,{type:`button`,variant:`solid`,size:`lg`,className:`mt-6 w-full shrink-0 min-h-12`,onClick:be,...L.parentHandlers,children:[x(ae,{ref:L.iconRef,size:16}),x(`span`,{children:A(`unresolvedCta`)})]}),Z.id&&x(g,{surface:p.HELP,itemId:Z.id,reactionCounts:Z.reactionCounts,viewerReaction:ve,groupItemIds:ye,isDummy:w,showCounts:I,className:`mt-4`}),x(de,{currentLocale:w?R:Z.locale,locales:w?[...r]:Z.translations.map(e=>e.locale),allowedLocales:w?void 0:P.supportedLocales,onSelect:w?e=>z(e):e=>{let t=Z.translations.find(t=>t.locale===e);t&&O?.(t.slug,t.locale)},className:`mt-6`}),F&&Q.length>0&&S(`section`,{className:`mt-6`,children:[x(`p`,{className:`mb-2 text-xs font-semibold tracking-wide text-wx-fg-muted uppercase`,children:A(`relatedTitle`)}),x(`ul`,{className:`flex flex-col gap-1.5`,children:Q.map(e=>x(`li`,{children:S(`button`,{type:`button`,onClick:()=>D?.(e.slug),className:`flex w-full flex-col items-start gap-0.5 rounded-wx-lg bg-wx-bg-elevated px-3 py-2 text-start transition-colors hover:bg-wx-bg-elevated/80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-wx-primary`,children:[x(`span`,{className:`block truncate text-sm font-medium text-wx-fg`,children:e.title}),e.excerpt&&x(`span`,{className:`line-clamp-1 block text-xs text-wx-fg-muted`,children:e.excerpt})]})},e._id))})]})]})}):x(T,{})}function T(){return x(o,{followDirection:!0,className:`flex-1`,viewportRef:u(),children:S(`div`,{className:`flex flex-col px-5 pt-5 pb-12`,"aria-busy":`true`,"aria-live":`polite`,children:[S(`div`,{className:`animate-pulse space-y-2.5`,children:[x(`div`,{className:`h-5 w-3/4 rounded-md bg-wx-bg-elevated`}),x(`div`,{className:`h-5 w-1/2 rounded-md bg-wx-bg-elevated`})]}),S(`div`,{className:`mt-4 flex items-center gap-2 animate-pulse`,children:[x(`div`,{className:`h-5 w-5 rounded-full bg-wx-bg-elevated`}),x(`div`,{className:`h-3 w-32 rounded-md bg-wx-bg-elevated`})]}),x(`div`,{className:`mt-6 space-y-2.5 animate-pulse`,children:[`w-full`,`w-11/12`,`w-10/12`,`w-full`,`w-9/12`,`w-full`,`w-11/12`,`w-7/12`].map((e,n)=>x(`div`,{className:t(`h-3 rounded-md bg-wx-bg-elevated`,e)},n))})]})})}export{w as HelpArticleView};
|
|
2
|
+
//# sourceMappingURL=widget-react-uIbfBWRJ.js.map
|
package/dist/widget-react.d.ts
CHANGED
|
@@ -238,6 +238,16 @@ export interface VisitorIdentity {
|
|
|
238
238
|
attributes?: Record<string, unknown>;
|
|
239
239
|
}
|
|
240
240
|
|
|
241
|
+
/**
|
|
242
|
+
* Navigation request: go to a tab (and optionally a help article / news post)
|
|
243
|
+
* without a remount and open the panel. A new `nonce` re-issues the request.
|
|
244
|
+
*/
|
|
245
|
+
export interface PreviewTabSignal {
|
|
246
|
+
tab: WidgetTab;
|
|
247
|
+
nonce: number;
|
|
248
|
+
article?: { kind: "help"; slug: string } | { kind: "news"; id: string };
|
|
249
|
+
}
|
|
250
|
+
|
|
241
251
|
export interface WexioWidgetProps {
|
|
242
252
|
publicKey?: string;
|
|
243
253
|
/**
|
|
@@ -261,6 +271,12 @@ export interface WexioWidgetProps {
|
|
|
261
271
|
* skipped. Memoise this.
|
|
262
272
|
*/
|
|
263
273
|
config?: InjectableWidgetConfig;
|
|
274
|
+
/** Open the panel on mount (uncontrolled afterwards). */
|
|
275
|
+
defaultOpen?: boolean;
|
|
276
|
+
/** Controlled open state; keep it in sync from `onOpen` / `onClose`. Omit to leave uncontrolled. */
|
|
277
|
+
open?: boolean;
|
|
278
|
+
/** Navigate to a tab / article without a remount (and open the panel). Same `nonce` = no-op. */
|
|
279
|
+
previewTab?: PreviewTabSignal;
|
|
264
280
|
onResize?: (size: { width: number; height: number }) => void;
|
|
265
281
|
/**
|
|
266
282
|
* Fired when the visitor opens the panel. Pairs with `onClose`.
|