@inseefr/lunatic 0.2.2-experimental → 0.2.3-prisme
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/LICENSE +21 -21
- package/README.md +25 -23
- package/lib/index.js +1191 -475
- package/lib/index.js.map +1 -1
- package/package.json +174 -172
- package/src/components/breadcrumb/breadcrumb.scss +22 -22
- package/src/components/checkbox/boolean.js +172 -172
- package/src/components/checkbox/checkbox.scss +73 -73
- package/src/components/checkbox/group.js +231 -231
- package/src/components/checkbox/one.js +11 -11
- package/src/components/component-wrapper/controls/component.js +70 -0
- package/src/components/component-wrapper/controls/controls.scss +6 -0
- package/src/components/component-wrapper/controls/index.js +1 -0
- package/src/components/component-wrapper/controls/validators/datepicker.js +44 -0
- package/src/components/component-wrapper/controls/validators/index.js +16 -0
- package/src/components/component-wrapper/controls/validators/input-number.js +23 -0
- package/src/components/{missing-wrapper → component-wrapper}/index.js +0 -0
- package/src/components/component-wrapper/missing/component.js +200 -0
- package/src/components/component-wrapper/missing/index.js +1 -0
- package/src/components/{missing-wrapper → component-wrapper/missing}/missing.scss +32 -32
- package/src/components/component-wrapper/wrapper.js +23 -0
- package/src/components/components.js +1 -0
- package/src/components/datepicker/component.js +26 -11
- package/src/components/declarations/component.js +46 -46
- package/src/components/declarations/declarations.scss +40 -40
- package/src/components/declarations/wrappers/input-declarations-wrapper.js +328 -274
- package/src/components/declarations/wrappers/simple-declarations-wrapper.js +54 -54
- package/src/components/dropdown/commons/actions.js +65 -56
- package/src/components/dropdown/commons/children-to-option.js +9 -9
- package/src/components/dropdown/commons/cleaner-callbacks.js +58 -58
- package/src/components/dropdown/commons/components/dropdown-container.js +29 -29
- package/src/components/dropdown/commons/components/dropdown.js +204 -183
- package/src/components/dropdown/commons/event-callbacks/on-mousedown-callback.js +15 -15
- package/src/components/dropdown/commons/reducer.js +3 -0
- package/src/components/dropdown/commons/tools/index.js +17 -17
- package/src/components/dropdown/component.js +135 -135
- package/src/components/dropdown/dropdown-edit/dropdown-edit.js +194 -185
- package/src/components/dropdown/dropdown-edit/index.js +11 -11
- package/src/components/dropdown/dropdown-simple/dropdown.js +173 -164
- package/src/components/dropdown/dropdown-simple/index.js +20 -20
- package/src/components/dropdown/dropdown.scss +178 -178
- package/src/components/icon/icon.scss +15 -15
- package/src/components/index.js +2 -0
- package/src/components/index.scss +177 -175
- package/src/components/input/input-number.js +30 -54
- package/src/components/input/input.js +11 -11
- package/src/components/input/input.scss +31 -37
- package/src/components/loop/component.js +170 -169
- package/src/components/loop/loop.scss +13 -13
- package/src/components/loop/wrapper.js +1 -1
- package/src/components/loop-constructor/block/block.scss +10 -10
- package/src/components/loop-constructor/block/component.js +9 -9
- package/src/components/loop-constructor/roster/component.js +8 -8
- package/src/components/loop-constructor/wrapper/body-component.js +146 -125
- package/src/components/modal/component.js +36 -0
- package/src/components/modal/index.js +1 -0
- package/src/components/modal/modal.scss +33 -0
- package/src/components/progress-bar/progress-bar.scss +54 -54
- package/src/components/radio/component.js +9 -9
- package/src/components/radio/radio.scss +59 -59
- package/src/components/sequence/component.js +50 -50
- package/src/components/sequence/sequence.scss +10 -10
- package/src/components/subsequence/component.js +49 -49
- package/src/components/suggester/check-store.js +2 -4
- package/src/components/suggester/components/panel/default-option-renderer.js +27 -27
- package/src/components/suggester/components/panel/option-container.js +61 -61
- package/src/components/suggester/components/panel/panel.js +47 -47
- package/src/components/suggester/components/selection/default-label-renderer.js +31 -31
- package/src/components/suggester/components/selection/label.js +35 -35
- package/src/components/suggester/components/selection/selection.js +50 -50
- package/src/components/suggester/components/suggester-content.js +2 -2
- package/src/components/suggester/components/suggester.js +128 -88
- package/src/components/suggester/components/suggester.scss +101 -101
- package/src/components/suggester/default-style.scss +125 -125
- package/src/components/suggester/find-best-label/find-best-label.js +51 -49
- package/src/components/suggester/find-best-label/index.js +1 -1
- package/src/components/suggester/idb-suggester.js +73 -67
- package/src/components/suggester/lunatic-suggester.js +140 -137
- package/src/components/suggester/searching/create-searching.js +49 -47
- package/src/components/suggester/searching/index.js +1 -1
- package/src/components/suggester/state-management/actions.js +38 -38
- package/src/components/suggester/state-management/reducer/reduce-on-delete-search.js +11 -11
- package/src/components/suggester/state-management/reducer/reduce-on-init.js +29 -29
- package/src/components/suggester/state-management/reducer/reducer.js +38 -38
- package/src/components/suggester/suggester-wrapper.js +127 -121
- package/src/components/suggester-loader-widget/loader.js +67 -67
- package/src/components/suggester-loader-widget/widget.js +123 -123
- package/src/components/table/table.js +173 -171
- package/src/components/table/table.scss +26 -26
- package/src/components/textarea/component.js +11 -11
- package/src/components/textarea/textarea.scss +8 -8
- package/src/components/tooltip/tooltip.scss +30 -30
- package/src/stories/checkbox-boolean/data.json +78 -78
- package/src/stories/datepicker/data.json +3 -1
- package/src/stories/dropdown/README.md +44 -44
- package/src/stories/dropdown/data.json +98 -98
- package/src/stories/dropdown/dropdown.stories.js +89 -89
- package/src/stories/progress-bar/progress-bar.stories.js +24 -24
- package/src/stories/questionnaire/arithmetic-management.json +47 -0
- package/src/stories/questionnaire/arithmetic.json +247 -247
- package/src/stories/questionnaire/kish.json +275 -0
- package/src/stories/questionnaire/logement-queen.json +23390 -0
- package/src/stories/questionnaire/logement-s2.json +46028 -0
- package/src/stories/questionnaire/logement.json +20347 -26087
- package/src/stories/questionnaire/loop-and-controls.json +481 -0
- package/src/stories/questionnaire/questionnaire.stories.js +236 -138
- package/src/stories/questionnaire/update-external/data.json +1 -0
- package/src/stories/questionnaire/update-external/questionnaire.json +75 -0
- package/src/stories/suggester/README.md +46 -46
- package/src/stories/suggester/bailleurs-sociaux/fetch-bailleurs.js +15 -15
- package/src/stories/suggester/bailleurs-sociaux/index.js +2 -2
- package/src/stories/suggester/bailleurs-sociaux/option-bailleur-renderer.js +58 -58
- package/src/stories/suggester/bailleurs-sociaux/preloader.svg +51 -51
- package/src/stories/suggester/bailleurs-sociaux/theme.scss +22 -22
- package/src/stories/suggester/bailleurs-sociaux-2021/fetch-bailleurs.js +12 -0
- package/src/stories/suggester/bailleurs-sociaux-2021/index.js +1 -0
- package/src/stories/suggester/cog-communes/fetch-cog.js +15 -15
- package/src/stories/suggester/data-auto.json +232 -231
- package/src/stories/suggester/data-vtl.json +82 -82
- package/src/stories/suggester/data.json +169 -136
- package/src/stories/suggester/naf-rev2/index.js +2 -2
- package/src/stories/suggester/naf-rev2/option-naf-renderer.js +17 -17
- package/src/stories/suggester/suggester-workers.stories.js +226 -179
- package/src/stories/suggester/suggester.stories.js +138 -133
- package/src/stories/utils/orchestrator-split.js +119 -0
- package/src/stories/utils/orchestrator.js +119 -108
- package/src/tests/components/input-number.spec.js +6 -12
- package/src/tests/components/missing-wrapper.spec.js +0 -1
- package/src/tests/utils/lib/table/roster.spec.js +25 -25
- package/src/tests/utils/to-expose/handler/results/res-input-edited.json +1 -1
- package/src/utils/components/dragger/dragger.scss +7 -7
- package/src/utils/idb-tools/create-db-opener.js +43 -43
- package/src/utils/idb-tools/create-open-db.js +25 -25
- package/src/utils/idb-tools/idb-bulk-insert.js +96 -96
- package/src/utils/idb-tools/index.js +10 -10
- package/src/utils/idb-tools/insert-entity.js +15 -15
- package/src/utils/idb-tools/open-db.js +13 -13
- package/src/utils/idb-tools/open-or-create-db.js +34 -34
- package/src/utils/lib/controls/index.js +1 -0
- package/src/utils/lib/controls/utils.js +152 -0
- package/src/utils/lib/decorator/title-decorator.js +16 -16
- package/src/utils/lib/env.js +2 -2
- package/src/utils/lib/index.js +2 -0
- package/src/utils/lib/input-number.js +1 -1
- package/src/utils/lib/options-positioning.js +9 -9
- package/src/utils/lib/pagination/navigation/shared.js +12 -9
- package/src/utils/lib/prop-types/lines.js +6 -6
- package/src/utils/lib/responses.js +11 -9
- package/src/utils/lib/splitting.js +142 -0
- package/src/utils/lib/style.js +10 -10
- package/src/utils/store-tools/auto-load.js +74 -73
- package/src/utils/suggester-workers/append-to-index/append.js +25 -25
- package/src/utils/suggester-workers/append-to-index/append.worker.js +16 -16
- package/src/utils/suggester-workers/append-to-index/create-append-task.js +45 -43
- package/src/utils/suggester-workers/append-to-index/index.js +2 -2
- package/src/utils/suggester-workers/append-to-index/prepare-entities.js +61 -61
- package/src/utils/suggester-workers/append-to-index/store-messages.js +21 -21
- package/src/utils/suggester-workers/commons-tokenizer/create-entity-tokenizer.js +56 -0
- package/src/utils/suggester-workers/commons-tokenizer/create-fields-tokenizer.js +56 -0
- package/src/utils/suggester-workers/commons-tokenizer/create-filter-stop-words.js +17 -17
- package/src/utils/suggester-workers/commons-tokenizer/filters/compose-filters.js +10 -0
- package/src/utils/suggester-workers/commons-tokenizer/filters/create-filter-stop-words.js +17 -0
- package/src/utils/suggester-workers/commons-tokenizer/filters/create-filter-stop-words.spec.js +14 -0
- package/src/utils/suggester-workers/commons-tokenizer/filters/filter-accents.js +12 -0
- package/src/utils/suggester-workers/commons-tokenizer/filters/filter-accents.spec.js +12 -0
- package/src/utils/suggester-workers/commons-tokenizer/{filter-double.js → filters/filter-double.js} +12 -12
- package/src/utils/suggester-workers/commons-tokenizer/filters/filter-double.spec.js +20 -0
- package/src/utils/suggester-workers/commons-tokenizer/{filter-length.js → filters/filter-length.js} +7 -7
- package/src/utils/suggester-workers/commons-tokenizer/filters/filter-length.spec.js +18 -0
- package/src/utils/suggester-workers/commons-tokenizer/{filter-stemmer.js → filters/filter-stemmer.js} +13 -13
- package/src/utils/suggester-workers/commons-tokenizer/filters/filter-stemmer.spec.js +12 -0
- package/src/utils/suggester-workers/commons-tokenizer/filters/filter-synonyms.js +36 -0
- package/src/utils/suggester-workers/commons-tokenizer/filters/filter-synonyms.spec.js +12 -0
- 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/filters/index.js +2 -0
- package/src/utils/suggester-workers/commons-tokenizer/{stop-words.js → filters/stop-words.js} +118 -118
- package/src/utils/suggester-workers/commons-tokenizer/get-regexp-from-pattern.js +8 -8
- package/src/utils/suggester-workers/commons-tokenizer/get-stemmer.js +18 -18
- package/src/utils/suggester-workers/commons-tokenizer/index.js +9 -8
- package/src/utils/suggester-workers/commons-tokenizer/prepare-string-indexation.js +13 -9
- package/src/utils/suggester-workers/commons-tokenizer/soft-tokenizer.js +7 -7
- package/src/utils/suggester-workers/create-worker.js +56 -0
- package/src/utils/suggester-workers/find-best-label/find-best-label.js +39 -39
- package/src/utils/suggester-workers/find-best-label/find-best-label.worker.js +40 -40
- package/src/utils/suggester-workers/find-best-label/tokenize.js +30 -33
- package/src/utils/suggester-workers/find-best-label/tokenize.spec.js +19 -19
- package/src/utils/suggester-workers/searching/compute-score.js +33 -33
- package/src/utils/suggester-workers/searching/get-db.js +18 -18
- package/src/utils/suggester-workers/searching/index.js +1 -1
- package/src/utils/suggester-workers/searching/order/create-alphanumeric-orderer.js +20 -20
- package/src/utils/suggester-workers/searching/order/index.js +19 -19
- package/src/utils/suggester-workers/{query-parser → searching/query-parser}/index.js +2 -2
- package/src/utils/suggester-workers/searching/query-parser/query-parser-soft.js +7 -0
- package/src/utils/suggester-workers/{query-parser → searching/query-parser}/query-parser-soft.spec.js +24 -24
- package/src/utils/suggester-workers/searching/query-parser/query-parser-tokenized.js +34 -0
- package/src/utils/suggester-workers/searching/resolve-query-parser.js +27 -27
- package/src/utils/suggester-workers/searching/search-in-index.js +17 -17
- package/src/utils/suggester-workers/searching/searching.js +70 -70
- package/src/utils/suggester-workers/searching/searching.worker.js +11 -11
- package/src/utils/to-expose/calculated-variables.js +113 -113
- package/src/utils/to-expose/handler.js +149 -112
- package/src/utils/to-expose/hooks/filter-components.js +27 -12
- package/src/utils/to-expose/hooks/index.js +2 -1
- package/src/utils/to-expose/hooks/lunatic-split.js +428 -0
- package/src/utils/to-expose/hooks/lunatic.js +284 -187
- package/src/utils/to-expose/index.js +1 -1
- package/src/utils/to-expose/init-questionnaire.js +164 -164
- package/src/utils/to-expose/interpret/vtl.js +18 -18
- package/src/utils/to-expose/state.js +66 -58
- package/src/components/missing-wrapper/component.js +0 -120
- package/src/components/missing-wrapper/wrapper.js +0 -10
- package/src/tests/utils/to-expose/hooks/use-lunatic.spec.js +0 -46
- package/src/utils/suggester-workers/commons-tokenizer/create-tokenizer.js +0 -103
- package/src/utils/suggester-workers/commons-tokenizer/filter-accents-to-lower.js +0 -9
- package/src/utils/suggester-workers/commons-tokenizer/filter-synonyms.js +0 -10
- package/src/utils/suggester-workers/query-parser/query-parser-soft.js +0 -7
- package/src/utils/suggester-workers/query-parser/query-parser-tokenized.js +0 -31
- package/src/utils/suggester-workers/query-parser/query-parser-tokenized.spec.js +0 -32
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import KeyboardEventHandler from 'react-keyboard-event-handler';
|
|
3
|
+
import Button from '../../button';
|
|
4
|
+
import * as U from '../../../utils/lib';
|
|
5
|
+
import './missing.scss';
|
|
6
|
+
|
|
7
|
+
const Missing = ({ Component, props }) => {
|
|
8
|
+
const {
|
|
9
|
+
dontKnowButton = "Don't know",
|
|
10
|
+
refusedButton = 'Refused',
|
|
11
|
+
missingResponse,
|
|
12
|
+
handleChange,
|
|
13
|
+
preferences,
|
|
14
|
+
missingStrategy,
|
|
15
|
+
missingShortcut = { dontKnow: '', refused: '' },
|
|
16
|
+
response,
|
|
17
|
+
responses,
|
|
18
|
+
cells,
|
|
19
|
+
components,
|
|
20
|
+
savingType,
|
|
21
|
+
bindings,
|
|
22
|
+
shortcut,
|
|
23
|
+
componentType,
|
|
24
|
+
paginatedLoop,
|
|
25
|
+
} = props;
|
|
26
|
+
|
|
27
|
+
const missingResponseName = U.getResponseName(missingResponse);
|
|
28
|
+
const buttonState = U.getResponseByPreference(preferences)(missingResponse);
|
|
29
|
+
const [oldMissingValue] = useState(() => buttonState);
|
|
30
|
+
|
|
31
|
+
const [bindingsForMissingStrategy, setBindingsForMissingStrategy] =
|
|
32
|
+
useState(null);
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Sources split: use MissingStragy only if missingResponse has been updated
|
|
36
|
+
* Ensures that missingResponse is persisted when the source has to be changed
|
|
37
|
+
*/
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
const isSameValue = buttonState === oldMissingValue;
|
|
40
|
+
if (bindingsForMissingStrategy && !isSameValue) {
|
|
41
|
+
if (U.isFunction(missingStrategy))
|
|
42
|
+
missingStrategy(bindingsForMissingStrategy);
|
|
43
|
+
setBindingsForMissingStrategy(null);
|
|
44
|
+
}
|
|
45
|
+
}, [
|
|
46
|
+
bindingsForMissingStrategy,
|
|
47
|
+
missingStrategy,
|
|
48
|
+
buttonState,
|
|
49
|
+
oldMissingValue,
|
|
50
|
+
]);
|
|
51
|
+
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
if (
|
|
54
|
+
buttonState !== null &&
|
|
55
|
+
U.hasToCleanMissing(savingType)({
|
|
56
|
+
response,
|
|
57
|
+
responses,
|
|
58
|
+
cells,
|
|
59
|
+
components,
|
|
60
|
+
})
|
|
61
|
+
) {
|
|
62
|
+
handleChange({ [missingResponseName]: null });
|
|
63
|
+
}
|
|
64
|
+
}, [
|
|
65
|
+
buttonState,
|
|
66
|
+
handleChange,
|
|
67
|
+
savingType,
|
|
68
|
+
response,
|
|
69
|
+
responses,
|
|
70
|
+
cells,
|
|
71
|
+
components,
|
|
72
|
+
missingResponseName,
|
|
73
|
+
]);
|
|
74
|
+
|
|
75
|
+
const getVarsToClean = () =>
|
|
76
|
+
U.getToClean(savingType)({
|
|
77
|
+
response,
|
|
78
|
+
responses,
|
|
79
|
+
cells,
|
|
80
|
+
components,
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
const onClick = (value) => () => {
|
|
84
|
+
const isSameValue = buttonState === value;
|
|
85
|
+
if (!isSameValue) {
|
|
86
|
+
const toClean = getVarsToClean();
|
|
87
|
+
if (Object.keys(toClean)) {
|
|
88
|
+
const { currentPage } = props;
|
|
89
|
+
const currentIterationIndex = getCurrentIterationIndex({
|
|
90
|
+
currentPage,
|
|
91
|
+
});
|
|
92
|
+
handleChange(toClean);
|
|
93
|
+
if (U.isFunction(missingStrategy)) {
|
|
94
|
+
const { fullBindings } = props;
|
|
95
|
+
const toHandle = getVarsToHandle({
|
|
96
|
+
toClean,
|
|
97
|
+
fullBindings,
|
|
98
|
+
currentIterationIndex,
|
|
99
|
+
});
|
|
100
|
+
const missingBindings = getMissingBindings({
|
|
101
|
+
currentIterationIndex,
|
|
102
|
+
bindings,
|
|
103
|
+
fullBindings,
|
|
104
|
+
toHandle,
|
|
105
|
+
});
|
|
106
|
+
setBindingsForMissingStrategy(missingBindings);
|
|
107
|
+
}
|
|
108
|
+
} else {
|
|
109
|
+
if (U.isFunction(missingStrategy))
|
|
110
|
+
setBindingsForMissingStrategy(bindings);
|
|
111
|
+
}
|
|
112
|
+
handleChange({ [missingResponseName]: value });
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
if ((componentType === 'Loop' && paginatedLoop) || !missingResponse)
|
|
117
|
+
return <Component {...props} />;
|
|
118
|
+
|
|
119
|
+
return (
|
|
120
|
+
<div className="missing-wrapper">
|
|
121
|
+
<div className="missing-component">
|
|
122
|
+
<Component {...props} />
|
|
123
|
+
</div>
|
|
124
|
+
<div className="missing-buttons">
|
|
125
|
+
<span
|
|
126
|
+
className={`missing-button${
|
|
127
|
+
buttonState === U.DK ? '-active' : ''
|
|
128
|
+
} missing-button-dk${buttonState === U.DK ? '-active' : ''}`}
|
|
129
|
+
>
|
|
130
|
+
<Button
|
|
131
|
+
label="dont-know-button"
|
|
132
|
+
value={dontKnowButton}
|
|
133
|
+
disabled={!missingResponseName || missingResponseName?.length === 0}
|
|
134
|
+
onClick={onClick(U.DK)}
|
|
135
|
+
/>
|
|
136
|
+
</span>
|
|
137
|
+
<span
|
|
138
|
+
className={`missing-button${
|
|
139
|
+
buttonState === U.RF ? '-active' : ''
|
|
140
|
+
} missing-button-rf${buttonState === U.RF ? '-active' : ''}`}
|
|
141
|
+
>
|
|
142
|
+
<Button
|
|
143
|
+
label="refused-button"
|
|
144
|
+
value={refusedButton}
|
|
145
|
+
disabled={!missingResponseName || missingResponseName?.length === 0}
|
|
146
|
+
onClick={onClick(U.RF)}
|
|
147
|
+
/>
|
|
148
|
+
</span>
|
|
149
|
+
</div>
|
|
150
|
+
{shortcut &&
|
|
151
|
+
missingResponseName?.length > 0 &&
|
|
152
|
+
missingShortcut &&
|
|
153
|
+
missingShortcut.dontKnow &&
|
|
154
|
+
missingShortcut.refused && (
|
|
155
|
+
<KeyboardEventHandler
|
|
156
|
+
handleKeys={Object.values(missingShortcut)}
|
|
157
|
+
onKeyEvent={(key, e) => {
|
|
158
|
+
e.preventDefault();
|
|
159
|
+
if (key === missingShortcut.dontKnow) onClick(U.DK)();
|
|
160
|
+
if (key === missingShortcut.refused) onClick(U.RF)();
|
|
161
|
+
}}
|
|
162
|
+
handleFocusableElements
|
|
163
|
+
/>
|
|
164
|
+
)}
|
|
165
|
+
</div>
|
|
166
|
+
);
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
export default Missing;
|
|
170
|
+
|
|
171
|
+
// TODO: make it recursive for Loop into Loop
|
|
172
|
+
const getCurrentIterationIndex = ({ currentPage }) => {
|
|
173
|
+
const { currentIteration } = U.splitPage(currentPage, 1);
|
|
174
|
+
if (currentIteration) return currentIteration - 1;
|
|
175
|
+
return null;
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
// TODO: make it recursive for Loop into Loop
|
|
179
|
+
const getVarsToHandle = ({ toClean, fullBindings, currentIterationIndex }) => {
|
|
180
|
+
if (currentIterationIndex || currentIterationIndex === 0) {
|
|
181
|
+
return Object.entries(toClean).reduce((acc, [name, value]) => {
|
|
182
|
+
const newValue = fullBindings[name].map((v, i) =>
|
|
183
|
+
i === currentIterationIndex ? value : v
|
|
184
|
+
);
|
|
185
|
+
return { ...acc, [name]: newValue };
|
|
186
|
+
}, {});
|
|
187
|
+
}
|
|
188
|
+
return toClean;
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
const getMissingBindings = ({
|
|
192
|
+
bindings,
|
|
193
|
+
fullBindings,
|
|
194
|
+
currentIterationIndex,
|
|
195
|
+
toHandle,
|
|
196
|
+
}) => {
|
|
197
|
+
if (currentIterationIndex || currentIterationIndex === 0)
|
|
198
|
+
return { ...fullBindings, ...toHandle };
|
|
199
|
+
return { ...bindings, ...toHandle };
|
|
200
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './component';
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
.lunatic-component {
|
|
2
|
-
.missing-wrapper {
|
|
3
|
-
.missing-buttons {
|
|
4
|
-
margin-top: 1em;
|
|
5
|
-
.button-lunatic {
|
|
6
|
-
width: 4em;
|
|
7
|
-
font-size: 1em;
|
|
8
|
-
font-weight: normal;
|
|
9
|
-
}
|
|
10
|
-
.missing-button {
|
|
11
|
-
.button-lunatic {
|
|
12
|
-
background-color: var(--color-very-very-light);
|
|
13
|
-
color: var(--color-primary-dark);
|
|
14
|
-
&:hover {
|
|
15
|
-
background-color: white;
|
|
16
|
-
color: var(--color-primary-main);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
.missing-button-active {
|
|
21
|
-
.button-lunatic {
|
|
22
|
-
background-color: var(--color-primary-dark);
|
|
23
|
-
color: var(--color-very-very-light);
|
|
24
|
-
&:hover {
|
|
25
|
-
background-color: var(--color-primary-main);
|
|
26
|
-
color: white;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
1
|
+
.lunatic-component {
|
|
2
|
+
.missing-wrapper {
|
|
3
|
+
.missing-buttons {
|
|
4
|
+
margin-top: 1em;
|
|
5
|
+
.button-lunatic {
|
|
6
|
+
width: 4em;
|
|
7
|
+
font-size: 1em;
|
|
8
|
+
font-weight: normal;
|
|
9
|
+
}
|
|
10
|
+
.missing-button {
|
|
11
|
+
.button-lunatic {
|
|
12
|
+
background-color: var(--color-very-very-light);
|
|
13
|
+
color: var(--color-primary-dark);
|
|
14
|
+
&:hover {
|
|
15
|
+
background-color: white;
|
|
16
|
+
color: var(--color-primary-main);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
.missing-button-active {
|
|
21
|
+
.button-lunatic {
|
|
22
|
+
background-color: var(--color-primary-dark);
|
|
23
|
+
color: var(--color-very-very-light);
|
|
24
|
+
&:hover {
|
|
25
|
+
background-color: var(--color-primary-main);
|
|
26
|
+
color: white;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Missing from './missing';
|
|
3
|
+
import Controls from './controls';
|
|
4
|
+
|
|
5
|
+
const componentWrapper = (Component) => (props) => {
|
|
6
|
+
const { missing, controls, componentType } = props;
|
|
7
|
+
const hasC = hasControls(controls, componentType);
|
|
8
|
+
if (missing && !hasC) return <Missing Component={Component} props={props} />;
|
|
9
|
+
if (!missing && hasC) return <Controls Component={Component} props={props} />;
|
|
10
|
+
if (missing && hasC) {
|
|
11
|
+
const ControlComponent = () => (
|
|
12
|
+
<Controls Component={Component} props={props} />
|
|
13
|
+
);
|
|
14
|
+
return <Missing Component={ControlComponent} props={props} />;
|
|
15
|
+
}
|
|
16
|
+
return <Component {...props} />;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const hasControls = (controls, componentType) =>
|
|
20
|
+
(Array.isArray(controls) && controls.length > 0) ||
|
|
21
|
+
['InputNumber', 'Datepicker'].includes(componentType);
|
|
22
|
+
|
|
23
|
+
export default componentWrapper;
|
|
@@ -6,6 +6,7 @@ export { default as Declarations } from './declarations';
|
|
|
6
6
|
export { default as Dropdown } from './dropdown';
|
|
7
7
|
export * from './input';
|
|
8
8
|
export { default as FilterDescription } from './filter-description';
|
|
9
|
+
export { default as Modal } from './modal';
|
|
9
10
|
export { default as ProgressBar } from './progress-bar';
|
|
10
11
|
export { default as Radio } from './radio';
|
|
11
12
|
export { default as Loop } from './loop';
|
|
@@ -1,11 +1,26 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import '
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
)
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import componentWrapper from '../component-wrapper';
|
|
4
|
+
import { InputDeclarationsWrapper } from '../declarations/wrappers';
|
|
5
|
+
import { areEqual } from '../../utils/lib';
|
|
6
|
+
import { getTypeControls } from '../component-wrapper/controls/validators';
|
|
7
|
+
import './datepicker.scss';
|
|
8
|
+
|
|
9
|
+
const Datepicker = (props) => (
|
|
10
|
+
<InputDeclarationsWrapper
|
|
11
|
+
type="date"
|
|
12
|
+
roleType="datepicker"
|
|
13
|
+
{...props}
|
|
14
|
+
validators={[getTypeControls]}
|
|
15
|
+
/>
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
Datepicker.defaultProps = {
|
|
19
|
+
validators: [],
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
Datepicker.propTypes = {
|
|
23
|
+
validators: PropTypes.arrayOf(PropTypes.func),
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export default componentWrapper(React.memo(Datepicker, areEqual));
|
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import * as U from '../../utils/lib';
|
|
4
|
-
import { interpret } from '../../utils/to-expose';
|
|
5
|
-
import './declarations.scss';
|
|
6
|
-
|
|
7
|
-
const Declarations = ({
|
|
8
|
-
id,
|
|
9
|
-
type,
|
|
10
|
-
declarations,
|
|
11
|
-
features,
|
|
12
|
-
bindings,
|
|
13
|
-
logFunction,
|
|
14
|
-
}) => {
|
|
15
|
-
const filtered = declarations.filter(({ position }) => position === type);
|
|
16
|
-
if (filtered.length === 0) return null;
|
|
17
|
-
return (
|
|
18
|
-
<div id={`declarations-${id}-${type}`} className="declarations-lunatic">
|
|
19
|
-
{filtered.map(({ id: idD, label, declarationType }) => (
|
|
20
|
-
<div
|
|
21
|
-
key={`${idD}`}
|
|
22
|
-
className={`declaration-lunatic declaration-${declarationType.toLowerCase()}`}
|
|
23
|
-
>
|
|
24
|
-
{interpret(features, logFunction)(bindings)(label)}
|
|
25
|
-
</div>
|
|
26
|
-
))}
|
|
27
|
-
</div>
|
|
28
|
-
);
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
Declarations.defaultProps = {
|
|
32
|
-
type: 'AFTER_QUESTION_TEXT',
|
|
33
|
-
declarations: [],
|
|
34
|
-
features: [],
|
|
35
|
-
bindings: {},
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
Declarations.propTypes = {
|
|
39
|
-
id: PropTypes.string.isRequired,
|
|
40
|
-
type: PropTypes.string,
|
|
41
|
-
declarations: U.declarationsPropTypes,
|
|
42
|
-
features: PropTypes.arrayOf(PropTypes.string),
|
|
43
|
-
bindings: PropTypes.object,
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export default Declarations;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import * as U from '../../utils/lib';
|
|
4
|
+
import { interpret } from '../../utils/to-expose';
|
|
5
|
+
import './declarations.scss';
|
|
6
|
+
|
|
7
|
+
const Declarations = ({
|
|
8
|
+
id,
|
|
9
|
+
type,
|
|
10
|
+
declarations,
|
|
11
|
+
features,
|
|
12
|
+
bindings,
|
|
13
|
+
logFunction,
|
|
14
|
+
}) => {
|
|
15
|
+
const filtered = declarations.filter(({ position }) => position === type);
|
|
16
|
+
if (filtered.length === 0) return null;
|
|
17
|
+
return (
|
|
18
|
+
<div id={`declarations-${id}-${type}`} className="declarations-lunatic">
|
|
19
|
+
{filtered.map(({ id: idD, label, declarationType }) => (
|
|
20
|
+
<div
|
|
21
|
+
key={`${idD}`}
|
|
22
|
+
className={`declaration-lunatic declaration-${declarationType.toLowerCase()}`}
|
|
23
|
+
>
|
|
24
|
+
{interpret(features, logFunction)(bindings)(label)}
|
|
25
|
+
</div>
|
|
26
|
+
))}
|
|
27
|
+
</div>
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
Declarations.defaultProps = {
|
|
32
|
+
type: 'AFTER_QUESTION_TEXT',
|
|
33
|
+
declarations: [],
|
|
34
|
+
features: [],
|
|
35
|
+
bindings: {},
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
Declarations.propTypes = {
|
|
39
|
+
id: PropTypes.string.isRequired,
|
|
40
|
+
type: PropTypes.string,
|
|
41
|
+
declarations: U.declarationsPropTypes,
|
|
42
|
+
features: PropTypes.arrayOf(PropTypes.string),
|
|
43
|
+
bindings: PropTypes.object,
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export default Declarations;
|
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
.lunatic-component {
|
|
2
|
-
.declarations-lunatic {
|
|
3
|
-
margin-bottom: 0.4rem;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
.declaration-instruction {
|
|
7
|
-
font-style: italic;
|
|
8
|
-
font-size: 80%;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
.declaration-comment {
|
|
12
|
-
font-size: 80%;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.declaration-statement {
|
|
16
|
-
font-style: italic;
|
|
17
|
-
font-size: 80%;
|
|
18
|
-
color: blue;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.declaration-help {
|
|
22
|
-
font-style: italic;
|
|
23
|
-
font-size: 80%;
|
|
24
|
-
color: green;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.declaration-warning {
|
|
28
|
-
font-style: bold;
|
|
29
|
-
font-size: 80%;
|
|
30
|
-
color: red;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.declaration-message_filter {
|
|
34
|
-
font-size: 100%;
|
|
35
|
-
color: rgb(73, 66, 66);
|
|
36
|
-
&:before {
|
|
37
|
-
content: '→ ';
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
1
|
+
.lunatic-component {
|
|
2
|
+
.declarations-lunatic {
|
|
3
|
+
margin-bottom: 0.4rem;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.declaration-instruction {
|
|
7
|
+
font-style: italic;
|
|
8
|
+
font-size: 80%;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.declaration-comment {
|
|
12
|
+
font-size: 80%;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.declaration-statement {
|
|
16
|
+
font-style: italic;
|
|
17
|
+
font-size: 80%;
|
|
18
|
+
color: blue;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.declaration-help {
|
|
22
|
+
font-style: italic;
|
|
23
|
+
font-size: 80%;
|
|
24
|
+
color: green;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.declaration-warning {
|
|
28
|
+
font-style: bold;
|
|
29
|
+
font-size: 80%;
|
|
30
|
+
color: red;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.declaration-message_filter {
|
|
34
|
+
font-size: 100%;
|
|
35
|
+
color: rgb(73, 66, 66);
|
|
36
|
+
&:before {
|
|
37
|
+
content: '→ ';
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|