@datawheel/bespoke 0.9.0 → 0.9.2
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 +2 -1
- package/dist/auth.js +1 -11
- package/dist/cms.js +36 -138
- package/dist/explore.js +9 -89
- package/dist/index.js +1 -7
- package/dist/redux-store.js +4 -31
- package/dist/report.js +12 -92
- package/dist/server.js +11 -57
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -16,9 +16,10 @@ NEXT_PUBLIC_IMAGE_SPLASH_WIDTH=1400
|
|
|
16
16
|
NEXT_PUBLIC_IMAGE_THUMB_WIDTH=400
|
|
17
17
|
|
|
18
18
|
# Providers
|
|
19
|
-
NEXT_PUBLIC_IMAGE_PROVIDERS="upload,local,flickr,unsplash,adobe"
|
|
19
|
+
NEXT_PUBLIC_IMAGE_PROVIDERS="upload,local,flickr,unsplash,adobe,pixabay"
|
|
20
20
|
FLICKR_API_KEY="xxxx"
|
|
21
21
|
UNSPLASH_API_KEY="xxxx"
|
|
22
|
+
PIXABAY_API_KEY="xxxx"
|
|
22
23
|
# unused ADOBE_STOCK_API_KEY="xxxx"
|
|
23
24
|
# unused ADOBE_STOCK_API_SECRET="xxxx"
|
|
24
25
|
# unused ADOBE_MANAGEMENT_API_KEY="xxxx"
|
package/dist/auth.js
CHANGED
|
@@ -1,11 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useEffect, useMemo } from 'react';
|
|
3
|
-
import { signIn, SessionProvider, useSession, signOut } from 'next-auth/react';
|
|
4
|
-
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
5
|
-
import { Menu, Button, Avatar, Text } from '@mantine/core';
|
|
6
|
-
import { IconUserCircle, IconLogout, IconEdit } from '@tabler/icons-react';
|
|
7
|
-
import $ from 'next/link';
|
|
8
|
-
|
|
9
|
-
function T(o={required:!1}){let{update:i,data:s,status:a}=useSession(o);return {update:i,user:s?.user,status:a,isLoading:a==="loading"}}var g=T;function w(o){let{SuccessComponent:i,FailureComponent:s}=o,a=new Set(o.allowedRoles);return function(n){let{user:m,status:r}=g(),l=useRouter();if(useEffect(()=>{r==="unauthenticated"&&signIn();},[r,l]),r==="loading")return jsx("div",{children:"Loading..."});if(!m)return jsx(s,{...n});let y=m.bespoke_roles||[];return a.size===0||y.some(t=>a.has(t))?jsx(i,{user:m,...n}):jsx(s,{...n})}}var N=SessionProvider;var p={ADMIN:"Admin",EDITOR:"Editor",WRITER:"Writer"},h={APP:"App",USER:"User"},z=o=>{let i=Object.values(p);return o?o.map(s=>({...s,type:i.includes(s.name)?h.APP:h.USER})):[]};function J({buttonProps:o={},editorMenuItemProps:i={},editorMenuItemRoute:s="/cms",logoutButtonProps:a={},menuProps:U={},options:n="",optionsPosition:m="bottom",translations:r={},withEditorMenuItem:l=!0,withSession:y=!0}){let{user:t,isLoading:P}=g(),b=useMemo(()=>t?.bespoke_roles||[],[t]),k=useMemo(()=>p&&Object.keys(p).length>0&&Object.keys(p).some(R=>b.includes(p[R])),[b]),x={leftIcon:jsx(IconUserCircle,{}),...o};if(t&&!P){let R={...i},M={color:"red",fullWidth:!0,leftIcon:jsx(IconLogout,{size:14}),size:"xs",variant:"subtle",...a},v={shadow:"md",width:"auto",position:"bottom",...U},I=jsx($,{href:s,passHref:!0,children:jsx(Menu.Item,{icon:jsx(IconEdit,{size:14}),...R,children:r["Go to editor"]||"Go to editor"})});return jsxs(Menu,{...v,children:[jsx(Menu.Target,{children:jsx(Button,{...x,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,{})]}),y&&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:P,...x,children:P?r["Signing in"]||"Signing in...":r["Sign in"]||"Sign in"})}var X=J;
|
|
10
|
-
|
|
11
|
-
export { X as BespokeLoginBtn, N as BespokeUserProvider, w as BespokeWithPageRoleAuthRequired, p as CMS_ROLES, z as addRoleTypes, g as useBespokeUser };
|
|
1
|
+
import {useRouter}from'next/router';import {useEffect,useMemo}from'react';import {SessionProvider,useSession,signIn,signOut}from'next-auth/react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {Menu,Button,Text,Avatar}from'@mantine/core';import {IconUserCircle,IconLogout,IconEdit}from'@tabler/icons-react';import $ from'next/link';function T(o={required:false}){let{update:i,data:s,status:a}=useSession(o);return {update:i,user:s?.user,status:a,isLoading:a==="loading"}}var g=T;function w(o){let{SuccessComponent:i,FailureComponent:s}=o,a=new Set(o.allowedRoles);return function(n){let{user:m,status:r}=g(),l=useRouter();if(useEffect(()=>{r==="unauthenticated"&&signIn();},[r,l]),r==="loading")return jsx("div",{children:"Loading..."});if(!m)return jsx(s,{...n});let y=m.bespoke_roles||[];return a.size===0||y.some(t=>a.has(t))?jsx(i,{user:m,...n}):jsx(s,{...n})}}var N=SessionProvider;var p={ADMIN:"Admin",EDITOR:"Editor",WRITER:"Writer"},h={APP:"App",USER:"User"},z=o=>{let i=Object.values(p);return o?o.map(s=>({...s,type:i.includes(s.name)?h.APP:h.USER})):[]};function J({buttonProps:o={},editorMenuItemProps:i={},editorMenuItemRoute:s="/cms",logoutButtonProps:a={},menuProps:U={},options:n="",optionsPosition:m="bottom",translations:r={},withEditorMenuItem:l=true,withSession:y=true}){let{user:t,isLoading:P}=g(),b=useMemo(()=>t?.bespoke_roles||[],[t]),k=useMemo(()=>p&&Object.keys(p).length>0&&Object.keys(p).some(R=>b.includes(p[R])),[b]),x={leftIcon:jsx(IconUserCircle,{}),...o};if(t&&!P){let R={...i},M={color:"red",fullWidth:true,leftIcon:jsx(IconLogout,{size:14}),size:"xs",variant:"subtle",...a},v={shadow:"md",width:"auto",position:"bottom",...U},I=jsx($,{href:s,passHref:true,children:jsx(Menu.Item,{icon:jsx(IconEdit,{size:14}),...R,children:r["Go to editor"]||"Go to editor"})});return jsxs(Menu,{...v,children:[jsx(Menu.Target,{children:jsx(Button,{...x,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,{})]}),y&&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:P,...x,children:P?r["Signing in"]||"Signing in...":r["Sign in"]||"Sign in"})}var X=J;export{X as BespokeLoginBtn,N as BespokeUserProvider,w as BespokeWithPageRoleAuthRequired,p as CMS_ROLES,z as addRoleTypes,g as useBespokeUser};
|