@uncinc/uncinc-react-kitchen-sink 2.5.3 → 2.5.4-1-treeshaking
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/KitchenSinkComponentMapperContext.js +3 -11
- package/dist/Context/ViewportContext.js +8 -21
- package/dist/Context/withMapping.js +6 -17
- package/dist/components/AbbreviationAnnotation/index.js +17 -28
- package/dist/components/AbbreviationAnnotation/stories.js +12 -21
- package/dist/components/Accordion/AccordionItem/index.js +18 -29
- package/dist/components/Accordion/AccordionItemVariant/index.js +14 -25
- package/dist/components/Accordion/index.js +6 -14
- package/dist/components/Accordion/stories.js +16 -26
- package/dist/components/ApiAutocomplete/index.js +7 -17
- package/dist/components/ApiAutocomplete/stories.js +7 -16
- package/dist/components/Button/index.js +21 -30
- package/dist/components/Button/stories.js +11 -21
- package/dist/components/Cookie/Checkbox/index.js +6 -14
- package/dist/components/Cookie/index.js +61 -71
- package/dist/components/Cookie/stories.js +20 -33
- package/dist/components/Dialog/DialogHelpersStory/index.js +13 -25
- package/dist/components/Dialog/DialogHookStory/index.js +13 -22
- package/dist/components/Dialog/DialogOverrideStory/index.js +9 -18
- package/dist/components/Dialog/index.js +35 -46
- package/dist/components/Dialog/stories.js +10 -19
- package/dist/components/FontSizeSwitcher/index.js +17 -28
- package/dist/components/FontSizeSwitcher/stories.js +10 -20
- package/dist/components/Form/Checkbox/index.js +13 -21
- package/dist/components/Form/Checkbox/stories.js +8 -17
- package/dist/components/Form/Checkboxes/index.js +19 -27
- package/dist/components/Form/Checkboxes/index.test.js +23 -27
- package/dist/components/Form/Checkboxes/stories.js +9 -18
- package/dist/components/Form/Date/index.js +4 -12
- package/dist/components/Form/Date/stories.js +7 -16
- package/dist/components/Form/DatePicker/index.js +12 -20
- package/dist/components/Form/DatePicker/stories.js +7 -16
- package/dist/components/Form/DateSelect/index.js +24 -35
- package/dist/components/Form/DateSelect/stories.js +10 -22
- package/dist/components/Form/Email/index.js +4 -12
- package/dist/components/Form/Email/stories.js +7 -16
- package/dist/components/Form/FormikWrapper/index.js +9 -17
- package/dist/components/Form/GenericFormElement/index.js +14 -22
- package/dist/components/Form/Number/index.js +6 -14
- package/dist/components/Form/Number/stories.js +7 -16
- package/dist/components/Form/RadioButtons/index.js +17 -25
- package/dist/components/Form/RadioButtons/index.test.js +23 -27
- package/dist/components/Form/RadioButtons/stories.js +9 -18
- package/dist/components/Form/SearchField/index.js +14 -22
- package/dist/components/Form/Select/Input/index.js +10 -18
- package/dist/components/Form/Select/index.js +10 -18
- package/dist/components/Form/Select/stories.js +9 -19
- package/dist/components/Form/TextField/index.js +11 -19
- package/dist/components/Form/TextField/index.test.js +23 -27
- package/dist/components/Form/TextField/stories.js +8 -17
- package/dist/components/Form/Textarea/index.js +10 -18
- package/dist/components/Form/Textarea/stories.js +7 -16
- package/dist/components/Hamburger/index.js +7 -15
- package/dist/components/Hamburger/stories.js +12 -22
- package/dist/components/Header/index.js +23 -38
- package/dist/components/Header/stories.js +22 -34
- package/dist/components/Image/Background/index.js +10 -21
- package/dist/components/Image/LazyLoadWrapper/index.js +16 -26
- package/dist/components/Image/Picture/index.js +20 -28
- package/dist/components/Image/index.js +11 -19
- package/dist/components/Image/stories.js +28 -41
- package/dist/components/InlineMenu/index.js +14 -25
- package/dist/components/InlineMenu/stories.js +18 -27
- package/dist/components/Layout/Container/index.js +10 -18
- package/dist/components/Layout/Container/stories.js +44 -53
- package/dist/components/Layout/QuickLayout/Auto/index.js +5 -13
- package/dist/components/Layout/QuickLayout/Center/index.js +6 -14
- package/dist/components/Layout/QuickLayout/Clamp/index.js +5 -13
- package/dist/components/Layout/QuickLayout/Sidebar/index.js +6 -14
- package/dist/components/Layout/QuickLayout/SpaceBetween/index.js +6 -14
- package/dist/components/Layout/QuickLayout/Stack/index.js +6 -14
- package/dist/components/Layout/QuickLayout/Wrap/index.js +7 -15
- package/dist/components/Layout/QuickLayout/index.js +16 -24
- package/dist/components/Layout/QuickLayout/stories.js +38 -54
- package/dist/components/Lottie/LottieAnimation/index.js +12 -23
- package/dist/components/Lottie/LottieAnimationWithMousePosition.js +8 -19
- package/dist/components/Lottie/index.js +29 -41
- package/dist/components/Lottie/stories.js +25 -36
- package/dist/components/MagicLine/index.js +12 -23
- package/dist/components/MagicLine/stories.js +16 -26
- package/dist/components/NavigationScroll/index.js +11 -21
- package/dist/components/NavigationScroll/stories.js +9 -18
- package/dist/components/Pagination/index.js +27 -36
- package/dist/components/Pagination/stories.js +17 -30
- package/dist/components/SearchKit/Facets/ChipFacet/index.js +11 -20
- package/dist/components/SearchKit/Facets/ListFacet/index.js +11 -20
- package/dist/components/SearchKit/Facets/SelectFacet/index.js +15 -24
- package/dist/components/SearchKit/Query/index.js +13 -24
- package/dist/components/SearchKit/SearchFacets/index.js +10 -18
- package/dist/components/SearchKit/SearchField/index.js +12 -23
- package/dist/components/SearchKit/SearchLoadMore/index.js +7 -15
- package/dist/components/SearchKit/SearchPage/index.js +8 -17
- package/dist/components/SearchKit/SearchPagination/index.js +6 -14
- package/dist/components/SearchKit/SearchReset/index.js +8 -16
- package/dist/components/SearchKit/SearchResults/index.js +28 -39
- package/dist/components/SearchKit/SearchSelectedFilters/Filters/CustomValue/index.js +6 -14
- package/dist/components/SearchKit/SearchSelectedFilters/Filters/DateRange/index.js +6 -14
- package/dist/components/SearchKit/SearchSelectedFilters/Filters/NumericRange/index.js +6 -14
- package/dist/components/SearchKit/SearchSelectedFilters/Filters/Value/index.js +7 -18
- package/dist/components/SearchKit/SearchSelectedFilters/index.js +18 -26
- package/dist/components/SearchKit/SearchSorting/index.js +9 -17
- package/dist/components/SearchKit/index.js +29 -40
- package/dist/components/SearchKit/stories.js +54 -69
- package/dist/components/Share/index.js +18 -26
- package/dist/components/Share/stories.js +7 -16
- package/dist/components/Sliders/SliderRelated/index.js +11 -19
- package/dist/components/Sliders/SliderRelated/stories.js +22 -33
- package/dist/components/WysiwygField/index.js +10 -18
- package/dist/components/WysiwygField/stories.js +10 -20
- package/dist/components/index.js +15 -111
- package/dist/config/constants.js +17 -37
- package/dist/config/i18next/index.js +9 -17
- package/dist/helpers/date.js +4 -13
- package/dist/helpers/gtm.js +4 -11
- package/dist/helpers/link.js +4 -12
- package/dist/helpers/useValueForCurrentViewPort.js +6 -13
- package/dist/hooks/useBoolean.js +6 -12
- package/dist/hooks/useClickOutside.js +3 -9
- package/dist/hooks/useDialog.js +6 -13
- package/dist/hooks/useDialogHelpers.js +11 -18
- package/dist/hooks/useEscape.js +3 -9
- package/dist/hooks/useOnScreen.js +4 -10
- package/dist/hooks/usePrevious.js +4 -10
- package/dist/hooks/useScrollPosition.js +4 -11
- package/dist/hooks/useTrapFocus.js +3 -9
- package/dist/hooks/useWindowDimensions.js +4 -10
- package/dist/index.js +76 -471
- package/dist/setupTests.js +2 -5
- package/package.json +9 -3
|
@@ -1,23 +1,16 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _react = _interopRequireDefault(require("react"));
|
|
8
|
-
var _formik = require("formik");
|
|
9
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
10
|
-
var _GenericFormElement = _interopRequireDefault(require("../GenericFormElement"));
|
|
11
|
-
require("./style.scss");
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
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); }
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Field } from 'formik';
|
|
4
|
+
import c from 'classnames';
|
|
5
|
+
import GenericFormElement from '../GenericFormElement';
|
|
6
|
+
import './style.scss';
|
|
14
7
|
function Checkbox(props) {
|
|
15
8
|
var name = props.name,
|
|
16
9
|
value = props.value,
|
|
17
10
|
validate = props.validate,
|
|
18
11
|
disabled = props.disabled,
|
|
19
12
|
className = props.className;
|
|
20
|
-
return /*#__PURE__*/
|
|
13
|
+
return /*#__PURE__*/React.createElement(Field, {
|
|
21
14
|
required: true,
|
|
22
15
|
name: name,
|
|
23
16
|
value: value,
|
|
@@ -27,19 +20,19 @@ function Checkbox(props) {
|
|
|
27
20
|
form = _ref.form;
|
|
28
21
|
var name = "".concat(props.name, "--").concat(props.value);
|
|
29
22
|
var checked = field.value && field.value.includes(value);
|
|
30
|
-
var classes = (
|
|
23
|
+
var classes = c('WebformCheckboxes__checkbox__input', {
|
|
31
24
|
'icon-before': true,
|
|
32
25
|
'icon-checkmark': true,
|
|
33
26
|
'icon-variant-1': checked
|
|
34
27
|
});
|
|
35
28
|
if (props.value === '__other__') {
|
|
36
|
-
var inputClasses = (
|
|
29
|
+
var inputClasses = c({
|
|
37
30
|
hidden: !field.value.includes('__other__')
|
|
38
31
|
});
|
|
39
|
-
return /*#__PURE__*/
|
|
32
|
+
return /*#__PURE__*/React.createElement("label", {
|
|
40
33
|
className: classes,
|
|
41
34
|
htmlFor: name
|
|
42
|
-
}, /*#__PURE__*/
|
|
35
|
+
}, /*#__PURE__*/React.createElement("input", _extends({}, field, {
|
|
43
36
|
name: props.name,
|
|
44
37
|
value: value,
|
|
45
38
|
type: "checkbox",
|
|
@@ -47,7 +40,7 @@ function Checkbox(props) {
|
|
|
47
40
|
checked: checked,
|
|
48
41
|
disabled: disabled,
|
|
49
42
|
className: className
|
|
50
|
-
})), /*#__PURE__*/
|
|
43
|
+
})), /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("span", null, props.otherLabel ? props.otherLabel : props.label), props.description && /*#__PURE__*/React.createElement("span", null, props.description)), /*#__PURE__*/React.createElement("textarea", {
|
|
51
44
|
placeholder: props.otherPlaceholder,
|
|
52
45
|
className: inputClasses,
|
|
53
46
|
onChange: function onChange(e) {
|
|
@@ -55,10 +48,10 @@ function Checkbox(props) {
|
|
|
55
48
|
}
|
|
56
49
|
}));
|
|
57
50
|
}
|
|
58
|
-
return /*#__PURE__*/
|
|
51
|
+
return /*#__PURE__*/React.createElement("label", {
|
|
59
52
|
className: classes,
|
|
60
53
|
htmlFor: name
|
|
61
|
-
}, /*#__PURE__*/
|
|
54
|
+
}, /*#__PURE__*/React.createElement("input", _extends({}, field, {
|
|
62
55
|
name: props.name,
|
|
63
56
|
value: value,
|
|
64
57
|
type: "checkbox",
|
|
@@ -66,7 +59,7 @@ function Checkbox(props) {
|
|
|
66
59
|
checked: checked,
|
|
67
60
|
disabled: disabled,
|
|
68
61
|
className: className
|
|
69
|
-
})), /*#__PURE__*/
|
|
62
|
+
})), /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("span", null, props.label), props.description && /*#__PURE__*/React.createElement("span", null, props.description)));
|
|
70
63
|
});
|
|
71
64
|
}
|
|
72
65
|
var Checkboxes = function Checkboxes(props) {
|
|
@@ -89,8 +82,8 @@ var Checkboxes = function Checkboxes(props) {
|
|
|
89
82
|
disabled = _props$disabled === void 0 ? false : _props$disabled,
|
|
90
83
|
otherLabel = props.otherLabel,
|
|
91
84
|
otherPlaceholder = props.otherPlaceholder;
|
|
92
|
-
return /*#__PURE__*/
|
|
93
|
-
className: (
|
|
85
|
+
return /*#__PURE__*/React.createElement(GenericFormElement, {
|
|
86
|
+
className: c('Checkboxes', wrapperClassName),
|
|
94
87
|
title: title,
|
|
95
88
|
required: required,
|
|
96
89
|
description: description,
|
|
@@ -101,11 +94,11 @@ var Checkboxes = function Checkboxes(props) {
|
|
|
101
94
|
}, Object.keys(options).map(function (value) {
|
|
102
95
|
var label = options[value];
|
|
103
96
|
var description = descriptions[value] || null;
|
|
104
|
-
return /*#__PURE__*/
|
|
97
|
+
return /*#__PURE__*/React.createElement(Checkbox, {
|
|
105
98
|
key: value,
|
|
106
99
|
label: label,
|
|
107
100
|
description: description,
|
|
108
|
-
className: (
|
|
101
|
+
className: c(className, {
|
|
109
102
|
'error': error && touched
|
|
110
103
|
}),
|
|
111
104
|
name: fieldName,
|
|
@@ -119,5 +112,4 @@ var Checkboxes = function Checkboxes(props) {
|
|
|
119
112
|
});
|
|
120
113
|
}));
|
|
121
114
|
};
|
|
122
|
-
|
|
123
|
-
exports.default = _default;
|
|
115
|
+
export default Checkboxes;
|
|
@@ -1,29 +1,25 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
1
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
-
var _react = _interopRequireDefault(require("react"));
|
|
5
|
-
var _react2 = require("@testing-library/react");
|
|
6
|
-
var _chai = _interopRequireWildcard(require("chai"));
|
|
7
|
-
var _sinon = _interopRequireDefault(require("sinon"));
|
|
8
|
-
var _sinonChai = _interopRequireDefault(require("sinon-chai"));
|
|
9
|
-
var _FormikWrapper = _interopRequireDefault(require("../FormikWrapper"));
|
|
10
|
-
var _ = _interopRequireDefault(require("."));
|
|
11
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
12
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
13
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
2
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
15
3
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
16
4
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { act, render } from '@testing-library/react';
|
|
7
|
+
import chai, { expect } from 'chai';
|
|
8
|
+
import sinon from 'sinon';
|
|
9
|
+
import sinonChai from 'sinon-chai';
|
|
10
|
+
import FormikWrapper from '../FormikWrapper';
|
|
11
|
+
import Checkboxes from '.';
|
|
12
|
+
|
|
17
13
|
// Use sinon-chai for spies.
|
|
18
|
-
|
|
14
|
+
chai.use(sinonChai);
|
|
19
15
|
var renderCheckboxes = function renderCheckboxes() {
|
|
20
|
-
var onSubmit = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] :
|
|
21
|
-
return
|
|
16
|
+
var onSubmit = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : sinon.spy();
|
|
17
|
+
return render( /*#__PURE__*/React.createElement(FormikWrapper, {
|
|
22
18
|
initialValues: {
|
|
23
19
|
'poison': []
|
|
24
20
|
},
|
|
25
21
|
onSubmit: onSubmit
|
|
26
|
-
}, /*#__PURE__*/
|
|
22
|
+
}, /*#__PURE__*/React.createElement(Checkboxes, {
|
|
27
23
|
title: "Pick your poison",
|
|
28
24
|
required: true,
|
|
29
25
|
description: "Please select your poison.",
|
|
@@ -43,7 +39,7 @@ var renderCheckboxes = function renderCheckboxes() {
|
|
|
43
39
|
return error;
|
|
44
40
|
},
|
|
45
41
|
otherLabel: "Anders"
|
|
46
|
-
}), /*#__PURE__*/
|
|
42
|
+
}), /*#__PURE__*/React.createElement("input", {
|
|
47
43
|
type: "submit",
|
|
48
44
|
value: "Verzenden"
|
|
49
45
|
})));
|
|
@@ -55,7 +51,7 @@ describe('<Checkboxes />', function () {
|
|
|
55
51
|
while (1) switch (_context.prev = _context.next) {
|
|
56
52
|
case 0:
|
|
57
53
|
_renderCheckboxes = renderCheckboxes(), container = _renderCheckboxes.container;
|
|
58
|
-
|
|
54
|
+
expect(container.querySelector('.Checkboxes__inner').querySelectorAll('label')).to.have.lengthOf(5);
|
|
59
55
|
case 2:
|
|
60
56
|
case "end":
|
|
61
57
|
return _context.stop();
|
|
@@ -65,7 +61,7 @@ describe('<Checkboxes />', function () {
|
|
|
65
61
|
test('renders a description element', function () {
|
|
66
62
|
var _renderCheckboxes2 = renderCheckboxes(),
|
|
67
63
|
container = _renderCheckboxes2.container;
|
|
68
|
-
|
|
64
|
+
expect(container.querySelectorAll('div.Checkboxes__description')).to.have.lengthOf(1);
|
|
69
65
|
});
|
|
70
66
|
test('displays a required error message', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
71
67
|
var _renderCheckboxes3, container;
|
|
@@ -73,9 +69,9 @@ describe('<Checkboxes />', function () {
|
|
|
73
69
|
while (1) switch (_context3.prev = _context3.next) {
|
|
74
70
|
case 0:
|
|
75
71
|
_renderCheckboxes3 = renderCheckboxes(), container = _renderCheckboxes3.container;
|
|
76
|
-
|
|
72
|
+
expect(container.querySelectorAll('div.Checkboxes__error')).to.have.lengthOf(0);
|
|
77
73
|
_context3.next = 4;
|
|
78
|
-
return
|
|
74
|
+
return act( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
79
75
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
80
76
|
while (1) switch (_context2.prev = _context2.next) {
|
|
81
77
|
case 0:
|
|
@@ -92,7 +88,7 @@ describe('<Checkboxes />', function () {
|
|
|
92
88
|
}, _callee2);
|
|
93
89
|
})));
|
|
94
90
|
case 4:
|
|
95
|
-
|
|
91
|
+
expect(container.querySelectorAll('div.Checkboxes__error')).to.have.lengthOf(1);
|
|
96
92
|
case 5:
|
|
97
93
|
case "end":
|
|
98
94
|
return _context3.stop();
|
|
@@ -104,12 +100,12 @@ describe('<Checkboxes />', function () {
|
|
|
104
100
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
105
101
|
while (1) switch (_context5.prev = _context5.next) {
|
|
106
102
|
case 0:
|
|
107
|
-
onSubmitCallback =
|
|
103
|
+
onSubmitCallback = sinon.spy();
|
|
108
104
|
_renderCheckboxes4 = renderCheckboxes(onSubmitCallback), container = _renderCheckboxes4.container;
|
|
109
105
|
inputs = container.querySelectorAll('input');
|
|
110
|
-
|
|
106
|
+
expect(container.querySelectorAll('div.Checkboxes__error')).to.have.lengthOf(0);
|
|
111
107
|
_context5.next = 6;
|
|
112
|
-
return
|
|
108
|
+
return act( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
113
109
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
114
110
|
while (1) switch (_context4.prev = _context4.next) {
|
|
115
111
|
case 0:
|
|
@@ -140,10 +136,10 @@ describe('<Checkboxes />', function () {
|
|
|
140
136
|
})));
|
|
141
137
|
case 6:
|
|
142
138
|
// Should not display an error message.
|
|
143
|
-
|
|
139
|
+
expect(container.querySelectorAll('div.Checkboxes__error')).to.have.lengthOf(0);
|
|
144
140
|
|
|
145
141
|
// Submitted values should contain my value.;
|
|
146
|
-
|
|
142
|
+
expect(onSubmitCallback).to.have.been.calledWith({
|
|
147
143
|
poison: ['rum', 'whisky']
|
|
148
144
|
});
|
|
149
145
|
case 8:
|
|
@@ -1,27 +1,19 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = exports.Checkboxes = void 0;
|
|
7
|
-
var _react = _interopRequireDefault(require("react"));
|
|
8
|
-
var _FormikWrapper = _interopRequireDefault(require("../FormikWrapper"));
|
|
9
|
-
var _ = _interopRequireDefault(require("."));
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
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); }
|
|
12
|
-
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import FormikWrapper from '../FormikWrapper';
|
|
4
|
+
import FormikCheckboxes from '.';
|
|
5
|
+
export default {
|
|
13
6
|
title: 'Molecules/Form'
|
|
14
7
|
};
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return /*#__PURE__*/_react.default.createElement(_FormikWrapper.default, _extends({}, props, {
|
|
8
|
+
export var Checkboxes = function Checkboxes(props) {
|
|
9
|
+
return /*#__PURE__*/React.createElement(FormikWrapper, _extends({}, props, {
|
|
18
10
|
initialValues: {
|
|
19
11
|
'poison': []
|
|
20
12
|
},
|
|
21
13
|
onSubmit: function onSubmit(values) {
|
|
22
14
|
return console.log(values);
|
|
23
15
|
}
|
|
24
|
-
}), /*#__PURE__*/
|
|
16
|
+
}), /*#__PURE__*/React.createElement(FormikCheckboxes, {
|
|
25
17
|
title: "Pick your poison",
|
|
26
18
|
required: true,
|
|
27
19
|
description: "Please select your poison.",
|
|
@@ -41,9 +33,8 @@ var Checkboxes = function Checkboxes(props) {
|
|
|
41
33
|
return error;
|
|
42
34
|
},
|
|
43
35
|
otherLabel: "Anders"
|
|
44
|
-
}), /*#__PURE__*/
|
|
36
|
+
}), /*#__PURE__*/React.createElement("input", {
|
|
45
37
|
type: "submit",
|
|
46
38
|
value: "Verzenden"
|
|
47
39
|
}));
|
|
48
|
-
};
|
|
49
|
-
exports.Checkboxes = Checkboxes;
|
|
40
|
+
};
|
|
@@ -1,17 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _react = _interopRequireDefault(require("react"));
|
|
8
|
-
var _TextField = _interopRequireDefault(require("../TextField"));
|
|
9
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
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); }
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import TextField from '../TextField';
|
|
11
4
|
var Date = function Date(props) {
|
|
12
|
-
return /*#__PURE__*/
|
|
5
|
+
return /*#__PURE__*/React.createElement(TextField, _extends({}, props, {
|
|
13
6
|
type: "date"
|
|
14
7
|
}));
|
|
15
8
|
};
|
|
16
|
-
|
|
17
|
-
exports.default = _default;
|
|
9
|
+
export default Date;
|
|
@@ -1,19 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
exports.default = exports.Date = void 0;
|
|
7
|
-
var _react = _interopRequireDefault(require("react"));
|
|
8
|
-
var _FormikWrapper = _interopRequireDefault(require("../FormikWrapper"));
|
|
9
|
-
var _ = _interopRequireDefault(require("."));
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
var _default = {
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import FormikWrapper from '../FormikWrapper';
|
|
3
|
+
import FormikDate from '.';
|
|
4
|
+
export default {
|
|
12
5
|
title: 'Molecules/Form'
|
|
13
6
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return /*#__PURE__*/_react.default.createElement(_FormikWrapper.default, null, /*#__PURE__*/_react.default.createElement(_.default, {
|
|
7
|
+
export var Date = function Date() {
|
|
8
|
+
return /*#__PURE__*/React.createElement(FormikWrapper, null, /*#__PURE__*/React.createElement(FormikDate, {
|
|
17
9
|
title: "Date",
|
|
18
10
|
required: true,
|
|
19
11
|
description: "This is a test input.",
|
|
@@ -27,5 +19,4 @@ var Date = function Date() {
|
|
|
27
19
|
return error;
|
|
28
20
|
}
|
|
29
21
|
}));
|
|
30
|
-
};
|
|
31
|
-
exports.Date = Date;
|
|
22
|
+
};
|
|
@@ -1,17 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var _reactDatepicker = _interopRequireDefault(require("react-datepicker"));
|
|
9
|
-
var _formik = require("formik");
|
|
10
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
11
|
-
var _GenericFormElement = _interopRequireDefault(require("../GenericFormElement"));
|
|
12
|
-
require("react-datepicker/dist/react-datepicker.css");
|
|
13
|
-
require("./style.scss");
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import ReactDatePicker from 'react-datepicker';
|
|
3
|
+
import { Field } from 'formik';
|
|
4
|
+
import c from 'classnames';
|
|
5
|
+
import GenericFormElement from '../GenericFormElement';
|
|
6
|
+
import 'react-datepicker/dist/react-datepicker.css';
|
|
7
|
+
import './style.scss';
|
|
15
8
|
var DatePicker = function DatePicker(props) {
|
|
16
9
|
var title = props.title,
|
|
17
10
|
required = props.required,
|
|
@@ -28,8 +21,8 @@ var DatePicker = function DatePicker(props) {
|
|
|
28
21
|
wrapperClassName = props.wrapperClassName,
|
|
29
22
|
_props$disabled = props.disabled,
|
|
30
23
|
disabled = _props$disabled === void 0 ? false : _props$disabled;
|
|
31
|
-
return /*#__PURE__*/
|
|
32
|
-
className: (
|
|
24
|
+
return /*#__PURE__*/React.createElement(GenericFormElement, {
|
|
25
|
+
className: c('DatePicker', wrapperClassName),
|
|
33
26
|
title: title,
|
|
34
27
|
required: required,
|
|
35
28
|
description: description,
|
|
@@ -37,7 +30,7 @@ var DatePicker = function DatePicker(props) {
|
|
|
37
30
|
touched: touched,
|
|
38
31
|
error: error,
|
|
39
32
|
displayRequiredIndicator: displayRequiredIndicator
|
|
40
|
-
}, /*#__PURE__*/
|
|
33
|
+
}, /*#__PURE__*/React.createElement(Field, {
|
|
41
34
|
placeholder: placeholder,
|
|
42
35
|
fieldName: fieldName,
|
|
43
36
|
validation: validation,
|
|
@@ -47,7 +40,7 @@ var DatePicker = function DatePicker(props) {
|
|
|
47
40
|
value: value
|
|
48
41
|
}, function (_ref) {
|
|
49
42
|
var form = _ref.form;
|
|
50
|
-
return /*#__PURE__*/
|
|
43
|
+
return /*#__PURE__*/React.createElement(ReactDatePicker, {
|
|
51
44
|
id: fieldName,
|
|
52
45
|
selected: value && new Date(value) || null,
|
|
53
46
|
onChange: function onChange(value) {
|
|
@@ -62,5 +55,4 @@ var DatePicker = function DatePicker(props) {
|
|
|
62
55
|
});
|
|
63
56
|
}));
|
|
64
57
|
};
|
|
65
|
-
|
|
66
|
-
exports.default = _default;
|
|
58
|
+
export default DatePicker;
|
|
@@ -1,19 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
exports.default = exports.DatePicker = void 0;
|
|
7
|
-
var _react = _interopRequireDefault(require("react"));
|
|
8
|
-
var _FormikWrapper = _interopRequireDefault(require("../FormikWrapper"));
|
|
9
|
-
var _ = _interopRequireDefault(require("."));
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
var _default = {
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import FormikWrapper from '../FormikWrapper';
|
|
3
|
+
import FormikDatePicker from '.';
|
|
4
|
+
export default {
|
|
12
5
|
title: 'Molecules/Form'
|
|
13
6
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return /*#__PURE__*/_react.default.createElement(_FormikWrapper.default, null, /*#__PURE__*/_react.default.createElement(_.default, {
|
|
7
|
+
export var DatePicker = function DatePicker() {
|
|
8
|
+
return /*#__PURE__*/React.createElement(FormikWrapper, null, /*#__PURE__*/React.createElement(FormikDatePicker, {
|
|
17
9
|
title: "Date",
|
|
18
10
|
required: true,
|
|
19
11
|
description: "This is a test input.",
|
|
@@ -27,5 +19,4 @@ var DatePicker = function DatePicker() {
|
|
|
27
19
|
return error;
|
|
28
20
|
}
|
|
29
21
|
}));
|
|
30
|
-
};
|
|
31
|
-
exports.DatePicker = DatePicker;
|
|
22
|
+
};
|
|
@@ -1,25 +1,15 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
-
var _formik = require("formik");
|
|
10
|
-
var _reactI18next = require("react-i18next");
|
|
11
|
-
var _GenericFormElement = _interopRequireDefault(require("../GenericFormElement"));
|
|
12
|
-
var _Input = _interopRequireDefault(require("../Select/Input"));
|
|
13
|
-
require("./style.scss");
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
16
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
17
1
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
18
2
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
19
3
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
20
4
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
21
5
|
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
22
6
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
import React, { useState, useCallback, useEffect } from 'react';
|
|
8
|
+
import { useFormikContext } from 'formik';
|
|
9
|
+
import { useTranslation } from 'react-i18next';
|
|
10
|
+
import GenericFormElement from '../GenericFormElement';
|
|
11
|
+
import SelectInput from '../Select/Input';
|
|
12
|
+
import './style.scss';
|
|
23
13
|
var DateSelect = function DateSelect(props) {
|
|
24
14
|
var title = props.title,
|
|
25
15
|
fieldName = props.fieldName,
|
|
@@ -34,41 +24,41 @@ var DateSelect = function DateSelect(props) {
|
|
|
34
24
|
dayPlaceholder = props.dayPlaceholder,
|
|
35
25
|
monthPlaceholder = props.monthPlaceholder,
|
|
36
26
|
yearPlaceholder = props.yearPlaceholder;
|
|
37
|
-
var _useFormikContext =
|
|
27
|
+
var _useFormikContext = useFormikContext(),
|
|
38
28
|
setFieldValue = _useFormikContext.setFieldValue,
|
|
39
29
|
isSubmitting = _useFormikContext.isSubmitting,
|
|
40
30
|
values = _useFormikContext.values;
|
|
41
|
-
var _useTranslation =
|
|
31
|
+
var _useTranslation = useTranslation(),
|
|
42
32
|
t = _useTranslation.t;
|
|
43
33
|
|
|
44
34
|
// Set all states for the date.
|
|
45
|
-
var _useState =
|
|
35
|
+
var _useState = useState(),
|
|
46
36
|
_useState2 = _slicedToArray(_useState, 2),
|
|
47
37
|
day = _useState2[0],
|
|
48
38
|
setDay = _useState2[1];
|
|
49
|
-
var _useState3 =
|
|
39
|
+
var _useState3 = useState(),
|
|
50
40
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
51
41
|
month = _useState4[0],
|
|
52
42
|
setMonth = _useState4[1];
|
|
53
|
-
var _useState5 =
|
|
43
|
+
var _useState5 = useState(),
|
|
54
44
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
55
45
|
year = _useState6[0],
|
|
56
46
|
setYear = _useState6[1];
|
|
57
|
-
var _useState7 =
|
|
47
|
+
var _useState7 = useState(),
|
|
58
48
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
59
49
|
showError = _useState8[0],
|
|
60
50
|
setShowError = _useState8[1];
|
|
61
|
-
var _useState9 =
|
|
51
|
+
var _useState9 = useState(),
|
|
62
52
|
_useState10 = _slicedToArray(_useState9, 2),
|
|
63
53
|
error = _useState10[0],
|
|
64
54
|
setError = _useState10[1];
|
|
65
|
-
var _useState11 =
|
|
55
|
+
var _useState11 = useState(),
|
|
66
56
|
_useState12 = _slicedToArray(_useState11, 2),
|
|
67
57
|
dateNotValid = _useState12[0],
|
|
68
58
|
setDateNotValid = _useState12[1];
|
|
69
59
|
|
|
70
60
|
// List all day options
|
|
71
|
-
var dayOptions =
|
|
61
|
+
var dayOptions = useCallback(function (placeholder) {
|
|
72
62
|
var options = [];
|
|
73
63
|
if (placeholder) {
|
|
74
64
|
options.push({
|
|
@@ -86,7 +76,7 @@ var DateSelect = function DateSelect(props) {
|
|
|
86
76
|
}, []);
|
|
87
77
|
|
|
88
78
|
// List all month options
|
|
89
|
-
var monthOptions =
|
|
79
|
+
var monthOptions = useCallback(function () {
|
|
90
80
|
var 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')];
|
|
91
81
|
return months.map(function (e, i) {
|
|
92
82
|
return {
|
|
@@ -97,7 +87,7 @@ var DateSelect = function DateSelect(props) {
|
|
|
97
87
|
}, []);
|
|
98
88
|
|
|
99
89
|
// List all options for possible years from the yearMin and yearMax variables.
|
|
100
|
-
var yearOptions =
|
|
90
|
+
var yearOptions = useCallback(function () {
|
|
101
91
|
var options = [];
|
|
102
92
|
for (var index = yearMin; index <= yearMax; index++) {
|
|
103
93
|
options.push({
|
|
@@ -109,7 +99,7 @@ var DateSelect = function DateSelect(props) {
|
|
|
109
99
|
}, [yearMin, yearMax]);
|
|
110
100
|
|
|
111
101
|
// Check if all fields are filled
|
|
112
|
-
|
|
102
|
+
useEffect(function () {
|
|
113
103
|
if (isSubmitting) {
|
|
114
104
|
if (required && !values[fieldName]) {
|
|
115
105
|
!dateNotValid && setError(requiredError);
|
|
@@ -119,7 +109,7 @@ var DateSelect = function DateSelect(props) {
|
|
|
119
109
|
}, [isSubmitting]);
|
|
120
110
|
|
|
121
111
|
// Validation and setting either an error or the FieldValue
|
|
122
|
-
|
|
112
|
+
useEffect(function () {
|
|
123
113
|
hideYear && setYear(fixedYear || new Date().getFullYear());
|
|
124
114
|
|
|
125
115
|
// All options are filled, start validation
|
|
@@ -153,14 +143,14 @@ var DateSelect = function DateSelect(props) {
|
|
|
153
143
|
setDateNotValid(false);
|
|
154
144
|
setFieldValue('dateSelect', '');
|
|
155
145
|
}, [day, month, year]);
|
|
156
|
-
return /*#__PURE__*/
|
|
146
|
+
return /*#__PURE__*/React.createElement(GenericFormElement, {
|
|
157
147
|
className: "DateSelect",
|
|
158
148
|
title: title,
|
|
159
149
|
required: required,
|
|
160
150
|
displayRequiredIndicator: displayRequiredIndicator,
|
|
161
151
|
error: error,
|
|
162
152
|
touched: showError
|
|
163
|
-
}, /*#__PURE__*/
|
|
153
|
+
}, /*#__PURE__*/React.createElement(SelectInput, {
|
|
164
154
|
id: "".concat(fieldName, "day"),
|
|
165
155
|
fieldName: "".concat(fieldName, "day"),
|
|
166
156
|
options: dayOptions(),
|
|
@@ -169,7 +159,7 @@ var DateSelect = function DateSelect(props) {
|
|
|
169
159
|
onChange: function onChange(day) {
|
|
170
160
|
return setDay(day);
|
|
171
161
|
}
|
|
172
|
-
}), /*#__PURE__*/
|
|
162
|
+
}), /*#__PURE__*/React.createElement(SelectInput, {
|
|
173
163
|
id: "".concat(fieldName, "month"),
|
|
174
164
|
fieldName: "".concat(fieldName, "month"),
|
|
175
165
|
options: monthOptions(),
|
|
@@ -178,7 +168,7 @@ var DateSelect = function DateSelect(props) {
|
|
|
178
168
|
onChange: function onChange(month) {
|
|
179
169
|
return setMonth(month);
|
|
180
170
|
}
|
|
181
|
-
}), !hideYear && /*#__PURE__*/
|
|
171
|
+
}), !hideYear && /*#__PURE__*/React.createElement(SelectInput, {
|
|
182
172
|
id: "".concat(fieldName, "year"),
|
|
183
173
|
fieldName: "".concat(fieldName, "year"),
|
|
184
174
|
options: yearOptions(),
|
|
@@ -201,5 +191,4 @@ DateSelect.defaultProps = {
|
|
|
201
191
|
monthPlaceholder: 'Maand',
|
|
202
192
|
yearPlaceholder: 'Jaar'
|
|
203
193
|
};
|
|
204
|
-
|
|
205
|
-
exports.default = _default;
|
|
194
|
+
export default DateSelect;
|