@inseefr/lunatic 2.4.4 → 2.4.5-mvp-eap

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 (77) hide show
  1. package/lib/components/commons/components/combo-box/combo-box-content.js +2 -5
  2. package/lib/components/commons/components/combo-box/combo-box.js +16 -16
  3. package/lib/components/commons/components/combo-box/panel/panel.js +2 -4
  4. package/lib/components/commons/components/combo-box/state-management/reduce-on-init.js +4 -1
  5. package/lib/components/commons/components/orchestrated-component.js +2 -0
  6. package/lib/components/commons/create-row-orchestrator.js +2 -2
  7. package/lib/components/dropdown/lunatic-dropdown.js +1 -0
  8. package/lib/components/input-number/html/__snapshots__/input-number.spec.tsx.snap +4 -4
  9. package/lib/components/input-number/html/input-number-thousand.js +21 -8
  10. package/lib/components/input-number/html/input-number.js +4 -24
  11. package/lib/components/input-number/html/input-number.scss +1 -1
  12. package/lib/components/input-number/html/input-number.spec.js +21 -27
  13. package/lib/components/input-number/lunatic-input-number.js +2 -0
  14. package/lib/components/loop/loop.js +6 -4
  15. package/lib/components/loop/roster-for-loop/roster-for-loop-orchestrator.js +1 -0
  16. package/lib/components/loop/roster-for-loop/roster-for-loop.js +45 -33
  17. package/lib/components/loop/roster-for-loop/roster-table.js +22 -18
  18. package/lib/components/loop/roster-for-loop/roster.scss +30 -37
  19. package/lib/components/loop/roster-for-loop/row.js +84 -31
  20. package/lib/components/pairwise-links/pairwise-links.js +2 -4
  21. package/lib/components/pairwise-links/row.js +1 -0
  22. package/lib/components/suggester/html/suggester.js +31 -12
  23. package/lib/components/suggester/idb-suggester/idb-suggester.js +10 -7
  24. package/lib/components/suggester/lunatic-suggester.js +31 -4
  25. package/lib/hooks/use-did-change.js +19 -0
  26. package/lib/src/components/commons/components/combo-box/combo-box.d.ts +4 -4
  27. package/lib/src/components/commons/components/combo-box/combo-box.stories.d.ts +2 -2
  28. package/lib/src/components/commons/components/combo-box/panel/panel.d.ts +1 -1
  29. package/lib/src/components/commons/components/combo-box/state-management/actions.d.ts +4 -4
  30. package/lib/src/components/commons/components/orchestrated-component.d.ts +3 -3
  31. package/lib/src/components/commons/create-row-orchestrator.d.ts +4 -3
  32. package/lib/src/components/dropdown/html/dropdown-writable/dropdown-writable.d.ts +1 -1
  33. package/lib/src/components/dropdown/html/dropdown.d.ts +2 -1
  34. package/lib/src/components/input-number/html/input-number-thousand.d.ts +1 -1
  35. package/lib/src/components/input-number/html/input-number.d.ts +2 -1
  36. package/lib/src/components/loop/block-for-loop/block-for-loop-ochestrator.d.ts +11 -3
  37. package/lib/src/components/loop/block-for-loop/block-for-loop.d.ts +5 -1
  38. package/lib/src/components/loop/roster-for-loop/roster-for-loop-orchestrator.d.ts +11 -3
  39. package/lib/src/components/loop/roster-for-loop/roster-for-loop.d.ts +8 -4
  40. package/lib/src/components/loop/roster-for-loop/roster-table.d.ts +3 -3
  41. package/lib/src/components/loop/roster-for-loop/row.d.ts +3 -2
  42. package/lib/src/components/suggester/html/suggester.d.ts +6 -4
  43. package/lib/src/components/suggester/idb-suggester/idb-suggester.d.ts +4 -3
  44. package/lib/src/components/suggester/lunatic-suggester.d.ts +1 -1
  45. package/lib/src/components/type.d.ts +25 -5
  46. package/lib/src/hooks/use-did-change.d.ts +4 -0
  47. package/lib/src/use-lunatic/commons/fill-components/fill-from-state.d.ts +61 -16
  48. package/lib/src/use-lunatic/commons/fill-components/fill-specific-expression.d.ts +36 -0
  49. package/lib/src/use-lunatic/reducer/commons/is-loop-component.d.ts +2 -2
  50. package/lib/src/use-lunatic/reducer/overview/overview-on-init.d.ts +1 -1
  51. package/lib/src/use-lunatic/reducer/reduce-update-state.d.ts +106 -1
  52. package/lib/src/use-lunatic/replace-component-sequence.d.ts +1 -1
  53. package/lib/src/use-lunatic/type-source.d.ts +11 -1
  54. package/lib/src/use-lunatic/type.d.ts +1 -1
  55. package/lib/stories/input-number/input-number.stories.js +9 -2
  56. package/lib/stories/input-number/source-dynamic.json +41 -0
  57. package/lib/stories/loop/block-for-loop.stories.js +1 -8
  58. package/lib/stories/loop/roster-for-loop.stories.js +8 -1
  59. package/lib/stories/loop/source-with-header.json +15 -3
  60. package/lib/stories/questionnaires/EAP/data-eap.json +46 -0
  61. package/lib/stories/questionnaires/EAP/eap.stories.js +71 -0
  62. package/lib/stories/questionnaires/EAP/source-eap.json +433 -0
  63. package/lib/stories/suggester/multipleResponses.json +100 -0
  64. package/lib/stories/suggester/suggester-workers.stories.js +1 -1
  65. package/lib/stories/suggester/suggester.stories.js +18 -6
  66. package/lib/use-lunatic/commons/fill-components/fill-component-expressions.js +1 -1
  67. package/lib/use-lunatic/commons/get-component-value/get-component-value.js +8 -0
  68. package/lib/use-lunatic/initial-state.js +1 -0
  69. package/lib/use-lunatic/reducer/reducer.js +1 -0
  70. package/package.json +1 -1
  71. package/lib/components/input-number/html/__snapshots__/inpute-number.spec.jsx.snap +0 -92
  72. package/lib/components/input-number/html/input-number-default.js +0 -57
  73. package/lib/components/loop/roster-for-loop/body.js +0 -52
  74. package/lib/components/loop/roster-for-loop/header.js +0 -34
  75. package/lib/src/components/input-number/html/input-number-default.d.ts +0 -13
  76. package/lib/src/components/loop/roster-for-loop/body.d.ts +0 -12
  77. package/lib/src/components/loop/roster-for-loop/header.d.ts +0 -9
@@ -4,9 +4,10 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports["default"] = void 0;
7
- var _idbSuggester = require("./idb-suggester");
7
+ var _react = require("react");
8
+ var _commons = require("../commons");
8
9
  var _lunaticComponentWithoutLabel = _interopRequireDefault(require("../commons/components/lunatic-component-without-label"));
9
- var _useOnHandleChange = _interopRequireDefault(require("../commons/use-on-handle-change"));
10
+ var _idbSuggester = require("./idb-suggester");
10
11
  var _jsxRuntime = require("react/jsx-runtime");
11
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
12
13
  function LunaticSuggester(_ref) {
@@ -28,12 +29,34 @@ function LunaticSuggester(_ref) {
28
29
  missingResponse = _ref.missingResponse,
29
30
  management = _ref.management,
30
31
  response = _ref.response,
32
+ responses = _ref.responses,
31
33
  getSuggesterStatus = _ref.getSuggesterStatus;
32
- var onChange = (0, _useOnHandleChange["default"])({
34
+ // ToDo :
35
+ /**
36
+ * response -> responses
37
+ * onChange(id) -> onChange({ code: '', label: '', info: '' }) -> onSelect in subComponent
38
+ * useOnHandleChange -> update to handleChange on 3 response REPONSENAME (historical value i.e the code), REPONSENAME_LABEL, REPONSENAME_INFO
39
+ */
40
+ // @ts-ignore
41
+ var onChangeSimple = (0, _commons.useOnHandleChange)({
33
42
  handleChange: handleChange,
34
43
  response: response,
35
44
  value: value
36
45
  });
46
+ var onChange = (0, _react.useCallback)(function (option) {
47
+ if (responses) {
48
+ responses.forEach(function (r) {
49
+ // @ts-ignore
50
+ if (value[r.id] != option[r.id]) {
51
+ // @ts-ignore
52
+ handleChange(r.response, option[r.id]);
53
+ }
54
+ });
55
+ } else {
56
+ // @ts-ignore
57
+ onChangeSimple(option === null || option === void 0 ? void 0 : option.id);
58
+ }
59
+ }, [handleChange, onChangeSimple, responses, value]);
37
60
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_lunaticComponentWithoutLabel["default"], {
38
61
  id: id,
39
62
  preferences: preferences,
@@ -48,8 +71,12 @@ function LunaticSuggester(_ref) {
48
71
  storeName: storeName,
49
72
  optionRenderer: optionRenderer,
50
73
  labelRenderer: labelRenderer,
51
- idbVersion: idbVersion,
74
+ idbVersion: idbVersion
75
+ // @ts-ignore
76
+ ,
52
77
  onSelect: onChange,
78
+ responses: responses,
79
+ response: response,
53
80
  disabled: disabled,
54
81
  id: id,
55
82
  value: value,
@@ -0,0 +1,19 @@
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,20 +1,20 @@
1
1
  import { ReactNode } from 'react';
2
+ import { LunaticBaseProps } from '../../../type';
2
3
  import './combo-box.scss';
3
4
  import { ComboBoxOption } from './combo-box.type';
4
- import { SelectionProps } from './selection/selection';
5
5
  import { PanelProps } from './panel/panel';
6
- import { LunaticBaseProps } from '../../../type';
6
+ import { SelectionProps } from './selection/selection';
7
7
  type Props = SelectionProps & PanelProps & {
8
8
  className?: string;
9
9
  classStyle?: string;
10
10
  value: string | null;
11
11
  messageError?: string;
12
- getOptionValue?: (o: ComboBoxOption) => string;
12
+ getOptionValue?: (o: ComboBoxOption) => string | undefined;
13
13
  label?: ReactNode;
14
14
  description?: ReactNode;
15
15
  errors?: LunaticBaseProps['errors'];
16
16
  onChange?: (s: string | null) => void;
17
- onSelect: (s: string | null) => void;
17
+ onSelect: (s: ComboBoxOption | null | string) => void;
18
18
  options: ComboBoxOption[];
19
19
  };
20
20
  declare const _default: import("react").ComponentType<Props>;
@@ -15,13 +15,13 @@ export declare const Default: Story<{
15
15
  classStyle?: string | undefined;
16
16
  value: string | null;
17
17
  messageError?: string | undefined;
18
- getOptionValue?: ((o: ComboBoxOption) => string) | undefined;
18
+ getOptionValue?: ((o: ComboBoxOption) => string | undefined) | undefined;
19
19
  label?: import("react").ReactNode;
20
20
  description?: import("react").ReactNode;
21
21
  errors?: {
22
22
  [id: string]: import("../../../..").LunaticError[];
23
23
  } | undefined;
24
24
  onChange?: ((s: string | null) => void) | undefined;
25
- onSelect: (s: string | null) => void;
25
+ onSelect: (s: string | ComboBoxOption | null) => void;
26
26
  options: ComboBoxOption[];
27
27
  }>;
@@ -12,6 +12,6 @@ export type PanelProps = {
12
12
  expanded?: boolean;
13
13
  id?: string;
14
14
  search?: string;
15
- onSelect: (value: string) => void;
15
+ onSelect: (value: string | ComboBoxOption | null) => void;
16
16
  };
17
17
  export declare function Panel({ optionRenderer: OptionRender, options, focused, selectedIndex, expanded, id, search, onSelect, }: PanelProps): import("react/jsx-runtime").JSX.Element;
@@ -40,8 +40,8 @@ export declare const onInit: ({ ...payload }: ComboAction<ComboActionKind.ON_INI
40
40
  readonly type: ComboActionKind.ON_INIT;
41
41
  readonly payload: {
42
42
  readonly options: ComboBoxOption[];
43
- readonly value: string | null;
44
- readonly getOptionValue: (o: ComboBoxOption) => string;
43
+ readonly value: string | ComboBoxOption | null;
44
+ readonly getOptionValue: (o: ComboBoxOption) => string | undefined;
45
45
  };
46
46
  };
47
47
  export type ComboAction<T extends ComboActionKind = ComboActionKind> = ({
@@ -70,8 +70,8 @@ export type ComboAction<T extends ComboActionKind = ComboActionKind> = ({
70
70
  type: ComboActionKind.ON_INIT;
71
71
  payload: {
72
72
  options: ComboBoxOption[];
73
- value: string | null;
74
- getOptionValue: (o: ComboBoxOption) => string;
73
+ value: string | ComboBoxOption | null;
74
+ getOptionValue: (o: ComboBoxOption) => string | undefined;
75
75
  };
76
76
  }) & {
77
77
  type: T;
@@ -1,9 +1,9 @@
1
- import { LunaticBaseProps } from '../../type';
2
1
  import { LunaticComponentDefinition } from '../../../use-lunatic/type';
2
+ import { LunaticBaseProps } from '../../type';
3
3
  type Props = {
4
4
  linksIterations?: [number, number];
5
5
  component: LunaticComponentDefinition;
6
6
  features?: string[];
7
- } & Pick<LunaticBaseProps, 'id' | 'iteration' | 'executeExpression' | 'handleChange' | 'missing' | 'shortcut' | 'management' | 'preferences' | 'value' | 'errors'>;
8
- declare function OrchestratedComponent({ id, component, handleChange, features, missing, shortcut, management, preferences, value, iteration, linksIterations, executeExpression, errors, }: Props): import("react/jsx-runtime").JSX.Element | null;
7
+ } & Pick<LunaticBaseProps, 'id' | 'iteration' | 'executeExpression' | 'handleChange' | 'missing' | 'shortcut' | 'management' | 'getSuggesterStatus' | 'preferences' | 'value' | 'errors'>;
8
+ declare function OrchestratedComponent({ id, component, handleChange, features, missing, shortcut, management, preferences, value, iteration, linksIterations, executeExpression, getSuggesterStatus, errors, }: Props): import("react/jsx-runtime").JSX.Element | null;
9
9
  export default OrchestratedComponent;
@@ -1,6 +1,6 @@
1
1
  import { FunctionComponent } from 'react';
2
- import { LunaticComponentProps } from '../type';
3
2
  import { LunaticComponentDefinition, LunaticState } from '../../use-lunatic/type';
3
+ import { LunaticComponentProps } from '../type';
4
4
  type OriginalProps = {
5
5
  key: number;
6
6
  rowIndex: number;
@@ -13,6 +13,7 @@ type OriginalProps = {
13
13
  [key: string]: unknown;
14
14
  }) => void;
15
15
  executeExpression: LunaticState['executeExpression'];
16
+ getSuggesterStatus?: LunaticState['getSuggesterStatus'];
16
17
  iteration?: number;
17
18
  linksIterations?: [number, number];
18
19
  features?: string[];
@@ -26,6 +27,6 @@ type OrchestratedProps = {
26
27
  index: number;
27
28
  [key: string]: unknown;
28
29
  }) => void;
29
- } & Pick<OriginalProps, 'id' | 'components' | 'valueMap' | 'features' | 'missing' | 'shortcut' | 'preferences' | 'executeExpression' | 'iteration' | 'errors'>;
30
- declare function createRowOrchestrator(Row: FunctionComponent<OriginalProps>): ({ id, components, nbRows, valueMap, handleChange, features, missing, shortcut, preferences, executeExpression, iteration, xAxisIterations, errors, }: OrchestratedProps) => import("react/jsx-runtime").JSX.Element | null;
30
+ } & Pick<OriginalProps, 'id' | 'components' | 'valueMap' | 'features' | 'missing' | 'shortcut' | 'preferences' | 'executeExpression' | 'iteration' | 'errors' | 'getSuggesterStatus'>;
31
+ declare function createRowOrchestrator(Row: FunctionComponent<OriginalProps>): ({ id, components, nbRows, valueMap, handleChange, features, missing, shortcut, preferences, executeExpression, getSuggesterStatus, iteration, xAxisIterations, errors, }: OrchestratedProps) => import("react/jsx-runtime").JSX.Element | null;
31
32
  export default createRowOrchestrator;
@@ -5,7 +5,7 @@ type Props = {
5
5
  id?: string;
6
6
  disabled?: boolean;
7
7
  options: ComboBoxOption[];
8
- onSelect: (v: string | null) => void;
8
+ onSelect: (v: string | null | ComboBoxOption) => void;
9
9
  className?: string;
10
10
  value: string | null;
11
11
  label?: ReactNode;
@@ -1,8 +1,9 @@
1
1
  import React from 'react';
2
2
  import './dropdown.scss';
3
3
  import { LunaticComponentProps } from '../../type';
4
+ import { ComboBoxOption } from '../../commons/components/combo-box/combo-box.type';
4
5
  export type DropdownProps = {
5
- onSelect: (v: string | null) => void;
6
+ onSelect: (value: string | ComboBoxOption | null) => void;
6
7
  className?: string;
7
8
  } & Pick<LunaticComponentProps<'Dropdown'>, 'id' | 'disabled' | 'options' | 'writable' | 'value' | 'description' | 'label' | 'errors'>;
8
9
  declare const _default: React.ComponentType<DropdownProps>;
@@ -9,5 +9,5 @@ type Props = {
9
9
  max?: number;
10
10
  decimals?: number;
11
11
  };
12
- declare const InputNumberThousand: ({ id, value, onChange, disabled, labelId, min, max, decimals, }: Props) => import("react/jsx-runtime").JSX.Element;
12
+ declare const InputNumberThousand: ({ id, onChange, value, disabled, required, labelId, min, max, decimals, }: Props) => import("react/jsx-runtime").JSX.Element;
13
13
  export default InputNumberThousand;
@@ -1,6 +1,6 @@
1
1
  import { ReactNode } from 'react';
2
- import './input-number.scss';
3
2
  import { LunaticBaseProps } from '../../type';
3
+ import './input-number.scss';
4
4
  type Props = {
5
5
  id?: string;
6
6
  onChange?: (n: number | null) => void;
@@ -14,6 +14,7 @@ type Props = {
14
14
  label?: ReactNode;
15
15
  description?: string;
16
16
  unit?: string;
17
+ dynamicUnit?: ReactNode;
17
18
  errors?: LunaticBaseProps['errors'];
18
19
  };
19
20
  declare const _default: import("react").ComponentType<Props>;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- declare const BlockForLoopOrchestrator: ({ id, components, nbRows, valueMap, handleChange, features, missing, shortcut, preferences, executeExpression, iteration, xAxisIterations, errors, }: {
2
+ declare const BlockForLoopOrchestrator: ({ id, components, nbRows, valueMap, handleChange, features, missing, shortcut, preferences, executeExpression, getSuggesterStatus, iteration, xAxisIterations, errors, }: {
3
3
  nbRows: number;
4
4
  xAxisIterations?: number | undefined;
5
5
  handleChange: (response: {
@@ -25,6 +25,10 @@ declare const BlockForLoopOrchestrator: ({ id, components, nbRows, valueMap, han
25
25
  logging?: import("../../../use-lunatic/commons/execute-expression/create-execute-expression").ExpressionLogger | undefined;
26
26
  bindingDependencies?: string[] | undefined;
27
27
  } | undefined) => T;
28
+ getSuggesterStatus?: ((name: string | undefined) => {
29
+ status: import("../../../use-lunatic/use-suggesters").SuggesterStatus;
30
+ timestamp: number;
31
+ }) | undefined;
28
32
  iteration?: number | undefined;
29
33
  linksIterations?: [number, number] | undefined;
30
34
  features?: string[] | undefined;
@@ -41,10 +45,14 @@ declare const BlockForLoopOrchestrator: ({ id, components, nbRows, valueMap, han
41
45
  logging?: import("../../../use-lunatic/commons/execute-expression/create-execute-expression").ExpressionLogger | undefined;
42
46
  bindingDependencies?: string[] | undefined;
43
47
  } | undefined) => T;
48
+ getSuggesterStatus: (name: string) => {
49
+ status: import("../../../use-lunatic/use-suggesters").SuggesterStatus;
50
+ timestamp: number;
51
+ };
44
52
  value: Record<string, unknown[]>;
45
- headers?: {
53
+ header?: {
46
54
  label: import("react").ReactNode;
47
55
  }[] | undefined;
48
56
  paginatedLoop?: boolean | undefined;
49
- }, "id" | "preferences" | "missing" | "errors" | "shortcut">, "id" | "components" | "iteration" | "executeExpression" | "features" | "preferences" | "missing" | "errors" | "shortcut" | "valueMap">) => import("react/jsx-runtime").JSX.Element | null;
57
+ }, "id" | "preferences" | "missing" | "errors" | "shortcut">, "id" | "components" | "iteration" | "executeExpression" | "features" | "preferences" | "missing" | "errors" | "shortcut" | "getSuggesterStatus" | "valueMap">) => import("react/jsx-runtime").JSX.Element | null;
50
58
  export default BlockForLoopOrchestrator;
@@ -12,8 +12,12 @@ declare const _default: React.ComponentType<import("../../type").LunaticBaseProp
12
12
  logging?: import("../../../use-lunatic/commons/execute-expression/create-execute-expression").ExpressionLogger | undefined;
13
13
  bindingDependencies?: string[] | undefined;
14
14
  } | undefined) => T;
15
+ getSuggesterStatus: (name: string) => {
16
+ status: import("../../../use-lunatic/use-suggesters").SuggesterStatus;
17
+ timestamp: number;
18
+ };
15
19
  value: Record<string, unknown[]>;
16
- headers?: {
20
+ header?: {
17
21
  label: React.ReactNode;
18
22
  }[] | undefined;
19
23
  paginatedLoop?: boolean | undefined;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- declare const RosterForLoopOrchestrator: ({ id, components, nbRows, valueMap, handleChange, features, missing, shortcut, preferences, executeExpression, iteration, xAxisIterations, errors, }: {
2
+ declare const RosterForLoopOrchestrator: ({ id, components, nbRows, valueMap, handleChange, features, missing, shortcut, preferences, executeExpression, getSuggesterStatus, iteration, xAxisIterations, errors, }: {
3
3
  nbRows: number;
4
4
  xAxisIterations?: number | undefined;
5
5
  handleChange: (response: {
@@ -25,6 +25,10 @@ declare const RosterForLoopOrchestrator: ({ id, components, nbRows, valueMap, ha
25
25
  logging?: import("../../../use-lunatic/commons/execute-expression/create-execute-expression").ExpressionLogger | undefined;
26
26
  bindingDependencies?: string[] | undefined;
27
27
  } | undefined) => T;
28
+ getSuggesterStatus?: ((name: string | undefined) => {
29
+ status: import("../../../use-lunatic/use-suggesters").SuggesterStatus;
30
+ timestamp: number;
31
+ }) | undefined;
28
32
  iteration?: number | undefined;
29
33
  linksIterations?: [number, number] | undefined;
30
34
  features?: string[] | undefined;
@@ -41,10 +45,14 @@ declare const RosterForLoopOrchestrator: ({ id, components, nbRows, valueMap, ha
41
45
  logging?: import("../../../use-lunatic/commons/execute-expression/create-execute-expression").ExpressionLogger | undefined;
42
46
  bindingDependencies?: string[] | undefined;
43
47
  } | undefined) => T;
48
+ getSuggesterStatus: (name: string) => {
49
+ status: import("../../../use-lunatic/use-suggesters").SuggesterStatus;
50
+ timestamp: number;
51
+ };
44
52
  value: Record<string, unknown[]>;
45
- headers?: {
53
+ header?: {
46
54
  label: import("react").ReactNode;
47
55
  }[] | undefined;
48
56
  paginatedLoop?: boolean | undefined;
49
- }, "id" | "preferences" | "missing" | "errors" | "shortcut">, "id" | "components" | "iteration" | "executeExpression" | "features" | "preferences" | "missing" | "errors" | "shortcut" | "valueMap">) => import("react/jsx-runtime").JSX.Element | null;
57
+ }, "id" | "preferences" | "missing" | "errors" | "shortcut">, "id" | "components" | "iteration" | "executeExpression" | "features" | "preferences" | "missing" | "errors" | "shortcut" | "getSuggesterStatus" | "valueMap">) => import("react/jsx-runtime").JSX.Element | null;
50
58
  export default RosterForLoopOrchestrator;
@@ -1,5 +1,5 @@
1
- import React from 'react';
2
- declare const _default: React.ComponentType<import("../../type").LunaticBaseProps<unknown> & {
1
+ /// <reference types="react" />
2
+ declare const _default: import("react").ComponentType<import("../../type").LunaticBaseProps<unknown> & {
3
3
  lines: {
4
4
  min: number;
5
5
  max: number;
@@ -12,9 +12,13 @@ declare const _default: React.ComponentType<import("../../type").LunaticBaseProp
12
12
  logging?: import("../../../use-lunatic/commons/execute-expression/create-execute-expression").ExpressionLogger | undefined;
13
13
  bindingDependencies?: string[] | undefined;
14
14
  } | undefined) => T;
15
+ getSuggesterStatus: (name: string) => {
16
+ status: import("../../../use-lunatic/use-suggesters").SuggesterStatus;
17
+ timestamp: number;
18
+ };
15
19
  value: Record<string, unknown[]>;
16
- headers?: {
17
- label: React.ReactNode;
20
+ header?: {
21
+ label: import("react").ReactNode;
18
22
  }[] | undefined;
19
23
  paginatedLoop?: boolean | undefined;
20
24
  }>;
@@ -1,5 +1,5 @@
1
- import './roster.scss';
2
1
  import { LunaticComponentProps } from '../../type';
2
+ import './roster.scss';
3
3
  type Props = {
4
4
  nbRows: number;
5
5
  handleChange: (response: {
@@ -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' | '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;
11
+ } & Pick<LunaticComponentProps<'RosterForLoop'>, 'id' | 'components' | 'executeExpression' | 'header' | 'value' | 'missing' | 'errors' | 'getSuggesterStatus'>;
12
+ declare function RosterTable({ components, nbRows, executeExpression, getSuggesterStatus, id, header, value: valueMap, missing, handleChange, }: Props): import("react/jsx-runtime").JSX.Element;
13
13
  export default RosterTable;
@@ -1,5 +1,5 @@
1
+ import { LunaticComponentDefinition, LunaticState } from '../../../use-lunatic/type';
1
2
  import { LunaticBaseProps } from '../../type';
2
- import { LunaticComponentDefinition } from '../../../use-lunatic/type';
3
3
  type Props = {
4
4
  id: string;
5
5
  valueMap?: Record<string, unknown>;
@@ -14,10 +14,11 @@ type Props = {
14
14
  missing?: LunaticBaseProps['missing'];
15
15
  management?: LunaticBaseProps['management'];
16
16
  executeExpression: LunaticBaseProps['executeExpression'];
17
+ getSuggesterStatus: LunaticState['getSuggesterStatus'];
17
18
  errors?: LunaticBaseProps['errors'];
18
19
  components: LunaticComponentDefinition[];
19
20
  preferences?: LunaticBaseProps['preferences'];
20
21
  shortcut?: LunaticBaseProps['shortcut'];
21
22
  };
22
- declare function Row({ id, components, valueMap, rowIndex, handleChange, features, missing, shortcut, management, preferences, executeExpression, errors, }: Props): import("react/jsx-runtime").JSX.Element;
23
+ declare function Row({ id, components, valueMap, rowIndex, handleChange, features, missing, shortcut, management, preferences, executeExpression, getSuggesterStatus, errors, }: Props): import("react/jsx-runtime").JSX.Element;
23
24
  export default Row;
@@ -1,12 +1,12 @@
1
- import React, { ReactNode } from 'react';
2
- import './default-style.scss';
1
+ import { ReactNode } from 'react';
3
2
  import { LunaticError } from '../../../use-lunatic/type';
4
3
  import { ComboBoxOption } from '../../commons/components/combo-box/combo-box.type';
5
4
  import { LunaticComponentProps } from '../../type';
5
+ import './default-style.scss';
6
6
  type Props = {
7
7
  className?: string;
8
8
  placeholder?: string;
9
- onSelect?: (s: string | null) => void;
9
+ onSelect?: (s: ComboBoxOption | null | string) => void;
10
10
  value: string | null;
11
11
  labelRenderer: LunaticComponentProps<'Suggester'>['labelRenderer'];
12
12
  optionRenderer: LunaticComponentProps<'Suggester'>['optionRenderer'];
@@ -18,6 +18,8 @@ type Props = {
18
18
  label?: ReactNode;
19
19
  description?: ReactNode;
20
20
  errors?: Record<string, LunaticError[]>;
21
+ responses?: any;
22
+ response?: any;
21
23
  };
22
- declare const _default: React.ComponentType<Props>;
24
+ declare const _default: import("react").ComponentType<Props>;
23
25
  export default _default;
@@ -1,6 +1,7 @@
1
+ import { ComboBoxOption } from '../../commons/components/combo-box/combo-box.type';
1
2
  import { LunaticComponentProps } from '../../type';
2
- type Props = Pick<LunaticComponentProps<'Suggester'>, 'storeName' | 'idbVersion' | 'id' | 'className' | 'optionRenderer' | 'labelRenderer' | 'disabled' | 'value' | 'label' | 'description' | 'getSuggesterStatus' | 'errors'> & {
3
- onSelect: (v: string | null) => void;
3
+ type Props = Pick<LunaticComponentProps<'Suggester'>, 'storeName' | 'idbVersion' | 'id' | 'className' | 'optionRenderer' | 'labelRenderer' | 'disabled' | 'value' | 'label' | 'description' | 'getSuggesterStatus' | 'errors' | 'response' | 'responses'> & {
4
+ onSelect: (v: ComboBoxOption | null) => void;
4
5
  };
5
- export declare function IDBSuggester({ storeName, idbVersion, id, className, optionRenderer, labelRenderer, onSelect, disabled, value, label, description, getSuggesterStatus, errors, }: Props): import("react/jsx-runtime").JSX.Element;
6
+ export declare function IDBSuggester({ storeName, idbVersion, id, className, optionRenderer, labelRenderer, onSelect, disabled, value, label, description, getSuggesterStatus, errors, responses, response, }: Props): import("react/jsx-runtime").JSX.Element;
6
7
  export {};
@@ -1,3 +1,3 @@
1
1
  import { LunaticComponentProps } from '../type';
2
- declare function LunaticSuggester({ id, storeName, optionRenderer, labelRenderer, idbVersion, focused, value, handleChange, disabled, errors, label, description, preferences, declarations, missing, missingResponse, management, response, getSuggesterStatus, }: LunaticComponentProps<'Suggester'>): import("react/jsx-runtime").JSX.Element;
2
+ declare function LunaticSuggester({ id, storeName, optionRenderer, labelRenderer, idbVersion, focused, value, handleChange, disabled, errors, label, description, preferences, declarations, missing, missingResponse, management, response, responses, getSuggesterStatus, }: LunaticComponentProps<'Suggester'>): import("react/jsx-runtime").JSX.Element;
3
3
  export default LunaticSuggester;
@@ -1,7 +1,7 @@
1
- import { LunaticComponentDefinition, LunaticError, LunaticExpression, LunaticState } from '../use-lunatic/type';
2
1
  import { CSSProperties, FunctionComponent, ReactNode } from 'react';
3
- import { SuggesterStatus } from '../use-lunatic/use-suggesters';
4
2
  import useLunatic from '../use-lunatic';
3
+ import { LunaticComponentDefinition, LunaticError, LunaticExpression, LunaticState } from '../use-lunatic/type';
4
+ import { SuggesterStatus } from '../use-lunatic/use-suggesters';
5
5
  export type LunaticBaseProps<ValueType = unknown> = {
6
6
  id: string;
7
7
  handleChange: (response: {
@@ -38,6 +38,10 @@ export type LunaticBaseProps<ValueType = unknown> = {
38
38
  componentType?: string;
39
39
  questionContext?: ReactNode;
40
40
  questionInformation?: ReactNode;
41
+ getSuggesterStatus?: (name: string) => {
42
+ status: SuggesterStatus;
43
+ timestamp: number;
44
+ };
41
45
  };
42
46
  export type SuggesterOption = {
43
47
  children?: string[];
@@ -58,6 +62,7 @@ type ComponentPropsByType = {
58
62
  max: number;
59
63
  decimals: number;
60
64
  unit?: string;
65
+ dynamicUnit?: ReactNode;
61
66
  response: {
62
67
  name: string;
63
68
  };
@@ -83,8 +88,12 @@ type ComponentPropsByType = {
83
88
  iterations?: number;
84
89
  components: LunaticComponentDefinition[];
85
90
  executeExpression: LunaticState['executeExpression'];
91
+ getSuggesterStatus: (name: string) => {
92
+ status: SuggesterStatus;
93
+ timestamp: number;
94
+ };
86
95
  value: Record<string, unknown[]>;
87
- headers?: Array<{
96
+ header?: Array<{
88
97
  label: ReactNode;
89
98
  }>;
90
99
  paginatedLoop?: boolean;
@@ -97,8 +106,12 @@ type ComponentPropsByType = {
97
106
  iterations?: number;
98
107
  components: LunaticComponentDefinition[];
99
108
  executeExpression: LunaticState['executeExpression'];
109
+ getSuggesterStatus: (name: string) => {
110
+ status: SuggesterStatus;
111
+ timestamp: number;
112
+ };
100
113
  value: Record<string, unknown[]>;
101
- headers?: Array<{
114
+ header?: Array<{
102
115
  label: ReactNode;
103
116
  }>;
104
117
  paginatedLoop?: boolean;
@@ -198,6 +211,7 @@ type ComponentPropsByType = {
198
211
  name: string;
199
212
  };
200
213
  writable?: boolean;
214
+ onSelect?: any;
201
215
  };
202
216
  Textarea: LunaticBaseProps<string> & {
203
217
  cols?: number;
@@ -236,9 +250,15 @@ type ComponentPropsByType = {
236
250
  }>;
237
251
  idbVersion?: string;
238
252
  focused: boolean;
239
- response: {
253
+ response?: {
240
254
  name: string;
241
255
  };
256
+ responses?: Array<{
257
+ id: string;
258
+ response: {
259
+ name: string;
260
+ };
261
+ }>;
242
262
  };
243
263
  };
244
264
  export type LunaticComponentType = keyof ComponentPropsByType;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Hook for debug purpose that log the data that changed between 2 renders
3
+ */
4
+ export declare function useDidChange(obj: Record<string, unknown>, suffix?: string): void;