@inseefr/lunatic 0.3.4-experimental → 0.3.7-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 +2 -2
- package/lib/index.js.map +1 -1
- package/package.json +2 -1
- package/src/components/breadcrumb/component.js +29 -29
- package/src/components/button/component.js +53 -53
- package/src/components/button/index.js +1 -1
- package/src/components/checkbox/index.js +3 -3
- package/src/components/datepicker/index.js +1 -1
- package/src/components/declarations/index.js +1 -1
- package/src/components/declarations/wrappers/list-declarations-wrapper.js +232 -232
- package/src/components/filter-description/component.js +42 -42
- package/src/components/icon/component.js +33 -33
- package/src/components/index.js +2 -0
- package/src/components/input/index.js +2 -2
- package/src/components/loop/index.js +1 -1
- package/src/components/loop-constructor/wrapper/body-component.js +13 -1
- package/src/components/radio/index.js +1 -1
- package/src/components/sequence/index.js +1 -1
- package/src/components/subsequence/index.js +1 -1
- package/src/components/suggester/check-store.js +70 -70
- package/src/components/suggester/components/create-on-keydown-callback.js +28 -28
- package/src/components/tooltip/response.js +52 -52
- package/src/stories/checkbox-boolean/data-forced.json +48 -48
- package/src/stories/checkbox-group/data-vtl.json +102 -102
- package/src/stories/icons/icons.stories.js +16 -16
- package/src/stories/questionnaire/kish.json +275 -0
- package/src/stories/questionnaire/questionnaire.stories.js +12 -0
- package/src/stories/utils/custom-lunatic.scss +23 -23
- package/src/tests/components/breadcrumb.spec.js +13 -13
- package/src/tests/components/button.spec.js +11 -11
- package/src/tests/components/checkbox-boolean.spec.js +45 -45
- package/src/tests/components/checkbox-group.spec.js +53 -53
- package/src/tests/components/checkbox-one.spec.js +32 -32
- package/src/tests/components/datepicker.spec.js +22 -22
- package/src/tests/components/declarations-wrappers/input-declarations-wrapper.spec.js +67 -67
- package/src/tests/components/declarations-wrappers/list-declarations-wrapper.spec.js +52 -52
- package/src/tests/components/declarations-wrappers/simple-declarations-wrapper.spec.js +21 -21
- package/src/tests/components/declarations.spec.js +46 -46
- package/src/tests/components/input.spec.js +18 -18
- package/src/tests/components/loops/loop-static.json +66 -66
- package/src/tests/components/loops/loop.json +258 -258
- package/src/tests/components/loops/loop.spec.js +30 -30
- package/src/tests/components/loops/roster-for-loop.spec.js +18 -18
- package/src/tests/components/progress-bar.spec.js +15 -15
- package/src/tests/components/radio.spec.js +27 -27
- package/src/tests/components/sequence.spec.js +9 -9
- package/src/tests/components/subsequence.spec.js +9 -9
- package/src/tests/components/table.spec.js +11 -11
- package/src/tests/components/textarea.spec.js +18 -18
- package/src/tests/components/tooltip.spec.js +25 -25
- package/src/tests/setup/setupTests.js +4 -4
- package/src/tests/utils/lib/alphabet.spec.js +36 -36
- package/src/tests/utils/lib/array.spec.js +22 -22
- package/src/tests/utils/lib/checkbox/group.spec.js +72 -72
- package/src/tests/utils/lib/decorator/title-decorator.spec.js +12 -12
- package/src/tests/utils/lib/input-number.spec.js +18 -18
- package/src/tests/utils/lib/items-positioning.spec.js +17 -17
- package/src/tests/utils/lib/label-position.spec.js +22 -22
- package/src/tests/utils/lib/loops/bindings.spec.js +75 -75
- package/src/tests/utils/lib/loops/shared.spec.js +82 -82
- package/src/tests/utils/lib/missing/missing.spec.js +74 -74
- package/src/tests/utils/lib/missing/mock.js +137 -137
- package/src/tests/utils/lib/pagination/shared.spec.js +42 -42
- package/src/tests/utils/lib/responses.spec.js +64 -64
- package/src/tests/utils/lib/style.spec.js +26 -26
- package/src/tests/utils/lib/tooltip/build-response.spec.js +95 -95
- package/src/tests/utils/lib/tooltip/content.spec.js +109 -109
- package/src/tests/utils/to-expose/handler/handler.spec.js +94 -94
- package/src/tests/utils/to-expose/handler/questionnaire.json +158 -158
- package/src/tests/utils/to-expose/handler/results/index.js +6 -6
- package/src/tests/utils/to-expose/handler/results/res-double.json +158 -158
- package/src/tests/utils/to-expose/handler/results/res-input-collected.json +158 -158
- package/src/tests/utils/to-expose/handler/results/res-loop.json +158 -158
- package/src/tests/utils/to-expose/handler/results/res-matrix.json +158 -158
- package/src/tests/utils/to-expose/handler/results/res-responses.json +158 -158
- package/src/tests/utils/to-expose/hooks/use-lunatic.spec.js +46 -46
- package/src/tests/utils/to-expose/init-questionnaire/data.json +12 -12
- package/src/tests/utils/to-expose/init-questionnaire/init-questionnaire.spec.js +19 -19
- package/src/tests/utils/to-expose/interpret/interpret.spec.js +48 -48
- package/src/tests/utils/to-expose/state/questionnaire.json +61 -61
- package/src/tests/utils/to-expose/state/results.js +78 -78
- package/src/utils/lib/tooltip/build-response.js +41 -41
- package/src/utils/store-tools/create/index.js +1 -1
- package/src/utils/store-tools/create/update-store-info.js +26 -26
- package/src/utils/store-tools/index.js +5 -5
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { interpret } from '../../utils/to-expose';
|
|
4
|
-
import { buildStyleObject } from '../../utils/lib';
|
|
5
|
-
|
|
6
|
-
const FilterDescription = ({
|
|
7
|
-
id,
|
|
8
|
-
label,
|
|
9
|
-
filterDescription,
|
|
10
|
-
features,
|
|
11
|
-
bindings,
|
|
12
|
-
style,
|
|
13
|
-
logFunction,
|
|
14
|
-
}) =>
|
|
15
|
-
filterDescription ? (
|
|
16
|
-
<div
|
|
17
|
-
id={`filter-description-${id}`}
|
|
18
|
-
aria-label={`filter-description`}
|
|
19
|
-
className="filter-description-lunatic"
|
|
20
|
-
style={buildStyleObject(style)}
|
|
21
|
-
>
|
|
22
|
-
{interpret(features, logFunction)(bindings)(label)}
|
|
23
|
-
</div>
|
|
24
|
-
) : null;
|
|
25
|
-
|
|
26
|
-
FilterDescription.defaultProps = {
|
|
27
|
-
filterDescription: false,
|
|
28
|
-
features: [],
|
|
29
|
-
bindings: {},
|
|
30
|
-
style: {},
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
FilterDescription.propTypes = {
|
|
34
|
-
id: PropTypes.string.isRequired,
|
|
35
|
-
label: PropTypes.string.isRequired,
|
|
36
|
-
filterDescription: PropTypes.bool,
|
|
37
|
-
features: PropTypes.arrayOf(PropTypes.string),
|
|
38
|
-
bindings: PropTypes.object,
|
|
39
|
-
style: PropTypes.object,
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export default FilterDescription;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { interpret } from '../../utils/to-expose';
|
|
4
|
+
import { buildStyleObject } from '../../utils/lib';
|
|
5
|
+
|
|
6
|
+
const FilterDescription = ({
|
|
7
|
+
id,
|
|
8
|
+
label,
|
|
9
|
+
filterDescription,
|
|
10
|
+
features,
|
|
11
|
+
bindings,
|
|
12
|
+
style,
|
|
13
|
+
logFunction,
|
|
14
|
+
}) =>
|
|
15
|
+
filterDescription ? (
|
|
16
|
+
<div
|
|
17
|
+
id={`filter-description-${id}`}
|
|
18
|
+
aria-label={`filter-description`}
|
|
19
|
+
className="filter-description-lunatic"
|
|
20
|
+
style={buildStyleObject(style)}
|
|
21
|
+
>
|
|
22
|
+
{interpret(features, logFunction)(bindings)(label)}
|
|
23
|
+
</div>
|
|
24
|
+
) : null;
|
|
25
|
+
|
|
26
|
+
FilterDescription.defaultProps = {
|
|
27
|
+
filterDescription: false,
|
|
28
|
+
features: [],
|
|
29
|
+
bindings: {},
|
|
30
|
+
style: {},
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
FilterDescription.propTypes = {
|
|
34
|
+
id: PropTypes.string.isRequired,
|
|
35
|
+
label: PropTypes.string.isRequired,
|
|
36
|
+
filterDescription: PropTypes.bool,
|
|
37
|
+
features: PropTypes.arrayOf(PropTypes.string),
|
|
38
|
+
bindings: PropTypes.object,
|
|
39
|
+
style: PropTypes.object,
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export default FilterDescription;
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
CheckboxChecked,
|
|
4
|
-
CheckboxUnchecked,
|
|
5
|
-
RadioChecked,
|
|
6
|
-
RadioUnchecked,
|
|
7
|
-
} from './assets';
|
|
8
|
-
import './icon.scss';
|
|
9
|
-
|
|
10
|
-
const Content = ({ type, checked }) => {
|
|
11
|
-
if (type === 'radio') {
|
|
12
|
-
if (checked) return <RadioChecked />;
|
|
13
|
-
return <RadioUnchecked />;
|
|
14
|
-
}
|
|
15
|
-
if (type === 'checkbox') {
|
|
16
|
-
if (checked) return <CheckboxChecked />;
|
|
17
|
-
return <CheckboxUnchecked />;
|
|
18
|
-
}
|
|
19
|
-
return null;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const Icon = ({ type, checked, disabled, children }) => (
|
|
23
|
-
<>
|
|
24
|
-
<span className={`list-icon-wrapper`}>
|
|
25
|
-
<span className={`list-icon ${disabled ? 'list-icon-disabled' : ''}`}>
|
|
26
|
-
<Content type={type} checked={checked} />
|
|
27
|
-
</span>
|
|
28
|
-
{children}
|
|
29
|
-
</span>
|
|
30
|
-
</>
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
export default Icon;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
CheckboxChecked,
|
|
4
|
+
CheckboxUnchecked,
|
|
5
|
+
RadioChecked,
|
|
6
|
+
RadioUnchecked,
|
|
7
|
+
} from './assets';
|
|
8
|
+
import './icon.scss';
|
|
9
|
+
|
|
10
|
+
const Content = ({ type, checked }) => {
|
|
11
|
+
if (type === 'radio') {
|
|
12
|
+
if (checked) return <RadioChecked />;
|
|
13
|
+
return <RadioUnchecked />;
|
|
14
|
+
}
|
|
15
|
+
if (type === 'checkbox') {
|
|
16
|
+
if (checked) return <CheckboxChecked />;
|
|
17
|
+
return <CheckboxUnchecked />;
|
|
18
|
+
}
|
|
19
|
+
return null;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const Icon = ({ type, checked, disabled, children }) => (
|
|
23
|
+
<>
|
|
24
|
+
<span className={`list-icon-wrapper`}>
|
|
25
|
+
<span className={`list-icon ${disabled ? 'list-icon-disabled' : ''}`}>
|
|
26
|
+
<Content type={type} checked={checked} />
|
|
27
|
+
</span>
|
|
28
|
+
{children}
|
|
29
|
+
</span>
|
|
30
|
+
</>
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
export default Icon;
|
package/src/components/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default as Input } from './input';
|
|
2
|
-
export { default as InputNumber } from './input-number';
|
|
1
|
+
export { default as Input } from './input';
|
|
2
|
+
export { default as InputNumber } from './input-number';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default } from './wrapper';
|
|
1
|
+
export { default } from './wrapper';
|
|
@@ -23,6 +23,7 @@ const BodyComponent = ({
|
|
|
23
23
|
components,
|
|
24
24
|
headers,
|
|
25
25
|
});
|
|
26
|
+
const featuresWithoutMD = features.filter((f) => f !== 'MD');
|
|
26
27
|
if (componentType === 'RosterForLoop')
|
|
27
28
|
return (
|
|
28
29
|
<table id={`table-${mainId}`} className="table-lunatic">
|
|
@@ -38,10 +39,16 @@ const BodyComponent = ({
|
|
|
38
39
|
componentType,
|
|
39
40
|
id,
|
|
40
41
|
rowNumber,
|
|
42
|
+
conditionFilter,
|
|
41
43
|
...componentProps
|
|
42
44
|
} = component;
|
|
43
45
|
const localBindings =
|
|
44
46
|
U.buildBindingsForDeeperComponents(rowNumber)(bindings);
|
|
47
|
+
if (conditionFilter) {
|
|
48
|
+
const { value = '' } = conditionFilter;
|
|
49
|
+
if (!interpret(featuresWithoutMD)(localBindings)(value))
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
45
52
|
if (componentType) {
|
|
46
53
|
const Component = lunatic[componentType];
|
|
47
54
|
return (
|
|
@@ -101,7 +108,12 @@ const BodyComponent = ({
|
|
|
101
108
|
const localBindings =
|
|
102
109
|
U.buildBindingsForDeeperComponents(i)(bindings);
|
|
103
110
|
// ensure to have only N-1 missingResponse
|
|
104
|
-
const { missingResponse } = componentProps;
|
|
111
|
+
const { missingResponse, conditionFilter } = componentProps;
|
|
112
|
+
if (conditionFilter) {
|
|
113
|
+
const { value = '' } = conditionFilter;
|
|
114
|
+
if (!interpret(featuresWithoutMD)(localBindings)(value))
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
105
117
|
return (
|
|
106
118
|
<div className="block-component" key={`${id}-row-${i}`}>
|
|
107
119
|
<Component
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default } from './component';
|
|
1
|
+
export { default } from './component';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default } from './component';
|
|
1
|
+
export { default } from './component';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default } from './component';
|
|
1
|
+
export { default } from './component';
|
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
import React, { useEffect, useState, useCallback } from 'react';
|
|
2
|
-
import { openDb, getEntity } from '../../utils/idb-tools';
|
|
3
|
-
import { CONSTANTES } from '../../utils/store-tools';
|
|
4
|
-
|
|
5
|
-
function CheckStore({ storeName, version, setStore, children }) {
|
|
6
|
-
const [ready, setReady] = useState(0);
|
|
7
|
-
const [refresh, setRefresh] = useState(false);
|
|
8
|
-
const [disabled, setDisabled] = useState(false);
|
|
9
|
-
|
|
10
|
-
const checkStore = useCallback(
|
|
11
|
-
async function () {
|
|
12
|
-
try {
|
|
13
|
-
const db = await openDb(storeName, version);
|
|
14
|
-
const info = await getEntity(db, CONSTANTES.STORE_INFO_NAME, storeName);
|
|
15
|
-
|
|
16
|
-
if (db && info) {
|
|
17
|
-
setReady(200);
|
|
18
|
-
setStore(info);
|
|
19
|
-
}
|
|
20
|
-
} catch (e) {
|
|
21
|
-
setReady(400);
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
[storeName, version, setStore]
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
useEffect(
|
|
28
|
-
function () {
|
|
29
|
-
checkStore();
|
|
30
|
-
},
|
|
31
|
-
[checkStore]
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
useEffect(
|
|
35
|
-
function () {
|
|
36
|
-
if (refresh) {
|
|
37
|
-
setRefresh(false);
|
|
38
|
-
setDisabled(true);
|
|
39
|
-
async function go() {
|
|
40
|
-
await checkStore();
|
|
41
|
-
setDisabled(false);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
go();
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
[refresh]
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
if (ready === 0) {
|
|
51
|
-
return (
|
|
52
|
-
<div className="lunatic-suggester-in-progress">
|
|
53
|
-
Le store {storeName} est en cour de chargement.
|
|
54
|
-
</div>
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
if (ready === 200) {
|
|
58
|
-
return children;
|
|
59
|
-
}
|
|
60
|
-
return (
|
|
61
|
-
<div className="lunatic-suggester-unvailable">
|
|
62
|
-
Le store {storeName} n'est pas disponible.
|
|
63
|
-
<button disabled={disabled} onClick={() => setRefresh(true)}>
|
|
64
|
-
Refresh
|
|
65
|
-
</button>
|
|
66
|
-
</div>
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export default CheckStore;
|
|
1
|
+
import React, { useEffect, useState, useCallback } from 'react';
|
|
2
|
+
import { openDb, getEntity } from '../../utils/idb-tools';
|
|
3
|
+
import { CONSTANTES } from '../../utils/store-tools';
|
|
4
|
+
|
|
5
|
+
function CheckStore({ storeName, version, setStore, children }) {
|
|
6
|
+
const [ready, setReady] = useState(0);
|
|
7
|
+
const [refresh, setRefresh] = useState(false);
|
|
8
|
+
const [disabled, setDisabled] = useState(false);
|
|
9
|
+
|
|
10
|
+
const checkStore = useCallback(
|
|
11
|
+
async function () {
|
|
12
|
+
try {
|
|
13
|
+
const db = await openDb(storeName, version);
|
|
14
|
+
const info = await getEntity(db, CONSTANTES.STORE_INFO_NAME, storeName);
|
|
15
|
+
|
|
16
|
+
if (db && info) {
|
|
17
|
+
setReady(200);
|
|
18
|
+
setStore(info);
|
|
19
|
+
}
|
|
20
|
+
} catch (e) {
|
|
21
|
+
setReady(400);
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
[storeName, version, setStore]
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
useEffect(
|
|
28
|
+
function () {
|
|
29
|
+
checkStore();
|
|
30
|
+
},
|
|
31
|
+
[checkStore]
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
useEffect(
|
|
35
|
+
function () {
|
|
36
|
+
if (refresh) {
|
|
37
|
+
setRefresh(false);
|
|
38
|
+
setDisabled(true);
|
|
39
|
+
async function go() {
|
|
40
|
+
await checkStore();
|
|
41
|
+
setDisabled(false);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
go();
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
[refresh]
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
if (ready === 0) {
|
|
51
|
+
return (
|
|
52
|
+
<div className="lunatic-suggester-in-progress">
|
|
53
|
+
Le store {storeName} est en cour de chargement.
|
|
54
|
+
</div>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
if (ready === 200) {
|
|
58
|
+
return children;
|
|
59
|
+
}
|
|
60
|
+
return (
|
|
61
|
+
<div className="lunatic-suggester-unvailable">
|
|
62
|
+
Le store {storeName} n'est pas disponible.
|
|
63
|
+
<button disabled={disabled} onClick={() => setRefresh(true)}>
|
|
64
|
+
Refresh
|
|
65
|
+
</button>
|
|
66
|
+
</div>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export default CheckStore;
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import { actions } from '../state-management';
|
|
2
|
-
import { BINDED_KEYS } from '../commons-tools';
|
|
3
|
-
|
|
4
|
-
function create(dispatch) {
|
|
5
|
-
return function (e) {
|
|
6
|
-
const { key } = e;
|
|
7
|
-
switch (key) {
|
|
8
|
-
case BINDED_KEYS.Tab:
|
|
9
|
-
e.stopPropagation();
|
|
10
|
-
// e.preventDefault();
|
|
11
|
-
dispatch(actions.onKeyDown(key));
|
|
12
|
-
break;
|
|
13
|
-
case BINDED_KEYS.ArrowDown:
|
|
14
|
-
case BINDED_KEYS.ArrowUp:
|
|
15
|
-
case BINDED_KEYS.Home:
|
|
16
|
-
case BINDED_KEYS.End:
|
|
17
|
-
case BINDED_KEYS.Enter:
|
|
18
|
-
case BINDED_KEYS.Escape:
|
|
19
|
-
e.preventDefault();
|
|
20
|
-
e.stopPropagation();
|
|
21
|
-
dispatch(actions.onKeyDown(key));
|
|
22
|
-
break;
|
|
23
|
-
default:
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export default create;
|
|
1
|
+
import { actions } from '../state-management';
|
|
2
|
+
import { BINDED_KEYS } from '../commons-tools';
|
|
3
|
+
|
|
4
|
+
function create(dispatch) {
|
|
5
|
+
return function (e) {
|
|
6
|
+
const { key } = e;
|
|
7
|
+
switch (key) {
|
|
8
|
+
case BINDED_KEYS.Tab:
|
|
9
|
+
e.stopPropagation();
|
|
10
|
+
// e.preventDefault();
|
|
11
|
+
dispatch(actions.onKeyDown(key));
|
|
12
|
+
break;
|
|
13
|
+
case BINDED_KEYS.ArrowDown:
|
|
14
|
+
case BINDED_KEYS.ArrowUp:
|
|
15
|
+
case BINDED_KEYS.Home:
|
|
16
|
+
case BINDED_KEYS.End:
|
|
17
|
+
case BINDED_KEYS.Enter:
|
|
18
|
+
case BINDED_KEYS.Escape:
|
|
19
|
+
e.preventDefault();
|
|
20
|
+
e.stopPropagation();
|
|
21
|
+
dispatch(actions.onKeyDown(key));
|
|
22
|
+
break;
|
|
23
|
+
default:
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default create;
|
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
import React, { useState, useEffect } from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import ReactTooltip from 'react-tooltip';
|
|
4
|
-
import * as U from '../../utils/lib';
|
|
5
|
-
import * as img from './img';
|
|
6
|
-
import './tooltip.scss';
|
|
7
|
-
|
|
8
|
-
const TooltipResponse = ({ id, response }) => {
|
|
9
|
-
const [tooltipElements, setTooltipElements] = useState(() =>
|
|
10
|
-
U.buildTooltip(response)
|
|
11
|
-
);
|
|
12
|
-
|
|
13
|
-
useEffect(() => {
|
|
14
|
-
setTooltipElements(U.buildTooltip(response));
|
|
15
|
-
}, [response]);
|
|
16
|
-
|
|
17
|
-
const { content, imgName } = tooltipElements;
|
|
18
|
-
|
|
19
|
-
if (!content) return null;
|
|
20
|
-
|
|
21
|
-
const text = content
|
|
22
|
-
.map(({ key, value }) => `${key} : ${value}<br />`)
|
|
23
|
-
.join('');
|
|
24
|
-
|
|
25
|
-
return (
|
|
26
|
-
<div className="tooltip-lunatic">
|
|
27
|
-
<span
|
|
28
|
-
data-for={`${id}-management-tooltip`}
|
|
29
|
-
data-tip={text}
|
|
30
|
-
data-multiline
|
|
31
|
-
>
|
|
32
|
-
<img id={id} alt="img-tooltip" src={img[imgName].src || img[imgName]} />
|
|
33
|
-
</span>
|
|
34
|
-
<ReactTooltip
|
|
35
|
-
id={`${id}-management-tooltip`}
|
|
36
|
-
className="tooltip-text"
|
|
37
|
-
place="left"
|
|
38
|
-
/>
|
|
39
|
-
</div>
|
|
40
|
-
);
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
TooltipResponse.defaultProps = {
|
|
44
|
-
response: {},
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
TooltipResponse.propTypes = {
|
|
48
|
-
id: PropTypes.string,
|
|
49
|
-
response: U.responsePropTypes,
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
export default TooltipResponse;
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import ReactTooltip from 'react-tooltip';
|
|
4
|
+
import * as U from '../../utils/lib';
|
|
5
|
+
import * as img from './img';
|
|
6
|
+
import './tooltip.scss';
|
|
7
|
+
|
|
8
|
+
const TooltipResponse = ({ id, response }) => {
|
|
9
|
+
const [tooltipElements, setTooltipElements] = useState(() =>
|
|
10
|
+
U.buildTooltip(response)
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
setTooltipElements(U.buildTooltip(response));
|
|
15
|
+
}, [response]);
|
|
16
|
+
|
|
17
|
+
const { content, imgName } = tooltipElements;
|
|
18
|
+
|
|
19
|
+
if (!content) return null;
|
|
20
|
+
|
|
21
|
+
const text = content
|
|
22
|
+
.map(({ key, value }) => `${key} : ${value}<br />`)
|
|
23
|
+
.join('');
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<div className="tooltip-lunatic">
|
|
27
|
+
<span
|
|
28
|
+
data-for={`${id}-management-tooltip`}
|
|
29
|
+
data-tip={text}
|
|
30
|
+
data-multiline
|
|
31
|
+
>
|
|
32
|
+
<img id={id} alt="img-tooltip" src={img[imgName].src || img[imgName]} />
|
|
33
|
+
</span>
|
|
34
|
+
<ReactTooltip
|
|
35
|
+
id={`${id}-management-tooltip`}
|
|
36
|
+
className="tooltip-text"
|
|
37
|
+
place="left"
|
|
38
|
+
/>
|
|
39
|
+
</div>
|
|
40
|
+
);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
TooltipResponse.defaultProps = {
|
|
44
|
+
response: {},
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
TooltipResponse.propTypes = {
|
|
48
|
+
id: PropTypes.string,
|
|
49
|
+
response: U.responsePropTypes,
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export default TooltipResponse;
|
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
{
|
|
2
|
-
"components": [
|
|
3
|
-
{
|
|
4
|
-
"id": "1",
|
|
5
|
-
"componentType": "CheckboxBoolean",
|
|
6
|
-
"mandatory": false,
|
|
7
|
-
"label": "➡ 1. Are you ready?",
|
|
8
|
-
"response": {
|
|
9
|
-
"name": "READY"
|
|
10
|
-
}
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
"id": "2",
|
|
14
|
-
"componentType": "CheckboxBoolean",
|
|
15
|
-
"mandatory": false,
|
|
16
|
-
"label": "➡ 2. Are you always ready?",
|
|
17
|
-
"response": {
|
|
18
|
-
"name": "READY2"
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
],
|
|
22
|
-
"variables": [
|
|
23
|
-
{
|
|
24
|
-
"variableType": "COLLECTED",
|
|
25
|
-
"name": "READY",
|
|
26
|
-
"componentRef": "1",
|
|
27
|
-
"values": {
|
|
28
|
-
"PREVIOUS": null,
|
|
29
|
-
"COLLECTED": true,
|
|
30
|
-
"FORCED": null,
|
|
31
|
-
"EDITED": null,
|
|
32
|
-
"INPUTED": null
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
"variableType": "COLLECTED",
|
|
37
|
-
"name": "READY2",
|
|
38
|
-
"componentRef": "2",
|
|
39
|
-
"values": {
|
|
40
|
-
"PREVIOUS": null,
|
|
41
|
-
"COLLECTED": true,
|
|
42
|
-
"FORCED": null,
|
|
43
|
-
"EDITED": null,
|
|
44
|
-
"INPUTED": null
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
]
|
|
48
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"components": [
|
|
3
|
+
{
|
|
4
|
+
"id": "1",
|
|
5
|
+
"componentType": "CheckboxBoolean",
|
|
6
|
+
"mandatory": false,
|
|
7
|
+
"label": "➡ 1. Are you ready?",
|
|
8
|
+
"response": {
|
|
9
|
+
"name": "READY"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"id": "2",
|
|
14
|
+
"componentType": "CheckboxBoolean",
|
|
15
|
+
"mandatory": false,
|
|
16
|
+
"label": "➡ 2. Are you always ready?",
|
|
17
|
+
"response": {
|
|
18
|
+
"name": "READY2"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
],
|
|
22
|
+
"variables": [
|
|
23
|
+
{
|
|
24
|
+
"variableType": "COLLECTED",
|
|
25
|
+
"name": "READY",
|
|
26
|
+
"componentRef": "1",
|
|
27
|
+
"values": {
|
|
28
|
+
"PREVIOUS": null,
|
|
29
|
+
"COLLECTED": true,
|
|
30
|
+
"FORCED": null,
|
|
31
|
+
"EDITED": null,
|
|
32
|
+
"INPUTED": null
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"variableType": "COLLECTED",
|
|
37
|
+
"name": "READY2",
|
|
38
|
+
"componentRef": "2",
|
|
39
|
+
"values": {
|
|
40
|
+
"PREVIOUS": null,
|
|
41
|
+
"COLLECTED": true,
|
|
42
|
+
"FORCED": null,
|
|
43
|
+
"EDITED": null,
|
|
44
|
+
"INPUTED": null
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
]
|
|
48
|
+
}
|