@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.
Files changed (51) hide show
  1. package/lib/components/index.js +7 -7
  2. package/lib/components/loop/loop.js +2 -2
  3. package/lib/components/loop/roster-for-loop/body.js +52 -0
  4. package/lib/components/loop/roster-for-loop/header.js +34 -0
  5. package/lib/components/loop/roster-for-loop/roster-for-loop.js +32 -35
  6. package/lib/components/loop/roster-for-loop/roster-table.js +16 -17
  7. package/lib/components/loop/roster-for-loop/roster.scss +34 -32
  8. package/lib/components/loop/roster-for-loop/row.js +19 -48
  9. package/lib/components/subsequence/subsequence.js +0 -2
  10. package/lib/components/summary/html/summary-container.js +14 -0
  11. package/lib/components/summary/html/summary-responses.js +53 -0
  12. package/lib/components/summary/html/summary-title.js +20 -0
  13. package/lib/components/summary/index.js +12 -0
  14. package/lib/components/summary/lunatic-summary.js +99 -0
  15. package/lib/src/components/index.d.ts +1 -1
  16. package/lib/src/components/loop/block-for-loop/block-for-loop-ochestrator.d.ts +1 -1
  17. package/lib/src/components/loop/block-for-loop/block-for-loop.d.ts +1 -1
  18. package/lib/src/components/loop/roster-for-loop/body.d.ts +12 -0
  19. package/lib/src/components/loop/roster-for-loop/header.d.ts +9 -0
  20. package/lib/src/components/loop/roster-for-loop/roster-for-loop-orchestrator.d.ts +1 -1
  21. package/lib/src/components/loop/roster-for-loop/roster-for-loop.d.ts +4 -4
  22. package/lib/src/components/loop/roster-for-loop/roster-table.d.ts +2 -2
  23. package/lib/src/components/subsequence/subsequence.d.ts +2 -2
  24. package/lib/src/components/summary/html/summary-container.d.ts +2 -0
  25. package/lib/src/components/summary/html/summary-responses.d.ts +12 -0
  26. package/lib/src/components/summary/html/summary-title.d.ts +5 -0
  27. package/lib/src/components/summary/index.d.ts +1 -0
  28. package/lib/src/components/summary/lunatic-summary.d.ts +7 -0
  29. package/lib/src/components/type.d.ts +16 -9
  30. package/lib/stories/loop/block-for-loop.stories.js +8 -1
  31. package/lib/stories/loop/roster-for-loop.stories.js +1 -8
  32. package/lib/stories/loop/source-with-header.json +4 -16
  33. package/lib/stories/questionnaires/simpsons/simpsons.stories.js +1 -1
  34. package/lib/stories/summary/data.json +32 -0
  35. package/lib/stories/summary/source.json +353 -0
  36. package/lib/stories/{duration/duration.stories.js → summary/summary.stories.js} +11 -15
  37. package/lib/use-lunatic/commons/fill-components/fill-component-expressions.js +1 -1
  38. package/package.json +1 -1
  39. package/lib/components/duration/duration.js +0 -117
  40. package/lib/components/duration/duration.scss +0 -16
  41. package/lib/components/duration/duration.spec.js +0 -49
  42. package/lib/components/duration/index.js +0 -13
  43. package/lib/components/duration/useDurationValues.js +0 -124
  44. package/lib/hooks/use-did-change.js +0 -19
  45. package/lib/src/components/duration/duration.d.ts +0 -4
  46. package/lib/src/components/duration/duration.spec.d.ts +0 -1
  47. package/lib/src/components/duration/index.d.ts +0 -1
  48. package/lib/src/components/duration/useDurationValues.d.ts +0 -43
  49. package/lib/src/hooks/use-did-change.d.ts +0 -4
  50. package/lib/stories/duration/source.json +0 -32
  51. package/lib/stories/duration/source1.json +0 -32
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.LunaticSummary = LunaticSummary;
7
+ var _summaryTitle = _interopRequireDefault(require("./html/summary-title"));
8
+ var _summaryContainer = require("./html/summary-container");
9
+ var _summaryResponses = _interopRequireDefault(require("./html/summary-responses"));
10
+ var _jsxRuntime = require("react/jsx-runtime");
11
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
12
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
13
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
14
+ 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); }
15
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
16
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
17
+ 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; }
18
+ function compileResponses(responses, executeExpression, iteration) {
19
+ if (!responses) {
20
+ return [];
21
+ }
22
+ var option = iteration || iteration === 0 ? iteration : undefined;
23
+ return responses.map(function (r) {
24
+ return {
25
+ label: executeExpression(r.label, {
26
+ iteration: option
27
+ }),
28
+ value: executeExpression(r.value, {
29
+ iteration: option
30
+ })
31
+ };
32
+ });
33
+ }
34
+ function CompiledTitle(_ref) {
35
+ var executeExpression = _ref.executeExpression,
36
+ iteration = _ref.iteration,
37
+ title = _ref.title;
38
+ if (!title && iteration) {
39
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
40
+ children: "Valeur pour ".concat(iteration + 1)
41
+ });
42
+ }
43
+ if (!title) {
44
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
45
+ children: "Valeurs renseign\xE9s :"
46
+ });
47
+ }
48
+ var hasIteration = iteration || iteration === 0;
49
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
50
+ children: executeExpression(title, hasIteration ? {
51
+ iteration: iteration
52
+ } : {})
53
+ });
54
+ }
55
+ function LunaticSummary(props) {
56
+ var executeExpression = props.executeExpression,
57
+ label = props.label,
58
+ sections = props.sections;
59
+ var compiledSections = sections.reduce(function (acc, section) {
60
+ var iterations = section.iterations,
61
+ title = section.title,
62
+ responses = section.responses;
63
+ if (iterations) {
64
+ var compiledIterations = executeExpression(iterations);
65
+ if (responses) {
66
+ var elements = Array(compiledIterations).fill(null).map(function (_, iteration) {
67
+ return {
68
+ values: compileResponses(responses, executeExpression, iteration),
69
+ title: /*#__PURE__*/(0, _jsxRuntime.jsx)(CompiledTitle, {
70
+ executeExpression: executeExpression,
71
+ iteration: iteration,
72
+ title: title
73
+ })
74
+ };
75
+ });
76
+ return [].concat(_toConsumableArray(acc), _toConsumableArray(elements));
77
+ }
78
+ }
79
+ if (responses) {
80
+ var element = {
81
+ title: /*#__PURE__*/(0, _jsxRuntime.jsx)(CompiledTitle, {
82
+ executeExpression: executeExpression,
83
+ iteration: undefined,
84
+ title: title
85
+ }),
86
+ values: compileResponses(responses, executeExpression, undefined)
87
+ };
88
+ return [].concat(_toConsumableArray(acc), [element]);
89
+ }
90
+ return acc;
91
+ }, []);
92
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_summaryContainer.SummaryContainer, {
93
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_summaryTitle["default"], {
94
+ label: label
95
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_summaryResponses["default"], {
96
+ sections: compiledSections
97
+ })]
98
+ });
99
+ }
@@ -22,6 +22,6 @@ 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";
25
+ export { Summary } from './summary';
26
26
  export { default as QuestionInformation } from './questions/question-information';
27
27
  export { default as QuestionContext } from './questions/question-context';
@@ -42,7 +42,7 @@ declare const BlockForLoopOrchestrator: ({ id, components, nbRows, valueMap, han
42
42
  bindingDependencies?: string[] | undefined;
43
43
  } | undefined) => T;
44
44
  value: Record<string, unknown[]>;
45
- header?: {
45
+ headers?: {
46
46
  label: import("react").ReactNode;
47
47
  }[] | undefined;
48
48
  paginatedLoop?: boolean | undefined;
@@ -13,7 +13,7 @@ declare const _default: React.ComponentType<import("../../type").LunaticBaseProp
13
13
  bindingDependencies?: string[] | undefined;
14
14
  } | undefined) => T;
15
15
  value: Record<string, unknown[]>;
16
- header?: {
16
+ headers?: {
17
17
  label: React.ReactNode;
18
18
  }[] | undefined;
19
19
  paginatedLoop?: boolean | undefined;
@@ -0,0 +1,12 @@
1
+ import { LunaticComponentProps } from '../../type';
2
+ type Props = {
3
+ nbRows: number;
4
+ handleChange: (response: {
5
+ name: string;
6
+ }, value: unknown, args: {
7
+ index: number;
8
+ [k: string]: unknown;
9
+ }) => void;
10
+ } & Pick<LunaticComponentProps<'RosterForLoop'>, 'id' | 'components' | 'executeExpression' | 'headers' | 'value' | 'management' | 'missing' | 'shortcut' | 'errors'>;
11
+ declare function Body({ id, components, nbRows, executeExpression, handleChange, value: valueMap, missing, }: Props): import("react/jsx-runtime").JSX.Element | null;
12
+ export default Body;
@@ -0,0 +1,9 @@
1
+ import { ReactNode } from 'react';
2
+ type Props = {
3
+ id?: string;
4
+ header?: Array<{
5
+ label: ReactNode;
6
+ }>;
7
+ };
8
+ declare function Header({ header, id }: Props): import("react/jsx-runtime").JSX.Element | null;
9
+ export default Header;
@@ -42,7 +42,7 @@ declare const RosterForLoopOrchestrator: ({ id, components, nbRows, valueMap, ha
42
42
  bindingDependencies?: string[] | undefined;
43
43
  } | undefined) => T;
44
44
  value: Record<string, unknown[]>;
45
- header?: {
45
+ headers?: {
46
46
  label: import("react").ReactNode;
47
47
  }[] | undefined;
48
48
  paginatedLoop?: boolean | undefined;
@@ -1,5 +1,5 @@
1
- /// <reference types="react" />
2
- declare const _default: import("react").ComponentType<import("../../type").LunaticBaseProps<unknown> & {
1
+ import React from 'react';
2
+ declare const _default: React.ComponentType<import("../../type").LunaticBaseProps<unknown> & {
3
3
  lines: {
4
4
  min: number;
5
5
  max: number;
@@ -13,8 +13,8 @@ declare const _default: import("react").ComponentType<import("../../type").Lunat
13
13
  bindingDependencies?: string[] | undefined;
14
14
  } | undefined) => T;
15
15
  value: Record<string, unknown[]>;
16
- header?: {
17
- label: import("react").ReactNode;
16
+ headers?: {
17
+ label: React.ReactNode;
18
18
  }[] | undefined;
19
19
  paginatedLoop?: boolean | undefined;
20
20
  }>;
@@ -8,6 +8,6 @@ type Props = {
8
8
  index: number;
9
9
  [k: string]: unknown;
10
10
  }) => void;
11
- } & Pick<LunaticComponentProps<'RosterForLoop'>, 'id' | 'components' | 'executeExpression' | 'header' | 'value' | 'missing' | 'errors'>;
12
- declare function RosterTable({ components, nbRows, executeExpression, id, header, value: valueMap, missing, handleChange, }: Props): import("react/jsx-runtime").JSX.Element;
11
+ } & Pick<LunaticComponentProps<'RosterForLoop'>, 'id' | 'components' | 'executeExpression' | 'headers' | 'value' | 'management' | 'missing' | 'shortcut' | 'errors'>;
12
+ declare function RosterTable({ components, nbRows, executeExpression, id, headers, value: valueMap, shortcut, missing, management, handleChange, }: Props): import("react/jsx-runtime").JSX.Element;
13
13
  export default RosterTable;
@@ -1,3 +1,3 @@
1
- import React from 'react';
2
- declare const _default: React.ComponentType<Pick<import("../type").LunaticBaseProps<string>, "label" | "id" | "declarations">>;
1
+ /// <reference types="react" />
2
+ declare const _default: import("react").ComponentType<Pick<import("../type").LunaticBaseProps<string>, "label" | "id" | "declarations">>;
3
3
  export default _default;
@@ -0,0 +1,2 @@
1
+ import { PropsWithChildren } from 'react';
2
+ export declare function SummaryContainer({ children }: PropsWithChildren): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,12 @@
1
+ import { ReactNode } from 'react';
2
+ type ResponsesValue = Array<{
3
+ label: ReactNode;
4
+ value: ReactNode;
5
+ }>;
6
+ declare const _default: import("react").ComponentType<{
7
+ sections: {
8
+ title?: ReactNode;
9
+ values?: ResponsesValue | undefined;
10
+ }[];
11
+ }>;
12
+ export default _default;
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import { LunaticBaseProps } from '../../type';
3
+ type SummaryTitleProps = Pick<LunaticBaseProps<string>, 'label'>;
4
+ declare const _default: import("react").ComponentType<SummaryTitleProps>;
5
+ export default _default;
@@ -0,0 +1 @@
1
+ export { LunaticSummary as Summary } from './lunatic-summary';
@@ -0,0 +1,7 @@
1
+ import { LunaticComponentProps } from '../type';
2
+ import { ReactNode } from 'react';
3
+ export type SummaryResponsesEntry = {
4
+ label: ReactNode;
5
+ value: ReactNode;
6
+ };
7
+ export declare function LunaticSummary(props: LunaticComponentProps<'Summary'>): import("react/jsx-runtime").JSX.Element;
@@ -2,7 +2,10 @@ 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';
5
+ export type VtlExpression = {
6
+ value: string;
7
+ type: 'VTL' | 'VTL|MD';
8
+ };
6
9
  export type LunaticBaseProps<ValueType = unknown> = {
7
10
  id: string;
8
11
  handleChange: (response: {
@@ -61,12 +64,6 @@ type ComponentPropsByType = {
61
64
  name: string;
62
65
  };
63
66
  };
64
- Duration: LunaticBaseProps<string | null> & {
65
- format: Formats;
66
- response: {
67
- name: string;
68
- };
69
- };
70
67
  Input: LunaticBaseProps<string> & {
71
68
  maxLength?: number;
72
69
  value: null | string;
@@ -90,7 +87,7 @@ type ComponentPropsByType = {
90
87
  components: LunaticComponentDefinition[];
91
88
  executeExpression: LunaticState['executeExpression'];
92
89
  value: Record<string, unknown[]>;
93
- header?: Array<{
90
+ headers?: Array<{
94
91
  label: ReactNode;
95
92
  }>;
96
93
  paginatedLoop?: boolean;
@@ -104,7 +101,7 @@ type ComponentPropsByType = {
104
101
  components: LunaticComponentDefinition[];
105
102
  executeExpression: LunaticState['executeExpression'];
106
103
  value: Record<string, unknown[]>;
107
- header?: Array<{
104
+ headers?: Array<{
108
105
  label: ReactNode;
109
106
  }>;
110
107
  paginatedLoop?: boolean;
@@ -246,6 +243,16 @@ type ComponentPropsByType = {
246
243
  name: string;
247
244
  };
248
245
  };
246
+ Summary: LunaticBaseProps<string | null> & {
247
+ sections: Array<{
248
+ responses?: Array<{
249
+ label: VtlExpression;
250
+ value: VtlExpression;
251
+ }>;
252
+ title?: VtlExpression;
253
+ iterations?: number;
254
+ }>;
255
+ };
249
256
  };
250
257
  export type LunaticComponentType = keyof ComponentPropsByType;
251
258
  export type LunaticComponentProps<T extends LunaticComponentType = LunaticComponentType> = ComponentPropsByType[T];
@@ -3,10 +3,11 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports["default"] = exports.Default = void 0;
6
+ exports["default"] = exports.WithHeader = exports.Default = void 0;
7
7
  var _react = _interopRequireDefault(require("react"));
8
8
  var _orchestrator = _interopRequireDefault(require("../utils/orchestrator"));
9
9
  var _sourceBloc = _interopRequireDefault(require("./source-bloc.json"));
10
+ var _sourceWithHeader = _interopRequireDefault(require("./source-with-header.json"));
10
11
  var _defaultArgTypes = _interopRequireDefault(require("../utils/default-arg-types"));
11
12
  var _jsxRuntime = require("react/jsx-runtime");
12
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
@@ -31,4 +32,10 @@ exports.Default = Default;
31
32
  Default.args = {
32
33
  id: 'bloc-for-loop',
33
34
  source: _sourceBloc["default"]
35
+ };
36
+ var WithHeader = Template.bind({});
37
+ exports.WithHeader = WithHeader;
38
+ WithHeader.args = {
39
+ id: 'bloc-for-loop-headers',
40
+ source: _sourceWithHeader["default"]
34
41
  };
@@ -3,12 +3,11 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports["default"] = exports.WithHeader = exports.Default = void 0;
6
+ exports["default"] = exports.Default = void 0;
7
7
  var _react = _interopRequireDefault(require("react"));
8
8
  var _orchestrator = _interopRequireDefault(require("../utils/orchestrator"));
9
9
  var _sourceRoster = _interopRequireDefault(require("./source-roster"));
10
10
  var _defaultArgTypes = _interopRequireDefault(require("../utils/default-arg-types"));
11
- var _sourceWithHeader = _interopRequireDefault(require("./source-with-header.json"));
12
11
  var _jsxRuntime = require("react/jsx-runtime");
13
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
14
13
  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); }
@@ -32,10 +31,4 @@ exports.Default = Default;
32
31
  Default.args = {
33
32
  id: 'roster-for-loop',
34
33
  source: _sourceRoster["default"]
35
- };
36
- var WithHeader = Template.bind({});
37
- exports.WithHeader = WithHeader;
38
- WithHeader.args = {
39
- id: 'roster-for-loop-headers',
40
- source: _sourceWithHeader["default"]
41
34
  };
@@ -14,28 +14,16 @@
14
14
  {
15
15
  "id": "loop-prenom",
16
16
  "componentType": "RosterForLoop",
17
- "header": [
18
- {
19
- "headerCell": true,
20
- "label": {
21
- "value": "Prénom",
22
- "type": "VTL|MD"
23
- }
24
- },
25
- {
26
- "headerCell": true,
27
- "label": {
28
- "value": "Age",
29
- "type": "VTL|MD"
30
- }
31
- }
17
+ "headers": [
18
+ { "headerCell": true, "label": "Prénom" },
19
+ { "headerCell": true, "label": "Age" }
32
20
  ],
33
21
  "label": { "value": "\"Ajouter un individu\"", "type": "VTL|MD" },
34
22
  "conditionFilter": { "value": "true", "type": "VTL" },
35
23
  "bindingDependencies": ["PRENOM", "AGE"],
36
24
  "lines": {
37
25
  "min": { "value": 1, "type": "VTL" },
38
- "max": { "value": 1000, "type": "VTL" }
26
+ "max": { "value": 10, "type": "VTL" }
39
27
  },
40
28
  "page": "1",
41
29
  "components": [
@@ -412,7 +412,7 @@ Filled.play = /*#__PURE__*/function () {
412
412
  _context.next = 134;
413
413
  return page.getByRole('row', {
414
414
  name: /Leave with pay/
415
- }).getByRole('spinbutton').fill('12');
415
+ }).fill('12');
416
416
  case 134:
417
417
  _context.next = 136;
418
418
  return page.getByRole('button', {
@@ -0,0 +1,32 @@
1
+ {
2
+ "COLLECTED": {
3
+ "NB_HAB": {
4
+ "EDITED": null,
5
+ "FORCED": null,
6
+ "INPUTED": null,
7
+ "PREVIOUS": null,
8
+ "COLLECTED": 2
9
+ },
10
+ "PRENOMS": {
11
+ "EDITED": [null],
12
+ "FORCED": [null],
13
+ "INPUTED": [null],
14
+ "PREVIOUS": [null],
15
+ "COLLECTED": ["Matt", "Julia"]
16
+ },
17
+ "AGE": {
18
+ "EDITED": [null],
19
+ "FORCED": [null],
20
+ "INPUTED": [null],
21
+ "PREVIOUS": [null],
22
+ "COLLECTED": [26, 31]
23
+ },
24
+ "SEXE": {
25
+ "EDITED": [null],
26
+ "FORCED": [null],
27
+ "INPUTED": [null],
28
+ "PREVIOUS": [null],
29
+ "COLLECTED": ["1", "2"]
30
+ }
31
+ }
32
+ }