@uncinc/uncinc-react-kitchen-sink 2.3.3 → 2.3.5
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/AbbreviationAnnotation/index.js +47 -0
- package/dist/components/AbbreviationAnnotation/stories.js +23 -0
- package/dist/components/AbbreviationAnnotation/stories.scss +39 -0
- package/dist/components/AbbreviationAnnotation/style.scss +33 -0
- 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 +12 -13
- 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 +6 -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 +0 -9
- 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 +9 -16
- package/dist/components/SearchKit/SearchSelectedFilters/index.js +0 -4
- package/dist/components/SearchKit/SearchSorting/index.js +2 -4
- 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 +4 -14
- 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/dist/index.js +2 -1
- package/dist/styles/assets/_base.scss +0 -1
- package/package.json +14 -5
- package/dist/pages/api/graphql.js +0 -25
|
@@ -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 { Field } from 'formik';
|
|
5
4
|
import c from 'classnames';
|
|
6
5
|
import GenericFormElement from '../GenericFormElement';
|
|
7
6
|
import './style.scss';
|
|
8
|
-
|
|
9
7
|
function Checkbox(props) {
|
|
10
8
|
const {
|
|
11
9
|
name,
|
|
@@ -30,7 +28,6 @@ function Checkbox(props) {
|
|
|
30
28
|
'icon-checkmark': true,
|
|
31
29
|
'icon-variant-1': checked
|
|
32
30
|
});
|
|
33
|
-
|
|
34
31
|
if (props.value === '__other__') {
|
|
35
32
|
const inputClasses = c({
|
|
36
33
|
hidden: !field.value.includes('__other__')
|
|
@@ -54,7 +51,6 @@ function Checkbox(props) {
|
|
|
54
51
|
}
|
|
55
52
|
}));
|
|
56
53
|
}
|
|
57
|
-
|
|
58
54
|
return /*#__PURE__*/React.createElement("label", {
|
|
59
55
|
className: classes,
|
|
60
56
|
htmlFor: name
|
|
@@ -69,7 +65,6 @@ function Checkbox(props) {
|
|
|
69
65
|
})), /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("span", null, props.label), props.description && /*#__PURE__*/React.createElement("span", null, props.description)));
|
|
70
66
|
});
|
|
71
67
|
}
|
|
72
|
-
|
|
73
68
|
const Checkboxes = props => {
|
|
74
69
|
const {
|
|
75
70
|
title,
|
|
@@ -120,5 +115,4 @@ const Checkboxes = props => {
|
|
|
120
115
|
});
|
|
121
116
|
}));
|
|
122
117
|
};
|
|
123
|
-
|
|
124
118
|
export default Checkboxes;
|
|
@@ -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 { Checkboxes } from './stories';
|
|
7
|
+
import { Checkboxes } from './stories';
|
|
8
8
|
|
|
9
|
+
// Use sinon-chai for spies.
|
|
9
10
|
chai.use(sinonChai);
|
|
10
11
|
describe('<Checkboxes />', () => {
|
|
11
12
|
it('renders 5 label elements', () => {
|
|
@@ -47,17 +48,20 @@ describe('<Checkboxes />', () => {
|
|
|
47
48
|
input.at(3).simulate('change');
|
|
48
49
|
await new Promise(resolve => {
|
|
49
50
|
setTimeout(resolve);
|
|
50
|
-
});
|
|
51
|
+
});
|
|
51
52
|
|
|
53
|
+
// Submit values, and wait for Formik to complete.
|
|
52
54
|
wrapper.find('Formik').simulate('submit');
|
|
53
55
|
await new Promise(resolve => {
|
|
54
56
|
setTimeout(resolve);
|
|
55
57
|
});
|
|
56
58
|
});
|
|
57
|
-
wrapper.update();
|
|
59
|
+
wrapper.update();
|
|
58
60
|
|
|
59
|
-
|
|
61
|
+
// Should not display an error message.
|
|
62
|
+
expect(wrapper.find('div.Checkboxes__error')).to.have.lengthOf(0);
|
|
60
63
|
|
|
64
|
+
// Submitted values should contain my value.
|
|
61
65
|
expect(onSubmitCallback).to.have.been.calledWith({
|
|
62
66
|
poison: ["rum", "whisky"]
|
|
63
67
|
});
|
|
@@ -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 FormikCheckboxes from '.';
|
|
@@ -26,11 +25,9 @@ export const Checkboxes = props => {
|
|
|
26
25
|
},
|
|
27
26
|
validation: value => {
|
|
28
27
|
let error;
|
|
29
|
-
|
|
30
28
|
if (value && value.length === 0) {
|
|
31
29
|
error = 'This field is required';
|
|
32
30
|
}
|
|
33
|
-
|
|
34
31
|
return error;
|
|
35
32
|
},
|
|
36
33
|
otherLabel: "Anders"
|
|
@@ -1,12 +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 TextField from '../TextField';
|
|
5
|
-
|
|
6
4
|
const Date = props => {
|
|
7
5
|
return /*#__PURE__*/React.createElement(TextField, _extends({}, props, {
|
|
8
6
|
type: "date"
|
|
9
7
|
}));
|
|
10
8
|
};
|
|
11
|
-
|
|
12
9
|
export default Date;
|
|
@@ -5,7 +5,6 @@ import c from 'classnames';
|
|
|
5
5
|
import GenericFormElement from '../GenericFormElement';
|
|
6
6
|
import "react-datepicker/dist/react-datepicker.css";
|
|
7
7
|
import './style.scss';
|
|
8
|
-
|
|
9
8
|
const DatePicker = props => {
|
|
10
9
|
const {
|
|
11
10
|
title,
|
|
@@ -57,5 +56,4 @@ const DatePicker = props => {
|
|
|
57
56
|
});
|
|
58
57
|
}));
|
|
59
58
|
};
|
|
60
|
-
|
|
61
59
|
export default DatePicker;
|
|
@@ -1,144 +1,169 @@
|
|
|
1
1
|
import React, { useState, useCallback, useEffect } from 'react';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import SelectInput from '../Select/Input';
|
|
2
|
+
import { useFormikContext } from 'formik';
|
|
3
|
+
import { useTranslation } from 'react-i18next';
|
|
5
4
|
import GenericFormElement from '../GenericFormElement';
|
|
5
|
+
import SelectInput from '../Select/Input';
|
|
6
6
|
import './style.scss';
|
|
7
|
-
|
|
8
7
|
const DateSelect = props => {
|
|
9
8
|
const {
|
|
10
9
|
title,
|
|
11
|
-
required,
|
|
12
|
-
description,
|
|
13
10
|
fieldName,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
yearMin,
|
|
12
|
+
yearMax,
|
|
13
|
+
hideYear,
|
|
14
|
+
fixedYear,
|
|
15
|
+
required,
|
|
19
16
|
displayRequiredIndicator,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
requiredError,
|
|
18
|
+
notValidError,
|
|
19
|
+
dayPlaceholder,
|
|
20
|
+
monthPlaceholder,
|
|
21
|
+
yearPlaceholder
|
|
22
|
+
} = props;
|
|
23
|
+
const {
|
|
24
|
+
setFieldValue,
|
|
25
|
+
isSubmitting,
|
|
26
|
+
values
|
|
27
|
+
} = useFormikContext();
|
|
28
|
+
const {
|
|
29
|
+
t
|
|
30
|
+
} = useTranslation();
|
|
24
31
|
|
|
32
|
+
// Set all states for the date.
|
|
25
33
|
const [day, setDay] = useState();
|
|
26
34
|
const [month, setMonth] = useState();
|
|
27
35
|
const [year, setYear] = useState();
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
const requiredError = 'This field is required';
|
|
32
|
-
const dateMin = 1900;
|
|
33
|
-
const dateMax = 2999; // Render all day options possible.
|
|
36
|
+
const [showError, setShowError] = useState();
|
|
37
|
+
const [error, setError] = useState();
|
|
38
|
+
const [dateNotValid, setDateNotValid] = useState();
|
|
34
39
|
|
|
35
|
-
|
|
40
|
+
// List all day options
|
|
41
|
+
const dayOptions = useCallback(placeholder => {
|
|
36
42
|
const options = [];
|
|
37
|
-
|
|
38
43
|
if (placeholder) {
|
|
39
44
|
options.push({
|
|
40
45
|
value: placeholder,
|
|
41
46
|
label: placeholder
|
|
42
47
|
});
|
|
43
48
|
}
|
|
44
|
-
|
|
45
49
|
for (let index = 1; index <= 31; index++) {
|
|
46
50
|
options.push({
|
|
47
51
|
value: index,
|
|
48
52
|
label: index
|
|
49
53
|
});
|
|
50
54
|
}
|
|
51
|
-
|
|
52
55
|
return options;
|
|
53
|
-
}, []);
|
|
56
|
+
}, []);
|
|
54
57
|
|
|
55
|
-
|
|
56
|
-
|
|
58
|
+
// List all month options
|
|
59
|
+
const monthOptions = useCallback(() => {
|
|
60
|
+
const months = [t('dateselect.months.jan', 'Januari'), t('dateselect.months.feb', 'Februari'), t('dateselect.months.mar', 'Maart'), t('dateselect.months.apr', 'April'), t('dateselect.months.may', 'Mei'), t('dateselect.months.jun', 'Juni'), t('dateselect.months.jul', 'Juli'), t('dateselect.months.aug', 'Augustus'), t('dateselect.months.sep', 'September'), t('dateselect.months.oct', 'Oktober'), t('dateselect.months.nov', 'November'), t('dateselect.months.dec', 'December')];
|
|
57
61
|
return months.map((e, i) => {
|
|
58
62
|
return {
|
|
59
63
|
value: i + 1,
|
|
60
64
|
label: e
|
|
61
65
|
};
|
|
62
66
|
});
|
|
63
|
-
}, []);
|
|
64
|
-
// the DateMin and DateMax variables.
|
|
67
|
+
}, []);
|
|
65
68
|
|
|
66
|
-
|
|
69
|
+
// List all options for possible years from the yearMin and yearMax variables.
|
|
70
|
+
const yearOptions = useCallback(() => {
|
|
67
71
|
const options = [];
|
|
68
|
-
|
|
69
|
-
for (let index = dateMin; index <= dateMax; index++) {
|
|
72
|
+
for (let index = yearMin; index <= yearMax; index++) {
|
|
70
73
|
options.push({
|
|
71
74
|
value: index,
|
|
72
75
|
label: index
|
|
73
76
|
});
|
|
74
77
|
}
|
|
75
|
-
|
|
76
78
|
return options;
|
|
77
|
-
}, [
|
|
79
|
+
}, [yearMin, yearMax]);
|
|
80
|
+
|
|
81
|
+
// Check if all fields are filled
|
|
78
82
|
useEffect(() => {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
83
|
+
if (isSubmitting) {
|
|
84
|
+
if (required && !values[fieldName]) {
|
|
85
|
+
!dateNotValid && setError(requiredError);
|
|
86
|
+
setShowError(true);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
84
89
|
}
|
|
90
|
+
}, [isSubmitting]);
|
|
85
91
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
// Validation and setting either an error or the FieldValue
|
|
93
|
+
useEffect(() => {
|
|
94
|
+
hideYear && setYear(fixedYear || new Date().getFullYear());
|
|
95
|
+
|
|
96
|
+
// All options are filled, start validation
|
|
97
|
+
if (day && month && year) {
|
|
98
|
+
const date = new Date(`${year}-${month}-${day}`);
|
|
99
|
+
if (!(
|
|
100
|
+
// Take note of the exclamation mark
|
|
101
|
+
date.getDate() === day && date.getMonth() + 1 === month && date.getFullYear() === year)) {
|
|
102
|
+
// Depending on your browser, an invalid date overflows to the next month.
|
|
103
|
+
// For example, the 30th of Februari can become the 2nd of March.
|
|
104
|
+
// If that is the case, you still get a valid Date object, but it's not what
|
|
105
|
+
// the user filled in.
|
|
106
|
+
setError(notValidError);
|
|
107
|
+
setShowError(true);
|
|
108
|
+
setDateNotValid(true);
|
|
109
|
+
setFieldValue("dateSelect", '');
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// The Date is valid, so we hide previous errors and set the FieldValue
|
|
114
|
+
setShowError(false);
|
|
115
|
+
setDateNotValid(false);
|
|
116
|
+
setFieldValue("dateSelect", date);
|
|
94
117
|
return;
|
|
95
|
-
}
|
|
96
|
-
|
|
118
|
+
}
|
|
97
119
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
120
|
+
// In case a Date was selected and set as FieldValue, but the user decides
|
|
121
|
+
// to change the date, we want to hide previous errors and clear the FieldValue
|
|
122
|
+
// so that validation - and also the useEffect on isSubmitting - can do it's job.
|
|
123
|
+
setShowError(false);
|
|
124
|
+
setDateNotValid(false);
|
|
125
|
+
setFieldValue("dateSelect", '');
|
|
126
|
+
}, [day, month, year]);
|
|
102
127
|
return /*#__PURE__*/React.createElement(GenericFormElement, {
|
|
103
|
-
className:
|
|
128
|
+
className: "DateSelect",
|
|
104
129
|
title: title,
|
|
105
130
|
required: required,
|
|
106
|
-
|
|
107
|
-
fieldName: fieldName,
|
|
108
|
-
touched: touched,
|
|
131
|
+
displayRequiredIndicator: displayRequiredIndicator,
|
|
109
132
|
error: error,
|
|
110
|
-
|
|
133
|
+
touched: showError
|
|
111
134
|
}, /*#__PURE__*/React.createElement(SelectInput, {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
options: renderDayOptions(),
|
|
135
|
+
id: `${fieldName}day`,
|
|
136
|
+
fieldName: `${fieldName}day`,
|
|
137
|
+
options: dayOptions(),
|
|
116
138
|
value: day,
|
|
117
|
-
placeholder:
|
|
118
|
-
onChange:
|
|
119
|
-
setDay(e);
|
|
120
|
-
}
|
|
139
|
+
placeholder: dayPlaceholder,
|
|
140
|
+
onChange: day => setDay(day)
|
|
121
141
|
}), /*#__PURE__*/React.createElement(SelectInput, {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
options: renderMonthOptions(),
|
|
142
|
+
id: `${fieldName}month`,
|
|
143
|
+
fieldName: `${fieldName}month`,
|
|
144
|
+
options: monthOptions(),
|
|
126
145
|
value: month,
|
|
127
|
-
placeholder:
|
|
128
|
-
onChange:
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
disabled: disabled,
|
|
134
|
-
fieldName: `${fieldName}[year]`,
|
|
135
|
-
options: renderYearOptions(),
|
|
146
|
+
placeholder: monthPlaceholder,
|
|
147
|
+
onChange: month => setMonth(month)
|
|
148
|
+
}), !hideYear && /*#__PURE__*/React.createElement(SelectInput, {
|
|
149
|
+
id: `${fieldName}year`,
|
|
150
|
+
fieldName: `${fieldName}year`,
|
|
151
|
+
options: yearOptions(),
|
|
136
152
|
value: year,
|
|
137
|
-
placeholder:
|
|
138
|
-
onChange:
|
|
139
|
-
setYear(e);
|
|
140
|
-
}
|
|
153
|
+
placeholder: yearPlaceholder,
|
|
154
|
+
onChange: year => setYear(year)
|
|
141
155
|
}));
|
|
142
156
|
};
|
|
143
|
-
|
|
157
|
+
DateSelect.defaultProps = {
|
|
158
|
+
title: 'Kies een datum',
|
|
159
|
+
fieldName: 'dateSelect',
|
|
160
|
+
yearMin: 1970,
|
|
161
|
+
yearMax: 2042,
|
|
162
|
+
hideYear: false,
|
|
163
|
+
requiredError: 'Waarde mag niet leeg zijn',
|
|
164
|
+
notValidError: 'Ongeldige datum',
|
|
165
|
+
dayPlaceholder: 'Dag',
|
|
166
|
+
monthPlaceholder: 'Maand',
|
|
167
|
+
yearPlaceholder: 'Jaar'
|
|
168
|
+
};
|
|
144
169
|
export default DateSelect;
|
|
@@ -1,24 +1,33 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
2
|
import FormikWrapper from '../FormikWrapper';
|
|
3
3
|
import FormikDateSelect from '.';
|
|
4
4
|
export default {
|
|
5
5
|
title: 'Molecules/Form'
|
|
6
6
|
};
|
|
7
7
|
export const DateSelect = () => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
error = 'Dit is een vereist veld.';
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return error;
|
|
8
|
+
const [date, setDate] = useState('');
|
|
9
|
+
return /*#__PURE__*/React.createElement(FormikWrapper, {
|
|
10
|
+
initialValues: {
|
|
11
|
+
dateSelect: date
|
|
12
|
+
},
|
|
13
|
+
validateOnBlur: true,
|
|
14
|
+
displayRequiredIndicator: "required",
|
|
15
|
+
onSubmit: (values, form) => {
|
|
16
|
+
form.setSubmitting(false);
|
|
17
|
+
setDate(values.dateSelect);
|
|
22
18
|
}
|
|
19
|
+
}, /*#__PURE__*/React.createElement(FormikDateSelect, {
|
|
20
|
+
title: "Pick a date",
|
|
21
|
+
fieldName: "dateSelect",
|
|
22
|
+
required: true,
|
|
23
|
+
dayPlaceholder: "Day",
|
|
24
|
+
monthPlaceholder: "Month",
|
|
25
|
+
yearPlaceholder: "Year",
|
|
26
|
+
requiredError: "Please fill all fields.",
|
|
27
|
+
notValidError: "That's not a valid date."
|
|
28
|
+
}), /*#__PURE__*/React.createElement("p", null, "Selected date: ", date.toString()), /*#__PURE__*/React.createElement("input", {
|
|
29
|
+
class: "submitButton",
|
|
30
|
+
type: "submit",
|
|
31
|
+
value: "Pick date"
|
|
23
32
|
}));
|
|
24
33
|
};
|
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|
label {
|
|
5
5
|
font-size: 1.8rem;
|
|
6
6
|
font-weight: 600;
|
|
7
|
-
line-height:
|
|
7
|
+
line-height: 2rem;
|
|
8
8
|
color: #1d1d1b;
|
|
9
9
|
margin-bottom: 5px;
|
|
10
10
|
}
|
|
11
11
|
input {
|
|
12
12
|
font-size: 1.8rem;
|
|
13
13
|
font-weight: 500;
|
|
14
|
-
line-height:
|
|
14
|
+
line-height: 2rem;
|
|
15
15
|
color: #939393;
|
|
16
16
|
padding: 1.2rem 5rem 1.4rem 2rem;
|
|
17
17
|
border-radius: 5px;
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
margin-top: 1rem;
|
|
37
37
|
font-size: 1.4rem;
|
|
38
38
|
font-style: italic;
|
|
39
|
-
line-height: 1.
|
|
39
|
+
line-height: 1.5rem;
|
|
40
40
|
letter-spacing: normal;
|
|
41
41
|
color: #1f1f1d;
|
|
42
42
|
}
|
|
@@ -45,8 +45,14 @@
|
|
|
45
45
|
margin-top: 1rem;
|
|
46
46
|
font-size: 1.4rem;
|
|
47
47
|
font-style: italic;
|
|
48
|
-
line-height: 1.
|
|
48
|
+
line-height: 1.2rem;
|
|
49
49
|
letter-spacing: normal;
|
|
50
50
|
color: #d30000;
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
+
|
|
54
|
+
.submitButton {
|
|
55
|
+
padding: 1rem;
|
|
56
|
+
border-radius: 5px;
|
|
57
|
+
border: solid 1px #888888;
|
|
58
|
+
}
|
|
@@ -1,12 +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 TextField from '../TextField';
|
|
5
|
-
|
|
6
4
|
const Email = props => {
|
|
7
5
|
return /*#__PURE__*/React.createElement(TextField, _extends({}, props, {
|
|
8
6
|
type: "email"
|
|
9
7
|
}));
|
|
10
8
|
};
|
|
11
|
-
|
|
12
9
|
export default Email;
|
|
@@ -1,8 +1,6 @@
|
|
|
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 { Form, Formik } from 'formik';
|
|
5
|
-
|
|
6
4
|
const renderChildrenRecursively = (child, childProps, displayRequiredIndicator) => {
|
|
7
5
|
const {
|
|
8
6
|
fieldName,
|
|
@@ -10,32 +8,30 @@ const renderChildrenRecursively = (child, childProps, displayRequiredIndicator)
|
|
|
10
8
|
htmlType,
|
|
11
9
|
children
|
|
12
10
|
} = child.props;
|
|
13
|
-
|
|
14
11
|
if (type === 'submit' || htmlType === 'submit') {
|
|
15
12
|
return /*#__PURE__*/React.cloneElement(child, {
|
|
16
13
|
disabled: childProps.isSubmitting
|
|
17
14
|
}, children);
|
|
18
15
|
}
|
|
19
|
-
|
|
20
16
|
const fieldProps = {
|
|
21
17
|
touched: childProps.touched[fieldName],
|
|
22
18
|
error: childProps.errors[fieldName],
|
|
23
19
|
value: childProps.values[fieldName],
|
|
24
20
|
displayRequiredIndicator: displayRequiredIndicator
|
|
25
21
|
};
|
|
26
|
-
return /*#__PURE__*/React.cloneElement(child, {
|
|
22
|
+
return /*#__PURE__*/React.cloneElement(child, {
|
|
23
|
+
...child.props,
|
|
27
24
|
...fieldProps
|
|
28
25
|
}, React.Children.map(children, subchild => {
|
|
29
26
|
// Happens when we conditionally render elements.
|
|
30
27
|
if (!subchild) {
|
|
31
28
|
return null;
|
|
32
|
-
}
|
|
33
|
-
|
|
29
|
+
}
|
|
34
30
|
|
|
31
|
+
// Happens for simple text nodes.
|
|
35
32
|
if (!subchild.props) {
|
|
36
33
|
return /*#__PURE__*/React.createElement("span", null, subchild);
|
|
37
34
|
}
|
|
38
|
-
|
|
39
35
|
const {
|
|
40
36
|
fieldName,
|
|
41
37
|
children
|
|
@@ -46,18 +42,17 @@ const renderChildrenRecursively = (child, childProps, displayRequiredIndicator)
|
|
|
46
42
|
value: childProps.values[fieldName],
|
|
47
43
|
displayRequiredIndicator: displayRequiredIndicator
|
|
48
44
|
};
|
|
49
|
-
|
|
50
45
|
if (children) {
|
|
51
|
-
return renderChildrenRecursively(subchild, {
|
|
46
|
+
return renderChildrenRecursively(subchild, {
|
|
47
|
+
...childProps
|
|
52
48
|
}, displayRequiredIndicator);
|
|
53
49
|
}
|
|
54
|
-
|
|
55
|
-
|
|
50
|
+
return /*#__PURE__*/React.cloneElement(subchild, {
|
|
51
|
+
...childProps,
|
|
56
52
|
...fieldProps
|
|
57
53
|
}, null);
|
|
58
54
|
}));
|
|
59
55
|
};
|
|
60
|
-
|
|
61
56
|
const FormikWrapper = props => {
|
|
62
57
|
const {
|
|
63
58
|
initialValues,
|
|
@@ -82,5 +77,4 @@ const FormikWrapper = props => {
|
|
|
82
77
|
return renderChildrenRecursively(child, childProps, displayRequiredIndicator);
|
|
83
78
|
})));
|
|
84
79
|
};
|
|
85
|
-
|
|
86
80
|
export default FormikWrapper;
|
|
@@ -3,7 +3,6 @@ import { useTranslation } from 'react-i18next';
|
|
|
3
3
|
import withMapping from '../../../Context/withMapping';
|
|
4
4
|
import WysiwygField from '../../WysiwygField';
|
|
5
5
|
import './style.scss';
|
|
6
|
-
|
|
7
6
|
const GenericFormElement = props => {
|
|
8
7
|
const {
|
|
9
8
|
t
|
|
@@ -37,5 +36,4 @@ const GenericFormElement = props => {
|
|
|
37
36
|
className: `FormElement__error ${className}__error`
|
|
38
37
|
}, error) : null);
|
|
39
38
|
};
|
|
40
|
-
|
|
41
39
|
export default withMapping(GenericFormElement);
|