@nocobase/plugin-notification-in-app-message 1.4.0-alpha → 1.4.0-alpha.20241031134640

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.
@@ -7,13 +7,13 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
- (function(r,a){typeof exports=="object"&&typeof module!="undefined"?a(exports,require("@nocobase/client"),require("react/jsx-runtime"),require("react"),require("antd"),require("@ant-design/icons"),require("antd-style"),require("@formily/reactive-react"),require("@emotion/css"),require("@nocobase/utils/client"),require("react-i18next"),require("@formily/reactive"),require("react-router-dom"),require("@nocobase/plugin-notification-manager/client"),require("@nocobase/plugin-workflow/client"),require("@formily/react")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","react/jsx-runtime","react","antd","@ant-design/icons","antd-style","@formily/reactive-react","@emotion/css","@nocobase/utils/client","react-i18next","@formily/reactive","react-router-dom","@nocobase/plugin-notification-manager/client","@nocobase/plugin-workflow/client","@formily/react"],a):(r=typeof globalThis!="undefined"?globalThis:r||self,a(r["@nocobase/plugin-notification-in-app-message"]={},r["@nocobase/client"],r.jsxRuntime,r.react,r.antd,r["@ant-design/icons"],r["antd-style"],r["@formily/reactive-react"],r["@emotion/css"],r["@nocobase/utils"],r["react-i18next"],r["@formily/reactive"],r["react-router-dom"],r["@nocobase/plugin-notification-manager"],r["@nocobase/plugin-workflow"],r["@formily/react"]))})(this,function(r,a,t,y,o,q,j,k,C,g,ee,h,te,ne,D,W){"use strict";var Ie=Object.defineProperty,Se=Object.defineProperties;var Ae=Object.getOwnPropertyDescriptors;var Z=Object.getOwnPropertySymbols;var Fe=Object.prototype.hasOwnProperty,Le=Object.prototype.propertyIsEnumerable;var $=(r,a,t)=>a in r?Ie(r,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[a]=t,S=(r,a)=>{for(var t in a||(a={}))Fe.call(a,t)&&$(r,t,a[t]);if(Z)for(var t of Z(a))Le.call(a,t)&&$(r,t,a[t]);return r},R=(r,a)=>Se(r,Ae(a));var b=(r,a,t)=>new Promise((y,o)=>{var q=C=>{try{k(t.next(C))}catch(g){o(g)}},j=C=>{try{k(t.throw(C))}catch(g){o(g)}},k=C=>C.done?y(C.value):Promise.resolve(C.value).then(q,j);k((t=t.apply(r,a)).next())});const G="notification-in-app-message";function I(){return ee.useTranslation([G,"client"],{nsMode:"fallback"})}let K;const oe=e=>{K=e},A=()=>K,E=h.observable({value:null}),B=h.observable({value:{}}),O=h.observable({value:!1}),Q=h.observable({value:0}),v=h.observable({value:"all"}),M=h.observable.computed(()=>Object.values(B.value).filter(n=>{var s;return n.userId==String((s=E.value)!=null?s:"")}).filter(n=>v.value==="read"?n.totalMsgCnt-n.unreadMsgCnt>0:v.value==="unread"?n.unreadMsgCnt>0:!0).sort((n,s)=>n.latestMsgReceiveTimestamp>s.latestMsgReceiveTimestamp?-1:1)),se=h.observable.computed(()=>M.value.length<Q.value),f=h.observable({value:null}),N=e=>b(this,null,function*(){var u,m,l;const n=A();O.value=!0;const s=yield n.request({url:"myInAppChannels:list",method:"get",params:g.merge({filter:{status:v.value}},e!=null?e:{})}),c=(u=s.data)==null?void 0:u.data;Array.isArray(c)&&c.forEach(p=>{B.value[p.name]=p});const d=(l=(m=s.data)==null?void 0:m.meta)==null?void 0:l.count;d>=0&&(Q.value=d),O.value=!1});h.autorun(()=>{var e;!f.value&&((e=M.value[0])!=null&&e.name)?f.value=M.value[0].name:(M.value.length===0||M.value.length>0&&!M.value.find(n=>n.name===f.value))&&(f.value=null)}),h.reaction(()=>v.value,()=>{var e;(e=M.value[0])!=null&&e.name&&(f.value=M.value[0].name)},{fireImmediately:!0});const re={name:"notificationInAppMessages",fieldNameMap:{id:"id",channelName:"channelName",userId:"userId",content:"content",status:"status",title:"title",receiveTimestamp:"receiveTimestamp",options:"options"}},F=h.observable({value:{}}),P=h.observable({value:!1}),ae=h.observable.computed(()=>Object.values(F.value).sort((e,n)=>e.receiveTimestamp>n.receiveTimestamp?-1:1)),le=e=>v.value==="read"?e.status==="read":v.value==="unread"?e.status==="unread":!0,ie=e=>{var n;return e.userId==String((n=E.value)!=null?n:"")},U=h.observable.computed(()=>f.value?ae.value.filter(n=>n.channelName===f.value&&le(n)&&ie):[]),X=(...n)=>b(this,[...n],function*(e={limit:30}){var u,m;P.value=!0,v.value!=="all"&&(e.filter=g.merge((u=e.filter)!=null?u:{},{status:v.value}));const c=yield A().request({url:"myInAppMessages:list",method:"get",params:e}),d=(m=c==null?void 0:c.data)==null?void 0:m.data.messages;Array.isArray(d)&&d.forEach(l=>{F.value[l.id]=l}),P.value=!1}),Y=e=>b(this,null,function*(){yield A().request({resource:re.name,action:"update",method:"post",params:e});const s=F.value[e.filterByTk];F.value[e.filterByTk]=S(S({},s),e.values),V()});h.autorun(()=>{f.value&&X({filter:{channelName:f.value}})});const z=h.observable({value:null}),V=()=>b(this,null,function*(){var s;const n=yield A().request({url:"myInAppMessages:count",method:"get",params:{filter:{status:"unread"}}});z.value=(s=n==null?void 0:n.data)==null?void 0:s.data.count}),ce=h.observable.computed(()=>{const e=f.value;if(!e)return!1;const n=B.value[e],s=U.value;if({read:n.totalMsgCnt-n.unreadMsgCnt>s.length,unread:n.unreadMsgCnt>s.length,all:n.totalMsgCnt>s.length}[v.value]&&s.length>0)return!0}),L=h.observable({value:!1}),_=h.observable({value:null});h.reaction(()=>_.value,e=>{if(e&&["message:created","message:updated"].includes(e.type)){const{data:n}=e;F.value[n.id]=n,e.type==="message:created"&&o.notification.info({message:t.jsx("div",{style:{textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap"},children:n.title}),description:n.content.slice(0,100)+(n.content.length>100?"...":""),onClick:()=>{L.value=!0,f.value=n.channelName,o.notification.destroy()}}),N({filter:{name:n.channelName}}),V()}});const ue=()=>b(this,null,function*(){let e=0;const n=g.uid(),s=d=>b(this,null,function*(){const p=(yield A().silent().request({url:"myInAppMessages:sse",method:"get",headers:{Accept:"text/event-stream"},params:{id:d},responseType:"stream",adapter:"fetch"})).data.pipeThrough(new TextDecoderStream).getReader();for(e=0;;){const{value:x,done:H}=yield p.read();if(H)break;const i=x.split(`
10
+ (function(r,a){typeof exports=="object"&&typeof module!="undefined"?a(exports,require("@nocobase/client"),require("react/jsx-runtime"),require("react"),require("antd"),require("@ant-design/icons"),require("antd-style"),require("@formily/reactive-react"),require("@emotion/css"),require("@nocobase/utils/client"),require("react-i18next"),require("@formily/reactive"),require("react-router-dom"),require("@nocobase/plugin-notification-manager/client"),require("@nocobase/plugin-workflow/client"),require("@formily/react")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","react/jsx-runtime","react","antd","@ant-design/icons","antd-style","@formily/reactive-react","@emotion/css","@nocobase/utils/client","react-i18next","@formily/reactive","react-router-dom","@nocobase/plugin-notification-manager/client","@nocobase/plugin-workflow/client","@formily/react"],a):(r=typeof globalThis!="undefined"?globalThis:r||self,a(r["@nocobase/plugin-notification-in-app-message"]={},r["@nocobase/client"],r.jsxRuntime,r.react,r.antd,r["@ant-design/icons"],r["antd-style"],r["@formily/reactive-react"],r["@emotion/css"],r["@nocobase/utils"],r["react-i18next"],r["@formily/reactive"],r["react-router-dom"],r["@nocobase/plugin-notification-manager"],r["@nocobase/plugin-workflow"],r["@formily/react"]))})(this,function(r,a,t,y,o,q,j,k,C,g,ee,h,te,ne,D,H){"use strict";var Ie=Object.defineProperty,Se=Object.defineProperties;var Ae=Object.getOwnPropertyDescriptors;var Z=Object.getOwnPropertySymbols;var Fe=Object.prototype.hasOwnProperty,Le=Object.prototype.propertyIsEnumerable;var $=(r,a,t)=>a in r?Ie(r,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[a]=t,S=(r,a)=>{for(var t in a||(a={}))Fe.call(a,t)&&$(r,t,a[t]);if(Z)for(var t of Z(a))Le.call(a,t)&&$(r,t,a[t]);return r},R=(r,a)=>Se(r,Ae(a));var b=(r,a,t)=>new Promise((y,o)=>{var q=C=>{try{k(t.next(C))}catch(g){o(g)}},j=C=>{try{k(t.throw(C))}catch(g){o(g)}},k=C=>C.done?y(C.value):Promise.resolve(C.value).then(q,j);k((t=t.apply(r,a)).next())});const W="notification-in-app-message";function I(){return ee.useTranslation([W,"client"],{nsMode:"fallback"})}let G;const oe=e=>{G=e},A=()=>G,E=h.observable({value:null}),B=h.observable({value:{}}),O=h.observable({value:!1}),K=h.observable({value:0}),v=h.observable({value:"all"}),M=h.observable.computed(()=>Object.values(B.value).filter(n=>{var s;return n.userId==String((s=E.value)!=null?s:"")}).filter(n=>v.value==="read"?n.totalMsgCnt-n.unreadMsgCnt>0:v.value==="unread"?n.unreadMsgCnt>0:!0).sort((n,s)=>n.latestMsgReceiveTimestamp>s.latestMsgReceiveTimestamp?-1:1)),se=h.observable.computed(()=>M.value.length<K.value),f=h.observable({value:null}),N=e=>b(this,null,function*(){var u,m,l;const n=A();O.value=!0;const s=yield n.request({url:"myInAppChannels:list",method:"get",params:g.merge({filter:{status:v.value}},e!=null?e:{})}),c=(u=s.data)==null?void 0:u.data;Array.isArray(c)&&c.forEach(p=>{B.value[p.name]=p});const d=(l=(m=s.data)==null?void 0:m.meta)==null?void 0:l.count;d>=0&&(K.value=d),O.value=!1});h.autorun(()=>{var e;!f.value&&((e=M.value[0])!=null&&e.name)?f.value=M.value[0].name:(M.value.length===0||M.value.length>0&&!M.value.find(n=>n.name===f.value))&&(f.value=null)}),h.reaction(()=>v.value,()=>{var e;(e=M.value[0])!=null&&e.name&&(f.value=M.value[0].name)},{fireImmediately:!0});const re={name:"notificationInAppMessages",fieldNameMap:{id:"id",channelName:"channelName",userId:"userId",content:"content",status:"status",title:"title",receiveTimestamp:"receiveTimestamp",options:"options"}},F=h.observable({value:{}}),P=h.observable({value:!1}),ae=h.observable.computed(()=>Object.values(F.value).sort((e,n)=>e.receiveTimestamp>n.receiveTimestamp?-1:1)),le=e=>v.value==="read"?e.status==="read":v.value==="unread"?e.status==="unread":!0,ie=e=>{var n;return e.userId==String((n=E.value)!=null?n:"")},U=h.observable.computed(()=>f.value?ae.value.filter(n=>n.channelName===f.value&&le(n)&&ie):[]),Q=(...n)=>b(this,[...n],function*(e={limit:30}){var u,m;P.value=!0,v.value!=="all"&&(e.filter=g.merge((u=e.filter)!=null?u:{},{status:v.value}));const c=yield A().request({url:"myInAppMessages:list",method:"get",params:e}),d=(m=c==null?void 0:c.data)==null?void 0:m.data.messages;Array.isArray(d)&&d.forEach(l=>{F.value[l.id]=l}),P.value=!1}),X=e=>b(this,null,function*(){yield A().request({resource:re.name,action:"update",method:"post",params:e});const s=F.value[e.filterByTk];F.value[e.filterByTk]=S(S({},s),e.values),z()});h.autorun(()=>{f.value&&Q({filter:{channelName:f.value}})});const Y=h.observable({value:null}),z=()=>b(this,null,function*(){var s;const n=yield A().request({url:"myInAppMessages:count",method:"get",params:{filter:{status:"unread"}}});Y.value=(s=n==null?void 0:n.data)==null?void 0:s.data.count}),ce=h.observable.computed(()=>{const e=f.value;if(!e)return!1;const n=B.value[e],s=U.value;if({read:n.totalMsgCnt-n.unreadMsgCnt>s.length,unread:n.unreadMsgCnt>s.length,all:n.totalMsgCnt>s.length}[v.value]&&s.length>0)return!0}),L=h.observable({value:!1}),_=h.observable({value:null});h.reaction(()=>_.value,e=>{if(e&&["message:created","message:updated"].includes(e.type)){const{data:n}=e;F.value[n.id]=n,e.type==="message:created"&&o.notification.info({message:t.jsx("div",{style:{textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap"},children:n.title}),description:n.content.slice(0,100)+(n.content.length>100?"...":""),onClick:()=>{L.value=!0,f.value=n.channelName,o.notification.destroy()}}),N({filter:{name:n.channelName}}),z()}});const ue=()=>b(this,null,function*(){let e=0;const n=g.uid(),s=d=>b(this,null,function*(){const p=(yield A().silent().request({url:"myInAppMessages:sse",method:"get",headers:{Accept:"text/event-stream"},params:{id:d},responseType:"stream",adapter:"fetch"})).data.pipeThrough(new TextDecoderStream).getReader();for(e=0;;){const{value:x,done:V}=yield p.read();if(V)break;const i=x.split(`
11
11
 
12
- `).filter(Boolean);for(const w of i){const T=JSON.parse(w.replace(/^data:\s*/,"").trim());_.value=T}}}),c=()=>b(this,null,function*(){try{yield s(n)}catch(d){console.error("Error during stream:",d.message);const u=e<6?1e3*Math.pow(2,e):6e4;return e++,setTimeout(()=>{c()},u),{error:d}}});c()}),de=k.observer(()=>{const{t:e}=I(),n=te.useNavigate(),{token:s}=o.theme.useToken(),[c,d]=y.useState(null),u=f.value,m=P.value,l=U.value,p={read:e("Read"),unread:e("Unread")};if(!u)return null;const x=i=>{var w;if(Y({filterByTk:i.id,values:{status:"read"}}),(w=i.options)!=null&&w.url){L.value=!1;const T=i.options.url;T.startsWith("/")?n(T):window.location.href=T}},H=y.useCallback(()=>{const i={},w=l[l.length-1];w&&(i.receiveTimestamp={$lt:w.receiveTimestamp}),u&&(i.channelName=u),X({filter:i,limit:30})},[l,u]);return t.jsxs(o.ConfigProvider,{theme:{components:{Badge:{dotSize:8}}},children:[t.jsx(o.Typography.Title,{level:4,style:{marginBottom:s.marginLG},children:B.value[u].title}),l.length===0&&P.value?t.jsx(o.Spin,{style:{width:"100%",marginTop:s.marginXXL}}):l.map((i,w)=>{var T;return t.jsx(t.Fragment,{children:t.jsx(o.Card,{size:"small",bordered:!1,style:{marginBottom:s.marginMD},onMouseEnter:()=>{d(i.id)},onMouseLeave:()=>{d(null)},title:t.jsx(o.Tooltip,{title:i.title,mouseEnterDelay:.5,children:t.jsx("div",{onClick:()=>{x(i)},style:{fontWeight:i.status==="unread"?"bold":"normal",cursor:"pointer",width:"100%"},children:i.title})}),extra:(T=i.options)!=null&&T.url?t.jsx(o.Button,{type:"link",onClick:ke=>{ke.stopPropagation(),x(i)},children:e("View")}):null,children:t.jsxs(o.Descriptions,{column:1,children:[t.jsxs(o.Descriptions.Item,{label:e("Content"),children:[" ",t.jsxs(o.Tooltip,{title:i.content.length>100?i.content:"",mouseEnterDelay:.5,children:[i.content.slice(0,100)+(i.content.length>100?"...":"")," "]})]}),t.jsx(o.Descriptions.Item,{label:e("Datetime"),children:g.dayjs(i.receiveTimestamp).fromNow()}),t.jsx(o.Descriptions.Item,{label:e("Status"),children:t.jsx("div",{style:{height:s.controlHeight},children:c===i.id&&i.status==="unread"?t.jsx(o.Button,{type:"link",size:"small",style:{fontSize:s.fontSizeSM},onClick:()=>{Y({filterByTk:i.id,values:{status:"read"}})},children:e("Mark as read")}):t.jsx(o.Tag,{color:i.status==="unread"?"red":"green",children:p[i.status]})})})]},w)},i.id)})}),ce.value&&t.jsx("div",{style:{width:"100%",display:"flex",justifyContent:"center"},children:t.jsx(o.Button,{onClick:H,loading:m,children:e("Loading more")})})]})}),pe=()=>{const{token:e}=o.theme.useToken(),{t:n}=I(),s=M.value;U.value;const c=f.value,d=()=>{const l={},p=s[s.length-1];p!=null&&p.latestMsgReceiveTimestamp&&(l.latestMsgReceiveTimestamp={$lt:p.latestMsgReceiveTimestamp}),N({filter:l,limit:30})},u=se.value?t.jsx("div",{style:{textAlign:"center",marginTop:12,height:32,lineHeight:"32px"},children:t.jsx(o.Button,{loading:O.value,onClick:d,children:n("Loading more")})}):null,m=()=>{const l=[{label:n("All"),key:"all"},{label:n("Unread"),key:"unread"},{label:n("Read"),key:"read"}];return t.jsx(o.ConfigProvider,{theme:{components:{Tabs:{horizontalItemMargin:"20px"}}},children:t.jsx(o.Tabs,{activeKey:v.value,items:l,onChange:p=>{v.value=p,N({})}})})};return t.jsxs(o.Layout,{style:{height:"100%"},children:[t.jsxs(o.Layout.Sider,{width:350,style:{height:"100%",overflowY:"auto",background:e.colorBgContainer,padding:"0 15px",border:"none"},children:[t.jsx(m,{}),t.jsx(o.List,{itemLayout:"horizontal",dataSource:s,loadMore:u,style:{paddingBottom:"20px"},loading:s.length===0&&O.value,renderItem:l=>{const p=c===l.name?e.colorPrimaryText:e.colorText,x=c===l.name?e.colorPrimaryText:e.colorTextTertiary;return t.jsxs(o.List.Item,{className:C.css`
12
+ `).filter(Boolean);for(const w of i){const T=JSON.parse(w.replace(/^data:\s*/,"").trim());_.value=T}}}),c=()=>b(this,null,function*(){try{yield s(n)}catch(d){console.error("Error during stream:",d.message);const u=e<6?1e3*Math.pow(2,e):6e4;return e++,setTimeout(()=>{c()},u),{error:d}}});c()}),de=k.observer(()=>{const{t:e}=I(),n=te.useNavigate(),{token:s}=o.theme.useToken(),[c,d]=y.useState(null),u=f.value,m=P.value,l=U.value,p={read:e("Read"),unread:e("Unread")};if(!u)return null;const x=i=>{var w;if(X({filterByTk:i.id,values:{status:"read"}}),(w=i.options)!=null&&w.url){L.value=!1;const T=i.options.url;T.startsWith("/")?n(T):window.location.href=T}},V=y.useCallback(()=>{const i={},w=l[l.length-1];w&&(i.receiveTimestamp={$lt:w.receiveTimestamp}),u&&(i.channelName=u),Q({filter:i,limit:30})},[l,u]);return t.jsxs(o.ConfigProvider,{theme:{components:{Badge:{dotSize:8}}},children:[t.jsx(o.Typography.Title,{level:4,style:{marginBottom:s.marginLG},children:B.value[u].title}),l.length===0&&P.value?t.jsx(o.Spin,{style:{width:"100%",marginTop:s.marginXXL}}):l.map((i,w)=>{var T;return t.jsx(t.Fragment,{children:t.jsx(o.Card,{size:"small",bordered:!1,style:{marginBottom:s.marginMD},onMouseEnter:()=>{d(i.id)},onMouseLeave:()=>{d(null)},title:t.jsx(o.Tooltip,{title:i.title,mouseEnterDelay:.5,children:t.jsx("div",{onClick:()=>{x(i)},style:{fontWeight:i.status==="unread"?"bold":"normal",cursor:"pointer",width:"100%"},children:i.title})}),extra:(T=i.options)!=null&&T.url?t.jsx(o.Button,{type:"link",onClick:ke=>{ke.stopPropagation(),x(i)},children:e("View")}):null,children:t.jsxs(o.Descriptions,{column:1,children:[t.jsxs(o.Descriptions.Item,{label:e("Content"),children:[" ",t.jsxs(o.Tooltip,{title:i.content.length>100?i.content:"",mouseEnterDelay:.5,children:[i.content.slice(0,100)+(i.content.length>100?"...":"")," "]})]}),t.jsx(o.Descriptions.Item,{label:e("Datetime"),children:g.dayjs(i.receiveTimestamp).fromNow()}),t.jsx(o.Descriptions.Item,{label:e("Status"),children:t.jsx("div",{style:{height:s.controlHeight},children:c===i.id&&i.status==="unread"?t.jsx(o.Button,{type:"link",size:"small",style:{fontSize:s.fontSizeSM},onClick:()=>{X({filterByTk:i.id,values:{status:"read"}})},children:e("Mark as read")}):t.jsx(o.Tag,{color:i.status==="unread"?"red":"green",children:p[i.status]})})})]},w)},i.id)})}),ce.value&&t.jsx("div",{style:{width:"100%",display:"flex",justifyContent:"center"},children:t.jsx(o.Button,{onClick:V,loading:m,children:e("Loading more")})})]})}),pe=()=>{const{token:e}=o.theme.useToken(),{t:n}=I(),s=M.value;U.value;const c=f.value,d=()=>{const l={},p=s[s.length-1];p!=null&&p.latestMsgReceiveTimestamp&&(l.latestMsgReceiveTimestamp={$lt:p.latestMsgReceiveTimestamp}),N({filter:l,limit:30})},u=se.value?t.jsx("div",{style:{textAlign:"center",marginTop:12,height:32,lineHeight:"32px"},children:t.jsx(o.Button,{loading:O.value,onClick:d,children:n("Loading more")})}):null,m=()=>{const l=[{label:n("All"),key:"all"},{label:n("Unread"),key:"unread"},{label:n("Read"),key:"read"}];return t.jsx(o.ConfigProvider,{theme:{components:{Tabs:{horizontalItemMargin:"20px"}}},children:t.jsx(o.Tabs,{activeKey:v.value,items:l,onChange:p=>{v.value=p,N({})}})})};return t.jsxs(o.Layout,{style:{height:"100%"},children:[t.jsxs(o.Layout.Sider,{width:350,style:{height:"100%",overflowY:"auto",background:e.colorBgContainer,padding:"0 15px",border:"none"},children:[t.jsx(m,{}),t.jsx(o.List,{itemLayout:"horizontal",dataSource:s,loadMore:u,style:{paddingBottom:"20px"},loading:s.length===0&&O.value,renderItem:l=>{const p=c===l.name?e.colorPrimaryText:e.colorText,x=c===l.name?e.colorPrimaryText:e.colorTextTertiary;return t.jsxs(o.List.Item,{className:C.css`
13
13
  &:hover {
14
14
  background-color: ${e.colorBgTextHover}};
15
15
  }
16
- `,style:R(S({padding:"10px 10px",color:p},c===l.name?{backgroundColor:e.colorPrimaryBg}:{}),{cursor:"pointer",marginTop:"10px",border:"none",borderRadius:"10px",display:"flex",flexDirection:"column",justifyContent:"space-between"}),onClick:()=>{f.value=l.name},children:[t.jsxs(o.Flex,{justify:"space-between",style:{width:"100%"},children:[t.jsx("div",{style:{width:"150px",textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",fontWeight:"bold"},children:l.title}),t.jsx("div",{style:{width:"120px",fontWeight:400,textAlign:"right",fontFamily:"monospace",color:x},children:g.dayjs(l.latestMsgReceiveTimestamp).fromNow()})]}),t.jsxs(o.Flex,{justify:"space-between",style:{width:"100%",marginTop:e.margin},children:[t.jsxs("div",{style:{width:"80%",textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",color:x},children:[" ",l.latestMsgTitle]}),v.value!=="read"?t.jsx(o.Badge,{style:{border:"none"},count:l.unreadMsgCnt}):null]})]})}})]}),t.jsx(o.Layout.Content,{style:{padding:e.paddingLG,height:"100%",overflowY:"auto"},children:c?t.jsx(de,{}):null})]})},he=k.observer(pe),fe=j.createStyles(({token:e})=>({button:{color:e.colorTextHeaderMenu+" !important"}})),me=e=>{var p,x;const{t:n}=I(),{styles:s}=fe(),d=(x=(p=a.useCurrentUserContext().data)==null?void 0:p.data)==null?void 0:x.id;y.useEffect(()=>{V()},[]),y.useEffect(()=>{E.value=d!=null?d:null},[d]);const u=y.useCallback(()=>{L.value=!0,N({})},[]);y.useEffect(()=>{ue()},[]);const m=t.jsx("div",{style:{padding:"0"},children:n("Message")}),l=t.jsx("div",{style:{marginLeft:"15px"},children:t.jsx(q.CloseOutlined,{})});return t.jsxs(o.ConfigProvider,{theme:{components:{Drawer:{paddingLG:0}}},children:[t.jsx(o.Tooltip,{title:n("Message"),children:t.jsx(o.Button,{className:s.button,title:"Apps",icon:t.jsx(a.Icon,{type:"MailOutlined"}),onClick:u})}),z.value&&t.jsx(o.Badge,{count:z.value,size:"small",offset:[-18,-16]}),t.jsx(o.Drawer,{title:m,open:L.value,closeIcon:l,width:900,onClose:()=>{L.value=!1},children:t.jsx(he,{})})]})},ge=k.observer(me),ve=e=>t.jsx(a.PinnedPluginListProvider,{items:{inbox:{order:301,component:"Inbox",pin:!0,snippet:"*"}},children:t.jsx(a.SchemaComponentOptions,{components:{Inbox:ge},children:e.children})});function ye(e){return e.isForeignKey?e.target==="users":e.collectionName==="users"&&e.name==="id"}function be(e){return typeof e.value==="object"&&e.value?t.jsx(Ce,S({},e)):t.jsx(xe,S({},e))}function xe({value:e,onChange:n}){const s=D.useWorkflowVariableOptions({types:[ye]});return t.jsx(a.Variable.Input,{scope:s,value:e,onChange:n,children:t.jsx(a.RemoteSelect,{fieldNames:{label:"nickname",value:"id"},service:{resource:"users"},manual:!1,value:e,onChange:n})})}function Ce(e){const n=W.useField(),s=a.useCollectionFilterOptions("users"),{token:c}=a.useToken();return t.jsx("div",{style:{border:`1px dashed ${c.colorBorder}`,padding:c.paddingSM},children:t.jsx(a.SchemaComponent,{basePath:n.address,schema:{type:"void",properties:{filter:{type:"object","x-component":"Filter","x-component-props":{options:s,dynamicComponent:D.FilterDynamicComponent}}}}})})}function Me(){const e=D.useWorkflowExecuted(),[n,s]=y.useState(!1),{t:c}=I(),d=W.useField(),{receivers:u}=d.form.values,m=y.useCallback(()=>{u.push(""),s(!1)},[u]),l=y.useCallback(()=>{u.push({filter:{}}),s(!1)},[u]),p=t.jsx(o.Button,{icon:t.jsx(q.PlusOutlined,{}),type:"dashed",block:!0,disabled:e,className:"ant-formily-array-base-addition",children:c("Add user")});return e?p:t.jsx(o.Popover,{open:n,onOpenChange:s,content:t.jsxs(o.Space,{direction:"vertical",size:"small",children:[t.jsx(o.Button,{type:"text",onClick:m,children:c("Select users")}),t.jsx(o.Button,{type:"text",onClick:l,children:c("Query users")})]}),children:p})}const we=({variableOptions:e})=>{const{t:n}=I();return t.jsx(a.SchemaComponent,{scope:{t:n},components:{UsersSelect:be,UsersAddition:Me},schema:{type:"void",properties:{receivers:{type:"array",title:'{{t("Receivers")}}',"x-decorator":"FormItem","x-component":"ArrayItems",items:{type:"void","x-component":"Space","x-component-props":{className:a.css`
16
+ `,style:R(S({padding:"10px 10px",color:p},c===l.name?{backgroundColor:e.colorPrimaryBg}:{}),{cursor:"pointer",marginTop:"10px",border:"none",borderRadius:"10px",display:"flex",flexDirection:"column",justifyContent:"space-between"}),onClick:()=>{f.value=l.name},children:[t.jsxs(o.Flex,{justify:"space-between",style:{width:"100%"},children:[t.jsx("div",{style:{width:"150px",textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",fontWeight:"bold"},children:l.title}),t.jsx("div",{style:{width:"120px",fontWeight:400,textAlign:"right",fontFamily:"monospace",color:x},children:g.dayjs(l.latestMsgReceiveTimestamp).fromNow()})]}),t.jsxs(o.Flex,{justify:"space-between",style:{width:"100%",marginTop:e.margin},children:[t.jsxs("div",{style:{width:"80%",textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",color:x},children:[" ",l.latestMsgTitle]}),v.value!=="read"?t.jsx(o.Badge,{style:{border:"none"},count:l.unreadMsgCnt}):null]})]})}})]}),t.jsx(o.Layout.Content,{style:{padding:e.paddingLG,height:"100%",overflowY:"auto"},children:c?t.jsx(de,{}):null})]})},he=k.observer(pe),fe=j.createStyles(({token:e})=>({button:{color:e.colorTextHeaderMenu+" !important"}})),me=e=>{var p,x;const{t:n}=I(),{styles:s}=fe(),d=(x=(p=a.useCurrentUserContext().data)==null?void 0:p.data)==null?void 0:x.id;y.useEffect(()=>{z()},[]),y.useEffect(()=>{E.value=d!=null?d:null},[d]);const u=y.useCallback(()=>{L.value=!0,N({})},[]);y.useEffect(()=>{ue()},[]);const m=t.jsx("div",{style:{padding:"0"},children:n("Message")}),l=t.jsx("div",{style:{marginLeft:"15px"},children:t.jsx(q.CloseOutlined,{})});return t.jsxs(o.ConfigProvider,{theme:{components:{Drawer:{paddingLG:0}}},children:[t.jsx(o.Tooltip,{title:n("Message"),children:t.jsx(o.Badge,{count:Y.value,size:"small",offset:[-12,14],children:t.jsx(o.Button,{className:s.button,title:"Apps",icon:t.jsx(a.Icon,{type:"MailOutlined"}),onClick:u})})}),t.jsx(o.Drawer,{title:m,open:L.value,closeIcon:l,width:900,onClose:()=>{L.value=!1},children:t.jsx(he,{})})]})},ge=k.observer(me),ve=e=>t.jsx(a.PinnedPluginListProvider,{items:{inbox:{order:301,component:"Inbox",pin:!0,snippet:"*"}},children:t.jsx(a.SchemaComponentOptions,{components:{Inbox:ge},children:e.children})});function ye(e){return e.isForeignKey?e.target==="users":e.collectionName==="users"&&e.name==="id"}function be(e){return typeof e.value==="object"&&e.value?t.jsx(Ce,S({},e)):t.jsx(xe,S({},e))}function xe({value:e,onChange:n}){const s=D.useWorkflowVariableOptions({types:[ye]});return t.jsx(a.Variable.Input,{scope:s,value:e,onChange:n,children:t.jsx(a.RemoteSelect,{fieldNames:{label:"nickname",value:"id"},service:{resource:"users"},manual:!1,value:e,onChange:n})})}function Ce(e){const n=H.useField(),s=a.useCollectionFilterOptions("users"),{token:c}=a.useToken();return t.jsx("div",{style:{border:`1px dashed ${c.colorBorder}`,padding:c.paddingSM},children:t.jsx(a.SchemaComponent,{basePath:n.address,schema:{type:"void",properties:{filter:{type:"object","x-component":"Filter","x-component-props":{options:s,dynamicComponent:D.FilterDynamicComponent}}}}})})}function Me(){const e=D.useWorkflowExecuted(),[n,s]=y.useState(!1),{t:c}=I(),d=H.useField(),{receivers:u}=d.form.values,m=y.useCallback(()=>{u.push(""),s(!1)},[u]),l=y.useCallback(()=>{u.push({filter:{}}),s(!1)},[u]),p=t.jsx(o.Button,{icon:t.jsx(q.PlusOutlined,{}),type:"dashed",block:!0,disabled:e,className:"ant-formily-array-base-addition",children:c("Add user")});return e?p:t.jsx(o.Popover,{open:n,onOpenChange:s,content:t.jsxs(o.Space,{direction:"vertical",size:"small",children:[t.jsx(o.Button,{type:"text",onClick:m,children:c("Select users")}),t.jsx(o.Button,{type:"text",onClick:l,children:c("Query users")})]}),children:p})}const we=({variableOptions:e})=>{const{t:n}=I();return t.jsx(a.SchemaComponent,{scope:{t:n},components:{UsersSelect:be,UsersAddition:Me},schema:{type:"void",properties:{receivers:{type:"array",title:'{{t("Receivers")}}',"x-decorator":"FormItem","x-component":"ArrayItems",items:{type:"void","x-component":"Space","x-component-props":{className:a.css`
17
17
  width: 100%;
18
18
  &.ant-space.ant-space-horizontal {
19
19
  flex-wrap: nowrap;
@@ -21,4 +21,4 @@
21
21
  > .ant-space-item:nth-child(2) {
22
22
  flex-grow: 1;
23
23
  }
24
- `},properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},input:{type:"string","x-decorator":"FormItem","x-component":"UsersSelect"},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}},required:!0,properties:{add:{type:"void",title:'{{t("Add receiver")}}',"x-component":"UsersAddition"}}},title:{type:"string",required:!0,title:'{{t("Message title")}}',"x-decorator":"FormItem","x-component":"Variable.TextArea","x-component-props":{scope:e,useTypedConstant:["string"]}},content:{type:"string",required:!0,title:'{{t("Message content")}}',"x-decorator":"FormItem","x-component":"Variable.RawTextArea","x-component-props":{scope:e,placeholder:"Hi,",autoSize:{minRows:10}}},options:{type:"object",properties:{url:{type:"string",required:!1,title:'{{t("Detail URL")}}',"x-decorator":"FormItem","x-component":"Variable.TextArea","x-component-props":{scope:e,useTypedConstant:["string"]},description:g.tval("Support two types of links in nocobase: internal links and external links. If using an internal link, the link starts with '/', for example, '/admin/page'. If using an external link, the link starts with 'http', for example, 'https://example.com'.")}}}}}})},Te=({variableOptions:e})=>{const{t:n}=I();return t.jsx(a.SchemaComponent,{scope:{t:n},schema:{type:"void",properties:{title:{type:"string",required:!0,title:'{{t("Message title")}}',"x-decorator":"FormItem","x-component":"Variable.TextArea","x-component-props":{scope:e,useTypedConstant:["string"]}},content:{type:"string",required:!0,title:'{{t("Message content")}}',"x-decorator":"FormItem","x-component":"Variable.RawTextArea","x-component-props":{scope:e,placeholder:"Hi,",autoSize:{minRows:10}}},options:{type:"object",properties:{url:{type:"string",required:!1,title:'{{t("Detail URL")}}',"x-decorator":"FormItem","x-component":"Variable.TextArea","x-component-props":{scope:e,useTypedConstant:["string"]},description:g.tval("Support two types of links in nocobase: internal links and external links. If using an internal link, the link starts with '/', for example, '/admin/page'. If using an external link, the link starts with 'http', for example, 'https://example.com'.")}}}}}})};class J extends a.Plugin{afterAdd(){return b(this,null,function*(){})}beforeLoad(){return b(this,null,function*(){})}load(){return b(this,null,function*(){oe(this.app.apiClient),this.app.use(ve),this.pm.get(ne).registerChannelType({title:g.tval("In-app message",{ns:G}),type:"in-app-message",components:{ChannelConfigForm:()=>null,MessageConfigForm:we,ContentConfigForm:Te},meta:{editable:!0,creatable:!0,deletable:!0}})})}}r.PluginNotificationInAppClient=J,r.default=J,Object.defineProperties(r,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
24
+ `},properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},input:{type:"string","x-decorator":"FormItem","x-component":"UsersSelect"},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}},required:!0,properties:{add:{type:"void",title:'{{t("Add receiver")}}',"x-component":"UsersAddition"}}},title:{type:"string",required:!0,title:'{{t("Message title")}}',"x-decorator":"FormItem","x-component":"Variable.TextArea","x-component-props":{scope:e,useTypedConstant:["string"]}},content:{type:"string",required:!0,title:'{{t("Message content")}}',"x-decorator":"FormItem","x-component":"Variable.RawTextArea","x-component-props":{scope:e,placeholder:"Hi,",autoSize:{minRows:10}}},options:{type:"object",properties:{url:{type:"string",required:!1,title:'{{t("Detail URL")}}',"x-decorator":"FormItem","x-component":"Variable.TextArea","x-component-props":{scope:e,useTypedConstant:["string"]},description:g.tval('Support two types of links: internal links and external links. If using an internal link, the link starts with"/", for example, "/admin". If using an external link, the link starts with "http", for example, "https://example.com".')}}}}}})},Te=({variableOptions:e})=>{const{t:n}=I();return t.jsx(a.SchemaComponent,{scope:{t:n},schema:{type:"void",properties:{title:{type:"string",required:!0,title:'{{t("Message title")}}',"x-decorator":"FormItem","x-component":"Variable.TextArea","x-component-props":{scope:e,useTypedConstant:["string"]}},content:{type:"string",required:!0,title:'{{t("Message content")}}',"x-decorator":"FormItem","x-component":"Variable.RawTextArea","x-component-props":{scope:e,placeholder:"Hi,",autoSize:{minRows:10}}},options:{type:"object",properties:{url:{type:"string",required:!1,title:'{{t("Detail URL")}}',"x-decorator":"FormItem","x-component":"Variable.TextArea","x-component-props":{scope:e,useTypedConstant:["string"]},description:g.tval('Support two types of links: internal links and external links. If using an internal link, the link starts with"/", for example, "/admin". If using an external link, the link starts with "http", for example, "https://example.com".')}}}}}})};class J extends a.Plugin{afterAdd(){return b(this,null,function*(){})}beforeLoad(){return b(this,null,function*(){})}load(){return b(this,null,function*(){oe(this.app.apiClient),this.app.use(ve),this.pm.get(ne).registerChannelType({title:g.tval("In-app message",{ns:W}),type:"in-app-message",components:{ChannelConfigForm:()=>null,MessageConfigForm:we,ContentConfigForm:Te},meta:{editable:!0,creatable:!0,deletable:!0}})})}}r.PluginNotificationInAppClient=J,r.default=J,Object.defineProperties(r,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -9,21 +9,21 @@
9
9
 
10
10
  module.exports = {
11
11
  "react": "18.2.0",
12
- "@nocobase/client": "1.4.0-alpha",
13
- "@nocobase/plugin-notification-manager": "1.4.0-alpha",
14
- "@nocobase/utils": "1.4.0-alpha",
12
+ "@nocobase/client": "1.4.0-alpha.20241031134640",
13
+ "@nocobase/plugin-notification-manager": "1.4.0-alpha.20241031134640",
14
+ "@nocobase/utils": "1.4.0-alpha.20241031134640",
15
15
  "react-i18next": "11.18.6",
16
- "@nocobase/server": "1.4.0-alpha",
16
+ "@nocobase/server": "1.4.0-alpha.20241031134640",
17
17
  "sequelize": "6.35.2",
18
- "@nocobase/database": "1.4.0-alpha",
18
+ "@nocobase/database": "1.4.0-alpha.20241031134640",
19
19
  "antd": "5.12.8",
20
20
  "@ant-design/icons": "5.2.6",
21
- "antd-style": "3.4.5",
21
+ "antd-style": "3.7.1",
22
22
  "@formily/reactive-react": "2.3.0",
23
23
  "@emotion/css": "11.13.0",
24
24
  "react-router-dom": "6.21.0",
25
25
  "@formily/react": "2.3.0",
26
26
  "@formily/core": "2.3.0",
27
- "@nocobase/plugin-workflow": "1.4.0-alpha",
27
+ "@nocobase/plugin-workflow": "1.4.0-alpha.20241031134640",
28
28
  "@formily/reactive": "2.3.0"
29
29
  };
@@ -17,6 +17,6 @@
17
17
  "Message content": "Message content",
18
18
  "Inapp Message": "Inapp Message",
19
19
  "Detail URL": "Detail URL",
20
- "Support two types of links in nocobase: internal links and external links. If using an internal link, the link starts with '/', for example, '/admin/page'. If using an external link, the link starts with 'http', for example, 'https://example.com'.": "Support two types of links in nocobase: internal links and external links. If using an internal link, the link starts with '/', for example, '/admin/page'. If using an external link, the link starts with 'http', for example, 'https://example.com'.",
20
+ "Support two types of links: internal links and external links. If using an internal link, the link starts with\"/\", for example, \"/admin\". If using an external link, the link starts with \"http\", for example, \"https://example.com\".": "Support two types of links: internal links and external links. If using an internal link, the link starts with \"/\", for example, \"/admin\". If using an external link, the link starts with \"http\", for example, \"https://example.com\".",
21
21
  "Mark as read": "Mark as read"
22
22
  }
@@ -16,6 +16,6 @@
16
16
  "Message content": "消息内容",
17
17
  "Inapp Message": "站内信",
18
18
  "Detail URL": "详情链接",
19
- "Support two types of links in nocobase: internal links and external links. If using an internal link, the link starts with '/', for example, '/admin/page'. If using an external link, the link starts with 'http', for example, 'https://example.com'.": "nocobase支持两种链接类型:内部链接和外部链接。如果使用内部链接,链接以'/'开头,例如,'/admin/page'。如果使用外部链接,链接以'http'开头,例如,'https://example.com'。",
19
+ "Support two types of links: internal links and external links. If using an internal link, the link starts with\"/\", for example, \"/admin\". If using an external link, the link starts with \"http\", for example, \"https://example.com\".": "支持两种链接类型:内部链接和外部链接。如果使用内部链接,链接以“/”开头,例如“/admin”。如果使用外部链接,链接以“http”开头,例如“https://example.com”。",
20
20
  "Mark as read": "标记为已读"
21
21
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/plugin-notification-in-app-message",
3
- "version": "1.4.0-alpha",
3
+ "version": "1.4.0-alpha.20241031134640",
4
4
  "displayName": "Notification: In-app message",
5
5
  "displayName.zh-CN": "通知:站内信",
6
6
  "description": "It supports users in receiving real-time message notifications within the NocoBase application.",
@@ -21,5 +21,5 @@
21
21
  "@nocobase/test": "1.x",
22
22
  "react-router-dom": "^6.x"
23
23
  },
24
- "gitHead": "aa109cf343a37673bbe7a83d6c7dae66c0b578b3"
24
+ "gitHead": "78cd6d9010f81b1c4d13d7673f6adf2eb0e598be"
25
25
  }