dinocollab-shared 1.2.40 → 1.2.42
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/dist/auth/profile.js +1 -1
- package/dist/auth/profile.js.map +1 -1
- package/dist/auth/service.js.map +1 -1
- package/dist/auth/widget.js.map +1 -1
- package/dist/notification/notify-list.js +1 -1
- package/dist/notification/notify-list.js.map +1 -1
- package/dist/notification/widget.js +1 -1
- package/dist/notification/widget.js.map +1 -1
- package/dist/types/auth/index.d.ts +1 -1
- package/dist/types/auth/index.d.ts.map +1 -1
- package/dist/types/auth/profile.d.ts +3 -3
- package/dist/types/auth/profile.d.ts.map +1 -1
- package/dist/types/auth/service.d.ts +1 -0
- package/dist/types/auth/service.d.ts.map +1 -1
- package/dist/types/auth/types.d.ts +2 -2
- package/dist/types/auth/types.d.ts.map +1 -1
- package/dist/types/auth/widget.d.ts +2 -2
- package/dist/types/auth/widget.d.ts.map +1 -1
- package/dist/types/notification/notify-list.d.ts +11 -2
- package/dist/types/notification/notify-list.d.ts.map +1 -1
- package/dist/types/notification/widget.d.ts +2 -0
- package/dist/types/notification/widget.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/auth/profile.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{inherits as t,createClass as e,objectSpread2 as o,classCallCheck as r,callSuper as l,defineProperty as n}from"../_virtual/_rollupPluginBabelHelpers.js";import{jsxs as i,jsx as a}from"react/jsx-runtime";import{Fragment as c,Component as s}from"react";import{Fade as u,Tooltip as d,IconButton as p,Avatar as h,Menu as m,Typography as f,Divider as v,MenuItem as g,Box as x,ListItemIcon as b,colors as C}from"@mui/material";import{getAvatarProps as k}from"../layout-global/helpers.js";var y={root:"Profile-root",title:"Profile-title",item:"Profile-item"},M=function(t,e){return"".concat("",".").concat(y[t]).concat("")},I=function(){function C(t){var e;return r(this,C),e=l(this,C,[t]),n(e,"toggle",function(){return e.setState({isOpen:!e.state.isOpen})}),n(e,"handleClick",function(t){e.setState({element:t.currentTarget})}),n(e,"handleMenuItemClick",function(t,o){o.onClick&&o.onClick(t),e.setState({element:null})}),n(e,"handleClose",function(){e.setState({element:null})}),e.state={isOpen:!1,element:null},e}return t(C,s),e(C,[{key:"render",value:function(){var t,e=this,r=this.props.profile,l=(null==r?void 0:r.UserName)||"Guest";return i(c,{children:[a(u,{in:!0,children:a(d,{title:"Account settings",children:a(p,{onClick:this.handleClick,size:"small","aria-controls":this.state.element?"account-menu":void 0,"aria-haspopup":"true","aria-expanded":this.state.element?"true":void 0,sx:{flex:0},children:a(h,o({src:null!==(t=null==r?void 0:r.AvatarUrl)&&void 0!==t?t:""},k(l)))})})}),i(m,{anchorEl:this.state.element,id:"account-menu",disableScrollLock:!0,open:!!this.state.element,onClose:this.handleClose,onClick:this.handleClose,MenuListProps:{component:"div"},slotProps:{paper:P(this.props.theme)},transformOrigin:{horizontal:"right",vertical:"top"},anchorOrigin:{horizontal:"right",vertical:"bottom"},children:[i(f,{variant:"subtitle1",noWrap:!0,className:y.title,onClick:function(t){return t.stopPropagation()},children:["Hello, ",l]}),a(v,{variant:"middle",sx:{mb:1}}),this.props.menuConfigs.map(function(t,r){return a(g,{children:i(x,o(o(o({className:y.item,onClick:function(o){return e.handleMenuItemClick(o,t)}},t.href?{component:"a",href:t.href}:{}),t.buttonProps),{},{children:[a(b,{children:t.icon}),t.title]}))},r)})]})]})}}])}(),P=function(){var t="light"===(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"dark"),e=t?"#fff":"#323234",o=t?"#000":"#fff",r=t?C.blue[600]:"#e78a3f",l=t?C.grey[200]:C.grey[700];return{elevation:0,sx:n(n(n(n(n(n(n({"--color-background":e,"--color-text":o,"--color-text-secondary":r,"--color-divider":l,minWidth:"
|
|
1
|
+
import{inherits as t,createClass as e,objectSpread2 as o,classCallCheck as r,callSuper as l,defineProperty as n}from"../_virtual/_rollupPluginBabelHelpers.js";import{jsxs as i,jsx as a}from"react/jsx-runtime";import{Fragment as c,Component as s}from"react";import{Fade as u,Tooltip as d,IconButton as p,Avatar as h,Menu as m,Typography as f,Divider as v,MenuItem as g,Box as x,ListItemIcon as b,colors as C}from"@mui/material";import{getAvatarProps as k}from"../layout-global/helpers.js";var y={root:"Profile-root",title:"Profile-title",item:"Profile-item"},M=function(t,e){return"".concat("",".").concat(y[t]).concat("")},I=function(){function C(t){var e;return r(this,C),e=l(this,C,[t]),n(e,"toggle",function(){return e.setState({isOpen:!e.state.isOpen})}),n(e,"handleClick",function(t){e.setState({element:t.currentTarget})}),n(e,"handleMenuItemClick",function(t,o){o.onClick&&o.onClick(t),e.setState({element:null})}),n(e,"handleClose",function(){e.setState({element:null})}),e.state={isOpen:!1,element:null},e}return t(C,s),e(C,[{key:"render",value:function(){var t,e=this,r=this.props.profile,l=(null==r?void 0:r.UserName)||"Guest";return i(c,{children:[a(u,{in:!0,children:a(d,{title:"Account settings",children:a(p,{onClick:this.handleClick,size:"small","aria-controls":this.state.element?"account-menu":void 0,"aria-haspopup":"true","aria-expanded":this.state.element?"true":void 0,sx:{flex:0},children:a(h,o({src:null!==(t=null==r?void 0:r.AvatarUrl)&&void 0!==t?t:""},k(l)))})})}),i(m,{anchorEl:this.state.element,id:"account-menu",disableScrollLock:!0,open:!!this.state.element,onClose:this.handleClose,onClick:this.handleClose,MenuListProps:{component:"div"},slotProps:{paper:P(this.props.theme)},transformOrigin:{horizontal:"right",vertical:"top"},anchorOrigin:{horizontal:"right",vertical:"bottom"},children:[i(f,{variant:"subtitle1",noWrap:!0,className:y.title,onClick:function(t){return t.stopPropagation()},children:["Hello, ",l]}),a(v,{variant:"middle",sx:{mb:1}}),this.props.menuConfigs.map(function(t,r){return a(g,{children:i(x,o(o(o({className:y.item,onClick:function(o){return e.handleMenuItemClick(o,t)}},t.href?{component:"a",href:t.href}:{}),t.buttonProps),{},{children:[a(b,{children:t.icon}),t.title]}))},r)})]})]})}}])}(),P=function(){var t="light"===(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"dark"),e=t?"#fff":"#323234",o=t?"#000":"#fff",r=t?C.blue[600]:"#e78a3f",l=t?C.grey[200]:C.grey[700];return{elevation:0,sx:n(n(n(n(n(n(n({"--color-background":e,"--color-text":o,"--color-text-secondary":r,"--color-divider":l,minWidth:"220px",overflow:"visible",filter:"drop-shadow(0px 2px 8px rgba(0,0,0,0.32))",mt:1.5,bgcolor:"var(--color-background)",color:"var(--color-text)"},M("title"),{marginTop:"-8px",padding:"10px 16px",fontWeight:"600",color:"var(--color-text)"}),M("item"),{display:"flex",alignItems:"center",gap:"8px",color:"currentColor",textDecoration:"none",padding:"6px 16px",flex:1}),".MuiAvatar-root",{width:32,height:32,ml:-.5,mr:1,bgcolor:"var(--color-avatar-bg)",color:"var(--color-avatar-text)"}),".MuiMenuItem-root",{padding:0,transition:"all 0.3s",color:"var(--color-text)",".MuiSvgIcon-root":{transition:"all 0.2s",transform:"translateX(0px) scale(1)"},"&:hover":{color:"var(--color-text-secondary)",backgroundColor:"var(--color-divider)",".MuiSvgIcon-root":{color:"var(--color-text-secondary)",transform:"translateX(4px) scale(1.2)"}}}),".MuiListItemIcon-root",{color:"var(--color-text)"}),".MuiDivider-root",{borderColor:"var(--color-divider)"}),"&:before",{content:'""',display:"block",position:"absolute",top:0,right:20,width:10,height:10,bgcolor:"var(--color-background)",transform:"translateY(-50%) rotate(45deg)",zIndex:0})}};export{I as Profile,I as default,y as profileClasses};
|
|
2
2
|
//# sourceMappingURL=profile.js.map
|
package/dist/auth/profile.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile.js","sources":["../../src/auth/profile.tsx"],"sourcesContent":["import { Component, Fragment } from 'react'\r\nimport type { PropsWithChildren } from 'react'\r\nimport { Box, MenuItem, Divider, IconButton, Tooltip, colors } from '@mui/material'\r\nimport { Avatar, Fade, ListItemIcon, Menu, PaperProps, Typography } from '@mui/material'\r\nimport { getAvatarProps } from '../layout-global/helpers'\r\nimport type { IIMenuConfigs, IMenuConfig, IProfile } from './types'\r\n\r\nexport const profileClasses = {\r\n root: 'Profile-root',\r\n title: 'Profile-title',\r\n item: 'Profile-item'\r\n}\r\n\r\nconst getClasses = (key: keyof typeof profileClasses, options?: { prefix?: string; suffix?: string }) => {\r\n return `${options?.prefix || ''}.${profileClasses[key]}${options?.suffix || ''}`\r\n}\r\n\r\nexport interface IAvatarButtonProps extends PropsWithChildren {\r\n profile: IProfile | null\r\n menuConfigs: IIMenuConfigs\r\n theme?: 'dark' | 'light'\r\n}\r\n\r\nexport interface IAvatarButtonState {\r\n isOpen: boolean\r\n element: HTMLElement | null\r\n}\r\n\r\nexport class Profile extends Component<IAvatarButtonProps, IAvatarButtonState> {\r\n constructor(props: IAvatarButtonProps) {\r\n super(props)\r\n this.state = {\r\n isOpen: false,\r\n element: null\r\n }\r\n }\r\n\r\n toggle = () => this.setState({ isOpen: !this.state.isOpen })\r\n\r\n handleClick = (event: React.MouseEvent<HTMLElement>) => {\r\n this.setState({ element: event.currentTarget })\r\n }\r\n\r\n handleMenuItemClick = (event: React.MouseEvent<HTMLAnchorElement | HTMLDivElement, MouseEvent>, menuConfig: IMenuConfig) => {\r\n if (menuConfig.onClick) {\r\n menuConfig.onClick(event)\r\n }\r\n this.setState({ element: null })\r\n }\r\n\r\n handleClose = () => {\r\n this.setState({ element: null })\r\n }\r\n\r\n render() {\r\n const { profile } = this.props\r\n const userName = profile?.UserName || 'Guest'\r\n return (\r\n <Fragment>\r\n <Fade in>\r\n <Tooltip title='Account settings'>\r\n <IconButton\r\n onClick={this.handleClick}\r\n size='small'\r\n aria-controls={this.state.element ? 'account-menu' : undefined}\r\n aria-haspopup='true'\r\n aria-expanded={this.state.element ? 'true' : undefined}\r\n sx={{ flex: 0 }}\r\n >\r\n <Avatar src={profile?.AvatarUrl ?? ''} {...getAvatarProps(userName)} />\r\n </IconButton>\r\n </Tooltip>\r\n </Fade>\r\n <Menu\r\n anchorEl={this.state.element}\r\n id='account-menu'\r\n disableScrollLock\r\n open={!!this.state.element}\r\n onClose={this.handleClose}\r\n onClick={this.handleClose}\r\n MenuListProps={{ component: 'div' }}\r\n slotProps={{ paper: getStylePaper(this.props.theme) }}\r\n transformOrigin={{ horizontal: 'right', vertical: 'top' }}\r\n anchorOrigin={{ horizontal: 'right', vertical: 'bottom' }}\r\n >\r\n <Typography\r\n variant='subtitle1'\r\n noWrap\r\n className={profileClasses.title}\r\n onClick={(e: React.MouseEvent<HTMLDivElement, MouseEvent>) => e.stopPropagation()}\r\n >\r\n Hello, {userName}\r\n </Typography>\r\n <Divider variant='middle' sx={{ mb: 1 }} />\r\n {this.props.menuConfigs.map((menuConfig, index) => (\r\n <MenuItem key={index}>\r\n <Box\r\n className={profileClasses.item}\r\n onClick={(e) => this.handleMenuItemClick(e, menuConfig)}\r\n {...(menuConfig.href ? { component: 'a', href: menuConfig.href } : {})}\r\n {...menuConfig.buttonProps}\r\n >\r\n <ListItemIcon>{menuConfig.icon}</ListItemIcon>\r\n {menuConfig.title}\r\n </Box>\r\n </MenuItem>\r\n ))}\r\n </Menu>\r\n </Fragment>\r\n )\r\n }\r\n}\r\n\r\nexport default Profile\r\n\r\nconst getStylePaper = (theme: 'dark' | 'light' = 'dark'): Partial<PaperProps<'div', {}>> => {\r\n const isLightTheme = theme === 'light'\r\n const backgroundColor = isLightTheme ? '#fff' : '#323234'\r\n const textColor = isLightTheme ? '#000' : '#fff'\r\n const textSecondaryColor = isLightTheme ? colors.blue[600] : '#e78a3f'\r\n const dividerColor = isLightTheme ? colors.grey[200] : colors.grey[700]\r\n return {\r\n elevation: 0,\r\n sx: {\r\n '--color-background': backgroundColor,\r\n '--color-text': textColor,\r\n '--color-text-secondary': textSecondaryColor,\r\n '--color-divider': dividerColor,\r\n\r\n minWidth: '200px',\r\n overflow: 'visible',\r\n filter: 'drop-shadow(0px 2px 8px rgba(0,0,0,0.32))',\r\n mt: 1.5,\r\n bgcolor: 'var(--color-background)', // dark background\r\n color: 'var(--color-text)', // white text,\r\n\r\n [getClasses('title')]: {\r\n marginTop: '-8px',\r\n padding: '10px 16px',\r\n fontWeight: '600',\r\n color: 'var(--color-text)'\r\n },\r\n [getClasses('item')]: {\r\n display: 'flex',\r\n alignItems: 'center',\r\n gap: '8px',\r\n color: 'currentColor',\r\n textDecoration: 'none',\r\n padding: '6px 16px',\r\n flex: 1\r\n },\r\n '& .MuiAvatar-root': {\r\n width: 32,\r\n height: 32,\r\n ml: -0.5,\r\n mr: 1,\r\n bgcolor: 'var(--color-avatar-bg)',\r\n color: 'var(--color-avatar-text)'\r\n },\r\n '& .MuiMenuItem-root': {\r\n padding: 0,\r\n transition: 'all 0.3s',\r\n color: 'var(--color-text)',\r\n '.MuiSvgIcon-root': {\r\n transition: 'all 0.2s',\r\n transform: 'translateX(0px) scale(1)'\r\n },\r\n '&:hover': {\r\n color: 'var(--color-text-secondary)',\r\n backgroundColor: 'var(--color-divider)',\r\n '.MuiSvgIcon-root': {\r\n color: 'var(--color-text-secondary)',\r\n transform: 'translateX(4px) scale(1.2)'\r\n }\r\n }\r\n },\r\n '& .MuiListItemIcon-root': {\r\n color: 'var(--color-text)'\r\n },\r\n '& .MuiDivider-root': {\r\n borderColor: 'var(--color-divider)'\r\n },\r\n '&:before': {\r\n content: '\"\"',\r\n display: 'block',\r\n position: 'absolute',\r\n top: 0,\r\n right: 20,\r\n width: 10,\r\n height: 10,\r\n bgcolor: 'var(--color-background)',\r\n transform: 'translateY(-50%) rotate(45deg)',\r\n zIndex: 0\r\n }\r\n }\r\n }\r\n}\r\n"],"names":["profileClasses","root","title","item","getClasses","key","options","concat","Profile","props","_this","_classCallCheck","_callSuper","_defineProperty","setState","isOpen","state","event","element","currentTarget","menuConfig","onClick","_inherits","Component","_createClass","value","_profile$AvatarUrl","_this2","this","profile","userName","UserName","_jsxs","Fragment","children","_jsx","Fade","in","Tooltip","IconButton","handleClick","size","undefined","sx","flex","Avatar","_objectSpread","src","AvatarUrl","getAvatarProps","Menu","anchorEl","id","disableScrollLock","open","onClose","handleClose","MenuListProps","component","slotProps","paper","getStylePaper","theme","transformOrigin","horizontal","vertical","anchorOrigin","Typography","variant","noWrap","className","e","stopPropagation","Divider","mb","menuConfigs","map","index","MenuItem","Box","handleMenuItemClick","href","buttonProps","ListItemIcon","icon","isLightTheme","arguments","length","backgroundColor","textColor","textSecondaryColor","colors","blue","dividerColor","grey","elevation","minWidth","overflow","filter","mt","bgcolor","color","marginTop","padding","fontWeight","display","alignItems","gap","textDecoration","width","height","ml","mr","transition","transform","borderColor","content","position","top","right","zIndex"],"mappings":"weAOO,IAAMA,EAAiB,CAC5BC,KAAM,eACNC,MAAO,gBACPC,KAAM,gBAGFC,EAAa,SAACC,EAAkCC,GACpD,MAAA,GAAAC,OAA6B,QAAEA,OAAIP,EAAeK,IAAIE,OAAsB,GAC9E,EAaaC,aACX,SAAAA,EAAYC,GAAyB,IAAAC,EAKlC,OALkCC,OAAAH,GACnCE,EAAAE,EAAAJ,KAAAA,GAAMC,IAAMI,EAAAH,EAOL,SAAA,WAAA,OAAMA,EAAKI,SAAS,CAAEC,QAASL,EAAKM,MAAMD,QAAS,GAAAF,EAAAH,EAE9C,cAAA,SAACO,GACbP,EAAKI,SAAS,CAAEI,QAASD,EAAME,kBAChCN,EAAAH,EAAA,sBAEqB,SAACO,EAAyEG,GAC1FA,EAAWC,SACbD,EAAWC,QAAQJ,GAErBP,EAAKI,SAAS,CAAEI,QAAS,SAC1BL,EAAAH,EAAA,cAEa,WACZA,EAAKI,SAAS,CAAEI,QAAS,SApBzBR,EAAKM,MAAQ,CACXD,QAAQ,EACRG,QAAS,MACVR,CACH,CAAC,OAAAY,EAAAd,EAP0Be,GAO1BC,EAAAhB,EAAA,CAAA,CAAAH,IAAA,SAAAoB,MAmBD,WAAM,IAAAC,EAAAC,EAAAC,KACIC,EAAYD,KAAKnB,MAAjBoB,QACFC,GAAWD,aAAO,EAAPA,EAASE,WAAY,QACtC,OACEC,EAACC,EAAQ,CAAAC,SAAA,CACPC,EAACC,EAAI,C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IhB"}
|
|
1
|
+
{"version":3,"file":"profile.js","sources":["../../src/auth/profile.tsx"],"sourcesContent":["import { Component, Fragment } from 'react'\r\nimport type { PropsWithChildren } from 'react'\r\nimport { Box, MenuItem, Divider, IconButton, Tooltip, colors } from '@mui/material'\r\nimport { Avatar, Fade, ListItemIcon, Menu, PaperProps, Typography } from '@mui/material'\r\nimport { getAvatarProps } from '../layout-global/helpers'\r\nimport type { IMenuItems, IMenuItem, IProfile } from './types'\r\n\r\nexport const profileClasses = {\r\n root: 'Profile-root',\r\n title: 'Profile-title',\r\n item: 'Profile-item'\r\n}\r\n\r\nconst getClasses = (key: keyof typeof profileClasses, options?: { prefix?: string; suffix?: string }) => {\r\n return `${options?.prefix || ''}.${profileClasses[key]}${options?.suffix || ''}`\r\n}\r\n\r\nexport interface IAvatarButtonProps extends PropsWithChildren {\r\n profile: IProfile | null\r\n menuConfigs: IMenuItems\r\n theme?: 'dark' | 'light'\r\n}\r\n\r\nexport interface IAvatarButtonState {\r\n isOpen: boolean\r\n element: HTMLElement | null\r\n}\r\n\r\nexport class Profile extends Component<IAvatarButtonProps, IAvatarButtonState> {\r\n constructor(props: IAvatarButtonProps) {\r\n super(props)\r\n this.state = {\r\n isOpen: false,\r\n element: null\r\n }\r\n }\r\n\r\n toggle = () => this.setState({ isOpen: !this.state.isOpen })\r\n\r\n handleClick = (event: React.MouseEvent<HTMLElement>) => {\r\n this.setState({ element: event.currentTarget })\r\n }\r\n\r\n handleMenuItemClick = (event: React.MouseEvent<HTMLAnchorElement | HTMLDivElement, MouseEvent>, menuConfig: IMenuItem) => {\r\n if (menuConfig.onClick) {\r\n menuConfig.onClick(event)\r\n }\r\n this.setState({ element: null })\r\n }\r\n\r\n handleClose = () => {\r\n this.setState({ element: null })\r\n }\r\n\r\n render() {\r\n const { profile } = this.props\r\n const userName = profile?.UserName || 'Guest'\r\n return (\r\n <Fragment>\r\n <Fade in>\r\n <Tooltip title='Account settings'>\r\n <IconButton\r\n onClick={this.handleClick}\r\n size='small'\r\n aria-controls={this.state.element ? 'account-menu' : undefined}\r\n aria-haspopup='true'\r\n aria-expanded={this.state.element ? 'true' : undefined}\r\n sx={{ flex: 0 }}\r\n >\r\n <Avatar src={profile?.AvatarUrl ?? ''} {...getAvatarProps(userName)} />\r\n </IconButton>\r\n </Tooltip>\r\n </Fade>\r\n <Menu\r\n anchorEl={this.state.element}\r\n id='account-menu'\r\n disableScrollLock\r\n open={!!this.state.element}\r\n onClose={this.handleClose}\r\n onClick={this.handleClose}\r\n MenuListProps={{ component: 'div' }}\r\n slotProps={{ paper: getStylePaper(this.props.theme) }}\r\n transformOrigin={{ horizontal: 'right', vertical: 'top' }}\r\n anchorOrigin={{ horizontal: 'right', vertical: 'bottom' }}\r\n >\r\n <Typography\r\n variant='subtitle1'\r\n noWrap\r\n className={profileClasses.title}\r\n onClick={(e: React.MouseEvent<HTMLDivElement, MouseEvent>) => e.stopPropagation()}\r\n >\r\n Hello, {userName}\r\n </Typography>\r\n <Divider variant='middle' sx={{ mb: 1 }} />\r\n {this.props.menuConfigs.map((menuConfig, index) => (\r\n <MenuItem key={index}>\r\n <Box\r\n className={profileClasses.item}\r\n onClick={(e) => this.handleMenuItemClick(e, menuConfig)}\r\n {...(menuConfig.href ? { component: 'a', href: menuConfig.href } : {})}\r\n {...menuConfig.buttonProps}\r\n >\r\n <ListItemIcon>{menuConfig.icon}</ListItemIcon>\r\n {menuConfig.title}\r\n </Box>\r\n </MenuItem>\r\n ))}\r\n </Menu>\r\n </Fragment>\r\n )\r\n }\r\n}\r\n\r\nexport default Profile\r\n\r\nconst getStylePaper = (theme: 'dark' | 'light' = 'dark'): Partial<PaperProps<'div', {}>> => {\r\n const isLightTheme = theme === 'light'\r\n const backgroundColor = isLightTheme ? '#fff' : '#323234'\r\n const textColor = isLightTheme ? '#000' : '#fff'\r\n const textSecondaryColor = isLightTheme ? colors.blue[600] : '#e78a3f'\r\n const dividerColor = isLightTheme ? colors.grey[200] : colors.grey[700]\r\n return {\r\n elevation: 0,\r\n sx: {\r\n '--color-background': backgroundColor,\r\n '--color-text': textColor,\r\n '--color-text-secondary': textSecondaryColor,\r\n '--color-divider': dividerColor,\r\n\r\n minWidth: '220px',\r\n overflow: 'visible',\r\n filter: 'drop-shadow(0px 2px 8px rgba(0,0,0,0.32))',\r\n mt: 1.5,\r\n bgcolor: 'var(--color-background)', // dark background\r\n color: 'var(--color-text)', // white text,\r\n\r\n [getClasses('title')]: {\r\n marginTop: '-8px',\r\n padding: '10px 16px',\r\n fontWeight: '600',\r\n color: 'var(--color-text)'\r\n },\r\n [getClasses('item')]: {\r\n display: 'flex',\r\n alignItems: 'center',\r\n gap: '8px',\r\n color: 'currentColor',\r\n textDecoration: 'none',\r\n padding: '6px 16px',\r\n flex: 1\r\n },\r\n '.MuiAvatar-root': {\r\n width: 32,\r\n height: 32,\r\n ml: -0.5,\r\n mr: 1,\r\n bgcolor: 'var(--color-avatar-bg)',\r\n color: 'var(--color-avatar-text)'\r\n },\r\n '.MuiMenuItem-root': {\r\n padding: 0,\r\n transition: 'all 0.3s',\r\n color: 'var(--color-text)',\r\n '.MuiSvgIcon-root': { transition: 'all 0.2s', transform: 'translateX(0px) scale(1)' },\r\n '&:hover': {\r\n color: 'var(--color-text-secondary)',\r\n backgroundColor: 'var(--color-divider)',\r\n '.MuiSvgIcon-root': { color: 'var(--color-text-secondary)', transform: 'translateX(4px) scale(1.2)' }\r\n }\r\n },\r\n '.MuiListItemIcon-root': { color: 'var(--color-text)' },\r\n '.MuiDivider-root': { borderColor: 'var(--color-divider)' },\r\n '&:before': {\r\n content: '\"\"',\r\n display: 'block',\r\n position: 'absolute',\r\n top: 0,\r\n right: 20,\r\n width: 10,\r\n height: 10,\r\n bgcolor: 'var(--color-background)',\r\n transform: 'translateY(-50%) rotate(45deg)',\r\n zIndex: 0\r\n }\r\n }\r\n }\r\n}\r\n"],"names":["profileClasses","root","title","item","getClasses","key","options","concat","Profile","props","_this","_classCallCheck","_callSuper","_defineProperty","setState","isOpen","state","event","element","currentTarget","menuConfig","onClick","_inherits","Component","_createClass","value","_profile$AvatarUrl","_this2","this","profile","userName","UserName","_jsxs","Fragment","children","_jsx","Fade","in","Tooltip","IconButton","handleClick","size","undefined","sx","flex","Avatar","_objectSpread","src","AvatarUrl","getAvatarProps","Menu","anchorEl","id","disableScrollLock","open","onClose","handleClose","MenuListProps","component","slotProps","paper","getStylePaper","theme","transformOrigin","horizontal","vertical","anchorOrigin","Typography","variant","noWrap","className","e","stopPropagation","Divider","mb","menuConfigs","map","index","MenuItem","Box","handleMenuItemClick","href","buttonProps","ListItemIcon","icon","isLightTheme","arguments","length","backgroundColor","textColor","textSecondaryColor","colors","blue","dividerColor","grey","elevation","minWidth","overflow","filter","mt","bgcolor","color","marginTop","padding","fontWeight","display","alignItems","gap","textDecoration","width","height","ml","mr","transition","transform","borderColor","content","position","top","right","zIndex"],"mappings":"weAOO,IAAMA,EAAiB,CAC5BC,KAAM,eACNC,MAAO,gBACPC,KAAM,gBAGFC,EAAa,SAACC,EAAkCC,GACpD,MAAA,GAAAC,OAA6B,QAAEA,OAAIP,EAAeK,IAAIE,OAAsB,GAC9E,EAaaC,aACX,SAAAA,EAAYC,GAAyB,IAAAC,EAKlC,OALkCC,OAAAH,GACnCE,EAAAE,EAAAJ,KAAAA,GAAMC,IAAMI,EAAAH,EAOL,SAAA,WAAA,OAAMA,EAAKI,SAAS,CAAEC,QAASL,EAAKM,MAAMD,QAAS,GAAAF,EAAAH,EAE9C,cAAA,SAACO,GACbP,EAAKI,SAAS,CAAEI,QAASD,EAAME,kBAChCN,EAAAH,EAAA,sBAEqB,SAACO,EAAyEG,GAC1FA,EAAWC,SACbD,EAAWC,QAAQJ,GAErBP,EAAKI,SAAS,CAAEI,QAAS,SAC1BL,EAAAH,EAAA,cAEa,WACZA,EAAKI,SAAS,CAAEI,QAAS,SApBzBR,EAAKM,MAAQ,CACXD,QAAQ,EACRG,QAAS,MACVR,CACH,CAAC,OAAAY,EAAAd,EAP0Be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AO,8BAA+Ba,UAAW,iCAG3E,wBAAyB,CAAEb,MAAO,sBAClC,mBAAoB,CAAEc,YAAa,yBACnC,WAAY,CACVC,QAAS,KACTX,QAAS,QACTY,SAAU,WACVC,IAAK,EACLC,MAAO,GACPV,MAAO,GACPC,OAAQ,GACRV,QAAS,0BACTc,UAAW,iCACXM,OAAQ,IAIhB"}
|
package/dist/auth/service.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.js","sources":["../../src/auth/service.ts"],"sourcesContent":["import { createObjectSingleton } from 'dinocollab-core/utils'\r\n\r\nexport interface IAuthMetaData {\r\n isAuth?: boolean\r\n token: string\r\n displayName: string\r\n email?: string\r\n avatarUrl?: string\r\n}\r\n\r\nexport interface IAuthProvider {\r\n tryAutoSignIn?: () => Promise<void>\r\n signIn(): Promise<void>\r\n signOut(): Promise<void>\r\n getInfo(): Promise<IAuthMetaData>\r\n}\r\n\r\nclass AuthProviderDefault implements IAuthProvider {\r\n async tryAutoSignIn() {\r\n console.log('Default tryAutoSignIn called')\r\n }\r\n async signIn() {\r\n console.log('Default signIn called')\r\n return Promise.resolve()\r\n }\r\n async signOut() {\r\n console.log('Default signOut called')\r\n return Promise.resolve()\r\n }\r\n async getInfo() {\r\n console.log('Default getInfo called')\r\n return Promise.resolve({ token: '', displayName: 'Guest User' })\r\n }\r\n}\r\n\r\nexport class AuthService {\r\n static key_provider = '__auth_key_provider__'\r\n static get provider(): IAuthProvider {\r\n const ObjectProvider = createObjectSingleton<IAuthProvider>(AuthService.key_provider)\r\n return ObjectProvider.get() ?? new AuthProviderDefault()\r\n }\r\n static setProvider(provider: IAuthProvider) {\r\n const ObjectProvider = createObjectSingleton<IAuthProvider>(AuthService.key_provider)\r\n ObjectProvider.set(provider ?? new AuthProviderDefault())\r\n }\r\n\r\n constructor() {\r\n this.tryAutoSignIn()\r\n }\r\n\r\n tryAutoSignIn() {\r\n return AuthService.provider.tryAutoSignIn?.()\r\n }\r\n signIn() {\r\n return AuthService.provider.signIn()\r\n }\r\n signOut() {\r\n return AuthService.provider.signOut()\r\n }\r\n getInfo() {\r\n return AuthService.provider.getInfo()\r\n }\r\n}\r\n"],"names":["AuthProviderDefault","_createClass","_classCallCheck","key","value","_tryAutoSignIn","_asyncToGenerator","_regenerator","m","_callee","w","_context","n","console","log","a","apply","this","arguments","_signIn","_callee2","_context2","Promise","resolve","_signOut","_callee3","_context3","_getInfo","_callee4","_context4","token","displayName","AuthService","tryAutoSignIn","_AuthService$provider","_AuthService$provider2","provider","call","signIn","signOut","getInfo","get","_ObjectProvider$get","createObjectSingleton","key_provider","set"],"mappings":"oNAA6D,
|
|
1
|
+
{"version":3,"file":"service.js","sources":["../../src/auth/service.ts"],"sourcesContent":["import { createObjectSingleton } from 'dinocollab-core/utils'\r\n\r\nexport interface IAuthMetaData {\r\n isAuth?: boolean\r\n token: string\r\n displayName: string\r\n email?: string\r\n avatarUrl?: string\r\n roles?: string[]\r\n}\r\n\r\nexport interface IAuthProvider {\r\n tryAutoSignIn?: () => Promise<void>\r\n signIn(): Promise<void>\r\n signOut(): Promise<void>\r\n getInfo(): Promise<IAuthMetaData>\r\n}\r\n\r\nclass AuthProviderDefault implements IAuthProvider {\r\n async tryAutoSignIn() {\r\n console.log('Default tryAutoSignIn called')\r\n }\r\n async signIn() {\r\n console.log('Default signIn called')\r\n return Promise.resolve()\r\n }\r\n async signOut() {\r\n console.log('Default signOut called')\r\n return Promise.resolve()\r\n }\r\n async getInfo() {\r\n console.log('Default getInfo called')\r\n return Promise.resolve({ token: '', displayName: 'Guest User' })\r\n }\r\n}\r\n\r\nexport class AuthService {\r\n static key_provider = '__auth_key_provider__'\r\n static get provider(): IAuthProvider {\r\n const ObjectProvider = createObjectSingleton<IAuthProvider>(AuthService.key_provider)\r\n return ObjectProvider.get() ?? new AuthProviderDefault()\r\n }\r\n static setProvider(provider: IAuthProvider) {\r\n const ObjectProvider = createObjectSingleton<IAuthProvider>(AuthService.key_provider)\r\n ObjectProvider.set(provider ?? new AuthProviderDefault())\r\n }\r\n\r\n constructor() {\r\n this.tryAutoSignIn()\r\n }\r\n\r\n tryAutoSignIn() {\r\n return AuthService.provider.tryAutoSignIn?.()\r\n }\r\n signIn() {\r\n return AuthService.provider.signIn()\r\n }\r\n signOut() {\r\n return AuthService.provider.signOut()\r\n }\r\n getInfo() {\r\n return AuthService.provider.getInfo()\r\n }\r\n}\r\n"],"names":["AuthProviderDefault","_createClass","_classCallCheck","key","value","_tryAutoSignIn","_asyncToGenerator","_regenerator","m","_callee","w","_context","n","console","log","a","apply","this","arguments","_signIn","_callee2","_context2","Promise","resolve","_signOut","_callee3","_context3","_getInfo","_callee4","_context4","token","displayName","AuthService","tryAutoSignIn","_AuthService$provider","_AuthService$provider2","provider","call","signIn","signOut","getInfo","get","_ObjectProvider$get","createObjectSingleton","key_provider","set"],"mappings":"oNAA6D,IAkBvDA,EAAmB,WAAA,OAAAC,EAAA,SAAAD,IAAAE,OAAAF,EAAA,EAAA,CAAA,CAAAG,IAAA,gBAAAC,OAAAC,EAAAC,EAAAC,IAAAC,EACvB,SAAAC,IAAA,OAAAF,IAAAG,EAAA,SAAAC,GAAA,cAAAA,EAAAC,GAAA,KAAA,EACEC,QAAQC,IAAI,gCAA+B,KAAA,EAAA,OAAAH,EAAAI,EAAA,GAAA,EAAAN,MAC5C,WAFkB,OAAAJ,EAAAW,MAAAC,KAAAC,UAAA,IAAA,CAAAf,IAAA,SAAAC,OAAAe,EAAAb,EAAAC,IAAAC,EAGnB,SAAAY,IAAA,OAAAb,IAAAG,EAAA,SAAAW,GAAA,UAAA,IAAAA,EAAAT,EACsC,OAApCC,QAAQC,IAAI,yBAAwBO,EAAAN,EAAA,EAC7BO,QAAQC,UAAS,EAAAH,MACzB,WAHW,OAAAD,EAAAH,MAAAC,KAAAC,UAAA,IAAA,CAAAf,IAAA,UAAAC,OAAAoB,EAAAlB,EAAAC,IAAAC,EAIZ,SAAAiB,IAAA,OAAAlB,IAAAG,EAAA,S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th/widget.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"widget.js","sources":["../../src/auth/widget.tsx"],"sourcesContent":["import { FC, useMemo } from 'react'\r\nimport { ButtonProps } from '@mui/material'\r\nimport Logout from '@mui/icons-material/Logout'\r\nimport LoginIcon from '@mui/icons-material/Login'\r\nimport ManageAccountsIcon from '@mui/icons-material/ManageAccounts'\r\nimport { IconButtonOrange } from '../components/buttons'\r\nimport type { IAppSiteBaseUrl } from '../types'\r\nimport type { IAuthState,
|
|
1
|
+
{"version":3,"file":"widget.js","sources":["../../src/auth/widget.tsx"],"sourcesContent":["import { FC, useMemo } from 'react'\r\nimport { ButtonProps } from '@mui/material'\r\nimport Logout from '@mui/icons-material/Logout'\r\nimport LoginIcon from '@mui/icons-material/Login'\r\nimport ManageAccountsIcon from '@mui/icons-material/ManageAccounts'\r\nimport { IconButtonOrange } from '../components/buttons'\r\nimport type { IAppSiteBaseUrl } from '../types'\r\nimport type { IAuthState, IMenuItems } from './types'\r\nimport Profile from './profile'\r\n\r\nexport interface IAuthBaseProps {\r\n baseUrl: IAppSiteBaseUrl\r\n fontSizeScale?: number\r\n // login\r\n hrefLogin?: string\r\n onLoginClick?: (e: React.MouseEvent<HTMLAnchorElement | HTMLDivElement, MouseEvent>) => void\r\n buttonLoginProps?: ButtonProps & { [key: string]: any }\r\n // menu\r\n menu?: IMenuItems\r\n}\r\n\r\nexport interface IAuthWidgetProps extends IAuthState, IAuthBaseProps {}\r\n\r\nexport const AuthWidget: FC<IAuthWidgetProps> = (props) => {\r\n const { isAuthenticated, profile, isLoading } = props\r\n if (isLoading) return null\r\n\r\n if (!isAuthenticated) {\r\n return (\r\n <IconButtonOrange\r\n onClick={props.onLoginClick as any}\r\n {...(props.hrefLogin ? { component: 'a', href: props.hrefLogin ?? '/' } : {})}\r\n {...props.buttonLoginProps}\r\n >\r\n <LoginIcon fontSize='small' />\r\n </IconButtonOrange>\r\n )\r\n // return (\r\n // <ResponsiveDisplay\r\n // xs={\r\n // <IconButtonOrange\r\n // onClick={props.onLoginClick as any}\r\n // {...(props.hrefLogin ? { component: 'a', href: props.hrefLogin ?? '/' } : {})}\r\n // {...props.buttonLoginProps}\r\n // >\r\n // <LoginIcon fontSize='small' />\r\n // </IconButtonOrange>\r\n // }\r\n // md={\r\n // <ButtonOrange\r\n // className='animate-bounce'\r\n // startIcon={<LoginIcon fontSize='small' />}\r\n // onClick={props.onLoginClick as any}\r\n // {...(props.hrefLogin ? { component: 'a', href: props.hrefLogin ?? '/' } : {})}\r\n // {...props.buttonLoginProps}\r\n // >\r\n // {/* <Typography variant='h6' sx={{ fontSize: `${(props.fontSizeScale ?? 1) * 0.9}rem` }}>\r\n // Login\r\n // </Typography> */}\r\n // <Typography variant='h6'>Login</Typography>\r\n // </ButtonOrange>\r\n // }\r\n // />\r\n // )\r\n }\r\n\r\n const menuConfigs = useMemo(() => {\r\n if (!props.menu || props.menu.length === 0) {\r\n return [\r\n { title: 'Manage Profile', icon: <ManageAccountsIcon fontSize='small' /> },\r\n { title: 'Logout', icon: <Logout fontSize='small' /> }\r\n ]\r\n }\r\n return props.menu ?? []\r\n }, [props.menu])\r\n\r\n // If the user is authenticated, display the AuthWidget with user details\r\n return <Profile profile={profile} menuConfigs={menuConfigs} />\r\n}\r\nexport default AuthWidget\r\n\r\nexport const createAuthWidget = (params: IAuthBaseProps) => {\r\n const _AuthWidget: FC<Omit<IAuthWidgetProps, 'baseUrl'>> = (props) => <AuthWidget {...params} {...props} />\r\n _AuthWidget.displayName = 'AuthWidget'\r\n return _AuthWidget\r\n}\r\n"],"names":["AuthWidget","props","_props$hrefLogin","isAuthenticated","profile","isLoading","_jsx","IconButtonOrange","_objectSpread","onClick","onLoginClick","hrefLogin","component","href","buttonLoginProps","children","LoginIcon","fontSize","menuConfigs","useMemo","_props$menu","menu","length","title","icon","ManageAccountsIcon","Logout","Profile","createAuthWidget","params","_AuthWidget","displayName"],"mappings":"6XAuBaA,EAAmC,SAACC,GAC/C,IAGsBC,EAHdC,EAAwCF,EAAxCE,gBAAiBC,EAAuBH,EAAvBG,QACzB,GADgDH,EAAdI,UACnB,OAAO,KAEtB,IAAKF,EACH,OACEG,EAACC,EAAgBC,EAAAA,EAAAA,EAAA,CACfC,QAASR,EAAMS,cACVT,EAAMU,UAAY,CAAEC,UAAW,IAAKC,KAAqBX,QAAjBA,EAAED,EAAMU,iBAAST,IAAAA,EAAAA,EAAI,KAAQ,CAAE,GACxED,EAAMa,kBAAgB,CAAA,EAAA,CAAAC,SAE1BT,EAACU,EAAU,CAAAC,SAAS,aAgC1B,IAAMC,EAAcC,EAAQ,WAAK,IAAAC,EAC/B,OAAKnB,EAAMoB,MAA8B,IAAtBpB,EAAMoB,KAAKC,eAM9BF,EAAOnB,EAAMoB,YAAI,IAAAD,EAAAA,EAAI,GALZ,CACL,CAAEG,MAAO,iBAAkBC,KAAMlB,EAACmB,EAAmB,CAAAR,SAAS,WAC9D,CAAEM,MAAO,SAAUC,KAAMlB,EAACoB,EAAO,CAAAT,SAAS,WAIhD,EAAG,CAAChB,EAAMoB,OAGV,OAAOf,EAACqB,EAAO,CAACvB,QAASA,EAASc,YAAaA,GACjD,EAGaU,EAAmB,SAACC,GAC/B,IAAMC,EAAqD,SAAC7B,GAAK,OAAKK,EAACN,EAAUQ,EAAAA,EAAA,CAAA,EAAKqB,GAAY5B,GAAS,EAE3G,OADA6B,EAAYC,YAAc,aACnBD,CACT"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{inherits as e,createClass as i,
|
|
1
|
+
import{inherits as e,createClass as i,objectSpread2 as t,classCallCheck as n,callSuper as r,defineProperty as o}from"../_virtual/_rollupPluginBabelHelpers.js";import{jsxs as l,jsx as a}from"react/jsx-runtime";import{Component as c}from"react";import{Box as s,Typography as d,alpha as m,colors as h,Stack as p,Divider as u,Button as f}from"@mui/material";import v from"@mui/icons-material/DraftsOutlined";import g from"@mui/icons-material/MarkEmailUnreadOutlined";import{formatTimeAgo as b}from"./helpers.js";import{NoDataPanel as x}from"../components/no-data-panel.js";import{NotifyListStyled as C,notifyListClasses as w}from"./styled.js";var N=function(){function N(){var e;n(this,N);for(var i=arguments.length,t=new Array(i),c=0;c<i;c++)t[c]=arguments[c];return e=r(this,N,[].concat(t)),o(e,"renderItem",function(i,t){return l(s,{className:w.item,onClick:function(){return e.onClickHandler(i)},children:[a(p,{px:1,children:i.IsRead?a(v,{color:"disabled"}):a(g,{color:"success"})}),l(s,{flex:1,children:[a(d,{variant:"subtitle1",component:"h6",className:w.itemTitle,children:i.Title}),a(d,{variant:"caption",className:w.itemSubTitle,children:i.SubTitle}),a(p,{direction:"row",spacing:1,justifyContent:"flex-end",children:a(d,{variant:"caption",color:m(h.common.white,.5),children:b(i.DateCreated)})})]})]},t.toString())}),o(e,"onClickHandler",function(i){e.props.onClick&&e.props.onClick(i)}),o(e,"getDescription",function(e){return 0===e?"No new notifications":1===e?"You have 1 unread notification":"You have ".concat(e," unread notifications")}),o(e,"getItems",function(i){return e.props.data.filter(function(e){return void 0===i||e.IsRead===i})}),e}return e(N,c),i(N,[{key:"render",value:function(){var e,i=this,n=this.getItems(!0),r=this.getItems(!1);return l(C,{className:"".concat(w.root).concat(this.props.isMobile?" mobile":""),children:[a("div",{className:w.header,children:l(s,{flex:1,children:[a(d,{variant:"h6",children:"Notifications"}),a(d,{variant:"body2",color:m(h.common.white,.6),children:this.getDescription(r.length)})]})}),l(p,{className:w.items,children:[r.length>0&&l("div",{children:[l("div",{className:w.groupTitle,children:[a(d,{variant:"caption",children:"Unseen"}),a(u,{sx:{borderColor:m(h.common.white,.1)}})]}),r.map(this.renderItem)]}),n.length>0&&l("div",{children:[l("div",{className:w.groupTitle,children:[a(d,{variant:"caption",children:"Seen"}),a(u,{sx:{borderColor:m(h.common.white,.1)}})]}),n.map(this.renderItem)]}),r.length+n.length===0&&a(x,{title:"No Notifications",subTitle:"You're all caught up!",sx:{minWidth:250,flex:1}})]}),!1!==this.props.enableViewAll&&a("div",{className:w.footer,children:a(f,t(t({variant:"text"},this.props.buttonViewAllProps),{},{onClick:function(e){var t,n,r,o;null===(t=i.props.buttonViewAllProps)||void 0===t||null===(n=t.onClick)||void 0===n||n.call(t,e),null===(r=(o=i.props).onViewAllClick)||void 0===r||r.call(o)},sx:t({flex:"0 0 auto",width:"auto"},null===(e=this.props.buttonViewAllProps)||void 0===e?void 0:e.sx),children:a(d,{variant:"caption",sx:{textTransform:"none",fontWeight:600},children:"View All"})}))})]})}}])}();export{N as default};
|
|
2
2
|
//# sourceMappingURL=notify-list.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notify-list.js","sources":["../../src/notification/notify-list.tsx"],"sourcesContent":["import { Component } from 'react'\r\nimport { alpha, Box, Button, colors, Divider, Stack, Typography } from '@mui/material'\r\nimport DraftsOutlinedIcon from '@mui/icons-material/DraftsOutlined'\r\nimport MarkEmailUnreadOutlinedIcon from '@mui/icons-material/MarkEmailUnreadOutlined'\r\nimport { INotification } from './types'\r\nimport { formatTimeAgo } from './helpers'\r\nimport { NoDataPanel } from '../components/no-data-panel'\r\nimport { NotifyListStyled, notifyListClasses } from './styled'\r\n\r\ninterface INotifyListProps {\r\n data: INotification[]\r\n onClick?: (value: INotification) => void\r\n isMobile?: boolean\r\n}\r\n\r\nclass NotifyList extends Component<INotifyListProps> {\r\n render() {\r\n const listReaded = this.getItems(true)\r\n const listUnReaded = this.getItems(false)\r\n return (\r\n <NotifyListStyled className={`${notifyListClasses.root}${this.props.isMobile ? ' mobile' : ''}`}>\r\n {/* Render the menu header */}\r\n <div className={notifyListClasses.header}>\r\n <Box flex={1}>\r\n <Typography variant='h6'>Notifications</Typography>\r\n <Typography variant='body2' color={alpha(colors.common.white, 0.6)}>\r\n {this.getDescription(listUnReaded.length)}\r\n </Typography>\r\n </Box>\r\n </div>\r\n {/* <Divider variant='middle' sx={{ borderColor: alpha(colors.common.white, 0.1) }} /> */}\r\n {/* Render sub-menu items */}\r\n <Stack className={notifyListClasses.items}>\r\n {listUnReaded.length > 0 && (\r\n <div>\r\n <div className={notifyListClasses.groupTitle}>\r\n <Typography variant='caption'>Unseen</Typography>\r\n <Divider sx={{ borderColor: alpha(colors.common.white, 0.1) }} />\r\n </div>\r\n {listUnReaded.map(this.renderItem)}\r\n </div>\r\n )}\r\n {listReaded.length > 0 && (\r\n <div>\r\n <div className={notifyListClasses.groupTitle}>\r\n <Typography variant='caption'>Seen</Typography>\r\n <Divider sx={{ borderColor: alpha(colors.common.white, 0.1) }} />\r\n </div>\r\n {listReaded.map(this.renderItem)}\r\n </div>\r\n )}\r\n {listUnReaded.length + listReaded.length === 0 && (\r\n <NoDataPanel title='No Notifications' subTitle=\"You're all caught up!\" sx={{ minWidth: 250, flex: 1 }} />\r\n )}\r\n </Stack>\r\n <div className={notifyListClasses.footer}>\r\n
|
|
1
|
+
{"version":3,"file":"notify-list.js","sources":["../../src/notification/notify-list.tsx"],"sourcesContent":["import { Component, ComponentProps } from 'react'\r\nimport { alpha, Box, Button, colors, Divider, Stack, Typography } from '@mui/material'\r\nimport DraftsOutlinedIcon from '@mui/icons-material/DraftsOutlined'\r\nimport MarkEmailUnreadOutlinedIcon from '@mui/icons-material/MarkEmailUnreadOutlined'\r\nimport { INotification } from './types'\r\nimport { formatTimeAgo } from './helpers'\r\nimport { NoDataPanel } from '../components/no-data-panel'\r\nimport { NotifyListStyled, notifyListClasses } from './styled'\r\n\r\nexport interface INotifyListSlots {\r\n /** @default true */\r\n enableViewAll?: boolean\r\n buttonViewAllProps?: ComponentProps<typeof Button> & { [key: string]: any }\r\n onViewAllClick?: () => void\r\n}\r\n\r\ninterface INotifyListProps extends INotifyListSlots {\r\n data: INotification[]\r\n onClick?: (value: INotification) => void\r\n isMobile?: boolean\r\n}\r\n\r\nclass NotifyList extends Component<INotifyListProps> {\r\n render() {\r\n const listReaded = this.getItems(true)\r\n const listUnReaded = this.getItems(false)\r\n return (\r\n <NotifyListStyled className={`${notifyListClasses.root}${this.props.isMobile ? ' mobile' : ''}`}>\r\n {/* Render the menu header */}\r\n <div className={notifyListClasses.header}>\r\n <Box flex={1}>\r\n <Typography variant='h6'>Notifications</Typography>\r\n <Typography variant='body2' color={alpha(colors.common.white, 0.6)}>\r\n {this.getDescription(listUnReaded.length)}\r\n </Typography>\r\n </Box>\r\n </div>\r\n {/* <Divider variant='middle' sx={{ borderColor: alpha(colors.common.white, 0.1) }} /> */}\r\n {/* Render sub-menu items */}\r\n <Stack className={notifyListClasses.items}>\r\n {listUnReaded.length > 0 && (\r\n <div>\r\n <div className={notifyListClasses.groupTitle}>\r\n <Typography variant='caption'>Unseen</Typography>\r\n <Divider sx={{ borderColor: alpha(colors.common.white, 0.1) }} />\r\n </div>\r\n {listUnReaded.map(this.renderItem)}\r\n </div>\r\n )}\r\n {listReaded.length > 0 && (\r\n <div>\r\n <div className={notifyListClasses.groupTitle}>\r\n <Typography variant='caption'>Seen</Typography>\r\n <Divider sx={{ borderColor: alpha(colors.common.white, 0.1) }} />\r\n </div>\r\n {listReaded.map(this.renderItem)}\r\n </div>\r\n )}\r\n {listUnReaded.length + listReaded.length === 0 && (\r\n <NoDataPanel title='No Notifications' subTitle=\"You're all caught up!\" sx={{ minWidth: 250, flex: 1 }} />\r\n )}\r\n </Stack>\r\n {this.props.enableViewAll !== false && (\r\n <div className={notifyListClasses.footer}>\r\n <Button\r\n variant='text'\r\n {...this.props.buttonViewAllProps}\r\n onClick={(e) => {\r\n this.props.buttonViewAllProps?.onClick?.(e)\r\n this.props.onViewAllClick?.()\r\n }}\r\n sx={{ flex: '0 0 auto', width: 'auto', ...this.props.buttonViewAllProps?.sx }}\r\n >\r\n <Typography variant='caption' sx={{ textTransform: 'none', fontWeight: 600 }}>\r\n View All\r\n </Typography>\r\n </Button>\r\n </div>\r\n )}\r\n </NotifyListStyled>\r\n )\r\n }\r\n\r\n renderItem = (item: INotification, index: number) => {\r\n // Render each item in the menu\r\n return (\r\n <Box key={index.toString()} className={notifyListClasses.item} onClick={() => this.onClickHandler(item)}>\r\n <Stack px={1}>{item.IsRead ? <DraftsOutlinedIcon color='disabled' /> : <MarkEmailUnreadOutlinedIcon color='success' />}</Stack>\r\n <Box flex={1}>\r\n <Typography variant='subtitle1' component='h6' className={notifyListClasses.itemTitle}>\r\n {item.Title}\r\n </Typography>\r\n <Typography variant='caption' className={notifyListClasses.itemSubTitle}>\r\n {item.SubTitle}\r\n </Typography>\r\n <Stack direction='row' spacing={1} justifyContent='flex-end'>\r\n <Typography variant='caption' color={alpha(colors.common.white, 0.5)}>\r\n {formatTimeAgo(item.DateCreated)}\r\n </Typography>\r\n </Stack>\r\n </Box>\r\n </Box>\r\n )\r\n }\r\n\r\n onClickHandler = (notification: INotification) => {\r\n if (!this.props.onClick) return\r\n // Call the onClick handler if provided\r\n this.props.onClick(notification)\r\n }\r\n\r\n getDescription = (count: number) => {\r\n if (count === 0) return 'No new notifications'\r\n if (count === 1) return 'You have 1 unread notification'\r\n return `You have ${count} unread notifications`\r\n }\r\n\r\n getItems = (isReaded?: boolean) => {\r\n return this.props.data.filter((item) => (isReaded !== undefined ? item.IsRead === isReaded : true))\r\n }\r\n}\r\nexport default NotifyList\r\n"],"names":["NotifyList","_this","_classCallCheck","_len","arguments","length","args","Array","_key","_callSuper","this","concat","_defineProperty","item","index","_jsxs","Box","className","notifyListClasses","onClick","onClickHandler","children","_jsx","Stack","px","IsRead","DraftsOutlinedIcon","color","MarkEmailUnreadOutlinedIcon","flex","Typography","variant","component","itemTitle","Title","itemSubTitle","SubTitle","direction","spacing","justifyContent","alpha","colors","common","white","formatTimeAgo","DateCreated","toString","notification","props","count","isReaded","data","filter","undefined","_inherits","Component","_createClass","key","value","_this$props$buttonVie","_this2","listReaded","getItems","listUnReaded","NotifyListStyled","root","isMobile","header","getDescription","items","groupTitle","Divider","sx","borderColor","map","renderItem","NoDataPanel","title","subTitle","minWidth","enableViewAll","footer","Button","_objectSpread","buttonViewAllProps","e","_this2$props$buttonVi","_this2$props$buttonVi2","_this2$props$onVi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AAWa,IAAIhE,KAAKiE,eAGxBZ,EAAa1D,OAASwD,EAAWxD,SAAW,GAC3CiB,EAACsD,EAAW,CAACC,MAAM,mBAAmBC,SAAS,wBAAwBN,GAAI,CAAEO,SAAU,IAAKlD,KAAM,SAGxE,IAA7BnB,KAAKsC,MAAMgC,eACV1D,EAAK,MAAA,CAAAL,UAAWC,EAAkB+D,gBAChC3D,EAAC4D,EAAMC,EAAAA,EAAA,CACLpD,QAAQ,QACJrB,KAAKsC,MAAMoC,oBAAkB,CAAA,EAAA,CACjCjE,QAAS,SAACkE,GAAK,IAAAC,EAAAC,EAAAC,EAAAC,EACgB,QAA7BH,EAAA1B,EAAKZ,MAAMoC,0BAAkB,IAAAE,GAASC,QAATA,EAA7BD,EAA+BnE,eAA/BoE,IAAsCA,GAAtCA,EAAAG,KAAAJ,EAAyCD,GAChB,QAAzBG,GAAAC,EAAA7B,EAAKZ,OAAM2C,sBAAXH,IAAyBA,GAAzBA,EAAAE,KAAAD,EACD,EACDjB,GAAEW,EAAA,CAAItD,KAAM,WAAY+D,MAAO,QAAwC,QAAlCjC,EAAKjD,KAAKsC,MAAMoC,0BAAkB,IAAAzB,OAAA,EAA7BA,EAA+Ba,IAEzEnD,SAAAC,EAACQ,EAAW,CAAAC,QAAQ,UAAUyC,GAAI,CAAEqB,cAAe,OAAQC,WAAY,KAAKzE,SAAA,oBAQxF,IAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{slicedToArray as t,toConsumableArray as n,inherits as o,createClass as e,
|
|
1
|
+
import{slicedToArray as t,toConsumableArray as n,inherits as o,createClass as e,objectSpread2 as r,asyncToGenerator as a,classCallCheck as i,callSuper as l,defineProperty as s,regenerator as c}from"../_virtual/_rollupPluginBabelHelpers.js";import{jsx as u,jsxs as d,Fragment as f}from"react/jsx-runtime";import{useTheme as p,useMediaQuery as h,Badge as m,Drawer as v}from"@mui/material";import{useState as C,useEffect as g,Component as y}from"react";import{GlobalModal as k,mapGlobalModalContext as w}from"dinocollab-core/api-context";import b from"@mui/icons-material/NotificationsNone";import{MenuStyled as D}from"./styled.js";import{IconButtonDark as S}from"../components/buttons.js";import{useFetchData as x}from"./hook.js";import R from"./notify-list.js";import{NotifyDetail as A}from"./notify-detail.js";var M=function(){function t(n){var o;return i(this,t),o=l(this,t,[n]),s(o,"onClickHandler",function(t){var n;o.onClose(),null===(n=o.globalModalContext)||void 0===n||n.show({backdropActivated:!0,renderContent:function(){var n;return u(A,{data:t,fetchDetail:o.props.fetchDetail,onRead:o.onReadHandler,onClose:null===(n=o.globalModalContext)||void 0===n?void 0:n.close})}})}),s(o,"onOpen",function(t){o.setState({anchorEl:t})}),s(o,"onClose",function(){o.setState({anchorEl:null})}),s(o,"onReadHandler",function(){var t=a(c().m(function t(n){var e,r,a;return c().w(function(t){for(;;)switch(t.n){case 0:null===(e=o.globalModalContext)||void 0===e||e.close();try{null===(r=(a=o.props).onRead)||void 0===r||r.call(a,n)}catch(t){console.error("Error updating read state:",t)}case 1:return t.a(2)}},t)}));return function(n){return t.apply(this,arguments)}}()),o.state={anchorEl:null,hydrated:!1},o}return o(t,y),e(t,[{key:"notifications",get:function(){var t;return null!==(t=this.props.data)&&void 0!==t?t:[]}},{key:"newFeatureCount",get:function(){return this.notifications.filter(function(t){return!t.IsRead}).length}},{key:"componentDidMount",value:function(){this.setState({hydrated:!0})}},{key:"componentDidUpdate",value:function(t){var n=this;if(t.data!==this.props.data&&this.props.data.length>0){var o=this.props.data.filter(function(t){return"Popup"===t.AreaType&&!t.IsRead});o.length>0&&setTimeout(function(){var t,e;null===(t=(e=n.props).onAutoShowPopup)||void 0===t||t.call(e,o[0])},1500)}}},{key:"render",value:function(){var t=this,n=Boolean(this.state.anchorEl);return d(f,{children:[u(S,{onClick:function(n){return t.onOpen(n.currentTarget)},children:u(m,{badgeContent:this.state.hydrated?this.newFeatureCount:0,color:"error",children:u(b,{fontSize:"small"})})}),this.props.isMobile?u(v,{anchor:"right",open:n,onClose:this.onClose,disableScrollLock:!0,PaperProps:{sx:{width:"calc(100% - 100px)",maxWidth:360}},children:w(function(n){return t.globalModalContext=n,u(R,r({data:t.props.data,onClick:t.onClickHandler,onViewAllClick:t.onClose},t.props.notifyListSlots))})}):u(D,{disableScrollLock:!0,anchorEl:this.state.anchorEl,open:n,onClose:this.onClose,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},MenuListProps:{component:"div"},children:w(function(n){return t.globalModalContext=n,u(R,r({data:t.props.data,onClick:t.onClickHandler,onViewAllClick:t.onClose},t.props.notifyListSlots))})})]})}}])}(),T=function(o){var e=x(o.featData),i=C([]),l=t(i,2),s=l[0],d=l[1],f=p(),m=h(f.breakpoints.down("sm"));g(function(){if(e.data){var t=n(e.data).sort(function(t,n){return new Date(n.DateCreated).getTime()-new Date(t.DateCreated).getTime()});d(t)}},[e.data]);var v=function(){var t=a(c().m(function t(n,e,a){var i;return c().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,null===(i=o.onRead)||void 0===i?void 0:i.call(o,n,e,a);case 1:d(function(t){return t.map(function(t){return t.Id===n?r(r({},t),{},{IsRead:!0}):t}).sort(function(t,n){return new Date(n.DateCreated).getTime()-new Date(t.DateCreated).getTime()})});case 2:return t.a(2)}},t)}));return function(n,o,e){return t.apply(this,arguments)}}();return u(k,{children:w(function(t){return u(M,{data:s,loading:e.loading,fetchDetail:o.fetchDetail,onRead:v,onAutoShowPopup:function(n){return function(t,n){n.show({backdropActivated:!0,renderContent:function(){return u(A,{data:t,fetchDetail:o.fetchDetail,onRead:(e=a(c().m(function t(o,e,r){return c().w(function(t){for(;;)switch(t.n){case 0:return n.close(),t.n=1,v(o,e,r);case 1:return t.a(2)}},t)})),function(t,n,o){return e.apply(this,arguments)}),onClose:n.close});var e}})}(n,t)},isMobile:m,notifyListSlots:o.notifyListSlots})})})},j=function(t){var n=function(n){return u(T,r(r({},t),n))};return n.displayName="NotificationWidget",n};export{T as NotificationWidget,j as createNotificationWidget,T as default};
|
|
2
2
|
//# sourceMappingURL=widget.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"widget.js","sources":["../../src/notification/widget.tsx"],"sourcesContent":["import { Badge, Drawer, useMediaQuery, useTheme } from '@mui/material'\r\nimport { Component, FC, useEffect, useState } from 'react'\r\nimport { GlobalModal, IGlobalModalContext, mapGlobalModalContext } from 'dinocollab-core/api-context'\r\nimport NotificationsNoneIcon from '@mui/icons-material/NotificationsNone'\r\nimport { MenuStyled } from './styled'\r\nimport { IconButtonDark } from '../components/buttons'\r\nimport { FetchDataFunction, useFetchData } from './hook'\r\nimport { INotification, ReadFunction, FetchDetailFunction, INotificationPropsDef } from './types'\r\nimport NotifyList from './notify-list'\r\nimport NotifyDetail from './notify-detail'\r\n\r\ninterface INotificationProps extends INotificationPropsDef {\r\n loading?: boolean\r\n data: INotification[]\r\n fetchDetail?: FetchDetailFunction\r\n onAutoShowPopup?: (notification: INotification) => void\r\n isMobile?: boolean\r\n}\r\n\r\ninterface INotificationState {\r\n anchorEl: HTMLElement | null\r\n hydrated: boolean\r\n}\r\nclass NotificationContent extends Component<INotificationProps, INotificationState> {\r\n globalModalContext?: IGlobalModalContext\r\n constructor(props: INotificationProps) {\r\n super(props)\r\n this.state = { anchorEl: null, hydrated: false }\r\n }\r\n\r\n get notifications() {\r\n return this.props.data ?? []\r\n }\r\n\r\n get newFeatureCount() {\r\n return this.notifications.filter((n) => !n.IsRead).length\r\n }\r\n\r\n componentDidMount() {\r\n // When mounted on the client, set hydrated = true\r\n this.setState({ hydrated: true })\r\n }\r\n\r\n componentDidUpdate(prevProps: INotificationProps) {\r\n // Auto show popup notifications\r\n if (prevProps.data !== this.props.data && this.props.data.length > 0) {\r\n const popupNotifications = this.props.data.filter((n) => n.AreaType === 'Popup' && !n.IsRead)\r\n if (popupNotifications.length > 0) {\r\n // Delay to improve UX\r\n setTimeout(() => {\r\n this.props.onAutoShowPopup?.(popupNotifications[0])\r\n }, 1500)\r\n }\r\n }\r\n }\r\n\r\n render() {\r\n const isOpen = Boolean(this.state.anchorEl)\r\n\r\n return (\r\n <>\r\n <IconButtonDark onClick={(e) => this.onOpen(e.currentTarget)}>\r\n <Badge badgeContent={this.state.hydrated ? this.newFeatureCount : 0} color='error'>\r\n <NotificationsNoneIcon fontSize='small' />\r\n </Badge>\r\n </IconButtonDark>\r\n\r\n {this.props.isMobile ? (\r\n <Drawer\r\n anchor='right'\r\n open={isOpen}\r\n onClose={this.onClose}\r\n disableScrollLock\r\n PaperProps={{ sx: { width: 'calc(100% - 100px)', maxWidth: 360 } }}\r\n >\r\n {mapGlobalModalContext((context: IGlobalModalContext) => {\r\n this.globalModalContext = context\r\n return <NotifyList data={this.props.data} onClick={this.onClickHandler} />\r\n })}\r\n </Drawer>\r\n ) : (\r\n <MenuStyled\r\n disableScrollLock\r\n anchorEl={this.state.anchorEl}\r\n open={isOpen}\r\n onClose={this.onClose}\r\n anchorOrigin={{ vertical: 'top', horizontal: 'right' }}\r\n transformOrigin={{ vertical: 'top', horizontal: 'right' }}\r\n MenuListProps={{ component: 'div' }}\r\n >\r\n {mapGlobalModalContext((context: IGlobalModalContext) => {\r\n this.globalModalContext = context\r\n return <NotifyList data={this.props.data} onClick={this.onClickHandler} />\r\n })}\r\n </MenuStyled>\r\n )}\r\n </>\r\n )\r\n }\r\n\r\n onClickHandler = (value: INotification) => {\r\n this.onClose()\r\n this.globalModalContext?.show({\r\n backdropActivated: true,\r\n renderContent: () => (\r\n <NotifyDetail data={value} fetchDetail={this.props.fetchDetail} onRead={this.onReadHandler} onClose={this.globalModalContext?.close} />\r\n )\r\n })\r\n }\r\n\r\n onOpen = (target: HTMLElement) => {\r\n this.setState({ anchorEl: target })\r\n }\r\n\r\n onClose = () => {\r\n this.setState({ anchorEl: null })\r\n }\r\n\r\n onReadHandler: ReadFunction = async (id) => {\r\n this.globalModalContext?.close()\r\n // NotifyLocalStorage.setSingle(value.Id)\r\n try {\r\n // Call the callback to update the read state in the parent component\r\n this.props.onRead?.(id)\r\n } catch (error) {\r\n console.error('Error updating read state:', error)\r\n }\r\n }\r\n}\r\n\r\nexport interface INotificationWidgetProps {\r\n featData: FetchDataFunction<INotification[]>\r\n fetchDetail?: FetchDetailFunction\r\n onRead?: ReadFunction\r\n}\r\n\r\nexport const NotificationWidget: FC<INotificationWidgetProps> = (props) => {\r\n const intitialData = useFetchData<INotification[]>(props.featData)\r\n const [data, setData] = useState<INotification[]>([])\r\n const theme = useTheme()\r\n const isMobile = useMediaQuery(theme.breakpoints.down('sm'))\r\n\r\n // When initialData changes, update the local state\r\n useEffect(() => {\r\n if (intitialData.data) {\r\n const sortedData = [...intitialData.data].sort((a, b) => new Date(b.DateCreated).getTime() - new Date(a.DateCreated).getTime())\r\n setData(sortedData)\r\n }\r\n }, [intitialData.data])\r\n\r\n // Function to update read notifications\r\n const handleRead: ReadFunction = async (id: string, signal, options) => {\r\n await props.onRead?.(id, signal, options)\r\n setData((prev) => {\r\n const l = prev.map((n) => (n.Id === id ? { ...n, IsRead: true } : n))\r\n return l.sort((a, b) => new Date(b.DateCreated).getTime() - new Date(a.DateCreated).getTime())\r\n })\r\n }\r\n\r\n // Auto show popup notification\r\n const handleAutoShowPopup = (notification: INotification, context: IGlobalModalContext) => {\r\n context.show({\r\n backdropActivated: true,\r\n renderContent: () => (\r\n <NotifyDetail\r\n data={notification}\r\n fetchDetail={props.fetchDetail}\r\n onRead={async (id, s, o) => {\r\n context.close()\r\n await handleRead(id, s, o)\r\n }}\r\n onClose={context.close}\r\n />\r\n )\r\n })\r\n }\r\n\r\n return (\r\n <GlobalModal>\r\n {mapGlobalModalContext((context: IGlobalModalContext) => (\r\n <NotificationContent\r\n data={data}\r\n loading={intitialData.loading}\r\n fetchDetail={props.fetchDetail}\r\n onRead={handleRead}\r\n onAutoShowPopup={(x) => handleAutoShowPopup(x, context)}\r\n isMobile={isMobile}\r\n />\r\n ))}\r\n </GlobalModal>\r\n )\r\n}\r\nexport default NotificationWidget\r\n\r\nexport const createNotificationWidget = (params: INotificationWidgetProps) => {\r\n const _NotificationWidget: FC<Partial<INotificationWidgetProps>> = (props) => <NotificationWidget {...params} {...props} />\r\n _NotificationWidget.displayName = 'NotificationWidget'\r\n return _NotificationWidget\r\n}\r\n"],"names":["NotificationContent","props","_this","_classCallCheck","_callSuper","_defineProperty","value","_this$globalModalCont","onClose","globalModalContext","show","backdropActivated","renderContent","_this$globalModalCont2","_jsx","NotifyDetail","data","fetchDetail","onRead","onReadHandler","close","target","setState","anchorEl","_ref","_asyncToGenerator","_regenerator","m","_callee","id","_this$globalModalCont3","_this$props$onRead","_this$props","w","_context","n","call","error","console","a","_x","apply","this","arguments","state","hydrated","_inherits","Component","_createClass","key","get","_this$props$data","notifications","filter","IsRead","length","prevProps","_this2","popupNotifications","AreaType","setTimeout","_this2$props$onAutoSh","_this2$props","onAutoShowPopup","_this3","isOpen","Boolean","_jsxs","IconButtonDark","onClick","e","onOpen","currentTarget","children","Badge","badgeContent","newFeatureCount","color","NotificationsNoneIcon","fontSize","isMobile","Drawer","anchor","open","disableScrollLock","PaperProps","sx","width","maxWidth","mapGlobalModalContext","context","NotifyList","onClickHandler","MenuStyled","anchorOrigin","vertical","horizontal","transformOrigin","MenuListProps","component","NotificationWidget","intitialData","useFetchData","featData","_useState","useState","_useState2","_slicedToArray","setData","theme","useTheme","useMediaQuery","breakpoints","down","useEffect","sortedData","_toConsumableArray","sort","b","Date","DateCreated","getTime","handleRead","_ref2","_callee2","signal","options","_props$onRead","_context2","prev","map","Id","_objectSpread","_x2","_x3","_x4","GlobalModal","loading","x","notification","_onRead","_callee3","s","o","_context3","_x5","_x6","_x7","handleAutoShowPopup","createNotificationWidget","params","_NotificationWidget","displayName"],"mappings":"0yBAS0C,IAcpCA,aAEJ,SAAAA,EAAYC,GAAyB,IAAAC,EAEa,OAFbC,OAAAH,GACnCE,EAAAE,EAAAJ,KAAAA,GAAMC,IAAMI,EAAAH,EA0EG,iBAAA,SAACI,GAAwB,IAAAC,EACx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GAAS,EAE3H,OADAsJ,EAAoBC,YAAc,qBAC3BD,CACT"}
|
|
1
|
+
{"version":3,"file":"widget.js","sources":["../../src/notification/widget.tsx"],"sourcesContent":["import { Badge, Drawer, useMediaQuery, useTheme } from '@mui/material'\r\nimport { Component, FC, useEffect, useState } from 'react'\r\nimport { GlobalModal, IGlobalModalContext, mapGlobalModalContext } from 'dinocollab-core/api-context'\r\nimport NotificationsNoneIcon from '@mui/icons-material/NotificationsNone'\r\nimport { MenuStyled } from './styled'\r\nimport { IconButtonDark } from '../components/buttons'\r\nimport { FetchDataFunction, useFetchData } from './hook'\r\nimport { INotification, ReadFunction, FetchDetailFunction, INotificationPropsDef } from './types'\r\nimport NotifyList, { INotifyListSlots } from './notify-list'\r\nimport NotifyDetail from './notify-detail'\r\n\r\ninterface INotificationProps extends INotificationPropsDef {\r\n loading?: boolean\r\n data: INotification[]\r\n fetchDetail?: FetchDetailFunction\r\n onAutoShowPopup?: (notification: INotification) => void\r\n isMobile?: boolean\r\n notifyListSlots?: INotifyListSlots\r\n}\r\n\r\ninterface INotificationState {\r\n anchorEl: HTMLElement | null\r\n hydrated: boolean\r\n}\r\nclass NotificationContent extends Component<INotificationProps, INotificationState> {\r\n globalModalContext?: IGlobalModalContext\r\n constructor(props: INotificationProps) {\r\n super(props)\r\n this.state = { anchorEl: null, hydrated: false }\r\n }\r\n\r\n get notifications() {\r\n return this.props.data ?? []\r\n }\r\n\r\n get newFeatureCount() {\r\n return this.notifications.filter((n) => !n.IsRead).length\r\n }\r\n\r\n componentDidMount() {\r\n // When mounted on the client, set hydrated = true\r\n this.setState({ hydrated: true })\r\n }\r\n\r\n componentDidUpdate(prevProps: INotificationProps) {\r\n // Auto show popup notifications\r\n if (prevProps.data !== this.props.data && this.props.data.length > 0) {\r\n const popupNotifications = this.props.data.filter((n) => n.AreaType === 'Popup' && !n.IsRead)\r\n if (popupNotifications.length > 0) {\r\n // Delay to improve UX\r\n setTimeout(() => {\r\n this.props.onAutoShowPopup?.(popupNotifications[0])\r\n }, 1500)\r\n }\r\n }\r\n }\r\n\r\n render() {\r\n const isOpen = Boolean(this.state.anchorEl)\r\n\r\n return (\r\n <>\r\n <IconButtonDark onClick={(e) => this.onOpen(e.currentTarget)}>\r\n <Badge badgeContent={this.state.hydrated ? this.newFeatureCount : 0} color='error'>\r\n <NotificationsNoneIcon fontSize='small' />\r\n </Badge>\r\n </IconButtonDark>\r\n\r\n {this.props.isMobile ? (\r\n <Drawer\r\n anchor='right'\r\n open={isOpen}\r\n onClose={this.onClose}\r\n disableScrollLock\r\n PaperProps={{ sx: { width: 'calc(100% - 100px)', maxWidth: 360 } }}\r\n >\r\n {mapGlobalModalContext((context: IGlobalModalContext) => {\r\n this.globalModalContext = context\r\n return <NotifyList data={this.props.data} onClick={this.onClickHandler} onViewAllClick={this.onClose} {...this.props.notifyListSlots} />\r\n })}\r\n </Drawer>\r\n ) : (\r\n <MenuStyled\r\n disableScrollLock\r\n anchorEl={this.state.anchorEl}\r\n open={isOpen}\r\n onClose={this.onClose}\r\n anchorOrigin={{ vertical: 'top', horizontal: 'right' }}\r\n transformOrigin={{ vertical: 'top', horizontal: 'right' }}\r\n MenuListProps={{ component: 'div' }}\r\n >\r\n {mapGlobalModalContext((context: IGlobalModalContext) => {\r\n this.globalModalContext = context\r\n return <NotifyList data={this.props.data} onClick={this.onClickHandler} onViewAllClick={this.onClose} {...this.props.notifyListSlots} />\r\n })}\r\n </MenuStyled>\r\n )}\r\n </>\r\n )\r\n }\r\n\r\n onClickHandler = (value: INotification) => {\r\n this.onClose()\r\n this.globalModalContext?.show({\r\n backdropActivated: true,\r\n renderContent: () => (\r\n <NotifyDetail data={value} fetchDetail={this.props.fetchDetail} onRead={this.onReadHandler} onClose={this.globalModalContext?.close} />\r\n )\r\n })\r\n }\r\n\r\n onOpen = (target: HTMLElement) => {\r\n this.setState({ anchorEl: target })\r\n }\r\n\r\n onClose = () => {\r\n this.setState({ anchorEl: null })\r\n }\r\n\r\n onReadHandler: ReadFunction = async (id) => {\r\n this.globalModalContext?.close()\r\n // NotifyLocalStorage.setSingle(value.Id)\r\n try {\r\n // Call the callback to update the read state in the parent component\r\n this.props.onRead?.(id)\r\n } catch (error) {\r\n console.error('Error updating read state:', error)\r\n }\r\n }\r\n}\r\n\r\nexport interface INotificationWidgetProps {\r\n featData: FetchDataFunction<INotification[]>\r\n fetchDetail?: FetchDetailFunction\r\n onRead?: ReadFunction\r\n notifyListSlots?: INotifyListSlots\r\n}\r\n\r\nexport const NotificationWidget: FC<INotificationWidgetProps> = (props) => {\r\n const intitialData = useFetchData<INotification[]>(props.featData)\r\n const [data, setData] = useState<INotification[]>([])\r\n const theme = useTheme()\r\n const isMobile = useMediaQuery(theme.breakpoints.down('sm'))\r\n\r\n // When initialData changes, update the local state\r\n useEffect(() => {\r\n if (intitialData.data) {\r\n const sortedData = [...intitialData.data].sort((a, b) => new Date(b.DateCreated).getTime() - new Date(a.DateCreated).getTime())\r\n setData(sortedData)\r\n }\r\n }, [intitialData.data])\r\n\r\n // Function to update read notifications\r\n const handleRead: ReadFunction = async (id: string, signal, options) => {\r\n await props.onRead?.(id, signal, options)\r\n setData((prev) => {\r\n const l = prev.map((n) => (n.Id === id ? { ...n, IsRead: true } : n))\r\n return l.sort((a, b) => new Date(b.DateCreated).getTime() - new Date(a.DateCreated).getTime())\r\n })\r\n }\r\n\r\n // Auto show popup notification\r\n const handleAutoShowPopup = (notification: INotification, context: IGlobalModalContext) => {\r\n context.show({\r\n backdropActivated: true,\r\n renderContent: () => (\r\n <NotifyDetail\r\n data={notification}\r\n fetchDetail={props.fetchDetail}\r\n onRead={async (id, s, o) => {\r\n context.close()\r\n await handleRead(id, s, o)\r\n }}\r\n onClose={context.close}\r\n />\r\n )\r\n })\r\n }\r\n\r\n return (\r\n <GlobalModal>\r\n {mapGlobalModalContext((context: IGlobalModalContext) => (\r\n <NotificationContent\r\n data={data}\r\n loading={intitialData.loading}\r\n fetchDetail={props.fetchDetail}\r\n onRead={handleRead}\r\n onAutoShowPopup={(x) => handleAutoShowPopup(x, context)}\r\n isMobile={isMobile}\r\n notifyListSlots={props.notifyListSlots}\r\n />\r\n ))}\r\n </GlobalModal>\r\n )\r\n}\r\nexport default NotificationWidget\r\n\r\nexport const createNotificationWidget = (params: INotificationWidgetProps) => {\r\n const _NotificationWidget: FC<Partial<INotificationWidgetProps>> = (props) => <NotificationWidget {...params} {...props} />\r\n _NotificationWidget.displayName = 'NotificationWidget'\r\n return _NotificationWidget\r\n}\r\n"],"names":["NotificationContent","props","_this","_classCallCheck","_callSuper","_defineProperty","value","_this$globalModalCont","onClose","globalModalContext","show","backdropActivated","renderContent","_this$globalModalCont2","_jsx","NotifyDetail","data","fetchDetail","onRead","onReadHandler","close","target","setState","anchorEl","_ref","_asyncToGenerator","_regenerator","m","_callee","id","_this$globalModalCont3","_this$props$onRead","_this$props","w","_context","n","call","error","console","a","_x","apply","this","arguments","state","hydrated","_inherits","Component","_createClass","key","get","_this$props$data","notifications","filter","IsRead","length","prevProps","_this2","popupNotifications","AreaType","setTimeout","_this2$props$onAutoSh","_this2$props","onAutoShowPopup","_this3","isOpen","Boolean","_jsxs","IconButtonDark","onClick","e","onOpen","currentTarget","children","Badge","badgeContent","newFeatureCount","color","NotificationsNoneIcon","fontSize","isMobile","Drawer","anchor","open","disableScrollLock","PaperProps","sx","width","maxWidth","mapGlobalModalContext","context","NotifyList","_objectSpread","onClickHandler","onViewAllClick","notifyListSlots","MenuStyled","anchorOrigin","vertical","horizontal","transformOrigin","MenuListProps","component","NotificationWidget","intitialData","useFetchData","featData","_useState","useState","_useState2","_slicedToArray","setData","theme","useTheme","useMediaQuery","breakpoints","down","useEffect","sortedData","_toConsumableArray","sort","b","Date","DateCreated","getTime","handleRead","_ref2","_callee2","signal","options","_props$onRead","_context2","prev","map","Id","_x2","_x3","_x4","GlobalModal","loading","x","notification","_onRead","_callee3","s","o","_context3","_x5","_x6","_x7","handleAutoShowPopup","createNotificationWidget","params","_NotificationWidget","displayName"],"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C,EAAAC,GAAA,OAAAP,EAAArG,MAAAC,KAAAC,UAAA,GAINnC,QAASkF,EAAQtE,QAJX,IAAA0H,CAKN,GAGP,CAU+BQ,CAAoBV,EAAGlD,EAAQ,EACvDV,SAAUA,EACVe,gBAAiB9F,EAAM8F,iBAE1B,IAGP,EAGawD,EAA2B,SAACC,GACvC,IAAMC,EAA6D,SAACxJ,GAAK,OAAKa,EAACyF,EAAkBX,EAAAA,EAAA,CAAA,EAAK4D,GAAYvJ,GAAS,EAE3H,OADAwJ,EAAoBC,YAAc,qBAC3BD,CACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/auth/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/auth/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAE1E,cAAc,UAAU,CAAA;AAExB,cAAc,WAAW,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Component } from 'react';
|
|
2
2
|
import type { PropsWithChildren } from 'react';
|
|
3
|
-
import type {
|
|
3
|
+
import type { IMenuItems, IMenuItem, IProfile } from './types';
|
|
4
4
|
export declare const profileClasses: {
|
|
5
5
|
root: string;
|
|
6
6
|
title: string;
|
|
@@ -8,7 +8,7 @@ export declare const profileClasses: {
|
|
|
8
8
|
};
|
|
9
9
|
export interface IAvatarButtonProps extends PropsWithChildren {
|
|
10
10
|
profile: IProfile | null;
|
|
11
|
-
menuConfigs:
|
|
11
|
+
menuConfigs: IMenuItems;
|
|
12
12
|
theme?: 'dark' | 'light';
|
|
13
13
|
}
|
|
14
14
|
export interface IAvatarButtonState {
|
|
@@ -19,7 +19,7 @@ export declare class Profile extends Component<IAvatarButtonProps, IAvatarButton
|
|
|
19
19
|
constructor(props: IAvatarButtonProps);
|
|
20
20
|
toggle: () => void;
|
|
21
21
|
handleClick: (event: React.MouseEvent<HTMLElement>) => void;
|
|
22
|
-
handleMenuItemClick: (event: React.MouseEvent<HTMLAnchorElement | HTMLDivElement, MouseEvent>, menuConfig:
|
|
22
|
+
handleMenuItemClick: (event: React.MouseEvent<HTMLAnchorElement | HTMLDivElement, MouseEvent>, menuConfig: IMenuItem) => void;
|
|
23
23
|
handleClose: () => void;
|
|
24
24
|
render(): import("react/jsx-runtime").JSX.Element;
|
|
25
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile.d.ts","sourceRoot":"","sources":["../../../src/auth/profile.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAY,MAAM,OAAO,CAAA;AAC3C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAA;AAI9C,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"profile.d.ts","sourceRoot":"","sources":["../../../src/auth/profile.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAY,MAAM,OAAO,CAAA;AAC3C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAA;AAI9C,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAE9D,eAAO,MAAM,cAAc;;;;CAI1B,CAAA;AAMD,MAAM,WAAW,kBAAmB,SAAQ,iBAAiB;IAC3D,OAAO,EAAE,QAAQ,GAAG,IAAI,CAAA;IACxB,WAAW,EAAE,UAAU,CAAA;IACvB,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;CACzB;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,OAAO,CAAA;IACf,OAAO,EAAE,WAAW,GAAG,IAAI,CAAA;CAC5B;AAED,qBAAa,OAAQ,SAAQ,SAAS,CAAC,kBAAkB,EAAE,kBAAkB,CAAC;gBAChE,KAAK,EAAE,kBAAkB;IAQrC,MAAM,aAAsD;IAE5D,WAAW,UAAW,gBAAgB,CAAC,WAAW,CAAC,UAElD;IAED,mBAAmB,UAAW,gBAAgB,CAAC,iBAAiB,GAAG,cAAc,EAAE,UAAU,CAAC,cAAc,SAAS,UAKpH;IAED,WAAW,aAEV;IAED,MAAM;CAyDP;AAED,eAAe,OAAO,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/auth/service.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,SAAS,CAAC,EAAE,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/auth/service.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;CACjB;AAED,MAAM,WAAW,aAAa;IAC5B,aAAa,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IACnC,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IACvB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IACxB,OAAO,IAAI,OAAO,CAAC,aAAa,CAAC,CAAA;CAClC;AAoBD,qBAAa,WAAW;IACtB,MAAM,CAAC,YAAY,SAA0B;IAC7C,MAAM,KAAK,QAAQ,IAAI,aAAa,CAGnC;IACD,MAAM,CAAC,WAAW,CAAC,QAAQ,EAAE,aAAa;;IAS1C,aAAa;IAGb,MAAM;IAGN,OAAO;IAGP,OAAO;CAGR"}
|
|
@@ -9,7 +9,7 @@ export interface IAuthState {
|
|
|
9
9
|
isAuthenticated?: boolean;
|
|
10
10
|
isLoading?: boolean;
|
|
11
11
|
}
|
|
12
|
-
export interface
|
|
12
|
+
export interface IMenuItem {
|
|
13
13
|
title: string;
|
|
14
14
|
icon: ReactNode;
|
|
15
15
|
href?: string;
|
|
@@ -18,5 +18,5 @@ export interface IMenuConfig {
|
|
|
18
18
|
[key: string]: any;
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
|
-
export type
|
|
21
|
+
export type IMenuItems = IMenuItem[];
|
|
22
22
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/auth/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,MAAM,WAAW,QAAQ;IACvB,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,QAAQ,GAAG,IAAI,CAAA;IACxB,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB;AAED,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/auth/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,MAAM,WAAW,QAAQ;IACvB,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,QAAQ,GAAG,IAAI,CAAA;IACxB,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB;AAED,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,SAAS,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,iBAAiB,GAAG,cAAc,EAAE,UAAU,CAAC,KAAK,IAAI,CAAA;IAC3F,WAAW,CAAC,EAAE,QAAQ,GAAG;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAA;CAChD;AAED,MAAM,MAAM,UAAU,GAAG,SAAS,EAAE,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
2
|
import { ButtonProps } from '@mui/material';
|
|
3
3
|
import type { IAppSiteBaseUrl } from '../types';
|
|
4
|
-
import type { IAuthState,
|
|
4
|
+
import type { IAuthState, IMenuItems } from './types';
|
|
5
5
|
export interface IAuthBaseProps {
|
|
6
6
|
baseUrl: IAppSiteBaseUrl;
|
|
7
7
|
fontSizeScale?: number;
|
|
@@ -10,7 +10,7 @@ export interface IAuthBaseProps {
|
|
|
10
10
|
buttonLoginProps?: ButtonProps & {
|
|
11
11
|
[key: string]: any;
|
|
12
12
|
};
|
|
13
|
-
menu?:
|
|
13
|
+
menu?: IMenuItems;
|
|
14
14
|
}
|
|
15
15
|
export interface IAuthWidgetProps extends IAuthState, IAuthBaseProps {
|
|
16
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"widget.d.ts","sourceRoot":"","sources":["../../../src/auth/widget.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAW,MAAM,OAAO,CAAA;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAK3C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"widget.d.ts","sourceRoot":"","sources":["../../../src/auth/widget.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAW,MAAM,OAAO,CAAA;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAK3C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAGrD,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,eAAe,CAAA;IACxB,aAAa,CAAC,EAAE,MAAM,CAAA;IAEtB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,YAAY,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,iBAAiB,GAAG,cAAc,EAAE,UAAU,CAAC,KAAK,IAAI,CAAA;IAC5F,gBAAgB,CAAC,EAAE,WAAW,GAAG;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAA;IAEvD,IAAI,CAAC,EAAE,UAAU,CAAA;CAClB;AAED,MAAM,WAAW,gBAAiB,SAAQ,UAAU,EAAE,cAAc;CAAG;AAEvE,eAAO,MAAM,UAAU,EAAE,EAAE,CAAC,gBAAgB,CAuD3C,CAAA;AACD,eAAe,UAAU,CAAA;AAEzB,eAAO,MAAM,gBAAgB,WAAY,cAAc,0CAItD,CAAA"}
|
|
@@ -1,6 +1,15 @@
|
|
|
1
|
-
import { Component } from 'react';
|
|
1
|
+
import { Component, ComponentProps } from 'react';
|
|
2
|
+
import { Button } from '@mui/material';
|
|
2
3
|
import { INotification } from './types';
|
|
3
|
-
interface
|
|
4
|
+
export interface INotifyListSlots {
|
|
5
|
+
/** @default true */
|
|
6
|
+
enableViewAll?: boolean;
|
|
7
|
+
buttonViewAllProps?: ComponentProps<typeof Button> & {
|
|
8
|
+
[key: string]: any;
|
|
9
|
+
};
|
|
10
|
+
onViewAllClick?: () => void;
|
|
11
|
+
}
|
|
12
|
+
interface INotifyListProps extends INotifyListSlots {
|
|
4
13
|
data: INotification[];
|
|
5
14
|
onClick?: (value: INotification) => void;
|
|
6
15
|
isMobile?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notify-list.d.ts","sourceRoot":"","sources":["../../../src/notification/notify-list.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"notify-list.d.ts","sourceRoot":"","sources":["../../../src/notification/notify-list.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AACjD,OAAO,EAAc,MAAM,EAAsC,MAAM,eAAe,CAAA;AAGtF,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAKvC,MAAM,WAAW,gBAAgB;IAC/B,oBAAoB;IACpB,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,kBAAkB,CAAC,EAAE,cAAc,CAAC,OAAO,MAAM,CAAC,GAAG;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAA;IAC3E,cAAc,CAAC,EAAE,MAAM,IAAI,CAAA;CAC5B;AAED,UAAU,gBAAiB,SAAQ,gBAAgB;IACjD,IAAI,EAAE,aAAa,EAAE,CAAA;IACrB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAA;IACxC,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAED,cAAM,UAAW,SAAQ,SAAS,CAAC,gBAAgB,CAAC;IAClD,MAAM;IA4DN,UAAU,SAAU,aAAa,SAAS,MAAM,6CAoB/C;IAED,cAAc,iBAAkB,aAAa,UAI5C;IAED,cAAc,UAAW,MAAM,YAI9B;IAED,QAAQ,cAAe,OAAO,qBAE7B;CACF;AACD,eAAe,UAAU,CAAA"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
2
|
import { FetchDataFunction } from './hook';
|
|
3
3
|
import { INotification, ReadFunction, FetchDetailFunction } from './types';
|
|
4
|
+
import { INotifyListSlots } from './notify-list';
|
|
4
5
|
export interface INotificationWidgetProps {
|
|
5
6
|
featData: FetchDataFunction<INotification[]>;
|
|
6
7
|
fetchDetail?: FetchDetailFunction;
|
|
7
8
|
onRead?: ReadFunction;
|
|
9
|
+
notifyListSlots?: INotifyListSlots;
|
|
8
10
|
}
|
|
9
11
|
export declare const NotificationWidget: FC<INotificationWidgetProps>;
|
|
10
12
|
export default NotificationWidget;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"widget.d.ts","sourceRoot":"","sources":["../../../src/notification/widget.tsx"],"names":[],"mappings":"AACA,OAAO,EAAa,EAAE,EAAuB,MAAM,OAAO,CAAA;AAK1D,OAAO,EAAE,iBAAiB,EAAgB,MAAM,QAAQ,CAAA;AACxD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,mBAAmB,EAAyB,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"widget.d.ts","sourceRoot":"","sources":["../../../src/notification/widget.tsx"],"names":[],"mappings":"AACA,OAAO,EAAa,EAAE,EAAuB,MAAM,OAAO,CAAA;AAK1D,OAAO,EAAE,iBAAiB,EAAgB,MAAM,QAAQ,CAAA;AACxD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,mBAAmB,EAAyB,MAAM,SAAS,CAAA;AACjG,OAAmB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AA2H5D,MAAM,WAAW,wBAAwB;IACvC,QAAQ,EAAE,iBAAiB,CAAC,aAAa,EAAE,CAAC,CAAA;IAC5C,WAAW,CAAC,EAAE,mBAAmB,CAAA;IACjC,MAAM,CAAC,EAAE,YAAY,CAAA;IACrB,eAAe,CAAC,EAAE,gBAAgB,CAAA;CACnC;AAED,eAAO,MAAM,kBAAkB,EAAE,EAAE,CAAC,wBAAwB,CAwD3D,CAAA;AACD,eAAe,kBAAkB,CAAA;AAEjC,eAAO,MAAM,wBAAwB,WAAY,wBAAwB,0CAIxE,CAAA"}
|