@wexio/messenger-widget-react 1.7.6 → 1.7.7
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 +7 -0
- package/dist/widget-react-BI1zRae2.js +2 -0
- package/dist/{widget-react-C8SNEdwd.js → widget-react-BbMhq_D0.js} +20 -20
- package/dist/widget-react-C6zJ0C4y.js +2 -0
- package/dist/{widget-react-DyHOzlxL.js → widget-react-Dul9xHaL.js} +11 -11
- package/dist/widget-react-PNvF_UGi.js +140 -0
- package/dist/widget-react-i3rT0ift.js +2 -0
- package/dist/widget-react.d.ts +18 -1
- package/dist/widget-react.js +30 -30
- package/package.json +1 -1
- package/dist/widget-react-Cjd5m37N.js +0 -2
- package/dist/widget-react-DJDytohv.js +0 -2
- package/dist/widget-react-D_H6kTTD.js +0 -140
- package/dist/widget-react-Df0nz7Rs.js +0 -2
|
@@ -0,0 +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{b as e,i as t,n}from"./widget-react-DIvxQOfe.js";import{C as r,Rt as i,S as a,a as o,at as s,b as c,i as l,n as u,on as d,ot as f,t as p,tt as m}from"./widget-react-BbMhq_D0.js";import{n as h}from"./widget-react-ChDwJoyJ.js";import{useCallback as g,useEffect as _,useMemo as v,useRef as y,useState as b}from"react";import{jsx as x,jsxs as S}from"react/jsx-runtime";function C(e){if(!e)return!1;let t=e.trimStart().slice(0,200);return/^<(?:[a-z!][^>]*|!--)/i.test(t)?!0:/<\/?(?:p|div|h[1-6]|ul|ol|li|br|strong|em|b|i|a|table|img|blockquote|figure|span)\b[^>]*>/i.test(e.slice(0,2e3))}var w=function(e){return e.HTML=`HTML`,e.MARKDOWN=`MARKDOWN`,e}({}),T=function(e){return e.HELP=`HELP`,e.NEWS=`NEWS`,e}({});function E(e,t){_(()=>{if(t)return e&&t(e),()=>t(null)},[e,t])}var D=`prose max-w-none text-sm leading-relaxed text-wx-fg [overflow-wrap:anywhere],[&_pre]:[overflow-wrap:normal],[&_p]:my-3 [&_strong]:font-semibold [&_em]:italic,[&_a]:text-wx-primary [&_a]:underline [&_a]:underline-offset-2,[&_a]:transition-opacity [&_a:hover]:opacity-70,[&_code]:rounded-[6px] [&_code]:bg-wx-bg-elevated [&_code]:px-1.5 [&_code]:py-0.5 [&_code]:font-mono [&_code]:text-[0.85em],[&_pre]:my-4 [&_pre]:overflow-x-auto [&_pre]:rounded-lg [&_pre]:border [&_pre]:border-wx-border,[&_pre]:bg-[#0f1115] [&_pre]:text-zinc-100 [&_pre]:p-4 [&_pre]:text-[12.5px] [&_pre]:leading-relaxed,[&_pre_code]:bg-transparent [&_pre_code]:p-0 [&_pre_code]:text-zinc-100,[&_.hljs-keyword]:text-violet-300 [&_.hljs-built_in]:text-violet-300 [&_.hljs-type]:text-violet-300,[&_.hljs-string]:text-emerald-300,[&_.hljs-number]:text-amber-300 [&_.hljs-literal]:text-amber-300,[&_.hljs-comment]:text-zinc-500 [&_.hljs-comment]:italic,[&_.hljs-attr]:text-sky-300 [&_.hljs-attribute]:text-sky-300,[&_.hljs-title]:text-zinc-100 [&_.hljs-title]:font-medium,[&_.hljs-tag]:text-rose-300 [&_.hljs-name]:text-rose-300,[&_h1]:mt-6 [&_h1]:mb-3 [&_h1]:text-xl [&_h1]:font-semibold [&_h1]:tracking-tight,[&_h2]:mt-5 [&_h2]:mb-2 [&_h2]:text-base [&_h2]:font-semibold [&_h2]:tracking-tight,[&_h3]:mt-4 [&_h3]:mb-1.5 [&_h3]:text-sm [&_h3]:font-semibold,[&_h1]:scroll-mt-16 [&_h2]:scroll-mt-16 [&_h3]:scroll-mt-16,[&_ul]:my-3 [&_ul]:list-disc [&_ul]:pl-5 [&_ul]:marker:text-wx-fg-subtle,[&_ol]:my-3 [&_ol]:list-decimal [&_ol]:pl-5 [&_ol]:marker:text-wx-fg-subtle,[&_li]:my-1,[&_ul[data-type=taskList]]:list-none! [&_ul[data-type=taskList]]:pl-0!,[&_ul[data-type=taskList]_li]:my-1.5 [&_ul[data-type=taskList]_li]:flex! [&_ul[data-type=taskList]_li]:items-start [&_ul[data-type=taskList]_li]:gap-2 [&_ul[data-type=taskList]_li]:pl-0,[&_ul[data-type=taskList]_li]:marker:content-none,[&_ul[data-type=taskList]_li>label]:m-0 [&_ul[data-type=taskList]_li>label]:inline-flex [&_ul[data-type=taskList]_li>label]:h-5 [&_ul[data-type=taskList]_li>label]:items-center [&_ul[data-type=taskList]_li>label]:shrink-0 [&_ul[data-type=taskList]_li>label]:select-none,[&_ul[data-type=taskList]_li>label]:pointer-events-none [&_ul[data-type=taskList]_li>label]:cursor-default,[&_ul[data-type=taskList]_input]:accent-wx-primary [&_ul[data-type=taskList]_input]:h-3.5 [&_ul[data-type=taskList]_input]:w-3.5,[&_ul[data-type=taskList]_li>label>span]:hidden,[&_ul[data-type=taskList]_li>div]:min-w-0 [&_ul[data-type=taskList]_li>div]:flex-1,[&_ul[data-type=taskList]_li>div>p]:my-0! [&_ul[data-type=taskList]_li>div>p]:leading-snug,[&_ul[data-type=taskList]_li[data-checked=true]>div]:text-wx-fg-muted [&_ul[data-type=taskList]_li[data-checked=true]>div]:line-through,[&_blockquote]:my-4 [&_blockquote]:border-l-2 [&_blockquote]:border-wx-primary/40,[&_blockquote]:pl-3 [&_blockquote]:italic [&_blockquote]:text-wx-fg-muted,[&_hr]:my-6 [&_hr]:border-wx-border,[&_img]:my-3 [&_img]:mx-auto [&_img]:block [&_img]:max-w-full,[&_figure]:my-5 [&_figure]:flex [&_figure]:flex-col [&_figure]:items-center [&_figure]:text-center,[&_figure_img]:my-0,[&_figcaption]:mt-2 [&_figcaption]:text-xs [&_figcaption]:italic [&_figcaption]:text-wx-fg-muted,[&_table]:my-3 [&_table]:w-full [&_table]:table-fixed [&_table]:border-collapse [&_table]:text-xs,[&_table]:overflow-hidden [&_table]:rounded-lg [&_table]:border [&_table]:border-wx-border,[&_thead]:bg-wx-bg-elevated,[&_th]:px-2.5 [&_th]:py-1.5 [&_th]:text-left [&_th]:font-medium [&_th]:text-wx-fg,[&_th]:border-b [&_th]:border-wx-border,[&_th+th]:border-l [&_th+th]:border-wx-border,[&_td]:px-2.5 [&_td]:py-1.5 [&_td]:text-wx-fg [&_td]:align-top,[&_td+td]:border-l [&_td+td]:border-wx-border,[&_tbody_tr]:border-t [&_tbody_tr]:border-wx-border,[&_tbody_tr:nth-child(odd)]:bg-wx-bg-elevated/40,[&_th_p]:my-0 [&_td_p]:my-0 [&_th_p]:inline [&_td_p]:inline,[&_details]:my-2 [&_details]:overflow-hidden [&_details]:rounded-lg [&_details]:border [&_details]:border-wx-border [&_details]:bg-wx-bg-elevated/40,[&_details+details]:mt-2,[&_summary]:relative [&_summary]:cursor-pointer [&_summary]:list-none [&_summary]:px-4 [&_summary]:py-3,[&_summary]:pr-10 [&_summary]:text-sm [&_summary]:font-medium [&_summary]:text-wx-fg,[&_summary::-webkit-details-marker]:hidden [&_summary::marker]:hidden,[&_summary]:after:absolute [&_summary]:after:right-4 [&_summary]:after:top-1/2,[&_summary]:after:-translate-y-1/2 [&_summary]:after:text-wx-fg-subtle,[&_summary]:after:text-base [&_summary]:after:leading-none,[&_summary]:after:transition-transform [&_summary]:after:content-['\\203A'],[&_details[open]_summary]:after:rotate-90,[&_details[open]_summary]:border-b [&_details[open]_summary]:border-wx-border,[&_details]:[&>:not(summary)]:px-4 [&_details]:[&>:not(summary)]:py-3,[&_details]:[&>:not(summary):first-of-type]:pt-3`.split(`,`).join(` `);function O({content:e,isHtml:t,markdownMarginClass:n}){return t?x(u,{html:e,className:`mt-0 ${D}`}):x(`div`,{className:`${n} ${D}`,children:x(o,{remarkPlugins:[l],children:e})})}function k({currentLocale:i,locales:o,allowedLocales:s,onSelect:l,className:u}){let d=e(`languageSelector`),[f,m]=b(!1),g=y(null);_(()=>{if(!f)return;let e=e=>{g.current&&!e.composedPath().includes(g.current)&&m(!1)},t=e=>{e.key===`Escape`&&m(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[f]);let v=s&&s.length>0?new Set(s.map(e=>e.split(`-`)[0].toLowerCase())):null,C=Array.from(new Set(o.filter(Boolean))).filter(e=>!v||v.has(e.split(`-`)[0].toLowerCase()));if(C.length<=1)return null;let w=i.split(`-`)[0].toLowerCase(),T=C.includes(i);return S(`div`,{ref:g,className:n(`relative`,u),children:[x(`p`,{className:`mb-1.5 text-xs font-semibold tracking-wide text-wx-fg-muted uppercase`,children:d(`title`)}),S(`button`,{type:`button`,onClick:()=>m(e=>!e),"aria-haspopup":`listbox`,"aria-expanded":f,"aria-label":d(`ariaLabel`),className:n(`flex w-full items-center gap-2 rounded-wx-sm border border-wx-border bg-wx-bg px-3 py-2`,`text-sm font-medium text-wx-fg transition-colors hover:bg-wx-bg-elevated`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-wx-primary`),children:[x(c,{size:15,className:`shrink-0 text-wx-fg-muted`}),x(`span`,{className:`min-w-0 flex-1 truncate text-left`,children:p(i)}),x(a,{size:15,className:n(`shrink-0 text-wx-fg-subtle transition-transform`,f&&`rotate-180`)})]}),x(h,{children:f&&x(t.ul,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:4},transition:{duration:.14},className:n(`absolute bottom-full left-0 z-20 mb-1 max-h-56 w-full overflow-auto`,`rounded-wx-sm border border-wx-border bg-wx-bg py-1 shadow-[0_12px_32px_rgba(0,0,0,0.16)]`),role:`listbox`,children:C.map(e=>{let t=T?e===i:e.split(`-`)[0].toLowerCase()===w;return x(`li`,{children:S(`button`,{type:`button`,role:`option`,"aria-selected":t,onClick:()=>{l(e),m(!1)},className:n(`flex w-full items-center gap-2 px-3 py-2 text-left text-sm transition-colors`,t?`font-semibold text-wx-primary`:`text-wx-fg hover:bg-wx-bg-elevated`),children:[x(`span`,{className:`min-w-0 flex-1 truncate`,children:p(e)}),t&&x(r,{size:15,className:`shrink-0 text-wx-primary`})]})},e)})})})]})}var A=(e,t)=>`wexio:reaction:${e}:${t}`,j=[{slotIndex:0,emoji:`🎉`},{slotIndex:1,emoji:`❤️`},{slotIndex:2,emoji:`👍`}],M={[T.NEWS]:`NewsPost`,[T.HELP]:`HelpArticle`};function N({surface:r,itemId:a,reactionCounts:o,viewerReaction:c,groupItemIds:l,readonly:u=!1,showCounts:p=!0,isDummy:h=!1,className:y}){let C=e(`reactions`),w=d(),{data:T,loading:E}=f({variables:{surface:r},fetchPolicy:`cache-first`,skip:h}),[D,{loading:O}]=s(),k=m(),N=i().storage,P=v(()=>h?j:T?.visitorReactionSet?.slots??[],[h,T]),F=h?!0:T?.visitorReactionSet?.enabled??!0,I=A(r,a),[L,R]=b(null);_(()=>{if(!h){R(c??null);return}if(typeof window>`u`)return;let e=N.getItem(I);R(e===null?null:Number(e))},[h,I,N,c]);let[z,B]=b({}),V=e=>(o?.[String(e)]??0)+(h?z[e]??0:0),H=g((e,t)=>{let n=M[r],i=l?.length?l:[a];for(let r of i){let i=w.cache.identify({__typename:n,_id:r});i&&w.cache.modify({id:i,fields:{viewerReaction:()=>t,reactionCounts:n=>{let r={...n??{}};return t!==null&&(r[t]=(r[t]??0)+1),e!==null&&(r[e]=Math.max(0,(r[e]??0)-1)),r}}})}},[w,r,l,a]),U=async e=>{if(u||O||L===e)return;let t=L;if(R(e),h){typeof window<`u`&&N.setItem(I,String(e)),B(n=>({...n,[e]:(n[e]??0)+1,...t===null?{}:{[t]:(n[t]??0)-1}}));return}if(H(t,e),k){k.enqueue({op:`reaction`,semantics:`convergence`,convergenceKey:`reaction:${r}:${a}`,payload:{surface:r,itemId:a,slotIndex:e}});return}try{await D({variables:{input:{surface:r,itemId:a,slotIndex:e}}})}catch{H(e,t),R(t)}};return E||!F||P.length===0?null:x(`div`,{className:n(`flex flex-wrap items-center justify-center gap-2`,y),role:`group`,"aria-label":C(`ariaLabel`),children:P.map(e=>{let r=L===e.slotIndex,i=V(e.slotIndex);return S(t.button,{type:`button`,disabled:u||O,onClick:()=>void U(e.slotIndex),whileTap:{scale:.9},whileHover:{scale:1.06},transition:{type:`spring`,stiffness:400,damping:18},className:n(`flex items-center gap-1.5 rounded-full px-3 py-1.5 text-2xl leading-none transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-wx-primary`,r?`bg-wx-primary/10 ring-1 ring-wx-primary/40`:`hover:bg-wx-bg-elevated`,u&&`cursor-default opacity-70`),"aria-pressed":r,"aria-label":C(`tapAria`,{emoji:e.emoji}),children:[x(`span`,{"aria-hidden":`true`,children:e.emoji}),p&&i>0&&x(`span`,{className:`text-xs font-medium text-wx-fg-muted`,children:i})]},e.slotIndex)})})}export{w as a,E as i,k as n,T as o,O as r,C as s,N as t};
|
|
2
|
+
//# sourceMappingURL=widget-react-C6zJ0C4y.js.map
|
|
@@ -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{n as e,r as t}from"./widget-react-DIvxQOfe.js";import{
|
|
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{n as e,r as t}from"./widget-react-DIvxQOfe.js";import{an as n,in as r,rn as i}from"./widget-react-BbMhq_D0.js";import*as a from"react";import{jsx as o}from"react/jsx-runtime";var s={},c=function(e){return e.Popular=`POPULAR`,e.Recent=`RECENT`,e}({}),l=n`
|
|
2
2
|
query VisitorHelpFolders($parentId: ID, $locale: String) {
|
|
3
3
|
visitorHelpFolders(parentId: $parentId, locale: $locale) {
|
|
4
4
|
_id
|
|
@@ -11,7 +11,7 @@ globalThis.process===void 0&&(globalThis.process={env:{},nextTick:function(e){se
|
|
|
11
11
|
articleCount
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
-
`;function u(e){return
|
|
14
|
+
`;function u(e){return r(l,{...s,...e})}n`
|
|
15
15
|
query VisitorHelpTags($locale: String) {
|
|
16
16
|
visitorHelpTags(locale: $locale) {
|
|
17
17
|
_id
|
|
@@ -20,7 +20,7 @@ globalThis.process===void 0&&(globalThis.process={env:{},nextTick:function(e){se
|
|
|
20
20
|
description
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
`;var d=
|
|
23
|
+
`;var d=n`
|
|
24
24
|
query VisitorHelpList($args: VisitorHelpListArgs) {
|
|
25
25
|
visitorHelpList(args: $args) {
|
|
26
26
|
items {
|
|
@@ -63,7 +63,7 @@ globalThis.process===void 0&&(globalThis.process={env:{},nextTick:function(e){se
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
-
`;function f(e){return
|
|
66
|
+
`;function f(e){return r(d,{...s,...e})}var p=n`
|
|
67
67
|
query VisitorHelpArticle($args: VisitorHelpArticleArgs!) {
|
|
68
68
|
visitorHelpArticle(args: $args) {
|
|
69
69
|
_id
|
|
@@ -108,7 +108,7 @@ globalThis.process===void 0&&(globalThis.process={env:{},nextTick:function(e){se
|
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
|
-
`;function m(e){return
|
|
111
|
+
`;function m(e){return r(p,{...s,...e})}var h=n`
|
|
112
112
|
query VisitorHelpArticlesByIds($ids: [ID!]!, $locale: String) {
|
|
113
113
|
visitorHelpArticlesByIds(ids: $ids, locale: $locale) {
|
|
114
114
|
_id
|
|
@@ -122,7 +122,7 @@ globalThis.process===void 0&&(globalThis.process={env:{},nextTick:function(e){se
|
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
|
-
`;function g(e){return
|
|
125
|
+
`;function g(e){return r(h,{...s,...e})}var _=n`
|
|
126
126
|
query VisitorHelpRelated($articleId: ID!, $limit: Int, $locale: String) {
|
|
127
127
|
visitorHelpRelated(articleId: $articleId, limit: $limit, locale: $locale) {
|
|
128
128
|
_id
|
|
@@ -135,13 +135,13 @@ globalThis.process===void 0&&(globalThis.process={env:{},nextTick:function(e){se
|
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
|
-
`;function v(e){return
|
|
138
|
+
`;function v(e){return r(_,{...s,...e})}var y=n`
|
|
139
139
|
mutation RecordVisitorHelpView($articleId: String!) {
|
|
140
140
|
recordVisitorHelpView(articleId: $articleId) {
|
|
141
141
|
ok
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
|
-
`;function b(e){return
|
|
144
|
+
`;function b(e){return i(y,{...s,...e})}var x=n`
|
|
145
145
|
query VisitorHelpListSlim($args: VisitorHelpListArgs) {
|
|
146
146
|
visitorHelpList(args: $args) {
|
|
147
147
|
items {
|
|
@@ -151,7 +151,7 @@ globalThis.process===void 0&&(globalThis.process={env:{},nextTick:function(e){se
|
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
|
-
`;function S(e){return
|
|
154
|
+
`;function S(e){return r(x,{...s,...e})}var C=n`
|
|
155
155
|
query VisitorHelpArticlesByIdsSlim($ids: [ID!]!, $locale: String) {
|
|
156
156
|
visitorHelpArticlesByIds(ids: $ids, locale: $locale) {
|
|
157
157
|
_id
|
|
@@ -159,5 +159,5 @@ globalThis.process===void 0&&(globalThis.process={env:{},nextTick:function(e){se
|
|
|
159
159
|
slug
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
|
-
`;function w(e){return
|
|
163
|
-
//# sourceMappingURL=widget-react-
|
|
162
|
+
`;function w(e){return r(C,{...s,...e})}function T(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function E(...e){return t=>{let n=!1,r=e.map(e=>{let r=T(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():T(e[t],null)}}}}var D=Symbol.for(`react.lazy`),O=a.use;function k(e){return typeof e==`object`&&!!e&&`then`in e}function A(e){return typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===D&&`_payload`in e&&k(e._payload)}function j(e){let t=N(e),n=a.forwardRef((e,n)=>{let{children:r,...i}=e;A(r)&&typeof O==`function`&&(r=O(r._payload));let s=a.Children.toArray(r),c=s.find(F);if(c){let e=c.props.children,r=s.map(t=>t===c?a.Children.count(e)>1?a.Children.only(null):a.isValidElement(e)?e.props.children:null:t);return o(t,{...i,ref:n,children:a.isValidElement(e)?a.cloneElement(e,void 0,r):null})}return o(t,{...i,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}var M=j(`Slot`);function N(e){let t=a.forwardRef((e,t)=>{let{children:n,...r}=e;if(A(n)&&typeof O==`function`&&(n=O(n._payload)),a.isValidElement(n)){let e=L(n),i=I(r,n.props);return n.type!==a.Fragment&&(i.ref=t?E(t,e):e),a.cloneElement(n,i)}return a.Children.count(n)>1?a.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var P=Symbol(`radix.slottable`);function F(e){return a.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===P}function I(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}function L(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var R=e=>typeof e==`boolean`?`${e}`:e===0?`0`:e,z=t,B=((e,t)=>n=>{if(t?.variants==null)return z(e,n?.class,n?.className);let{variants:r,defaultVariants:i}=t,a=Object.keys(r).map(e=>{let t=n?.[e],a=i?.[e];if(t===null)return null;let o=R(t)||R(a);return r[e][o]}),o=n&&Object.entries(n).reduce((e,t)=>{let[n,r]=t;return r===void 0||(e[n]=r),e},{});return z(e,a,t?.compoundVariants?.reduce((e,t)=>{let{class:n,className:r,...a}=t;return Object.entries(a).every(e=>{let[t,n]=e;return Array.isArray(n)?n.includes({...i,...o}[t]):{...i,...o}[t]===n})?[...e,n,r]:e},[]),n?.class,n?.className)})(`inline-flex items-center justify-center gap-2 font-semibold transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-wx-primary focus-visible:ring-offset-2 focus-visible:ring-offset-wx-bg disabled:pointer-events-none disabled:opacity-50`,{variants:{variant:{solid:`bg-wx-primary text-wx-primary-fg hover:bg-wx-primary-hover`,tonal:`bg-wx-bg-elevated text-wx-fg hover:bg-wx-bg-elevated-2`,ghost:`bg-transparent text-wx-fg-muted hover:bg-wx-bg-elevated hover:text-wx-fg`,outline:`border border-wx-border bg-transparent text-wx-fg hover:bg-wx-bg-elevated`},size:{sm:`h-8 px-3 text-xs rounded-wx-sm whitespace-nowrap`,md:`h-10 px-4 text-sm rounded-wx whitespace-nowrap`,lg:`h-12 px-5 text-sm rounded-wx-lg whitespace-nowrap`,tile:`w-full px-5 py-5 text-base rounded-wx-lg`,icon:`h-9 w-9 rounded-full whitespace-nowrap`}},defaultVariants:{variant:`solid`,size:`md`}}),V=a.forwardRef(({className:t,variant:n,size:r,asChild:i=!1,...a},s)=>o(i?M:`button`,{ref:s,className:e(B({variant:n,size:r,className:t})),...a}));V.displayName=`Button`;export{d as a,g as c,f as d,S as f,l as i,w as l,j as n,b as o,v as p,c as r,m as s,V as t,u};
|
|
163
|
+
//# sourceMappingURL=widget-react-Dul9xHaL.js.map
|
|
@@ -0,0 +1,140 @@
|
|
|
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{S as e,b as t,i as n,n as r,t as i}from"./widget-react-DIvxQOfe.js";import{A as a,Dt as o,Q as s,Rt as c,an as l,f as u,in as d,k as f,l as p,m,nt as h,v as g,y as _}from"./widget-react-BbMhq_D0.js";import{c as v}from"./widget-react-_QsYqFeh.js";import{useCallback as y,useEffect as b,useMemo as x,useRef as S,useState as C}from"react";import{Fragment as w,jsx as T,jsxs as E}from"react/jsx-runtime";var D={},O=l`
|
|
2
|
+
query VisitorNewsList($args: VisitorNewsListArgs) {
|
|
3
|
+
visitorNewsList(args: $args) {
|
|
4
|
+
items {
|
|
5
|
+
_id
|
|
6
|
+
title
|
|
7
|
+
slug
|
|
8
|
+
excerpt
|
|
9
|
+
publishedAt
|
|
10
|
+
upstreamUpdatedAt
|
|
11
|
+
reactionCounts
|
|
12
|
+
coverImageUrl {
|
|
13
|
+
_id
|
|
14
|
+
url
|
|
15
|
+
}
|
|
16
|
+
externalCoverImageUrl
|
|
17
|
+
authors {
|
|
18
|
+
_id
|
|
19
|
+
name
|
|
20
|
+
photo {
|
|
21
|
+
_id
|
|
22
|
+
url
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
categories {
|
|
26
|
+
_id
|
|
27
|
+
slug
|
|
28
|
+
label
|
|
29
|
+
}
|
|
30
|
+
tags {
|
|
31
|
+
_id
|
|
32
|
+
slug
|
|
33
|
+
label
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
meta {
|
|
37
|
+
totalCount
|
|
38
|
+
currentPage
|
|
39
|
+
totalPages
|
|
40
|
+
hasNextPage
|
|
41
|
+
hasPreviousPage
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
`;function k(e){return d(O,{...D,...e})}var A=l`
|
|
46
|
+
query VisitorNewsPostCard($args: VisitorNewsPostArgs!) {
|
|
47
|
+
visitorNewsPost(args: $args) {
|
|
48
|
+
_id
|
|
49
|
+
title
|
|
50
|
+
excerpt
|
|
51
|
+
coverImageUrl {
|
|
52
|
+
_id
|
|
53
|
+
url
|
|
54
|
+
}
|
|
55
|
+
externalCoverImageUrl
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
`;function j(e){return d(A,{...D,...e})}var M=l`
|
|
59
|
+
query VisitorNewsPost($args: VisitorNewsPostArgs!) {
|
|
60
|
+
visitorNewsPost(args: $args) {
|
|
61
|
+
_id
|
|
62
|
+
title
|
|
63
|
+
slug
|
|
64
|
+
excerpt
|
|
65
|
+
contentMarkdown
|
|
66
|
+
bodyFormat
|
|
67
|
+
locale
|
|
68
|
+
publishedAt
|
|
69
|
+
upstreamUpdatedAt
|
|
70
|
+
viewCount
|
|
71
|
+
reactionCounts
|
|
72
|
+
viewerReaction
|
|
73
|
+
sourceUrl
|
|
74
|
+
coverImageUrl {
|
|
75
|
+
_id
|
|
76
|
+
url
|
|
77
|
+
}
|
|
78
|
+
externalCoverImageUrl
|
|
79
|
+
source {
|
|
80
|
+
_id
|
|
81
|
+
name
|
|
82
|
+
type
|
|
83
|
+
}
|
|
84
|
+
authors {
|
|
85
|
+
_id
|
|
86
|
+
name
|
|
87
|
+
photo {
|
|
88
|
+
_id
|
|
89
|
+
url
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
categories {
|
|
93
|
+
_id
|
|
94
|
+
slug
|
|
95
|
+
label
|
|
96
|
+
}
|
|
97
|
+
tags {
|
|
98
|
+
_id
|
|
99
|
+
slug
|
|
100
|
+
label
|
|
101
|
+
}
|
|
102
|
+
translations {
|
|
103
|
+
_id
|
|
104
|
+
locale
|
|
105
|
+
slug
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
`;function N(e){return d(M,{...D,...e})}var P=l`
|
|
110
|
+
query VisitorNewsRelated($postId: ID!, $limit: Int, $locale: String) {
|
|
111
|
+
visitorNewsRelated(postId: $postId, limit: $limit, locale: $locale) {
|
|
112
|
+
_id
|
|
113
|
+
title
|
|
114
|
+
slug
|
|
115
|
+
excerpt
|
|
116
|
+
publishedAt
|
|
117
|
+
coverImageUrl {
|
|
118
|
+
_id
|
|
119
|
+
url
|
|
120
|
+
}
|
|
121
|
+
externalCoverImageUrl
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
`;function F(e){return d(P,{...D,...e})}l`
|
|
125
|
+
mutation RecordVisitorNewsView($postId: String!) {
|
|
126
|
+
recordVisitorNewsView(postId: $postId) {
|
|
127
|
+
ok
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
`;var I=l`
|
|
131
|
+
query VisitorNewsListSlim($args: VisitorNewsListArgs) {
|
|
132
|
+
visitorNewsList(args: $args) {
|
|
133
|
+
items {
|
|
134
|
+
_id
|
|
135
|
+
title
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
`;function L(e){return d(I,{...D,...e})}var R=i(`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`}]]),z=i(`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 B({icon:e,size:t=20,strokeWidth:n=2,className:i,...a}){return T(e,{width:t,height:t,strokeWidth:n,className:r(`shrink-0`,i),...a})}function V({className:e,...t}){return T(`div`,{"data-slot":`skeleton`,className:r(`animate-pulse rounded-wx-sm bg-wx-bg-elevated`,e),...t})}function H(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 U({authors:e,max:t=3,className:n}){return!e||e.length===0?null:T(`span`,{className:`flex items-center -space-x-1.5 ${n??``}`,children:e.slice(0,t).map(e=>e.photoUrl?T(`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):T(`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 W({value:e,onChange:t,placeholder:n,className:i}){return E(`div`,{className:r(`sticky top-0 z-10 flex items-center gap-2.5 border-wx-border border-b bg-wx-bg px-4`,i),children:[T(v,{size:16,className:`shrink-0 text-wx-fg-muted`}),T(`input`,{type:`search`,value:e,onChange:e=>t(e.target.value),placeholder:n,className:r(`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 G=new Map;function K(e){let t=S(null);return b(()=>{let n=t.current;if(!n)return;let r=G.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=()=>{G.set(e,n.scrollTop)};return n.addEventListener(`scroll`,s,{passive:!0}),()=>{i=!0,n.removeEventListener(`scroll`,s)}},[e]),t}function q({url:e,className:t}){let[n,i]=C(null);return!e||n===e?null:T(`img`,{ref:t=>{t?.complete&&t.naturalWidth===0&&i(e)},src:e,alt:``,"aria-hidden":`true`,"data-testid":`news-cover`,onError:()=>i(e),className:r(`w-full bg-wx-bg-elevated-2 object-cover`,t)})}function J(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 Y(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 X=10,ee=240;function Z({isDummy:n,onOpenArticle:r}){let i=t(`news`),l=a(),u=e(),d=s(),[g,_]=C(``),v=te(g,300),S=v.length>=2,D=d.previewData?.newsPosts,O=!n&&Array.isArray(D)&&D.length>0,[A,j]=C(X),{data:M,error:N,loading:P,fetchMore:F}=k({variables:{args:{locale:u,limit:X,offset:0,...S?{query:v}:{}}},skip:n||O,notifyOnNetworkStatusChange:!0});b(()=>{j(X)},[v,O]);let I=c().publicKey,L=p(I&&!n&&!S?h.news(I,u):null,M),R=x(()=>(L?.visitorNewsList?.items??[]).filter(e=>!!e).map(Q),[L]),H=O?(D??[]).filter(e=>!!e&&typeof e==`object`).map(Q):[],U=y(e=>e.title.toLowerCase().includes(v.toLowerCase())||e.excerpt.toLowerCase().includes(v.toLowerCase()),[v]),G=n?S?o(l).filter(U):o(l):O?S?H.filter(U):H:R,q=O||n?G.slice(0,A):G,J=x(()=>n||O?A<G.length:L?.visitorNewsList?.meta?.hasNextPage??!1,[n,O,A,G.length,L]),[Y,Z]=C(!1),$=y(async()=>{if(!(!J||Y)){if(n||O){j(e=>e+X);return}Z(!0);try{await F({variables:{args:{locale:u,limit:X,offset:M?.visitorNewsList?.items?.length??0,...S?{query:v}:{}}},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{Z(!1)}}},[J,Y,n,O,S,v,u,F,M]),re=K(`news`),ie=y(e=>{let t=e.currentTarget;t.scrollHeight-t.clientHeight-t.scrollTop<ee&&$()},[$]),ae=G.length>0||S,oe=n&&!f(l)||!n&&!O&&P&&q.length===0;return N&&q.length===0?T(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 px-6 py-12 text-center`,children:T(`p`,{className:`text-sm text-wx-fg-muted`,children:i(`emptyTitle`)})}):E(m,{followDirection:!0,className:`flex-1`,viewportRef:re,onScroll:ie,children:[ae&&T(W,{value:g,onChange:_,placeholder:i(`searchPlaceholder`)}),T(`div`,{className:`flex flex-col gap-3 px-4 pt-4 pb-6`,children:oe?Array.from({length:3}).map((e,t)=>E(`div`,{className:`overflow-hidden rounded-wx-lg bg-wx-bg-elevated`,children:[T(V,{className:`aspect-[16/10] w-full rounded-none`}),E(`div`,{className:`space-y-2 px-5 py-4`,children:[T(V,{className:`h-3 w-3/4`}),T(V,{className:`h-3 w-1/2`}),T(V,{className:`mt-1 h-2 w-1/3`})]})]},t)):q.length===0?E(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 px-6 py-12 text-center`,children:[T(`div`,{className:`flex h-14 w-14 items-center justify-center rounded-full bg-wx-bg-elevated text-wx-fg-muted`,children:T(B,{icon:z,size:28})}),T(`p`,{className:`text-base font-semibold text-wx-fg`,children:i(S?`noResults`:`emptyTitle`)}),!S&&T(`p`,{className:`text-sm text-wx-fg-muted`,children:i(`emptyBody`)})]}):E(w,{children:[q.map((e,t)=>T(ne,{item:e,locale:u,delay:t<X?t*.04:0,onClick:()=>r(e.id)},e.id)),Y&&T(`div`,{className:`flex justify-center py-3`,children:T(V,{className:`h-3 w-24`})})]})})]})}function Q(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`?u(e.excerpt,240):``,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 te(e,t){let[n,r]=C(e);return b(()=>{let n=setTimeout(()=>r(e),t);return()=>clearTimeout(n)},[e,t]),n}function ne({item:e,locale:i,delay:a,onClick:o}){let s=t(`news`),c=e.categories??(e.category?[e.category]:[]),l=H(e.authors);return E(n.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:r(`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:[T(q,{url:e.coverImageUrl,className:`aspect-[16/10]`}),E(`div`,{className:`px-5 py-4`,children:[(c.length>0||l!=null)&&E(`div`,{className:`mb-1.5 flex items-center justify-between gap-2`,children:[T(`div`,{className:`flex min-w-0 flex-wrap gap-1.5`,children:c.slice(0,2).map(e=>T(`span`,{className:`text-[10px] font-semibold uppercase tracking-wide text-wx-primary`,children:e.label},e.slug))}),T(U,{authors:l,className:`shrink-0`})]}),T(_,{className:`text-sm`,children:e.title}),e.excerpt&&T(g,{className:`mt-1 line-clamp-4 text-xs`,children:e.excerpt}),E(`p`,{className:`mt-2 flex items-center gap-2 text-xs text-wx-fg-subtle`,children:[T(`span`,{children:new Date(e.publishedAt).toLocaleDateString(i,{month:`short`,day:`numeric`,year:`numeric`})}),J(e)&&e.upstreamUpdatedAt&&T(`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(e.upstreamUpdatedAt).toLocaleString(i),children:s(`editedAt`,{when:Y(e.upstreamUpdatedAt)})})]}),e.tags&&e.tags.length>0&&T(`div`,{className:`mt-2.5 flex flex-wrap gap-1`,children:e.tags.slice(0,4).map(e=>T(`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{F as _,K as a,H as c,z as d,R as f,N as g,j as h,q as i,V as l,L as m,Y as n,W as o,O as p,J as r,U as s,Z as t,B as u};
|
|
140
|
+
//# sourceMappingURL=widget-react-PNvF_UGi.js.map
|
|
@@ -0,0 +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{b as e,n as t}from"./widget-react-DIvxQOfe.js";import{A as n,O as r,Q as i,Rt as ee,_ as a,c as te,d as ne,f as o,g as s,j as c,jt as l,l as re,m as u,nt as ie,u as d,w as f}from"./widget-react-BbMhq_D0.js";import{i as p}from"./widget-react-_QsYqFeh.js";import{o as m,p as h,s as ae,t as oe}from"./widget-react-Dul9xHaL.js";import{t as se}from"./widget-react-BxEMz2N0.js";import{a as g,i as ce,n as le,o as ue,r as de,s as _,t as v}from"./widget-react-C6zJ0C4y.js";import{useEffect as y,useMemo as b,useRef as fe,useState as pe}from"react";import{jsx as x,jsxs as S}from"react/jsx-runtime";var C=5;function me(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 he(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===g.HTML?g.HTML:g.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=n(),M=d(),N=i(),{config:P}=f(),F=P.messenger?.showRelatedHelpArticles??!0,I=P.messenger?.showReactionCounts??!0,L=se(),[R,ge]=pe(C),z=c(R,j),B=b(()=>{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]),V=!!B,{data:H,loading:_e}=ae({variables:{args:{slug:t,locale:C}},skip:w||V}),U=ee(),W=U.publicKey,G=re(W&&!w&&!V?ie.article(W,t,C):null,H),[K]=m(),{trackLinkClick:q}=te(),J=fe(null),Y=b(()=>w?l(z).find(e=>e.slug===t):null,[w,t,z]),X=w?Y?{id:Y.id,title:Y.title,excerpt:Y.excerpt,content:Y.contentMarkdown,contentFormat:g.MARKDOWN,authors:Y.authors,tags:Y.tags,reactionCounts:null,locale:R,translations:[]}:null:V&&B?{...he(B),reactionCounts:B.reactionCounts??null,locale:C,translations:[]}:G?.visitorHelpArticle?{id:G.visitorHelpArticle._id,title:G.visitorHelpArticle.title,excerpt:G.visitorHelpArticle.excerpt??``,content:G.visitorHelpArticle.content,contentFormat:G.visitorHelpArticle.contentFormat,authors:G.visitorHelpArticle.authors,tags:G.visitorHelpArticle.tags,reactionCounts:G.visitorHelpArticle.reactionCounts??null,locale:G.visitorHelpArticle.locale,translations:G.visitorHelpArticle.translations}:null,{data:ve}=h({variables:{articleId:X?.id??``,limit:5,locale:C},skip:w||V||!X?.id||!F}),ye=b(()=>{if(!V||!X?.id)return[];let e=(N.previewData?.helpArticles??[]).filter(e=>!!e&&typeof e==`object`),t=new Set((X.tags??[]).map(e=>typeof e==`object`&&e&&`slug`in e?String(e.slug):null).filter(e=>!!e)),n=(()=>{let e=B;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??``)!==X.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}))},[V,X,B,N.previewData]),be=b(()=>w?me(l(z),t):[],[w,z,t]),Z=w?be:V?ye:ve?.visitorHelpRelated??[],xe=w||V?null:H?.visitorHelpArticle?.viewerReaction??null,Se=!w&&!V&&H?.visitorHelpArticle?[H.visitorHelpArticle._id,...(H.visitorHelpArticle.translations??[]).map(e=>e._id)]:X?.id?[X.id]:[];y(()=>{w||!X?.id||!U.token||K({variables:{articleId:X.id}}).catch(()=>{})},[X?.id,w,K,U]),y(()=>{w||V||!X?.id||J.current!==X.id&&(J.current=X.id,q({url:`/help/${t}`,targetType:`HELP_ARTICLE`,targetRefId:X.id}))},[X?.id,w,V,t,q]),ce(X?.title,k);let Ce=()=>E();if(!_e&&!X)return x(`div`,{className:`flex flex-1 flex-col items-center justify-center px-6 py-12`,children:x(s,{children:x(a,{className:`py-8 text-center`,children:x(`p`,{className:`text-sm font-semibold text-wx-fg`,children:A(`articleNotFound`)})})})});let we=C.split(`-`)[0].toLowerCase(),Q=X?X.locale.split(`-`)[0].toLowerCase():null;if(!w&&!V&&!P.contentLocaleFallback&&Q!==null&&Q!==we)return x(`div`,{className:`flex flex-1 flex-col items-center justify-center px-6 py-12`,children:x(s,{children:x(a,{className:`py-8 text-center`,children:x(`p`,{className:`text-sm font-semibold text-wx-fg`,children:A(`articleNotTranslated`)})})})});if(!X)return x(T,{});let $=ne(X.excerpt,X.content)?``:o(X.excerpt,400);return x(u,{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:X.title}),X.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:X.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:X.authors.map(e=>e.name??``).filter(Boolean).join(`, `)})})]}),X.tags.length>0&&x(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:X.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))}),$&&x(`p`,{className:`mt-2 mb-5 text-sm text-wx-fg-muted`,children:$}),x(de,{content:X.content,isHtml:X.contentFormat===g.HTML||_(X.content),markdownMarginClass:`mt-3`}),S(oe,{type:`button`,variant:`solid`,size:`lg`,className:`mt-6 w-full shrink-0 min-h-12`,onClick:Ce,...L.parentHandlers,children:[x(p,{ref:L.iconRef,size:16}),x(`span`,{children:A(`unresolvedCta`)})]}),X.id&&x(v,{surface:ue.HELP,itemId:X.id,reactionCounts:X.reactionCounts,viewerReaction:xe,groupItemIds:Se,isDummy:w,showCounts:I,className:`mt-4`}),x(le,{currentLocale:w?R:X.locale,locales:w?[...r]:X.translations.map(e=>e.locale),allowedLocales:w?void 0:P.supportedLocales,onSelect:w?e=>ge(e):e=>{let t=X.translations.find(t=>t.locale===e);t&&O?.(t.slug,t.locale)},className:`mt-6`}),F&&Z.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:Z.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:o(e.excerpt,160)})]})},e._id))})]})]})})}function T(){return x(u,{followDirection:!0,className:`flex-1`,viewportRef:d(),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-i3rT0ift.js.map
|
package/dist/widget-react.d.ts
CHANGED
|
@@ -101,11 +101,21 @@ export type HomeNamedIcon =
|
|
|
101
101
|
| "discord"
|
|
102
102
|
| "slack"
|
|
103
103
|
| "line"
|
|
104
|
+
| "signal"
|
|
105
|
+
| "wechat"
|
|
104
106
|
| "facebook"
|
|
105
107
|
| "twitter"
|
|
106
108
|
| "linkedin"
|
|
107
109
|
| "reddit"
|
|
108
110
|
| "tiktok"
|
|
111
|
+
| "youtube"
|
|
112
|
+
| "x"
|
|
113
|
+
| "threads"
|
|
114
|
+
| "pinterest"
|
|
115
|
+
| "snapchat"
|
|
116
|
+
| "twitch"
|
|
117
|
+
| "github"
|
|
118
|
+
| "spotify"
|
|
109
119
|
| "chat"
|
|
110
120
|
| "email"
|
|
111
121
|
| "phone"
|
|
@@ -120,7 +130,14 @@ export type HomeNamedIcon =
|
|
|
120
130
|
| "lock"
|
|
121
131
|
| "shield"
|
|
122
132
|
| "user"
|
|
123
|
-
| "users"
|
|
133
|
+
| "users"
|
|
134
|
+
| "globe"
|
|
135
|
+
| "calendar"
|
|
136
|
+
| "map-pin"
|
|
137
|
+
| "shopping-cart"
|
|
138
|
+
| "download"
|
|
139
|
+
| "gift"
|
|
140
|
+
| "file-text";
|
|
124
141
|
|
|
125
142
|
export type HomeQuickActionIcon =
|
|
126
143
|
| { kind: "named"; name: HomeNamedIcon; colored?: boolean }
|