@aarhus-university/au-lib-react-components 11.3.2 → 11.4.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 (97) hide show
  1. package/.eslintrc.js +34 -34
  2. package/.storybook/main.js +20 -20
  3. package/.storybook/preview.js +17 -17
  4. package/README.md +19 -19
  5. package/__tests__/jest/AUButtonComponent.test.tsx +165 -165
  6. package/__tests__/jest/AUErrorComponent.test.tsx +142 -142
  7. package/__tests__/jest/AUModalComponent.test.tsx +186 -186
  8. package/__tests__/jest/AUNotificationComponent.test.tsx +115 -115
  9. package/__tests__/jest/AUSpinnerComponent.test.tsx +57 -57
  10. package/__tests__/jest/AUToolbarComponent.test.tsx +46 -46
  11. package/__tests__/jest/context.test.ts +25 -25
  12. package/__tests__/jest/helpers.test.ts +15 -15
  13. package/__tests__/jest/setupTests.ts +2 -2
  14. package/babel.config.js +8 -8
  15. package/build/umd/all.css +2 -2
  16. package/build/umd/all.js +1 -1
  17. package/build/umd/alphabox.js +1 -1
  18. package/build/umd/databox.js +1 -1
  19. package/build/umd/diagramme.js +1 -1
  20. package/build/umd/flowbox.js +1 -1
  21. package/build/umd/universe.js +1 -1
  22. package/build-storybook.log +367 -367
  23. package/package.json +114 -114
  24. package/src/components/AUAlertComponent.tsx +70 -70
  25. package/src/components/AUAutoSuggestComponent.js +158 -158
  26. package/src/components/AUButtonComponent.tsx +84 -84
  27. package/src/components/AUCalendarComponent.tsx +493 -493
  28. package/src/components/AUContentToggleComponent.tsx +47 -47
  29. package/src/components/AUDatepickerComponent.tsx +121 -121
  30. package/src/components/AUErrorComponent.tsx +78 -78
  31. package/src/components/AUMobilePrefixComponent.tsx +15 -15
  32. package/src/components/AUModalComponent.tsx +68 -68
  33. package/src/components/AUNotificationComponent.tsx +43 -43
  34. package/src/components/AUReceiptComponent.tsx +33 -33
  35. package/src/components/AUSpinnerComponent.tsx +36 -36
  36. package/src/components/AUStepComponent.tsx +47 -41
  37. package/src/components/AUSubNavComponent.tsx +48 -48
  38. package/src/components/AUSubmitButtonContainerComponent.tsx +29 -29
  39. package/src/components/AUTabbedContentComponent.tsx +145 -145
  40. package/src/components/AUTableComponent.tsx +24 -24
  41. package/src/components/AUToastComponent.tsx +104 -104
  42. package/src/components/AUToolbarComponent.tsx +101 -101
  43. package/src/components/AUTruncatorComponent.tsx +124 -129
  44. package/src/components/wrapping/AUEmbedComponent.js +47 -47
  45. package/src/layout-2016/components/alphabox/AlphaBoxComponent.js +143 -143
  46. package/src/layout-2016/components/alphabox/AlphaBoxContentComponent.js +136 -136
  47. package/src/layout-2016/components/common/AUCollapsibleComponent.js +152 -152
  48. package/src/layout-2016/components/common/AUSpinnerComponent.js +103 -103
  49. package/src/layout-2016/components/databox/DataBoxAlphabetComponent.js +144 -144
  50. package/src/layout-2016/components/databox/DataBoxAssociationComponent.js +122 -122
  51. package/src/layout-2016/components/databox/DataBoxButtonComponent.js +157 -157
  52. package/src/layout-2016/components/databox/DataBoxComponent.js +297 -297
  53. package/src/layout-2016/components/databox/DataBoxGroupingComponent.js +64 -64
  54. package/src/layout-2016/components/databox/DataBoxSearchResultComponent.js +36 -36
  55. package/src/layout-2016/components/databox/DataBoxStackedAssociationComponent.js +54 -54
  56. package/src/layout-2016/components/databox/DataBoxSuggestionComponent.js +39 -39
  57. package/src/layout-2016/components/diagramme/AUDiagrammeComponent.js +309 -309
  58. package/src/layout-2016/components/flowbox/FlowBoxComponent.js +126 -126
  59. package/src/layout-2016/components/flowbox/FlowBoxPhoneComponent.js +104 -104
  60. package/src/layout-2016/components/profile/AUProfileAvatar2016Component.js +103 -103
  61. package/src/layout-2016/components/universe/StaffTopComponent.js +363 -363
  62. package/src/layout-2016/components/universe/StudentTopComponent.js +137 -137
  63. package/src/layout-2016/components/universe/UniverseContainerComponent.js +65 -65
  64. package/src/layout-2016/lib/all.js +3 -3
  65. package/src/layout-2016/lib/au-alphabox.js +100 -100
  66. package/src/layout-2016/lib/au-databox.js +400 -400
  67. package/src/layout-2016/lib/au-diagramme.js +85 -85
  68. package/src/layout-2016/lib/au-flowbox.js +93 -93
  69. package/src/layout-2016/lib/universe.js +9 -9
  70. package/src/lib/context.tsx +51 -51
  71. package/src/lib/dates.ts +50 -50
  72. package/src/lib/helpers.ts +208 -208
  73. package/src/lib/hooks.ts +75 -75
  74. package/src/lib/i18n.ts +600 -600
  75. package/src/lib/portals.tsx +119 -119
  76. package/src/lib/tracking.ts +69 -69
  77. package/src/lib/wrapping.ts +21 -21
  78. package/src/styles/_settings.scss +10 -10
  79. package/src/styles/alphabox.scss +222 -222
  80. package/src/styles/app.scss +7 -7
  81. package/src/styles/autosuggest.scss +57 -57
  82. package/src/styles/databox.scss +563 -563
  83. package/src/styles/diagramme.scss +119 -119
  84. package/src/styles/flowbox.scss +72 -72
  85. package/src/styles/maps.scss +395 -395
  86. package/stories/AUButtonComponent.stories.tsx +127 -127
  87. package/stories/AUContentToggleComponent.stories.tsx +63 -63
  88. package/stories/AUErrorComponent.stories.tsx +98 -98
  89. package/stories/AUModalComponent.stories.tsx +83 -83
  90. package/stories/AUNotificationComponent.stories.tsx +116 -116
  91. package/stories/AUSpinnerComponent.stories.tsx +41 -41
  92. package/stories/AUStepComponent.stories.tsx +40 -40
  93. package/stories/AUToolbarComponent.stories.tsx +326 -326
  94. package/stories/AUTruncatorComponent.stories.tsx +102 -0
  95. package/stories/lib/helpers.tsx +128 -128
  96. package/tsconfig.json +46 -46
  97. package/webpack.config.js +89 -89
@@ -1,158 +1,158 @@
1
- /* eslint-disable @typescript-eslint/no-empty-function */
2
- import React from 'react';
3
- import PropTypes from 'prop-types';
4
- import Autosuggest from 'react-autosuggest';
5
- import debounce from 'lodash.debounce';
6
-
7
- class AUAutoSuggestComponent extends React.Component {
8
- constructor(props) {
9
- super(props);
10
- this.state = {
11
- value: '',
12
- suggestions: [],
13
- noSuggestions: false,
14
- };
15
-
16
- this.onChange = this.onChange.bind(this);
17
- this.onEnter = this.onEnter.bind(this);
18
- this.onSuggestionsFetchRequested = debounce(this.onSuggestionsFetchRequested.bind(this), 400);
19
- this.onSuggestionsClearRequested = this.onSuggestionsClearRequested.bind(this);
20
- this.onSuggestionSelected = this.onSuggestionSelected.bind(this);
21
- }
22
-
23
- onChange(_, { newValue }) {
24
- const { setQuery } = this.props;
25
- this.setState({
26
- value: newValue,
27
- }, () => {
28
- setQuery(newValue);
29
- });
30
- }
31
-
32
- onEnter(event) {
33
- const { suggestions } = this.state;
34
- const { setResults } = this.props;
35
- if (event.key === 'Enter') {
36
- setResults(suggestions);
37
- }
38
- }
39
-
40
- onSuggestionsFetchRequested({ value }) {
41
- const { getSuggestions, collection } = this.props;
42
- getSuggestions(value, collection, (suggestions) => {
43
- this.setState({
44
- suggestions,
45
- noSuggestions: suggestions.length === 0 && value.trim() !== '' && value.trim().length > 1,
46
- });
47
- });
48
- }
49
-
50
- onSuggestionsClearRequested() {
51
- this.setState({
52
- suggestions: [],
53
- });
54
- }
55
-
56
- onSuggestionSelected(event, { suggestion }) {
57
- const { setResults, clearInput } = this.props;
58
- setResults([suggestion]);
59
- if (clearInput) {
60
- this.setState({
61
- value: '',
62
- });
63
- }
64
- }
65
-
66
- render() {
67
- const { value, suggestions, noSuggestions } = this.state;
68
- const {
69
- placeholder,
70
- getSuggestionValue,
71
- renderSuggestion,
72
- id,
73
- theme,
74
- type,
75
- initialValue,
76
- disabled,
77
- noResultsText,
78
- } = this.props;
79
- const inputProps = {
80
- placeholder,
81
- value: initialValue || value,
82
- id,
83
- type,
84
- disabled,
85
- 'aria-label': placeholder,
86
- onChange: this.onChange,
87
- onKeyDown: this.onEnter,
88
- };
89
-
90
- return (
91
- <>
92
- <Autosuggest
93
- suggestions={suggestions}
94
- onSuggestionsFetchRequested={this.onSuggestionsFetchRequested}
95
- onSuggestionsClearRequested={this.onSuggestionsClearRequested}
96
- onSuggestionSelected={this.onSuggestionSelected}
97
- getSuggestionValue={getSuggestionValue}
98
- renderSuggestion={renderSuggestion}
99
- inputProps={inputProps}
100
- theme={theme}
101
- />
102
- {
103
- (noSuggestions && noResultsText) && (
104
- <p className="no-results">
105
- <em>{noResultsText}</em>
106
- </p>
107
- )
108
- }
109
- </>
110
- );
111
- }
112
- }
113
-
114
- AUAutoSuggestComponent.displayName = 'AUAutoSuggestComponent';
115
-
116
- AUAutoSuggestComponent.defaultProps = {
117
- id: 'autosuggest1',
118
- theme: {
119
- container: 'react-autosuggest__container',
120
- containerOpen: 'react-autosuggest__container--open',
121
- input: 'react-autosuggest__input',
122
- inputOpen: 'react-autosuggest__input--open',
123
- inputFocused: 'react-autosuggest__input--focused',
124
- suggestionsContainer: 'react-autosuggest__suggestions-container',
125
- suggestionsContainerOpen: 'react-autosuggest__suggestions-container--open',
126
- suggestionsList: 'react-autosuggest__suggestions-list',
127
- suggestion: 'react-autosuggest__suggestion',
128
- suggestionFirst: 'react-autosuggest__suggestion--first',
129
- suggestionHighlighted: 'react-autosuggest__suggestion--highlighted',
130
- sectionContainer: 'react-autosuggest__section-container',
131
- sectionContainerFirst: 'react-autosuggest__section-container--first',
132
- sectionTitle: 'react-autosuggest__section-title',
133
- },
134
- clearInput: false,
135
- type: 'text',
136
- initialValue: '',
137
- disabled: false,
138
- setQuery: () => { },
139
- noResultsText: '',
140
- };
141
-
142
- AUAutoSuggestComponent.propTypes = {
143
- setQuery: PropTypes.func,
144
- getSuggestions: PropTypes.func.isRequired,
145
- getSuggestionValue: PropTypes.func.isRequired,
146
- renderSuggestion: PropTypes.func.isRequired,
147
- setResults: PropTypes.func.isRequired,
148
- collection: PropTypes.arrayOf(PropTypes.shape({})).isRequired,
149
- placeholder: PropTypes.string.isRequired,
150
- id: PropTypes.string,
151
- theme: PropTypes.shape({}),
152
- clearInput: PropTypes.bool,
153
- type: PropTypes.string,
154
- initialValue: PropTypes.string,
155
- disabled: PropTypes.bool,
156
- noResultsText: PropTypes.string,
157
- };
158
- export default AUAutoSuggestComponent;
1
+ /* eslint-disable @typescript-eslint/no-empty-function */
2
+ import React from 'react';
3
+ import PropTypes from 'prop-types';
4
+ import Autosuggest from 'react-autosuggest';
5
+ import debounce from 'lodash.debounce';
6
+
7
+ class AUAutoSuggestComponent extends React.Component {
8
+ constructor(props) {
9
+ super(props);
10
+ this.state = {
11
+ value: '',
12
+ suggestions: [],
13
+ noSuggestions: false,
14
+ };
15
+
16
+ this.onChange = this.onChange.bind(this);
17
+ this.onEnter = this.onEnter.bind(this);
18
+ this.onSuggestionsFetchRequested = debounce(this.onSuggestionsFetchRequested.bind(this), 400);
19
+ this.onSuggestionsClearRequested = this.onSuggestionsClearRequested.bind(this);
20
+ this.onSuggestionSelected = this.onSuggestionSelected.bind(this);
21
+ }
22
+
23
+ onChange(_, { newValue }) {
24
+ const { setQuery } = this.props;
25
+ this.setState({
26
+ value: newValue,
27
+ }, () => {
28
+ setQuery(newValue);
29
+ });
30
+ }
31
+
32
+ onEnter(event) {
33
+ const { suggestions } = this.state;
34
+ const { setResults } = this.props;
35
+ if (event.key === 'Enter') {
36
+ setResults(suggestions);
37
+ }
38
+ }
39
+
40
+ onSuggestionsFetchRequested({ value }) {
41
+ const { getSuggestions, collection } = this.props;
42
+ getSuggestions(value, collection, (suggestions) => {
43
+ this.setState({
44
+ suggestions,
45
+ noSuggestions: suggestions.length === 0 && value.trim() !== '' && value.trim().length > 1,
46
+ });
47
+ });
48
+ }
49
+
50
+ onSuggestionsClearRequested() {
51
+ this.setState({
52
+ suggestions: [],
53
+ });
54
+ }
55
+
56
+ onSuggestionSelected(event, { suggestion }) {
57
+ const { setResults, clearInput } = this.props;
58
+ setResults([suggestion]);
59
+ if (clearInput) {
60
+ this.setState({
61
+ value: '',
62
+ });
63
+ }
64
+ }
65
+
66
+ render() {
67
+ const { value, suggestions, noSuggestions } = this.state;
68
+ const {
69
+ placeholder,
70
+ getSuggestionValue,
71
+ renderSuggestion,
72
+ id,
73
+ theme,
74
+ type,
75
+ initialValue,
76
+ disabled,
77
+ noResultsText,
78
+ } = this.props;
79
+ const inputProps = {
80
+ placeholder,
81
+ value: initialValue || value,
82
+ id,
83
+ type,
84
+ disabled,
85
+ 'aria-label': placeholder,
86
+ onChange: this.onChange,
87
+ onKeyDown: this.onEnter,
88
+ };
89
+
90
+ return (
91
+ <>
92
+ <Autosuggest
93
+ suggestions={suggestions}
94
+ onSuggestionsFetchRequested={this.onSuggestionsFetchRequested}
95
+ onSuggestionsClearRequested={this.onSuggestionsClearRequested}
96
+ onSuggestionSelected={this.onSuggestionSelected}
97
+ getSuggestionValue={getSuggestionValue}
98
+ renderSuggestion={renderSuggestion}
99
+ inputProps={inputProps}
100
+ theme={theme}
101
+ />
102
+ {
103
+ (noSuggestions && noResultsText) && (
104
+ <p className="no-results">
105
+ <em>{noResultsText}</em>
106
+ </p>
107
+ )
108
+ }
109
+ </>
110
+ );
111
+ }
112
+ }
113
+
114
+ AUAutoSuggestComponent.displayName = 'AUAutoSuggestComponent';
115
+
116
+ AUAutoSuggestComponent.defaultProps = {
117
+ id: 'autosuggest1',
118
+ theme: {
119
+ container: 'react-autosuggest__container',
120
+ containerOpen: 'react-autosuggest__container--open',
121
+ input: 'react-autosuggest__input',
122
+ inputOpen: 'react-autosuggest__input--open',
123
+ inputFocused: 'react-autosuggest__input--focused',
124
+ suggestionsContainer: 'react-autosuggest__suggestions-container',
125
+ suggestionsContainerOpen: 'react-autosuggest__suggestions-container--open',
126
+ suggestionsList: 'react-autosuggest__suggestions-list',
127
+ suggestion: 'react-autosuggest__suggestion',
128
+ suggestionFirst: 'react-autosuggest__suggestion--first',
129
+ suggestionHighlighted: 'react-autosuggest__suggestion--highlighted',
130
+ sectionContainer: 'react-autosuggest__section-container',
131
+ sectionContainerFirst: 'react-autosuggest__section-container--first',
132
+ sectionTitle: 'react-autosuggest__section-title',
133
+ },
134
+ clearInput: false,
135
+ type: 'text',
136
+ initialValue: '',
137
+ disabled: false,
138
+ setQuery: () => { },
139
+ noResultsText: '',
140
+ };
141
+
142
+ AUAutoSuggestComponent.propTypes = {
143
+ setQuery: PropTypes.func,
144
+ getSuggestions: PropTypes.func.isRequired,
145
+ getSuggestionValue: PropTypes.func.isRequired,
146
+ renderSuggestion: PropTypes.func.isRequired,
147
+ setResults: PropTypes.func.isRequired,
148
+ collection: PropTypes.arrayOf(PropTypes.shape({})).isRequired,
149
+ placeholder: PropTypes.string.isRequired,
150
+ id: PropTypes.string,
151
+ theme: PropTypes.shape({}),
152
+ clearInput: PropTypes.bool,
153
+ type: PropTypes.string,
154
+ initialValue: PropTypes.string,
155
+ disabled: PropTypes.bool,
156
+ noResultsText: PropTypes.string,
157
+ };
158
+ export default AUAutoSuggestComponent;
@@ -1,84 +1,84 @@
1
- import React, {
2
- FC, MouseEvent, RefObject,
3
- } from 'react';
4
-
5
- const AUButtonComponent: FC<AUButtonComponentProps> = ({
6
- label,
7
- disabled,
8
- size,
9
- type,
10
- icon,
11
- iconPosition,
12
- hideLabel,
13
- mode,
14
- btnRef,
15
- classNames,
16
- ariaExpanded,
17
- asSubmit,
18
- onClick,
19
- }: AUButtonComponentProps) => {
20
- const sizeClass = size === 'default' ? '' : `button--${size}`;
21
- const typeClass = type === 'default' ? '' : `button--${type}`;
22
- let iconClass = '';
23
- if (icon) {
24
- iconClass = `button--icon icon-${icon}`;
25
- if (iconPosition) {
26
- iconClass = `${iconClass} button--icon--${iconPosition}`;
27
- }
28
-
29
- if (hideLabel) {
30
- iconClass = `${iconClass} button--icon--hide-label`;
31
- }
32
- }
33
- let modeClass = '';
34
- if (mode !== 'none') {
35
- modeClass = `button--${mode}`;
36
- }
37
-
38
- return (
39
- <button
40
- ref={btnRef}
41
- type={asSubmit ? 'submit' : 'button'}
42
- disabled={disabled}
43
- className={[
44
- 'button',
45
- sizeClass,
46
- typeClass,
47
- iconClass,
48
- modeClass,
49
- disabled && mode !== 'processing' ? 'visually-disabled' : '',
50
- ].concat(classNames || []).join(' ').replace(/\s+/g, ' ').trim()}
51
- title={icon && hideLabel ? label : undefined}
52
- aria-expanded={ariaExpanded}
53
- onClick={(event: MouseEvent<HTMLButtonElement>) => {
54
- if (typeof onClick !== 'undefined') {
55
- onClick(event, btnRef);
56
- }
57
- }}
58
- >
59
- {label}
60
- </button>
61
- );
62
- };
63
-
64
- AUButtonComponent.defaultProps = {
65
- disabled: false,
66
- size: 'default',
67
- type: 'default',
68
- icon: '',
69
- iconPosition: 'left',
70
- hideLabel: false,
71
- mode: 'none',
72
- classNames: [],
73
- ariaExpanded: false,
74
- asSubmit: false,
75
- // eslint-disable-next-line no-console
76
- onClick: (
77
- event: MouseEvent<HTMLButtonElement>,
78
- ref: RefObject<HTMLButtonElement> | undefined,
79
- // eslint-disable-next-line no-console
80
- ) => console.log(event, ref),
81
- };
82
-
83
- AUButtonComponent.displayName = 'AUButtonComponent';
84
- export default AUButtonComponent;
1
+ import React, {
2
+ FC, MouseEvent, RefObject,
3
+ } from 'react';
4
+
5
+ const AUButtonComponent: FC<AUButtonComponentProps> = ({
6
+ label,
7
+ disabled,
8
+ size,
9
+ type,
10
+ icon,
11
+ iconPosition,
12
+ hideLabel,
13
+ mode,
14
+ btnRef,
15
+ classNames,
16
+ ariaExpanded,
17
+ asSubmit,
18
+ onClick,
19
+ }: AUButtonComponentProps) => {
20
+ const sizeClass = size === 'default' ? '' : `button--${size}`;
21
+ const typeClass = type === 'default' ? '' : `button--${type}`;
22
+ let iconClass = '';
23
+ if (icon) {
24
+ iconClass = `button--icon icon-${icon}`;
25
+ if (iconPosition) {
26
+ iconClass = `${iconClass} button--icon--${iconPosition}`;
27
+ }
28
+
29
+ if (hideLabel) {
30
+ iconClass = `${iconClass} button--icon--hide-label`;
31
+ }
32
+ }
33
+ let modeClass = '';
34
+ if (mode !== 'none') {
35
+ modeClass = `button--${mode}`;
36
+ }
37
+
38
+ return (
39
+ <button
40
+ ref={btnRef}
41
+ type={asSubmit ? 'submit' : 'button'}
42
+ disabled={disabled}
43
+ className={[
44
+ 'button',
45
+ sizeClass,
46
+ typeClass,
47
+ iconClass,
48
+ modeClass,
49
+ disabled && mode !== 'processing' ? 'visually-disabled' : '',
50
+ ].concat(classNames || []).join(' ').replace(/\s+/g, ' ').trim()}
51
+ title={icon && hideLabel ? label : undefined}
52
+ aria-expanded={ariaExpanded}
53
+ onClick={(event: MouseEvent<HTMLButtonElement>) => {
54
+ if (typeof onClick !== 'undefined') {
55
+ onClick(event, btnRef);
56
+ }
57
+ }}
58
+ >
59
+ {label}
60
+ </button>
61
+ );
62
+ };
63
+
64
+ AUButtonComponent.defaultProps = {
65
+ disabled: false,
66
+ size: 'default',
67
+ type: 'default',
68
+ icon: '',
69
+ iconPosition: 'left',
70
+ hideLabel: false,
71
+ mode: 'none',
72
+ classNames: [],
73
+ ariaExpanded: false,
74
+ asSubmit: false,
75
+ // eslint-disable-next-line no-console
76
+ onClick: (
77
+ event: MouseEvent<HTMLButtonElement>,
78
+ ref: RefObject<HTMLButtonElement> | undefined,
79
+ // eslint-disable-next-line no-console
80
+ ) => console.log(event, ref),
81
+ };
82
+
83
+ AUButtonComponent.displayName = 'AUButtonComponent';
84
+ export default AUButtonComponent;