@inseefr/lunatic 2.4.8-beta → 2.4.8-fixDatePicker
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/lib/components/index.js +0 -7
- package/lib/src/components/index.d.ts +0 -1
- package/lib/src/components/type.d.ts +0 -7
- package/package.json +2 -2
- package/lib/components/duration/duration.js +0 -117
- package/lib/components/duration/duration.scss +0 -16
- package/lib/components/duration/duration.spec.js +0 -49
- package/lib/components/duration/index.js +0 -13
- package/lib/components/duration/useDurationValues.js +0 -124
- package/lib/src/components/duration/duration.d.ts +0 -4
- package/lib/src/components/duration/duration.spec.d.ts +0 -1
- package/lib/src/components/duration/index.d.ts +0 -1
- package/lib/src/components/duration/useDurationValues.d.ts +0 -43
- package/lib/stories/duration/duration.stories.js +0 -41
- package/lib/stories/duration/source.json +0 -32
- package/lib/stories/duration/source1.json +0 -32
package/lib/components/index.js
CHANGED
|
@@ -51,12 +51,6 @@ Object.defineProperty(exports, "Dropdown", {
|
|
|
51
51
|
return _dropdown["default"];
|
|
52
52
|
}
|
|
53
53
|
});
|
|
54
|
-
Object.defineProperty(exports, "Duration", {
|
|
55
|
-
enumerable: true,
|
|
56
|
-
get: function get() {
|
|
57
|
-
return _duration["default"];
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
54
|
Object.defineProperty(exports, "FilterDescription", {
|
|
61
55
|
enumerable: true,
|
|
62
56
|
get: function get() {
|
|
@@ -188,7 +182,6 @@ var _suggesterLoaderWidget = _interopRequireDefault(require("./suggester-loader-
|
|
|
188
182
|
var _roundabout = _interopRequireDefault(require("./roundabout"));
|
|
189
183
|
var _table = _interopRequireDefault(require("./table"));
|
|
190
184
|
var _componentSet = _interopRequireDefault(require("./component-set"));
|
|
191
|
-
var _duration = _interopRequireDefault(require("./duration"));
|
|
192
185
|
var _questionInformation = _interopRequireDefault(require("./questions/question-information"));
|
|
193
186
|
var _questionContext = _interopRequireDefault(require("./questions/question-context"));
|
|
194
187
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
@@ -22,6 +22,5 @@ export { default as SuggesterLoaderWidget } from './suggester-loader-widget';
|
|
|
22
22
|
export { default as Roundabout } from './roundabout';
|
|
23
23
|
export { default as Table } from './table';
|
|
24
24
|
export { default as ComponentSet } from './component-set';
|
|
25
|
-
export { default as Duration } from "./duration";
|
|
26
25
|
export { default as QuestionInformation } from './questions/question-information';
|
|
27
26
|
export { default as QuestionContext } from './questions/question-context';
|
|
@@ -2,7 +2,6 @@ import { LunaticComponentDefinition, LunaticError, LunaticExpression, LunaticSta
|
|
|
2
2
|
import { CSSProperties, FunctionComponent, ReactNode } from 'react';
|
|
3
3
|
import { SuggesterStatus } from '../use-lunatic/use-suggesters';
|
|
4
4
|
import useLunatic from '../use-lunatic';
|
|
5
|
-
type Formats = 'PTnHnM' | 'PnYnM';
|
|
6
5
|
export type LunaticBaseProps<ValueType = unknown> = {
|
|
7
6
|
id: string;
|
|
8
7
|
handleChange: (response: {
|
|
@@ -61,12 +60,6 @@ type ComponentPropsByType = {
|
|
|
61
60
|
name: string;
|
|
62
61
|
};
|
|
63
62
|
};
|
|
64
|
-
Duration: LunaticBaseProps<string | null> & {
|
|
65
|
-
format: Formats;
|
|
66
|
-
response: {
|
|
67
|
-
name: string;
|
|
68
|
-
};
|
|
69
|
-
};
|
|
70
63
|
Input: LunaticBaseProps<string> & {
|
|
71
64
|
maxLength?: number;
|
|
72
65
|
value: null | string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inseefr/lunatic",
|
|
3
|
-
"version": "2.4.8-
|
|
3
|
+
"version": "2.4.8-fixDatePicker",
|
|
4
4
|
"workersVersion": "0.2.5-experimental",
|
|
5
5
|
"description": "Library of questionnaire components",
|
|
6
6
|
"repository": {
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"library"
|
|
53
53
|
],
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@inseefr/trevas": "^0.1.
|
|
55
|
+
"@inseefr/trevas": "^0.1.17",
|
|
56
56
|
"@inseefr/vtl-2.0-antlr-tools": "^0.1.0-bundle",
|
|
57
57
|
"antlr4": "4.11.0",
|
|
58
58
|
"classnames": "^2.3.1",
|
|
@@ -1,117 +0,0 @@
|
|
|
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
|
-
require("./duration.scss");
|
|
9
|
-
var _useDurationValues2 = require("./useDurationValues");
|
|
10
|
-
var _commons = require("../commons");
|
|
11
|
-
var _lunaticComponentWithoutLabel = _interopRequireDefault(require("../commons/components/lunatic-component-without-label"));
|
|
12
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
14
|
-
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); }
|
|
15
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
16
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
17
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
18
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
19
|
-
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
20
|
-
function Duration(props) {
|
|
21
|
-
var value = props.value,
|
|
22
|
-
label = props.label,
|
|
23
|
-
format = props.format,
|
|
24
|
-
handleChange = props.handleChange,
|
|
25
|
-
response = props.response,
|
|
26
|
-
id = props.id,
|
|
27
|
-
preferences = props.preferences,
|
|
28
|
-
declarations = props.declarations,
|
|
29
|
-
missing = props.missing,
|
|
30
|
-
missingResponse = props.missingResponse,
|
|
31
|
-
management = props.management,
|
|
32
|
-
description = props.description;
|
|
33
|
-
var onChange = (0, _commons.useOnHandleChange)({
|
|
34
|
-
handleChange: handleChange,
|
|
35
|
-
response: response,
|
|
36
|
-
value: value
|
|
37
|
-
});
|
|
38
|
-
var _useDurationValues = (0, _useDurationValues2.useDurationValues)(value, format, onChange),
|
|
39
|
-
propsHours = _useDurationValues.propsHours,
|
|
40
|
-
propsMinutes = _useDurationValues.propsMinutes,
|
|
41
|
-
propsYears = _useDurationValues.propsYears,
|
|
42
|
-
propsMonths = _useDurationValues.propsMonths;
|
|
43
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_lunaticComponentWithoutLabel["default"], {
|
|
44
|
-
id: id,
|
|
45
|
-
preferences: preferences,
|
|
46
|
-
declarations: declarations,
|
|
47
|
-
value: value,
|
|
48
|
-
missing: missing,
|
|
49
|
-
missingResponse: missingResponse,
|
|
50
|
-
management: management,
|
|
51
|
-
description: description,
|
|
52
|
-
handleChange: handleChange,
|
|
53
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
54
|
-
className: "container",
|
|
55
|
-
children: [label, /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {}), format === 'PTnHnM' && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
56
|
-
className: "field-group",
|
|
57
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
58
|
-
className: "input-field-group",
|
|
59
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("label", {
|
|
60
|
-
htmlFor: "hoursInput",
|
|
61
|
-
className: "input-label",
|
|
62
|
-
children: "Heures:"
|
|
63
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("input", _objectSpread(_objectSpread({
|
|
64
|
-
id: "hoursInput",
|
|
65
|
-
type: "number"
|
|
66
|
-
}, propsHours), {}, {
|
|
67
|
-
className: "input-field"
|
|
68
|
-
}))]
|
|
69
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
70
|
-
className: "input-field-group",
|
|
71
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("label", {
|
|
72
|
-
htmlFor: "minutesInput",
|
|
73
|
-
className: "input-label",
|
|
74
|
-
children: "Minutes:"
|
|
75
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("input", _objectSpread(_objectSpread({
|
|
76
|
-
id: "minutesInput",
|
|
77
|
-
type: "number"
|
|
78
|
-
}, propsMinutes), {}, {
|
|
79
|
-
min: "0",
|
|
80
|
-
className: "input-field"
|
|
81
|
-
}))]
|
|
82
|
-
})]
|
|
83
|
-
}), format === 'PnYnM' && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
84
|
-
className: "field-group",
|
|
85
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
86
|
-
className: "input-field-group",
|
|
87
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("label", {
|
|
88
|
-
htmlFor: "yearsInput",
|
|
89
|
-
className: "input-label",
|
|
90
|
-
children: "Ann\xE9es:"
|
|
91
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("input", _objectSpread(_objectSpread({
|
|
92
|
-
id: "yearsInput",
|
|
93
|
-
type: "number"
|
|
94
|
-
}, propsYears), {}, {
|
|
95
|
-
min: "0",
|
|
96
|
-
className: "input-field"
|
|
97
|
-
}))]
|
|
98
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
99
|
-
className: "input-field-group",
|
|
100
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("label", {
|
|
101
|
-
htmlFor: "monthsInput",
|
|
102
|
-
className: "input-label",
|
|
103
|
-
children: "Mois:"
|
|
104
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("input", _objectSpread(_objectSpread({
|
|
105
|
-
id: "monthsInput",
|
|
106
|
-
type: "number"
|
|
107
|
-
}, propsMonths), {}, {
|
|
108
|
-
min: "0",
|
|
109
|
-
className: "input-field"
|
|
110
|
-
}))]
|
|
111
|
-
})]
|
|
112
|
-
})]
|
|
113
|
-
})
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
var _default = Duration;
|
|
117
|
-
exports["default"] = _default;
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _react = _interopRequireDefault(require("react"));
|
|
4
|
-
var _react2 = require("@testing-library/react");
|
|
5
|
-
var _vitest = require("vitest");
|
|
6
|
-
var _duration = _interopRequireDefault(require("./duration"));
|
|
7
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
8
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
9
|
-
(0, _vitest.describe)('Duration component', function () {
|
|
10
|
-
var handleChange = _vitest.vi.fn();
|
|
11
|
-
(0, _vitest.it)('should render with hours and minutes inputs when format is "PTnHnM"', function () {
|
|
12
|
-
var _render = (0, _react2.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_duration["default"], {
|
|
13
|
-
format: "PTnHnM",
|
|
14
|
-
handleChange: handleChange,
|
|
15
|
-
id: '',
|
|
16
|
-
value: null,
|
|
17
|
-
executeExpression: function executeExpression(expression, args) {
|
|
18
|
-
throw new Error('Function not implemented.');
|
|
19
|
-
},
|
|
20
|
-
response: {
|
|
21
|
-
name: ''
|
|
22
|
-
}
|
|
23
|
-
})),
|
|
24
|
-
getByLabelText = _render.getByLabelText;
|
|
25
|
-
var hoursInput = getByLabelText('Heures:');
|
|
26
|
-
var minutesInput = getByLabelText('Minutes:');
|
|
27
|
-
(0, _vitest.expect)(hoursInput).toBeInTheDocument();
|
|
28
|
-
(0, _vitest.expect)(minutesInput).toBeInTheDocument();
|
|
29
|
-
});
|
|
30
|
-
(0, _vitest.it)('should render with years and months inputs when format is "PnYnM"', function () {
|
|
31
|
-
var _render2 = (0, _react2.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_duration["default"], {
|
|
32
|
-
format: "PnYnM",
|
|
33
|
-
handleChange: handleChange,
|
|
34
|
-
id: '',
|
|
35
|
-
value: null,
|
|
36
|
-
executeExpression: function executeExpression(expression, args) {
|
|
37
|
-
throw new Error('Function not implemented.');
|
|
38
|
-
},
|
|
39
|
-
response: {
|
|
40
|
-
name: ''
|
|
41
|
-
}
|
|
42
|
-
})),
|
|
43
|
-
getByLabelText = _render2.getByLabelText;
|
|
44
|
-
var yearsInput = getByLabelText('Années:');
|
|
45
|
-
var monthsInput = getByLabelText('Mois:');
|
|
46
|
-
(0, _vitest.expect)(yearsInput).toBeInTheDocument();
|
|
47
|
-
(0, _vitest.expect)(monthsInput).toBeInTheDocument();
|
|
48
|
-
});
|
|
49
|
-
});
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "default", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function get() {
|
|
9
|
-
return _duration["default"];
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
var _duration = _interopRequireDefault(require("./duration"));
|
|
13
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.useDurationValues = void 0;
|
|
7
|
-
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); }
|
|
8
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
9
|
-
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."); }
|
|
10
|
-
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); }
|
|
11
|
-
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; }
|
|
12
|
-
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; } }
|
|
13
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
14
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
15
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
16
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
17
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
18
|
-
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
19
|
-
var useDurationValues = function useDurationValues(value, format, handleChange) {
|
|
20
|
-
var duration = parseISO8601Duration(value);
|
|
21
|
-
// Gestionnaire de changement pour les champs individuels (heures, minutes, mois, années)
|
|
22
|
-
var onChangeHandler = function onChangeHandler(key) {
|
|
23
|
-
return function (e) {
|
|
24
|
-
// Mise à jour de la valeur de la durée avec la clé dynamique
|
|
25
|
-
handleChange(formatISO8601Duration(format, _objectSpread(_objectSpread({}, duration), {}, _defineProperty({}, key, e.target.value))));
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
var propsHours = {
|
|
29
|
-
value: duration.hours,
|
|
30
|
-
onChange: onChangeHandler("hours"),
|
|
31
|
-
min: "0",
|
|
32
|
-
max: "23"
|
|
33
|
-
};
|
|
34
|
-
var propsMinutes = {
|
|
35
|
-
value: duration.minutes,
|
|
36
|
-
onChange: onChangeHandler("minutes"),
|
|
37
|
-
min: "0",
|
|
38
|
-
max: "59"
|
|
39
|
-
};
|
|
40
|
-
var propsMonths = {
|
|
41
|
-
value: duration.months,
|
|
42
|
-
onChange: onChangeHandler("months"),
|
|
43
|
-
min: "0",
|
|
44
|
-
max: "11"
|
|
45
|
-
};
|
|
46
|
-
var propsYears = {
|
|
47
|
-
value: duration.years,
|
|
48
|
-
onChange: onChangeHandler("years"),
|
|
49
|
-
min: "0"
|
|
50
|
-
};
|
|
51
|
-
// Retourne les propriétés pour chaque champ de durée
|
|
52
|
-
return {
|
|
53
|
-
propsHours: propsHours,
|
|
54
|
-
propsMonths: propsMonths,
|
|
55
|
-
propsYears: propsYears,
|
|
56
|
-
propsMinutes: propsMinutes
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
|
-
exports.useDurationValues = useDurationValues;
|
|
60
|
-
// Fonction pour parser une durée au format ISO8601 en objets individuels
|
|
61
|
-
var parseISO8601Duration = function parseISO8601Duration(duration) {
|
|
62
|
-
// Si la durée est vide, retourne des valeurs vides pour chaque champ
|
|
63
|
-
if (!duration) {
|
|
64
|
-
return {
|
|
65
|
-
hours: '',
|
|
66
|
-
minutes: '',
|
|
67
|
-
years: '',
|
|
68
|
-
months: ''
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
// Expression régulière pour le format heures:minutes (PTnHnM)
|
|
72
|
-
var regexHourMinute = /PT(\d+H)?(\d+M)?/i;
|
|
73
|
-
var matchHourMinute = duration.match(regexHourMinute);
|
|
74
|
-
// Si la durée correspond au format heures:minutes (PTnHnM)
|
|
75
|
-
if (matchHourMinute) {
|
|
76
|
-
var _matchHourMinute = _slicedToArray(matchHourMinute, 3),
|
|
77
|
-
hours = _matchHourMinute[1],
|
|
78
|
-
minutes = _matchHourMinute[2];
|
|
79
|
-
return {
|
|
80
|
-
hours: hours ? hours.replace('H', '') : '',
|
|
81
|
-
minutes: minutes ? minutes.replace('M', '') : '',
|
|
82
|
-
years: '',
|
|
83
|
-
months: ''
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
// Expression régulière pour le format années:mois (PnYnM)
|
|
87
|
-
var regexYearMonth = /P(\d+Y)?(\d+M)?/i;
|
|
88
|
-
var matchYearMonth = duration.match(regexYearMonth);
|
|
89
|
-
// Si la durée correspond au format années:mois (PnYnM)
|
|
90
|
-
if (matchYearMonth) {
|
|
91
|
-
var _matchYearMonth = _slicedToArray(matchYearMonth, 3),
|
|
92
|
-
years = _matchYearMonth[1],
|
|
93
|
-
months = _matchYearMonth[2];
|
|
94
|
-
return {
|
|
95
|
-
years: years ? years.replace('Y', '') : '',
|
|
96
|
-
months: months ? months.replace('M', '') : '',
|
|
97
|
-
hours: '',
|
|
98
|
-
minutes: ''
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
// Si la durée ne correspond à aucun des formats connus, retourne des valeurs vides pour chaque champ
|
|
102
|
-
return {
|
|
103
|
-
hours: '',
|
|
104
|
-
minutes: '',
|
|
105
|
-
years: '',
|
|
106
|
-
months: ''
|
|
107
|
-
};
|
|
108
|
-
};
|
|
109
|
-
// Fonction pour formatter les objets individuels en durée au format souhaité
|
|
110
|
-
var formatISO8601Duration = function formatISO8601Duration(format, duration) {
|
|
111
|
-
// Si tous les champs de durée sont vides, retourne null
|
|
112
|
-
if (!duration.hours && !duration.minutes && !duration.years && !duration.months) {
|
|
113
|
-
return null;
|
|
114
|
-
}
|
|
115
|
-
// Formatage de la durée en fonction du format spécifié
|
|
116
|
-
if (format === 'PTnHnM') {
|
|
117
|
-
return "PT".concat(duration.hours ? "".concat(duration.hours, "H") : '0H').concat(duration.minutes ? "".concat(duration.minutes, "M") : '0M');
|
|
118
|
-
}
|
|
119
|
-
if (format === 'PnYnM') {
|
|
120
|
-
return "P".concat(duration.years ? "".concat(duration.years, "Y") : '0Y').concat(duration.months ? "".concat(duration.months, "M") : '0M');
|
|
121
|
-
}
|
|
122
|
-
// Si le format spécifié n'est pas valide, retourne null
|
|
123
|
-
return null;
|
|
124
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "./duration";
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
export declare const useDurationValues: (value: string | null, format: Formats, handleChange: (v: string | null) => void) => {
|
|
2
|
-
propsHours: {
|
|
3
|
-
value: string;
|
|
4
|
-
onChange: (e: {
|
|
5
|
-
target: {
|
|
6
|
-
value: string;
|
|
7
|
-
};
|
|
8
|
-
}) => void;
|
|
9
|
-
min: string;
|
|
10
|
-
max: string;
|
|
11
|
-
};
|
|
12
|
-
propsMonths: {
|
|
13
|
-
value: string;
|
|
14
|
-
onChange: (e: {
|
|
15
|
-
target: {
|
|
16
|
-
value: string;
|
|
17
|
-
};
|
|
18
|
-
}) => void;
|
|
19
|
-
min: string;
|
|
20
|
-
max: string;
|
|
21
|
-
};
|
|
22
|
-
propsYears: {
|
|
23
|
-
value: string;
|
|
24
|
-
onChange: (e: {
|
|
25
|
-
target: {
|
|
26
|
-
value: string;
|
|
27
|
-
};
|
|
28
|
-
}) => void;
|
|
29
|
-
min: string;
|
|
30
|
-
};
|
|
31
|
-
propsMinutes: {
|
|
32
|
-
value: string;
|
|
33
|
-
onChange: (e: {
|
|
34
|
-
target: {
|
|
35
|
-
value: string;
|
|
36
|
-
};
|
|
37
|
-
}) => void;
|
|
38
|
-
min: string;
|
|
39
|
-
max: string;
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
type Formats = "PTnHnM" | "PnYnM";
|
|
43
|
-
export {};
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = exports.PnYnM = exports.PTnHnM = void 0;
|
|
7
|
-
var _react = _interopRequireDefault(require("react"));
|
|
8
|
-
var _defaultArgTypes = _interopRequireDefault(require("../utils/default-arg-types"));
|
|
9
|
-
var _orchestrator = _interopRequireDefault(require("../utils/orchestrator"));
|
|
10
|
-
var _source = _interopRequireDefault(require("./source"));
|
|
11
|
-
var _source2 = _interopRequireDefault(require("./source1"));
|
|
12
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
14
|
-
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); }
|
|
15
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
16
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
17
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
18
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
19
|
-
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
20
|
-
var stories = {
|
|
21
|
-
title: 'Components/Duration',
|
|
22
|
-
component: _orchestrator["default"],
|
|
23
|
-
argTypes: _defaultArgTypes["default"]
|
|
24
|
-
};
|
|
25
|
-
var _default = stories;
|
|
26
|
-
exports["default"] = _default;
|
|
27
|
-
var Template = function Template(args) {
|
|
28
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_orchestrator["default"], _objectSpread({}, args));
|
|
29
|
-
};
|
|
30
|
-
var PnYnM = Template.bind({});
|
|
31
|
-
exports.PnYnM = PnYnM;
|
|
32
|
-
PnYnM.args = {
|
|
33
|
-
id: 'durationAnnéesMois',
|
|
34
|
-
source: _source["default"]
|
|
35
|
-
};
|
|
36
|
-
var PTnHnM = Template.bind({});
|
|
37
|
-
exports.PTnHnM = PTnHnM;
|
|
38
|
-
PTnHnM.args = {
|
|
39
|
-
id: 'durationHeureMinute',
|
|
40
|
-
source: _source2["default"]
|
|
41
|
-
};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"components": [
|
|
3
|
-
{
|
|
4
|
-
"id": "kxi788",
|
|
5
|
-
"componentType": "Duration",
|
|
6
|
-
"mandatory": false,
|
|
7
|
-
"format": "PnYnM",
|
|
8
|
-
"page": "1",
|
|
9
|
-
"maxPage": "1",
|
|
10
|
-
"label": {
|
|
11
|
-
"value": "\"➡ 1. \" || \"Duration \"",
|
|
12
|
-
"type": "VTL|MD"
|
|
13
|
-
},
|
|
14
|
-
"description": { "value": "\"Description\"", "type": "VTL|MD" },
|
|
15
|
-
"conditionFilter": { "value": "true", "type": "VTL" },
|
|
16
|
-
"response": { "name": "DUREE" }
|
|
17
|
-
}
|
|
18
|
-
],
|
|
19
|
-
"variables": [
|
|
20
|
-
{
|
|
21
|
-
"variableType": "COLLECTED",
|
|
22
|
-
"name": "DUREE",
|
|
23
|
-
"values": {
|
|
24
|
-
"PREVIOUS": null,
|
|
25
|
-
"COLLECTED": null,
|
|
26
|
-
"FORCED": null,
|
|
27
|
-
"EDITED": null,
|
|
28
|
-
"INPUTED": null
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
]
|
|
32
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"components": [
|
|
3
|
-
{
|
|
4
|
-
"id": "kxi788",
|
|
5
|
-
"componentType": "Duration",
|
|
6
|
-
"mandatory": false,
|
|
7
|
-
"format": "PTnHnM",
|
|
8
|
-
"page": "1",
|
|
9
|
-
"maxPage": "1",
|
|
10
|
-
"label": {
|
|
11
|
-
"value": "\"➡ 1. \" || \"Duration \"",
|
|
12
|
-
"type": "VTL|MD"
|
|
13
|
-
},
|
|
14
|
-
"description": { "value": "\"Description\"", "type": "VTL|MD" },
|
|
15
|
-
"conditionFilter": { "value": "true", "type": "VTL" },
|
|
16
|
-
"response": { "name": "DUREE" }
|
|
17
|
-
}
|
|
18
|
-
],
|
|
19
|
-
"variables": [
|
|
20
|
-
{
|
|
21
|
-
"variableType": "COLLECTED",
|
|
22
|
-
"name": "DUREE",
|
|
23
|
-
"values": {
|
|
24
|
-
"PREVIOUS": null,
|
|
25
|
-
"COLLECTED": "PT12H50M",
|
|
26
|
-
"FORCED": null,
|
|
27
|
-
"EDITED": null,
|
|
28
|
-
"INPUTED": null
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
]
|
|
32
|
-
}
|