@datawheel/bespoke 0.8.0-rc.2 → 0.8.0-rc.21

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/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Reports
2
2
 
3
-
4
3
  ## EnvVars
4
+
5
5
  ```
6
6
  # Bespoke
7
7
  REPORTS_DB_CONNECTION="postgres://user:@localhost:5432/database"
@@ -32,6 +32,8 @@ AUTH0_CLIENT_SECRET="xxxxxxxxxxx"
32
32
 
33
33
  # Timeout
34
34
  NEXT_PUBLIC_REPORTS_API_FETCH_TIMEOUT=100000
35
+
36
+ NEXT_PUBLIC_PDF_API_URL=[https://screenshots.datawheel.us/rest](https://screenshot-service-dev.datawheel.us/)
35
37
  ```
36
38
 
37
39
  ### Environmental variables into Bespoke Report scope
@@ -49,4 +51,4 @@ publicRuntimeConfig: {
49
51
  },
50
52
  ```
51
53
 
52
- And is gonna be offered as ENV_API and ENV_WHATEVER in the list of variables in the profile.
54
+ And is gonna be offered as ENV_API and ENV_WHATEVER in the list of variables in the profile.
package/dist/auth.js CHANGED
@@ -6,6 +6,6 @@ import { Menu, Button, Avatar, Text } from '@mantine/core';
6
6
  import { IconUserCircle, IconLogout, IconEdit } from '@tabler/icons-react';
7
7
  import H from 'next/link';
8
8
 
9
- function v(){let{update:s,data:i,status:t}=useSession();return {update:s,user:i?.user,status:t,isLoading:t==="loading"}}var f=v;function w(s){let{SuccessComponent:i,FailureComponent:t}=s,l=new Set(s.allowedRoles);return function(n){let{user:u,status:r}=f(),m=useRouter();if(useEffect(()=>{r==="unauthenticated"&&signIn();},[r,m]),r==="loading")return jsx("div",{children:"Loading..."});if(!u)return jsx(t,{...n});let U=u.bespoke_roles||[];return l.size===0||U.some(o=>l.has(o))?jsx(i,{user:u,...n}):jsx(t,{...n})}}var N=SessionProvider;var a={ADMIN:"Admin",EDITOR:"Editor",WRITER:"Writer"},b={APP:"App",USER:"User"},z=s=>{let i=Object.values(a);return s?s.map(t=>({...t,type:i.includes(t.name)?b.APP:b.USER})):[]};function $({buttonProps:s={},editorMenuItemProps:i={},editorMenuItemRoute:t="/cms",logoutButtonProps:l={},menuProps:R={},options:n="",optionsPosition:u="bottom",translations:r={},withEditorMenuItem:m=!0,withSession:U=!0}){let{user:o,isLoading:P}=f(),S=useMemo(()=>o?.bespoke_roles||[],[o]),k=useMemo(()=>a&&Object.keys(a).length>0&&Object.keys(a).some(x=>S.includes(a[x])),[S]),h={leftIcon:jsx(IconUserCircle,{}),...s};if(o&&!P){let x={...i},M={color:"red",fullWidth:!0,leftIcon:jsx(IconLogout,{size:14}),size:"xs",variant:"subtle",...l},T={shadow:"md",width:"auto",position:"bottom",...R},I=jsx(H,{href:t,passHref:!0,children:jsx(Menu.Item,{icon:jsx(IconEdit,{size:14}),...x,children:r["Go to editor"]||"Go to editor"})});return jsxs(Menu,{...T,children:[jsx(Menu.Target,{children:jsx(Button,{...h,children:`${r["Welcome message"]||`Hi, ${o.name||o.email}`}`})}),jsxs(Menu.Dropdown,{children:[u==="top"&&jsxs(Fragment,{children:[m&&k&&I,n,(n||m&&k)&&jsx(Menu.Divider,{})]}),U&&jsxs(Menu.Item,{component:"span",style:{pointerEvents:"none"},icon:jsx(Avatar,{src:o.picture,radius:"md"}),children:[jsx(Text,{size:"sm",weight:500,children:o.name}),jsx(Text,{color:"dimmed",size:"xs",children:o.email})]}),jsx(Button,{onClick:()=>signOut({callbackUrl:process.env.NEXT_PUBLIC_REPORTS_BASE_URL||"/"}),...M,children:r.Disconnect||"Disconnect"}),u==="bottom"&&jsxs(Fragment,{children:[(n||m&&k)&&jsx(Menu.Divider,{}),m&&k&&I,n]})]})]})}return jsx(Button,{onClick:()=>signIn(),loading:P,...h,children:P?r["Signing in"]||"Signing in...":r["Sign in"]||"Sign in"})}var X=$;
9
+ function v(o={required:!1}){let{update:i,data:s,status:a}=useSession(o);return {update:i,user:s?.user,status:a,isLoading:a==="loading"}}var f=v;function w(o){let{SuccessComponent:i,FailureComponent:s}=o,a=new Set(o.allowedRoles);return function(n){let{user:m,status:r}=f(),l=useRouter();if(useEffect(()=>{r==="unauthenticated"&&signIn();},[r,l]),r==="loading")return jsx("div",{children:"Loading..."});if(!m)return jsx(s,{...n});let P=m.bespoke_roles||[];return a.size===0||P.some(t=>a.has(t))?jsx(i,{user:m,...n}):jsx(s,{...n})}}var N=SessionProvider;var p={ADMIN:"Admin",EDITOR:"Editor",WRITER:"Writer"},b={APP:"App",USER:"User"},z=o=>{let i=Object.values(p);return o?o.map(s=>({...s,type:i.includes(s.name)?b.APP:b.USER})):[]};function $({buttonProps:o={},editorMenuItemProps:i={},editorMenuItemRoute:s="/cms",logoutButtonProps:a={},menuProps:U={},options:n="",optionsPosition:m="bottom",translations:r={},withEditorMenuItem:l=!0,withSession:P=!0}){let{user:t,isLoading:x}=f(),S=useMemo(()=>t?.bespoke_roles||[],[t]),k=useMemo(()=>p&&Object.keys(p).length>0&&Object.keys(p).some(y=>S.includes(p[y])),[S]),h={leftIcon:jsx(IconUserCircle,{}),...o};if(t&&!x){let y={...i},M={color:"red",fullWidth:!0,leftIcon:jsx(IconLogout,{size:14}),size:"xs",variant:"subtle",...a},T={shadow:"md",width:"auto",position:"bottom",...U},I=jsx(H,{href:s,passHref:!0,children:jsx(Menu.Item,{icon:jsx(IconEdit,{size:14}),...y,children:r["Go to editor"]||"Go to editor"})});return jsxs(Menu,{...T,children:[jsx(Menu.Target,{children:jsx(Button,{...h,children:`${r["Welcome message"]||`Hi, ${t.name||t.email}`}`})}),jsxs(Menu.Dropdown,{children:[m==="top"&&jsxs(Fragment,{children:[l&&k&&I,n,(n||l&&k)&&jsx(Menu.Divider,{})]}),P&&jsxs(Menu.Item,{component:"span",style:{pointerEvents:"none"},icon:jsx(Avatar,{src:t.picture,radius:"md"}),children:[jsx(Text,{size:"sm",weight:500,children:t.name}),jsx(Text,{color:"dimmed",size:"xs",children:t.email})]}),jsx(Button,{onClick:()=>signOut({callbackUrl:process.env.NEXT_PUBLIC_REPORTS_BASE_URL||"/"}),...M,children:r.Disconnect||"Disconnect"}),m==="bottom"&&jsxs(Fragment,{children:[(n||l&&k)&&jsx(Menu.Divider,{}),l&&k&&I,n]})]})]})}return jsx(Button,{onClick:()=>signIn(),loading:x,...h,children:x?r["Signing in"]||"Signing in...":r["Sign in"]||"Sign in"})}var X=$;
10
10
 
11
- export { X as BespokeLoginBtn, N as BespokeUserProvider, w as BespokeWithPageRoleAuthRequired, a as CMS_ROLES, z as addRoleTypes, f as useBespokeUser };
11
+ export { X as BespokeLoginBtn, N as BespokeUserProvider, w as BespokeWithPageRoleAuthRequired, p as CMS_ROLES, z as addRoleTypes, f as useBespokeUser };