@inseefr/lunatic 0.3.0-experimental → 0.3.4-experimental
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/lib/index.js +218 -260
- package/lib/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/component-wrapper/controls/validators/datepicker.js +25 -14
- package/src/components/component-wrapper/missing/component.js +37 -17
- package/src/components/datepicker/component.js +8 -12
- package/src/components/declarations/wrappers/input-declarations-wrapper.js +31 -9
- package/src/components/dropdown/commons/components/dropdown.js +21 -0
- package/src/components/dropdown/dropdown-edit/dropdown-edit.js +4 -1
- package/src/components/dropdown/dropdown-simple/dropdown.js +3 -1
- package/src/components/input/input-number.js +2 -1
- package/src/components/loop-constructor/block/index.js +1 -1
- package/src/components/loop-constructor/index.js +1 -1
- package/src/components/loop-constructor/roster/index.js +1 -1
- package/src/components/loop-constructor/wrapper/body-component.js +3 -0
- package/src/components/loop-constructor/wrapper/build-components.js +33 -33
- package/src/components/loop-constructor/wrapper/index.js +1 -1
- package/src/components/suggester/components/panel/option-container.js +1 -1
- package/src/components/suggester/components/suggester-content.js +42 -42
- package/src/components/suggester/components/suggester.js +43 -3
- package/src/components/suggester/idb-suggester.js +7 -1
- package/src/components/suggester/lunatic-suggester.js +1 -0
- package/src/components/suggester/suggester-wrapper.js +9 -3
- package/src/components/table/table.js +3 -1
- package/src/stories/loop-constructor/README.md +27 -27
- package/src/stories/loop-constructor/data-input-forced.json +64 -64
- package/src/stories/loop-constructor/data-input.json +100 -100
- package/src/stories/loop-constructor/data-loop-forced.json +66 -66
- package/src/stories/loop-constructor/data-loop-static-forced.json +66 -66
- package/src/stories/loop-constructor/data-loop-static.json +81 -81
- package/src/stories/loop-constructor/data-loop.json +81 -81
- package/src/stories/loop-constructor/data-roster-forced.json +68 -68
- package/src/stories/loop-constructor/data-roster.json +83 -83
- package/src/stories/loop-constructor/loop-constructor.stories.js +180 -180
- package/src/stories/questionnaire/arithmetic-management.json +47 -0
- package/src/stories/questionnaire/logement-queen.json +23389 -22705
- package/src/stories/questionnaire/logement-s2.json +46027 -44536
- package/src/stories/questionnaire/questionnaire.stories.js +46 -13
- package/src/stories/questionnaire/update-external/data.json +1 -0
- package/src/stories/questionnaire/update-external/questionnaire.json +75 -0
- package/src/stories/suggester/data.json +4 -1
- package/src/stories/suggester/suggester-workers.stories.js +4 -1
- package/src/stories/utils/orchestrator-split.js +119 -0
- package/src/stories/utils/orchestrator.js +12 -3
- package/src/tests/utils/to-expose/handler/results/res-input-edited.json +158 -158
- package/src/tests/utils/to-expose/state/state.spec.js +59 -59
- package/src/utils/lib/index.js +1 -0
- package/src/utils/lib/pagination/navigation/shared.js +5 -5
- package/src/utils/lib/splitting.js +142 -0
- package/src/utils/suggester-workers/commons-tokenizer/create-entity-tokenizer.js +4 -2
- package/src/utils/suggester-workers/commons-tokenizer/filters/{filter-accents-to-lower.js → filter-accents.js} +2 -2
- package/src/utils/suggester-workers/commons-tokenizer/filters/{filter-accents-to-lower.spec.js → filter-accents.spec.js} +1 -1
- package/src/utils/suggester-workers/commons-tokenizer/filters/filter-synonyms.js +27 -1
- package/src/utils/suggester-workers/commons-tokenizer/filters/filter-to-lower.js +10 -0
- package/src/utils/suggester-workers/commons-tokenizer/filters/filter-to-lower.spec.js +12 -0
- package/src/utils/suggester-workers/commons-tokenizer/index.js +1 -1
- package/src/utils/to-expose/handler.js +67 -28
- package/src/utils/to-expose/hooks/filter-components.js +106 -106
- package/src/utils/to-expose/hooks/index.js +2 -1
- package/src/utils/to-expose/hooks/lunatic-split.js +421 -0
- package/src/utils/to-expose/hooks/lunatic.js +39 -7
- package/src/utils/to-expose/index.js +11 -11
- package/src/utils/to-expose/state.js +23 -15
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
2
|
import { storiesOf } from '@storybook/react';
|
|
3
3
|
import Orchestrator from '../utils/orchestrator';
|
|
4
|
+
import OrchestratorSplit from '../utils/orchestrator-split';
|
|
4
5
|
import { titleDecorator } from 'utils/lib';
|
|
5
6
|
import calcVar from './calc-var';
|
|
6
7
|
import logement from './logement';
|
|
@@ -10,6 +11,9 @@ import logementSequence from './logement-sequence';
|
|
|
10
11
|
import dataLogement from './data-logement';
|
|
11
12
|
import simpsons from './simpsons';
|
|
12
13
|
import arithmetic from './arithmetic';
|
|
14
|
+
import arithmeticManagement from './arithmetic-management';
|
|
15
|
+
import updateExternalQuestionnaire from './update-external/questionnaire';
|
|
16
|
+
import updateExternalData from './update-external/data';
|
|
13
17
|
import { positioningOptions, featuresOptions } from '../utils/options';
|
|
14
18
|
import { boolean, select } from '@storybook/addon-knobs/react';
|
|
15
19
|
|
|
@@ -33,26 +37,24 @@ def.addWithJSX('Calculated Variables', () => (
|
|
|
33
37
|
/>
|
|
34
38
|
));
|
|
35
39
|
|
|
36
|
-
def.addWithJSX('
|
|
40
|
+
def.addWithJSX('Arithmetic', () => (
|
|
37
41
|
<Orchestrator
|
|
38
42
|
id="props"
|
|
39
|
-
source={
|
|
40
|
-
missing={boolean('Missing', false)}
|
|
43
|
+
source={arithmetic}
|
|
41
44
|
features={select('Features', featuresOptions, ['VTL', 'MD'])}
|
|
42
45
|
positioning={select('Items positioning', positioningOptions, 'DEFAULT')}
|
|
43
46
|
disabled={boolean('Disabled', false)}
|
|
44
|
-
focused={boolean('Focused', false)}
|
|
45
|
-
management={boolean('Management', false)}
|
|
46
47
|
/>
|
|
47
48
|
));
|
|
48
49
|
|
|
49
|
-
def.addWithJSX('Arithmetic', () => (
|
|
50
|
+
def.addWithJSX('Arithmetic - Management', () => (
|
|
50
51
|
<Orchestrator
|
|
51
52
|
id="props"
|
|
52
|
-
source={
|
|
53
|
+
source={arithmeticManagement}
|
|
53
54
|
features={select('Features', featuresOptions, ['VTL', 'MD'])}
|
|
54
55
|
positioning={select('Items positioning', positioningOptions, 'DEFAULT')}
|
|
55
56
|
disabled={boolean('Disabled', false)}
|
|
57
|
+
management={boolean('Management', true)}
|
|
56
58
|
/>
|
|
57
59
|
));
|
|
58
60
|
|
|
@@ -91,7 +93,7 @@ paginated.addWithJSX('Calculated Variables', () => (
|
|
|
91
93
|
));
|
|
92
94
|
|
|
93
95
|
paginated.addWithJSX('Logement', () => (
|
|
94
|
-
<
|
|
96
|
+
<OrchestratorSplit
|
|
95
97
|
id="props"
|
|
96
98
|
source={logement}
|
|
97
99
|
data={dataLogement}
|
|
@@ -108,11 +110,11 @@ paginated.addWithJSX('Logement', () => (
|
|
|
108
110
|
));
|
|
109
111
|
|
|
110
112
|
paginated.addWithJSX('Logement - Queen', () => (
|
|
111
|
-
<
|
|
113
|
+
<OrchestratorSplit
|
|
112
114
|
id="props"
|
|
113
115
|
source={logementQueen}
|
|
114
116
|
data={dataLogement}
|
|
115
|
-
missing={boolean('Missing',
|
|
117
|
+
missing={boolean('Missing', true)}
|
|
116
118
|
activeGoNextForMissing={boolean('Active go next for missing', false)}
|
|
117
119
|
features={select('Features', featuresOptions, ['VTL', 'MD'])}
|
|
118
120
|
positioning={select('Items positioning', positioningOptions, 'DEFAULT')}
|
|
@@ -124,7 +126,7 @@ paginated.addWithJSX('Logement - Queen', () => (
|
|
|
124
126
|
));
|
|
125
127
|
|
|
126
128
|
paginated.addWithJSX('Logement - Sequence', () => (
|
|
127
|
-
<
|
|
129
|
+
<OrchestratorSplit
|
|
128
130
|
id="props"
|
|
129
131
|
source={logementSequence}
|
|
130
132
|
data={dataLogement}
|
|
@@ -140,7 +142,7 @@ paginated.addWithJSX('Logement - Sequence', () => (
|
|
|
140
142
|
));
|
|
141
143
|
|
|
142
144
|
paginated.addWithJSX('Logement - S2', () => (
|
|
143
|
-
<
|
|
145
|
+
<OrchestratorSplit
|
|
144
146
|
id="props"
|
|
145
147
|
source={logementS2}
|
|
146
148
|
missing={boolean('Missing', false)}
|
|
@@ -170,3 +172,34 @@ paginated.addWithJSX('Simpsons', () => (
|
|
|
170
172
|
pagination
|
|
171
173
|
/>
|
|
172
174
|
));
|
|
175
|
+
|
|
176
|
+
const other = storiesOf('Questionnaire/Other', module).addDecorator(
|
|
177
|
+
(Component) => {
|
|
178
|
+
const WrappedComponent = titleDecorator(Component);
|
|
179
|
+
return <WrappedComponent title="<Questionnaire />" />;
|
|
180
|
+
}
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
other.addWithJSX('Update external', () => {
|
|
184
|
+
const [addExternal, setAddExternal] = useState(null);
|
|
185
|
+
return (
|
|
186
|
+
<>
|
|
187
|
+
<button
|
|
188
|
+
onClick={() => setAddExternal({ PROMO: true })}
|
|
189
|
+
>{`Fire PROMO --> True`}</button>
|
|
190
|
+
<button
|
|
191
|
+
onClick={() => setAddExternal({ PROMO: false })}
|
|
192
|
+
>{`Fire PROMO --> False`}</button>
|
|
193
|
+
<Orchestrator
|
|
194
|
+
id="props"
|
|
195
|
+
source={updateExternalQuestionnaire}
|
|
196
|
+
data={updateExternalData}
|
|
197
|
+
features={select('Features', featuresOptions, ['VTL', 'MD'])}
|
|
198
|
+
positioning={select('Items positioning', positioningOptions, 'DEFAULT')}
|
|
199
|
+
disabled={boolean('Disabled', false)}
|
|
200
|
+
focused={boolean('Focused', false)}
|
|
201
|
+
addExternal={addExternal}
|
|
202
|
+
/>
|
|
203
|
+
</>
|
|
204
|
+
);
|
|
205
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "EXTERNAL": { "PROMO": null } }
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
{
|
|
2
|
+
"components": [
|
|
3
|
+
{
|
|
4
|
+
"id": "seq1",
|
|
5
|
+
"componentType": "Sequence",
|
|
6
|
+
"label": "\"I - Collect number\"",
|
|
7
|
+
"conditionFilter": { "value": "true" }
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"id": "input1",
|
|
11
|
+
"componentType": "InputNumber",
|
|
12
|
+
"label": "Number",
|
|
13
|
+
"conditionFilter": { "value": "true" },
|
|
14
|
+
"response": { "name": "NUM" },
|
|
15
|
+
"bindingDependencies": ["NUM"]
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"id": "seq2",
|
|
19
|
+
"componentType": "Sequence",
|
|
20
|
+
"label": "\"II - Promo rate\"",
|
|
21
|
+
"conditionFilter": {
|
|
22
|
+
"value": "PROMO = true",
|
|
23
|
+
"bindingDependencies": ["PROMO"]
|
|
24
|
+
},
|
|
25
|
+
"bindingDependencies": ["PROMO"]
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"id": "input2",
|
|
29
|
+
"componentType": "InputNumber",
|
|
30
|
+
"label": "Rate",
|
|
31
|
+
"conditionFilter": {
|
|
32
|
+
"value": "PROMO = true",
|
|
33
|
+
"bindingDependencies": ["PROMO"]
|
|
34
|
+
},
|
|
35
|
+
"response": {
|
|
36
|
+
"name": "PROMO_RATE",
|
|
37
|
+
"bindingDependencies": ["PROMO_RATE"]
|
|
38
|
+
},
|
|
39
|
+
"bindingDependencies": ["PROMO", "PROMO_RATE"]
|
|
40
|
+
}
|
|
41
|
+
],
|
|
42
|
+
"variables": [
|
|
43
|
+
{
|
|
44
|
+
"variableType": "COLLECTED",
|
|
45
|
+
"name": "NUM",
|
|
46
|
+
"componentRef": "input1",
|
|
47
|
+
"values": {
|
|
48
|
+
"PREVIOUS": null,
|
|
49
|
+
"COLLECTED": null,
|
|
50
|
+
"FORCED": null,
|
|
51
|
+
"EDITED": null,
|
|
52
|
+
"INPUTED": null
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"variableType": "COLLECTED",
|
|
57
|
+
"name": "PROMO_RATE",
|
|
58
|
+
"componentRef": "input2",
|
|
59
|
+
"values": {
|
|
60
|
+
"PREVIOUS": null,
|
|
61
|
+
"COLLECTED": null,
|
|
62
|
+
"FORCED": null,
|
|
63
|
+
"EDITED": null,
|
|
64
|
+
"INPUTED": null
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
{ "variableType": "EXTERNAL", "name": "PROMO", "value": null },
|
|
68
|
+
{
|
|
69
|
+
"variableType": "CALCULATED",
|
|
70
|
+
"name": "DOUBLE_PROMO_RATE",
|
|
71
|
+
"expression": "cast(PROMO_RATE, integer) * 2",
|
|
72
|
+
"bindingDependencies": ["PROMO_RATE"]
|
|
73
|
+
}
|
|
74
|
+
]
|
|
75
|
+
}
|
|
@@ -46,7 +46,10 @@
|
|
|
46
46
|
"name": "libelle2",
|
|
47
47
|
"rules": ["[\\w]+"],
|
|
48
48
|
"language": "French",
|
|
49
|
-
"synonyms":
|
|
49
|
+
"synonyms": [
|
|
50
|
+
{ "source": "saint", "target": ["st"] },
|
|
51
|
+
{ "source": "oph", "target": ["renaud", "nicolas"] }
|
|
52
|
+
],
|
|
50
53
|
"stemmer": false
|
|
51
54
|
},
|
|
52
55
|
{ "name": "code" }
|
|
@@ -53,7 +53,10 @@ const bailleursSociaux = {
|
|
|
53
53
|
rules: ['[\\w]+'],
|
|
54
54
|
language: 'French',
|
|
55
55
|
stemmer: false,
|
|
56
|
-
synonyms:
|
|
56
|
+
synonyms: [
|
|
57
|
+
{ source: 'saint', target: ['st'] },
|
|
58
|
+
{ source: 'oph', target: ['renaud', 'nicolas'] },
|
|
59
|
+
],
|
|
57
60
|
},
|
|
58
61
|
{ name: 'code' },
|
|
59
62
|
],
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
|
+
import * as lunatic from 'components';
|
|
3
|
+
import './custom-lunatic.scss';
|
|
4
|
+
|
|
5
|
+
function getStoreInfoRequired() {
|
|
6
|
+
return {};
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const defaultFeatures = ['VTL'];
|
|
10
|
+
|
|
11
|
+
const OrchestratorForStories = ({
|
|
12
|
+
source,
|
|
13
|
+
suggesters,
|
|
14
|
+
data,
|
|
15
|
+
management = false,
|
|
16
|
+
pagination = false,
|
|
17
|
+
modalForControls = false,
|
|
18
|
+
features = defaultFeatures,
|
|
19
|
+
bindings: initialBindings,
|
|
20
|
+
initialPage = '1',
|
|
21
|
+
getStoreInfo = getStoreInfoRequired,
|
|
22
|
+
missing = false,
|
|
23
|
+
shortcut = false,
|
|
24
|
+
activeGoNextForMissing = false,
|
|
25
|
+
suggesterFetcher,
|
|
26
|
+
autoSuggesterLoading,
|
|
27
|
+
addExternal,
|
|
28
|
+
...rest
|
|
29
|
+
}) => {
|
|
30
|
+
const preferences = management
|
|
31
|
+
? ['COLLECTED', 'FORCED', 'EDITED']
|
|
32
|
+
: ['COLLECTED'];
|
|
33
|
+
const savingType = management ? 'EDITED' : 'COLLECTED';
|
|
34
|
+
const {
|
|
35
|
+
handleChange,
|
|
36
|
+
handleExternals,
|
|
37
|
+
components,
|
|
38
|
+
bindings,
|
|
39
|
+
pagination: {
|
|
40
|
+
goNext,
|
|
41
|
+
goPrevious,
|
|
42
|
+
page,
|
|
43
|
+
setPage,
|
|
44
|
+
maxPage,
|
|
45
|
+
isFirstPage,
|
|
46
|
+
isLastPage,
|
|
47
|
+
flow,
|
|
48
|
+
},
|
|
49
|
+
} = lunatic.useLunaticSplit(source, data, {
|
|
50
|
+
suggesters,
|
|
51
|
+
savingType,
|
|
52
|
+
preferences,
|
|
53
|
+
features,
|
|
54
|
+
management,
|
|
55
|
+
pagination,
|
|
56
|
+
modalForControls,
|
|
57
|
+
initialPage,
|
|
58
|
+
suggesterFetcher,
|
|
59
|
+
autoSuggesterLoading,
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
handleExternals(addExternal);
|
|
64
|
+
}, [addExternal, handleExternals]);
|
|
65
|
+
|
|
66
|
+
const Button = lunatic.Button;
|
|
67
|
+
|
|
68
|
+
const missingStrategy = (b) => goNext(null, b);
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<div className="container">
|
|
72
|
+
<div className="components">
|
|
73
|
+
{components.map((q) => {
|
|
74
|
+
const { id, componentType } = q;
|
|
75
|
+
const Component = lunatic[componentType];
|
|
76
|
+
const { storeName } = q;
|
|
77
|
+
|
|
78
|
+
return (
|
|
79
|
+
<div className="lunatic lunatic-component" key={`component-${id}`}>
|
|
80
|
+
<Component
|
|
81
|
+
{...rest}
|
|
82
|
+
{...q}
|
|
83
|
+
{...getStoreInfo(storeName)}
|
|
84
|
+
handleChange={handleChange}
|
|
85
|
+
preferences={preferences}
|
|
86
|
+
savingType={savingType}
|
|
87
|
+
management={management}
|
|
88
|
+
features={features}
|
|
89
|
+
bindings={{ ...bindings, ...initialBindings }}
|
|
90
|
+
currentPage={page}
|
|
91
|
+
setPage={setPage}
|
|
92
|
+
flow={flow}
|
|
93
|
+
pagination={pagination}
|
|
94
|
+
missing={missing}
|
|
95
|
+
shortcut={shortcut}
|
|
96
|
+
missingStrategy={activeGoNextForMissing && missingStrategy}
|
|
97
|
+
/>
|
|
98
|
+
</div>
|
|
99
|
+
);
|
|
100
|
+
})}
|
|
101
|
+
</div>
|
|
102
|
+
{pagination && (
|
|
103
|
+
<>
|
|
104
|
+
<div className="pagination">
|
|
105
|
+
<Button
|
|
106
|
+
onClick={goPrevious}
|
|
107
|
+
disabled={isFirstPage}
|
|
108
|
+
value="Previous"
|
|
109
|
+
/>
|
|
110
|
+
<Button onClick={goNext} disabled={isLastPage} value="Next" />
|
|
111
|
+
</div>
|
|
112
|
+
<div>{`Page : ${page}/${maxPage}`}</div>
|
|
113
|
+
</>
|
|
114
|
+
)}
|
|
115
|
+
</div>
|
|
116
|
+
);
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
export default OrchestratorForStories;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
2
|
import * as lunatic from 'components';
|
|
3
3
|
import './custom-lunatic.scss';
|
|
4
4
|
|
|
@@ -6,14 +6,16 @@ function getStoreInfoRequired() {
|
|
|
6
6
|
return {};
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
+
const defaultFeatures = ['VTL'];
|
|
10
|
+
|
|
9
11
|
const OrchestratorForStories = ({
|
|
10
12
|
source,
|
|
11
13
|
suggesters,
|
|
12
|
-
data
|
|
14
|
+
data,
|
|
13
15
|
management = false,
|
|
14
16
|
pagination = false,
|
|
15
17
|
modalForControls = false,
|
|
16
|
-
features =
|
|
18
|
+
features = defaultFeatures,
|
|
17
19
|
bindings: initialBindings,
|
|
18
20
|
initialPage = '1',
|
|
19
21
|
getStoreInfo = getStoreInfoRequired,
|
|
@@ -22,6 +24,7 @@ const OrchestratorForStories = ({
|
|
|
22
24
|
activeGoNextForMissing = false,
|
|
23
25
|
suggesterFetcher,
|
|
24
26
|
autoSuggesterLoading,
|
|
27
|
+
addExternal,
|
|
25
28
|
...rest
|
|
26
29
|
}) => {
|
|
27
30
|
const preferences = management
|
|
@@ -30,6 +33,7 @@ const OrchestratorForStories = ({
|
|
|
30
33
|
const savingType = management ? 'EDITED' : 'COLLECTED';
|
|
31
34
|
const {
|
|
32
35
|
handleChange,
|
|
36
|
+
handleExternals,
|
|
33
37
|
components,
|
|
34
38
|
bindings,
|
|
35
39
|
pagination: {
|
|
@@ -54,6 +58,11 @@ const OrchestratorForStories = ({
|
|
|
54
58
|
suggesterFetcher,
|
|
55
59
|
autoSuggesterLoading,
|
|
56
60
|
});
|
|
61
|
+
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
handleExternals(addExternal);
|
|
64
|
+
}, [addExternal, handleExternals]);
|
|
65
|
+
|
|
57
66
|
const Button = lunatic.Button;
|
|
58
67
|
|
|
59
68
|
const missingStrategy = (b) => goNext(null, b);
|