@inseefr/lunatic 3.4.8 → 3.4.10-rc.0
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/CheckboxGroup/CheckboxGroup.js +3 -1
- package/components/CheckboxGroup/CheckboxGroup.js.map +1 -1
- package/components/CheckboxGroup/CustomCheckboxGroup.d.ts +1 -1
- package/components/CheckboxGroup/CustomCheckboxGroup.js +2 -5
- package/components/CheckboxGroup/CustomCheckboxGroup.js.map +1 -1
- package/components/CheckboxOne/CheckboxOne.js +3 -1
- package/components/CheckboxOne/CheckboxOne.js.map +1 -1
- package/components/Datepicker/Datepicker.js +7 -1
- package/components/Datepicker/Datepicker.js.map +1 -1
- package/components/Input/Input.js +3 -1
- package/components/Input/Input.js.map +1 -1
- package/components/InputNumber/InputNumber.spec.js +12 -0
- package/components/InputNumber/InputNumber.spec.js.map +1 -1
- package/components/InputNumber/InputNumberThousand.js +3 -1
- package/components/InputNumber/InputNumberThousand.js.map +1 -1
- package/components/Radio/Radio.d.ts +1 -0
- package/components/Radio/Radio.js +3 -1
- package/components/Radio/Radio.js.map +1 -1
- package/components/library.d.ts +1 -0
- package/components/shared/Checkbox/CheckboxOption.d.ts +4 -0
- package/components/shared/Checkbox/CheckboxOption.js +4 -2
- package/components/shared/Checkbox/CheckboxOption.js.map +1 -1
- package/components/shared/Checkbox/CheckboxOption.spec.js +14 -0
- package/components/shared/Checkbox/CheckboxOption.spec.js.map +1 -1
- package/components/shared/Radio/RadioGroup.d.ts +1 -1
- package/components/shared/Radio/RadioGroup.js +2 -2
- package/components/shared/Radio/RadioGroup.js.map +1 -1
- package/components/shared/Radio/RadioOption.d.ts +1 -0
- package/components/shared/Radio/RadioOption.js +2 -2
- package/components/shared/Radio/RadioOption.js.map +1 -1
- package/components/shared/Radio/RadioOption.spec.js +12 -0
- package/components/shared/Radio/RadioOption.spec.js.map +1 -1
- package/components/type.d.ts +3 -0
- package/esm/components/CheckboxGroup/CheckboxGroup.js +3 -1
- package/esm/components/CheckboxGroup/CheckboxGroup.js.map +1 -1
- package/esm/components/CheckboxGroup/CustomCheckboxGroup.d.ts +1 -1
- package/esm/components/CheckboxGroup/CustomCheckboxGroup.js +2 -6
- package/esm/components/CheckboxGroup/CustomCheckboxGroup.js.map +1 -1
- package/esm/components/CheckboxOne/CheckboxOne.js +3 -1
- package/esm/components/CheckboxOne/CheckboxOne.js.map +1 -1
- package/esm/components/Datepicker/Datepicker.js +7 -1
- package/esm/components/Datepicker/Datepicker.js.map +1 -1
- package/esm/components/Input/Input.js +3 -1
- package/esm/components/Input/Input.js.map +1 -1
- package/esm/components/InputNumber/InputNumber.spec.js +12 -0
- package/esm/components/InputNumber/InputNumber.spec.js.map +1 -1
- package/esm/components/InputNumber/InputNumberThousand.js +3 -1
- package/esm/components/InputNumber/InputNumberThousand.js.map +1 -1
- package/esm/components/Radio/Radio.d.ts +1 -0
- package/esm/components/Radio/Radio.js +3 -1
- package/esm/components/Radio/Radio.js.map +1 -1
- package/esm/components/library.d.ts +1 -0
- package/esm/components/shared/Checkbox/CheckboxOption.d.ts +4 -0
- package/esm/components/shared/Checkbox/CheckboxOption.js +5 -3
- package/esm/components/shared/Checkbox/CheckboxOption.js.map +1 -1
- package/esm/components/shared/Checkbox/CheckboxOption.spec.js +14 -0
- package/esm/components/shared/Checkbox/CheckboxOption.spec.js.map +1 -1
- package/esm/components/shared/Radio/RadioGroup.d.ts +1 -1
- package/esm/components/shared/Radio/RadioGroup.js +2 -2
- package/esm/components/shared/Radio/RadioGroup.js.map +1 -1
- package/esm/components/shared/Radio/RadioOption.d.ts +1 -0
- package/esm/components/shared/Radio/RadioOption.js +2 -2
- package/esm/components/shared/Radio/RadioOption.js.map +1 -1
- package/esm/components/shared/Radio/RadioOption.spec.js +12 -0
- package/esm/components/shared/Radio/RadioOption.spec.js.map +1 -1
- package/esm/components/type.d.ts +3 -0
- package/esm/main.css +5 -2
- package/esm/main.css.map +1 -1
- package/esm/use-lunatic/commons/fill-components/fill-components.d.ts +1 -0
- package/esm/use-lunatic/commons/fill-components/fill-components.js +1 -1
- package/esm/use-lunatic/commons/fill-components/fill-components.js.map +1 -1
- package/esm/use-lunatic/commons/page.js +4 -1
- package/esm/use-lunatic/commons/page.js.map +1 -1
- package/esm/use-lunatic/lunatic-context.d.ts +7 -1
- package/esm/use-lunatic/lunatic-context.js +7 -1
- package/esm/use-lunatic/lunatic-context.js.map +1 -1
- package/esm/use-lunatic/props/getComponentTypeProps.d.ts +3 -0
- package/esm/use-lunatic/props/propOptions.d.ts +1 -1
- package/esm/use-lunatic/props/propOptions.js.map +1 -1
- package/esm/use-lunatic/reducer/reducerInitializer.d.ts +2 -1
- package/esm/use-lunatic/reducer/reducerInitializer.js +3 -1
- package/esm/use-lunatic/reducer/reducerInitializer.js.map +1 -1
- package/esm/use-lunatic/type.d.ts +7 -0
- package/esm/use-lunatic/use-lunatic.js +11 -3
- package/esm/use-lunatic/use-lunatic.js.map +1 -1
- package/main.css +5 -2
- package/main.css.map +1 -1
- package/package.json +6 -1
- package/src/components/CheckboxGroup/CheckboxGroup.tsx +3 -0
- package/src/components/CheckboxGroup/CustomCheckboxGroup.tsx +3 -14
- package/src/components/CheckboxOne/CheckboxOne.tsx +3 -0
- package/src/components/Datepicker/Datepicker.tsx +8 -1
- package/src/components/Input/Input.tsx +4 -0
- package/src/components/Input/__snapshots__/Input.spec.tsx.snap +2 -0
- package/src/components/InputNumber/InputNumber.spec.tsx +20 -0
- package/src/components/InputNumber/InputNumberThousand.tsx +4 -0
- package/src/components/InputNumber/__snapshots__/InputNumber.spec.tsx.snap +2 -0
- package/src/components/Radio/Radio.tsx +3 -0
- package/src/components/RosterForLoop/__snapshots__/RosterForLoop.spec.tsx.snap +2 -0
- package/src/components/shared/Checkbox/CheckboxOption.spec.tsx +21 -0
- package/src/components/shared/Checkbox/CheckboxOption.tsx +54 -33
- package/src/components/shared/Radio/RadioGroup.tsx +3 -0
- package/src/components/shared/Radio/RadioOption.spec.tsx +36 -0
- package/src/components/shared/Radio/RadioOption.tsx +5 -1
- package/src/components/type.ts +3 -0
- package/src/css/components/CheckboxOne.scss +1 -1
- package/src/css/components/CheckboxOption.scss +14 -18
- package/src/css/components/Combobox.scss +3 -2
- package/src/css/components/Datepicker.scss +8 -8
- package/src/css/components/Declarations.scss +1 -1
- package/src/css/components/Dragger.scss +6 -6
- package/src/css/components/Duration.scss +4 -4
- package/src/css/components/IconButton.scss +4 -2
- package/src/css/components/Input.scss +3 -0
- package/src/css/components/Missing.scss +1 -1
- package/src/css/components/Roundabout.scss +3 -3
- package/src/css/components/Suggester.scss +2 -2
- package/src/css/components/Table.scss +9 -7
- package/src/css/main.scss +167 -167
- package/src/stories/behaviour/filter/dataLoop.json +22 -0
- package/src/stories/behaviour/filter/filter.stories.jsx +36 -0
- package/src/stories/behaviour/filter/source.json +238 -0
- package/src/stories/behaviour/filter/sourceLoop.json +372 -0
- package/src/stories/behaviour/missing/missing.stories.jsx +9 -0
- package/src/stories/behaviour/paste/test.stories.jsx +5 -0
- package/src/stories/checkbox-group/checkbox-group.stories.jsx +25 -6
- package/src/stories/checkbox-one/checkboxOne.stories.jsx +24 -2
- package/src/stories/overview/overview.stories.jsx +8 -1
- package/src/stories/radio/radio.stories.jsx +46 -6
- package/src/stories/utils/default-arg-types.js +12 -1
- package/src/stories/utils/default-args.js +3 -0
- package/src/stories/utils/orchestrator.jsx +8 -1
- package/src/stories/utils/orchestrator.scss +9 -7
- package/src/stories/utils/overview.scss +0 -1
- package/src/use-lunatic/commons/fill-components/fill-components.ts +4 -1
- package/src/use-lunatic/commons/page.ts +4 -1
- package/src/use-lunatic/lunatic-context.tsx +9 -0
- package/src/use-lunatic/props/propOptions.ts +2 -1
- package/src/use-lunatic/reducer/reducerInitializer.tsx +4 -0
- package/src/use-lunatic/type.ts +5 -0
- package/src/use-lunatic/use-lunatic.test.ts +68 -1
- package/src/use-lunatic/use-lunatic.ts +10 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/use-lunatic/commons/fill-components/fill-components.d.ts +1 -0
- package/use-lunatic/commons/fill-components/fill-components.js +1 -1
- package/use-lunatic/commons/fill-components/fill-components.js.map +1 -1
- package/use-lunatic/commons/page.js +4 -1
- package/use-lunatic/commons/page.js.map +1 -1
- package/use-lunatic/lunatic-context.d.ts +7 -1
- package/use-lunatic/lunatic-context.js +9 -2
- package/use-lunatic/lunatic-context.js.map +1 -1
- package/use-lunatic/props/getComponentTypeProps.d.ts +3 -0
- package/use-lunatic/props/propOptions.d.ts +1 -1
- package/use-lunatic/props/propOptions.js.map +1 -1
- package/use-lunatic/reducer/reducerInitializer.d.ts +2 -1
- package/use-lunatic/reducer/reducerInitializer.js +3 -1
- package/use-lunatic/reducer/reducerInitializer.js.map +1 -1
- package/use-lunatic/type.d.ts +7 -0
- package/use-lunatic/use-lunatic.js +11 -3
- package/use-lunatic/use-lunatic.js.map +1 -1
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
.story-with-sidebar aside label {
|
|
19
19
|
display: block;
|
|
20
20
|
font-weight: bold;
|
|
21
|
-
margin-bottom: .3em;
|
|
21
|
+
margin-bottom: 0.3em;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
.story-with-sidebar aside {
|
|
@@ -26,7 +26,9 @@
|
|
|
26
26
|
grid-template-columns: 1fr;
|
|
27
27
|
gap: 1rem;
|
|
28
28
|
padding: 1rem;
|
|
29
|
-
box-shadow:
|
|
29
|
+
box-shadow:
|
|
30
|
+
0 4px 3px rgba(0, 0, 0, 0.07),
|
|
31
|
+
0px 2px 2px rgba(0, 0, 0, 0.06);
|
|
30
32
|
background-color: #f1f5f9;
|
|
31
33
|
|
|
32
34
|
.pagination {
|
|
@@ -36,8 +38,8 @@
|
|
|
36
38
|
|
|
37
39
|
.story-pager h3 {
|
|
38
40
|
font-size: 1rem;
|
|
39
|
-
padding-bottom: .3rem;
|
|
40
|
-
margin-bottom: .5rem;
|
|
41
|
+
padding-bottom: 0.3rem;
|
|
42
|
+
margin-bottom: 0.5rem;
|
|
41
43
|
border-bottom: solid 1px rgba(0, 0, 0, 0.3);
|
|
42
44
|
}
|
|
43
45
|
|
|
@@ -46,7 +48,7 @@
|
|
|
46
48
|
padding: 0 0 0 20px;
|
|
47
49
|
line-height: 1.4;
|
|
48
50
|
font-size: 0.9rem;
|
|
49
|
-
color: rgba(0, 0, 0, 0.75)
|
|
51
|
+
color: rgba(0, 0, 0, 0.75);
|
|
50
52
|
}
|
|
51
53
|
|
|
52
54
|
.story-pager ul strong {
|
|
@@ -57,8 +59,8 @@
|
|
|
57
59
|
color: #721c24;
|
|
58
60
|
background-color: #f8d7da;
|
|
59
61
|
position: relative;
|
|
60
|
-
padding: .75rem 1.25rem;
|
|
62
|
+
padding: 0.75rem 1.25rem;
|
|
61
63
|
margin-bottom: 1rem;
|
|
62
64
|
border: 1px solid #f5c6cb;
|
|
63
|
-
border-radius: .25rem;
|
|
65
|
+
border-radius: 0.25rem;
|
|
64
66
|
}
|
|
@@ -14,6 +14,7 @@ import { getIterationsProp } from '../../props/propIterations';
|
|
|
14
14
|
import { getOptionsProp } from '../../props/propOptions';
|
|
15
15
|
|
|
16
16
|
type FillComponentArgs = {
|
|
17
|
+
disableFilters?: boolean;
|
|
17
18
|
handleChanges: LunaticChangesHandler;
|
|
18
19
|
executeExpression: LunaticReducerState['executeExpression'];
|
|
19
20
|
goToPage: LunaticState['goToPage'];
|
|
@@ -71,5 +72,7 @@ export function fillComponents(
|
|
|
71
72
|
): LunaticComponentProps[] {
|
|
72
73
|
return components
|
|
73
74
|
.map((component) => fillComponent(component, state))
|
|
74
|
-
.filter(
|
|
75
|
+
.filter(
|
|
76
|
+
({ conditionFilter }) => state.disableFilters || (conditionFilter ?? true)
|
|
77
|
+
);
|
|
75
78
|
}
|
|
@@ -24,10 +24,13 @@ export function pageStringToNumbers(page: string): number[] {
|
|
|
24
24
|
* if no components can be displayed on this page (using filter)
|
|
25
25
|
*/
|
|
26
26
|
export function isPageEmpty(state: LunaticReducerState): boolean {
|
|
27
|
-
const { executeExpression, pager } = state;
|
|
27
|
+
const { executeExpression, pager, options } = state;
|
|
28
28
|
const { iteration } = pager;
|
|
29
29
|
const components = getComponentsFromState(state);
|
|
30
30
|
const visibleComponents = components.filter((component) => {
|
|
31
|
+
if (options.disableFilters) {
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
31
34
|
if ('conditionFilter' in component && component.conditionFilter) {
|
|
32
35
|
return executeConditionFilter(
|
|
33
36
|
component.conditionFilter,
|
|
@@ -15,6 +15,7 @@ const LunaticContext = createContext({
|
|
|
15
15
|
missingShortcut: { dontKnow: '', refused: '' },
|
|
16
16
|
dontKnowButton: D.DK,
|
|
17
17
|
refusedButton: D.RF,
|
|
18
|
+
componentsOptions: { detailAlwaysDisplayed: false },
|
|
18
19
|
});
|
|
19
20
|
/** Provide `missing` `missingStrategy`, `shortcut` and `missingShortcut`, `dontKnowButton`, `refusedButton` to Missing component
|
|
20
21
|
* to manage non-response buttons and shortcut */
|
|
@@ -37,6 +38,11 @@ export const useLunaticMissing = () => {
|
|
|
37
38
|
};
|
|
38
39
|
};
|
|
39
40
|
|
|
41
|
+
export const useLunaticComponentsOptions = () => {
|
|
42
|
+
const { componentsOptions } = useContext(LunaticContext);
|
|
43
|
+
return componentsOptions;
|
|
44
|
+
};
|
|
45
|
+
|
|
40
46
|
/** Provide `management` to display data states [COLLECTED,EDITED,FORCED] */
|
|
41
47
|
export const useLunaticManagement = () => {
|
|
42
48
|
return useContext(LunaticContext).management;
|
|
@@ -50,6 +56,7 @@ export function createLunaticProvider({
|
|
|
50
56
|
missingShortcut,
|
|
51
57
|
dontKnowButton,
|
|
52
58
|
refusedButton,
|
|
59
|
+
componentsOptions,
|
|
53
60
|
}: {
|
|
54
61
|
management: boolean;
|
|
55
62
|
missing: boolean;
|
|
@@ -58,6 +65,7 @@ export function createLunaticProvider({
|
|
|
58
65
|
missingShortcut: { dontKnow: string; refused: string };
|
|
59
66
|
dontKnowButton: string;
|
|
60
67
|
refusedButton: string;
|
|
68
|
+
componentsOptions: { detailAlwaysDisplayed: boolean };
|
|
61
69
|
}): FunctionComponent<PropsWithChildren> {
|
|
62
70
|
const value = {
|
|
63
71
|
management,
|
|
@@ -67,6 +75,7 @@ export function createLunaticProvider({
|
|
|
67
75
|
missingShortcut,
|
|
68
76
|
dontKnowButton,
|
|
69
77
|
refusedButton,
|
|
78
|
+
componentsOptions,
|
|
70
79
|
};
|
|
71
80
|
return function Provider({ children }: PropsWithChildren) {
|
|
72
81
|
return (
|
|
@@ -8,12 +8,13 @@ import type { DeepTranslateExpression } from '../commons/fill-components/fill-co
|
|
|
8
8
|
import { isNumber } from '../../utils/number';
|
|
9
9
|
import type { LunaticVariablesStore } from '../commons/variables/lunatic-variables-store';
|
|
10
10
|
|
|
11
|
+
/* Used for radio option and checkbox one option */
|
|
11
12
|
export type InterpretedOption = {
|
|
12
13
|
label: ReactNode;
|
|
13
14
|
value?: string;
|
|
14
15
|
checked?: boolean;
|
|
15
|
-
detailLabel?: ReactNode;
|
|
16
16
|
description?: ReactNode;
|
|
17
|
+
detailLabel?: ReactNode;
|
|
17
18
|
detailValue?: string | null;
|
|
18
19
|
onDetailChange?: (value: string) => void;
|
|
19
20
|
onCheck?: () => void;
|
|
@@ -35,6 +35,7 @@ const baseState = {
|
|
|
35
35
|
overview: [],
|
|
36
36
|
updateBindings: () => {},
|
|
37
37
|
executeExpression: <T,>() => null as T,
|
|
38
|
+
options: { disableFilters: false },
|
|
38
39
|
} satisfies LunaticReducerState;
|
|
39
40
|
|
|
40
41
|
export function reducerInitializer({
|
|
@@ -44,6 +45,7 @@ export function reducerInitializer({
|
|
|
44
45
|
initialPage = '1',
|
|
45
46
|
lastReachedPage = undefined,
|
|
46
47
|
withOverview = false,
|
|
48
|
+
disableFilters = false,
|
|
47
49
|
getReferentiel,
|
|
48
50
|
onVariableChange,
|
|
49
51
|
logger,
|
|
@@ -54,6 +56,7 @@ export function reducerInitializer({
|
|
|
54
56
|
initialPage?: LunaticOptions['initialPage'];
|
|
55
57
|
lastReachedPage?: LunaticOptions['lastReachedPage'];
|
|
56
58
|
withOverview?: LunaticOptions['withOverview'];
|
|
59
|
+
disableFilters?: LunaticOptions['disableFilters'];
|
|
57
60
|
getReferentiel?: LunaticOptions['getReferentiel'];
|
|
58
61
|
onVariableChange: RefObject<LunaticOptions['onVariableChange']>;
|
|
59
62
|
logger: LunaticLogger;
|
|
@@ -145,6 +148,7 @@ export function reducerInitializer({
|
|
|
145
148
|
overview: withOverview ? buildOverview(source) : [],
|
|
146
149
|
updateBindings,
|
|
147
150
|
executeExpression,
|
|
151
|
+
options: { disableFilters },
|
|
148
152
|
});
|
|
149
153
|
}
|
|
150
154
|
|
package/src/use-lunatic/type.ts
CHANGED
|
@@ -131,9 +131,13 @@ export type LunaticReducerState = {
|
|
|
131
131
|
value: unknown,
|
|
132
132
|
options: { iteration?: number[] }
|
|
133
133
|
) => unknown;
|
|
134
|
+
options: {
|
|
135
|
+
disableFilters?: boolean;
|
|
136
|
+
};
|
|
134
137
|
};
|
|
135
138
|
|
|
136
139
|
export type LunaticOptions = {
|
|
140
|
+
disableFilters?: boolean;
|
|
137
141
|
features?: ('MD' | 'VTL')[];
|
|
138
142
|
preferences?: ['COLLECTED'];
|
|
139
143
|
savingType?: 'COLLECTED';
|
|
@@ -157,6 +161,7 @@ export type LunaticOptions = {
|
|
|
157
161
|
// Enable change tracking to keep a track of what variable changed (allow using getChangedData())
|
|
158
162
|
trackChanges?: boolean;
|
|
159
163
|
logger?: LunaticLogger;
|
|
164
|
+
componentsOptions?: { detailAlwaysDisplayed?: boolean };
|
|
160
165
|
};
|
|
161
166
|
|
|
162
167
|
// Type representing the return type of "useLunatic()"
|
|
@@ -11,6 +11,7 @@ import sourceCleaningLoop from '../stories/behaviour/cleaning/source-loop.json';
|
|
|
11
11
|
import sourceCleaningResizing from '../stories/behaviour/resizing/source-resizing-cleaning.json';
|
|
12
12
|
import type { LunaticData, PageTag } from './type';
|
|
13
13
|
import { useLunatic } from './use-lunatic';
|
|
14
|
+
import { useCallback } from 'react';
|
|
14
15
|
|
|
15
16
|
const dataFromObject = (o: Record<string, unknown>): LunaticData => {
|
|
16
17
|
return {
|
|
@@ -79,8 +80,22 @@ describe('use-lunatic()', () => {
|
|
|
79
80
|
|
|
80
81
|
describe('Provider', () => {
|
|
81
82
|
it('should not generate a new Provider every render', () => {
|
|
82
|
-
const { result } = renderHook(() =>
|
|
83
|
+
const { result } = renderHook(() => {
|
|
84
|
+
const missingStrategy = useCallback(() => {}, []);
|
|
85
|
+
return useLunatic(sourceSimpsons as any, undefined, {
|
|
86
|
+
management: false,
|
|
87
|
+
missing: false,
|
|
88
|
+
missingStrategy,
|
|
89
|
+
shortcut: false,
|
|
90
|
+
missingShortcut: { dontKnow: '1', refused: '2' },
|
|
91
|
+
dontKnowButton: 'DK',
|
|
92
|
+
refusedButton: 'RF',
|
|
93
|
+
componentsOptions: { detailAlwaysDisplayed: false },
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
|
|
83
97
|
const oldProvider = result.current.Provider;
|
|
98
|
+
|
|
84
99
|
act(() => {
|
|
85
100
|
result.current.goNextPage();
|
|
86
101
|
});
|
|
@@ -179,6 +194,58 @@ describe('use-lunatic()', () => {
|
|
|
179
194
|
});
|
|
180
195
|
});
|
|
181
196
|
|
|
197
|
+
describe('disable filters', () => {
|
|
198
|
+
const lunaticConfigurationWithoutDisableFilters = {
|
|
199
|
+
management: false,
|
|
200
|
+
activeControls: false,
|
|
201
|
+
initialPage: '1' as PageTag,
|
|
202
|
+
getStoreInfo: () => {},
|
|
203
|
+
missing: false,
|
|
204
|
+
shortcut: false,
|
|
205
|
+
activeGoNextForMissing: false,
|
|
206
|
+
showOverview: false,
|
|
207
|
+
filterDescription: true,
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
it('should filter out some components by default', function () {
|
|
211
|
+
const { result } = renderHook(() =>
|
|
212
|
+
useLunatic(
|
|
213
|
+
sourceLogement as any,
|
|
214
|
+
undefined,
|
|
215
|
+
lunaticConfigurationWithoutDisableFilters
|
|
216
|
+
)
|
|
217
|
+
);
|
|
218
|
+
act(() => result.current.goToPage({ page: '3' }));
|
|
219
|
+
const currentPage = result.current.pageTag;
|
|
220
|
+
expect(currentPage).not.toBe('3');
|
|
221
|
+
});
|
|
222
|
+
it('should filter out some components when false', function () {
|
|
223
|
+
const { result } = renderHook(() =>
|
|
224
|
+
useLunatic(sourceLogement as any, undefined, {
|
|
225
|
+
...lunaticConfigurationWithoutDisableFilters,
|
|
226
|
+
disableFilters: false,
|
|
227
|
+
})
|
|
228
|
+
);
|
|
229
|
+
act(() => result.current.goToPage({ page: '3' }));
|
|
230
|
+
const currentPage = result.current.pageTag;
|
|
231
|
+
expect(currentPage).not.toBe('3');
|
|
232
|
+
});
|
|
233
|
+
it('should not filter any component when true', function () {
|
|
234
|
+
const { result } = renderHook(() =>
|
|
235
|
+
useLunatic(sourceLogement as any, undefined, {
|
|
236
|
+
...lunaticConfigurationWithoutDisableFilters,
|
|
237
|
+
disableFilters: true,
|
|
238
|
+
})
|
|
239
|
+
);
|
|
240
|
+
act(() => result.current.goToPage({ page: '3' }));
|
|
241
|
+
const currentPage = result.current.pageTag;
|
|
242
|
+
expect(currentPage).toBe('3');
|
|
243
|
+
|
|
244
|
+
const components = result.current.getComponents();
|
|
245
|
+
expect(components.length).toBe(1);
|
|
246
|
+
});
|
|
247
|
+
});
|
|
248
|
+
|
|
182
249
|
describe('cleaning', () => {
|
|
183
250
|
it('should handle cleaning in a loop', () => {
|
|
184
251
|
const { result } = renderHook(() =>
|
|
@@ -42,6 +42,7 @@ const DEFAULT_DONT_KNOW = D.DK;
|
|
|
42
42
|
const DEFAULT_REFUSED = D.RF;
|
|
43
43
|
|
|
44
44
|
const defaultOptions = {
|
|
45
|
+
disableFilters: false,
|
|
45
46
|
features: DEFAULT_FEATURES,
|
|
46
47
|
preferences: DEFAULT_PREFERENCES,
|
|
47
48
|
savingType: COLLECTED,
|
|
@@ -62,6 +63,7 @@ const defaultOptions = {
|
|
|
62
63
|
refusedButton: DEFAULT_REFUSED,
|
|
63
64
|
trackChanges: false,
|
|
64
65
|
logger: ConsoleLogger,
|
|
66
|
+
componentsOptions: { detailAlwaysDisplayed: false },
|
|
65
67
|
} satisfies LunaticOptions;
|
|
66
68
|
|
|
67
69
|
export function useLunatic(
|
|
@@ -71,6 +73,7 @@ export function useLunatic(
|
|
|
71
73
|
) {
|
|
72
74
|
const options = mergeDefault(argOptions, defaultOptions);
|
|
73
75
|
const {
|
|
76
|
+
disableFilters,
|
|
74
77
|
management,
|
|
75
78
|
missing,
|
|
76
79
|
missingStrategy,
|
|
@@ -82,6 +85,7 @@ export function useLunatic(
|
|
|
82
85
|
trackChanges,
|
|
83
86
|
preferences,
|
|
84
87
|
logger,
|
|
88
|
+
componentsOptions,
|
|
85
89
|
} = options;
|
|
86
90
|
|
|
87
91
|
// Help debug with warnings for options expected to be memoized
|
|
@@ -113,15 +117,19 @@ export function useLunatic(
|
|
|
113
117
|
missingShortcut,
|
|
114
118
|
dontKnowButton,
|
|
115
119
|
refusedButton,
|
|
120
|
+
componentsOptions,
|
|
116
121
|
}),
|
|
122
|
+
/* eslint-disable-next-line react-hooks/exhaustive-deps -- object deps are not being handled very well by useMemo so we need to compare single values */
|
|
117
123
|
[
|
|
118
124
|
management,
|
|
119
125
|
missing,
|
|
120
126
|
missingStrategy,
|
|
121
127
|
shortcut,
|
|
122
|
-
missingShortcut,
|
|
128
|
+
missingShortcut.dontKnow,
|
|
129
|
+
missingShortcut.refused,
|
|
123
130
|
dontKnowButton,
|
|
124
131
|
refusedButton,
|
|
132
|
+
componentsOptions.detailAlwaysDisplayed,
|
|
125
133
|
]
|
|
126
134
|
);
|
|
127
135
|
|
|
@@ -179,6 +187,7 @@ export function useLunatic(
|
|
|
179
187
|
const { isFirstPage, isLastPage } = isFirstLastPage(state.pager);
|
|
180
188
|
|
|
181
189
|
const components = fillComponents(getComponentsFromState(state), {
|
|
190
|
+
disableFilters,
|
|
182
191
|
handleChanges,
|
|
183
192
|
preferences,
|
|
184
193
|
goToPage,
|