@inseefr/lunatic 2.4.6-withoutColor → 2.4.7-datePicker
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.
|
@@ -14,6 +14,12 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
15
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
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
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
18
|
+
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
|
+
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
|
+
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
|
+
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
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
17
23
|
function Datepicker(_ref) {
|
|
18
24
|
var disabled = _ref.disabled,
|
|
19
25
|
readOnly = _ref.readOnly,
|
|
@@ -27,10 +33,21 @@ function Datepicker(_ref) {
|
|
|
27
33
|
errors = _ref.errors,
|
|
28
34
|
description = _ref.description;
|
|
29
35
|
var labelId = "lunatic-datepicker-".concat(id);
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
36
|
+
|
|
37
|
+
// store the date value in the local date state
|
|
38
|
+
var _useState = (0, _react.useState)(value || ''),
|
|
39
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
40
|
+
date = _useState2[0],
|
|
41
|
+
setDate = _useState2[1];
|
|
42
|
+
|
|
43
|
+
// custom event handler to update date value
|
|
44
|
+
var handleDateChange = function handleDateChange(event) {
|
|
45
|
+
var inputValue = event.target.value;
|
|
46
|
+
setDate(inputValue);
|
|
47
|
+
if (onChange) {
|
|
48
|
+
onChange(inputValue);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
34
51
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_datepickerContainer["default"], {
|
|
35
52
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_commons.Label, {
|
|
36
53
|
htmlFor: id,
|
|
@@ -42,8 +59,8 @@ function Datepicker(_ref) {
|
|
|
42
59
|
labelId: labelId,
|
|
43
60
|
readOnly: readOnly,
|
|
44
61
|
disabled: disabled,
|
|
45
|
-
value:
|
|
46
|
-
onChange:
|
|
62
|
+
value: date,
|
|
63
|
+
onChange: handleDateChange,
|
|
47
64
|
min: min,
|
|
48
65
|
max: max
|
|
49
66
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_commons.Errors, {
|
|
@@ -29,9 +29,10 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
|
|
|
29
29
|
label: 'Test Sequence Label',
|
|
30
30
|
style: {
|
|
31
31
|
backgroundColor: 'red'
|
|
32
|
-
}
|
|
33
|
-
questionInformation: 'question-information'
|
|
32
|
+
}
|
|
33
|
+
// questionInformation: 'question-information',
|
|
34
34
|
};
|
|
35
|
+
|
|
35
36
|
(0, _vitest.it)('renders the label and declarations in the correct order', function () {
|
|
36
37
|
var _render = (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_lunaticSequence["default"], _objectSpread({}, mockProps))),
|
|
37
38
|
getByText = _render.getByText,
|
|
@@ -39,9 +40,10 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
|
|
|
39
40
|
var sequenceLabel = getByText('Test Sequence Label');
|
|
40
41
|
var declaration1 = getByText('Declaration 1');
|
|
41
42
|
var declaration3 = getByText('Declaration 3');
|
|
42
|
-
|
|
43
|
+
// const questionInformation = getByText('question-information');
|
|
44
|
+
|
|
43
45
|
(0, _vitest.expect)(sequenceLabel).toBeInTheDocument();
|
|
44
|
-
|
|
46
|
+
// expect(questionInformation).toBeInTheDocument();
|
|
45
47
|
// Declarations before text should appear before the label
|
|
46
48
|
(0, _vitest.expect)(declaration1).toBeInTheDocument();
|
|
47
49
|
// expect(sequenceLabel?.previousSibling?.childNodes[0]).toBe(declaration1);
|