Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@entur-partner/common

Package Overview
Dependencies
Maintainers
2
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@entur-partner/common - npm Package Compare versions

Comparing version 0.0.9 to 0.0.10

dist/PermissionCheck.d.ts

26

dist/common.cjs.development.js

@@ -608,2 +608,27 @@ 'use strict';

function checkPermission(permission1, permission2) {
return permission1.access === permission2.access && permission1.operation === permission2.operation;
}
function hasPermissions(permissions, requiredPermission) {
return permissions.find(userPermission => checkPermission(requiredPermission, userPermission)) !== undefined;
}
const PermissionCheck = ({
children,
fallback = null,
permissions,
oneOf = [],
all = []
}) => {
if (!Array.isArray(all)) {
all = [all];
}
const allIsAllowed = all.every(requiredPermission => hasPermissions(permissions, requiredPermission));
const oneOfIsAllowed = oneOf.length > 0 ? oneOf.some(requiredPermission => hasPermissions(permissions, requiredPermission)) : true;
const allowed = allIsAllowed && oneOfIsAllowed;
return React__default.createElement(React__default.Fragment, null, allowed ? children : fallback);
};
const Breadcrumbs = ({

@@ -660,2 +685,3 @@ pathname,

exports.Pager = Pager;
exports.PermissionCheck = PermissionCheck;
exports.RouteLeavingGuard = RouteLeavingGuard;

@@ -662,0 +688,0 @@ exports.Stack = Stack;

2

dist/common.cjs.production.min.js

@@ -1,2 +0,2 @@

"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),a=e(t),n=e(require("classnames")),r=require("@entur/typography"),l=require("@entur/tooltip"),s=require("@entur/icons"),o=require("@entur/button"),c=require("@entur/form"),i=require("@entur/dropdown"),m=require("@entur-partner/util"),u=require("@entur/modal"),p=require("react-router-dom"),d=require("@entur/menu");const g=({as:e="div",children:t,paddingTop:r,paddingRight:l,paddingBottom:s,paddingLeft:o,paddingX:c,paddingY:i,padding:m,marginTop:u,marginRight:p,marginBottom:d,marginLeft:g,marginX:h,marginY:v,margin:E,className:b})=>{const N=[],f=r||i||m,x=s||i||m,C=o||c||m,L=l||c||m,B=u||v||E,S=d||v||E,F=g||h||E,_=p||h||E;f&&N.push(`eps-pt-${f}`),x&&N.push(`eps-pb-${x}`),C&&N.push(`eps-pl-${C}`),L&&N.push(`eps-pr-${L}`),B&&N.push(`eps-mt-${B}`),S&&N.push(`eps-mb-${S}`),F&&N.push(`eps-ml-${F}`),_&&N.push(`eps-mr-${_}`);const y=n(["eps-box",N,b]);return a.createElement(e,{className:y},t)},h=({children:e,space:n,className:r})=>{const l=t.Children.toArray(e);return l.length<=1?a.createElement(a.Fragment,null,l):a.createElement("div",{className:r},l.map((e,t)=>t===l.length-1?a.createElement("div",{key:t},e):a.createElement(g,{paddingBottom:n,key:t},e)))};function v(e){var t,a;return"true"===process.env[`REACT_APP_${e}`]||"true"===(null===(t=window.localStorage)||void 0===t?void 0:t.getItem(e))||"true"===(null===(a=window.localStorage)||void 0===a?void 0:a.getItem(`REACT_APP_${e}`))}const E=({title:e,...t})=>a.createElement("svg",Object.assign({width:257,height:37,viewBox:"0 0 257 37"},t),a.createElement("title",null,e),a.createElement("g",{fill:"none",fillRule:"evenodd"},a.createElement("path",{fill:"#FFF",d:"M0 .231V25.72h18.745v-4.318H4.869v-6.163h12.31v-4.318H4.87V4.55h13.876V.231z"}),a.createElement("path",{fill:"#FF5959",d:"M0 36.408h45.253v-4.32H0z"}),a.createElement("path",{fill:"#FFF",d:"M40.384.231v15.425L23.656.231h-.521V25.72h4.869V10.573L44.732 25.72h.521V.23zM69.25 15.238h-7.267v21.17h-4.87v-21.17H49.81V10.92h19.44zM83.863 36.86c-1.646 0-3.142-.255-4.486-.765-1.345-.51-2.493-1.23-3.443-2.159-.95-.928-1.687-2.054-2.208-3.378-.522-1.323-.783-2.797-.783-4.422V10.92h4.869v15.216c0 1.277.209 2.333.626 3.169.417.836.933 1.497 1.548 1.985a5.346 5.346 0 001.982 1.01c.707.186 1.339.278 1.895.278.557 0 1.188-.092 1.896-.279a5.35 5.35 0 001.982-1.01c.614-.487 1.13-1.148 1.548-1.984.417-.836.625-1.892.625-3.169V10.92h4.87v15.216c0 1.625-.256 3.1-.766 4.422-.51 1.324-1.24 2.45-2.19 3.378-.952.929-2.1 1.648-3.444 2.159-1.344.51-2.851.766-4.52.766M104.21 24.047h5.546c1.016 0 1.854-.127 2.513-.383.658-.255 1.179-.592 1.56-1.01.381-.418.641-.888.78-1.41.138-.522.208-1.05.208-1.584 0-.627-.099-1.207-.295-1.741a3.718 3.718 0 00-.901-1.393c-.405-.394-.924-.708-1.56-.94-.636-.232-1.404-.348-2.305-.348h-5.546v8.81zm0 4.248v8.113h-4.87V10.92h11.567c1.3 0 2.49.215 3.57.644 1.08.43 2.004 1.033 2.77 1.81a8.287 8.287 0 011.794 2.787c.43 1.079.645 2.257.645 3.534 0 .952-.128 1.874-.383 2.768-.256.894-.61 1.7-1.063 2.42a7.32 7.32 0 01-1.672 1.863 5.929 5.929 0 01-2.178 1.096l6.339 8.566h-5.808l-5.893-8.113h-4.818z"}),a.createElement("g",{fill:"#FF5959"},a.createElement("path",{d:"M141.051 23.448h5.628c4.185 0 5.989-1.984 5.989-4.942 0-2.742-1.515-4.618-5.989-4.618h-5.628v9.56zm0 3.067v9.776h-3.571V10.75h9.632c6.674 0 9.127 3.211 9.127 7.54 0 4.979-3.102 8.226-9.2 8.226h-5.988zM169.695 28.715c-1.371-.288-2.958-.505-4.401-.505-2.85 0-4.041 1.263-4.041 3.139s1.407 2.706 3.463 2.706c2.49 0 4.979-1.443 4.979-4.221v-1.119zm-4.293-2.958c1.551 0 3.174.253 4.293.469v-.83c0-2.525-1.154-3.896-4.33-3.896-2.164 0-3.824.866-4.942 2.092l-2.02-2.272c1.732-1.66 3.644-2.598 7.07-2.598 5.052 0 7.469 1.876 7.469 7.215v10.354h-3.211V34.02h-.108c-1.082 1.767-3.211 2.705-5.592 2.705-3.32 0-6.241-1.66-6.241-5.303 0-3.103 1.912-5.664 7.612-5.664zM178.965 19.191h3.211v2.886h.108c.938-1.984 2.922-3.355 5.231-3.355.47 0 .938.036 1.335.144l-.144 3.14a6.77 6.77 0 00-1.552-.181c-3.246 0-4.798 2.633-4.798 5.483v8.983h-3.39v-17.1zM199.961 36.291h-1.912c-4.004 0-5.988-.938-5.988-5.772v-8.55h-2.778V19.19h2.778v-4.654h3.355v4.654h4.473v2.778h-4.473v7.973c0 3.427 1.587 3.535 3.319 3.535h1.226v2.814zM219.767 36.291h-3.391V26.84c0-2.778-1.083-5.375-4.257-5.375-3.14 0-5.268 2.597-5.268 6.169v8.658h-3.391v-17.1h3.32v2.814h.143c.794-1.623 3.067-3.283 5.99-3.283 4.941 0 6.854 3.644 6.854 8.081v9.488zM227.847 26.262h10.57c0-2.597-2.272-4.726-5.087-4.726-2.922 0-5.014 1.948-5.483 4.726zm-.036 2.453c.397 3.355 2.633 5.195 5.844 5.195 2.778 0 4.618-1.623 5.484-2.67l2.164 1.804c-1.37 1.913-4.365 3.716-8.045 3.716-4.942 0-8.73-3.535-8.73-8.55 0-5.195 3.752-9.488 8.983-9.488 5.303 0 8.009 4.365 8.009 8.19 0 .649-.036 1.226-.072 1.803H227.81zM246.245 19.191h3.21v2.886h.109c.938-1.984 2.922-3.355 5.231-3.355.469 0 .938.036 1.335.144l-.145 3.14a6.77 6.77 0 00-1.551-.181c-3.247 0-4.798 2.633-4.798 5.483v8.983h-3.391v-17.1z"})))),b=({children:e,className:t})=>{const r=n(["eps-user-menu__item",t]);return a.createElement("div",{className:r},e)},N=({language:e,options:t,className:r,onChange:l,...s})=>{const o=n("eps-language-select",r);return a.createElement("div",Object.assign({},s,{className:o}),a.createElement(c.SegmentedControl,{onChange:e=>{m.assertIsDefined(e),l(e)},selectedValue:e},t.map(e=>a.createElement(c.SegmentedChoice,{key:e.value,value:e.value},e.label,e.required&&a.createElement("span",{className:"asterisk-margin"},"*")))))},f=({date:e,locale:t,as:n="main",hideTime:r,...l})=>a.createElement(n,Object.assign({},l),r?m.localeDate(e,t):m.localeDateTime(e,t)),x=({isOpen:e=!1,children:t,message:n,size:l="medium",buttons:s,onConfirm:c,messages:i,onClose:p,onDismiss:d,...h})=>{const v=t||n,E=p||d;return a.createElement(u.Modal,Object.assign({size:l,open:e,onDismiss:E},h),m.isString(v)?a.createElement(r.Paragraph,null,v):a.createElement(g,{paddingBottom:"medium"},v),a.createElement(o.ButtonGroup,null,c?a.createElement(a.Fragment,null,a.createElement(o.SecondaryButton,{onClick:E,"data-testid":"cancel-modal-button"},i.cancel),a.createElement(o.PrimaryButton,{onClick:c,"data-testid":"confirm-modal-button"},i.confirm)):s))};exports.ActionBar=({children:e})=>a.createElement(a.Fragment,null,a.createElement("div",{className:"eps-action-bar-padding"}),a.createElement("div",{className:"eps-action-bar"},e)),exports.ActionBarLeft=({children:e})=>a.createElement("div",{className:"eps-action-bar-left"},e),exports.ActionBarRight=({children:e})=>a.createElement("div",{className:"eps-action-bar-right"},e),exports.AuditInfo=({items:e,locale:t,className:r,...l})=>{const s=n("ep-audit-info",r);return a.createElement("div",Object.assign({className:s},l),e.map(({label:e,value:n},r)=>a.createElement(h,{space:"small",key:r},a.createElement("div",{className:"ep-audit-info-label"},e),a.createElement("div",null,m.isDate(n)||m.isDateString(n)?a.createElement(f,{date:n,locale:t}):a.createElement("span",null,n)))))},exports.Box=g,exports.Breadcrumbs=({pathname:e,onBreadcrumbLookup:t})=>{const n="/"===e?[]:["/"];(e.length>1?e.replace(/\/$/,""):e).split("/").reduce((e,t)=>{const a=`${e}/${t}`;return n.push(a),a});const r=n.map(e=>({title:t(e),path:e})).filter(({title:e})=>void 0!==e);return a.createElement(d.BreadcrumbNavigation,null,r.map(({title:e,path:t},n)=>a.createElement(d.BreadcrumbItem,{key:t,as:n===r.length-1?"span":p.Link,to:t},e)))},exports.ConfirmModal=x,exports.Content=({as:e="main",className:t,children:r})=>{const l=n(["eps-content",t]);return a.createElement(e,{className:l},r)},exports.EnturPartnerLogo=({as:e="nav",className:t,altText:r})=>{const l=n(["eps-logo-wrapper",t]);return a.createElement(e,{className:l},a.createElement(E,{title:r,className:"logo"}))},exports.EnturPartnerLogoSvg=E,exports.ErrorBoundary=class extends t.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e){var t,a;null===(t=(a=this.props).handleError)||void 0===t||t.call(a,e)}render(){const{error:e}=this.state,{fallback:t,children:a}=this.props;return e?(n=t)&&"[object Function]"==={}.toString.call(n)?t({retry:()=>this.setState({error:null}),error:e}):t:a;var n}},exports.FeatureToggle=({children:e,flag:t})=>v(t)?a.createElement(a.Fragment,null,e):null,exports.FormatCurrencyAmount=({amount:e,as:t="span",...n})=>{const r=Number(e)||0,l=new Intl.NumberFormat("nb-NO",{maximumFractionDigits:2,minimumFractionDigits:2}).format(r);return a.createElement(t,Object.assign({},n),l)},exports.FormatDateTime=f,exports.LanguageSelect=N,exports.LinkButton=({children:e,className:t,...l})=>a.createElement(r.Link,Object.assign({},l,{as:"button",className:n("eps-link-button",t)}),e),exports.Menu=({as:e="nav",className:t,children:r})=>{const l=n(["eds-contrast","eps-menu",t]);return a.createElement(e,{className:l},r)},exports.MultiLanguageInput=({className:e,inputComponent:r,alertLabel:l,alertLevel:s,name:o,languages:i,values:m,onChange:u,defaultLanguage:p="nob",label:d="",onBlur:g=(()=>{}),...v})=>{const[E,b]=t.useState(p),f=n("multi-language-input",e),x=m[E];return a.createElement("div",{className:f,tabIndex:0,onBlur:e=>{e.persist();const t=e.currentTarget;setTimeout(()=>{t&&!t.contains(document.activeElement)&&g(e)},0)},"data-testid":`multi-lang-input-${o}`},a.createElement(c.InputGroup,{label:d,variant:s,feedback:l},a.createElement(h,{space:"extraSmall"},a.createElement(N,{language:E,options:i,onChange:e=>(e=>{b(e)})(e)}),a.createElement(r,Object.assign({name:o,className:"language-item",onChange:e=>(e=>{const t=Object.assign({},m);""!==e&&e?t[E]=e:delete t[E],u(t)})(e.target.value),value:x||""},v)))))},exports.OrganisationDropDown=({organisations:e,onChange:t,selectedOrganisationId:n})=>{const r=e.find(e=>e.id===n);return a.createElement(i.Dropdown,{className:"eds-contrast",items:[...e.sort((e,t)=>e.name.localeCompare(t.name,"nb")).map(e=>({value:e.id,label:e.name}))],initialSelectedItem:r?{value:r.id,label:r.name}:null,onChange:e=>{e&&t(e.value)}})},exports.Pager=({collectionSize:e,pageSize:t,onPageChange:n,currentPage:r})=>{const l=Math.ceil(e/t);return a.createElement(d.Pagination,{pageCount:l,currentPage:r,onPageChange:e=>{n(e)}})},exports.RouteLeavingGuard=({children:e,shouldBlockNavigation:n,...r})=>{const l=p.useHistory(),[s,o]=t.useState("ALLOW"),[c,i]=t.useState(l.location);return a.createElement(a.Fragment,null,a.createElement(p.Prompt,{message:e=>!n(e)||"ALLOW"!==s||(o("BLOCKED"),i(e),!1)}),a.createElement(x,Object.assign({onDismiss:()=>{o("ALLOW")},open:"BLOCKED"===s,onConfirm:()=>{l.push(c.pathname)}},r),e))},exports.Stack=h,exports.StatusLabel=({active:e=!1,label:t="",aggressiveInactive:r,showBullet:l,center:s})=>{const o=n("eps-status-label__bullet",{active:e,aggressive:r}),c=n("eps-status-label",{center:s});return a.createElement("div",{className:c},l&&a.createElement("div",{className:o}),a.createElement("div",null,t))},exports.Unbutton=({children:e,className:t,...r})=>a.createElement(o.Button,Object.assign({variant:"primary"},r,{className:n("eps-unbutton",t)}),e),exports.UserMenu=({className:e,messages:t,onLogout:r,onLanguageChange:i,onShowGdprDialog:m,userName:u,language:p,children:d})=>{const g=n(["eps-user-menu__trigger-button",e]);return a.createElement("div",{id:"eps-user-menu"},a.createElement(l.Popover,null,a.createElement(l.PopoverTrigger,null,null!=d?d:a.createElement(o.SecondaryButton,{"data-testid":"user-menu-trigger",className:g},a.createElement(s.UserIcon,null),u)),a.createElement(l.PopoverContent,null,a.createElement(b,null,a.createElement(o.SecondaryButton,{onClick:r,"data-testid":"user-menu-logout",className:"eps-user-menu__button eps-user-menu__item"},a.createElement(s.UploadIcon,{style:{transform:"rotate(90deg)"}}),t.logout)),a.createElement(c.RadioGroup,{name:t.nb,value:p,onChange:e=>i(e.target.value)},a.createElement(b,{className:"eps-user-menu__radio"},a.createElement(c.Radio,{value:"nb"},t.nb)),a.createElement(b,{className:"eps-user-menu__radio"},a.createElement(c.Radio,{value:"en"},t.en))),a.createElement(b,null,a.createElement(o.SecondaryButton,{onClick:m,className:"eps-user-menu__button"},t.termsAndConditions)))))},exports.useEventListener=function(e,a,n=window){const r=t.useRef();t.useEffect(()=>{r.current=a},[a]),t.useEffect(()=>{if(!n||!n.addEventListener)return;const t=e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.call(r,e)};return n.addEventListener(e,t),()=>{n.removeEventListener(e,t)}},[e,n])},exports.useFeatureToggle=v;
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),a=e(t),n=e(require("classnames")),r=require("@entur/typography"),l=require("@entur/tooltip"),s=require("@entur/icons"),o=require("@entur/button"),c=require("@entur/form"),i=require("@entur/dropdown"),m=require("@entur-partner/util"),u=require("@entur/modal"),p=require("react-router-dom"),d=require("@entur/menu");const g=({as:e="div",children:t,paddingTop:r,paddingRight:l,paddingBottom:s,paddingLeft:o,paddingX:c,paddingY:i,padding:m,marginTop:u,marginRight:p,marginBottom:d,marginLeft:g,marginX:h,marginY:v,margin:E,className:b})=>{const f=[],N=r||i||m,x=s||i||m,C=o||c||m,L=l||c||m,B=u||v||E,F=d||v||E,S=g||h||E,y=p||h||E;N&&f.push(`eps-pt-${N}`),x&&f.push(`eps-pb-${x}`),C&&f.push(`eps-pl-${C}`),L&&f.push(`eps-pr-${L}`),B&&f.push(`eps-mt-${B}`),F&&f.push(`eps-mb-${F}`),S&&f.push(`eps-ml-${S}`),y&&f.push(`eps-mr-${y}`);const O=n(["eps-box",f,b]);return a.createElement(e,{className:O},t)},h=({children:e,space:n,className:r})=>{const l=t.Children.toArray(e);return l.length<=1?a.createElement(a.Fragment,null,l):a.createElement("div",{className:r},l.map((e,t)=>t===l.length-1?a.createElement("div",{key:t},e):a.createElement(g,{paddingBottom:n,key:t},e)))};function v(e){var t,a;return"true"===process.env[`REACT_APP_${e}`]||"true"===(null===(t=window.localStorage)||void 0===t?void 0:t.getItem(e))||"true"===(null===(a=window.localStorage)||void 0===a?void 0:a.getItem(`REACT_APP_${e}`))}const E=({title:e,...t})=>a.createElement("svg",Object.assign({width:257,height:37,viewBox:"0 0 257 37"},t),a.createElement("title",null,e),a.createElement("g",{fill:"none",fillRule:"evenodd"},a.createElement("path",{fill:"#FFF",d:"M0 .231V25.72h18.745v-4.318H4.869v-6.163h12.31v-4.318H4.87V4.55h13.876V.231z"}),a.createElement("path",{fill:"#FF5959",d:"M0 36.408h45.253v-4.32H0z"}),a.createElement("path",{fill:"#FFF",d:"M40.384.231v15.425L23.656.231h-.521V25.72h4.869V10.573L44.732 25.72h.521V.23zM69.25 15.238h-7.267v21.17h-4.87v-21.17H49.81V10.92h19.44zM83.863 36.86c-1.646 0-3.142-.255-4.486-.765-1.345-.51-2.493-1.23-3.443-2.159-.95-.928-1.687-2.054-2.208-3.378-.522-1.323-.783-2.797-.783-4.422V10.92h4.869v15.216c0 1.277.209 2.333.626 3.169.417.836.933 1.497 1.548 1.985a5.346 5.346 0 001.982 1.01c.707.186 1.339.278 1.895.278.557 0 1.188-.092 1.896-.279a5.35 5.35 0 001.982-1.01c.614-.487 1.13-1.148 1.548-1.984.417-.836.625-1.892.625-3.169V10.92h4.87v15.216c0 1.625-.256 3.1-.766 4.422-.51 1.324-1.24 2.45-2.19 3.378-.952.929-2.1 1.648-3.444 2.159-1.344.51-2.851.766-4.52.766M104.21 24.047h5.546c1.016 0 1.854-.127 2.513-.383.658-.255 1.179-.592 1.56-1.01.381-.418.641-.888.78-1.41.138-.522.208-1.05.208-1.584 0-.627-.099-1.207-.295-1.741a3.718 3.718 0 00-.901-1.393c-.405-.394-.924-.708-1.56-.94-.636-.232-1.404-.348-2.305-.348h-5.546v8.81zm0 4.248v8.113h-4.87V10.92h11.567c1.3 0 2.49.215 3.57.644 1.08.43 2.004 1.033 2.77 1.81a8.287 8.287 0 011.794 2.787c.43 1.079.645 2.257.645 3.534 0 .952-.128 1.874-.383 2.768-.256.894-.61 1.7-1.063 2.42a7.32 7.32 0 01-1.672 1.863 5.929 5.929 0 01-2.178 1.096l6.339 8.566h-5.808l-5.893-8.113h-4.818z"}),a.createElement("g",{fill:"#FF5959"},a.createElement("path",{d:"M141.051 23.448h5.628c4.185 0 5.989-1.984 5.989-4.942 0-2.742-1.515-4.618-5.989-4.618h-5.628v9.56zm0 3.067v9.776h-3.571V10.75h9.632c6.674 0 9.127 3.211 9.127 7.54 0 4.979-3.102 8.226-9.2 8.226h-5.988zM169.695 28.715c-1.371-.288-2.958-.505-4.401-.505-2.85 0-4.041 1.263-4.041 3.139s1.407 2.706 3.463 2.706c2.49 0 4.979-1.443 4.979-4.221v-1.119zm-4.293-2.958c1.551 0 3.174.253 4.293.469v-.83c0-2.525-1.154-3.896-4.33-3.896-2.164 0-3.824.866-4.942 2.092l-2.02-2.272c1.732-1.66 3.644-2.598 7.07-2.598 5.052 0 7.469 1.876 7.469 7.215v10.354h-3.211V34.02h-.108c-1.082 1.767-3.211 2.705-5.592 2.705-3.32 0-6.241-1.66-6.241-5.303 0-3.103 1.912-5.664 7.612-5.664zM178.965 19.191h3.211v2.886h.108c.938-1.984 2.922-3.355 5.231-3.355.47 0 .938.036 1.335.144l-.144 3.14a6.77 6.77 0 00-1.552-.181c-3.246 0-4.798 2.633-4.798 5.483v8.983h-3.39v-17.1zM199.961 36.291h-1.912c-4.004 0-5.988-.938-5.988-5.772v-8.55h-2.778V19.19h2.778v-4.654h3.355v4.654h4.473v2.778h-4.473v7.973c0 3.427 1.587 3.535 3.319 3.535h1.226v2.814zM219.767 36.291h-3.391V26.84c0-2.778-1.083-5.375-4.257-5.375-3.14 0-5.268 2.597-5.268 6.169v8.658h-3.391v-17.1h3.32v2.814h.143c.794-1.623 3.067-3.283 5.99-3.283 4.941 0 6.854 3.644 6.854 8.081v9.488zM227.847 26.262h10.57c0-2.597-2.272-4.726-5.087-4.726-2.922 0-5.014 1.948-5.483 4.726zm-.036 2.453c.397 3.355 2.633 5.195 5.844 5.195 2.778 0 4.618-1.623 5.484-2.67l2.164 1.804c-1.37 1.913-4.365 3.716-8.045 3.716-4.942 0-8.73-3.535-8.73-8.55 0-5.195 3.752-9.488 8.983-9.488 5.303 0 8.009 4.365 8.009 8.19 0 .649-.036 1.226-.072 1.803H227.81zM246.245 19.191h3.21v2.886h.109c.938-1.984 2.922-3.355 5.231-3.355.469 0 .938.036 1.335.144l-.145 3.14a6.77 6.77 0 00-1.551-.181c-3.247 0-4.798 2.633-4.798 5.483v8.983h-3.391v-17.1z"})))),b=({children:e,className:t})=>{const r=n(["eps-user-menu__item",t]);return a.createElement("div",{className:r},e)},f=({language:e,options:t,className:r,onChange:l,...s})=>{const o=n("eps-language-select",r);return a.createElement("div",Object.assign({},s,{className:o}),a.createElement(c.SegmentedControl,{onChange:e=>{m.assertIsDefined(e),l(e)},selectedValue:e},t.map(e=>a.createElement(c.SegmentedChoice,{key:e.value,value:e.value},e.label,e.required&&a.createElement("span",{className:"asterisk-margin"},"*")))))},N=({date:e,locale:t,as:n="main",hideTime:r,...l})=>a.createElement(n,Object.assign({},l),r?m.localeDate(e,t):m.localeDateTime(e,t)),x=({isOpen:e=!1,children:t,message:n,size:l="medium",buttons:s,onConfirm:c,messages:i,onClose:p,onDismiss:d,...h})=>{const v=t||n,E=p||d;return a.createElement(u.Modal,Object.assign({size:l,open:e,onDismiss:E},h),m.isString(v)?a.createElement(r.Paragraph,null,v):a.createElement(g,{paddingBottom:"medium"},v),a.createElement(o.ButtonGroup,null,c?a.createElement(a.Fragment,null,a.createElement(o.SecondaryButton,{onClick:E,"data-testid":"cancel-modal-button"},i.cancel),a.createElement(o.PrimaryButton,{onClick:c,"data-testid":"confirm-modal-button"},i.confirm)):s))};function C(e,t){return void 0!==e.find(e=>{return(a=t).access===(n=e).access&&a.operation===n.operation;var a,n})}exports.ActionBar=({children:e})=>a.createElement(a.Fragment,null,a.createElement("div",{className:"eps-action-bar-padding"}),a.createElement("div",{className:"eps-action-bar"},e)),exports.ActionBarLeft=({children:e})=>a.createElement("div",{className:"eps-action-bar-left"},e),exports.ActionBarRight=({children:e})=>a.createElement("div",{className:"eps-action-bar-right"},e),exports.AuditInfo=({items:e,locale:t,className:r,...l})=>{const s=n("ep-audit-info",r);return a.createElement("div",Object.assign({className:s},l),e.map(({label:e,value:n},r)=>a.createElement(h,{space:"small",key:r},a.createElement("div",{className:"ep-audit-info-label"},e),a.createElement("div",null,m.isDate(n)||m.isDateString(n)?a.createElement(N,{date:n,locale:t}):a.createElement("span",null,n)))))},exports.Box=g,exports.Breadcrumbs=({pathname:e,onBreadcrumbLookup:t})=>{const n="/"===e?[]:["/"];(e.length>1?e.replace(/\/$/,""):e).split("/").reduce((e,t)=>{const a=`${e}/${t}`;return n.push(a),a});const r=n.map(e=>({title:t(e),path:e})).filter(({title:e})=>void 0!==e);return a.createElement(d.BreadcrumbNavigation,null,r.map(({title:e,path:t},n)=>a.createElement(d.BreadcrumbItem,{key:t,as:n===r.length-1?"span":p.Link,to:t},e)))},exports.ConfirmModal=x,exports.Content=({as:e="main",className:t,children:r})=>{const l=n(["eps-content",t]);return a.createElement(e,{className:l},r)},exports.EnturPartnerLogo=({as:e="nav",className:t,altText:r})=>{const l=n(["eps-logo-wrapper",t]);return a.createElement(e,{className:l},a.createElement(E,{title:r,className:"logo"}))},exports.EnturPartnerLogoSvg=E,exports.ErrorBoundary=class extends t.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e){var t,a;null===(t=(a=this.props).handleError)||void 0===t||t.call(a,e)}render(){const{error:e}=this.state,{fallback:t,children:a}=this.props;return e?(n=t)&&"[object Function]"==={}.toString.call(n)?t({retry:()=>this.setState({error:null}),error:e}):t:a;var n}},exports.FeatureToggle=({children:e,flag:t})=>v(t)?a.createElement(a.Fragment,null,e):null,exports.FormatCurrencyAmount=({amount:e,as:t="span",...n})=>{const r=Number(e)||0,l=new Intl.NumberFormat("nb-NO",{maximumFractionDigits:2,minimumFractionDigits:2}).format(r);return a.createElement(t,Object.assign({},n),l)},exports.FormatDateTime=N,exports.LanguageSelect=f,exports.LinkButton=({children:e,className:t,...l})=>a.createElement(r.Link,Object.assign({},l,{as:"button",className:n("eps-link-button",t)}),e),exports.Menu=({as:e="nav",className:t,children:r})=>{const l=n(["eds-contrast","eps-menu",t]);return a.createElement(e,{className:l},r)},exports.MultiLanguageInput=({className:e,inputComponent:r,alertLabel:l,alertLevel:s,name:o,languages:i,values:m,onChange:u,defaultLanguage:p="nob",label:d="",onBlur:g=(()=>{}),...v})=>{const[E,b]=t.useState(p),N=n("multi-language-input",e),x=m[E];return a.createElement("div",{className:N,tabIndex:0,onBlur:e=>{e.persist();const t=e.currentTarget;setTimeout(()=>{t&&!t.contains(document.activeElement)&&g(e)},0)},"data-testid":`multi-lang-input-${o}`},a.createElement(c.InputGroup,{label:d,variant:s,feedback:l},a.createElement(h,{space:"extraSmall"},a.createElement(f,{language:E,options:i,onChange:e=>(e=>{b(e)})(e)}),a.createElement(r,Object.assign({name:o,className:"language-item",onChange:e=>(e=>{const t=Object.assign({},m);""!==e&&e?t[E]=e:delete t[E],u(t)})(e.target.value),value:x||""},v)))))},exports.OrganisationDropDown=({organisations:e,onChange:t,selectedOrganisationId:n})=>{const r=e.find(e=>e.id===n);return a.createElement(i.Dropdown,{className:"eds-contrast",items:[...e.sort((e,t)=>e.name.localeCompare(t.name,"nb")).map(e=>({value:e.id,label:e.name}))],initialSelectedItem:r?{value:r.id,label:r.name}:null,onChange:e=>{e&&t(e.value)}})},exports.Pager=({collectionSize:e,pageSize:t,onPageChange:n,currentPage:r})=>{const l=Math.ceil(e/t);return a.createElement(d.Pagination,{pageCount:l,currentPage:r,onPageChange:e=>{n(e)}})},exports.PermissionCheck=({children:e,fallback:t=null,permissions:n,oneOf:r=[],all:l=[]})=>{Array.isArray(l)||(l=[l]);const s=l.every(e=>C(n,e)),o=!(r.length>0)||r.some(e=>C(n,e));return a.createElement(a.Fragment,null,s&&o?e:t)},exports.RouteLeavingGuard=({children:e,shouldBlockNavigation:n,...r})=>{const l=p.useHistory(),[s,o]=t.useState("ALLOW"),[c,i]=t.useState(l.location);return a.createElement(a.Fragment,null,a.createElement(p.Prompt,{message:e=>!n(e)||"ALLOW"!==s||(o("BLOCKED"),i(e),!1)}),a.createElement(x,Object.assign({onDismiss:()=>{o("ALLOW")},open:"BLOCKED"===s,onConfirm:()=>{l.push(c.pathname)}},r),e))},exports.Stack=h,exports.StatusLabel=({active:e=!1,label:t="",aggressiveInactive:r,showBullet:l,center:s})=>{const o=n("eps-status-label__bullet",{active:e,aggressive:r}),c=n("eps-status-label",{center:s});return a.createElement("div",{className:c},l&&a.createElement("div",{className:o}),a.createElement("div",null,t))},exports.Unbutton=({children:e,className:t,...r})=>a.createElement(o.Button,Object.assign({variant:"primary"},r,{className:n("eps-unbutton",t)}),e),exports.UserMenu=({className:e,messages:t,onLogout:r,onLanguageChange:i,onShowGdprDialog:m,userName:u,language:p,children:d})=>{const g=n(["eps-user-menu__trigger-button",e]);return a.createElement("div",{id:"eps-user-menu"},a.createElement(l.Popover,null,a.createElement(l.PopoverTrigger,null,null!=d?d:a.createElement(o.SecondaryButton,{"data-testid":"user-menu-trigger",className:g},a.createElement(s.UserIcon,null),u)),a.createElement(l.PopoverContent,null,a.createElement(b,null,a.createElement(o.SecondaryButton,{onClick:r,"data-testid":"user-menu-logout",className:"eps-user-menu__button eps-user-menu__item"},a.createElement(s.UploadIcon,{style:{transform:"rotate(90deg)"}}),t.logout)),a.createElement(c.RadioGroup,{name:t.nb,value:p,onChange:e=>i(e.target.value)},a.createElement(b,{className:"eps-user-menu__radio"},a.createElement(c.Radio,{value:"nb"},t.nb)),a.createElement(b,{className:"eps-user-menu__radio"},a.createElement(c.Radio,{value:"en"},t.en))),a.createElement(b,null,a.createElement(o.SecondaryButton,{onClick:m,className:"eps-user-menu__button"},t.termsAndConditions)))))},exports.useEventListener=function(e,a,n=window){const r=t.useRef();t.useEffect(()=>{r.current=a},[a]),t.useEffect(()=>{if(!n||!n.addEventListener)return;const t=e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.call(r,e)};return n.addEventListener(e,t),()=>{n.removeEventListener(e,t)}},[e,n])},exports.useFeatureToggle=v;
//# sourceMappingURL=common.cjs.production.min.js.map

@@ -607,2 +607,27 @@ import React, { Children, useRef, useEffect, useState, Component } from 'react';

function checkPermission(permission1, permission2) {
return permission1.access === permission2.access && permission1.operation === permission2.operation;
}
function hasPermissions(permissions, requiredPermission) {
return permissions.find(userPermission => checkPermission(requiredPermission, userPermission)) !== undefined;
}
const PermissionCheck = ({
children,
fallback = null,
permissions,
oneOf = [],
all = []
}) => {
if (!Array.isArray(all)) {
all = [all];
}
const allIsAllowed = all.every(requiredPermission => hasPermissions(permissions, requiredPermission));
const oneOfIsAllowed = oneOf.length > 0 ? oneOf.some(requiredPermission => hasPermissions(permissions, requiredPermission)) : true;
const allowed = allIsAllowed && oneOfIsAllowed;
return React.createElement(React.Fragment, null, allowed ? children : fallback);
};
const Breadcrumbs = ({

@@ -639,3 +664,3 @@ pathname,

export { ActionBar, ActionBarLeft, ActionBarRight, AuditInfo, Box, Breadcrumbs, ConfirmModal, Content, EnturPartnerLogo, EnturPartnerLogoSvg, ErrorBoundary, FeatureToggle, FormatCurrencyAmount, FormatDateTime, LanguageSelect, LinkButton, Menu, MultiLanguageInput, OrganisationDropDown, Pager, RouteLeavingGuard, Stack, StatusLabel, Unbutton, UserMenu, useEventListener, useFeatureToggle };
export { ActionBar, ActionBarLeft, ActionBarRight, AuditInfo, Box, Breadcrumbs, ConfirmModal, Content, EnturPartnerLogo, EnturPartnerLogoSvg, ErrorBoundary, FeatureToggle, FormatCurrencyAmount, FormatDateTime, LanguageSelect, LinkButton, Menu, MultiLanguageInput, OrganisationDropDown, Pager, PermissionCheck, RouteLeavingGuard, Stack, StatusLabel, Unbutton, UserMenu, useEventListener, useFeatureToggle };
//# sourceMappingURL=common.esm.js.map

@@ -24,2 +24,3 @@ import './index.scss';

export * from './Box';
export * from './PermissionCheck';
export * from './Breadcrumbs';
{
"name": "@entur-partner/common",
"version": "0.0.9",
"version": "0.0.10",
"license": "EUPL-1.2",

@@ -31,3 +31,3 @@ "main": "dist/index.js",

"dependencies": {
"@entur-partner/util": "^0.0.2",
"@entur-partner/util": "^0.0.3",
"@entur/button": "^2.2.11",

@@ -41,2 +41,3 @@ "@entur/form": "^3.0.3",

"devDependencies": {
"@entur-partner/permission-client-node": "^1.1.2",
"@entur/tokens": "^1.3.5",

@@ -58,3 +59,3 @@ "identity-obj-proxy": "^3.0.0"

},
"gitHead": "11c534c51b081aebb0933481e4ebbecc8c3c5732"
"gitHead": "ce564b77bdcfff44ef156c38e0c03b454be19c0a"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc