@aarhus-university/au-lib-react-components 9.11.18 → 9.12.1
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/.eslintrc +18 -18
- package/README.md +20 -20
- package/babel.config.js +6 -6
- package/build/dev.html +328 -328
- package/build/umd/all.css +2 -2
- package/build/umd/all.css.map +1 -1
- package/build/umd/all.js +1 -1
- package/build/umd/alphabox.js +1 -1
- package/build/umd/alphabox.js.map +1 -1
- package/build/umd/auAuth.js +1 -1
- package/build/umd/auAuth.js.map +1 -1
- package/build/umd/databox.js +2 -2
- package/build/umd/databox.js.LICENSE.txt +5 -5
- package/build/umd/databox.js.map +1 -1
- package/build/umd/diagramme.js +1 -1
- package/build/umd/flowbox.js +1 -1
- package/build/umd/flowbox.js.map +1 -1
- package/build/umd/news.js +1 -1
- package/build/umd/news.js.map +1 -1
- package/build/umd/universe.js +1 -1
- package/build/umd/universe.js.map +1 -1
- package/package.json +60 -60
- package/src/all.js +3 -3
- package/src/app.js +263 -263
- package/src/components/AUAlertComponent.js +158 -158
- package/src/components/AUAmountComponent.js +84 -84
- package/src/components/AUBannerComponent.js +99 -99
- package/src/components/AUCalendarComponent.js +393 -393
- package/src/components/AUCollapsibleComponent.js +173 -173
- package/src/components/AUDatepickerComponent.js +105 -105
- package/src/components/AUDiagrammeComponent.js +310 -310
- package/src/components/AUFilterCheckboxComponent.js +122 -122
- package/src/components/AUFocusComponent.js +55 -55
- package/src/components/AUModalComponent.js +94 -94
- package/src/components/AUPaginationComponent.js +103 -103
- package/src/components/AUSpinnerComponent.js +125 -125
- package/src/components/AutoSuggestComponent.js +157 -132
- package/src/components/alphabox/AlphaBoxComponent.js +145 -140
- package/src/components/alphabox/AlphaBoxContentComponent.js +136 -125
- package/src/components/context/AUUserContextComponent.js +91 -91
- package/src/components/context/ImpersonateComponent.js +54 -54
- package/src/components/databox/DataBoxAlphabetComponent.js +144 -144
- package/src/components/databox/DataBoxAssociationComponent.js +122 -122
- package/src/components/databox/DataBoxButtonComponent.js +153 -153
- package/src/components/databox/DataBoxComponent.js +297 -297
- package/src/components/databox/DataBoxGroupingComponent.js +62 -62
- package/src/components/databox/DataBoxSearchResultComponent.js +40 -40
- package/src/components/databox/DataBoxStackedAssociationComponent.js +58 -58
- package/src/components/databox/DataBoxSuggestionComponent.js +39 -39
- package/src/components/delphinus/AUAlertComponent.js +85 -85
- package/src/components/delphinus/AUCalendarComponent.js +487 -487
- package/src/components/delphinus/AUContentToggleComponent.js +32 -32
- package/src/components/delphinus/AUDatepickerComponent.js +164 -164
- package/src/components/delphinus/AULoginComponent.js +65 -65
- package/src/components/delphinus/AUModalComponent.js +94 -94
- package/src/components/delphinus/AUSpinnerComponent.js +114 -114
- package/src/components/delphinus/AUSubNavComponent.js +53 -53
- package/src/components/delphinus/AUTabbedContentComponent.js +150 -150
- package/src/components/delphinus/AUTableComponent.js +28 -28
- package/src/components/delphinus/AUToastComponent.js +91 -91
- package/src/components/delphinus/AUToolbarComponent.js +48 -48
- package/src/components/delphinus/hooks.js +28 -28
- package/src/components/flowbox/FlowBoxComponent.js +126 -126
- package/src/components/flowbox/FlowBoxPhoneComponent.js +106 -106
- package/src/components/form/AUMobilePrefixComponent.js +18 -18
- package/src/components/form/AUReceiptComponent.js +40 -40
- package/src/components/form/AUSubmitButtonContainerComponent.js +39 -39
- package/src/components/news/EventLayout1Component.js +94 -94
- package/src/components/news/EventLayout2Component.js +90 -90
- package/src/components/news/EventLayout3Component.js +68 -68
- package/src/components/news/NewsCategoriesComponent.js +21 -21
- package/src/components/news/NewsCollageBannerComponent.js +71 -71
- package/src/components/news/NewsCollageBannerRSSComponent.js +79 -79
- package/src/components/news/NewsColumnsComponent.js +125 -125
- package/src/components/news/NewsLanguageChangeComponent.js +74 -74
- package/src/components/news/NewsLayout1Component.js +80 -80
- package/src/components/news/NewsLayout2Component.js +80 -80
- package/src/components/news/NewsLayout3Component.js +81 -81
- package/src/components/news/NewsLayout4Component.js +80 -80
- package/src/components/news/NewsLayout5Component.js +61 -61
- package/src/components/news/NewsLayout6Component.js +55 -55
- package/src/components/news/NewsLayout7Component.js +58 -58
- package/src/components/news/NewsLayout8Component.js +57 -57
- package/src/components/news/NewsListComponent.js +291 -291
- package/src/components/news/NewsPopUpComponent.js +591 -591
- package/src/components/news/NewsRSSComponent.js +74 -74
- package/src/components/news/NewsSocialComponent.js +104 -104
- package/src/components/news/NewsSubHeaderComponent.js +19 -19
- package/src/components/password/AUChangePasswordComponent.js +190 -177
- package/src/components/password/AUCurrentPasswordComponent.js +72 -72
- package/src/components/password/AUNewPasswordComponent.js +143 -143
- package/src/components/password/AUPasswordActions.js +101 -101
- package/src/components/password/AUPasswordHooks.js +47 -47
- package/src/components/password/AUPasswordReducer.js +78 -78
- package/src/components/password/AUPasswordRequirementsComponent.js +29 -29
- package/src/components/profile/AUProfileActions.js +128 -128
- package/src/components/profile/AUProfileAvatar2016Component.js +99 -99
- package/src/components/profile/AUProfileAvatarComponent.js +83 -83
- package/src/components/profile/AUProfileAvatarV2Component.js +91 -91
- package/src/components/profile/AUProfileAvatarV3Component.js +80 -80
- package/src/components/profile/AUProfileContainerComponent.js +283 -283
- package/src/components/profile/AUProfileHooks.js +30 -30
- package/src/components/profile/AUProfileItemComponent.js +54 -54
- package/src/components/profile/AUProfileLanguageComponent.js +131 -131
- package/src/components/profile/AUProfileLoginComponent.js +41 -41
- package/src/components/profile/AUProfileMailComponent.js +307 -307
- package/src/components/profile/AUProfileMobileComponent.js +164 -164
- package/src/components/profile/AUProfileNameComponent.js +253 -253
- package/src/components/profile/AUProfileNextOfKinComponent.js +216 -216
- package/src/components/profile/AUProfileReducer.js +230 -230
- package/src/components/profile/AUProfileWidgetComponent.js +95 -95
- package/src/components/profile/AUProfileWidgetV2Component.js +116 -116
- package/src/components/profile/AUProfileWidgetV3Component.js +130 -130
- package/src/components/universe/StaffTopComponent.js +362 -362
- package/src/components/universe/StudentTopComponent.js +137 -137
- package/src/components/universe/UniverseContainerComponent.js +62 -62
- package/src/components/wrapping/AUEmbedComponent.js +47 -47
- package/src/config/webpack.dev.config.js +47 -47
- package/src/config/webpack.umd.config.js +86 -85
- package/src/index.js +6 -6
- package/src/lib/au-alphabox.js +102 -102
- package/src/lib/au-auth.js +227 -227
- package/src/lib/au-databox.js +403 -403
- package/src/lib/au-diagramme.js +87 -87
- package/src/lib/au-flowbox.js +95 -95
- package/src/lib/au-news.js +371 -371
- package/src/lib/helpers.js +222 -219
- package/src/lib/i18n.js +603 -601
- package/src/lib/menu.js +10 -10
- package/src/lib/tracking.js +65 -65
- package/src/lib/universe.js +9 -9
- package/src/lib/urlHandler.js +63 -63
- package/src/lib/validation.js +219 -181
- package/src/lib/wrapping.js +16 -16
- package/src/styles/_settings.scss +10 -10
- package/src/styles/alert.scss +39 -39
- package/src/styles/alphabox.scss +222 -208
- package/src/styles/app.scss +13 -13
- package/src/styles/autosuggest.scss +57 -57
- package/src/styles/calendar.scss +111 -111
- package/src/styles/databox.scss +563 -563
- package/src/styles/diagramme.scss +119 -119
- package/src/styles/filtercheckbox.scss +4 -4
- package/src/styles/flowbox.scss +72 -72
- package/src/styles/maps.scss +395 -395
- package/src/styles/modal.scss +34 -34
- package/src/styles/pagination.scss +10 -10
- package/src/styles/spinner.scss +30 -30
|
@@ -1,132 +1,157 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import Autosuggest from 'react-autosuggest';
|
|
4
|
-
import debounce from 'lodash.debounce';
|
|
5
|
-
|
|
6
|
-
class AutoSuggestComponent extends React.Component {
|
|
7
|
-
constructor(props) {
|
|
8
|
-
super(props);
|
|
9
|
-
this.state = {
|
|
10
|
-
value: '',
|
|
11
|
-
suggestions: [],
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
this.
|
|
16
|
-
this.
|
|
17
|
-
this.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import Autosuggest from 'react-autosuggest';
|
|
4
|
+
import debounce from 'lodash.debounce';
|
|
5
|
+
|
|
6
|
+
class AutoSuggestComponent extends React.Component {
|
|
7
|
+
constructor(props) {
|
|
8
|
+
super(props);
|
|
9
|
+
this.state = {
|
|
10
|
+
value: '',
|
|
11
|
+
suggestions: [],
|
|
12
|
+
noSuggestions: false,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
this.onChange = this.onChange.bind(this);
|
|
16
|
+
this.onEnter = this.onEnter.bind(this);
|
|
17
|
+
this.onSuggestionsFetchRequested = debounce(this.onSuggestionsFetchRequested.bind(this), 400);
|
|
18
|
+
this.onSuggestionsClearRequested = this.onSuggestionsClearRequested.bind(this);
|
|
19
|
+
this.onSuggestionSelected = this.onSuggestionSelected.bind(this);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
onChange(_, { newValue }) {
|
|
23
|
+
const { setQuery } = this.props;
|
|
24
|
+
this.setState({
|
|
25
|
+
value: newValue,
|
|
26
|
+
}, () => {
|
|
27
|
+
setQuery(newValue);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
onEnter(event) {
|
|
32
|
+
const { suggestions } = this.state;
|
|
33
|
+
const { setResults } = this.props;
|
|
34
|
+
if (event.key === 'Enter') {
|
|
35
|
+
setResults(suggestions);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
onSuggestionsFetchRequested({ value }) {
|
|
40
|
+
const { getSuggestions, collection } = this.props;
|
|
41
|
+
getSuggestions(value, collection, (suggestions) => {
|
|
42
|
+
this.setState({
|
|
43
|
+
suggestions,
|
|
44
|
+
noSuggestions: suggestions.length === 0 && value.trim() !== '' && value.trim().length > 1,
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
onSuggestionsClearRequested() {
|
|
50
|
+
this.setState({
|
|
51
|
+
suggestions: [],
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
onSuggestionSelected(event, { suggestion }) {
|
|
56
|
+
const { setResults, clearInput } = this.props;
|
|
57
|
+
setResults([suggestion]);
|
|
58
|
+
if (clearInput) {
|
|
59
|
+
this.setState({
|
|
60
|
+
value: '',
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
render() {
|
|
66
|
+
const { value, suggestions, noSuggestions } = this.state;
|
|
67
|
+
const {
|
|
68
|
+
placeholder,
|
|
69
|
+
getSuggestionValue,
|
|
70
|
+
renderSuggestion,
|
|
71
|
+
id,
|
|
72
|
+
theme,
|
|
73
|
+
type,
|
|
74
|
+
initialValue,
|
|
75
|
+
disabled,
|
|
76
|
+
noResultsText,
|
|
77
|
+
} = this.props;
|
|
78
|
+
const inputProps = {
|
|
79
|
+
placeholder,
|
|
80
|
+
value: initialValue || value,
|
|
81
|
+
id,
|
|
82
|
+
type,
|
|
83
|
+
disabled,
|
|
84
|
+
'aria-label': placeholder,
|
|
85
|
+
onChange: this.onChange,
|
|
86
|
+
onKeyDown: this.onEnter,
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
return (
|
|
90
|
+
<>
|
|
91
|
+
<Autosuggest
|
|
92
|
+
suggestions={suggestions}
|
|
93
|
+
onSuggestionsFetchRequested={this.onSuggestionsFetchRequested}
|
|
94
|
+
onSuggestionsClearRequested={this.onSuggestionsClearRequested}
|
|
95
|
+
onSuggestionSelected={this.onSuggestionSelected}
|
|
96
|
+
getSuggestionValue={getSuggestionValue}
|
|
97
|
+
renderSuggestion={renderSuggestion}
|
|
98
|
+
inputProps={inputProps}
|
|
99
|
+
theme={theme}
|
|
100
|
+
/>
|
|
101
|
+
{
|
|
102
|
+
(noSuggestions && noResultsText) && (
|
|
103
|
+
<p className="no-results">
|
|
104
|
+
<em>{noResultsText}</em>
|
|
105
|
+
</p>
|
|
106
|
+
)
|
|
107
|
+
}
|
|
108
|
+
</>
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
AutoSuggestComponent.displayName = 'AutoSuggestComponent';
|
|
114
|
+
|
|
115
|
+
AutoSuggestComponent.defaultProps = {
|
|
116
|
+
id: 'autosuggest1',
|
|
117
|
+
theme: {
|
|
118
|
+
container: 'react-autosuggest__container',
|
|
119
|
+
containerOpen: 'react-autosuggest__container--open',
|
|
120
|
+
input: 'react-autosuggest__input',
|
|
121
|
+
inputOpen: 'react-autosuggest__input--open',
|
|
122
|
+
inputFocused: 'react-autosuggest__input--focused',
|
|
123
|
+
suggestionsContainer: 'react-autosuggest__suggestions-container',
|
|
124
|
+
suggestionsContainerOpen: 'react-autosuggest__suggestions-container--open',
|
|
125
|
+
suggestionsList: 'react-autosuggest__suggestions-list',
|
|
126
|
+
suggestion: 'react-autosuggest__suggestion',
|
|
127
|
+
suggestionFirst: 'react-autosuggest__suggestion--first',
|
|
128
|
+
suggestionHighlighted: 'react-autosuggest__suggestion--highlighted',
|
|
129
|
+
sectionContainer: 'react-autosuggest__section-container',
|
|
130
|
+
sectionContainerFirst: 'react-autosuggest__section-container--first',
|
|
131
|
+
sectionTitle: 'react-autosuggest__section-title',
|
|
132
|
+
},
|
|
133
|
+
clearInput: false,
|
|
134
|
+
type: 'text',
|
|
135
|
+
initialValue: '',
|
|
136
|
+
disabled: false,
|
|
137
|
+
setQuery: () => { },
|
|
138
|
+
noResultsText: '',
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
AutoSuggestComponent.propTypes = {
|
|
142
|
+
setQuery: PropTypes.func,
|
|
143
|
+
getSuggestions: PropTypes.func.isRequired,
|
|
144
|
+
getSuggestionValue: PropTypes.func.isRequired,
|
|
145
|
+
renderSuggestion: PropTypes.func.isRequired,
|
|
146
|
+
setResults: PropTypes.func.isRequired,
|
|
147
|
+
collection: PropTypes.arrayOf(PropTypes.any).isRequired,
|
|
148
|
+
placeholder: PropTypes.string.isRequired,
|
|
149
|
+
id: PropTypes.string,
|
|
150
|
+
theme: PropTypes.shape({}),
|
|
151
|
+
clearInput: PropTypes.bool,
|
|
152
|
+
type: PropTypes.string,
|
|
153
|
+
initialValue: PropTypes.string,
|
|
154
|
+
disabled: PropTypes.bool,
|
|
155
|
+
noResultsText: PropTypes.string,
|
|
156
|
+
};
|
|
157
|
+
export default AutoSuggestComponent;
|
|
@@ -1,140 +1,145 @@
|
|
|
1
|
-
/* eslint-env browser */
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
|
-
import axios from 'axios';
|
|
5
|
-
import AlphaBoxContentComponent from './AlphaBoxContentComponent';
|
|
6
|
-
import AutoSuggestComponent from '../AutoSuggestComponent';
|
|
7
|
-
import DataBoxSuggestionComponent from '../databox/DataBoxSuggestionComponent';
|
|
8
|
-
|
|
9
|
-
class AlphaBoxComponent extends React.Component {
|
|
10
|
-
constructor(props) {
|
|
11
|
-
super(props);
|
|
12
|
-
|
|
13
|
-
this.state = {
|
|
14
|
-
items: [],
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
this.getSuggestions = this.getSuggestions.bind(this);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
componentDidMount() {
|
|
21
|
-
const { box } = this.props;
|
|
22
|
-
const { data } = box;
|
|
23
|
-
if (data.mode === 'json' && data.source !== '') {
|
|
24
|
-
if (data.itemsOnly) {
|
|
25
|
-
data.source += '?itemsOnly=true';
|
|
26
|
-
}
|
|
27
|
-
axios.get(data.source).then((promise) => {
|
|
28
|
-
const { data: pData } = promise;
|
|
29
|
-
this.setState({ items: pData.items });
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
getSuggestions(value,
|
|
35
|
-
const { items } = this.state;
|
|
36
|
-
const inputValue = value.trim().toLowerCase();
|
|
37
|
-
const inputLength = inputValue.length;
|
|
38
|
-
callback(inputLength < 2 ? []
|
|
39
|
-
: items.filter(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
1
|
+
/* eslint-env browser */
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import axios from 'axios';
|
|
5
|
+
import AlphaBoxContentComponent from './AlphaBoxContentComponent';
|
|
6
|
+
import AutoSuggestComponent from '../AutoSuggestComponent';
|
|
7
|
+
import DataBoxSuggestionComponent from '../databox/DataBoxSuggestionComponent';
|
|
8
|
+
|
|
9
|
+
class AlphaBoxComponent extends React.Component {
|
|
10
|
+
constructor(props) {
|
|
11
|
+
super(props);
|
|
12
|
+
|
|
13
|
+
this.state = {
|
|
14
|
+
items: [],
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
this.getSuggestions = this.getSuggestions.bind(this);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
componentDidMount() {
|
|
21
|
+
const { box } = this.props;
|
|
22
|
+
const { data } = box;
|
|
23
|
+
if (data.mode === 'json' && data.source !== '') {
|
|
24
|
+
if (data.itemsOnly) {
|
|
25
|
+
data.source += '?itemsOnly=true';
|
|
26
|
+
}
|
|
27
|
+
axios.get(data.source).then((promise) => {
|
|
28
|
+
const { data: pData } = promise;
|
|
29
|
+
this.setState({ items: pData.items });
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
getSuggestions(value, _, callback) {
|
|
35
|
+
const { items } = this.state;
|
|
36
|
+
const inputValue = value.trim().toLowerCase();
|
|
37
|
+
const inputLength = inputValue.length;
|
|
38
|
+
callback(inputLength < 2 ? []
|
|
39
|
+
: items.filter(
|
|
40
|
+
(x) => x.name.toLowerCase().indexOf(inputValue) > -1
|
|
41
|
+
|| x.name.replace(/-/ig, ' ').toLowerCase().indexOf(inputValue) > -1
|
|
42
|
+
|| x.name.replace(/ /ig, '-').toLowerCase().indexOf(inputValue) > -1,
|
|
43
|
+
)
|
|
44
|
+
.sort((a, b) => a.name.toLowerCase().localeCompare(b.name.toLowerCase(), 'da', { ignorePunctuation: true })));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
render() {
|
|
48
|
+
const { box } = this.props;
|
|
49
|
+
const { items } = this.state;
|
|
50
|
+
const { config } = box;
|
|
51
|
+
const renderLinks = config.links.map((l) => (
|
|
52
|
+
<li key={l.title}>
|
|
53
|
+
<a
|
|
54
|
+
href={l.url}
|
|
55
|
+
onClick={() => {
|
|
56
|
+
if (typeof l.onClick === 'function') {
|
|
57
|
+
l.onClick();
|
|
58
|
+
}
|
|
59
|
+
}}
|
|
60
|
+
style={{ backgroundColor: box.background.linkColor }}
|
|
61
|
+
>
|
|
62
|
+
{l.title}
|
|
63
|
+
</a>
|
|
64
|
+
</li>
|
|
65
|
+
));
|
|
66
|
+
|
|
67
|
+
return (
|
|
68
|
+
<div className="au_alphabox" style={{ backgroundColor: box.background.color }}>
|
|
69
|
+
<div>
|
|
70
|
+
<h2>
|
|
71
|
+
<a href={config.url}>{config.title}</a>
|
|
72
|
+
</h2>
|
|
73
|
+
<AlphaBoxContentComponent
|
|
74
|
+
items={items}
|
|
75
|
+
linkColor={box.background.linkColor}
|
|
76
|
+
noResultsText={config.noResultsAlphabet}
|
|
77
|
+
noResultsUri={config.noResultsUri}
|
|
78
|
+
/>
|
|
79
|
+
<AutoSuggestComponent
|
|
80
|
+
placeholder={box.search.placeHolder}
|
|
81
|
+
setResults={(_items) => {
|
|
82
|
+
if (_items.length >= 1 && _items[0].url) {
|
|
83
|
+
window.location.href = _items[0].url;
|
|
84
|
+
}
|
|
85
|
+
}}
|
|
86
|
+
collection={[]}
|
|
87
|
+
getSuggestions={this.getSuggestions}
|
|
88
|
+
getSuggestionValue={(suggestion) => suggestion.name}
|
|
89
|
+
renderSuggestion={(suggestion) => <DataBoxSuggestionComponent item={suggestion} />}
|
|
90
|
+
noResultsText={config.noResultsSearch}
|
|
91
|
+
/>
|
|
92
|
+
{
|
|
93
|
+
config.description !== '' && (
|
|
94
|
+
<h3>{config.description}</h3>
|
|
95
|
+
)
|
|
96
|
+
}
|
|
97
|
+
{
|
|
98
|
+
config.links.length > 0 && (
|
|
99
|
+
<ul className="quicklinks resetlist">
|
|
100
|
+
{renderLinks}
|
|
101
|
+
</ul>
|
|
102
|
+
)
|
|
103
|
+
}
|
|
104
|
+
</div>
|
|
105
|
+
</div>
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
AlphaBoxComponent.propTypes = {
|
|
111
|
+
box: PropTypes.shape({
|
|
112
|
+
id: PropTypes.number.isRequired,
|
|
113
|
+
data: PropTypes.shape({
|
|
114
|
+
itemsOnly: PropTypes.bool.isRequired,
|
|
115
|
+
mode: PropTypes.string.isRequired,
|
|
116
|
+
source: PropTypes.string.isRequired,
|
|
117
|
+
}),
|
|
118
|
+
config: PropTypes.shape({
|
|
119
|
+
name: PropTypes.string.isRequired,
|
|
120
|
+
url: PropTypes.string.isRequired,
|
|
121
|
+
description: PropTypes.string.isRequired,
|
|
122
|
+
container: PropTypes.string.isRequired,
|
|
123
|
+
tracking: PropTypes.string.isRequired,
|
|
124
|
+
links: PropTypes.arrayOf(PropTypes.shape({
|
|
125
|
+
title: PropTypes.string.isRequired,
|
|
126
|
+
url: PropTypes.string.isRequired,
|
|
127
|
+
})).isRequired,
|
|
128
|
+
title: PropTypes.string.isRequired,
|
|
129
|
+
noResultsAlphabet: PropTypes.string.isRequired,
|
|
130
|
+
noResultsSearch: PropTypes.string.isRequired,
|
|
131
|
+
noResultsUri: PropTypes.string.isRequired,
|
|
132
|
+
}).isRequired,
|
|
133
|
+
background: PropTypes.shape({
|
|
134
|
+
color: PropTypes.string.isRequired,
|
|
135
|
+
linkColor: PropTypes.string.isRequired,
|
|
136
|
+
}).isRequired,
|
|
137
|
+
search: PropTypes.shape({
|
|
138
|
+
placeHolder: PropTypes.string.isRequired,
|
|
139
|
+
minLength: PropTypes.number.isRequired,
|
|
140
|
+
}).isRequired,
|
|
141
|
+
}).isRequired,
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
AlphaBoxComponent.displayName = 'AlphaBoxComponent';
|
|
145
|
+
export default AlphaBoxComponent;
|