@coorpacademy/components 11.6.1 → 11.7.3-alpha.29
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/README.md +3 -3
- package/es/atom/loader/index.native.d.ts +10 -0
- package/es/atom/loader/index.native.d.ts.map +1 -0
- package/es/atom/loader/index.native.js +192 -0
- package/es/atom/loader/index.native.js.map +1 -0
- package/es/atom/select/index.d.ts +18 -0
- package/es/atom/select/index.d.ts.map +1 -1
- package/es/atom/select/index.js +69 -15
- package/es/atom/select/index.js.map +1 -1
- package/es/molecule/answer/index.d.ts.map +1 -1
- package/es/molecule/answer/index.js +17 -12
- package/es/molecule/answer/index.js.map +1 -1
- package/es/molecule/brand-form-group/index.d.ts +18 -0
- package/es/molecule/empty-state-dashboard/index.d.ts +23 -0
- package/es/molecule/empty-state-dashboard/index.d.ts.map +1 -0
- package/es/molecule/empty-state-dashboard/index.js +31 -0
- package/es/molecule/empty-state-dashboard/index.js.map +1 -0
- package/es/molecule/empty-state-dashboard/style.css +55 -0
- package/es/molecule/empty-state-dashboard/types.d.ts +19 -0
- package/es/molecule/empty-state-dashboard/types.d.ts.map +1 -0
- package/es/molecule/empty-state-dashboard/types.js +19 -0
- package/es/molecule/empty-state-dashboard/types.js.map +1 -0
- package/es/molecule/filters/filters-wrapper.d.ts +1 -0
- package/es/molecule/filters/filters-wrapper.d.ts.map +1 -1
- package/es/molecule/filters/filters-wrapper.js +9 -5
- package/es/molecule/filters/filters-wrapper.js.map +1 -1
- package/es/molecule/filters/index.d.ts +10 -0
- package/es/molecule/filters/index.d.ts.map +1 -1
- package/es/molecule/filters/index.js +6 -3
- package/es/molecule/filters/index.js.map +1 -1
- package/es/molecule/questions/drop-down/index.d.ts +1 -0
- package/es/molecule/questions/drop-down/index.d.ts.map +1 -1
- package/es/molecule/questions/drop-down/index.js +9 -5
- package/es/molecule/questions/drop-down/index.js.map +1 -1
- package/es/molecule/questions/qcm/index.d.ts +1 -0
- package/es/molecule/questions/qcm/index.d.ts.map +1 -1
- package/es/molecule/questions/qcm/index.js +9 -5
- package/es/molecule/questions/qcm/index.js.map +1 -1
- package/es/molecule/questions/qcm-drag/index.d.ts +3 -1
- package/es/molecule/questions/qcm-drag/index.d.ts.map +1 -1
- package/es/molecule/questions/qcm-drag/index.js +9 -5
- package/es/molecule/questions/qcm-drag/index.js.map +1 -1
- package/es/molecule/questions/qcm-graphic/index.d.ts +1 -0
- package/es/molecule/questions/qcm-graphic/index.d.ts.map +1 -1
- package/es/molecule/questions/qcm-graphic/index.js +9 -5
- package/es/molecule/questions/qcm-graphic/index.js.map +1 -1
- package/es/molecule/questions/question-range/index.d.ts +1 -0
- package/es/molecule/questions/question-range/index.d.ts.map +1 -1
- package/es/molecule/questions/question-range/index.js +10 -6
- package/es/molecule/questions/question-range/index.js.map +1 -1
- package/es/molecule/questions/template/index.d.ts +6 -2
- package/es/molecule/questions/template/index.d.ts.map +1 -1
- package/es/molecule/questions/template/index.js +9 -5
- package/es/molecule/questions/template/index.js.map +1 -1
- package/es/molecule/setup-slide/index.d.ts +9 -0
- package/es/molecule/setup-slider/index.d.ts +9 -0
- package/es/organism/brand-form/index.d.ts +18 -0
- package/es/organism/list-item/index.d.ts +8 -6
- package/es/organism/list-item/index.d.ts.map +1 -1
- package/es/organism/list-item/index.js +16 -2
- package/es/organism/list-item/index.js.map +1 -1
- package/es/organism/list-item/style.css +18 -0
- package/es/organism/list-items/index.d.ts +2 -0
- package/es/organism/list-items/index.js +5 -1
- package/es/organism/list-items/index.js.map +1 -1
- package/es/organism/user-preferences/index.d.ts +1 -0
- package/es/organism/user-preferences/index.d.ts.map +1 -1
- package/es/organism/user-preferences/index.js +9 -5
- package/es/organism/user-preferences/index.js.map +1 -1
- package/es/organism/wizard-contents/index.d.ts +18 -0
- package/es/template/activity/index.d.ts +36 -40
- package/es/template/activity/index.d.ts.map +1 -1
- package/es/template/activity/index.js +89 -111
- package/es/template/activity/index.js.map +1 -1
- package/es/template/activity/stars-summary.d.ts +9 -18
- package/es/template/activity/stars-summary.d.ts.map +1 -1
- package/es/template/activity/stars-summary.js +94 -122
- package/es/template/activity/stars-summary.js.map +1 -1
- package/es/template/back-office/brand-update/index.d.ts +56 -0
- package/es/template/back-office/brand-update/index.d.ts.map +1 -1
- package/es/template/back-office/brand-update/index.js +12 -3
- package/es/template/back-office/brand-update/index.js.map +1 -1
- package/es/template/back-office/brand-update/style.css +5 -1
- package/es/template/common/search-page/index.d.ts +11 -0
- package/es/template/common/search-page/index.d.ts.map +1 -1
- package/es/template/common/search-page/index.js +6 -3
- package/es/template/common/search-page/index.js.map +1 -1
- package/es/util/button-icons.d.ts +1 -0
- package/es/util/button-icons.d.ts.map +1 -1
- package/es/util/button-icons.js +3 -2
- package/es/util/button-icons.js.map +1 -1
- package/lib/atom/loader/index.native.d.ts +10 -0
- package/lib/atom/loader/index.native.d.ts.map +1 -0
- package/lib/atom/loader/index.native.js +205 -0
- package/lib/atom/loader/index.native.js.map +1 -0
- package/lib/atom/select/index.d.ts +18 -0
- package/lib/atom/select/index.d.ts.map +1 -1
- package/lib/atom/select/index.js +72 -14
- package/lib/atom/select/index.js.map +1 -1
- package/lib/molecule/answer/index.d.ts.map +1 -1
- package/lib/molecule/answer/index.js +18 -13
- package/lib/molecule/answer/index.js.map +1 -1
- package/lib/molecule/brand-form-group/index.d.ts +18 -0
- package/lib/molecule/empty-state-dashboard/index.d.ts +23 -0
- package/lib/molecule/empty-state-dashboard/index.d.ts.map +1 -0
- package/lib/molecule/empty-state-dashboard/index.js +42 -0
- package/lib/molecule/empty-state-dashboard/index.js.map +1 -0
- package/lib/molecule/empty-state-dashboard/style.css +55 -0
- package/lib/molecule/empty-state-dashboard/types.d.ts +19 -0
- package/lib/molecule/empty-state-dashboard/types.d.ts.map +1 -0
- package/lib/molecule/empty-state-dashboard/types.js +29 -0
- package/lib/molecule/empty-state-dashboard/types.js.map +1 -0
- package/lib/molecule/filters/filters-wrapper.d.ts +1 -0
- package/lib/molecule/filters/filters-wrapper.d.ts.map +1 -1
- package/lib/molecule/filters/filters-wrapper.js +9 -5
- package/lib/molecule/filters/filters-wrapper.js.map +1 -1
- package/lib/molecule/filters/index.d.ts +10 -0
- package/lib/molecule/filters/index.d.ts.map +1 -1
- package/lib/molecule/filters/index.js +6 -3
- package/lib/molecule/filters/index.js.map +1 -1
- package/lib/molecule/questions/drop-down/index.d.ts +1 -0
- package/lib/molecule/questions/drop-down/index.d.ts.map +1 -1
- package/lib/molecule/questions/drop-down/index.js +9 -5
- package/lib/molecule/questions/drop-down/index.js.map +1 -1
- package/lib/molecule/questions/qcm/index.d.ts +1 -0
- package/lib/molecule/questions/qcm/index.d.ts.map +1 -1
- package/lib/molecule/questions/qcm/index.js +9 -5
- package/lib/molecule/questions/qcm/index.js.map +1 -1
- package/lib/molecule/questions/qcm-drag/index.d.ts +3 -1
- package/lib/molecule/questions/qcm-drag/index.d.ts.map +1 -1
- package/lib/molecule/questions/qcm-drag/index.js +9 -5
- package/lib/molecule/questions/qcm-drag/index.js.map +1 -1
- package/lib/molecule/questions/qcm-graphic/index.d.ts +1 -0
- package/lib/molecule/questions/qcm-graphic/index.d.ts.map +1 -1
- package/lib/molecule/questions/qcm-graphic/index.js +9 -5
- package/lib/molecule/questions/qcm-graphic/index.js.map +1 -1
- package/lib/molecule/questions/question-range/index.d.ts +1 -0
- package/lib/molecule/questions/question-range/index.d.ts.map +1 -1
- package/lib/molecule/questions/question-range/index.js +10 -6
- package/lib/molecule/questions/question-range/index.js.map +1 -1
- package/lib/molecule/questions/template/index.d.ts +6 -2
- package/lib/molecule/questions/template/index.d.ts.map +1 -1
- package/lib/molecule/questions/template/index.js +9 -5
- package/lib/molecule/questions/template/index.js.map +1 -1
- package/lib/molecule/setup-slide/index.d.ts +9 -0
- package/lib/molecule/setup-slider/index.d.ts +9 -0
- package/lib/organism/brand-form/index.d.ts +18 -0
- package/lib/organism/list-item/index.d.ts +8 -6
- package/lib/organism/list-item/index.d.ts.map +1 -1
- package/lib/organism/list-item/index.js +16 -2
- package/lib/organism/list-item/index.js.map +1 -1
- package/lib/organism/list-item/style.css +18 -0
- package/lib/organism/list-items/index.d.ts +2 -0
- package/lib/organism/list-items/index.js +5 -1
- package/lib/organism/list-items/index.js.map +1 -1
- package/lib/organism/user-preferences/index.d.ts +1 -0
- package/lib/organism/user-preferences/index.d.ts.map +1 -1
- package/lib/organism/user-preferences/index.js +9 -5
- package/lib/organism/user-preferences/index.js.map +1 -1
- package/lib/organism/wizard-contents/index.d.ts +18 -0
- package/lib/template/activity/index.d.ts +36 -40
- package/lib/template/activity/index.d.ts.map +1 -1
- package/lib/template/activity/index.js +95 -110
- package/lib/template/activity/index.js.map +1 -1
- package/lib/template/activity/stars-summary.d.ts +9 -18
- package/lib/template/activity/stars-summary.d.ts.map +1 -1
- package/lib/template/activity/stars-summary.js +90 -119
- package/lib/template/activity/stars-summary.js.map +1 -1
- package/lib/template/back-office/brand-update/index.d.ts +56 -0
- package/lib/template/back-office/brand-update/index.d.ts.map +1 -1
- package/lib/template/back-office/brand-update/index.js +13 -3
- package/lib/template/back-office/brand-update/index.js.map +1 -1
- package/lib/template/back-office/brand-update/style.css +5 -1
- package/lib/template/common/search-page/index.d.ts +11 -0
- package/lib/template/common/search-page/index.d.ts.map +1 -1
- package/lib/template/common/search-page/index.js +6 -3
- package/lib/template/common/search-page/index.js.map +1 -1
- package/lib/util/button-icons.d.ts +1 -0
- package/lib/util/button-icons.d.ts.map +1 -1
- package/lib/util/button-icons.js +2 -1
- package/lib/util/button-icons.js.map +1 -1
- package/locales/bs/global.json +8 -1
- package/locales/cs/global.json +9 -1
- package/locales/de/global.json +9 -1
- package/locales/en/global.json +1 -1
- package/locales/es/global.json +9 -1
- package/locales/et/global.json +9 -1
- package/locales/fr/global.json +1 -1
- package/locales/hr/global.json +9 -1
- package/locales/hu/global.json +9 -1
- package/locales/hy/global.json +0 -1
- package/locales/it/global.json +9 -1
- package/locales/ja/global.json +9 -1
- package/locales/ko/global.json +9 -1
- package/locales/nl/global.json +9 -1
- package/locales/pl/global.json +9 -1
- package/locales/pt/global.json +9 -1
- package/locales/ro/global.json +9 -1
- package/locales/ru/global.json +1 -1
- package/locales/sk/global.json +9 -1
- package/locales/tl/global.json +9 -1
- package/locales/tr/global.json +9 -1
- package/locales/uk/global.json +9 -1
- package/locales/vi/global.json +9 -1
- package/locales/zh/global.json +9 -1
- package/locales/zh_TW/global.json +9 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -28,7 +28,6 @@ npm run start:ie # for Internet Explorer
|
|
|
28
28
|
|
|
29
29
|
Then open `http://localhost:3004`.
|
|
30
30
|
|
|
31
|
-
|
|
32
31
|
### Analyse your component
|
|
33
32
|
|
|
34
33
|
The `props` is the contract your app should fill in order to use the component.
|
|
@@ -78,6 +77,7 @@ which is also launched automatically whenever you run `npm start`
|
|
|
78
77
|
- Be sure to have `translate: Provider.childContextTypes.translate` in the contextTypes object of your component
|
|
79
78
|
|
|
80
79
|
example:
|
|
80
|
+
|
|
81
81
|
```
|
|
82
82
|
....
|
|
83
83
|
|
|
@@ -143,7 +143,7 @@ const props = {
|
|
|
143
143
|
}
|
|
144
144
|
```
|
|
145
145
|
|
|
146
|
-
#### Additional information
|
|
146
|
+
#### Additional information
|
|
147
147
|
|
|
148
148
|
The props include classNames && size control to handle additional styling.
|
|
149
149
|
|
|
@@ -180,4 +180,4 @@ You may need to install these optional libs depending on which native components
|
|
|
180
180
|
|
|
181
181
|
Error when trying to launch the storybook:
|
|
182
182
|
|
|
183
|
-
Try to delete your ```node_modules```, go to the project's root and launch: ```yarn
|
|
183
|
+
Try to delete your ```node_modules```, go to the project's root and launch: ```yarn```
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ColorValue } from 'react-native';
|
|
3
|
+
export declare type Props = {
|
|
4
|
+
color?: ColorValue;
|
|
5
|
+
height?: number;
|
|
6
|
+
readyToHide: boolean;
|
|
7
|
+
};
|
|
8
|
+
declare const Loader: (props: Props) => JSX.Element | null;
|
|
9
|
+
export default Loader;
|
|
10
|
+
//# sourceMappingURL=index.native.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.native.d.ts","sourceRoot":"","sources":["../../../src/atom/loader/index.native.tsx"],"names":[],"mappings":";AAEA,OAAO,EAA0C,UAAU,EAAC,MAAM,cAAc,CAAC;AAoCjF,oBAAY,KAAK,GAAG;IAClB,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,OAAO,CAAC;CACtB,CAAC;AAKF,QAAA,MAAM,MAAM,UAAW,KAAK,uBAqK3B,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { useAnimateProp } from '@coorpacademy/react-native-animation';
|
|
2
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { Animated, StyleSheet, Easing } from 'react-native';
|
|
4
|
+
import { useTemplateContext } from '../../template/app-review/template-context';
|
|
5
|
+
|
|
6
|
+
const createStyleSheet = theme => StyleSheet.create({
|
|
7
|
+
container: {
|
|
8
|
+
alignItems: 'center',
|
|
9
|
+
justifyContent: 'center'
|
|
10
|
+
},
|
|
11
|
+
dot: {
|
|
12
|
+
position: 'absolute'
|
|
13
|
+
},
|
|
14
|
+
blue: {
|
|
15
|
+
backgroundColor: theme.colors.cta
|
|
16
|
+
},
|
|
17
|
+
red: {
|
|
18
|
+
backgroundColor: theme.colors.negative
|
|
19
|
+
},
|
|
20
|
+
green: {
|
|
21
|
+
backgroundColor: theme.colors.positive
|
|
22
|
+
},
|
|
23
|
+
yellow: {
|
|
24
|
+
backgroundColor: theme.colors.battle
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const CYCLE_DURATION = 3000;
|
|
29
|
+
const MIN_TIME = 1000;
|
|
30
|
+
|
|
31
|
+
const Loader = props => {
|
|
32
|
+
const templateContext = useTemplateContext();
|
|
33
|
+
const {
|
|
34
|
+
theme
|
|
35
|
+
} = templateContext;
|
|
36
|
+
const [styleSheet, setStylesheet] = useState(null);
|
|
37
|
+
const [visible, setVisible] = useState(true);
|
|
38
|
+
const [minTimeIsSpent, setMinTimeSpent] = useState(false);
|
|
39
|
+
const rotation = useRef(new Animated.Value(0)).current;
|
|
40
|
+
const scale = useRef(new Animated.Value(0)).current;
|
|
41
|
+
const hideAnimation = useAnimateProp({
|
|
42
|
+
property: 'opacity',
|
|
43
|
+
fromValue: 1,
|
|
44
|
+
toValue: 0
|
|
45
|
+
});
|
|
46
|
+
const {
|
|
47
|
+
height = 60,
|
|
48
|
+
color,
|
|
49
|
+
readyToHide
|
|
50
|
+
} = props;
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
const _stylesheet = createStyleSheet(theme);
|
|
53
|
+
|
|
54
|
+
setStylesheet(_stylesheet);
|
|
55
|
+
}, [theme]);
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
if (readyToHide && minTimeIsSpent) {
|
|
58
|
+
setVisible(false);
|
|
59
|
+
}
|
|
60
|
+
}, [readyToHide, minTimeIsSpent]);
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
if (!visible) {
|
|
63
|
+
hideAnimation.start();
|
|
64
|
+
}
|
|
65
|
+
}, [visible, hideAnimation]);
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
setTimeout(() => {
|
|
68
|
+
setMinTimeSpent(true);
|
|
69
|
+
}, MIN_TIME);
|
|
70
|
+
|
|
71
|
+
const _animation = Animated.parallel([Animated.loop(Animated.sequence([Animated.timing(scale, {
|
|
72
|
+
toValue: 0,
|
|
73
|
+
duration: 0,
|
|
74
|
+
useNativeDriver: false
|
|
75
|
+
}), Animated.timing(scale, {
|
|
76
|
+
toValue: 1,
|
|
77
|
+
duration: CYCLE_DURATION,
|
|
78
|
+
useNativeDriver: false,
|
|
79
|
+
easing: Easing.inOut(Easing.sin)
|
|
80
|
+
}), Animated.timing(scale, {
|
|
81
|
+
toValue: 2,
|
|
82
|
+
duration: CYCLE_DURATION,
|
|
83
|
+
useNativeDriver: false,
|
|
84
|
+
easing: Easing.inOut(Easing.sin)
|
|
85
|
+
}), Animated.timing(scale, {
|
|
86
|
+
toValue: 3,
|
|
87
|
+
duration: CYCLE_DURATION,
|
|
88
|
+
useNativeDriver: false,
|
|
89
|
+
easing: Easing.inOut(Easing.sin)
|
|
90
|
+
})])), Animated.loop(Animated.sequence([Animated.timing(rotation, {
|
|
91
|
+
toValue: 0,
|
|
92
|
+
duration: 0,
|
|
93
|
+
useNativeDriver: false
|
|
94
|
+
}), Animated.timing(rotation, {
|
|
95
|
+
toValue: 1,
|
|
96
|
+
duration: CYCLE_DURATION,
|
|
97
|
+
useNativeDriver: false,
|
|
98
|
+
easing: Easing.inOut(Easing.sin)
|
|
99
|
+
})]))]);
|
|
100
|
+
|
|
101
|
+
_animation.start();
|
|
102
|
+
|
|
103
|
+
return () => {
|
|
104
|
+
_animation.stop();
|
|
105
|
+
}; // eslint bad warning --> effect only onmount
|
|
106
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
107
|
+
}, []);
|
|
108
|
+
|
|
109
|
+
if (!styleSheet) {
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const interpolatedScale = scale.interpolate({
|
|
114
|
+
inputRange: [0, 0.45, 1, 1.32, 1.5, 2, 2.3, 2.64, 3],
|
|
115
|
+
outputRange: [0.5, 0.2, 0.5, 0.5, 0.8, 0.5, 0.5, 0.3, 0.5]
|
|
116
|
+
});
|
|
117
|
+
const interpolatedRotation = rotation.interpolate({
|
|
118
|
+
inputRange: [0, 1],
|
|
119
|
+
outputRange: ['0deg', '360deg']
|
|
120
|
+
});
|
|
121
|
+
const dotWidth = rotation.interpolate({
|
|
122
|
+
inputRange: [0, 0.5, 1],
|
|
123
|
+
outputRange: [height / 2, height / 6, height / 2]
|
|
124
|
+
});
|
|
125
|
+
const dotTranslate = rotation.interpolate({
|
|
126
|
+
inputRange: [0, 0.5, 1],
|
|
127
|
+
outputRange: [-25 * (height / 60), -35 * (height / 60), -25 * (height / 60)]
|
|
128
|
+
});
|
|
129
|
+
const dotStyle = {
|
|
130
|
+
width: dotWidth,
|
|
131
|
+
height: height / 6,
|
|
132
|
+
borderRadius: height / 12
|
|
133
|
+
};
|
|
134
|
+
return /*#__PURE__*/React.createElement(Animated.View, {
|
|
135
|
+
style: hideAnimation.animatedStyle
|
|
136
|
+
}, /*#__PURE__*/React.createElement(Animated.View, {
|
|
137
|
+
style: [styleSheet.container, {
|
|
138
|
+
height,
|
|
139
|
+
width: height,
|
|
140
|
+
transform: [{
|
|
141
|
+
scaleX: interpolatedScale
|
|
142
|
+
}, {
|
|
143
|
+
scaleY: interpolatedScale
|
|
144
|
+
}, {
|
|
145
|
+
rotateZ: interpolatedRotation
|
|
146
|
+
}]
|
|
147
|
+
}]
|
|
148
|
+
}, /*#__PURE__*/React.createElement(Animated.View, {
|
|
149
|
+
style: [styleSheet.dot, color ? {
|
|
150
|
+
backgroundColor: color
|
|
151
|
+
} : styleSheet.red, dotStyle, {
|
|
152
|
+
transform: [{
|
|
153
|
+
rotateZ: '45deg'
|
|
154
|
+
}, {
|
|
155
|
+
translateX: dotTranslate
|
|
156
|
+
}]
|
|
157
|
+
}]
|
|
158
|
+
}), /*#__PURE__*/React.createElement(Animated.View, {
|
|
159
|
+
style: [styleSheet.dot, color ? {
|
|
160
|
+
backgroundColor: color
|
|
161
|
+
} : styleSheet.green, dotStyle, {
|
|
162
|
+
transform: [{
|
|
163
|
+
rotateZ: '135deg'
|
|
164
|
+
}, {
|
|
165
|
+
translateX: dotTranslate
|
|
166
|
+
}]
|
|
167
|
+
}]
|
|
168
|
+
}), /*#__PURE__*/React.createElement(Animated.View, {
|
|
169
|
+
style: [styleSheet.dot, color ? {
|
|
170
|
+
backgroundColor: color
|
|
171
|
+
} : styleSheet.yellow, dotStyle, {
|
|
172
|
+
transform: [{
|
|
173
|
+
rotateZ: '225deg'
|
|
174
|
+
}, {
|
|
175
|
+
translateX: dotTranslate
|
|
176
|
+
}]
|
|
177
|
+
}]
|
|
178
|
+
}), /*#__PURE__*/React.createElement(Animated.View, {
|
|
179
|
+
style: [styleSheet.dot, color ? {
|
|
180
|
+
backgroundColor: color
|
|
181
|
+
} : styleSheet.blue, dotStyle, {
|
|
182
|
+
transform: [{
|
|
183
|
+
rotateZ: '315deg'
|
|
184
|
+
}, {
|
|
185
|
+
translateX: dotTranslate
|
|
186
|
+
}]
|
|
187
|
+
}]
|
|
188
|
+
})));
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
export default Loader;
|
|
192
|
+
//# sourceMappingURL=index.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.native.js","names":["useAnimateProp","React","useEffect","useRef","useState","Animated","StyleSheet","Easing","useTemplateContext","createStyleSheet","theme","create","container","alignItems","justifyContent","dot","position","blue","backgroundColor","colors","cta","red","negative","green","positive","yellow","battle","CYCLE_DURATION","MIN_TIME","Loader","props","templateContext","styleSheet","setStylesheet","visible","setVisible","minTimeIsSpent","setMinTimeSpent","rotation","Value","current","scale","hideAnimation","property","fromValue","toValue","height","color","readyToHide","_stylesheet","start","setTimeout","_animation","parallel","loop","sequence","timing","duration","useNativeDriver","easing","inOut","sin","stop","interpolatedScale","interpolate","inputRange","outputRange","interpolatedRotation","dotWidth","dotTranslate","dotStyle","width","borderRadius","animatedStyle","transform","scaleX","scaleY","rotateZ","translateX"],"sources":["../../../src/atom/loader/index.native.tsx"],"sourcesContent":["import {useAnimateProp} from '@coorpacademy/react-native-animation';\nimport React, {useEffect, useRef, useState} from 'react';\nimport {Animated, StyleSheet, Easing, ViewStyle, ColorValue} from 'react-native';\nimport {useTemplateContext} from '../../template/app-review/template-context';\nimport {Theme} from '../../variables/theme.native';\n\ntype StyleSheetType = {\n container: ViewStyle;\n dot: ViewStyle;\n blue: ViewStyle;\n red: ViewStyle;\n green: ViewStyle;\n yellow: ViewStyle;\n};\n\nconst createStyleSheet = (theme: Theme): StyleSheetType =>\n StyleSheet.create({\n container: {\n alignItems: 'center',\n justifyContent: 'center'\n },\n dot: {\n position: 'absolute'\n },\n blue: {\n backgroundColor: theme.colors.cta\n },\n red: {\n backgroundColor: theme.colors.negative\n },\n green: {\n backgroundColor: theme.colors.positive\n },\n yellow: {\n backgroundColor: theme.colors.battle\n }\n });\n\nexport type Props = {\n color?: ColorValue;\n height?: number;\n readyToHide: boolean;\n};\n\nconst CYCLE_DURATION = 3000;\nconst MIN_TIME = 1000;\n\nconst Loader = (props: Props) => {\n const templateContext = useTemplateContext();\n const {theme} = templateContext;\n\n const [styleSheet, setStylesheet] = useState<StyleSheetType | null>(null);\n const [visible, setVisible] = useState<boolean>(true);\n const [minTimeIsSpent, setMinTimeSpent] = useState<boolean>(false);\n\n const rotation = useRef<Animated.Value>(new Animated.Value(0)).current;\n const scale = useRef<Animated.Value>(new Animated.Value(0)).current;\n\n const hideAnimation = useAnimateProp({\n property: 'opacity',\n fromValue: 1,\n toValue: 0\n });\n\n const {height = 60, color, readyToHide} = props;\n\n useEffect(() => {\n const _stylesheet = createStyleSheet(theme);\n setStylesheet(_stylesheet);\n }, [theme]);\n\n useEffect(() => {\n if (readyToHide && minTimeIsSpent) {\n setVisible(false);\n }\n }, [readyToHide, minTimeIsSpent]);\n\n useEffect(() => {\n if (!visible) {\n hideAnimation.start();\n }\n }, [visible, hideAnimation]);\n\n useEffect(() => {\n setTimeout(() => {\n setMinTimeSpent(true);\n }, MIN_TIME);\n\n const _animation = Animated.parallel([\n Animated.loop(\n Animated.sequence([\n Animated.timing(scale, {toValue: 0, duration: 0, useNativeDriver: false}),\n Animated.timing(scale, {\n toValue: 1,\n duration: CYCLE_DURATION,\n useNativeDriver: false,\n easing: Easing.inOut(Easing.sin)\n }),\n Animated.timing(scale, {\n toValue: 2,\n duration: CYCLE_DURATION,\n useNativeDriver: false,\n easing: Easing.inOut(Easing.sin)\n }),\n Animated.timing(scale, {\n toValue: 3,\n duration: CYCLE_DURATION,\n useNativeDriver: false,\n easing: Easing.inOut(Easing.sin)\n })\n ])\n ),\n Animated.loop(\n Animated.sequence([\n Animated.timing(rotation, {toValue: 0, duration: 0, useNativeDriver: false}),\n Animated.timing(rotation, {\n toValue: 1,\n duration: CYCLE_DURATION,\n useNativeDriver: false,\n easing: Easing.inOut(Easing.sin)\n })\n ])\n )\n ]);\n\n _animation.start();\n\n return () => {\n _animation.stop();\n };\n // eslint bad warning --> effect only onmount\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n if (!styleSheet) {\n return null;\n }\n\n const interpolatedScale = scale.interpolate({\n inputRange: [0, 0.45, 1, 1.32, 1.5, 2, 2.3, 2.64, 3],\n outputRange: [0.5, 0.2, 0.5, 0.5, 0.8, 0.5, 0.5, 0.3, 0.5]\n });\n\n const interpolatedRotation = rotation.interpolate({\n inputRange: [0, 1],\n outputRange: ['0deg', '360deg']\n });\n const dotWidth = rotation.interpolate({\n inputRange: [0, 0.5, 1],\n outputRange: [height / 2, height / 6, height / 2]\n });\n const dotTranslate = rotation.interpolate({\n inputRange: [0, 0.5, 1],\n outputRange: [-25 * (height / 60), -35 * (height / 60), -25 * (height / 60)]\n });\n const dotStyle = {\n width: dotWidth,\n height: height / 6,\n borderRadius: height / 12\n };\n\n return (\n <Animated.View style={hideAnimation.animatedStyle}>\n <Animated.View\n style={[\n styleSheet.container,\n {\n height,\n width: height,\n transform: [\n {scaleX: interpolatedScale},\n {scaleY: interpolatedScale},\n {rotateZ: interpolatedRotation}\n ]\n }\n ]}\n >\n <Animated.View\n style={[\n styleSheet.dot,\n color ? {backgroundColor: color} : styleSheet.red,\n dotStyle,\n {transform: [{rotateZ: '45deg'}, {translateX: dotTranslate}]}\n ]}\n />\n <Animated.View\n style={[\n styleSheet.dot,\n color ? {backgroundColor: color} : styleSheet.green,\n dotStyle,\n {transform: [{rotateZ: '135deg'}, {translateX: dotTranslate}]}\n ]}\n />\n <Animated.View\n style={[\n styleSheet.dot,\n color ? {backgroundColor: color} : styleSheet.yellow,\n dotStyle,\n {transform: [{rotateZ: '225deg'}, {translateX: dotTranslate}]}\n ]}\n />\n <Animated.View\n style={[\n styleSheet.dot,\n color ? {backgroundColor: color} : styleSheet.blue,\n dotStyle,\n {transform: [{rotateZ: '315deg'}, {translateX: dotTranslate}]}\n ]}\n />\n </Animated.View>\n </Animated.View>\n );\n};\n\nexport default Loader;\n"],"mappings":"AAAA,SAAQA,cAAR,QAA6B,sCAA7B;AACA,OAAOC,KAAP,IAAeC,SAAf,EAA0BC,MAA1B,EAAkCC,QAAlC,QAAiD,OAAjD;AACA,SAAQC,QAAR,EAAkBC,UAAlB,EAA8BC,MAA9B,QAAkE,cAAlE;AACA,SAAQC,kBAAR,QAAiC,4CAAjC;;AAYA,MAAMC,gBAAgB,GAAIC,KAAD,IACvBJ,UAAU,CAACK,MAAX,CAAkB;EAChBC,SAAS,EAAE;IACTC,UAAU,EAAE,QADH;IAETC,cAAc,EAAE;EAFP,CADK;EAKhBC,GAAG,EAAE;IACHC,QAAQ,EAAE;EADP,CALW;EAQhBC,IAAI,EAAE;IACJC,eAAe,EAAER,KAAK,CAACS,MAAN,CAAaC;EAD1B,CARU;EAWhBC,GAAG,EAAE;IACHH,eAAe,EAAER,KAAK,CAACS,MAAN,CAAaG;EAD3B,CAXW;EAchBC,KAAK,EAAE;IACLL,eAAe,EAAER,KAAK,CAACS,MAAN,CAAaK;EADzB,CAdS;EAiBhBC,MAAM,EAAE;IACNP,eAAe,EAAER,KAAK,CAACS,MAAN,CAAaO;EADxB;AAjBQ,CAAlB,CADF;;AA6BA,MAAMC,cAAc,GAAG,IAAvB;AACA,MAAMC,QAAQ,GAAG,IAAjB;;AAEA,MAAMC,MAAM,GAAIC,KAAD,IAAkB;EAC/B,MAAMC,eAAe,GAAGvB,kBAAkB,EAA1C;EACA,MAAM;IAACE;EAAD,IAAUqB,eAAhB;E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E,CAAC;QAACG,OAAO,EAAE;MAAV,CAAD,EAAsB;QAACC,UAAU,EAAET;MAAb,CAAtB;IAAZ,CAJK;EADT,EAtBF,eA8BE,oBAAC,QAAD,CAAU,IAAV;IACE,KAAK,EAAE,CACLrC,UAAU,CAACjB,GADN,EAELgC,KAAK,GAAG;MAAC7B,eAAe,EAAE6B;IAAlB,CAAH,GAA8Bf,UAAU,CAACP,MAFzC,EAGL6C,QAHK,EAIL;MAACI,SAAS,EAAE,CAAC;QAACG,OAAO,EAAE;MAAV,CAAD,EAAsB;QAACC,UAAU,EAAET;MAAb,CAAtB;IAAZ,CAJK;EADT,EA9BF,eAsCE,oBAAC,QAAD,CAAU,IAAV;IACE,KAAK,EAAE,CACLrC,UAAU,CAACjB,GADN,EAELgC,KAAK,GAAG;MAAC7B,eAAe,EAAE6B;IAAlB,CAAH,GAA8Bf,UAAU,CAACf,IAFzC,EAGLqD,QAHK,EAIL;MAACI,SAAS,EAAE,CAAC;QAACG,OAAO,EAAE;MAAV,CAAD,EAAsB;QAACC,UAAU,EAAET;MAAb,CAAtB;IAAZ,CAJK;EADT,EAtCF,CADF,CADF;AAmDD,CArKD;;AAuKA,eAAexC,MAAf"}
|
|
@@ -4,6 +4,15 @@ export namespace SelectOptionPropTypes {
|
|
|
4
4
|
const selected: PropTypes.Requireable<boolean>;
|
|
5
5
|
const validOption: PropTypes.Requireable<boolean>;
|
|
6
6
|
}
|
|
7
|
+
export namespace SelectOptionGroupPropTypes {
|
|
8
|
+
const label: PropTypes.Validator<string>;
|
|
9
|
+
const options: PropTypes.Requireable<(PropTypes.InferProps<{
|
|
10
|
+
name: PropTypes.Validator<string>;
|
|
11
|
+
value: PropTypes.Requireable<NonNullable<string | number | null | undefined>>;
|
|
12
|
+
selected: PropTypes.Requireable<boolean>;
|
|
13
|
+
validOption: PropTypes.Requireable<boolean>;
|
|
14
|
+
}> | null | undefined)[]>;
|
|
15
|
+
}
|
|
7
16
|
export default Select;
|
|
8
17
|
import PropTypes from "prop-types";
|
|
9
18
|
declare function Select(props: any, legacyContext: any): JSX.Element;
|
|
@@ -48,6 +57,15 @@ declare namespace Select {
|
|
|
48
57
|
selected: PropTypes.Requireable<boolean>;
|
|
49
58
|
validOption: PropTypes.Requireable<boolean>;
|
|
50
59
|
}> | null | undefined)[]>;
|
|
60
|
+
optgroups: PropTypes.Requireable<(PropTypes.InferProps<{
|
|
61
|
+
label: PropTypes.Validator<string>;
|
|
62
|
+
options: PropTypes.Requireable<(PropTypes.InferProps<{
|
|
63
|
+
name: PropTypes.Validator<string>;
|
|
64
|
+
value: PropTypes.Requireable<NonNullable<string | number | null | undefined>>;
|
|
65
|
+
selected: PropTypes.Requireable<boolean>;
|
|
66
|
+
validOption: PropTypes.Requireable<boolean>;
|
|
67
|
+
}> | null | undefined)[]>;
|
|
68
|
+
}> | null | undefined)[]>;
|
|
51
69
|
modified: PropTypes.Requireable<boolean>;
|
|
52
70
|
error: PropTypes.Requireable<boolean>;
|
|
53
71
|
'aria-label': PropTypes.Requireable<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atom/select/index.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atom/select/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AA2DA,qEAqLC"}
|
package/es/atom/select/index.js
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
2
|
|
|
3
|
-
import React, { useMemo } from 'react';
|
|
3
|
+
import React, { useCallback, useMemo, useState } from 'react';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
import classnames from 'classnames';
|
|
6
|
+
import concat from 'lodash/fp/concat';
|
|
6
7
|
import filter from 'lodash/fp/filter';
|
|
7
8
|
import find from 'lodash/fp/find';
|
|
9
|
+
import flatMapDeep from 'lodash/fp/flatMapDeep';
|
|
8
10
|
import get from 'lodash/fp/get';
|
|
9
11
|
import getOr from 'lodash/fp/getOr';
|
|
10
12
|
import includes from 'lodash/fp/includes';
|
|
13
|
+
import isEmpty from 'lodash/fp/isEmpty';
|
|
11
14
|
import keys from 'lodash/fp/keys';
|
|
12
15
|
import map from 'lodash/fp/map';
|
|
13
16
|
import size from 'lodash/fp/size';
|
|
14
|
-
import { NovaCompositionNavigationArrowDown as ArrowDown } from '@coorpacademy/nova-icons';
|
|
17
|
+
import { NovaCompositionNavigationArrowDown as ArrowDown, NovaCompositionNavigationArrowTop as ArrowUp } from '@coorpacademy/nova-icons';
|
|
15
18
|
import Provider, { GetSkinFromContext } from '../provider';
|
|
16
19
|
import getClassState from '../../util/get-class-state';
|
|
17
20
|
import style from './style.css';
|
|
@@ -28,10 +31,35 @@ const themeStyle = {
|
|
|
28
31
|
coorpmanager: null
|
|
29
32
|
};
|
|
30
33
|
|
|
34
|
+
const ArrowView = ({
|
|
35
|
+
shouldRender,
|
|
36
|
+
isArrowUp,
|
|
37
|
+
ariaLabel,
|
|
38
|
+
arrowClass,
|
|
39
|
+
arrowColor
|
|
40
|
+
}) => {
|
|
41
|
+
const props = useMemo(() => _extends({}, ariaLabel & {
|
|
42
|
+
'aria-label': ariaLabel
|
|
43
|
+
}, arrowColor & {
|
|
44
|
+
color: arrowColor
|
|
45
|
+
}, {
|
|
46
|
+
className: arrowClass
|
|
47
|
+
}), [ariaLabel, arrowClass, arrowColor]);
|
|
48
|
+
|
|
49
|
+
if (shouldRender) {
|
|
50
|
+
return isArrowUp ? /*#__PURE__*/React.createElement(ArrowUp, _extends({}, props, {
|
|
51
|
+
"data-testid": "select-arrow-up-icon"
|
|
52
|
+
})) : /*#__PURE__*/React.createElement(ArrowDown, _extends({}, props, {
|
|
53
|
+
"data-testid": "select-arrow-down-icon"
|
|
54
|
+
}));
|
|
55
|
+
} else return null;
|
|
56
|
+
};
|
|
57
|
+
|
|
31
58
|
const Select = (props, legacyContext) => {
|
|
32
59
|
const {
|
|
33
60
|
name,
|
|
34
61
|
options = [],
|
|
62
|
+
optgroups = [],
|
|
35
63
|
className,
|
|
36
64
|
borderClassName,
|
|
37
65
|
onChange,
|
|
@@ -47,12 +75,23 @@ const Select = (props, legacyContext) => {
|
|
|
47
75
|
} = props;
|
|
48
76
|
const skin = GetSkinFromContext(legacyContext);
|
|
49
77
|
const title = useMemo(() => propTitle ? `${propTitle}${required ? '*' : ''}` : null, [propTitle, required]);
|
|
50
|
-
const
|
|
78
|
+
const [isArrowUp, setIsArrowUp] = useState(false);
|
|
79
|
+
const handleSelectOnFocus = useCallback(() => setIsArrowUp(true), []);
|
|
80
|
+
const handleSelectOnBlur = useCallback(() => setIsArrowUp(false), []);
|
|
81
|
+
|
|
82
|
+
const selectOption = (option, index) => {
|
|
51
83
|
return /*#__PURE__*/React.createElement("option", {
|
|
52
84
|
key: index,
|
|
53
85
|
value: option.value,
|
|
54
86
|
className: style.selectOption
|
|
55
87
|
}, option.name);
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const optionList = !isEmpty(options) ? options.map((option, index) => selectOption(option, index)) : optgroups.map((optgroup, index) => {
|
|
91
|
+
return /*#__PURE__*/React.createElement("optgroup", {
|
|
92
|
+
key: index,
|
|
93
|
+
label: optgroup.label
|
|
94
|
+
}, optgroup.options && optgroup.options.map((option, i) => selectOption(option, i)));
|
|
56
95
|
});
|
|
57
96
|
const titleView = title ? /*#__PURE__*/React.createElement("span", {
|
|
58
97
|
className: style.title
|
|
@@ -61,31 +100,28 @@ const Select = (props, legacyContext) => {
|
|
|
61
100
|
selected: true
|
|
62
101
|
}, options)) : get('value', find({
|
|
63
102
|
selected: true
|
|
64
|
-
}, options)), [multiple, options]);
|
|
103
|
+
}, concat(options, flatMapDeep('options', optgroups)))), [multiple, options, optgroups]);
|
|
65
104
|
const selectedLabel = useMemo(() => multiple ? map(get('name'), filter({
|
|
66
105
|
selected: true
|
|
67
|
-
}, options)) : get('
|
|
106
|
+
}, options)) : get('value', find({
|
|
68
107
|
selected: true
|
|
69
|
-
}, options)), [multiple, options]);
|
|
108
|
+
}, concat(options, flatMapDeep('options', optgroups)))), [multiple, options, optgroups]);
|
|
70
109
|
const isSelectedInValidOption = useMemo(() => theme === 'player' && getOr(false, 'name', find({
|
|
71
110
|
validOption: false,
|
|
72
111
|
selected: true
|
|
73
112
|
}, options)), [options, theme]);
|
|
74
113
|
const handleChange = useMemo(() => multiple ? e => {
|
|
114
|
+
setIsArrowUp(false);
|
|
75
115
|
onChange(map(get('value'), e.target.selectedOptions));
|
|
76
116
|
} : e => {
|
|
117
|
+
setIsArrowUp(false);
|
|
77
118
|
onChange(e.target.value);
|
|
78
119
|
}, [onChange, multiple]);
|
|
79
120
|
const black = useMemo(() => getOr('#14171A', 'common.black', skin), [skin]);
|
|
80
121
|
const color = useMemo(() => getOr('#00B0FF', 'common.primary', skin), [skin]);
|
|
81
|
-
const
|
|
122
|
+
const isThemeOneOfQuestionTemplateOrPlayer = useMemo(() => includes(theme, ['question', 'template', 'player']), [theme]);
|
|
123
|
+
const shouldUseSkinFontColor = useMemo(() => !isSelectedInValidOption && selected && isThemeOneOfQuestionTemplateOrPlayer, [isSelectedInValidOption, selected, isThemeOneOfQuestionTemplateOrPlayer]);
|
|
82
124
|
const arrowColor = selected ? color : undefined;
|
|
83
|
-
const arrowView = !multiple ? /*#__PURE__*/React.createElement(ArrowDown, {
|
|
84
|
-
color: includes(theme, ['question', 'template', 'player']) ? arrowColor : black,
|
|
85
|
-
className: shouldUseSkinFontColor ? style.selectedArrow : style.arrow,
|
|
86
|
-
"aria-label": ariaLabel,
|
|
87
|
-
"data-testid": "select-arrow-down-icon"
|
|
88
|
-
}) : null;
|
|
89
125
|
const behaviorClassName = useMemo(() => getClassState(style.default, style.modified, style.error, modified, error), [error, modified]);
|
|
90
126
|
const composedClassName = useMemo(() => classnames(theme && theme !== 'coorpmanager' ? themeStyle[theme] : behaviorClassName, selected ? style.selected : style.unselected, className), [behaviorClassName, className, selected, theme]);
|
|
91
127
|
const labelSize = useMemo(() => size(selectedLabel), [selectedLabel]);
|
|
@@ -104,7 +140,13 @@ const Select = (props, legacyContext) => {
|
|
|
104
140
|
style: _extends({}, shouldUseSkinFontColor && {
|
|
105
141
|
color
|
|
106
142
|
})
|
|
107
|
-
}, selectedLabel),
|
|
143
|
+
}, selectedLabel), /*#__PURE__*/React.createElement(ArrowView, {
|
|
144
|
+
shouldRender: !multiple,
|
|
145
|
+
isArrowUp: isArrowUp,
|
|
146
|
+
ariaLabel: ariaLabel,
|
|
147
|
+
arrowClass: shouldUseSkinFontColor ? style.selectedArrow : style.arrow,
|
|
148
|
+
arrowColor: isThemeOneOfQuestionTemplateOrPlayer ? arrowColor : black
|
|
149
|
+
}), /*#__PURE__*/React.createElement("select", {
|
|
108
150
|
"data-name": "native-select",
|
|
109
151
|
className: style.selectBox,
|
|
110
152
|
title: selectedLabel,
|
|
@@ -112,7 +154,14 @@ const Select = (props, legacyContext) => {
|
|
|
112
154
|
onChange: handleChange,
|
|
113
155
|
value: selected,
|
|
114
156
|
multiple: multiple,
|
|
115
|
-
disabled: disabled
|
|
157
|
+
disabled: disabled,
|
|
158
|
+
onClick: handleSelectOnFocus,
|
|
159
|
+
onBlur: handleSelectOnBlur // onBlur does not handle completely an out of bounds click
|
|
160
|
+
// ex: select is Opened and a click is done outside, cancelling the select
|
|
161
|
+
// that doesn't count as a Blur, so an onMouseLeave is needed
|
|
162
|
+
,
|
|
163
|
+
onMouseLeave: handleSelectOnBlur,
|
|
164
|
+
"data-testid": "native-select"
|
|
116
165
|
}, optionList)), /*#__PURE__*/React.createElement("div", {
|
|
117
166
|
className: style.description
|
|
118
167
|
}, description));
|
|
@@ -124,6 +173,10 @@ export const SelectOptionPropTypes = {
|
|
|
124
173
|
selected: PropTypes.bool,
|
|
125
174
|
validOption: PropTypes.bool
|
|
126
175
|
};
|
|
176
|
+
export const SelectOptionGroupPropTypes = {
|
|
177
|
+
label: PropTypes.string.isRequired,
|
|
178
|
+
options: PropTypes.arrayOf(PropTypes.shape(SelectOptionPropTypes))
|
|
179
|
+
};
|
|
127
180
|
Select.contextTypes = {
|
|
128
181
|
skin: Provider.childContextTypes.skin
|
|
129
182
|
};
|
|
@@ -139,6 +192,7 @@ Select.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
139
192
|
onChange: PropTypes.func,
|
|
140
193
|
theme: PropTypes.oneOf(keys(themeStyle)),
|
|
141
194
|
options: PropTypes.arrayOf(PropTypes.shape(SelectOptionPropTypes)),
|
|
195
|
+
optgroups: PropTypes.arrayOf(PropTypes.shape(SelectOptionGroupPropTypes)),
|
|
142
196
|
modified: PropTypes.bool,
|
|
143
197
|
error: PropTypes.bool,
|
|
144
198
|
'aria-label': PropTypes.string
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","useMemo","PropTypes","classnames","filter","find","get","getOr","includes","keys","map","size","NovaCompositionNavigationArrowDown","ArrowDown","Provider","GetSkinFromContext","getClassState","style","themeStyle","invalid","header","mooc","question","sort","thematiques","player","template","coorpmanager","Select","props","legacyContext","name","options","className","borderClassName","onChange","multiple","disabled","required","description","theme","modified","error","title","propTitle","ariaLabel","skin","optionList","option","index","value","selectOption","titleView","selected","selectedLabel","isSelectedInValidOption","validOption","handleChange","e","target","selectedOptions","black","color","shouldUseSkinFontColor","arrowColor","undefined","arrowView","selectedArrow","arrow","behaviorClassName","default","composedClassName","unselected","labelSize","isLongLabel","selectWrapper","selectSpan","noLabelCommon","longLabel","selectBox","SelectOptionPropTypes","string","isRequired","oneOfType","number","bool","contextTypes","childContextTypes","propTypes","func","oneOf","arrayOf","shape"],"sources":["../../../src/atom/select/index.js"],"sourcesContent":["import React, {useMemo} from 'react';\nimport PropTypes from 'prop-types';\nimport classnames from 'classnames';\nimport filter from 'lodash/fp/filter';\nimport find from 'lodash/fp/find';\nimport get from 'lodash/fp/get';\nimport getOr from 'lodash/fp/getOr';\nimport includes from 'lodash/fp/includes';\nimport keys from 'lodash/fp/keys';\nimport map from 'lodash/fp/map';\nimport size from 'lodash/fp/size';\nimport {NovaCompositionNavigationArrowDown as ArrowDown} from '@coorpacademy/nova-icons';\nimport Provider, {GetSkinFromContext} from '../provider';\nimport getClassState from '../../util/get-class-state';\nimport style from './style.css';\n\nconst themeStyle = {\n filter: style.filter,\n invalid: style.invalid,\n header: style.header,\n mooc: style.mooc,\n question: style.question,\n sort: style.sort,\n thematiques: style.thematiques,\n player: style.player,\n template: style.template,\n coorpmanager: null\n};\n\nconst Select = (props, legacyContext) => {\n const {\n name,\n options = [],\n className,\n borderClassName,\n onChange,\n multiple = false,\n disabled,\n required,\n description,\n theme,\n modified = false,\n error = false,\n title: propTitle,\n 'aria-label': ariaLabel\n } = props;\n\n const skin = GetSkinFromContext(legacyContext);\n const title = useMemo(\n () => (propTitle ? `${propTitle}${required ? '*' : ''}` : null),\n [propTitle, required]\n );\n\n const optionList =\n options &&\n options.map((option, index) => {\n return (\n <option key={index} value={option.value} className={style.selectOption}>\n {option.name}\n </option>\n );\n });\n\n const titleView = title ? <span className={style.title}>{title} </span> : null;\n\n const selected = useMemo(\n () =>\n multiple\n ? map(get('value'), filter({selected: true}, options))\n : get('value', find({selected: true}, options)),\n [multiple, options]\n );\n const selectedLabel = useMemo(\n () =>\n multiple\n ? map(get('name'), filter({selected: true}, options))\n : get('name', find({selected: true}, options)),\n [multiple, options]\n );\n\n const isSelectedInValidOption = useMemo(\n () =>\n theme === 'player' &&\n getOr(false, 'name', find({validOption: false, selected: true}, options)),\n [options, theme]\n );\n\n const handleChange = useMemo(\n () =>\n multiple\n ? e => {\n onChange(map(get('value'), e.target.selectedOptions));\n }\n : e => {\n onChange(e.target.value);\n },\n [onChange, multiple]\n );\n\n const black = useMemo(() => getOr('#14171A', 'common.black', skin), [skin]);\n const color = useMemo(() => getOr('#00B0FF', 'common.primary', skin), [skin]);\n const shouldUseSkinFontColor = useMemo(\n () =>\n !isSelectedInValidOption && selected && includes(theme, ['question', 'template', 'player']),\n [isSelectedInValidOption, selected, theme]\n );\n const arrowColor = selected ? color : undefined;\n\n const arrowView = !multiple ? (\n <ArrowDown\n color={includes(theme, ['question', 'template', 'player']) ? arrowColor : black}\n className={shouldUseSkinFontColor ? style.selectedArrow : style.arrow}\n aria-label={ariaLabel}\n data-testid=\"select-arrow-down-icon\"\n />\n ) : null;\n const behaviorClassName = useMemo(\n () => getClassState(style.default, style.modified, style.error, modified, error),\n [error, modified]\n );\n const composedClassName = useMemo(\n () =>\n classnames(\n theme && theme !== 'coorpmanager' ? themeStyle[theme] : behaviorClassName,\n selected ? style.selected : style.unselected,\n className\n ),\n [behaviorClassName, className, selected, theme]\n );\n\n const labelSize = useMemo(() => size(selectedLabel), [selectedLabel]);\n\n const isLongLabel = useMemo(() => labelSize >= 65, [labelSize]);\n\n return (\n <div\n className={classnames(\n composedClassName,\n theme === 'coorpmanager' ? style.coorpmanager : null\n )}\n >\n <label\n data-name=\"select-wrapper\"\n style={{\n ...(shouldUseSkinFontColor && {\n color\n })\n }}\n className={style.selectWrapper}\n >\n {titleView}\n <span\n data-name=\"select-span\"\n className={classnames(\n style.selectSpan,\n includes(theme, ['player', 'invalid', 'question', 'thematiques', 'template'])\n ? style.noLabelCommon\n : null,\n borderClassName,\n isLongLabel ? style.longLabel : null\n )}\n style={{\n ...(shouldUseSkinFontColor && {\n color\n })\n }}\n >\n {selectedLabel}\n </span>\n {arrowView}\n <select\n data-name=\"native-select\"\n className={style.selectBox}\n title={selectedLabel}\n name={name}\n onChange={handleChange}\n value={selected}\n multiple={multiple}\n disabled={disabled}\n >\n {optionList}\n </select>\n </label>\n <div className={style.description}>{description}</div>\n </div>\n );\n};\n\nexport const SelectOptionPropTypes = {\n name: PropTypes.string.isRequired,\n value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n selected: PropTypes.bool,\n validOption: PropTypes.bool\n};\n\nSelect.contextTypes = {\n skin: Provider.childContextTypes.skin\n};\n\nSelect.propTypes = {\n title: PropTypes.string,\n name: PropTypes.string,\n className: PropTypes.string,\n borderClassName: PropTypes.string,\n disabled: PropTypes.bool,\n multiple: PropTypes.bool,\n description: PropTypes.string,\n required: PropTypes.bool,\n onChange: PropTypes.func,\n theme: PropTypes.oneOf(keys(themeStyle)),\n options: PropTypes.arrayOf(PropTypes.shape(SelectOptionPropTypes)),\n modified: PropTypes.bool,\n error: PropTypes.bool,\n 'aria-label': PropTypes.string\n};\n\nexport default Select;\n"],"mappings":";;AAAA,OAAOA,KAAP,IAAeC,OAAf,QAA6B,OAA7B;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,OAAOC,UAAP,MAAuB,YAAvB;AACA,OAAOC,MAAP,MAAmB,kBAAnB;AACA,OAAOC,IAAP,MAAiB,gBAAjB;AACA,OAAOC,GAAP,MAAgB,eAAhB;AACA,OAAOC,KAAP,MAAkB,iBAAlB;AACA,OAAOC,QAAP,MAAqB,oBAArB;AACA,OAAOC,IAAP,MAAiB,gBAAjB;AACA,OAAOC,GAAP,MAAgB,eAAhB;AACA,OAAOC,IAAP,MAAiB,gBAAjB;AACA,SAAQC,kCAAkC,IAAIC,SAA9C,QAA8D,0BAA9D;AACA,OAAOC,QAAP,IAAkBC,kBAAlB,QAA2C,aAA3C;AACA,OAAOC,aAAP,MAA0B,4BAA1B;AACA,OAAOC,KAAP,MAAkB,aAAlB;AAEA,MAAMC,UAAU,GAAG;EACjBd,MAAM,EAAEa,KAAK,CAACb,MADG;EAEjBe,OAAO,EAAEF,KAAK,CAACE,OAFE;EAGjBC,MAAM,EAAEH,KAAK,CAACG,MAHG;EAIjBC,IAAI,EAAEJ,KAAK,CAACI,IAJK;EAKjBC,QAAQ,EAAEL,KAAK,CAACK,QALC;EAMjBC,IAAI,EAAEN,KAAK,CAACM,IANK;EAOjBC,WAAW,EAAEP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AcnF,SAAS,CAAC+E;AAdP,CAAnB;AAiBA,eAAerD,MAAf"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","useCallback","useMemo","useState","PropTypes","classnames","concat","filter","find","flatMapDeep","get","getOr","includes","isEmpty","keys","map","size","NovaCompositionNavigationArrowDown","ArrowDown","NovaCompositionNavigationArrowTop","ArrowUp","Provider","GetSkinFromContext","getClassState","style","themeStyle","invalid","header","mooc","question","sort","thematiques","player","template","coorpmanager","ArrowView","shouldRender","isArrowUp","ariaLabel","arrowClass","arrowColor","props","color","className","Select","legacyContext","name","options","optgroups","borderClassName","onChange","multiple","disabled","required","description","theme","modified","error","title","propTitle","skin","setIsArrowUp","handleSelectOnFocus","handleSelectOnBlur","selectOption","option","index","value","optionList","optgroup","label","i","titleView","selected","selectedLabel","isSelectedInValidOption","validOption","handleChange","e","target","selectedOptions","black","isThemeOneOfQuestionTemplateOrPlayer","shouldUseSkinFontColor","undefined","behaviorClassName","default","composedClassName","unselected","labelSize","isLongLabel","selectWrapper","selectSpan","noLabelCommon","longLabel","selectedArrow","arrow","selectBox","SelectOptionPropTypes","string","isRequired","oneOfType","number","bool","SelectOptionGroupPropTypes","arrayOf","shape","contextTypes","childContextTypes","propTypes","func","oneOf"],"sources":["../../../src/atom/select/index.js"],"sourcesContent":["import React, {useCallback, useMemo, useState} from 'react';\nimport PropTypes from 'prop-types';\nimport classnames from 'classnames';\nimport concat from 'lodash/fp/concat';\nimport filter from 'lodash/fp/filter';\nimport find from 'lodash/fp/find';\nimport flatMapDeep from 'lodash/fp/flatMapDeep';\nimport get from 'lodash/fp/get';\nimport getOr from 'lodash/fp/getOr';\nimport includes from 'lodash/fp/includes';\nimport isEmpty from 'lodash/fp/isEmpty';\nimport keys from 'lodash/fp/keys';\nimport map from 'lodash/fp/map';\nimport size from 'lodash/fp/size';\nimport {\n NovaCompositionNavigationArrowDown as ArrowDown,\n NovaCompositionNavigationArrowTop as ArrowUp\n} from '@coorpacademy/nova-icons';\nimport Provider, {GetSkinFromContext} from '../provider';\nimport getClassState from '../../util/get-class-state';\nimport style from './style.css';\n\nconst themeStyle = {\n filter: style.filter,\n invalid: style.invalid,\n header: style.header,\n mooc: style.mooc,\n question: style.question,\n sort: style.sort,\n thematiques: style.thematiques,\n player: style.player,\n template: style.template,\n coorpmanager: null\n};\n\nconst ArrowView = ({shouldRender, isArrowUp, ariaLabel, arrowClass, arrowColor}) => {\n const props = useMemo(\n () => ({\n ...(ariaLabel &\n {\n 'aria-label': ariaLabel\n }),\n ...(arrowColor &\n {\n color: arrowColor\n }),\n className: arrowClass\n }),\n [ariaLabel, arrowClass, arrowColor]\n );\n if (shouldRender) {\n return isArrowUp ? (\n <ArrowUp {...props} data-testid=\"select-arrow-up-icon\" />\n ) : (\n <ArrowDown {...props} data-testid=\"select-arrow-down-icon\" />\n );\n } else return null;\n};\n\nconst Select = (props, legacyContext) => {\n const {\n name,\n options = [],\n optgroups = [],\n className,\n borderClassName,\n onChange,\n multiple = false,\n disabled,\n required,\n description,\n theme,\n modified = false,\n error = false,\n title: propTitle,\n 'aria-label': ariaLabel\n } = props;\n\n const skin = GetSkinFromContext(legacyContext);\n const title = useMemo(\n () => (propTitle ? `${propTitle}${required ? '*' : ''}` : null),\n [propTitle, required]\n );\n\n const [isArrowUp, setIsArrowUp] = useState(false);\n\n const handleSelectOnFocus = useCallback(() => setIsArrowUp(true), []);\n const handleSelectOnBlur = useCallback(() => setIsArrowUp(false), []);\n\n const selectOption = (option, index) => {\n return (\n <option key={index} value={option.value} className={style.selectOption}>\n {option.name}\n </option>\n );\n };\n\n const optionList = !isEmpty(options)\n ? options.map((option, index) => selectOption(option, index))\n : optgroups.map((optgroup, index) => {\n return (\n <optgroup key={index} label={optgroup.label}>\n {optgroup.options && optgroup.options.map((option, i) => selectOption(option, i))}\n </optgroup>\n );\n });\n\n const titleView = title ? <span className={style.title}>{title} </span> : null;\n\n const selected = useMemo(\n () =>\n multiple\n ? map(get('value'), filter({selected: true}, options))\n : get('value', find({selected: true}, concat(options, flatMapDeep('options', optgroups)))),\n [multiple, options, optgroups]\n );\n const selectedLabel = useMemo(\n () =>\n multiple\n ? map(get('name'), filter({selected: true}, options))\n : get('value', find({selected: true}, concat(options, flatMapDeep('options', optgroups)))),\n [multiple, options, optgroups]\n );\n\n const isSelectedInValidOption = useMemo(\n () =>\n theme === 'player' &&\n getOr(false, 'name', find({validOption: false, selected: true}, options)),\n [options, theme]\n );\n\n const handleChange = useMemo(\n () =>\n multiple\n ? e => {\n setIsArrowUp(false);\n onChange(map(get('value'), e.target.selectedOptions));\n }\n : e => {\n setIsArrowUp(false);\n onChange(e.target.value);\n },\n [onChange, multiple]\n );\n\n const black = useMemo(() => getOr('#14171A', 'common.black', skin), [skin]);\n const color = useMemo(() => getOr('#00B0FF', 'common.primary', skin), [skin]);\n const isThemeOneOfQuestionTemplateOrPlayer = useMemo(\n () => includes(theme, ['question', 'template', 'player']),\n [theme]\n );\n const shouldUseSkinFontColor = useMemo(\n () => !isSelectedInValidOption && selected && isThemeOneOfQuestionTemplateOrPlayer,\n [isSelectedInValidOption, selected, isThemeOneOfQuestionTemplateOrPlayer]\n );\n const arrowColor = selected ? color : undefined;\n\n const behaviorClassName = useMemo(\n () => getClassState(style.default, style.modified, style.error, modified, error),\n [error, modified]\n );\n const composedClassName = useMemo(\n () =>\n classnames(\n theme && theme !== 'coorpmanager' ? themeStyle[theme] : behaviorClassName,\n selected ? style.selected : style.unselected,\n className\n ),\n [behaviorClassName, className, selected, theme]\n );\n\n const labelSize = useMemo(() => size(selectedLabel), [selectedLabel]);\n\n const isLongLabel = useMemo(() => labelSize >= 65, [labelSize]);\n\n return (\n <div\n className={classnames(\n composedClassName,\n theme === 'coorpmanager' ? style.coorpmanager : null\n )}\n >\n <label\n data-name=\"select-wrapper\"\n style={{\n ...(shouldUseSkinFontColor && {\n color\n })\n }}\n className={style.selectWrapper}\n >\n {titleView}\n <span\n data-name=\"select-span\"\n className={classnames(\n style.selectSpan,\n includes(theme, ['player', 'invalid', 'question', 'thematiques', 'template'])\n ? style.noLabelCommon\n : null,\n borderClassName,\n isLongLabel ? style.longLabel : null\n )}\n style={{\n ...(shouldUseSkinFontColor && {\n color\n })\n }}\n >\n {selectedLabel}\n </span>\n <ArrowView\n shouldRender={!multiple}\n isArrowUp={isArrowUp}\n ariaLabel={ariaLabel}\n arrowClass={shouldUseSkinFontColor ? style.selectedArrow : style.arrow}\n arrowColor={isThemeOneOfQuestionTemplateOrPlayer ? arrowColor : black}\n />\n <select\n data-name=\"native-select\"\n className={style.selectBox}\n title={selectedLabel}\n name={name}\n onChange={handleChange}\n value={selected}\n multiple={multiple}\n disabled={disabled}\n onClick={handleSelectOnFocus}\n onBlur={handleSelectOnBlur}\n // onBlur does not handle completely an out of bounds click\n // ex: select is Opened and a click is done outside, cancelling the select\n // that doesn't count as a Blur, so an onMouseLeave is needed\n onMouseLeave={handleSelectOnBlur}\n data-testid=\"native-select\"\n >\n {optionList}\n </select>\n </label>\n <div className={style.description}>{description}</div>\n </div>\n );\n};\n\nexport const SelectOptionPropTypes = {\n name: PropTypes.string.isRequired,\n value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n selected: PropTypes.bool,\n validOption: PropTypes.bool\n};\n\nexport const SelectOptionGroupPropTypes = {\n label: PropTypes.string.isRequired,\n options: PropTypes.arrayOf(PropTypes.shape(SelectOptionPropTypes))\n};\n\nSelect.contextTypes = {\n skin: Provider.childContextTypes.skin\n};\n\nSelect.propTypes = {\n title: PropTypes.string,\n name: PropTypes.string,\n className: PropTypes.string,\n borderClassName: PropTypes.string,\n disabled: PropTypes.bool,\n multiple: PropTypes.bool,\n description: PropTypes.string,\n required: PropTypes.bool,\n onChange: PropTypes.func,\n theme: PropTypes.oneOf(keys(themeStyle)),\n options: PropTypes.arrayOf(PropTypes.shape(SelectOptionPropTypes)),\n optgroups: PropTypes.arrayOf(PropTypes.shape(SelectOptionGroupPropTypes)),\n modified: PropTypes.bool,\n error: PropTypes.bool,\n 'aria-label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ElD,SAAS,CAAC+F,MAPN;EAQjB9C,QAAQ,EAAEjD,SAAS,CAACmG,IARH;EASjBrD,QAAQ,EAAE9C,SAAS,CAAC0G,IATH;EAUjBvD,KAAK,EAAEnD,SAAS,CAAC2G,KAAV,CAAgBjG,IAAI,CAACW,UAAD,CAApB,CAVU;EAWjBsB,OAAO,EAAE3C,SAAS,CAACqG,OAAV,CAAkBrG,SAAS,CAACsG,KAAV,CAAgBR,qBAAhB,CAAlB,CAXQ;EAYjBlD,SAAS,EAAE5C,SAAS,CAACqG,OAAV,CAAkBrG,SAAS,CAACsG,KAAV,CAAgBF,0BAAhB,CAAlB,CAZM;EAajBhD,QAAQ,EAAEpD,SAAS,CAACmG,IAbH;EAcjB9C,KAAK,EAAErD,SAAS,CAACmG,IAdA;EAejB,cAAcnG,SAAS,CAAC+F;AAfP,CAAnB;AAkBA,eAAevD,MAAf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/molecule/answer/index.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/molecule/answer/index.js"],"names":[],"mappings":";AAwEA,iDASC"}
|
|
@@ -14,8 +14,8 @@ import Qcm from '../questions/qcm';
|
|
|
14
14
|
import QcmGraphic from '../questions/qcm-graphic';
|
|
15
15
|
import QuestionRange from '../questions/question-range';
|
|
16
16
|
import Template from '../questions/template';
|
|
17
|
-
import Provider from '../../atom/provider';
|
|
18
17
|
import Audio from '../audio';
|
|
18
|
+
import { GetTranslateFromContext } from '../../atom/provider';
|
|
19
19
|
import style from './style.css';
|
|
20
20
|
import propTypes, { MediaViewPropTypes, TYPE_AUDIO, TYPE_IMAGE, TYPE_VIDEO } from './prop-types';
|
|
21
21
|
|
|
@@ -64,38 +64,46 @@ MediaView.propTypes = process.env.NODE_ENV !== "production" ? MediaViewPropTypes
|
|
|
64
64
|
const Switch = ({
|
|
65
65
|
model,
|
|
66
66
|
help
|
|
67
|
-
}, {
|
|
68
|
-
translate
|
|
69
67
|
}) => {
|
|
70
68
|
const {
|
|
71
69
|
type
|
|
72
70
|
} = model;
|
|
71
|
+
const translate = GetTranslateFromContext();
|
|
73
72
|
|
|
74
73
|
switch (type) {
|
|
75
74
|
case 'qcmDrag':
|
|
76
75
|
return /*#__PURE__*/React.createElement(QcmDrag, _extends({}, model, {
|
|
77
|
-
help: help
|
|
76
|
+
help: help,
|
|
77
|
+
groupAriaLabel: translate('answer_the_question')
|
|
78
78
|
}));
|
|
79
79
|
|
|
80
80
|
case 'qcm':
|
|
81
|
-
return /*#__PURE__*/React.createElement(Qcm, model
|
|
81
|
+
return /*#__PURE__*/React.createElement(Qcm, _extends({}, model, {
|
|
82
|
+
groupAriaLabel: translate('answer_the_question')
|
|
83
|
+
}));
|
|
82
84
|
|
|
83
85
|
case 'qcmGraphic':
|
|
84
|
-
return /*#__PURE__*/React.createElement(QcmGraphic, model
|
|
86
|
+
return /*#__PURE__*/React.createElement(QcmGraphic, _extends({}, model, {
|
|
87
|
+
groupAriaLabel: translate('answer_the_question')
|
|
88
|
+
}));
|
|
85
89
|
|
|
86
90
|
case 'freeText':
|
|
87
91
|
return /*#__PURE__*/React.createElement(FreeText, model);
|
|
88
92
|
|
|
89
93
|
case 'dropDown':
|
|
90
94
|
return /*#__PURE__*/React.createElement(DropDown, _extends({}, model, {
|
|
91
|
-
|
|
95
|
+
groupAriaLabel: translate('answer_the_question')
|
|
92
96
|
}));
|
|
93
97
|
|
|
94
98
|
case 'slider':
|
|
95
|
-
return /*#__PURE__*/React.createElement(QuestionRange, model
|
|
99
|
+
return /*#__PURE__*/React.createElement(QuestionRange, _extends({}, model, {
|
|
100
|
+
groupAriaLabel: translate('answer_the_question')
|
|
101
|
+
}));
|
|
96
102
|
|
|
97
103
|
case 'template':
|
|
98
|
-
return /*#__PURE__*/React.createElement(Template, model
|
|
104
|
+
return /*#__PURE__*/React.createElement(Template, _extends({}, model, {
|
|
105
|
+
groupAriaLabel: translate('answer_the_question')
|
|
106
|
+
}));
|
|
99
107
|
}
|
|
100
108
|
};
|
|
101
109
|
|
|
@@ -103,9 +111,6 @@ Switch.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
103
111
|
model: propTypes.model,
|
|
104
112
|
help: propTypes.help
|
|
105
113
|
} : {};
|
|
106
|
-
Switch.contextTypes = {
|
|
107
|
-
translate: Provider.childContextTypes.translate
|
|
108
|
-
};
|
|
109
114
|
|
|
110
115
|
const Answer = props => {
|
|
111
116
|
const {
|