@uncinc/uncinc-react-kitchen-sink 2.3.2 → 2.3.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.
- package/dist/Context/withMapping.js +1 -6
- package/dist/components/Accordion/AccordionItem/index.js +0 -5
- package/dist/components/Accordion/AccordionItemVariant/index.js +0 -5
- package/dist/components/Accordion/index.js +0 -2
- package/dist/components/ApiAutocomplete/index.js +6 -12
- package/dist/components/Button/index.js +4 -10
- package/dist/components/Cookie/Checkbox/index.js +0 -2
- package/dist/components/Cookie/index.js +39 -34
- package/dist/components/FontSizeSwitcher/index.js +2 -8
- package/dist/components/Form/Checkbox/index.js +1 -4
- package/dist/components/Form/Checkbox/stories.js +0 -2
- package/dist/components/Form/Checkboxes/index.js +1 -7
- package/dist/components/Form/Checkboxes/index.test.js +8 -4
- package/dist/components/Form/Checkboxes/stories.js +1 -4
- package/dist/components/Form/Date/index.js +1 -4
- package/dist/components/Form/Date/stories.js +0 -2
- package/dist/components/Form/DatePicker/index.js +0 -2
- package/dist/components/Form/DatePicker/stories.js +0 -2
- package/dist/components/Form/DateSelect/index.js +110 -85
- package/dist/components/Form/DateSelect/stories.js +24 -15
- package/dist/components/Form/DateSelect/style.scss +10 -4
- package/dist/components/Form/Email/index.js +1 -4
- package/dist/components/Form/Email/stories.js +0 -2
- package/dist/components/Form/FormikWrapper/index.js +9 -15
- package/dist/components/Form/GenericFormElement/index.js +0 -2
- package/dist/components/Form/Number/index.js +1 -10
- package/dist/components/Form/Number/stories.js +0 -2
- package/dist/components/Form/RadioButtons/index.js +1 -7
- package/dist/components/Form/RadioButtons/index.test.js +8 -4
- package/dist/components/Form/RadioButtons/stories.js +1 -4
- package/dist/components/Form/SearchField/index.js +0 -2
- package/dist/components/Form/Select/Input/index.js +4 -14
- package/dist/components/Form/Select/index.js +1 -4
- package/dist/components/Form/Select/stories.js +0 -4
- package/dist/components/Form/TextField/index.js +0 -6
- package/dist/components/Form/TextField/index.test.js +8 -4
- package/dist/components/Form/TextField/stories.js +1 -4
- package/dist/components/Form/Textarea/index.js +0 -2
- package/dist/components/Form/Textarea/stories.js +0 -2
- package/dist/components/Hamburger/index.js +0 -2
- package/dist/components/Header/index.js +4 -9
- package/dist/components/Image/Background/index.js +1 -7
- package/dist/components/Image/LazyLoadWrapper/index.js +0 -12
- package/dist/components/Image/Picture/index.js +4 -19
- package/dist/components/Image/index.js +0 -4
- package/dist/components/InlineMenu/index.js +0 -9
- package/dist/components/Layout/Container/index.js +1 -4
- package/dist/components/Layout/Container/stories.js +0 -3
- package/dist/components/Layout/QuickLayout/Auto/index.js +0 -2
- package/dist/components/Layout/QuickLayout/Center/index.js +0 -2
- package/dist/components/Layout/QuickLayout/Clamp/index.js +0 -2
- package/dist/components/Layout/QuickLayout/Sidebar/index.js +0 -2
- package/dist/components/Layout/QuickLayout/SpaceBetween/index.js +0 -2
- package/dist/components/Layout/QuickLayout/Stack/index.js +1 -4
- package/dist/components/Layout/QuickLayout/Wrap/index.js +0 -2
- package/dist/components/Layout/QuickLayout/index.js +0 -9
- package/dist/components/Lottie/LottieAnimation/index.js +12 -17
- package/dist/components/Lottie/LottieAnimationWithMousePosition.js +8 -9
- package/dist/components/Lottie/index.js +3 -3
- package/dist/components/Lottie/stories.js +10 -5
- package/dist/components/MagicLine/index.js +0 -14
- package/dist/components/MagicLine/stories.js +0 -2
- package/dist/components/NavigationScroll/index.js +2 -12
- package/dist/components/Pagination/index.js +0 -7
- package/dist/components/SearchKit/Facets/ChipFacet/index.js +0 -2
- package/dist/components/SearchKit/Facets/HierarchicalFilterFacet/index.js +0 -2
- package/dist/components/SearchKit/Facets/HierarchicalMenuFacet/index.js +0 -2
- package/dist/components/SearchKit/Facets/SelectFacet/index.js +0 -6
- package/dist/components/SearchKit/Query/index.js +3 -6
- package/dist/components/SearchKit/SearchFacets/index.js +0 -7
- package/dist/components/SearchKit/SearchField/index.js +36 -18
- package/dist/components/SearchKit/SearchLoadMore/index.js +0 -7
- package/dist/components/SearchKit/SearchPage/index.js +3 -9
- package/dist/components/SearchKit/SearchPagination/index.js +0 -5
- package/dist/components/SearchKit/SearchReset/index.js +0 -2
- package/dist/components/SearchKit/SearchResults/index.js +44 -17
- package/dist/components/SearchKit/SearchSelectedFilters/index.js +0 -4
- package/dist/components/SearchKit/SearchSorting/index.js +0 -2
- package/dist/components/SearchKit/index.js +0 -3
- package/dist/components/SearchKit/stories.js +2 -7
- package/dist/components/Share/index.js +0 -3
- package/dist/components/Sliders/SliderRelated/index.js +1 -6
- package/dist/components/Sliders/SliderRelated/stories.js +1 -4
- package/dist/components/Webform/WebformActions/index.js +0 -2
- package/dist/components/Webform/WebformCheckbox/index.js +1 -8
- package/dist/components/Webform/WebformCheckboxes/index.js +1 -9
- package/dist/components/Webform/WebformContainer/index.js +5 -6
- package/dist/components/Webform/WebformDate/index.js +12 -18
- package/dist/components/Webform/WebformMapper/index.js +1 -18
- package/dist/components/Webform/WebformNumber/index.js +1 -4
- package/dist/components/Webform/WebformRadioButtons/index.js +1 -9
- package/dist/components/Webform/WebformSelect/index.js +1 -9
- package/dist/components/Webform/WebformTextField/index.js +1 -8
- package/dist/components/Webform/WebformTextarea/index.js +1 -8
- package/dist/components/Webform/WebformWizardPage/index.js +6 -8
- package/dist/components/Webform/index.js +1 -8
- package/dist/components/Webform/withStates.js +6 -19
- package/dist/components/WysiwygField/index.js +1 -8
- package/dist/components/WysiwygField/stories.js +0 -3
- package/dist/config/constants.js +3 -4
- package/dist/config/i18next/index.js +23 -0
- package/dist/config/i18next/locales/en.json +22 -0
- package/dist/config/i18next/locales/nl.json +22 -0
- package/dist/helpers/gtm.js +11 -15
- package/dist/helpers/link.js +0 -4
- package/dist/helpers/useValueForCurrentViewPort.js +20 -14
- package/dist/hooks/useOnScreen.js +2 -2
- package/dist/hooks/usePrevious.js +3 -2
- package/dist/hooks/useScrollPosition.js +0 -3
- package/dist/hooks/useWindowDimensions.js +0 -3
- package/package.json +16 -7
- package/dist/components/WysiwygField/stories.scss +0 -3
- package/dist/helpers/makeSafeForCSS.js +0 -5
|
@@ -3,7 +3,6 @@ import SelectStyled from 'react-select';
|
|
|
3
3
|
import c from 'classnames';
|
|
4
4
|
import { Field } from 'formik';
|
|
5
5
|
import './style.scss';
|
|
6
|
-
|
|
7
6
|
const SelectInput = props => {
|
|
8
7
|
const {
|
|
9
8
|
fieldName,
|
|
@@ -23,10 +22,10 @@ const SelectInput = props => {
|
|
|
23
22
|
} = props;
|
|
24
23
|
let {
|
|
25
24
|
selectedOption
|
|
26
|
-
} = props;
|
|
25
|
+
} = props;
|
|
27
26
|
|
|
27
|
+
// Check if options is [{value, label}] or {value: label}.
|
|
28
28
|
let optionsTransformed = options;
|
|
29
|
-
|
|
30
29
|
if (!Array.isArray(options)) {
|
|
31
30
|
optionsTransformed = Object.keys(options).map(value => {
|
|
32
31
|
const label = options[value];
|
|
@@ -35,25 +34,22 @@ const SelectInput = props => {
|
|
|
35
34
|
label: label
|
|
36
35
|
};
|
|
37
36
|
});
|
|
38
|
-
}
|
|
39
|
-
|
|
37
|
+
}
|
|
40
38
|
|
|
39
|
+
// If the selected option is not set, find the currently selected option by value.
|
|
41
40
|
if (!selectedOption) {
|
|
42
41
|
if (multiple) {
|
|
43
42
|
const _value = value !== undefined ? value : defaultValue || [];
|
|
44
|
-
|
|
45
43
|
selectedOption = optionsTransformed.filter(option => {
|
|
46
44
|
return _value.includes(option.value);
|
|
47
45
|
});
|
|
48
46
|
} else {
|
|
49
47
|
const _value = value !== undefined ? value : defaultValue || '';
|
|
50
|
-
|
|
51
48
|
selectedOption = optionsTransformed.find(option => {
|
|
52
49
|
return option.value === _value;
|
|
53
50
|
});
|
|
54
51
|
}
|
|
55
52
|
}
|
|
56
|
-
|
|
57
53
|
return /*#__PURE__*/React.createElement(Field, {
|
|
58
54
|
required: true,
|
|
59
55
|
name: fieldName,
|
|
@@ -72,7 +68,6 @@ const SelectInput = props => {
|
|
|
72
68
|
disabled: disabled,
|
|
73
69
|
onChange: e => {
|
|
74
70
|
let value = '';
|
|
75
|
-
|
|
76
71
|
if (e) {
|
|
77
72
|
if (multiple) {
|
|
78
73
|
value = e.map(item => {
|
|
@@ -86,11 +81,9 @@ const SelectInput = props => {
|
|
|
86
81
|
value = [];
|
|
87
82
|
}
|
|
88
83
|
}
|
|
89
|
-
|
|
90
84
|
if (onChange) {
|
|
91
85
|
onChange(value);
|
|
92
86
|
}
|
|
93
|
-
|
|
94
87
|
form.setFieldValue(fieldName, value);
|
|
95
88
|
},
|
|
96
89
|
options: optionsTransformed,
|
|
@@ -99,11 +92,9 @@ const SelectInput = props => {
|
|
|
99
92
|
if (option.disabled) {
|
|
100
93
|
return true;
|
|
101
94
|
}
|
|
102
|
-
|
|
103
95
|
if (size && selectedOption.length >= size) {
|
|
104
96
|
return true;
|
|
105
97
|
}
|
|
106
|
-
|
|
107
98
|
return false;
|
|
108
99
|
},
|
|
109
100
|
placeholder: placeholder,
|
|
@@ -133,5 +124,4 @@ const SelectInput = props => {
|
|
|
133
124
|
});
|
|
134
125
|
});
|
|
135
126
|
};
|
|
136
|
-
|
|
137
127
|
export default SelectInput;
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign
|
|
2
|
-
|
|
1
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
3
2
|
import React from 'react';
|
|
4
3
|
import c from 'classnames';
|
|
5
4
|
import GenericFormElement from '../GenericFormElement';
|
|
6
5
|
import SelectInput from './Input';
|
|
7
6
|
import './style.scss';
|
|
8
|
-
|
|
9
7
|
const Select = props => {
|
|
10
8
|
const {
|
|
11
9
|
title,
|
|
@@ -37,5 +35,4 @@ const Select = props => {
|
|
|
37
35
|
multiple: multiple
|
|
38
36
|
})));
|
|
39
37
|
};
|
|
40
|
-
|
|
41
38
|
export default Select;
|
|
@@ -20,11 +20,9 @@ export const Select = () => {
|
|
|
20
20
|
defaultValue: "wine",
|
|
21
21
|
validation: value => {
|
|
22
22
|
let error;
|
|
23
|
-
|
|
24
23
|
if (!value) {
|
|
25
24
|
error = 'Dit is een vereist veld.';
|
|
26
25
|
}
|
|
27
|
-
|
|
28
26
|
return error;
|
|
29
27
|
},
|
|
30
28
|
onChange: e => {
|
|
@@ -50,11 +48,9 @@ export const SelectMultiple = () => {
|
|
|
50
48
|
defaultValue: ['wine'],
|
|
51
49
|
validation: value => {
|
|
52
50
|
let error;
|
|
53
|
-
|
|
54
51
|
if (!value) {
|
|
55
52
|
error = 'Dit is een vereist veld.';
|
|
56
53
|
}
|
|
57
|
-
|
|
58
54
|
return error;
|
|
59
55
|
},
|
|
60
56
|
onChange: e => {
|
|
@@ -4,7 +4,6 @@ import c from 'classnames';
|
|
|
4
4
|
import withMapping from '../../../Context/withMapping';
|
|
5
5
|
import GenericFormElement from '../GenericFormElement';
|
|
6
6
|
import './style.scss';
|
|
7
|
-
|
|
8
7
|
const TextField = props => {
|
|
9
8
|
const {
|
|
10
9
|
title,
|
|
@@ -23,21 +22,17 @@ const TextField = props => {
|
|
|
23
22
|
disabled = false
|
|
24
23
|
} = props;
|
|
25
24
|
const type = props.type || "text";
|
|
26
|
-
|
|
27
25
|
const handleChange = e => {
|
|
28
26
|
const {
|
|
29
27
|
handleChange
|
|
30
28
|
} = props;
|
|
31
|
-
|
|
32
29
|
if (handleChange) {
|
|
33
30
|
handleChange(e);
|
|
34
31
|
}
|
|
35
|
-
|
|
36
32
|
if (onChange) {
|
|
37
33
|
onChange(e);
|
|
38
34
|
}
|
|
39
35
|
};
|
|
40
|
-
|
|
41
36
|
return /*#__PURE__*/React.createElement(GenericFormElement, {
|
|
42
37
|
className: c("TextField", wrapperClassName),
|
|
43
38
|
title: title,
|
|
@@ -60,5 +55,4 @@ const TextField = props => {
|
|
|
60
55
|
disabled: disabled
|
|
61
56
|
}));
|
|
62
57
|
};
|
|
63
|
-
|
|
64
58
|
export default withMapping(TextField);
|
|
@@ -4,8 +4,9 @@ import { mount } from 'enzyme';
|
|
|
4
4
|
import { act } from '@testing-library/react';
|
|
5
5
|
import sinon from 'sinon';
|
|
6
6
|
import sinonChai from 'sinon-chai';
|
|
7
|
-
import { TextField } from './stories';
|
|
7
|
+
import { TextField } from './stories';
|
|
8
8
|
|
|
9
|
+
// Use sinon-chai for spies.
|
|
9
10
|
chai.use(sinonChai);
|
|
10
11
|
describe('<TextField />', () => {
|
|
11
12
|
it('renders a label element', () => {
|
|
@@ -41,17 +42,20 @@ describe('<TextField />', () => {
|
|
|
41
42
|
input.simulate('change');
|
|
42
43
|
await new Promise(resolve => {
|
|
43
44
|
setTimeout(resolve);
|
|
44
|
-
});
|
|
45
|
+
});
|
|
45
46
|
|
|
47
|
+
// Submit values, and wait for Formik to complete.
|
|
46
48
|
wrapper.find('Formik').simulate('submit');
|
|
47
49
|
await new Promise(resolve => {
|
|
48
50
|
setTimeout(resolve);
|
|
49
51
|
});
|
|
50
52
|
});
|
|
51
|
-
wrapper.update();
|
|
53
|
+
wrapper.update();
|
|
52
54
|
|
|
53
|
-
|
|
55
|
+
// Should not display an error message.
|
|
56
|
+
expect(wrapper.find('div.TextField__error')).to.have.lengthOf(0);
|
|
54
57
|
|
|
58
|
+
// Submitted values should contain my value.
|
|
55
59
|
expect(onSubmitCallback).to.have.been.calledWith({
|
|
56
60
|
firstname: value
|
|
57
61
|
});
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign
|
|
2
|
-
|
|
1
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
3
2
|
import React from 'react';
|
|
4
3
|
import FormikWrapper from '../FormikWrapper';
|
|
5
4
|
import FormikTextField from '.';
|
|
@@ -20,11 +19,9 @@ export const TextField = props => {
|
|
|
20
19
|
fieldName: "firstname",
|
|
21
20
|
validation: value => {
|
|
22
21
|
let error;
|
|
23
|
-
|
|
24
22
|
if (!value) {
|
|
25
23
|
error = 'Dit is een vereist veld.';
|
|
26
24
|
}
|
|
27
|
-
|
|
28
25
|
return error;
|
|
29
26
|
},
|
|
30
27
|
onChange: e => console.log(e.target.value)
|
|
@@ -3,7 +3,6 @@ import { Field } from 'formik';
|
|
|
3
3
|
import c from 'classnames';
|
|
4
4
|
import GenericFormElement from '../GenericFormElement';
|
|
5
5
|
import './style.scss';
|
|
6
|
-
|
|
7
6
|
const Textarea = props => {
|
|
8
7
|
const {
|
|
9
8
|
title,
|
|
@@ -43,5 +42,4 @@ const Textarea = props => {
|
|
|
43
42
|
disabled: disabled
|
|
44
43
|
}));
|
|
45
44
|
};
|
|
46
|
-
|
|
47
45
|
export default Textarea;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import './style.scss';
|
|
3
|
-
|
|
4
3
|
const Hamburger = ({
|
|
5
4
|
onClick,
|
|
6
5
|
numberOfLines
|
|
@@ -16,7 +15,6 @@ const Hamburger = ({
|
|
|
16
15
|
}).map((item, index) => /*#__PURE__*/React.createElement("span", {
|
|
17
16
|
key: index
|
|
18
17
|
}))));
|
|
19
|
-
|
|
20
18
|
Hamburger.defaultProps = {
|
|
21
19
|
onClick: () => {},
|
|
22
20
|
numberOfLines: 3
|
|
@@ -4,7 +4,6 @@ import Container from '../Layout/Container';
|
|
|
4
4
|
import Hamburger from '../Hamburger';
|
|
5
5
|
import NavigationScroll from '../NavigationScroll';
|
|
6
6
|
import './style.scss';
|
|
7
|
-
|
|
8
7
|
const Header = ({
|
|
9
8
|
logo,
|
|
10
9
|
menu,
|
|
@@ -24,18 +23,17 @@ const Header = ({
|
|
|
24
23
|
"Header--force-hamburger": forceHamburger,
|
|
25
24
|
"show-nav": active
|
|
26
25
|
});
|
|
27
|
-
|
|
28
26
|
if (forceHamburger) {
|
|
29
|
-
import('./style-force-hamburger.scss').then(() => {
|
|
27
|
+
import('./style-force-hamburger.scss').then(() => {
|
|
28
|
+
// Do nothing.
|
|
30
29
|
});
|
|
31
30
|
} else {
|
|
32
|
-
import('./style-default.scss').then(() => {
|
|
31
|
+
import('./style-default.scss').then(() => {
|
|
32
|
+
// Do nothing.
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
|
-
|
|
36
35
|
const onUpdateNavigationScroll = (isVisible, hasReachedTop, scrolledPastNavHeight) => {
|
|
37
36
|
const shouldUpdate = state.visible !== isVisible || state.reachedTop !== hasReachedTop || state.scrolledPastNavHeight !== scrolledPastNavHeight;
|
|
38
|
-
|
|
39
37
|
if (shouldUpdate) {
|
|
40
38
|
setState({
|
|
41
39
|
scrolledPastNavHeight,
|
|
@@ -44,7 +42,6 @@ const Header = ({
|
|
|
44
42
|
});
|
|
45
43
|
}
|
|
46
44
|
};
|
|
47
|
-
|
|
48
45
|
const headerComponent = /*#__PURE__*/React.createElement("header", {
|
|
49
46
|
className: className
|
|
50
47
|
}, /*#__PURE__*/React.createElement(Container, null, /*#__PURE__*/React.createElement("div", {
|
|
@@ -64,7 +61,6 @@ const Header = ({
|
|
|
64
61
|
}))))), subMenu && /*#__PURE__*/React.createElement("div", {
|
|
65
62
|
className: "Header__subMenu"
|
|
66
63
|
}, /*#__PURE__*/React.createElement(Container, null, subMenu)));
|
|
67
|
-
|
|
68
64
|
if (withAnimation) {
|
|
69
65
|
return /*#__PURE__*/React.createElement(NavigationScroll, {
|
|
70
66
|
onUpdate: onUpdateNavigationScroll,
|
|
@@ -74,5 +70,4 @@ const Header = ({
|
|
|
74
70
|
return headerComponent;
|
|
75
71
|
}
|
|
76
72
|
};
|
|
77
|
-
|
|
78
73
|
export default Header;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign
|
|
2
|
-
|
|
1
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
3
2
|
import React, { useRef } from 'react';
|
|
4
3
|
import c from 'classnames';
|
|
5
4
|
import Picture from '../Picture';
|
|
6
5
|
import './style.scss';
|
|
7
|
-
|
|
8
6
|
const ImageBackground = ({
|
|
9
7
|
className,
|
|
10
8
|
children,
|
|
@@ -13,17 +11,14 @@ const ImageBackground = ({
|
|
|
13
11
|
}) => {
|
|
14
12
|
const bgElem = useRef(null);
|
|
15
13
|
const imgElement = useRef(null);
|
|
16
|
-
|
|
17
14
|
const onLoad = e => {
|
|
18
15
|
const src = typeof imgElement.current.currentSrc !== 'undefined' ? imgElement.current.currentSrc : imgElement.current.src;
|
|
19
|
-
|
|
20
16
|
if (withGradient) {
|
|
21
17
|
bgElem.current.style.backgroundImage = `${withGradient}, url("${src}")`;
|
|
22
18
|
} else {
|
|
23
19
|
bgElem.current.style.backgroundImage = `url("${src}")`;
|
|
24
20
|
}
|
|
25
21
|
};
|
|
26
|
-
|
|
27
22
|
const classes = c('ImageBackground', className);
|
|
28
23
|
return /*#__PURE__*/React.createElement("div", {
|
|
29
24
|
className: classes,
|
|
@@ -35,5 +30,4 @@ const ImageBackground = ({
|
|
|
35
30
|
imageRef: imgElement
|
|
36
31
|
}, props)), children);
|
|
37
32
|
};
|
|
38
|
-
|
|
39
33
|
export default ImageBackground;
|
|
@@ -3,7 +3,6 @@ import classNames from 'classnames';
|
|
|
3
3
|
import LazyLoad from 'react-lazyload';
|
|
4
4
|
import { Map } from 'immutable';
|
|
5
5
|
import './style.scss';
|
|
6
|
-
|
|
7
6
|
class LazyLoadWrapper extends Component {
|
|
8
7
|
constructor(props) {
|
|
9
8
|
super(props);
|
|
@@ -12,7 +11,6 @@ class LazyLoadWrapper extends Component {
|
|
|
12
11
|
error: false
|
|
13
12
|
};
|
|
14
13
|
}
|
|
15
|
-
|
|
16
14
|
render() {
|
|
17
15
|
const {
|
|
18
16
|
lazyload: shouldLazyLoad,
|
|
@@ -23,38 +21,30 @@ class LazyLoadWrapper extends Component {
|
|
|
23
21
|
src: "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",
|
|
24
22
|
alt: "placeholder"
|
|
25
23
|
});
|
|
26
|
-
|
|
27
24
|
if (!shouldLazyLoad) {
|
|
28
25
|
return children;
|
|
29
26
|
}
|
|
30
|
-
|
|
31
27
|
const addOnLoadCallback = element => {
|
|
32
28
|
const newProps = {};
|
|
33
|
-
|
|
34
29
|
newProps.onLoad = event => {
|
|
35
30
|
this.setState({
|
|
36
31
|
loaded: true
|
|
37
32
|
});
|
|
38
33
|
};
|
|
39
|
-
|
|
40
34
|
newProps.onError = event => {
|
|
41
35
|
this.setState({
|
|
42
36
|
error: true
|
|
43
37
|
});
|
|
44
38
|
};
|
|
45
|
-
|
|
46
39
|
let elements = [];
|
|
47
40
|
const elementMap = Map(element);
|
|
48
|
-
|
|
49
41
|
if (Array.isArray(elementMap.getIn(['props', 'children']))) {
|
|
50
42
|
elements = React.Children.map(element.props.children, child => {
|
|
51
43
|
return addOnLoadCallback(child);
|
|
52
44
|
});
|
|
53
45
|
}
|
|
54
|
-
|
|
55
46
|
return /*#__PURE__*/React.cloneElement(element, newProps, ...elements);
|
|
56
47
|
};
|
|
57
|
-
|
|
58
48
|
const {
|
|
59
49
|
loaded,
|
|
60
50
|
error
|
|
@@ -75,7 +65,5 @@ class LazyLoadWrapper extends Component {
|
|
|
75
65
|
return addOnLoadCallback(child);
|
|
76
66
|
}))));
|
|
77
67
|
}
|
|
78
|
-
|
|
79
68
|
}
|
|
80
|
-
|
|
81
69
|
export default LazyLoadWrapper;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign
|
|
2
|
-
|
|
1
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
3
2
|
import React from 'react';
|
|
4
3
|
import Immutable from 'immutable';
|
|
5
4
|
import path from 'path';
|
|
6
5
|
import mimeTypes from './data/ext-to-mime-types.json';
|
|
7
6
|
import './style.scss';
|
|
8
7
|
const FALLBACK_MIME_TYPE = 'image/jpg';
|
|
9
|
-
|
|
10
8
|
const Picture = ({
|
|
11
9
|
src,
|
|
12
10
|
className,
|
|
@@ -29,26 +27,21 @@ const Picture = ({
|
|
|
29
27
|
alt,
|
|
30
28
|
title
|
|
31
29
|
};
|
|
32
|
-
|
|
33
30
|
const getImageExtension = url => {
|
|
34
31
|
const sanitizedUrl = url.replace(/\?.*/, '');
|
|
35
32
|
return path.extname(sanitizedUrl).toLowerCase();
|
|
36
33
|
};
|
|
37
|
-
|
|
38
34
|
const getMimeType = url => {
|
|
39
35
|
const extension = getImageExtension(url);
|
|
40
36
|
return mimeTypes[extension] ? mimeTypes[extension] : FALLBACK_MIME_TYPE;
|
|
41
37
|
};
|
|
42
|
-
|
|
43
38
|
const isValidImage = url => {
|
|
44
39
|
if (!url) {
|
|
45
40
|
return false;
|
|
46
41
|
}
|
|
47
|
-
|
|
48
42
|
const extension = getImageExtension(url);
|
|
49
43
|
return Object.keys(mimeTypes).includes(extension);
|
|
50
44
|
};
|
|
51
|
-
|
|
52
45
|
if (Immutable.Iterable.isIterable(Immutable.fromJS(src))) {
|
|
53
46
|
// Sources have to be defined in a descending order.
|
|
54
47
|
// We sort them from best to worst quality.
|
|
@@ -61,20 +54,17 @@ const Picture = ({
|
|
|
61
54
|
if (image !== false) {
|
|
62
55
|
return image;
|
|
63
56
|
}
|
|
64
|
-
|
|
65
57
|
;
|
|
66
58
|
return null;
|
|
67
|
-
});
|
|
59
|
+
});
|
|
68
60
|
|
|
61
|
+
// Only render if all our image sources are valid
|
|
69
62
|
const hasValidSources = sources.count() > 0;
|
|
70
|
-
|
|
71
63
|
if (!hasValidSources) {
|
|
72
64
|
return null;
|
|
73
65
|
}
|
|
74
|
-
|
|
75
66
|
const fallback = sources.valueSeq().first();
|
|
76
67
|
let renderedSourcesWebP = [];
|
|
77
|
-
|
|
78
68
|
if (includeWebP) {
|
|
79
69
|
/* eslint-disable react/no-array-index-key */
|
|
80
70
|
renderedSourcesWebP = sources.map((url, breakpoint) => {
|
|
@@ -87,9 +77,8 @@ const Picture = ({
|
|
|
87
77
|
});
|
|
88
78
|
}).valueSeq();
|
|
89
79
|
}
|
|
90
|
-
/* eslint-disable react/no-array-index-key */
|
|
91
|
-
|
|
92
80
|
|
|
81
|
+
/* eslint-disable react/no-array-index-key */
|
|
93
82
|
const renderedSources = sources.map((url, breakpoint) => /*#__PURE__*/React.createElement("source", {
|
|
94
83
|
key: breakpoint,
|
|
95
84
|
srcSet: url,
|
|
@@ -103,7 +92,6 @@ const Picture = ({
|
|
|
103
92
|
src: fallback
|
|
104
93
|
})));
|
|
105
94
|
}
|
|
106
|
-
|
|
107
95
|
if (src && isValidImage(src)) {
|
|
108
96
|
if (includeWebP) {
|
|
109
97
|
const webpUrl = src.replace(/\.(png|gif|jp(e?)g)/, '.webp');
|
|
@@ -120,17 +108,14 @@ const Picture = ({
|
|
|
120
108
|
src: src
|
|
121
109
|
})));
|
|
122
110
|
}
|
|
123
|
-
|
|
124
111
|
return /*#__PURE__*/React.createElement("img", _extends({}, attrs, {
|
|
125
112
|
onLoad: e => onLoad(e),
|
|
126
113
|
ref: imageRef,
|
|
127
114
|
src: src
|
|
128
115
|
}));
|
|
129
116
|
}
|
|
130
|
-
|
|
131
117
|
return null;
|
|
132
118
|
};
|
|
133
|
-
|
|
134
119
|
Picture.defaultProps = {
|
|
135
120
|
onLoad: () => {}
|
|
136
121
|
};
|
|
@@ -3,21 +3,17 @@ import PropTypes from 'prop-types';
|
|
|
3
3
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
4
4
|
import LazyLoadWrapper from './LazyLoadWrapper';
|
|
5
5
|
import Picture from './Picture';
|
|
6
|
-
|
|
7
6
|
const Image = props => {
|
|
8
7
|
const {
|
|
9
8
|
lazyload
|
|
10
9
|
} = props;
|
|
11
|
-
|
|
12
10
|
if (lazyload) {
|
|
13
11
|
return /*#__PURE__*/React.createElement(LazyLoadWrapper, {
|
|
14
12
|
lazyload: lazyload
|
|
15
13
|
}, /*#__PURE__*/React.createElement(Picture, props));
|
|
16
14
|
}
|
|
17
|
-
|
|
18
15
|
return /*#__PURE__*/React.createElement(Picture, props);
|
|
19
16
|
};
|
|
20
|
-
|
|
21
17
|
Image.propTypes = {
|
|
22
18
|
src: PropTypes.oneOfType([PropTypes.string, ImmutablePropTypes.map]).isRequired,
|
|
23
19
|
lazyload: PropTypes.bool
|
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
import React, { useState, useEffect } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import './style.scss';
|
|
4
|
-
|
|
5
4
|
const InlineMenu = ({
|
|
6
5
|
items,
|
|
7
6
|
scrollToTopOffset
|
|
8
7
|
}) => {
|
|
9
8
|
const [scrollPosition, setSrollPosition] = useState(0);
|
|
10
|
-
|
|
11
9
|
const handleScroll = () => {
|
|
12
10
|
const position = window.pageYOffset;
|
|
13
11
|
setSrollPosition(position);
|
|
14
12
|
};
|
|
15
|
-
|
|
16
13
|
useEffect(() => {
|
|
17
14
|
window.addEventListener('scroll', handleScroll);
|
|
18
15
|
return () => {
|
|
@@ -20,7 +17,6 @@ const InlineMenu = ({
|
|
|
20
17
|
};
|
|
21
18
|
}, []);
|
|
22
19
|
if (!items) return null;
|
|
23
|
-
|
|
24
20
|
const offset = el => {
|
|
25
21
|
const rect = el.getBoundingClientRect();
|
|
26
22
|
const scrollLeft = window.pageXOffset || document.documentElement.scrollLeft;
|
|
@@ -30,7 +26,6 @@ const InlineMenu = ({
|
|
|
30
26
|
left: rect.left + scrollLeft
|
|
31
27
|
};
|
|
32
28
|
};
|
|
33
|
-
|
|
34
29
|
const handleClick = id => {
|
|
35
30
|
const element = document.getElementById(id);
|
|
36
31
|
if (!element) return null;
|
|
@@ -39,20 +34,17 @@ const InlineMenu = ({
|
|
|
39
34
|
behavior: "smooth"
|
|
40
35
|
});
|
|
41
36
|
};
|
|
42
|
-
|
|
43
37
|
const handleActiveState = (currentId, nextId, activeByDefault) => {
|
|
44
38
|
const element = document.getElementById(currentId);
|
|
45
39
|
const nextElement = document.getElementById(nextId);
|
|
46
40
|
if (!element && activeByDefault) return true;
|
|
47
41
|
if (!element) return null;
|
|
48
|
-
|
|
49
42
|
if (!nextElement) {
|
|
50
43
|
return scrollPosition > offset(element).top - (scrollToTopOffset + 10);
|
|
51
44
|
} else {
|
|
52
45
|
return (scrollPosition > offset(element).top - (scrollToTopOffset + 10) || activeByDefault) && scrollPosition < offset(nextElement).top - (scrollToTopOffset + 10);
|
|
53
46
|
}
|
|
54
47
|
};
|
|
55
|
-
|
|
56
48
|
return /*#__PURE__*/React.createElement("nav", {
|
|
57
49
|
className: "InlineMenu"
|
|
58
50
|
}, /*#__PURE__*/React.createElement("ul", {
|
|
@@ -67,7 +59,6 @@ const InlineMenu = ({
|
|
|
67
59
|
key: elementId
|
|
68
60
|
}, menuItemName || 'missing menuItemName'))));
|
|
69
61
|
};
|
|
70
|
-
|
|
71
62
|
InlineMenu.defaultProps = {
|
|
72
63
|
items: [],
|
|
73
64
|
scrollToTopOffset: 0,
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign
|
|
2
|
-
|
|
1
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
3
2
|
import React from 'react';
|
|
4
3
|
import PropTypes from 'prop-types';
|
|
5
4
|
import classNames from 'classnames';
|
|
6
5
|
import './style.scss';
|
|
7
|
-
|
|
8
6
|
const Container = ({
|
|
9
7
|
className,
|
|
10
8
|
fluid,
|
|
@@ -27,7 +25,6 @@ const Container = ({
|
|
|
27
25
|
className: classes
|
|
28
26
|
}, props), children);
|
|
29
27
|
};
|
|
30
|
-
|
|
31
28
|
Container.defaultProps = {
|
|
32
29
|
small: false,
|
|
33
30
|
large: false,
|
|
@@ -4,11 +4,9 @@ import './stories.scss';
|
|
|
4
4
|
export default {
|
|
5
5
|
title: 'Templates/Grid'
|
|
6
6
|
};
|
|
7
|
-
|
|
8
7
|
const Filler = () => /*#__PURE__*/React.createElement("div", {
|
|
9
8
|
className: "Filler"
|
|
10
9
|
});
|
|
11
|
-
|
|
12
10
|
const Columns = () => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
13
11
|
className: "row"
|
|
14
12
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -78,7 +76,6 @@ const Columns = () => /*#__PURE__*/React.createElement(React.Fragment, null, /*#
|
|
|
78
76
|
}, /*#__PURE__*/React.createElement(Filler, null)), /*#__PURE__*/React.createElement("div", {
|
|
79
77
|
class: "col-1"
|
|
80
78
|
}, /*#__PURE__*/React.createElement(Filler, null))));
|
|
81
|
-
|
|
82
79
|
export const Default = () => /*#__PURE__*/React.createElement(Container, null, /*#__PURE__*/React.createElement(Columns, null));
|
|
83
80
|
export const Small = () => /*#__PURE__*/React.createElement(Container, {
|
|
84
81
|
small: true
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import c from 'classnames';
|
|
3
|
-
|
|
4
3
|
const QuickLayoutAuto = ({
|
|
5
4
|
children,
|
|
6
5
|
min,
|
|
@@ -17,7 +16,6 @@ const QuickLayoutAuto = ({
|
|
|
17
16
|
}
|
|
18
17
|
}, children);
|
|
19
18
|
};
|
|
20
|
-
|
|
21
19
|
QuickLayoutAuto.defaultProps = {
|
|
22
20
|
min: '150px',
|
|
23
21
|
gap: '1rem'
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import c from 'classnames';
|
|
3
3
|
import './style.scss';
|
|
4
|
-
|
|
5
4
|
const QuickLayoutCentered = ({
|
|
6
5
|
children,
|
|
7
6
|
className
|
|
@@ -11,5 +10,4 @@ const QuickLayoutCentered = ({
|
|
|
11
10
|
className: classes
|
|
12
11
|
}, children);
|
|
13
12
|
};
|
|
14
|
-
|
|
15
13
|
export default QuickLayoutCentered;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import c from 'classnames';
|
|
3
|
-
|
|
4
3
|
const QuickLayoutClamp = ({
|
|
5
4
|
children,
|
|
6
5
|
min,
|
|
@@ -16,7 +15,6 @@ const QuickLayoutClamp = ({
|
|
|
16
15
|
}
|
|
17
16
|
}, children);
|
|
18
17
|
};
|
|
19
|
-
|
|
20
18
|
QuickLayoutClamp.defaultProps = {
|
|
21
19
|
min: '1rem',
|
|
22
20
|
value: '2.5vw',
|