@aarhus-university/au-lib-react-components 10.5.0 → 10.6.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.
Files changed (94) hide show
  1. package/.eslintrc.js +34 -33
  2. package/.storybook/main.js +7 -7
  3. package/.storybook/preview.js +10 -10
  4. package/README.md +19 -19
  5. package/__tests__/jest/AUButtonComponent.test.tsx +163 -163
  6. package/__tests__/jest/AUSpinnerComponent.test.tsx +57 -0
  7. package/__tests__/jest/helpers.test.ts +15 -15
  8. package/__tests__/jest/setupTests.ts +2 -2
  9. package/babel.config.js +8 -8
  10. package/build/umd/all.css +2 -2
  11. package/build/umd/all.js +1 -1
  12. package/build/umd/alphabox.js +1 -1
  13. package/build/umd/databox.js +1 -1
  14. package/build/umd/databox.js.map +1 -1
  15. package/build/umd/diagramme.js +1 -1
  16. package/build/umd/flowbox.js +1 -1
  17. package/build/umd/universe.js +1 -1
  18. package/package.json +107 -107
  19. package/src/components/AUAlertComponent.tsx +70 -70
  20. package/src/components/AUAutoSuggestComponent.js +158 -158
  21. package/src/components/AUButtonComponent.tsx +77 -77
  22. package/src/components/AUCalendarComponent.tsx +493 -493
  23. package/src/components/AUContentToggleComponent.tsx +33 -33
  24. package/src/components/AUDatepickerComponent.tsx +117 -117
  25. package/src/components/AUMobilePrefixComponent.tsx +15 -15
  26. package/src/components/AUModalComponent.tsx +80 -80
  27. package/src/components/AUReceiptComponent.tsx +33 -33
  28. package/src/components/AUSpinnerComponent.tsx +33 -91
  29. package/src/components/AUSubNavComponent.tsx +48 -48
  30. package/src/components/AUSubmitButtonContainerComponent.tsx +31 -31
  31. package/src/components/AUTabbedContentComponent.tsx +145 -145
  32. package/src/components/AUTableComponent.tsx +24 -24
  33. package/src/components/AUToastComponent.tsx +103 -103
  34. package/src/components/AUToolbarComponent.tsx +45 -45
  35. package/src/components/profile/AUProfileActions.js +128 -128
  36. package/src/components/profile/AUProfileAvatarComponent.js +83 -83
  37. package/src/components/profile/AUProfileAvatarV2Component.js +91 -91
  38. package/src/components/profile/AUProfileAvatarV3Component.tsx +42 -42
  39. package/src/components/profile/AUProfileContainerComponent.js +283 -283
  40. package/src/components/profile/AUProfileHooks.js +30 -30
  41. package/src/components/profile/AUProfileItemComponent.js +54 -54
  42. package/src/components/profile/AUProfileLanguageComponent.js +131 -131
  43. package/src/components/profile/AUProfileLoginComponent.tsx +26 -26
  44. package/src/components/profile/AUProfileMailComponent.js +307 -307
  45. package/src/components/profile/AUProfileMobileComponent.js +164 -164
  46. package/src/components/profile/AUProfileNameComponent.js +253 -253
  47. package/src/components/profile/AUProfileNextOfKinComponent.js +216 -216
  48. package/src/components/profile/AUProfileReducer.js +230 -230
  49. package/src/components/profile/AUProfileWidgetComponent.js +95 -95
  50. package/src/components/profile/AUProfileWidgetV2Component.js +116 -116
  51. package/src/components/profile/AUProfileWidgetV3Component.tsx +122 -122
  52. package/src/components/wrapping/AUEmbedComponent.js +47 -47
  53. package/src/layout-2016/components/alphabox/AlphaBoxComponent.js +143 -143
  54. package/src/layout-2016/components/alphabox/AlphaBoxContentComponent.js +136 -136
  55. package/src/layout-2016/components/common/AUCollapsibleComponent.js +152 -152
  56. package/src/layout-2016/components/common/AUSpinnerComponent.js +103 -103
  57. package/src/layout-2016/components/databox/DataBoxAlphabetComponent.js +144 -144
  58. package/src/layout-2016/components/databox/DataBoxAssociationComponent.js +122 -122
  59. package/src/layout-2016/components/databox/DataBoxButtonComponent.js +157 -157
  60. package/src/layout-2016/components/databox/DataBoxComponent.js +297 -297
  61. package/src/layout-2016/components/databox/DataBoxGroupingComponent.js +64 -64
  62. package/src/layout-2016/components/databox/DataBoxSearchResultComponent.js +36 -36
  63. package/src/layout-2016/components/databox/DataBoxStackedAssociationComponent.js +54 -54
  64. package/src/layout-2016/components/databox/DataBoxSuggestionComponent.js +39 -39
  65. package/src/layout-2016/components/diagramme/AUDiagrammeComponent.js +309 -309
  66. package/src/layout-2016/components/flowbox/FlowBoxComponent.js +126 -126
  67. package/src/layout-2016/components/flowbox/FlowBoxPhoneComponent.js +104 -104
  68. package/src/layout-2016/components/profile/AUProfileAvatar2016Component.js +103 -103
  69. package/src/layout-2016/components/universe/StaffTopComponent.js +363 -363
  70. package/src/layout-2016/components/universe/StudentTopComponent.js +137 -137
  71. package/src/layout-2016/components/universe/UniverseContainerComponent.js +65 -65
  72. package/src/layout-2016/lib/all.js +3 -3
  73. package/src/layout-2016/lib/au-alphabox.js +100 -100
  74. package/src/layout-2016/lib/au-databox.js +400 -400
  75. package/src/layout-2016/lib/au-diagramme.js +85 -85
  76. package/src/layout-2016/lib/au-flowbox.js +93 -93
  77. package/src/layout-2016/lib/universe.js +9 -9
  78. package/src/lib/helpers.ts +194 -194
  79. package/src/lib/hooks.ts +33 -33
  80. package/src/lib/i18n.ts +600 -600
  81. package/src/lib/tracking.ts +69 -69
  82. package/src/lib/wrapping.ts +21 -21
  83. package/src/styles/_settings.scss +10 -10
  84. package/src/styles/alphabox.scss +222 -222
  85. package/src/styles/app.scss +7 -7
  86. package/src/styles/autosuggest.scss +57 -57
  87. package/src/styles/databox.scss +563 -563
  88. package/src/styles/diagramme.scss +119 -119
  89. package/src/styles/flowbox.scss +72 -72
  90. package/src/styles/maps.scss +395 -395
  91. package/stories/AUButtonComponent.stories.tsx +85 -88
  92. package/stories/AUSpinnerComponent.stories.tsx +41 -0
  93. package/tsconfig.json +46 -46
  94. 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;