@inseefr/lunatic 2.5.2-beta → 2.5.2-rc1-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/component-set/html/component-set-components.js +5 -23
- package/lib/components/loop/block-for-loop/row.js +6 -16
- package/lib/src/components/component-set/html/component-set-components.d.ts +1 -1
- package/lib/src/utils/get-component-value.d.ts +5 -0
- package/lib/stories/checkboxGroup/checkboxGroup.stories.js +17 -1
- package/lib/stories/checkboxGroup/sourceComponentset.json +424 -0
- package/lib/stories/checkboxGroup/sourceLoop.json +83 -0
- package/lib/utils/get-component-value.js +38 -0
- package/package.json +1 -1
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports["default"] = void 0;
|
|
8
8
|
var _commons = require("../../commons");
|
|
9
9
|
var _componentSetComponentContainer = _interopRequireDefault(require("./component-set-component-container"));
|
|
10
|
+
var _getComponentValue = require("../../../utils/get-component-value");
|
|
10
11
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
12
|
var _excluded = ["components", "componentClassName", "className", "value"];
|
|
12
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
@@ -17,45 +18,26 @@ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _ty
|
|
|
17
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); }
|
|
18
19
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
19
20
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
20
|
-
/**
|
|
21
|
-
* Extract the value associated with a component
|
|
22
|
-
*/
|
|
23
|
-
function getComponentValue(component, value) {
|
|
24
|
-
if (hasResponse(component) && component.response.name in value) {
|
|
25
|
-
var _value$component$resp;
|
|
26
|
-
return (_value$component$resp = value[component.response.name]) !== null && _value$component$resp !== void 0 ? _value$component$resp : '';
|
|
27
|
-
}
|
|
28
|
-
return undefined;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Narrow the type of the component
|
|
33
|
-
*/
|
|
34
|
-
function hasResponse(component) {
|
|
35
|
-
return 'response' in component;
|
|
36
|
-
}
|
|
37
21
|
function ComponentSetComponents(_ref) {
|
|
38
22
|
var components = _ref.components,
|
|
39
23
|
componentClassName = _ref.componentClassName,
|
|
40
24
|
className = _ref.className,
|
|
41
|
-
|
|
25
|
+
valueMap = _ref.value,
|
|
42
26
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
43
27
|
if (!Array.isArray(components)) {
|
|
44
28
|
return null;
|
|
45
29
|
}
|
|
46
30
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
47
31
|
children: components.map(function (component) {
|
|
48
|
-
var id = component.id;
|
|
49
|
-
var componentValue = getComponentValue(component, value);
|
|
50
32
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentSetComponentContainer["default"], {
|
|
51
33
|
className: className,
|
|
52
34
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_commons.OrchestratedComponent, _objectSpread(_objectSpread({}, props), {}, {
|
|
53
35
|
component: component,
|
|
54
|
-
id: id,
|
|
36
|
+
id: component.id,
|
|
55
37
|
className: componentClassName,
|
|
56
|
-
value:
|
|
38
|
+
value: (0, _getComponentValue.getComponentValue)(component, valueMap)
|
|
57
39
|
}))
|
|
58
|
-
}, id);
|
|
40
|
+
}, component.id);
|
|
59
41
|
})
|
|
60
42
|
});
|
|
61
43
|
}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
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); }
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports["default"] = void 0;
|
|
7
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
9
|
var _commons = require("../../commons");
|
|
10
|
+
var _getComponentValue = require("../../../utils/get-component-value");
|
|
9
11
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
10
12
|
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); }
|
|
11
13
|
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; }
|
|
12
|
-
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); }
|
|
13
14
|
function Row(_ref) {
|
|
14
15
|
var components = _ref.components,
|
|
15
16
|
_ref$valueMap = _ref.valueMap,
|
|
@@ -31,16 +32,8 @@ function Row(_ref) {
|
|
|
31
32
|
}, [handleChange, rowIndex]);
|
|
32
33
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
33
34
|
children: components.map(function (component) {
|
|
34
|
-
var id = component.id;
|
|
35
|
-
var
|
|
36
|
-
var value = undefined;
|
|
37
|
-
if (hasResponse(component)) {
|
|
38
|
-
var name = component.response.name;
|
|
39
|
-
var valueArray = valueMap[name];
|
|
40
|
-
if (Array.isArray(valueArray)) {
|
|
41
|
-
value = valueArray[rowIndex] || '';
|
|
42
|
-
}
|
|
43
|
-
}
|
|
35
|
+
var id = "".concat(component.id, "-").concat(rowIndex);
|
|
36
|
+
var value = (0, _getComponentValue.getComponentValue)(component, valueMap, rowIndex);
|
|
44
37
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_commons.OrchestratedComponent, {
|
|
45
38
|
component: component,
|
|
46
39
|
handleChange: handleChangeRow,
|
|
@@ -49,18 +42,15 @@ function Row(_ref) {
|
|
|
49
42
|
shortcut: shortcut,
|
|
50
43
|
management: management,
|
|
51
44
|
value: value,
|
|
52
|
-
id:
|
|
45
|
+
id: id,
|
|
53
46
|
preferences: preferences,
|
|
54
47
|
iteration: rowIndex,
|
|
55
48
|
executeExpression: executeExpression,
|
|
56
49
|
errors: errors,
|
|
57
50
|
disabled: disabled
|
|
58
|
-
},
|
|
51
|
+
}, id);
|
|
59
52
|
})
|
|
60
53
|
});
|
|
61
54
|
}
|
|
62
|
-
function hasResponse(component) {
|
|
63
|
-
return !!component && _typeof(component) === 'object' && 'response' in component;
|
|
64
|
-
}
|
|
65
55
|
var _default = Row;
|
|
66
56
|
exports["default"] = _default;
|
|
@@ -3,5 +3,5 @@ type Props = {
|
|
|
3
3
|
className?: string;
|
|
4
4
|
componentClassName?: string;
|
|
5
5
|
} & Omit<LunaticComponentProps<'ComponentSet'>, 'id' | 'response'>;
|
|
6
|
-
declare function ComponentSetComponents({ components, componentClassName, className, value, ...props }: Props): import("react/jsx-runtime").JSX.Element | null;
|
|
6
|
+
declare function ComponentSetComponents({ components, componentClassName, className, value: valueMap, ...props }: Props): import("react/jsx-runtime").JSX.Element | null;
|
|
7
7
|
export default ComponentSetComponents;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extract the value associated with a component
|
|
3
|
+
* If the component expect multiple values (it has a responses property) then extract a map of values
|
|
4
|
+
*/
|
|
5
|
+
export declare function getComponentValue<T = unknown>(component: unknown, valueMap: Record<string, unknown>, rowIndex?: number): T;
|
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports["default"] = exports.Default = void 0;
|
|
6
|
+
exports["default"] = exports.Loop = exports.Default = exports.ComponentSet = void 0;
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
8
|
var _orchestrator = _interopRequireDefault(require("../utils/orchestrator"));
|
|
9
9
|
var _source = _interopRequireDefault(require("./source"));
|
|
10
|
+
var _sourceComponentset = _interopRequireDefault(require("./sourceComponentset"));
|
|
11
|
+
var _sourceLoop = _interopRequireDefault(require("./sourceLoop"));
|
|
10
12
|
var _defaultArgTypes = _interopRequireDefault(require("../utils/default-arg-types"));
|
|
11
13
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
@@ -40,4 +42,18 @@ Default.args = {
|
|
|
40
42
|
id: 'checkboxGroup',
|
|
41
43
|
source: _source["default"],
|
|
42
44
|
shortcut: true
|
|
45
|
+
};
|
|
46
|
+
var ComponentSet = Template.bind({});
|
|
47
|
+
exports.ComponentSet = ComponentSet;
|
|
48
|
+
ComponentSet.args = {
|
|
49
|
+
id: 'checkboxGroup',
|
|
50
|
+
source: _sourceComponentset["default"],
|
|
51
|
+
shortcut: true
|
|
52
|
+
};
|
|
53
|
+
var Loop = Template.bind({});
|
|
54
|
+
exports.Loop = Loop;
|
|
55
|
+
Loop.args = {
|
|
56
|
+
id: 'checkboxGroup',
|
|
57
|
+
source: _sourceLoop["default"],
|
|
58
|
+
shortcut: true
|
|
43
59
|
};
|
|
@@ -0,0 +1,424 @@
|
|
|
1
|
+
{
|
|
2
|
+
"maxPage": "5",
|
|
3
|
+
"components": [
|
|
4
|
+
{
|
|
5
|
+
"id": "component-set",
|
|
6
|
+
"componentType": "ComponentSet",
|
|
7
|
+
"page": "1",
|
|
8
|
+
"conditionFilter": { "value": "true", "type": "VTL" },
|
|
9
|
+
"label": {
|
|
10
|
+
"value": "\"## Who are you?\"",
|
|
11
|
+
"type": "VTL|MD"
|
|
12
|
+
},
|
|
13
|
+
"description": {
|
|
14
|
+
"value": "\"This is your opportunity to tell me about yourself!\"",
|
|
15
|
+
"type": "VTL|MD"
|
|
16
|
+
},
|
|
17
|
+
"components": [
|
|
18
|
+
{
|
|
19
|
+
"id": "checkboxbooleanGroupNumeric",
|
|
20
|
+
"componentType": "CheckboxGroup",
|
|
21
|
+
"label": {
|
|
22
|
+
"value": "Situation matrimoniale",
|
|
23
|
+
"type": "VTL|MD"
|
|
24
|
+
},
|
|
25
|
+
"hierarchy": {
|
|
26
|
+
"sequence": {
|
|
27
|
+
"id": "kmnnjaf1",
|
|
28
|
+
"label": {
|
|
29
|
+
"value": "Situation matrimoniale",
|
|
30
|
+
"type": "VTL|MD"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"subSequence": {
|
|
34
|
+
"id": "kmw3dz2a",
|
|
35
|
+
"page": "2",
|
|
36
|
+
"label": {
|
|
37
|
+
"value": "Mois préférés de l'année",
|
|
38
|
+
"type": "VTL|MD"
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"missingResponse": { "name": "SITUMATRI_MISSING" },
|
|
43
|
+
"responses": [
|
|
44
|
+
{
|
|
45
|
+
"id": "kmort6x9-QOP-kmosa98y",
|
|
46
|
+
"label": {
|
|
47
|
+
"value": "Française de naissance ou par réintégration",
|
|
48
|
+
"type": "VTL"
|
|
49
|
+
},
|
|
50
|
+
"response": { "name": "NATIO1N1" }
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
{
|
|
54
|
+
"id": "kmort6x9-QOP-kmos360k",
|
|
55
|
+
"label": {
|
|
56
|
+
"value": "\"Française par déclaration, naturalisation, option à la majorité\"",
|
|
57
|
+
"type": "VTL"
|
|
58
|
+
},
|
|
59
|
+
"response": { "name": "NATIO1N2" }
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
{
|
|
63
|
+
"id": "kmort6x9-QOP-kmos37e1",
|
|
64
|
+
"label": { "value": "Étrangère", "type": "VTL" },
|
|
65
|
+
"response": { "name": "NATIO1N3" }
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
{
|
|
69
|
+
"id": "kmort6x9-QOP-kmorue9c",
|
|
70
|
+
"label": {
|
|
71
|
+
"value": "Apatride (pas de nationalité)",
|
|
72
|
+
"type": "VTL"
|
|
73
|
+
},
|
|
74
|
+
"response": { "name": "NATIO1N4" }
|
|
75
|
+
}
|
|
76
|
+
]
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"id": "checkboxbooleanGroupAlpha",
|
|
80
|
+
"componentType": "CheckboxGroup",
|
|
81
|
+
"label": {
|
|
82
|
+
"value": "Mois préférés de l'année",
|
|
83
|
+
"type": "VTL|MD"
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
"hierarchy": {
|
|
87
|
+
"sequence": {
|
|
88
|
+
"id": "kmnnjaf1",
|
|
89
|
+
"page": "1",
|
|
90
|
+
"label": {
|
|
91
|
+
"value": "Situation matrimoniale",
|
|
92
|
+
"type": "VTL|MD"
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
"subSequence": {
|
|
96
|
+
"id": "kmw3dz2a",
|
|
97
|
+
"label": {
|
|
98
|
+
"value": "Mois préférés de l'année",
|
|
99
|
+
"type": "VTL|MD"
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
"missingResponse": { "name": "SITUMATRI_MISSING" },
|
|
104
|
+
"bindingDependencies": [
|
|
105
|
+
"MOIS1",
|
|
106
|
+
"MOIS2",
|
|
107
|
+
"MOIS3",
|
|
108
|
+
"MOIS4",
|
|
109
|
+
"MOIS5",
|
|
110
|
+
"MOIS6",
|
|
111
|
+
"MOIS7",
|
|
112
|
+
"MOIS8",
|
|
113
|
+
"MOIS9",
|
|
114
|
+
"MOIS10",
|
|
115
|
+
"MOIS11",
|
|
116
|
+
"MOIS12"
|
|
117
|
+
],
|
|
118
|
+
"responses": [
|
|
119
|
+
{
|
|
120
|
+
"id": "mois1",
|
|
121
|
+
"label": {
|
|
122
|
+
"value": "Janvier",
|
|
123
|
+
"type": "VTL|MD"
|
|
124
|
+
},
|
|
125
|
+
"response": { "name": "MOIS1" }
|
|
126
|
+
},
|
|
127
|
+
|
|
128
|
+
{
|
|
129
|
+
"id": "mois2",
|
|
130
|
+
"label": {
|
|
131
|
+
"value": "Février",
|
|
132
|
+
"type": "VTL|MD"
|
|
133
|
+
},
|
|
134
|
+
"response": { "name": "MOIS2" }
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
"id": "mois3",
|
|
138
|
+
"label": {
|
|
139
|
+
"value": "Mars",
|
|
140
|
+
"type": "VTL|MD"
|
|
141
|
+
},
|
|
142
|
+
"response": { "name": "MOIS3" }
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
"id": "mois4",
|
|
146
|
+
"label": {
|
|
147
|
+
"value": "Avril",
|
|
148
|
+
"type": "VTL|MD"
|
|
149
|
+
},
|
|
150
|
+
"response": { "name": "MOIS4" }
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
"id": "mois5",
|
|
154
|
+
"label": {
|
|
155
|
+
"value": "Mai",
|
|
156
|
+
"type": "VTL|MD"
|
|
157
|
+
},
|
|
158
|
+
"response": { "name": "MOIS5" }
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
"id": "mois6",
|
|
162
|
+
"label": {
|
|
163
|
+
"value": "Juin",
|
|
164
|
+
"type": "VTL|MD"
|
|
165
|
+
},
|
|
166
|
+
"response": { "name": "MOIS6" }
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
"id": "mois7",
|
|
170
|
+
"label": {
|
|
171
|
+
"value": "Juillet",
|
|
172
|
+
"type": "VTL|MD"
|
|
173
|
+
},
|
|
174
|
+
"response": { "name": "MOIS7" }
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
"id": "mois8",
|
|
178
|
+
"label": {
|
|
179
|
+
"value": "Août",
|
|
180
|
+
"type": "VTL|MD"
|
|
181
|
+
},
|
|
182
|
+
"response": { "name": "MOIS8" }
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
"id": "mois9",
|
|
186
|
+
"label": {
|
|
187
|
+
"value": "Septembre",
|
|
188
|
+
"type": "VTL|MD"
|
|
189
|
+
},
|
|
190
|
+
"response": { "name": "MOIS9" }
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
"id": "mois10",
|
|
194
|
+
"label": {
|
|
195
|
+
"value": "Octobre",
|
|
196
|
+
"type": "VTL|MD"
|
|
197
|
+
},
|
|
198
|
+
"response": { "name": "MOIS10" }
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
"id": "mois11",
|
|
202
|
+
"label": {
|
|
203
|
+
"value": "Novembre",
|
|
204
|
+
"type": "VTL|MD"
|
|
205
|
+
},
|
|
206
|
+
"response": { "name": "MOIS11" }
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
"id": "mois12",
|
|
210
|
+
"label": {
|
|
211
|
+
"value": "Décembre",
|
|
212
|
+
"type": "VTL|MD"
|
|
213
|
+
},
|
|
214
|
+
"response": { "name": "MOIS12" }
|
|
215
|
+
}
|
|
216
|
+
]
|
|
217
|
+
}
|
|
218
|
+
]
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
"id": "seq",
|
|
222
|
+
"componentType": "Sequence",
|
|
223
|
+
"label": {
|
|
224
|
+
"value": "\"Merci !\"",
|
|
225
|
+
"type": "VTL|MD"
|
|
226
|
+
},
|
|
227
|
+
"conditionFilter": { "value": "true", "type": "VTL" },
|
|
228
|
+
"page": "2"
|
|
229
|
+
}
|
|
230
|
+
],
|
|
231
|
+
"variables": [
|
|
232
|
+
{
|
|
233
|
+
"variableType": "COLLECTED",
|
|
234
|
+
"name": "NATIO1N1",
|
|
235
|
+
"values": {
|
|
236
|
+
"PREVIOUS": null,
|
|
237
|
+
"COLLECTED": null,
|
|
238
|
+
"FORCED": null,
|
|
239
|
+
"EDITED": null,
|
|
240
|
+
"INPUTED": null
|
|
241
|
+
}
|
|
242
|
+
},
|
|
243
|
+
|
|
244
|
+
{
|
|
245
|
+
"variableType": "COLLECTED",
|
|
246
|
+
"name": "NATIO1N2",
|
|
247
|
+
"values": {
|
|
248
|
+
"PREVIOUS": null,
|
|
249
|
+
"COLLECTED": null,
|
|
250
|
+
"FORCED": null,
|
|
251
|
+
"EDITED": null,
|
|
252
|
+
"INPUTED": null
|
|
253
|
+
}
|
|
254
|
+
},
|
|
255
|
+
|
|
256
|
+
{
|
|
257
|
+
"variableType": "COLLECTED",
|
|
258
|
+
"name": "NATIO1N3",
|
|
259
|
+
"values": {
|
|
260
|
+
"PREVIOUS": null,
|
|
261
|
+
"COLLECTED": null,
|
|
262
|
+
"FORCED": null,
|
|
263
|
+
"EDITED": null,
|
|
264
|
+
"INPUTED": null
|
|
265
|
+
}
|
|
266
|
+
},
|
|
267
|
+
|
|
268
|
+
{
|
|
269
|
+
"variableType": "COLLECTED",
|
|
270
|
+
"name": "NATIO1N4",
|
|
271
|
+
"values": {
|
|
272
|
+
"PREVIOUS": null,
|
|
273
|
+
"COLLECTED": null,
|
|
274
|
+
"FORCED": null,
|
|
275
|
+
"EDITED": null,
|
|
276
|
+
"INPUTED": null
|
|
277
|
+
}
|
|
278
|
+
},
|
|
279
|
+
|
|
280
|
+
{
|
|
281
|
+
"variableType": "COLLECTED",
|
|
282
|
+
"name": "MOIS1",
|
|
283
|
+
"values": {
|
|
284
|
+
"PREVIOUS": null,
|
|
285
|
+
"COLLECTED": null,
|
|
286
|
+
"FORCED": null,
|
|
287
|
+
"EDITED": null,
|
|
288
|
+
"INPUTED": null
|
|
289
|
+
}
|
|
290
|
+
},
|
|
291
|
+
|
|
292
|
+
{
|
|
293
|
+
"variableType": "COLLECTED",
|
|
294
|
+
"name": "MOIS2",
|
|
295
|
+
"values": {
|
|
296
|
+
"PREVIOUS": null,
|
|
297
|
+
"COLLECTED": null,
|
|
298
|
+
"FORCED": null,
|
|
299
|
+
"EDITED": null,
|
|
300
|
+
"INPUTED": null
|
|
301
|
+
}
|
|
302
|
+
},
|
|
303
|
+
|
|
304
|
+
{
|
|
305
|
+
"variableType": "COLLECTED",
|
|
306
|
+
"name": "MOIS3",
|
|
307
|
+
"values": {
|
|
308
|
+
"PREVIOUS": null,
|
|
309
|
+
"COLLECTED": null,
|
|
310
|
+
"FORCED": null,
|
|
311
|
+
"EDITED": null,
|
|
312
|
+
"INPUTED": null
|
|
313
|
+
}
|
|
314
|
+
},
|
|
315
|
+
|
|
316
|
+
{
|
|
317
|
+
"variableType": "COLLECTED",
|
|
318
|
+
"name": "MOIS4",
|
|
319
|
+
"values": {
|
|
320
|
+
"PREVIOUS": null,
|
|
321
|
+
"COLLECTED": null,
|
|
322
|
+
"FORCED": null,
|
|
323
|
+
"EDITED": null,
|
|
324
|
+
"INPUTED": null
|
|
325
|
+
}
|
|
326
|
+
},
|
|
327
|
+
|
|
328
|
+
{
|
|
329
|
+
"variableType": "COLLECTED",
|
|
330
|
+
"name": "MOIS5",
|
|
331
|
+
"values": {
|
|
332
|
+
"PREVIOUS": null,
|
|
333
|
+
"COLLECTED": null,
|
|
334
|
+
"FORCED": null,
|
|
335
|
+
"EDITED": null,
|
|
336
|
+
"INPUTED": null
|
|
337
|
+
}
|
|
338
|
+
},
|
|
339
|
+
|
|
340
|
+
{
|
|
341
|
+
"variableType": "COLLECTED",
|
|
342
|
+
"name": "MOIS6",
|
|
343
|
+
"values": {
|
|
344
|
+
"PREVIOUS": null,
|
|
345
|
+
"COLLECTED": null,
|
|
346
|
+
"FORCED": null,
|
|
347
|
+
"EDITED": null,
|
|
348
|
+
"INPUTED": null
|
|
349
|
+
}
|
|
350
|
+
},
|
|
351
|
+
|
|
352
|
+
{
|
|
353
|
+
"variableType": "COLLECTED",
|
|
354
|
+
"name": "MOIS7",
|
|
355
|
+
"values": {
|
|
356
|
+
"PREVIOUS": null,
|
|
357
|
+
"COLLECTED": null,
|
|
358
|
+
"FORCED": null,
|
|
359
|
+
"EDITED": null,
|
|
360
|
+
"INPUTED": null
|
|
361
|
+
}
|
|
362
|
+
},
|
|
363
|
+
|
|
364
|
+
{
|
|
365
|
+
"variableType": "COLLECTED",
|
|
366
|
+
"name": "MOIS8",
|
|
367
|
+
"values": {
|
|
368
|
+
"PREVIOUS": null,
|
|
369
|
+
"COLLECTED": null,
|
|
370
|
+
"FORCED": null,
|
|
371
|
+
"EDITED": null,
|
|
372
|
+
"INPUTED": null
|
|
373
|
+
}
|
|
374
|
+
},
|
|
375
|
+
|
|
376
|
+
{
|
|
377
|
+
"variableType": "COLLECTED",
|
|
378
|
+
"name": "MOIS9",
|
|
379
|
+
"values": {
|
|
380
|
+
"PREVIOUS": null,
|
|
381
|
+
"COLLECTED": null,
|
|
382
|
+
"FORCED": null,
|
|
383
|
+
"EDITED": null,
|
|
384
|
+
"INPUTED": null
|
|
385
|
+
}
|
|
386
|
+
},
|
|
387
|
+
|
|
388
|
+
{
|
|
389
|
+
"variableType": "COLLECTED",
|
|
390
|
+
"name": "MOIS10",
|
|
391
|
+
"values": {
|
|
392
|
+
"PREVIOUS": null,
|
|
393
|
+
"COLLECTED": null,
|
|
394
|
+
"FORCED": null,
|
|
395
|
+
"EDITED": null,
|
|
396
|
+
"INPUTED": null
|
|
397
|
+
}
|
|
398
|
+
},
|
|
399
|
+
|
|
400
|
+
{
|
|
401
|
+
"variableType": "COLLECTED",
|
|
402
|
+
"name": "MOIS11",
|
|
403
|
+
"values": {
|
|
404
|
+
"PREVIOUS": null,
|
|
405
|
+
"COLLECTED": null,
|
|
406
|
+
"FORCED": null,
|
|
407
|
+
"EDITED": null,
|
|
408
|
+
"INPUTED": null
|
|
409
|
+
}
|
|
410
|
+
},
|
|
411
|
+
|
|
412
|
+
{
|
|
413
|
+
"variableType": "COLLECTED",
|
|
414
|
+
"name": "MOIS12",
|
|
415
|
+
"values": {
|
|
416
|
+
"PREVIOUS": null,
|
|
417
|
+
"COLLECTED": null,
|
|
418
|
+
"FORCED": null,
|
|
419
|
+
"EDITED": null,
|
|
420
|
+
"INPUTED": null
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
]
|
|
424
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
{
|
|
2
|
+
"maxPage": "5",
|
|
3
|
+
"components": [
|
|
4
|
+
{
|
|
5
|
+
"id": "component-set",
|
|
6
|
+
"componentType": "Loop",
|
|
7
|
+
"page": "1",
|
|
8
|
+
"conditionFilter": { "value": "true", "type": "VTL" },
|
|
9
|
+
"iterations": { "value": 2, "type": "VTL" },
|
|
10
|
+
"label": {
|
|
11
|
+
"value": "\"## Who are you?\"",
|
|
12
|
+
"type": "VTL|MD"
|
|
13
|
+
},
|
|
14
|
+
"description": {
|
|
15
|
+
"value": "\"This is your opportunity to tell me about yourself!\"",
|
|
16
|
+
"type": "VTL|MD"
|
|
17
|
+
},
|
|
18
|
+
"components": [
|
|
19
|
+
{
|
|
20
|
+
"id": "checkboxbooleanGroupNumeric",
|
|
21
|
+
"componentType": "CheckboxGroup",
|
|
22
|
+
"label": {
|
|
23
|
+
"value": "Est-ce que vous travaillez à l'Insee ?",
|
|
24
|
+
"type": "VTL|MD"
|
|
25
|
+
},
|
|
26
|
+
"missingResponse": { "name": "SITUMATRI_MISSING" },
|
|
27
|
+
"responses": [
|
|
28
|
+
{
|
|
29
|
+
"id": "kmort6x9-QOP-kmosa98y",
|
|
30
|
+
"label": {
|
|
31
|
+
"value": "non",
|
|
32
|
+
"type": "VTL"
|
|
33
|
+
},
|
|
34
|
+
"response": { "name": "NON" }
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"id": "kmort6x9-QOP-kmos360k",
|
|
38
|
+
"label": {
|
|
39
|
+
"value": "\"oui\"",
|
|
40
|
+
"type": "VTL"
|
|
41
|
+
},
|
|
42
|
+
"response": { "name": "OUI" }
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"id": "seq",
|
|
50
|
+
"componentType": "Sequence",
|
|
51
|
+
"label": {
|
|
52
|
+
"value": "\"Merci !\"",
|
|
53
|
+
"type": "VTL|MD"
|
|
54
|
+
},
|
|
55
|
+
"conditionFilter": { "value": "true", "type": "VTL" },
|
|
56
|
+
"page": "2"
|
|
57
|
+
}
|
|
58
|
+
],
|
|
59
|
+
"variables": [
|
|
60
|
+
{
|
|
61
|
+
"variableType": "COLLECTED",
|
|
62
|
+
"name": "OUI",
|
|
63
|
+
"values": {
|
|
64
|
+
"PREVIOUS": [null],
|
|
65
|
+
"COLLECTED": [null],
|
|
66
|
+
"FORCED": [null],
|
|
67
|
+
"EDITED": [null],
|
|
68
|
+
"INPUTED": [null]
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"variableType": "COLLECTED",
|
|
73
|
+
"name": "NON",
|
|
74
|
+
"values": {
|
|
75
|
+
"PREVIOUS": [null],
|
|
76
|
+
"COLLECTED": [null],
|
|
77
|
+
"FORCED": [null],
|
|
78
|
+
"EDITED": [null],
|
|
79
|
+
"INPUTED": [null]
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
]
|
|
83
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getComponentValue = getComponentValue;
|
|
7
|
+
var _object = require("./object");
|
|
8
|
+
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); }
|
|
9
|
+
/**
|
|
10
|
+
* Extract the value associated with a component
|
|
11
|
+
* If the component expect multiple values (it has a responses property) then extract a map of values
|
|
12
|
+
*/
|
|
13
|
+
function getComponentValue(component, valueMap, rowIndex) {
|
|
14
|
+
var value = undefined;
|
|
15
|
+
if (hasResponse(component)) {
|
|
16
|
+
var valueArray = valueMap[component.response.name];
|
|
17
|
+
if (Array.isArray(valueArray)) {
|
|
18
|
+
value = valueArray[rowIndex !== null && rowIndex !== void 0 ? rowIndex : 0] || '';
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// For checkbox group we need to send the map of values
|
|
23
|
+
if (hasResponses(component)) {
|
|
24
|
+
value = (0, _object.objectMap)(valueMap, function (k, v) {
|
|
25
|
+
if (Array.isArray(v)) {
|
|
26
|
+
return [k, v[rowIndex !== null && rowIndex !== void 0 ? rowIndex : 0]];
|
|
27
|
+
}
|
|
28
|
+
return [k, v];
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
return value;
|
|
32
|
+
}
|
|
33
|
+
function hasResponse(component) {
|
|
34
|
+
return !!component && _typeof(component) === 'object' && 'response' in component && 'name' in component.response;
|
|
35
|
+
}
|
|
36
|
+
function hasResponses(component) {
|
|
37
|
+
return !!component && _typeof(component) === 'object' && 'responses' in component;
|
|
38
|
+
}
|