@inseefr/lunatic 0.4.0-v2 → 0.4.1-v2

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.
@@ -19,6 +19,10 @@ var _constants = require("../utils/constants");
19
19
 
20
20
  var _autoLoad = require("../utils/store-tools/auto-load");
21
21
 
22
+ var _constants2 = require("../constants");
23
+
24
+ var _calculatedVariables = require("./commons/calculated-variables");
25
+
22
26
  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); }
23
27
 
24
28
  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; }
@@ -78,7 +82,9 @@ function useLunatic(source) {
78
82
  suggestersConfiguration = _ref.suggesters,
79
83
  suggesterFetcher = _ref.suggesterFetcher,
80
84
  _ref$modalForControls = _ref.modalForControls,
81
- modalForControls = _ref$modalForControls === void 0 ? false : _ref$modalForControls;
85
+ modalForControls = _ref$modalForControls === void 0 ? false : _ref$modalForControls,
86
+ _ref$filterDescriptio = _ref.filterDescription,
87
+ filterDescription = _ref$filterDescriptio === void 0 ? false : _ref$filterDescriptio;
82
88
 
83
89
  var _useReducer = (0, _react.useReducer)(_reducer["default"], _initialState["default"]),
84
90
  _useReducer2 = _slicedToArray(_useReducer, 2),
@@ -153,15 +159,23 @@ function useLunatic(source) {
153
159
  onChange(response, value, args);
154
160
  }, [dispatch, onChange]);
155
161
 
156
- var getState = function getState() {
162
+ var getState = function getState(withRefreshedCalculated) {
157
163
  var variables = state.variables;
158
- return Object.entries(variables).reduce(function (acc, _ref3) {
164
+ var builtVariables = Object.entries(variables).reduce(function (acc, _ref3) {
159
165
  var _ref4 = _slicedToArray(_ref3, 2),
160
166
  k = _ref4[0],
161
- value = _ref4[1].value;
167
+ _ref4$ = _ref4[1],
168
+ value = _ref4$.value,
169
+ type = _ref4$.type;
162
170
 
163
- return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, k, value));
171
+ if (type !== _constants2.CALCULATED || !withRefreshedCalculated) return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, k, value));
172
+ return acc;
164
173
  }, {});
174
+ if (!withRefreshedCalculated) return builtVariables;
175
+ return (0, _calculatedVariables.interpretAllCalculatedVariables)({
176
+ variables: variables,
177
+ builtVariables: builtVariables
178
+ });
165
179
  };
166
180
 
167
181
  var pageTag = (0, _commons.getPageTag)(pager);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inseefr/lunatic",
3
- "version": "0.4.0-v2",
3
+ "version": "0.4.1-v2",
4
4
  "workersVersion": "0.2.4-experimental",
5
5
  "description": "Library of questionnaire components",
6
6
  "repository": {