@aarhus-university/au-lib-react-components 8.81.0 → 8.82.0

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "sideEffects": false,
3
3
  "name": "@aarhus-university/au-lib-react-components",
4
- "version": "8.81.0",
4
+ "version": "8.82.0",
5
5
  "description": "Library for shared React components for various applications on au.dk",
6
6
  "scripts": {
7
7
  "build": "webpack --config ./webpack.config.js"
@@ -31,7 +31,7 @@ const AUProfileAvatarComponent: FC<AUProfileAvatarComponentProps> = memo(({
31
31
  auId={auId}
32
32
  settings={settings}
33
33
  profileLabels={profileLabels}
34
- changeLanguageUri={changeLanguageUri}
34
+ changeLanguageUri={changeLanguageUri || ''}
35
35
  logoutUri={logoutUri}
36
36
  />
37
37
  </AUSubNavComponent>
@@ -1,13 +1,12 @@
1
1
  /* eslint-env browser */
2
- import React from 'react';
3
- import PropTypes from 'prop-types';
2
+ import React, { FC } from 'react';
4
3
 
5
- const AUProfileLoginComponent = ({
4
+ const AUProfileLoginComponent: FC<AUProfileLoginComponentProps> = ({
6
5
  loggedIn,
7
6
  loginUri,
8
7
  children,
9
8
  text,
10
- }) => {
9
+ }: AUProfileLoginComponentProps) => {
11
10
  if (!loggedIn) {
12
11
  return (
13
12
  <a
@@ -23,17 +22,5 @@ const AUProfileLoginComponent = ({
23
22
  return children;
24
23
  };
25
24
 
26
- AUProfileLoginComponent.defaultProps = {
27
- loggedIn: false,
28
- loginUri: '',
29
- };
30
-
31
- AUProfileLoginComponent.propTypes = {
32
- loggedIn: PropTypes.bool,
33
- loginUri: PropTypes.string,
34
- children: PropTypes.element.isRequired,
35
- text: PropTypes.string.isRequired,
36
- };
37
-
38
25
  AUProfileLoginComponent.displayName = 'AUProfileLoginComponent';
39
26
  export default AUProfileLoginComponent;
@@ -43,7 +43,11 @@ const AUProfileWidgetComponent: FC<AUProfileWidgetComponentProps> = memo(({
43
43
  type="button"
44
44
  disabled={s.disabled}
45
45
  className={`sub-nav__item ${s.classNames}`}
46
- onClick={() => s.onClick(btnRefs.current[i])}
46
+ onClick={() => {
47
+ if (typeof s.onClick === 'function') {
48
+ s.onClick(btnRefs.current[i]);
49
+ }
50
+ }}
47
51
  data-icon={s.icon}
48
52
  data-gtm={s.dataGtm}
49
53
  >
@@ -66,18 +66,26 @@ interface ITrackers {
66
66
  interface IProfileSettings {
67
67
  type: string,
68
68
  url: string,
69
- classNames: string,
70
- icon: string,
69
+ classNames?: string,
70
+ icon?: string,
71
71
  dataGtm: string,
72
72
  text: string,
73
- disabled: boolean,
74
- onClick: (el: Element) => void,
73
+ disabled?: boolean,
74
+ onClick?: (el: Element) => void,
75
75
  }
76
76
 
77
- interface IProfileUser {
77
+ interface IUserContext {
78
78
  auId: number,
79
79
  firstNames: string,
80
80
  lastName: string,
81
+ name: string,
81
82
  preferredLanguage: string,
82
- studentNumber: string,
83
+ userName: string,
84
+ memberOfGroups: IAdGroup[],
85
+ impersonatingUser: IUserContext | null,
86
+ }
87
+
88
+ interface IAdGroup {
89
+ id: string,
90
+ name: string,
83
91
  }
@@ -149,10 +149,17 @@ interface AUProfileWidgetComponentProps {
149
149
  }
150
150
 
151
151
  interface AUProfileAvatarComponentProps {
152
- user: IProfileUser,
152
+ user: IUserContext,
153
153
  settings: IProfileSettings[],
154
154
  profileLabels: any, // Noget med labels her?
155
155
  logoutUri: string,
156
- changeLanguageUri: string,
156
+ changeLanguageUri?: string,
157
157
  lang: string,
158
158
  }
159
+
160
+ interface AUProfileLoginComponentProps {
161
+ loggedIn: boolean,
162
+ loginUri: string,
163
+ children: JSX.Element,
164
+ text: string,
165
+ }