@inseefr/lunatic 2.4.8-dynamicArray → 2.4.9-beta
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 +7 -7
- package/lib/components/loop/loop.js +2 -2
- package/lib/components/loop/roster-for-loop/body.js +52 -0
- package/lib/components/loop/roster-for-loop/header.js +34 -0
- package/lib/components/loop/roster-for-loop/roster-for-loop.js +32 -35
- package/lib/components/loop/roster-for-loop/roster-table.js +16 -17
- package/lib/components/loop/roster-for-loop/roster.scss +34 -32
- package/lib/components/loop/roster-for-loop/row.js +19 -48
- package/lib/components/subsequence/subsequence.js +0 -2
- package/lib/components/summary/html/summary-container.js +14 -0
- package/lib/components/summary/html/summary-responses.js +53 -0
- package/lib/components/summary/html/summary-title.js +20 -0
- package/lib/components/summary/index.js +12 -0
- package/lib/components/summary/lunatic-summary.js +99 -0
- package/lib/src/components/index.d.ts +1 -1
- package/lib/src/components/loop/block-for-loop/block-for-loop-ochestrator.d.ts +1 -1
- package/lib/src/components/loop/block-for-loop/block-for-loop.d.ts +1 -1
- package/lib/src/components/loop/roster-for-loop/body.d.ts +12 -0
- package/lib/src/components/loop/roster-for-loop/header.d.ts +9 -0
- package/lib/src/components/loop/roster-for-loop/roster-for-loop-orchestrator.d.ts +1 -1
- package/lib/src/components/loop/roster-for-loop/roster-for-loop.d.ts +4 -4
- package/lib/src/components/loop/roster-for-loop/roster-table.d.ts +2 -2
- package/lib/src/components/subsequence/subsequence.d.ts +2 -2
- package/lib/src/components/summary/html/summary-container.d.ts +2 -0
- package/lib/src/components/summary/html/summary-responses.d.ts +12 -0
- package/lib/src/components/summary/html/summary-title.d.ts +5 -0
- package/lib/src/components/summary/index.d.ts +1 -0
- package/lib/src/components/summary/lunatic-summary.d.ts +7 -0
- package/lib/src/components/type.d.ts +16 -9
- package/lib/stories/loop/block-for-loop.stories.js +8 -1
- package/lib/stories/loop/roster-for-loop.stories.js +1 -8
- package/lib/stories/loop/source-with-header.json +4 -16
- package/lib/stories/questionnaires/simpsons/simpsons.stories.js +1 -1
- package/lib/stories/summary/data.json +32 -0
- package/lib/stories/summary/source.json +353 -0
- package/lib/stories/{duration/duration.stories.js → summary/summary.stories.js} +11 -15
- package/lib/use-lunatic/commons/fill-components/fill-component-expressions.js +1 -1
- package/package.json +1 -1
- 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/hooks/use-did-change.js +0 -19
- 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/src/hooks/use-did-change.d.ts +0 -4
- package/lib/stories/duration/source.json +0 -32
- package/lib/stories/duration/source1.json +0 -32
|
@@ -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,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.useDidChange = useDidChange;
|
|
7
|
-
var _react = require("react");
|
|
8
|
-
/**
|
|
9
|
-
* Hook for debug purpose that log the data that changed between 2 renders
|
|
10
|
-
*/
|
|
11
|
-
function useDidChange(obj, suffix) {
|
|
12
|
-
var ref = (0, _react.useRef)(obj);
|
|
13
|
-
for (var key in obj) {
|
|
14
|
-
if (obj[key] !== ref.current[key]) {
|
|
15
|
-
console.log("\"".concat(key, "\" has changed ").concat(suffix !== null && suffix !== void 0 ? suffix : ''), obj[key]);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
ref.current = obj;
|
|
19
|
-
}
|
|
@@ -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,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
|
-
}
|