@aarhus-university/au-lib-react-components 10.0.1 → 10.0.4

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.
Files changed (44) hide show
  1. package/build/umd/all.css +2 -2
  2. package/build/umd/all.js +1 -1
  3. package/build/umd/alphabox.js +1 -1
  4. package/build/umd/databox.js +1 -1
  5. package/build/umd/diagramme.js +1 -1
  6. package/build/umd/flowbox.js +1 -1
  7. package/build/umd/universe.js +1 -1
  8. package/package.json +3 -3
  9. package/src/components/AUAutoSuggestComponent.js +158 -158
  10. package/src/components/AUSpinnerComponent.tsx +91 -67
  11. package/src/components/AUTabbedContentComponent.tsx +1 -1
  12. package/src/components/AUToastComponent.tsx +11 -12
  13. package/src/components/profile/AUProfileLoginComponent.tsx +26 -26
  14. package/src/layout-2016/components/alphabox/AlphaBoxComponent.js +143 -143
  15. package/src/layout-2016/components/alphabox/AlphaBoxContentComponent.js +136 -136
  16. package/src/layout-2016/components/common/AUCollapsibleComponent.js +152 -152
  17. package/src/layout-2016/components/common/AUSpinnerComponent.js +103 -103
  18. package/src/layout-2016/components/databox/DataBoxAlphabetComponent.js +144 -144
  19. package/src/layout-2016/components/databox/DataBoxAssociationComponent.js +122 -122
  20. package/src/layout-2016/components/databox/DataBoxButtonComponent.js +157 -157
  21. package/src/layout-2016/components/databox/DataBoxComponent.js +297 -297
  22. package/src/layout-2016/components/databox/DataBoxGroupingComponent.js +64 -64
  23. package/src/layout-2016/components/databox/DataBoxSearchResultComponent.js +36 -36
  24. package/src/layout-2016/components/databox/DataBoxStackedAssociationComponent.js +54 -54
  25. package/src/layout-2016/components/databox/DataBoxSuggestionComponent.js +39 -39
  26. package/src/layout-2016/components/diagramme/AUDiagrammeComponent.js +309 -309
  27. package/src/layout-2016/components/flowbox/FlowBoxComponent.js +126 -126
  28. package/src/layout-2016/components/flowbox/FlowBoxPhoneComponent.js +104 -104
  29. package/src/layout-2016/components/profile/AUProfileAvatar2016Component.js +103 -103
  30. package/src/layout-2016/components/universe/StaffTopComponent.js +363 -363
  31. package/src/layout-2016/components/universe/StudentTopComponent.js +137 -137
  32. package/src/layout-2016/components/universe/UniverseContainerComponent.js +65 -65
  33. package/src/layout-2016/lib/all.js +3 -3
  34. package/src/layout-2016/lib/au-alphabox.js +100 -100
  35. package/src/layout-2016/lib/au-databox.js +400 -400
  36. package/src/layout-2016/lib/au-diagramme.js +85 -85
  37. package/src/layout-2016/lib/au-flowbox.js +93 -93
  38. package/src/layout-2016/lib/universe.js +9 -9
  39. package/src/lib/helpers.ts +194 -194
  40. package/tsconfig.json +46 -46
  41. package/types/common/interfaces/gui.d.ts +13 -1
  42. package/types/common/interfaces/model.d.ts +29 -29
  43. package/types/common/props.d.ts +166 -165
  44. package/webpack.config.js +89 -89
@@ -1,152 +1,152 @@
1
- /* eslint-disable @typescript-eslint/no-empty-function */
2
- import React from 'react';
3
- import PropTypes from 'prop-types';
4
-
5
- class AUCollapsibleComponent extends React.Component {
6
- constructor(props) {
7
- super(props);
8
-
9
- this.state = {
10
- collapsed: props.collapsed,
11
- };
12
- }
13
-
14
- componentDidMount() {
15
- const { attributes } = this.props;
16
- attributes.forEach((a) => {
17
- if (a.selector) {
18
- const el = this.node.querySelector(a.selector);
19
- if (el) {
20
- el.setAttribute(a.attr, a.value);
21
- }
22
- } else {
23
- this.node.setAttribute(a.attr, a.value);
24
- }
25
- });
26
- }
27
-
28
- render() {
29
- const {
30
- header,
31
- level,
32
- content,
33
- classNames,
34
- onClick,
35
- children,
36
- dataID,
37
- headerElement,
38
- } = this.props;
39
- const { collapsed } = this.state;
40
- let className = 'csc-frame au_collapsible';
41
- if (collapsed) {
42
- className += ' au_collapsed';
43
- }
44
-
45
- if (classNames) {
46
- className += ` ${classNames}`;
47
- }
48
-
49
- return (
50
- <div data-id={dataID} ref={(node) => { this.node = node; }} className={className}>
51
- {(() => {
52
- if (level > -1) {
53
- return (
54
- <div
55
- className="csc-header"
56
- onClick={() => {
57
- this.setState((prevState) => ({
58
- collapsed: !prevState.collapsed,
59
- }), () => {
60
- const { collapsed: newCollapsed } = this.state;
61
- onClick(newCollapsed, this.node);
62
- });
63
- }}
64
- onKeyUp={() => {
65
-
66
- }}
67
- role="button"
68
- tabIndex={0}
69
- >
70
- {(() => {
71
- switch (level) {
72
- case 0 && headerElement != null:
73
- return headerElement;
74
- case 1:
75
- return (
76
- <h1>
77
- {header}
78
- </h1>
79
- );
80
- case 2:
81
- return (
82
- <h2>
83
- {header}
84
- </h2>
85
- );
86
- case 3:
87
- return (
88
- <h3>
89
- {header}
90
- </h3>
91
- );
92
- case 4:
93
- return (
94
- <h4>
95
- {header}
96
- </h4>
97
- );
98
- case 5:
99
- return (
100
- <h5>
101
- {header}
102
- </h5>
103
- );
104
- default:
105
- return (
106
- <h6>
107
- {header}
108
- </h6>
109
- );
110
- }
111
- })()}
112
- </div>
113
- );
114
- }
115
- return null;
116
- })()}
117
- {children || content}
118
- </div>
119
- );
120
- }
121
- }
122
-
123
- AUCollapsibleComponent.defaultProps = {
124
- dataID: null,
125
- children: null,
126
- content: null,
127
- header: '',
128
- headerElement: null,
129
- level: 1,
130
- classNames: '',
131
- onClick: () => { },
132
- attributes: [],
133
- };
134
-
135
- AUCollapsibleComponent.propTypes = {
136
- dataID: PropTypes.string,
137
- children: PropTypes.element,
138
- collapsed: PropTypes.bool.isRequired,
139
- header: PropTypes.string,
140
- headerElement: PropTypes.element,
141
- level: PropTypes.number,
142
- content: PropTypes.element,
143
- classNames: PropTypes.string,
144
- onClick: PropTypes.func,
145
- attributes: PropTypes.arrayOf(PropTypes.shape({
146
- attr: PropTypes.string,
147
- value: PropTypes.string,
148
- selector: PropTypes.string,
149
- })),
150
- };
151
- AUCollapsibleComponent.displayName = 'AUCollapsibleComponent';
152
- export default AUCollapsibleComponent;
1
+ /* eslint-disable @typescript-eslint/no-empty-function */
2
+ import React from 'react';
3
+ import PropTypes from 'prop-types';
4
+
5
+ class AUCollapsibleComponent extends React.Component {
6
+ constructor(props) {
7
+ super(props);
8
+
9
+ this.state = {
10
+ collapsed: props.collapsed,
11
+ };
12
+ }
13
+
14
+ componentDidMount() {
15
+ const { attributes } = this.props;
16
+ attributes.forEach((a) => {
17
+ if (a.selector) {
18
+ const el = this.node.querySelector(a.selector);
19
+ if (el) {
20
+ el.setAttribute(a.attr, a.value);
21
+ }
22
+ } else {
23
+ this.node.setAttribute(a.attr, a.value);
24
+ }
25
+ });
26
+ }
27
+
28
+ render() {
29
+ const {
30
+ header,
31
+ level,
32
+ content,
33
+ classNames,
34
+ onClick,
35
+ children,
36
+ dataID,
37
+ headerElement,
38
+ } = this.props;
39
+ const { collapsed } = this.state;
40
+ let className = 'csc-frame au_collapsible';
41
+ if (collapsed) {
42
+ className += ' au_collapsed';
43
+ }
44
+
45
+ if (classNames) {
46
+ className += ` ${classNames}`;
47
+ }
48
+
49
+ return (
50
+ <div data-id={dataID} ref={(node) => { this.node = node; }} className={className}>
51
+ {(() => {
52
+ if (level > -1) {
53
+ return (
54
+ <div
55
+ className="csc-header"
56
+ onClick={() => {
57
+ this.setState((prevState) => ({
58
+ collapsed: !prevState.collapsed,
59
+ }), () => {
60
+ const { collapsed: newCollapsed } = this.state;
61
+ onClick(newCollapsed, this.node);
62
+ });
63
+ }}
64
+ onKeyUp={() => {
65
+
66
+ }}
67
+ role="button"
68
+ tabIndex={0}
69
+ >
70
+ {(() => {
71
+ switch (level) {
72
+ case 0 && headerElement != null:
73
+ return headerElement;
74
+ case 1:
75
+ return (
76
+ <h1>
77
+ {header}
78
+ </h1>
79
+ );
80
+ case 2:
81
+ return (
82
+ <h2>
83
+ {header}
84
+ </h2>
85
+ );
86
+ case 3:
87
+ return (
88
+ <h3>
89
+ {header}
90
+ </h3>
91
+ );
92
+ case 4:
93
+ return (
94
+ <h4>
95
+ {header}
96
+ </h4>
97
+ );
98
+ case 5:
99
+ return (
100
+ <h5>
101
+ {header}
102
+ </h5>
103
+ );
104
+ default:
105
+ return (
106
+ <h6>
107
+ {header}
108
+ </h6>
109
+ );
110
+ }
111
+ })()}
112
+ </div>
113
+ );
114
+ }
115
+ return null;
116
+ })()}
117
+ {children || content}
118
+ </div>
119
+ );
120
+ }
121
+ }
122
+
123
+ AUCollapsibleComponent.defaultProps = {
124
+ dataID: null,
125
+ children: null,
126
+ content: null,
127
+ header: '',
128
+ headerElement: null,
129
+ level: 1,
130
+ classNames: '',
131
+ onClick: () => { },
132
+ attributes: [],
133
+ };
134
+
135
+ AUCollapsibleComponent.propTypes = {
136
+ dataID: PropTypes.string,
137
+ children: PropTypes.element,
138
+ collapsed: PropTypes.bool.isRequired,
139
+ header: PropTypes.string,
140
+ headerElement: PropTypes.element,
141
+ level: PropTypes.number,
142
+ content: PropTypes.element,
143
+ classNames: PropTypes.string,
144
+ onClick: PropTypes.func,
145
+ attributes: PropTypes.arrayOf(PropTypes.shape({
146
+ attr: PropTypes.string,
147
+ value: PropTypes.string,
148
+ selector: PropTypes.string,
149
+ })),
150
+ };
151
+ AUCollapsibleComponent.displayName = 'AUCollapsibleComponent';
152
+ export default AUCollapsibleComponent;
@@ -1,103 +1,103 @@
1
- /* eslint-disable @typescript-eslint/no-empty-function */
2
- /* eslint-env browser */
3
- import React from 'react';
4
- import PropTypes from 'prop-types';
5
- import { isElementInViewport } from '../../../lib/helpers';
6
-
7
- class AUSpinnerComponent extends React.Component {
8
- constructor(props) {
9
- super(props);
10
-
11
- this.state = {
12
- loading: true,
13
- visible: props.visible,
14
- };
15
-
16
- this.lazyLoad = this.lazyLoad.bind(this);
17
- }
18
-
19
- componentDidMount() {
20
- this.lazyLoad();
21
- window.addEventListener('scroll', () => {
22
- this.lazyLoad();
23
- });
24
- }
25
-
26
- componentDidUpdate() {
27
- this.lazyLoad();
28
- }
29
-
30
- static getDerivedStateFromProps(nextProps, prevState) {
31
- if (nextProps.visible !== prevState.visible) {
32
- return {
33
- visible: nextProps.visible,
34
- };
35
- }
36
-
37
- return null;
38
- }
39
-
40
- lazyLoad() {
41
- const {
42
- loadingCondition,
43
- loaded,
44
- domID,
45
- onLoad,
46
- } = this.props;
47
- const { loading, visible } = this.state;
48
-
49
- const element = document.getElementById(domID);
50
- if (!loaded && loading && loadingCondition && (visible || isElementInViewport(element))) {
51
- this.setState({
52
- loading: false,
53
- }, () => {
54
- onLoad();
55
- });
56
- }
57
- }
58
-
59
- render() {
60
- const {
61
- columns, content, loaded, domID, children,
62
- } = this.props;
63
-
64
- if (!loaded) {
65
- return (
66
- <div id={domID} className={`cell column ${columns}`}>
67
- <p className="spinner" />
68
- </div>
69
- );
70
- }
71
-
72
- return children || content;
73
- }
74
- }
75
-
76
- AUSpinnerComponent.defaultProps = {
77
- domID: 'au-spinner-component',
78
- visible: false,
79
- columns: 'large-12 medium-12 small-12',
80
- content: null,
81
- children: null,
82
- onLoad: () => {},
83
- };
84
-
85
- AUSpinnerComponent.propTypes = {
86
- /**
87
- * Relevant ved mere end en spinner per side
88
- */
89
- domID: PropTypes.string,
90
- /**
91
- * Om den er synlig på skærmen ved indlæsning
92
- */
93
- visible: PropTypes.bool,
94
- columns: PropTypes.string,
95
- content: PropTypes.element,
96
- children: PropTypes.element,
97
- loaded: PropTypes.bool.isRequired,
98
- loadingCondition: PropTypes.bool.isRequired,
99
- onLoad: PropTypes.func,
100
- };
101
-
102
- AUSpinnerComponent.displayName = 'AUSpinnerComponent';
103
- export default AUSpinnerComponent;
1
+ /* eslint-disable @typescript-eslint/no-empty-function */
2
+ /* eslint-env browser */
3
+ import React from 'react';
4
+ import PropTypes from 'prop-types';
5
+ import { isElementInViewport } from '../../../lib/helpers';
6
+
7
+ class AUSpinnerComponent extends React.Component {
8
+ constructor(props) {
9
+ super(props);
10
+
11
+ this.state = {
12
+ loading: true,
13
+ visible: props.visible,
14
+ };
15
+
16
+ this.lazyLoad = this.lazyLoad.bind(this);
17
+ }
18
+
19
+ componentDidMount() {
20
+ this.lazyLoad();
21
+ window.addEventListener('scroll', () => {
22
+ this.lazyLoad();
23
+ });
24
+ }
25
+
26
+ componentDidUpdate() {
27
+ this.lazyLoad();
28
+ }
29
+
30
+ static getDerivedStateFromProps(nextProps, prevState) {
31
+ if (nextProps.visible !== prevState.visible) {
32
+ return {
33
+ visible: nextProps.visible,
34
+ };
35
+ }
36
+
37
+ return null;
38
+ }
39
+
40
+ lazyLoad() {
41
+ const {
42
+ loadingCondition,
43
+ loaded,
44
+ domID,
45
+ onLoad,
46
+ } = this.props;
47
+ const { loading, visible } = this.state;
48
+
49
+ const element = document.getElementById(domID);
50
+ if (!loaded && loading && loadingCondition && (visible || isElementInViewport(element))) {
51
+ this.setState({
52
+ loading: false,
53
+ }, () => {
54
+ onLoad();
55
+ });
56
+ }
57
+ }
58
+
59
+ render() {
60
+ const {
61
+ columns, content, loaded, domID, children,
62
+ } = this.props;
63
+
64
+ if (!loaded) {
65
+ return (
66
+ <div id={domID} className={`cell column ${columns}`}>
67
+ <p className="spinner" />
68
+ </div>
69
+ );
70
+ }
71
+
72
+ return children || content;
73
+ }
74
+ }
75
+
76
+ AUSpinnerComponent.defaultProps = {
77
+ domID: 'au-spinner-component',
78
+ visible: false,
79
+ columns: 'large-12 medium-12 small-12',
80
+ content: null,
81
+ children: null,
82
+ onLoad: () => {},
83
+ };
84
+
85
+ AUSpinnerComponent.propTypes = {
86
+ /**
87
+ * Relevant ved mere end en spinner per side
88
+ */
89
+ domID: PropTypes.string,
90
+ /**
91
+ * Om den er synlig på skærmen ved indlæsning
92
+ */
93
+ visible: PropTypes.bool,
94
+ columns: PropTypes.string,
95
+ content: PropTypes.element,
96
+ children: PropTypes.element,
97
+ loaded: PropTypes.bool.isRequired,
98
+ loadingCondition: PropTypes.bool.isRequired,
99
+ onLoad: PropTypes.func,
100
+ };
101
+
102
+ AUSpinnerComponent.displayName = 'AUSpinnerComponent';
103
+ export default AUSpinnerComponent;