@datawheel/bespoke 1.0.0-beta.2 → 1.0.0-beta.5
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.css +1 -0
- package/dist/auth.js +1 -1
- package/dist/cms.css +1 -1
- package/dist/cms.js +32 -32
- package/dist/explore.css +1 -1
- package/dist/explore.js +7 -7
- package/dist/report.css +1 -1
- package/dist/report.js +11 -11
- package/package.json +1 -1
package/dist/auth.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.e{pointer-events:none}
|
package/dist/auth.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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
|
|
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 X from'next/link';function O(o={required:false}){let{update:i,data:s,status:a}=useSession(o);return {update:i,user:s?.user,status:a,isLoading:a==="loading"}}var f=O;function N(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 y=m.bespoke_roles||[];return a.size===0||y.some(t=>a.has(t))?jsx(i,{user:m,...n}):jsx(s,{...n})}}var z=SessionProvider;var p={ADMIN:"Admin",EDITOR:"Editor",WRITER:"Writer"},h={APP:"App",USER:"User"},V=o=>{let i=Object.values(p);return o?o.map(s=>({...s,type:i.includes(s.name)?h.APP:h.USER})):[]};var _={sessionItem:"e"};function Y({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:S}=f(),b=useMemo(()=>t?.bespoke_roles||[],[t]),k=useMemo(()=>p&&Object.keys(p).length>0&&Object.keys(p).some(P=>b.includes(p[P])),[b]),x={leftSection:jsx(IconUserCircle,{}),...o};if(t&&!S){let P={...i},v={color:"red",fullWidth:true,leftSection:jsx(IconLogout,{size:14}),size:"xs",variant:"subtle",...a},A={shadow:"md",width:"auto",position:"bottom",...U},I=jsx(X,{href:s,passHref:true,children:jsx(Menu.Item,{leftSection:jsx(IconEdit,{size:14}),...P,children:r["Go to editor"]||"Go to editor"})});return jsxs(Menu,{...A,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",className:_.sessionItem,leftSection:jsx(Avatar,{src:t.picture,radius:"md"}),children:[jsx(Text,{size:"sm",fw:500,children:t.name}),jsx(Text,{c:"dimmed",size:"xs",children:t.email})]}),jsx(Button,{onClick:()=>signOut({callbackUrl:process.env.NEXT_PUBLIC_REPORTS_BASE_URL||"/"}),...v,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:S,...x,children:S?r["Signing in"]||"Signing in...":r["Sign in"]||"Sign in"})}var K=Y;export{K as BespokeLoginBtn,z as BespokeUserProvider,N as BespokeWithPageRoleAuthRequired,p as CMS_ROLES,V as addRoleTypes,f as useBespokeUser};
|
package/dist/cms.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.
|
|
1
|
+
.J{z-index:99;overflow:hidden;transition:width .3s;box-shadow:0 4px 15px 5px #0000000d}.K{flex:1}.L{flex-grow:1}.b{display:block;width:100%}.b:hover{background-color:var(--mantine-color-gray-2)!important;transition:background-color .2s}.M{flex-shrink:0}.N{border:none;background-color:var(--mantine-color-blue-0);border-radius:var(--mantine-radius-sm);color:var(--mantine-color-blue-7);font-size:.75rem;font-weight:700;width:80px}.O{font-size:.75rem}.P{pointer-events:none}.Q{max-width:100px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.m.u{font-size:11px;padding:0}.m.u .R{background-color:transparent!important;padding:0}.a .S{border-bottom:0}.a .T{padding:2px}.a .U{padding:0}.a .V{margin-right:4px}.W{border-top-right-radius:0;border-bottom-right-radius:0}.X{border-top-left-radius:0;border-bottom-left-radius:0;border-left:1px solid #fff;background-color:#e7f5ff;min-height:1.875rem;height:1.875rem;width:1.875rem;font-size:.75rem}.Z:hover{background-color:#ebebeb}.v{box-sizing:border-box;z-index:99;transition:right .4s;overflow:hidden;background:#f1f3f5}.v[data-dragging-over=true]{background:#e7f5ff}.n{transition:background-color .45s}.n .w{opacity:0;transition:opacity .45s}.n:hover{background-color:#e9ecefe6!important}.n:hover .w{opacity:1}.y{border:none;border-radius:2px}.y[data-active=true]{border:1px solid #74c0fc}.o{background:inherit;border:1px solid transparent}.o[data-dragging-over=true]{background:#e7f5ff}.o .k{visibility:hidden}.o:hover .k{visibility:visible}.o:hover{border:1px solid #96f2d7}.l{border:1px solid transparent;resize:horizontal}.l:hover{border:1px solid transparent}.l[data-show-outline=true]:hover{border:1px solid var(--mantine-color-blue-2)}.l[data-show-outline=true]:hover:before{position:absolute;top:0;left:0;font-size:8px;color:var(--mantine-color-blue-5);transform:translateY(-100%);content:attr(data-block-label);width:-moz-fit-content;width:fit-content}._{height:100%}.d{position:"absolute";top:"50%";z-index:10;opacity:.55}.d:hover{opacity:1}.d[data-direction=left]{left:16px}.d[data-direction=right]{right:16px}.ee{table-layout:fixed}.re{min-height:100px;max-height:350px;overflow-x:"auto";background:red}.oe{padding:5px!important;text-wrap:wrap}.z{display:block}@media(min-width:1000px){.z{display:none}}.te{width:450px}.ie{min-height:36px}.j{display:none}@media(min-width:1000px){.j{display:block}}.ae{cursor:pointer}.ne{width:100%}.le{cursor:pointer}.de{display:flex;align-items:center}.se{cursor:pointer;width:100%}.pe{align-items:center;border-radius:var(--mantine-radius-sm);cursor:default;display:flex;font-size:.75rem;font-weight:500;height:1.375rem;margin:calc(var(--mantine-spacing-xs) / 2 - .125rem) calc(var(--mantine-spacing-xs) / 2);max-width:calc(100% - .625rem);padding-left:calc(var(--mantine-spacing-sm) / 1.5);padding-right:0;-webkit-user-select:none;-moz-user-select:none;user-select:none}.ge{background-color:var(--mantine-color-dark-7);color:var(--mantine-color-dark-0)}.fe{background-color:var(--mantine-color-gray-1);color:var(--mantine-color-gray-7)}.he{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.xe{margin-left:calc(var(--mantine-spacing-sm) / 6)}.be{color:var(--mantine-color-dark-0)}.me{color:var(--mantine-color-gray-7)}.ue{position:relative}.ve{background-color:var(--mantine-color-dark-5);color:var(--mantine-color-dark-1)}.we{background-color:var(--mantine-color-gray-3);color:var(--mantine-color-gray-7)}.ye{overflow:hidden}.c{align-items:center;box-sizing:border-box;display:flex;flex-wrap:wrap;margin-left:calc(-var(--mantine-spacing-xs)/2);min-height:2.125rem}.c[data-clearable]{margin-right:2.25rem}.c::-moz-placeholder{opacity:1}.c::placeholder{opacity:1}.ke{color:var(--mantine-color-dark-3)}.ze{color:var(--mantine-color-gray-5)}.je{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:transparent;border:0;color:inherit;flex:1;font-size:var(--mantine-font-size-sm);margin-left:calc(var(--mantine-spacing-xs) / 2);max-height:1.375rem;min-width:3.75rem;outline:0;padding:0}.Ye{display:flex;max-height:18.75rem}.qe{width:100%}.Ae{overflow:auto;width:100%}.Be{position:relative;width:100%}.f{border-radius:var(--mantine-radius-xs);padding:15px 5px;position:absolute;left:0;top:0;width:100%}.f[data-hovered],.f:hover{background-color:var(--mantine-color-gray-1)}.Y[data-hovered],.Y:hover{background-color:var(--mantine-color-dark-4)}.Ce{transition:transform .2s}.De{transform:rotate(-180deg)}.Fe{justify-self:flex-start}.Ge{justify-self:center}.He{justify-self:flex-end}.Ie{display:flex;min-height:400px}.Je{display:flex}.Ke{flex:1}.chart{flex:1 1 100%}.Le{flex-grow:1;max-width:calc(100% - 38px)}.q{overflow-x:auto;scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;flex-wrap:nowrap}.q::-webkit-scrollbar{display:none}.Me{flex-wrap:nowrap;width:-moz-fit-content;width:fit-content}.h{height:100%;z-index:1;top:0;width:50px;position:absolute;background-size:cover;display:flex;align-items:center}.h[data-direction=left]{background:linear-gradient(to right,#fff 15px,#fff0);left:0;justify-content:flex-start}.h[data-direction=right]{background:linear-gradient(to left,#fff 15px,#fff0);right:0;justify-content:flex-end}.Ne{border-radius:4px;transform:translate(-50%);z-index:20}.A{flex-direction:column}@media(min-width:62em){.A{flex-direction:row}}.B{max-width:100%;min-width:unset}@media(min-width:62em){.B{max-width:var(--column-max-width);min-width:300px}}.Oe:hover .C{visibility:visible;opacity:1}.C{visibility:hidden;opacity:0;transition:visibility 0s,opacity .2s ease-in-out}.Pe{flex-grow:1}.Qe{z-index:20}.Re{position:relative;border-radius:0}.Se{background-color:transparent}.Te{position:sticky;z-index:2;top:0;border-radius:0}.Ue{border-top:none;border-left:none;border-right:none}.Ve{page-break-before:always}.We,.Xe{z-index:1}.Ze{box-shadow:initial}._e{box-shadow:none}.D{position:relative}.D:before{content:"";position:absolute;top:.25rem;bottom:.25rem;left:calc(.875rem + var(--level) * 1.5rem);width:.0625rem;background-color:#dee2e6;z-index:0}.er,.rr{visibility:hidden}.or{flex:1}.tr{max-height:400px;overflow-y:auto}.ir{word-wrap:break-word;white-space:normal}.ar{box-shadow:0 2px 6px #0000001a;border-radius:.25rem;background:#fff}.nr{width:100%;box-shadow:0 -2px 6px #0000001a}.lr{width:auto;box-shadow:0 2px 6px #0000001a}.s{display:flex;gap:1rem;align-items:center;list-style-type:none}.s[data-align=left]{justify-content:flex-start}.s[data-align=center]{justify-content:center}.s[data-align=right]{justify-content:flex-end}.t{display:flex}.t[data-align=left]{justify-content:flex-start}.t[data-align=center]{justify-content:center}.t[data-align=right]{justify-content:flex-end}.t li{margin-right:1rem}.E{display:flex}.E .chart{flex:1 1 100%}.dr{width:60px}.cr:after{content:" *";color:red}.F{background-color:transparent}.F[data-selected=true]{background-color:#e7f5ff}.i{font-size:14px;line-height:1.2;background-color:var(--mantine-color-gray-0);border-color:var(--mantine-color-gray-4);border-width:1px;border-style:solid;border-radius:var(--mantine-radius-md);padding-left:var(--mantine-spacing-xs);padding-right:var(--mantine-spacing-xs);font-weight:400}.i.sr{color:var(--mantine-color-gray-7);background-color:var(--mantine-color-gray-1)}.i:focus-visible{outline-color:var(--mantine-color-blue-5);background-color:var(--mantine-color-gray-0)}.i code{font-family:monospace;color:var(--mantine-color-blue-6);font-weight:700;letter-spacing:.02em}.i .pr:first-of-type:before{color:var(--mantine-color-gray-6);content:attr(data-placeholder);float:left;height:0;pointer-events:none}.gr{align-items:stretch;margin:0;position:relative}.fr{display:flex;flex-direction:column}.hr{position:absolute;right:0;top:0}.xr{flex-grow:1;display:flex;flex-direction:column}.br{flex-grow:1}.mr{align-self:stretch;display:flex;flex-direction:column;height:100%;position:relative}.ur{align-self:stretch;display:flex;flex-direction:column;height:100%;border-left:2px solid var(--mantine-color-gray-0)}.vr{display:flex;flex-direction:column;border-left:2px solid var(--mantine-color-gray-0)}.wr~.yr{min-height:calc(100vh - 50px)}.x{height:0}.x button{background-color:#fff;opacity:0;transition:opacity .1s;z-index:2}.r:hover>.x button{opacity:1}.r:hover .G,.r:hover .kr,.G.zr{opacity:1}.r:hover .H,.r.jr .H{opacity:.4}.r .Yr{min-height:20px}.qr{max-height:90vw}.Ar pre{font-size:12px;line-height:1.25}.Br{overflow:hidden;border-right:1px solid #dee2e6;flex-shrink:0;flex-grow:0}.I{border:1px solid transparent;cursor:default}.I:hover{border:1px solid blue}.p{cursor:default;border:1px solid transparent}.p .Cr{color:var(--section-color)}.p[data-active=true]{border:1px solid #dee2e6}.p:hover{border:1px solid #339af0}.Dr{overflow:hidden;border-left:1px solid #dee2e6;flex-shrink:0;flex-grow:0}.g{backdrop-filter:none;opacity:0}.g button{display:none}.g:hover{opacity:1;backdrop-filter:blur(.2375rem)}.g:hover button{display:flex}
|