@uncinc/uncinc-react-kitchen-sink 2.3.3 → 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.
Files changed (112) hide show
  1. package/dist/Context/withMapping.js +1 -6
  2. package/dist/components/Accordion/AccordionItem/index.js +0 -5
  3. package/dist/components/Accordion/AccordionItemVariant/index.js +0 -5
  4. package/dist/components/Accordion/index.js +0 -2
  5. package/dist/components/ApiAutocomplete/index.js +6 -12
  6. package/dist/components/Button/index.js +4 -10
  7. package/dist/components/Cookie/Checkbox/index.js +0 -2
  8. package/dist/components/Cookie/index.js +39 -34
  9. package/dist/components/FontSizeSwitcher/index.js +2 -8
  10. package/dist/components/Form/Checkbox/index.js +1 -4
  11. package/dist/components/Form/Checkbox/stories.js +0 -2
  12. package/dist/components/Form/Checkboxes/index.js +1 -7
  13. package/dist/components/Form/Checkboxes/index.test.js +8 -4
  14. package/dist/components/Form/Checkboxes/stories.js +1 -4
  15. package/dist/components/Form/Date/index.js +1 -4
  16. package/dist/components/Form/Date/stories.js +0 -2
  17. package/dist/components/Form/DatePicker/index.js +0 -2
  18. package/dist/components/Form/DatePicker/stories.js +0 -2
  19. package/dist/components/Form/DateSelect/index.js +110 -85
  20. package/dist/components/Form/DateSelect/stories.js +24 -15
  21. package/dist/components/Form/DateSelect/style.scss +10 -4
  22. package/dist/components/Form/Email/index.js +1 -4
  23. package/dist/components/Form/Email/stories.js +0 -2
  24. package/dist/components/Form/FormikWrapper/index.js +9 -15
  25. package/dist/components/Form/GenericFormElement/index.js +0 -2
  26. package/dist/components/Form/Number/index.js +1 -10
  27. package/dist/components/Form/Number/stories.js +0 -2
  28. package/dist/components/Form/RadioButtons/index.js +1 -7
  29. package/dist/components/Form/RadioButtons/index.test.js +8 -4
  30. package/dist/components/Form/RadioButtons/stories.js +1 -4
  31. package/dist/components/Form/SearchField/index.js +0 -2
  32. package/dist/components/Form/Select/Input/index.js +4 -14
  33. package/dist/components/Form/Select/index.js +1 -4
  34. package/dist/components/Form/Select/stories.js +0 -4
  35. package/dist/components/Form/TextField/index.js +0 -6
  36. package/dist/components/Form/TextField/index.test.js +8 -4
  37. package/dist/components/Form/TextField/stories.js +1 -4
  38. package/dist/components/Form/Textarea/index.js +0 -2
  39. package/dist/components/Form/Textarea/stories.js +0 -2
  40. package/dist/components/Hamburger/index.js +0 -2
  41. package/dist/components/Header/index.js +4 -9
  42. package/dist/components/Image/Background/index.js +1 -7
  43. package/dist/components/Image/LazyLoadWrapper/index.js +0 -12
  44. package/dist/components/Image/Picture/index.js +4 -19
  45. package/dist/components/Image/index.js +0 -4
  46. package/dist/components/InlineMenu/index.js +0 -9
  47. package/dist/components/Layout/Container/index.js +1 -4
  48. package/dist/components/Layout/Container/stories.js +0 -3
  49. package/dist/components/Layout/QuickLayout/Auto/index.js +0 -2
  50. package/dist/components/Layout/QuickLayout/Center/index.js +0 -2
  51. package/dist/components/Layout/QuickLayout/Clamp/index.js +0 -2
  52. package/dist/components/Layout/QuickLayout/Sidebar/index.js +0 -2
  53. package/dist/components/Layout/QuickLayout/SpaceBetween/index.js +0 -2
  54. package/dist/components/Layout/QuickLayout/Stack/index.js +1 -4
  55. package/dist/components/Layout/QuickLayout/Wrap/index.js +0 -2
  56. package/dist/components/Layout/QuickLayout/index.js +0 -9
  57. package/dist/components/Lottie/LottieAnimation/index.js +12 -17
  58. package/dist/components/Lottie/LottieAnimationWithMousePosition.js +8 -9
  59. package/dist/components/Lottie/index.js +3 -3
  60. package/dist/components/Lottie/stories.js +10 -5
  61. package/dist/components/MagicLine/index.js +0 -14
  62. package/dist/components/MagicLine/stories.js +0 -2
  63. package/dist/components/NavigationScroll/index.js +2 -12
  64. package/dist/components/Pagination/index.js +0 -7
  65. package/dist/components/SearchKit/Facets/ChipFacet/index.js +0 -2
  66. package/dist/components/SearchKit/Facets/HierarchicalFilterFacet/index.js +0 -2
  67. package/dist/components/SearchKit/Facets/HierarchicalMenuFacet/index.js +0 -2
  68. package/dist/components/SearchKit/Facets/SelectFacet/index.js +0 -6
  69. package/dist/components/SearchKit/Query/index.js +3 -6
  70. package/dist/components/SearchKit/SearchFacets/index.js +0 -7
  71. package/dist/components/SearchKit/SearchField/index.js +0 -9
  72. package/dist/components/SearchKit/SearchLoadMore/index.js +0 -7
  73. package/dist/components/SearchKit/SearchPage/index.js +3 -9
  74. package/dist/components/SearchKit/SearchPagination/index.js +0 -5
  75. package/dist/components/SearchKit/SearchReset/index.js +0 -2
  76. package/dist/components/SearchKit/SearchResults/index.js +6 -11
  77. package/dist/components/SearchKit/SearchSelectedFilters/index.js +0 -4
  78. package/dist/components/SearchKit/SearchSorting/index.js +0 -2
  79. package/dist/components/SearchKit/index.js +0 -3
  80. package/dist/components/SearchKit/stories.js +2 -7
  81. package/dist/components/Share/index.js +0 -3
  82. package/dist/components/Sliders/SliderRelated/index.js +1 -6
  83. package/dist/components/Sliders/SliderRelated/stories.js +1 -4
  84. package/dist/components/Webform/WebformActions/index.js +0 -2
  85. package/dist/components/Webform/WebformCheckbox/index.js +1 -8
  86. package/dist/components/Webform/WebformCheckboxes/index.js +1 -9
  87. package/dist/components/Webform/WebformContainer/index.js +5 -6
  88. package/dist/components/Webform/WebformDate/index.js +12 -18
  89. package/dist/components/Webform/WebformMapper/index.js +1 -18
  90. package/dist/components/Webform/WebformNumber/index.js +1 -4
  91. package/dist/components/Webform/WebformRadioButtons/index.js +1 -9
  92. package/dist/components/Webform/WebformSelect/index.js +1 -9
  93. package/dist/components/Webform/WebformTextField/index.js +1 -8
  94. package/dist/components/Webform/WebformTextarea/index.js +1 -8
  95. package/dist/components/Webform/WebformWizardPage/index.js +6 -8
  96. package/dist/components/Webform/index.js +1 -8
  97. package/dist/components/Webform/withStates.js +6 -19
  98. package/dist/components/WysiwygField/index.js +1 -8
  99. package/dist/components/WysiwygField/stories.js +0 -3
  100. package/dist/config/constants.js +3 -4
  101. package/dist/config/i18next/index.js +23 -0
  102. package/dist/config/i18next/locales/en.json +22 -0
  103. package/dist/config/i18next/locales/nl.json +22 -0
  104. package/dist/helpers/gtm.js +11 -15
  105. package/dist/helpers/link.js +0 -4
  106. package/dist/helpers/useValueForCurrentViewPort.js +20 -14
  107. package/dist/hooks/useOnScreen.js +2 -2
  108. package/dist/hooks/usePrevious.js +3 -2
  109. package/dist/hooks/useScrollPosition.js +0 -3
  110. package/dist/hooks/useWindowDimensions.js +0 -3
  111. package/package.json +14 -5
  112. package/dist/pages/api/graphql.js +0 -25
@@ -1,144 +1,169 @@
1
1
  import React, { useState, useCallback, useEffect } from 'react';
2
- import moment from 'moment';
3
- import c from 'classnames';
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
- touched,
15
- error,
16
- values,
17
- setFieldValue,
18
- setFieldError,
11
+ yearMin,
12
+ yearMax,
13
+ hideYear,
14
+ fixedYear,
15
+ required,
19
16
  displayRequiredIndicator,
20
- className,
21
- wrapperClassName,
22
- disabled = false
23
- } = props; // Set all states for the date.
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 placeholderDay = 'Dag';
29
- const placeholderMonth = 'Maand';
30
- const placeholderYear = 'Jaar';
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
- const renderDayOptions = useCallback(placeholder => {
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
- }, []); // Render all options possible for months.
56
+ }, []);
54
57
 
55
- const renderMonthOptions = useCallback(() => {
56
- const months = ['Januari', 'Februari', 'Maart', 'April', 'Mei', 'Juni', 'Juli', 'Augustus', 'September', 'October', 'November', 'December'];
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
- }, []); // Render all options for possible years from
64
- // the DateMin and DateMax variables.
67
+ }, []);
65
68
 
66
- const renderYearOptions = useCallback(() => {
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
- }, [dateMax, dateMin]);
79
+ }, [yearMin, yearMax]);
80
+
81
+ // Check if all fields are filled
78
82
  useEffect(() => {
79
- // If one of these is not set return.
80
- if (!day || !month || !year) {
81
- setFieldError(requiredError || 'Dit is geen geldige geboortedatum.');
82
- setFieldValue(fieldName, null);
83
- return;
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
- if (day === placeholderDay || month === placeholderMonth || year === placeholderYear) {
87
- setFieldError(requiredError || 'Dit is geen geldige geboortedatum.');
88
- return;
89
- } // If birthday is invalid, like 2000/02/30, set an error.
90
-
91
-
92
- if (moment(values[fieldName])._isValid === false || day === placeholderDay || month === placeholderMonth || year === placeholderYear) {
93
- setFieldError(requiredError || 'Dit is geen geldige geboortedatum.');
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
- } // Transform state items to date object.
96
-
118
+ }
97
119
 
98
- const birthdate = moment(`${year}-${month}-${day}`, 'YYYY-MM-DD');
99
- setFieldError('');
100
- setFieldValue(fieldName, birthdate.format('YYYY-MM-DD'));
101
- }, [day, month, year, fieldName, values, setFieldValue, setFieldError, requiredError]);
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: c("DateSelect", wrapperClassName),
128
+ className: "DateSelect",
104
129
  title: title,
105
130
  required: required,
106
- description: description,
107
- fieldName: fieldName,
108
- touched: touched,
131
+ displayRequiredIndicator: displayRequiredIndicator,
109
132
  error: error,
110
- displayRequiredIndicator: displayRequiredIndicator
133
+ touched: showError
111
134
  }, /*#__PURE__*/React.createElement(SelectInput, {
112
- className: className,
113
- disabled: disabled,
114
- fieldName: `${fieldName}[day]`,
115
- options: renderDayOptions(),
135
+ id: `${fieldName}day`,
136
+ fieldName: `${fieldName}day`,
137
+ options: dayOptions(),
116
138
  value: day,
117
- placeholder: placeholderDay,
118
- onChange: e => {
119
- setDay(e);
120
- }
139
+ placeholder: dayPlaceholder,
140
+ onChange: day => setDay(day)
121
141
  }), /*#__PURE__*/React.createElement(SelectInput, {
122
- className: className,
123
- disabled: disabled,
124
- fieldName: `${fieldName}[month]`,
125
- options: renderMonthOptions(),
142
+ id: `${fieldName}month`,
143
+ fieldName: `${fieldName}month`,
144
+ options: monthOptions(),
126
145
  value: month,
127
- placeholder: placeholderMonth,
128
- onChange: e => {
129
- setMonth(e);
130
- }
131
- }), /*#__PURE__*/React.createElement(SelectInput, {
132
- className: className,
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: placeholderYear,
138
- onChange: e => {
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
- return /*#__PURE__*/React.createElement(FormikWrapper, null, /*#__PURE__*/React.createElement(FormikDateSelect, {
9
- title: "Date",
10
- required: true,
11
- description: "This is a test input.",
12
- placeholder: "This is a placeholder",
13
- fieldName: "date",
14
- validation: value => {
15
- let error;
16
-
17
- if (!value) {
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: 1.89;
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: 1.89;
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.29;
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.14;
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 || 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); }
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;
@@ -13,11 +13,9 @@ export const Email = () => {
13
13
  fieldName: "email",
14
14
  validation: value => {
15
15
  let error;
16
-
17
16
  if (!value) {
18
17
  error = 'Dit is een vereist veld.';
19
18
  }
20
-
21
19
  return error;
22
20
  }
23
21
  }));
@@ -1,8 +1,6 @@
1
- function _extends() { _extends = Object.assign || 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); }
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, { ...child.props,
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
- } // Happens for simple text nodes.
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, { ...childProps
46
+ return renderChildrenRecursively(subchild, {
47
+ ...childProps
52
48
  }, displayRequiredIndicator);
53
49
  }
54
-
55
- return /*#__PURE__*/React.cloneElement(subchild, { ...childProps,
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);
@@ -1,8 +1,6 @@
1
- function _extends() { _extends = Object.assign || 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); }
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 Number = props => {
7
5
  const {
8
6
  min,
@@ -11,25 +9,19 @@ const Number = props => {
11
9
  required,
12
10
  requiredError
13
11
  } = props;
14
-
15
12
  const validation = value => {
16
13
  let error;
17
-
18
14
  if (required && !value) {
19
15
  error = requiredError || `Value can not be empty`;
20
16
  }
21
-
22
17
  if (min && parseInt(value) < min) {
23
18
  error = `Value can not be lower than ${min}.`;
24
19
  }
25
-
26
20
  if (max && parseInt(value) > max) {
27
21
  error = `Value can not be higher than ${max}.`;
28
22
  }
29
-
30
23
  return error;
31
24
  };
32
-
33
25
  return /*#__PURE__*/React.createElement(TextField, _extends({}, props, {
34
26
  type: "number",
35
27
  validation: validation,
@@ -38,5 +30,4 @@ const Number = props => {
38
30
  step: step
39
31
  }));
40
32
  };
41
-
42
33
  export default Number;
@@ -16,11 +16,9 @@ export const Number = () => {
16
16
  fieldName: "amount",
17
17
  validation: value => {
18
18
  let error;
19
-
20
19
  if (!value) {
21
20
  error = 'Dit is een vereist veld.';
22
21
  }
23
-
24
22
  return error;
25
23
  }
26
24
  }));
@@ -1,11 +1,9 @@
1
- function _extends() { _extends = Object.assign || 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); }
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
  const Radio = props => {
10
8
  const {
11
9
  className,
@@ -24,7 +22,6 @@ const Radio = props => {
24
22
  'icon-radio': true,
25
23
  'icon-variant-1': field.value && field.value === props.value
26
24
  });
27
-
28
25
  if (props.value === '__other__') {
29
26
  const inputClasses = c({
30
27
  hidden: field.value !== '__other__'
@@ -44,7 +41,6 @@ const Radio = props => {
44
41
  }
45
42
  }));
46
43
  }
47
-
48
44
  return /*#__PURE__*/React.createElement("label", {
49
45
  htmlFor: name,
50
46
  className: classes
@@ -57,7 +53,6 @@ const Radio = props => {
57
53
  })), /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("span", null, props.label), props.description && /*#__PURE__*/React.createElement("span", null, props.description)));
58
54
  });
59
55
  };
60
-
61
56
  const RadioButtons = props => {
62
57
  const {
63
58
  title,
@@ -102,5 +97,4 @@ const RadioButtons = props => {
102
97
  });
103
98
  }));
104
99
  };
105
-
106
100
  export default RadioButtons;
@@ -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 { RadioButtons } from './stories'; // Use sinon-chai for spies.
7
+ import { RadioButtons } from './stories';
8
8
 
9
+ // Use sinon-chai for spies.
9
10
  chai.use(sinonChai);
10
11
  describe('<RadioButtons />', () => {
11
12
  it('renders 5 label elements', () => {
@@ -42,17 +43,20 @@ describe('<RadioButtons />', () => {
42
43
  input.at(2).simulate('change');
43
44
  await new Promise(resolve => {
44
45
  setTimeout(resolve);
45
- }); // Submit values, and wait for Formik to complete.
46
+ });
46
47
 
48
+ // Submit values, and wait for Formik to complete.
47
49
  wrapper.find('Formik').simulate('submit');
48
50
  await new Promise(resolve => {
49
51
  setTimeout(resolve);
50
52
  });
51
53
  });
52
- wrapper.update(); // Should not display an error message.
54
+ wrapper.update();
53
55
 
54
- expect(wrapper.find('div.RadioButtons__error')).to.have.lengthOf(0); // Submitted values should contain my value.
56
+ // Should not display an error message.
57
+ expect(wrapper.find('div.RadioButtons__error')).to.have.lengthOf(0);
55
58
 
59
+ // Submitted values should contain my value.
56
60
  expect(onSubmitCallback).to.have.been.calledWith({
57
61
  poison: 'rum'
58
62
  });
@@ -1,5 +1,4 @@
1
- function _extends() { _extends = Object.assign || 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); }
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 FormikRadio from '.';
@@ -31,11 +30,9 @@ export const RadioButtons = props => {
31
30
  },
32
31
  validation: value => {
33
32
  let error;
34
-
35
33
  if (!value) {
36
34
  error = 'This field is required';
37
35
  }
38
-
39
36
  return error;
40
37
  },
41
38
  otherLabel: "Anders"
@@ -3,7 +3,6 @@ import { Field } from 'formik';
3
3
  import c from 'classnames';
4
4
  import withMapping from '../../../Context/withMapping';
5
5
  import WysiwygField from '../../WysiwygField';
6
-
7
6
  const SearchField = props => {
8
7
  const {
9
8
  title,
@@ -44,5 +43,4 @@ const SearchField = props => {
44
43
  className: "SearchField__error WebformComponent--error"
45
44
  }, error) : null);
46
45
  };
47
-
48
46
  export default withMapping(SearchField);