@inseefr/lunatic 3.4.8-rc.0 → 3.4.9
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 +4 -2
- 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/index.d.ts +0 -1
- package/esm/index.js +0 -1
- package/esm/index.js.map +1 -1
- package/esm/main.css +5 -2
- package/esm/main.css.map +1 -1
- package/esm/type.source.d.ts +25 -40
- package/esm/type.source.js +1 -0
- package/esm/type.source.js.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 +6 -1
- package/esm/use-lunatic/use-lunatic.js.map +1 -1
- package/esm/utils/search/SearchMiniSearch.spec.d.ts +1 -0
- package/esm/utils/search/SearchMiniSearch.spec.js +51 -0
- package/esm/utils/search/SearchMiniSearch.spec.js.map +1 -0
- package/esm/utils/search/melauto.js +1 -1
- package/esm/utils/search/melauto.spec.d.ts +1 -0
- package/esm/utils/search/melauto.spec.js +67 -0
- package/esm/utils/search/melauto.spec.js.map +1 -0
- package/esm/utils/search/tokenizer.d.ts +7 -2
- package/esm/utils/search/tokenizer.js +23 -8
- package/esm/utils/search/tokenizer.js.map +1 -1
- package/esm/utils/search/tokenizer.spec.d.ts +1 -0
- package/esm/utils/search/tokenizer.spec.js +160 -0
- package/esm/utils/search/tokenizer.spec.js.map +1 -0
- package/index.d.ts +0 -1
- package/index.js +1 -4
- package/index.js.map +1 -1
- package/main.css +5 -2
- package/main.css.map +1 -1
- package/package.json +28 -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 +19 -0
- 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/index.ts +0 -2
- 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 +11 -1
- package/src/stories/utils/orchestrator.scss +9 -7
- package/src/stories/utils/overview.scss +0 -1
- package/src/type.source.ts +93 -108
- 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 +52 -0
- package/src/use-lunatic/use-lunatic.ts +7 -0
- package/src/utils/search/SearchMiniSearch.spec.ts +58 -0
- package/src/utils/search/melauto.spec.ts +75 -0
- package/src/utils/search/melauto.ts +1 -1
- package/src/utils/search/tokenizer.spec.ts +205 -0
- package/src/utils/search/tokenizer.ts +27 -8
- package/tsconfig.build.tsbuildinfo +1 -1
- package/type.source.d.ts +25 -40
- package/type.source.js +1 -0
- package/type.source.js.map +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 +6 -1
- package/use-lunatic/use-lunatic.js.map +1 -1
- package/utils/search/SearchMiniSearch.spec.d.ts +1 -0
- package/utils/search/SearchMiniSearch.spec.js +51 -0
- package/utils/search/SearchMiniSearch.spec.js.map +1 -0
- package/utils/search/melauto.js +1 -1
- package/utils/search/melauto.spec.d.ts +1 -0
- package/utils/search/melauto.spec.js +69 -0
- package/utils/search/melauto.spec.js.map +1 -0
- package/utils/search/tokenizer.d.ts +7 -2
- package/utils/search/tokenizer.js +24 -8
- package/utils/search/tokenizer.js.map +1 -1
- package/utils/search/tokenizer.spec.d.ts +1 -0
- package/utils/search/tokenizer.spec.js +162 -0
- package/utils/search/tokenizer.spec.js.map +1 -0
|
@@ -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
|
}
|
package/src/type.source.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
1
2
|
/**
|
|
2
3
|
* This file was automatically generated by json-schema-to-typescript.
|
|
3
4
|
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
|
@@ -34,20 +35,18 @@ export type ComponentDefinition =
|
|
|
34
35
|
| ComponentSummaryDefinition
|
|
35
36
|
| ComponentText
|
|
36
37
|
| ComponentAccordion;
|
|
37
|
-
export type ComponentInputDefinition =
|
|
38
|
+
export type ComponentInputDefinition = ComponentDefinitionBaseWithResponse & {
|
|
38
39
|
componentType: 'Input' | 'Textarea';
|
|
39
40
|
maxLength?: number;
|
|
40
41
|
};
|
|
41
|
-
export type ComponentInputDefinition1 = ComponentDefinitionBaseWithResponse;
|
|
42
42
|
export type ComponentDefinitionBaseWithResponse = ComponentDefinitionBase & {
|
|
43
43
|
response: ResponseDefinition;
|
|
44
44
|
};
|
|
45
|
-
export type ComponentSequenceDefinition =
|
|
45
|
+
export type ComponentSequenceDefinition = ComponentDefinitionBase & {
|
|
46
46
|
componentType: 'Sequence' | 'Subsequence';
|
|
47
47
|
goToPage?: string;
|
|
48
48
|
};
|
|
49
|
-
export type
|
|
50
|
-
export type ComponentRoundaboutDefinition = ComponentRoundaboutDefinition1 & {
|
|
49
|
+
export type ComponentRoundaboutDefinition = ComponentDefinitionBase & {
|
|
51
50
|
componentType: 'Roundabout';
|
|
52
51
|
iterations: VTLScalarExpression;
|
|
53
52
|
locked: boolean;
|
|
@@ -59,25 +58,22 @@ export type ComponentRoundaboutDefinition = ComponentRoundaboutDefinition1 & {
|
|
|
59
58
|
};
|
|
60
59
|
components: ComponentDefinitionWithPage[];
|
|
61
60
|
};
|
|
62
|
-
export type ComponentRoundaboutDefinition1 = ComponentDefinitionBase;
|
|
63
61
|
export type ComponentLoopDefinition = {
|
|
64
62
|
componentType: 'Loop';
|
|
65
63
|
loopDependencies?: string[];
|
|
66
64
|
} & ComponentLoopDefinition1;
|
|
67
65
|
export type ComponentLoopDefinition1 = PaginatedLoop | BlockLoop;
|
|
68
|
-
export type PaginatedLoop =
|
|
66
|
+
export type PaginatedLoop = ComponentDefinitionBase & {
|
|
69
67
|
components: ComponentDefinitionWithPage[];
|
|
70
68
|
iterations: VTLScalarExpression;
|
|
71
69
|
maxPage: string;
|
|
72
70
|
paginatedLoop: true;
|
|
73
71
|
};
|
|
74
|
-
export type
|
|
75
|
-
export type BlockLoop = BlockLoop1 & {
|
|
72
|
+
export type BlockLoop = ComponentDefinitionBase & {
|
|
76
73
|
paginatedLoop: false;
|
|
77
74
|
components: ComponentDefinition[];
|
|
78
|
-
} &
|
|
79
|
-
export type BlockLoop1 =
|
|
80
|
-
export type BlockLoop2 =
|
|
75
|
+
} & BlockLoop1;
|
|
76
|
+
export type BlockLoop1 =
|
|
81
77
|
| {
|
|
82
78
|
lines: {
|
|
83
79
|
min: VTLExpression;
|
|
@@ -87,17 +83,15 @@ export type BlockLoop2 =
|
|
|
87
83
|
| {
|
|
88
84
|
iterations: VTLExpression;
|
|
89
85
|
};
|
|
90
|
-
export type ComponentRosterForLoopDefinition =
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
max: VTLScalarExpression;
|
|
97
|
-
};
|
|
98
|
-
header?: TableHeader;
|
|
86
|
+
export type ComponentRosterForLoopDefinition = ComponentDefinitionBase & {
|
|
87
|
+
componentType: 'RosterForLoop';
|
|
88
|
+
components: ComponentDefinition[];
|
|
89
|
+
lines: {
|
|
90
|
+
min: VTLScalarExpression;
|
|
91
|
+
max: VTLScalarExpression;
|
|
99
92
|
};
|
|
100
|
-
|
|
93
|
+
header?: TableHeader;
|
|
94
|
+
};
|
|
101
95
|
export type Options = {
|
|
102
96
|
value: string | boolean;
|
|
103
97
|
label: VTLExpression;
|
|
@@ -111,7 +105,7 @@ export type TableHeader = {
|
|
|
111
105
|
rowspan?: number;
|
|
112
106
|
options?: Options;
|
|
113
107
|
}[];
|
|
114
|
-
export type ComponentTableDefinition =
|
|
108
|
+
export type ComponentTableDefinition = ComponentDefinitionBase & {
|
|
115
109
|
componentType: 'Table';
|
|
116
110
|
header?: TableHeader;
|
|
117
111
|
body: (
|
|
@@ -121,57 +115,49 @@ export type ComponentTableDefinition = ComponentTableDefinition1 & {
|
|
|
121
115
|
}
|
|
122
116
|
)[][];
|
|
123
117
|
};
|
|
124
|
-
export type
|
|
125
|
-
export type ComponentNumberDefinition = ComponentNumberDefinition1 & {
|
|
118
|
+
export type ComponentNumberDefinition = ComponentDefinitionBaseWithResponse & {
|
|
126
119
|
componentType: 'InputNumber';
|
|
127
120
|
unit?: string | VTLExpression;
|
|
128
121
|
min?: number;
|
|
129
122
|
max?: number;
|
|
130
123
|
decimals?: number;
|
|
131
124
|
};
|
|
132
|
-
export type
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
};
|
|
137
|
-
export type ComponentDurationDefinition1 = ComponentDefinitionBaseWithResponse;
|
|
138
|
-
export type ComponentDatePickerDefinition = ComponentDatePickerDefinition1 & {
|
|
139
|
-
componentType: 'Datepicker';
|
|
140
|
-
dateFormat: 'YYYY-MM-DD' | 'YYYY' | 'YYYY-MM';
|
|
141
|
-
min?: string;
|
|
142
|
-
max?: string;
|
|
143
|
-
};
|
|
144
|
-
export type ComponentDatePickerDefinition1 =
|
|
145
|
-
ComponentDefinitionBaseWithResponse;
|
|
146
|
-
export type ComponentCheckboxGroupDefinition =
|
|
147
|
-
ComponentCheckboxGroupDefinition1 & {
|
|
148
|
-
componentType: 'CheckboxGroup';
|
|
149
|
-
orientation?: 'horizontal' | 'vertical';
|
|
150
|
-
responses: {
|
|
151
|
-
label: VTLExpression;
|
|
152
|
-
description?: VTLExpression;
|
|
153
|
-
response: ResponseDefinition;
|
|
154
|
-
conditionFilter?: VTLExpression;
|
|
155
|
-
id: string;
|
|
156
|
-
detail?: {
|
|
157
|
-
label?: VTLExpression;
|
|
158
|
-
response: ResponseDefinition;
|
|
159
|
-
};
|
|
160
|
-
}[];
|
|
125
|
+
export type ComponentDurationDefinition =
|
|
126
|
+
ComponentDefinitionBaseWithResponse & {
|
|
127
|
+
componentType: 'Duration';
|
|
128
|
+
format: 'PnYnM' | 'PTnHnM';
|
|
161
129
|
};
|
|
162
|
-
export type
|
|
130
|
+
export type ComponentDatePickerDefinition =
|
|
131
|
+
ComponentDefinitionBaseWithResponse & {
|
|
132
|
+
componentType: 'Datepicker';
|
|
133
|
+
dateFormat: 'YYYY-MM-DD' | 'YYYY' | 'YYYY-MM';
|
|
134
|
+
min?: string;
|
|
135
|
+
max?: string;
|
|
136
|
+
};
|
|
137
|
+
export type ComponentCheckboxGroupDefinition = ComponentDefinitionBase & {
|
|
138
|
+
componentType: 'CheckboxGroup';
|
|
139
|
+
orientation?: 'horizontal' | 'vertical';
|
|
140
|
+
responses: {
|
|
141
|
+
label: VTLExpression;
|
|
142
|
+
description?: VTLExpression;
|
|
143
|
+
response: ResponseDefinition;
|
|
144
|
+
conditionFilter?: VTLExpression;
|
|
145
|
+
id: string;
|
|
146
|
+
detail?: {
|
|
147
|
+
label?: VTLExpression;
|
|
148
|
+
response: ResponseDefinition;
|
|
149
|
+
};
|
|
150
|
+
}[];
|
|
151
|
+
};
|
|
163
152
|
export type ComponentCheckboxBooleanDefinition =
|
|
164
|
-
|
|
153
|
+
ComponentDefinitionBaseWithResponse & {
|
|
165
154
|
componentType: 'CheckboxBoolean';
|
|
166
155
|
};
|
|
167
|
-
export type
|
|
168
|
-
ComponentDefinitionBaseWithResponse;
|
|
169
|
-
export type ComponentRadioDefinition = ComponentRadioDefinition1 & {
|
|
156
|
+
export type ComponentRadioDefinition = ComponentDefinitionBaseWithResponse & {
|
|
170
157
|
componentType: 'Radio';
|
|
171
158
|
orientation?: 'horizontal' | 'vertical';
|
|
172
159
|
options: OptionsWithDetail;
|
|
173
160
|
};
|
|
174
|
-
export type ComponentRadioDefinition1 = ComponentDefinitionBaseWithResponse;
|
|
175
161
|
export type OptionsWithDetail = {
|
|
176
162
|
value: string | boolean;
|
|
177
163
|
label: VTLExpression;
|
|
@@ -183,63 +169,59 @@ export type OptionsWithDetail = {
|
|
|
183
169
|
};
|
|
184
170
|
};
|
|
185
171
|
}[];
|
|
186
|
-
export type ComponentDropdownDefinition =
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
export type ComponentQuestionDefinition =
|
|
172
|
+
export type ComponentDropdownDefinition =
|
|
173
|
+
ComponentDefinitionBaseWithResponse & {
|
|
174
|
+
componentType: 'Dropdown';
|
|
175
|
+
options: Options;
|
|
176
|
+
};
|
|
177
|
+
export type ComponentQuestionDefinition = ComponentDefinitionBase & {
|
|
192
178
|
componentType: 'Question';
|
|
193
179
|
components: ComponentDefinition[];
|
|
194
180
|
};
|
|
195
|
-
export type
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
};
|
|
200
|
-
export type ComponentCheckboxOneDefinition1 =
|
|
201
|
-
ComponentDefinitionBaseWithResponse;
|
|
202
|
-
export type ComponentSuggesterDefinition = ComponentSuggesterDefinition1 & {
|
|
203
|
-
componentType: 'Suggester';
|
|
204
|
-
/**
|
|
205
|
-
* Nom / Index du référentiel à utiliser
|
|
206
|
-
*/
|
|
207
|
-
storeName: string;
|
|
208
|
-
/**
|
|
209
|
-
* Permet l'entrée d'une valeur arbitraire (Autre)
|
|
210
|
-
*/
|
|
211
|
-
arbitrary?: {
|
|
212
|
-
response: ResponseDefinition;
|
|
181
|
+
export type ComponentCheckboxOneDefinition =
|
|
182
|
+
ComponentDefinitionBaseWithResponse & {
|
|
183
|
+
componentType: 'CheckboxOne';
|
|
184
|
+
options: OptionsWithDetail;
|
|
213
185
|
};
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
optionResponses?: {
|
|
186
|
+
export type ComponentSuggesterDefinition =
|
|
187
|
+
ComponentDefinitionBaseWithResponse & {
|
|
188
|
+
componentType: 'Suggester';
|
|
218
189
|
/**
|
|
219
|
-
* Nom
|
|
190
|
+
* Nom / Index du référentiel à utiliser
|
|
220
191
|
*/
|
|
221
|
-
|
|
192
|
+
storeName: string;
|
|
222
193
|
/**
|
|
223
|
-
*
|
|
194
|
+
* Permet l'entrée d'une valeur arbitraire (Autre)
|
|
224
195
|
*/
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
};
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
196
|
+
arbitrary?: {
|
|
197
|
+
response: ResponseDefinition;
|
|
198
|
+
};
|
|
199
|
+
/**
|
|
200
|
+
* Liste des attributs de la nomenclature à sauvegarder dans une variable
|
|
201
|
+
*/
|
|
202
|
+
optionResponses?: {
|
|
203
|
+
/**
|
|
204
|
+
* Nom de la variable
|
|
205
|
+
*/
|
|
206
|
+
name: string;
|
|
207
|
+
/**
|
|
208
|
+
* Nom de la propriété dans la nomenclature
|
|
209
|
+
*/
|
|
210
|
+
attribute: string;
|
|
211
|
+
}[];
|
|
212
|
+
};
|
|
213
|
+
export type ComponentPairWiseLinksDefinition = ComponentDefinitionBase & {
|
|
214
|
+
componentType: 'PairwiseLinks';
|
|
215
|
+
xAxisIterations: VTLScalarExpression;
|
|
216
|
+
yAxisIterations: VTLScalarExpression;
|
|
217
|
+
symLinks: {
|
|
218
|
+
[k: string]: {
|
|
219
|
+
[k: string]: string | null;
|
|
238
220
|
};
|
|
239
|
-
components: ComponentDefinition[];
|
|
240
221
|
};
|
|
241
|
-
|
|
242
|
-
|
|
222
|
+
components: ComponentDefinition[];
|
|
223
|
+
};
|
|
224
|
+
export type ComponentSummaryDefinition = ComponentDefinitionBase & {
|
|
243
225
|
componentType: 'Summary';
|
|
244
226
|
sections: {
|
|
245
227
|
id: string;
|
|
@@ -252,7 +234,6 @@ export type ComponentSummaryDefinition = ComponentSummaryDefinition1 & {
|
|
|
252
234
|
}[];
|
|
253
235
|
}[];
|
|
254
236
|
};
|
|
255
|
-
export type ComponentSummaryDefinition1 = ComponentDefinitionBase;
|
|
256
237
|
export type Variable =
|
|
257
238
|
| {
|
|
258
239
|
variableType: 'EXTERNAL';
|
|
@@ -465,4 +446,8 @@ export type SuggesterDefinition = {
|
|
|
465
446
|
| {
|
|
466
447
|
type: 'soft';
|
|
467
448
|
};
|
|
449
|
+
/**
|
|
450
|
+
* list of words to exclude from the searching
|
|
451
|
+
*/
|
|
452
|
+
stopWords?: string[];
|
|
468
453
|
};
|
|
@@ -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()"
|
|
@@ -179,6 +179,58 @@ describe('use-lunatic()', () => {
|
|
|
179
179
|
});
|
|
180
180
|
});
|
|
181
181
|
|
|
182
|
+
describe('disable filters', () => {
|
|
183
|
+
const lunaticConfigurationWithoutDisableFilters = {
|
|
184
|
+
management: false,
|
|
185
|
+
activeControls: false,
|
|
186
|
+
initialPage: '1' as PageTag,
|
|
187
|
+
getStoreInfo: () => {},
|
|
188
|
+
missing: false,
|
|
189
|
+
shortcut: false,
|
|
190
|
+
activeGoNextForMissing: false,
|
|
191
|
+
showOverview: false,
|
|
192
|
+
filterDescription: true,
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
it('should filter out some components by default', function () {
|
|
196
|
+
const { result } = renderHook(() =>
|
|
197
|
+
useLunatic(
|
|
198
|
+
sourceLogement as any,
|
|
199
|
+
undefined,
|
|
200
|
+
lunaticConfigurationWithoutDisableFilters
|
|
201
|
+
)
|
|
202
|
+
);
|
|
203
|
+
act(() => result.current.goToPage({ page: '3' }));
|
|
204
|
+
const currentPage = result.current.pageTag;
|
|
205
|
+
expect(currentPage).not.toBe('3');
|
|
206
|
+
});
|
|
207
|
+
it('should filter out some components when false', function () {
|
|
208
|
+
const { result } = renderHook(() =>
|
|
209
|
+
useLunatic(sourceLogement as any, undefined, {
|
|
210
|
+
...lunaticConfigurationWithoutDisableFilters,
|
|
211
|
+
disableFilters: false,
|
|
212
|
+
})
|
|
213
|
+
);
|
|
214
|
+
act(() => result.current.goToPage({ page: '3' }));
|
|
215
|
+
const currentPage = result.current.pageTag;
|
|
216
|
+
expect(currentPage).not.toBe('3');
|
|
217
|
+
});
|
|
218
|
+
it('should not filter any component when true', function () {
|
|
219
|
+
const { result } = renderHook(() =>
|
|
220
|
+
useLunatic(sourceLogement as any, undefined, {
|
|
221
|
+
...lunaticConfigurationWithoutDisableFilters,
|
|
222
|
+
disableFilters: true,
|
|
223
|
+
})
|
|
224
|
+
);
|
|
225
|
+
act(() => result.current.goToPage({ page: '3' }));
|
|
226
|
+
const currentPage = result.current.pageTag;
|
|
227
|
+
expect(currentPage).toBe('3');
|
|
228
|
+
|
|
229
|
+
const components = result.current.getComponents();
|
|
230
|
+
expect(components.length).toBe(1);
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
|
|
182
234
|
describe('cleaning', () => {
|
|
183
235
|
it('should handle cleaning in a loop', () => {
|
|
184
236
|
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,6 +117,7 @@ export function useLunatic(
|
|
|
113
117
|
missingShortcut,
|
|
114
118
|
dontKnowButton,
|
|
115
119
|
refusedButton,
|
|
120
|
+
componentsOptions,
|
|
116
121
|
}),
|
|
117
122
|
[
|
|
118
123
|
management,
|
|
@@ -122,6 +127,7 @@ export function useLunatic(
|
|
|
122
127
|
missingShortcut,
|
|
123
128
|
dontKnowButton,
|
|
124
129
|
refusedButton,
|
|
130
|
+
componentsOptions,
|
|
125
131
|
]
|
|
126
132
|
);
|
|
127
133
|
|
|
@@ -179,6 +185,7 @@ export function useLunatic(
|
|
|
179
185
|
const { isFirstPage, isLastPage } = isFirstLastPage(state.pager);
|
|
180
186
|
|
|
181
187
|
const components = fillComponents(getComponentsFromState(state), {
|
|
188
|
+
disableFilters,
|
|
182
189
|
handleChanges,
|
|
183
190
|
preferences,
|
|
184
191
|
goToPage,
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeAll, afterEach } from 'vitest';
|
|
2
|
+
import { SearchMinisearch } from './SearchMinisearch';
|
|
3
|
+
|
|
4
|
+
vi.mock('minisearch', () => {
|
|
5
|
+
return {
|
|
6
|
+
default: vi.fn().mockImplementation(() => ({
|
|
7
|
+
addAll: vi.fn(),
|
|
8
|
+
search: vi.fn(),
|
|
9
|
+
})),
|
|
10
|
+
};
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
vi.mock('./melauto', () => ({
|
|
14
|
+
applyMelauto: vi.fn(),
|
|
15
|
+
}));
|
|
16
|
+
|
|
17
|
+
describe('SearchMinisearch', () => {
|
|
18
|
+
let searchInstance: SearchMinisearch<any>;
|
|
19
|
+
const mockData = [
|
|
20
|
+
{ id: '1', label: 'First Item' },
|
|
21
|
+
{ id: '2', label: 'Second Item' },
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
beforeAll(() => {
|
|
25
|
+
searchInstance = new SearchMinisearch({
|
|
26
|
+
name: 'test-suggester',
|
|
27
|
+
fields: [{ name: 'id' }, { name: 'label' }],
|
|
28
|
+
queryParser: {
|
|
29
|
+
type: 'tokenized',
|
|
30
|
+
params: { language: 'English', pattern: '\\w+', min: 1 },
|
|
31
|
+
},
|
|
32
|
+
max: 10,
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
afterEach(() => {
|
|
37
|
+
const miniSearchMock = searchInstance.db as any;
|
|
38
|
+
miniSearchMock.addAll.mockClear();
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('should initialize and index data correctly', async () => {
|
|
42
|
+
await searchInstance.index(mockData);
|
|
43
|
+
|
|
44
|
+
// Check if MiniSearch instance was created and indexed
|
|
45
|
+
expect(searchInstance.db).not.toBeNull();
|
|
46
|
+
expect(searchInstance.isIndexed()).toBe(true);
|
|
47
|
+
|
|
48
|
+
// Check if addAll was called with the correct data
|
|
49
|
+
expect(searchInstance.db?.addAll).toHaveBeenCalledWith(mockData);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('should not re-index if already indexed', async () => {
|
|
53
|
+
searchInstance.indexed = true;
|
|
54
|
+
await searchInstance.index(mockData);
|
|
55
|
+
|
|
56
|
+
expect(searchInstance.db?.addAll).not.toHaveBeenCalled();
|
|
57
|
+
});
|
|
58
|
+
});
|