@inseefr/lunatic 3.6.0 → 3.6.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.
- package/components/shared/Checkbox/CheckboxOption.d.ts +1 -0
- package/components/shared/Checkbox/CheckboxOption.js +2 -2
- package/components/shared/Checkbox/CheckboxOption.js.map +1 -1
- package/components/shared/Radio/RadioOption.js +2 -2
- package/components/shared/Radio/RadioOption.js.map +1 -1
- package/components/type.d.ts +2 -1
- package/esm/components/shared/Checkbox/CheckboxOption.d.ts +1 -0
- package/esm/components/shared/Checkbox/CheckboxOption.js +2 -2
- package/esm/components/shared/Checkbox/CheckboxOption.js.map +1 -1
- package/esm/components/shared/Radio/RadioOption.js +2 -2
- package/esm/components/shared/Radio/RadioOption.js.map +1 -1
- package/esm/components/type.d.ts +2 -1
- package/esm/type.source.d.ts +3 -0
- package/esm/use-lunatic/commons/variables/behaviours/cleaning-behaviour.d.ts +7 -2
- package/esm/use-lunatic/commons/variables/behaviours/cleaning-behaviour.js +106 -33
- package/esm/use-lunatic/commons/variables/behaviours/cleaning-behaviour.js.map +1 -1
- package/esm/use-lunatic/commons/variables/get-questionnaire-data.js +2 -1
- package/esm/use-lunatic/commons/variables/get-questionnaire-data.js.map +1 -1
- package/esm/use-lunatic/commons/variables/lunatic-variables-store.js +2 -0
- package/esm/use-lunatic/commons/variables/lunatic-variables-store.js.map +1 -1
- package/esm/use-lunatic/commons/variables/lunatic-variables-store.spec.js +75 -1
- package/esm/use-lunatic/commons/variables/lunatic-variables-store.spec.js.map +1 -1
- package/esm/use-lunatic/hooks/useCallbackOnNextRender.d.ts +4 -0
- package/esm/use-lunatic/hooks/useCallbackOnNextRender.js +28 -0
- package/esm/use-lunatic/hooks/useCallbackOnNextRender.js.map +1 -0
- package/esm/use-lunatic/props/getComponentTypeProps.d.ts +2 -1
- package/esm/use-lunatic/props/propOptions.d.ts +4 -1
- package/esm/use-lunatic/props/propOptions.js +8 -6
- package/esm/use-lunatic/props/propOptions.js.map +1 -1
- package/esm/use-lunatic/props/propOptions.spec.js +68 -0
- package/esm/use-lunatic/props/propOptions.spec.js.map +1 -1
- package/esm/use-lunatic/use-lunatic.js +4 -2
- package/esm/use-lunatic/use-lunatic.js.map +1 -1
- package/package.json +9 -1
- package/src/components/shared/Checkbox/CheckboxOption.tsx +3 -0
- package/src/components/shared/Radio/RadioOption.tsx +2 -0
- package/src/components/type.ts +2 -1
- package/src/stories/questionnaires/simpsons/source.json +6 -0
- package/src/stories/utils/Orchestrator.tsx +1 -1
- package/src/type.source.ts +3 -0
- package/src/use-lunatic/commons/variables/behaviours/cleaning-behaviour.ts +120 -30
- package/src/use-lunatic/commons/variables/get-questionnaire-data.ts +4 -1
- package/src/use-lunatic/commons/variables/lunatic-variables-store.spec.ts +86 -1
- package/src/use-lunatic/commons/variables/lunatic-variables-store.ts +1 -0
- package/src/use-lunatic/hooks/useCallbackOnNextRender.test.tsx +50 -0
- package/src/use-lunatic/hooks/useCallbackOnNextRender.ts +31 -0
- package/src/use-lunatic/props/propOptions.spec.ts +88 -0
- package/src/use-lunatic/props/propOptions.ts +8 -4
- package/src/use-lunatic/use-lunatic.ts +5 -2
- package/tsconfig.build.tsbuildinfo +1 -1
- package/type.source.d.ts +3 -0
- package/use-lunatic/commons/variables/behaviours/cleaning-behaviour.d.ts +7 -2
- package/use-lunatic/commons/variables/behaviours/cleaning-behaviour.js +105 -32
- package/use-lunatic/commons/variables/behaviours/cleaning-behaviour.js.map +1 -1
- package/use-lunatic/commons/variables/get-questionnaire-data.js +2 -1
- package/use-lunatic/commons/variables/get-questionnaire-data.js.map +1 -1
- package/use-lunatic/commons/variables/lunatic-variables-store.js +2 -0
- package/use-lunatic/commons/variables/lunatic-variables-store.js.map +1 -1
- package/use-lunatic/commons/variables/lunatic-variables-store.spec.js +75 -1
- package/use-lunatic/commons/variables/lunatic-variables-store.spec.js.map +1 -1
- package/use-lunatic/hooks/useCallbackOnNextRender.d.ts +4 -0
- package/use-lunatic/hooks/useCallbackOnNextRender.js +31 -0
- package/use-lunatic/hooks/useCallbackOnNextRender.js.map +1 -0
- package/use-lunatic/props/getComponentTypeProps.d.ts +2 -1
- package/use-lunatic/props/propOptions.d.ts +4 -1
- package/use-lunatic/props/propOptions.js +5 -3
- package/use-lunatic/props/propOptions.js.map +1 -1
- package/use-lunatic/props/propOptions.spec.js +68 -0
- package/use-lunatic/props/propOptions.spec.js.map +1 -1
- package/use-lunatic/use-lunatic.js +4 -2
- package/use-lunatic/use-lunatic.js.map +1 -1
|
@@ -18,6 +18,7 @@ export type InterpretedOption = {
|
|
|
18
18
|
description?: ReactNode;
|
|
19
19
|
detailLabel?: ReactNode;
|
|
20
20
|
detailValue?: string | null;
|
|
21
|
+
detailMaxLength?: number;
|
|
21
22
|
onDetailChange?: (value: string) => void;
|
|
22
23
|
onCheck?: () => void;
|
|
23
24
|
onUncheck?: () => void;
|
|
@@ -61,6 +62,7 @@ export function getOptionsProp(
|
|
|
61
62
|
detailValue: response.detail?.response
|
|
62
63
|
? variables.get(response.detail.response.name, iteration)
|
|
63
64
|
: undefined,
|
|
65
|
+
detailMaxLength: response.detail?.maxLength,
|
|
64
66
|
onCheck: (checked: boolean) => {
|
|
65
67
|
handleChanges([{ name: response.response.name, value: checked }]);
|
|
66
68
|
},
|
|
@@ -108,6 +110,12 @@ export function getOptionsProp(
|
|
|
108
110
|
value: option.value,
|
|
109
111
|
checked: value === option.value,
|
|
110
112
|
detailLabel: 'detail' in option ? option.detail?.label : undefined,
|
|
113
|
+
detailValue:
|
|
114
|
+
'detail' in option && option.detail
|
|
115
|
+
? variables.get(option.detail.response.name, iteration)
|
|
116
|
+
: null,
|
|
117
|
+
detailMaxLength:
|
|
118
|
+
'detail' in option ? option.detail?.maxLength : undefined,
|
|
111
119
|
onCheck: () => {
|
|
112
120
|
handleChanges([
|
|
113
121
|
{ name: definition.response.name, value: option.value },
|
|
@@ -117,10 +125,6 @@ export function getOptionsProp(
|
|
|
117
125
|
onUncheck: () => {
|
|
118
126
|
handleChanges([{ name: definition.response.name, value: null }]);
|
|
119
127
|
},
|
|
120
|
-
detailValue:
|
|
121
|
-
'detail' in option && option.detail
|
|
122
|
-
? variables.get(option.detail.response.name, iteration)
|
|
123
|
-
: null,
|
|
124
128
|
onDetailChange:
|
|
125
129
|
'detail' in option && option.detail
|
|
126
130
|
? (value: string) => {
|
|
@@ -32,6 +32,7 @@ import { mergeDefault } from '../utils/object';
|
|
|
32
32
|
import { useRefSync } from '../hooks/useRefSync';
|
|
33
33
|
import { ConsoleLogger } from './logger/ConsoleLogger';
|
|
34
34
|
import { useWarnDepChange } from './hooks/useWarnDepChange';
|
|
35
|
+
import { useCallbackOnNextRender } from './hooks/useCallbackOnNextRender';
|
|
35
36
|
|
|
36
37
|
const empty = {}; // Keep the same empty object (to avoid problem with useEffect dependencies)
|
|
37
38
|
const DEFAULT_DATA = empty as LunaticData;
|
|
@@ -169,12 +170,14 @@ export function useLunatic(
|
|
|
169
170
|
[dispatch]
|
|
170
171
|
);
|
|
171
172
|
|
|
173
|
+
const onChangeAfterRender = useCallbackOnNextRender(onChange);
|
|
174
|
+
|
|
172
175
|
const handleChanges = useCallback<LunaticChangesHandler>(
|
|
173
176
|
(responses) => {
|
|
174
177
|
dispatch(handleChangesAction(responses));
|
|
175
|
-
|
|
178
|
+
onChangeAfterRender(responses);
|
|
176
179
|
},
|
|
177
|
-
[dispatch,
|
|
180
|
+
[dispatch, onChangeAfterRender]
|
|
178
181
|
);
|
|
179
182
|
|
|
180
183
|
const getData: LunaticState['getData'] = (
|