@inseefr/lunatic 2.7.20-rc.1 → 2.7.20-rc.2

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.
@@ -4,7 +4,6 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
4
4
  var _react = require("@testing-library/react");
5
5
  var _vitest = require("vitest");
6
6
  var _errors = _interopRequireWildcard(require("./errors"));
7
- var _typeSource = require("../../../../use-lunatic/type-source");
8
7
  var _jsxRuntime = require("react/jsx-runtime");
9
8
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
10
9
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
@@ -13,19 +12,19 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
13
12
  id1: [{
14
13
  id: 'error1',
15
14
  errorMessage: 'Error 1 message',
16
- criticality: _typeSource.Criticality.ERROR,
17
- typeOfControl: _typeSource.TypeOfControl.CONSISTENCY
15
+ criticality: 'ERROR',
16
+ typeOfControl: 'CONSISTENCY'
18
17
  }],
19
18
  id2: [{
20
19
  id: 'error2',
21
20
  errorMessage: 'Error 2 message',
22
- criticality: _typeSource.Criticality.ERROR,
23
- typeOfControl: _typeSource.TypeOfControl.CONSISTENCY
21
+ criticality: 'ERROR',
22
+ typeOfControl: 'CONSISTENCY'
24
23
  }, {
25
24
  id: 'error3',
26
25
  errorMessage: 'Error 3 message',
27
- criticality: _typeSource.Criticality.ERROR,
28
- typeOfControl: _typeSource.TypeOfControl.CONSISTENCY
26
+ criticality: 'ERROR',
27
+ typeOfControl: 'CONSISTENCY'
29
28
  }]
30
29
  };
31
30
  (0, _vitest.it)('renders null when no active errors', function () {
@@ -3,7 +3,6 @@
3
3
  var _react = require("@testing-library/react");
4
4
  var _modalControls = _interopRequireDefault(require("./modal-controls"));
5
5
  var _vitest = require("vitest");
6
- var _typeSource = require("../../use-lunatic/type-source");
7
6
  var _jsxRuntime = require("react/jsx-runtime");
8
7
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
9
8
  (0, _vitest.describe)('ModalControls component', function () {
@@ -11,15 +10,15 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
11
10
  var errors = {
12
11
  field1: [{
13
12
  id: 'message1',
14
- criticality: _typeSource.Criticality.ERROR,
13
+ criticality: 'ERROR',
15
14
  errorMessage: 'Error message 1',
16
- typeOfControl: _typeSource.TypeOfControl.CONSISTENCY
15
+ typeOfControl: 'CONSISTENCY'
17
16
  }],
18
17
  field2: [{
19
18
  id: 'message2',
20
- criticality: _typeSource.Criticality.ERROR,
19
+ criticality: 'ERROR',
21
20
  errorMessage: 'Error message 2',
22
- typeOfControl: _typeSource.TypeOfControl.CONSISTENCY
21
+ typeOfControl: 'CONSISTENCY'
23
22
  }]
24
23
  };
25
24
  var goNext = _vitest.vi.fn();
@@ -46,16 +45,16 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
46
45
  (0, _vitest.it)('should call the goNext function when the skip button is clicked', function () {
47
46
  var errors = {
48
47
  field1: [{
49
- criticality: _typeSource.Criticality.ERROR,
48
+ criticality: 'ERROR',
50
49
  errorMessage: 'Error message 1',
51
50
  id: 'message1',
52
- typeOfControl: _typeSource.TypeOfControl.CONSISTENCY
51
+ typeOfControl: 'CONSISTENCY'
53
52
  }],
54
53
  field2: [{
55
- criticality: _typeSource.Criticality.ERROR,
54
+ criticality: 'ERROR',
56
55
  errorMessage: 'Error message 2',
57
56
  id: 'message2',
58
- typeOfControl: _typeSource.TypeOfControl.CONSISTENCY
57
+ typeOfControl: 'CONSISTENCY'
59
58
  }]
60
59
  };
61
60
  var goNext = _vitest.vi.fn();
package/lib/index.js CHANGED
@@ -1,9 +1,11 @@
1
1
  "use strict";
2
2
 
3
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  var _exportNames = {
8
+ components: true,
7
9
  LunaticComponents: true,
8
10
  useLunatic: true
9
11
  };
@@ -13,13 +15,15 @@ Object.defineProperty(exports, "LunaticComponents", {
13
15
  return _lunaticComponents.LunaticComponents;
14
16
  }
15
17
  });
18
+ exports.components = void 0;
16
19
  Object.defineProperty(exports, "useLunatic", {
17
20
  enumerable: true,
18
21
  get: function get() {
19
22
  return _useLunatic["default"];
20
23
  }
21
24
  });
22
- var _components = require("./components");
25
+ var _components = _interopRequireWildcard(require("./components"));
26
+ exports.components = _components;
23
27
  Object.keys(_components).forEach(function (key) {
24
28
  if (key === "default" || key === "__esModule") return;
25
29
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -33,4 +37,6 @@ Object.keys(_components).forEach(function (key) {
33
37
  });
34
38
  var _lunaticComponents = require("./components/lunatic-components");
35
39
  var _useLunatic = _interopRequireDefault(require("./use-lunatic"));
36
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
40
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
41
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
42
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
@@ -1,4 +1,5 @@
1
1
  export * from './components';
2
+ export * as components from './components';
2
3
  export { LunaticComponents } from './components/lunatic-components';
3
4
  export { default as useLunatic } from './use-lunatic';
4
5
  export type { LunaticComponentDefinition, LunaticControl, LunaticData, LunaticValues, LunaticError, LunaticExpression, LunaticVariable, LunaticCollectedValue, LunaticStateVariable, LunaticState, } from './use-lunatic/type';
@@ -28,28 +28,14 @@ export type DeclarationType = {
28
28
  export type ConditionFilterType = LabelType & {
29
29
  bindingDependencies?: string[];
30
30
  };
31
- export declare enum Criticality {
32
- INFO = "INFO",
33
- WARN = "WARN",
34
- ERROR = "ERROR"
35
- }
36
- export declare enum TypeOfControl {
37
- FORMAT = "FORMAT",
38
- CONSISTENCY = "CONSISTENCY"
39
- }
40
- export declare enum ControlTypeEnum {
41
- roundabout = "roundabout",
42
- row = "ROW",
43
- simple = "simple"
44
- }
45
31
  export type ControlType = {
46
32
  id: string;
47
- criticality: Criticality;
48
- typeOfControl: TypeOfControl;
33
+ criticality: 'INFO' | 'WARN' | 'ERROR';
34
+ typeOfControl: 'FORMAT' | 'CONSISTENCY';
49
35
  control: LabelType;
50
36
  errorMessage: LabelType;
51
37
  bindingDependencies: string[];
52
- type: ControlTypeEnum;
38
+ type: 'roundabout' | 'ROW' | 'simple';
53
39
  iterations?: number;
54
40
  };
55
41
  export type ResponseType = {
@@ -1773,7 +1773,10 @@
1773
1773
  "mandatory": false,
1774
1774
  "page": "28",
1775
1775
  "positioning": "HORIZONTAL",
1776
- "label": { "value": "\"➡ 3. \" || \"Tableau 2 axes\"", "type": "VTL|MD" },
1776
+ "label": {
1777
+ "value": "\"➡ 3. \" || \"Tableau 2 axes\"",
1778
+ "type": "VTL|MD"
1779
+ },
1777
1780
  "conditionFilter": {
1778
1781
  "value": "(COCHECASE = true)",
1779
1782
  "type": "VTL",
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.compileControls = compileControls;
7
7
  var _replaceComponentSequence = require("../replace-component-sequence");
8
- var _typeSource = require("../type-source");
9
8
  var _fillComponentExpressions = _interopRequireDefault(require("./fill-components/fill-component-expressions"));
10
9
  var _getComponentsFromState = _interopRequireDefault(require("./get-components-from-state"));
11
10
  var _checkRoundaboutControl = require("../reducer/controls/check-roundabout-control");
@@ -40,7 +39,7 @@ function checkComponents(state, components) {
40
39
  // The component has global level controls
41
40
  if (Array.isArray(controls)) {
42
41
  var componentErrors = checkControls(controls.filter(function (c) {
43
- return c.type !== _typeSource.ControlTypeEnum.row;
42
+ return c.type !== 'ROW';
44
43
  }), state.executeExpression, state.pager);
45
44
  if (componentErrors.length > 0) {
46
45
  errors[id] = componentErrors;
@@ -51,7 +50,7 @@ function checkComponents(state, components) {
51
50
  if (isLoopComponent(component)) {
52
51
  var _component$controls;
53
52
  var rowControls = (_component$controls = component.controls) === null || _component$controls === void 0 ? void 0 : _component$controls.filter(function (c) {
54
- return c.type === _typeSource.ControlTypeEnum.row;
53
+ return c.type === 'ROW';
55
54
  });
56
55
  if (rowControls !== null && rowControls !== void 0 && rowControls.length) {
57
56
  errors = checkComponentInLoop(state, _objectSpread(_objectSpread({}, component), {}, {
@@ -82,7 +81,7 @@ function checkComponents(state, components) {
82
81
  function checkControls(controls, executeExpression, pager) {
83
82
  return controls.map(function (control) {
84
83
  switch (control.type) {
85
- case _typeSource.ControlTypeEnum.roundabout:
84
+ case 'roundabout':
86
85
  return (0, _checkRoundaboutControl.checkRoundaboutControl)(control, executeExpression);
87
86
  default:
88
87
  return (0, _checkBaseControl.checkBaseControl)(control, executeExpression, pager);
@@ -153,7 +152,7 @@ function hasCriticalError(errors) {
153
152
  }
154
153
  // Look for at least one critical error in the list
155
154
  var criticalError = Object.values(errors).flat().find(function (error) {
156
- return error.criticality.startsWith(_typeSource.Criticality.ERROR) || error.typeOfControl === _typeSource.TypeOfControl.FORMAT;
155
+ return error.criticality.startsWith('ERROR') || error.typeOfControl === 'FORMAT';
157
156
  });
158
157
  return criticalError !== undefined;
159
158
  }
@@ -2,25 +2,4 @@
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
- });
6
- exports.TypeOfControl = exports.Criticality = exports.ControlTypeEnum = void 0;
7
- /**
8
- * Types used for source data (lunatic models and data.json)
9
- */
10
- var Criticality = exports.Criticality = /*#__PURE__*/function (Criticality) {
11
- Criticality["INFO"] = "INFO";
12
- Criticality["WARN"] = "WARN";
13
- Criticality["ERROR"] = "ERROR";
14
- return Criticality;
15
- }({});
16
- var TypeOfControl = exports.TypeOfControl = /*#__PURE__*/function (TypeOfControl) {
17
- TypeOfControl["FORMAT"] = "FORMAT";
18
- TypeOfControl["CONSISTENCY"] = "CONSISTENCY";
19
- return TypeOfControl;
20
- }({});
21
- var ControlTypeEnum = exports.ControlTypeEnum = /*#__PURE__*/function (ControlTypeEnum) {
22
- ControlTypeEnum["roundabout"] = "roundabout";
23
- ControlTypeEnum["row"] = "ROW";
24
- ControlTypeEnum["simple"] = "simple";
25
- return ControlTypeEnum;
26
- }({}); //Is it realy needed ?
5
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inseefr/lunatic",
3
- "version": "2.7.20-rc.1",
3
+ "version": "2.7.20-rc.2",
4
4
  "workersVersion": "0.3.0",
5
5
  "description": "Library of questionnaire components",
6
6
  "repository": {
@@ -159,7 +159,7 @@
159
159
  "jsdom-global": "^3.0.2",
160
160
  "postcss": "^8.2.6",
161
161
  "postcss-scss": "^3.0.4",
162
- "prettier": "^2.0.5",
162
+ "prettier": "^3.2.5",
163
163
  "react": "^18.0.0",
164
164
  "react-dom": "^18.0.0",
165
165
  "regenerator-runtime": "^0.13.7",
@@ -180,13 +180,6 @@
180
180
  "publishConfig": {
181
181
  "access": "public"
182
182
  },
183
- "prettier": {
184
- "singleQuote": true,
185
- "semi": true,
186
- "useTabs": true,
187
- "bracketSpacing": true,
188
- "trailingComma": "es5"
189
- },
190
183
  "peerDependencies": {
191
184
  "react": "^18.0.0"
192
185
  },