@coorpacademy/components 11.7.2 → 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.
Files changed (140) hide show
  1. package/README.md +3 -3
  2. package/es/atom/loader/index.native.d.ts +10 -0
  3. package/es/atom/loader/index.native.d.ts.map +1 -0
  4. package/es/atom/loader/index.native.js +192 -0
  5. package/es/atom/loader/index.native.js.map +1 -0
  6. package/es/atom/select/index.d.ts +18 -0
  7. package/es/atom/select/index.d.ts.map +1 -1
  8. package/es/atom/select/index.js +21 -4
  9. package/es/atom/select/index.js.map +1 -1
  10. package/es/molecule/answer/index.d.ts.map +1 -1
  11. package/es/molecule/answer/index.js +19 -6
  12. package/es/molecule/answer/index.js.map +1 -1
  13. package/es/molecule/brand-form-group/index.d.ts +18 -0
  14. package/es/molecule/filters/filters-wrapper.d.ts +1 -0
  15. package/es/molecule/filters/filters-wrapper.d.ts.map +1 -1
  16. package/es/molecule/filters/filters-wrapper.js +9 -5
  17. package/es/molecule/filters/filters-wrapper.js.map +1 -1
  18. package/es/molecule/filters/index.d.ts +10 -0
  19. package/es/molecule/filters/index.d.ts.map +1 -1
  20. package/es/molecule/filters/index.js +6 -3
  21. package/es/molecule/filters/index.js.map +1 -1
  22. package/es/molecule/questions/drop-down/index.d.ts +1 -0
  23. package/es/molecule/questions/drop-down/index.d.ts.map +1 -1
  24. package/es/molecule/questions/drop-down/index.js +9 -5
  25. package/es/molecule/questions/drop-down/index.js.map +1 -1
  26. package/es/molecule/questions/qcm/index.d.ts +1 -0
  27. package/es/molecule/questions/qcm/index.d.ts.map +1 -1
  28. package/es/molecule/questions/qcm/index.js +9 -5
  29. package/es/molecule/questions/qcm/index.js.map +1 -1
  30. package/es/molecule/questions/qcm-drag/index.d.ts +3 -1
  31. package/es/molecule/questions/qcm-drag/index.d.ts.map +1 -1
  32. package/es/molecule/questions/qcm-drag/index.js +9 -5
  33. package/es/molecule/questions/qcm-drag/index.js.map +1 -1
  34. package/es/molecule/questions/qcm-graphic/index.d.ts +1 -0
  35. package/es/molecule/questions/qcm-graphic/index.d.ts.map +1 -1
  36. package/es/molecule/questions/qcm-graphic/index.js +9 -5
  37. package/es/molecule/questions/qcm-graphic/index.js.map +1 -1
  38. package/es/molecule/questions/question-range/index.d.ts +1 -0
  39. package/es/molecule/questions/question-range/index.d.ts.map +1 -1
  40. package/es/molecule/questions/question-range/index.js +10 -6
  41. package/es/molecule/questions/question-range/index.js.map +1 -1
  42. package/es/molecule/questions/template/index.d.ts +6 -2
  43. package/es/molecule/questions/template/index.d.ts.map +1 -1
  44. package/es/molecule/questions/template/index.js +9 -5
  45. package/es/molecule/questions/template/index.js.map +1 -1
  46. package/es/molecule/setup-slide/index.d.ts +9 -0
  47. package/es/molecule/setup-slider/index.d.ts +9 -0
  48. package/es/organism/brand-form/index.d.ts +18 -0
  49. package/es/organism/user-preferences/index.d.ts +1 -0
  50. package/es/organism/user-preferences/index.d.ts.map +1 -1
  51. package/es/organism/user-preferences/index.js +9 -5
  52. package/es/organism/user-preferences/index.js.map +1 -1
  53. package/es/organism/wizard-contents/index.d.ts +18 -0
  54. package/es/template/back-office/brand-update/index.d.ts +36 -0
  55. package/es/template/common/search-page/index.d.ts +11 -0
  56. package/es/template/common/search-page/index.d.ts.map +1 -1
  57. package/es/template/common/search-page/index.js +6 -3
  58. package/es/template/common/search-page/index.js.map +1 -1
  59. package/lib/atom/loader/index.native.d.ts +10 -0
  60. package/lib/atom/loader/index.native.d.ts.map +1 -0
  61. package/lib/atom/loader/index.native.js +205 -0
  62. package/lib/atom/loader/index.native.js.map +1 -0
  63. package/lib/atom/select/index.d.ts +18 -0
  64. package/lib/atom/select/index.d.ts.map +1 -1
  65. package/lib/atom/select/index.js +26 -5
  66. package/lib/atom/select/index.js.map +1 -1
  67. package/lib/molecule/answer/index.d.ts.map +1 -1
  68. package/lib/molecule/answer/index.js +20 -6
  69. package/lib/molecule/answer/index.js.map +1 -1
  70. package/lib/molecule/brand-form-group/index.d.ts +18 -0
  71. package/lib/molecule/filters/filters-wrapper.d.ts +1 -0
  72. package/lib/molecule/filters/filters-wrapper.d.ts.map +1 -1
  73. package/lib/molecule/filters/filters-wrapper.js +9 -5
  74. package/lib/molecule/filters/filters-wrapper.js.map +1 -1
  75. package/lib/molecule/filters/index.d.ts +10 -0
  76. package/lib/molecule/filters/index.d.ts.map +1 -1
  77. package/lib/molecule/filters/index.js +6 -3
  78. package/lib/molecule/filters/index.js.map +1 -1
  79. package/lib/molecule/questions/drop-down/index.d.ts +1 -0
  80. package/lib/molecule/questions/drop-down/index.d.ts.map +1 -1
  81. package/lib/molecule/questions/drop-down/index.js +9 -5
  82. package/lib/molecule/questions/drop-down/index.js.map +1 -1
  83. package/lib/molecule/questions/qcm/index.d.ts +1 -0
  84. package/lib/molecule/questions/qcm/index.d.ts.map +1 -1
  85. package/lib/molecule/questions/qcm/index.js +9 -5
  86. package/lib/molecule/questions/qcm/index.js.map +1 -1
  87. package/lib/molecule/questions/qcm-drag/index.d.ts +3 -1
  88. package/lib/molecule/questions/qcm-drag/index.d.ts.map +1 -1
  89. package/lib/molecule/questions/qcm-drag/index.js +9 -5
  90. package/lib/molecule/questions/qcm-drag/index.js.map +1 -1
  91. package/lib/molecule/questions/qcm-graphic/index.d.ts +1 -0
  92. package/lib/molecule/questions/qcm-graphic/index.d.ts.map +1 -1
  93. package/lib/molecule/questions/qcm-graphic/index.js +9 -5
  94. package/lib/molecule/questions/qcm-graphic/index.js.map +1 -1
  95. package/lib/molecule/questions/question-range/index.d.ts +1 -0
  96. package/lib/molecule/questions/question-range/index.d.ts.map +1 -1
  97. package/lib/molecule/questions/question-range/index.js +10 -6
  98. package/lib/molecule/questions/question-range/index.js.map +1 -1
  99. package/lib/molecule/questions/template/index.d.ts +6 -2
  100. package/lib/molecule/questions/template/index.d.ts.map +1 -1
  101. package/lib/molecule/questions/template/index.js +9 -5
  102. package/lib/molecule/questions/template/index.js.map +1 -1
  103. package/lib/molecule/setup-slide/index.d.ts +9 -0
  104. package/lib/molecule/setup-slider/index.d.ts +9 -0
  105. package/lib/organism/brand-form/index.d.ts +18 -0
  106. package/lib/organism/user-preferences/index.d.ts +1 -0
  107. package/lib/organism/user-preferences/index.d.ts.map +1 -1
  108. package/lib/organism/user-preferences/index.js +9 -5
  109. package/lib/organism/user-preferences/index.js.map +1 -1
  110. package/lib/organism/wizard-contents/index.d.ts +18 -0
  111. package/lib/template/back-office/brand-update/index.d.ts +36 -0
  112. package/lib/template/common/search-page/index.d.ts +11 -0
  113. package/lib/template/common/search-page/index.d.ts.map +1 -1
  114. package/lib/template/common/search-page/index.js +6 -3
  115. package/lib/template/common/search-page/index.js.map +1 -1
  116. package/locales/.mtslconfig.json +1 -0
  117. package/locales/cs/global.json +1 -0
  118. package/locales/de/global.json +1 -0
  119. package/locales/en/global.json +1 -0
  120. package/locales/es/global.json +1 -0
  121. package/locales/et/global.json +1 -0
  122. package/locales/fr/global.json +1 -0
  123. package/locales/hr/global.json +1 -0
  124. package/locales/hu/global.json +1 -0
  125. package/locales/it/global.json +1 -0
  126. package/locales/ja/global.json +1 -0
  127. package/locales/ko/global.json +1 -0
  128. package/locales/nl/global.json +1 -0
  129. package/locales/pl/global.json +1 -0
  130. package/locales/pt/global.json +1 -0
  131. package/locales/ro/global.json +1 -0
  132. package/locales/ru/global.json +1 -0
  133. package/locales/sk/global.json +1 -0
  134. package/locales/tl/global.json +1 -0
  135. package/locales/tr/global.json +1 -0
  136. package/locales/uk/global.json +1 -0
  137. package/locales/vi/global.json +1 -0
  138. package/locales/zh/global.json +1 -0
  139. package/locales/zh_TW/global.json +1 -0
  140. package/package.json +3 -3
@@ -0,0 +1,205 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.default = void 0;
5
+
6
+ var _reactNativeAnimation = require("@coorpacademy/react-native-animation");
7
+
8
+ var _react = _interopRequireWildcard(require("react"));
9
+
10
+ var _reactNative = require("react-native");
11
+
12
+ var _templateContext = require("../../template/app-review/template-context");
13
+
14
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
15
+
16
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
17
+
18
+ const createStyleSheet = theme => _reactNative.StyleSheet.create({
19
+ container: {
20
+ alignItems: 'center',
21
+ justifyContent: 'center'
22
+ },
23
+ dot: {
24
+ position: 'absolute'
25
+ },
26
+ blue: {
27
+ backgroundColor: theme.colors.cta
28
+ },
29
+ red: {
30
+ backgroundColor: theme.colors.negative
31
+ },
32
+ green: {
33
+ backgroundColor: theme.colors.positive
34
+ },
35
+ yellow: {
36
+ backgroundColor: theme.colors.battle
37
+ }
38
+ });
39
+
40
+ const CYCLE_DURATION = 3000;
41
+ const MIN_TIME = 1000;
42
+
43
+ const Loader = props => {
44
+ const templateContext = (0, _templateContext.useTemplateContext)();
45
+ const {
46
+ theme
47
+ } = templateContext;
48
+ const [styleSheet, setStylesheet] = (0, _react.useState)(null);
49
+ const [visible, setVisible] = (0, _react.useState)(true);
50
+ const [minTimeIsSpent, setMinTimeSpent] = (0, _react.useState)(false);
51
+ const rotation = (0, _react.useRef)(new _reactNative.Animated.Value(0)).current;
52
+ const scale = (0, _react.useRef)(new _reactNative.Animated.Value(0)).current;
53
+ const hideAnimation = (0, _reactNativeAnimation.useAnimateProp)({
54
+ property: 'opacity',
55
+ fromValue: 1,
56
+ toValue: 0
57
+ });
58
+ const {
59
+ height = 60,
60
+ color,
61
+ readyToHide
62
+ } = props;
63
+ (0, _react.useEffect)(() => {
64
+ const _stylesheet = createStyleSheet(theme);
65
+
66
+ setStylesheet(_stylesheet);
67
+ }, [theme]);
68
+ (0, _react.useEffect)(() => {
69
+ if (readyToHide && minTimeIsSpent) {
70
+ setVisible(false);
71
+ }
72
+ }, [readyToHide, minTimeIsSpent]);
73
+ (0, _react.useEffect)(() => {
74
+ if (!visible) {
75
+ hideAnimation.start();
76
+ }
77
+ }, [visible, hideAnimation]);
78
+ (0, _react.useEffect)(() => {
79
+ setTimeout(() => {
80
+ setMinTimeSpent(true);
81
+ }, MIN_TIME);
82
+
83
+ const _animation = _reactNative.Animated.parallel([_reactNative.Animated.loop(_reactNative.Animated.sequence([_reactNative.Animated.timing(scale, {
84
+ toValue: 0,
85
+ duration: 0,
86
+ useNativeDriver: false
87
+ }), _reactNative.Animated.timing(scale, {
88
+ toValue: 1,
89
+ duration: CYCLE_DURATION,
90
+ useNativeDriver: false,
91
+ easing: _reactNative.Easing.inOut(_reactNative.Easing.sin)
92
+ }), _reactNative.Animated.timing(scale, {
93
+ toValue: 2,
94
+ duration: CYCLE_DURATION,
95
+ useNativeDriver: false,
96
+ easing: _reactNative.Easing.inOut(_reactNative.Easing.sin)
97
+ }), _reactNative.Animated.timing(scale, {
98
+ toValue: 3,
99
+ duration: CYCLE_DURATION,
100
+ useNativeDriver: false,
101
+ easing: _reactNative.Easing.inOut(_reactNative.Easing.sin)
102
+ })])), _reactNative.Animated.loop(_reactNative.Animated.sequence([_reactNative.Animated.timing(rotation, {
103
+ toValue: 0,
104
+ duration: 0,
105
+ useNativeDriver: false
106
+ }), _reactNative.Animated.timing(rotation, {
107
+ toValue: 1,
108
+ duration: CYCLE_DURATION,
109
+ useNativeDriver: false,
110
+ easing: _reactNative.Easing.inOut(_reactNative.Easing.sin)
111
+ })]))]);
112
+
113
+ _animation.start();
114
+
115
+ return () => {
116
+ _animation.stop();
117
+ }; // eslint bad warning --> effect only onmount
118
+ // eslint-disable-next-line react-hooks/exhaustive-deps
119
+ }, []);
120
+
121
+ if (!styleSheet) {
122
+ return null;
123
+ }
124
+
125
+ const interpolatedScale = scale.interpolate({
126
+ inputRange: [0, 0.45, 1, 1.32, 1.5, 2, 2.3, 2.64, 3],
127
+ outputRange: [0.5, 0.2, 0.5, 0.5, 0.8, 0.5, 0.5, 0.3, 0.5]
128
+ });
129
+ const interpolatedRotation = rotation.interpolate({
130
+ inputRange: [0, 1],
131
+ outputRange: ['0deg', '360deg']
132
+ });
133
+ const dotWidth = rotation.interpolate({
134
+ inputRange: [0, 0.5, 1],
135
+ outputRange: [height / 2, height / 6, height / 2]
136
+ });
137
+ const dotTranslate = rotation.interpolate({
138
+ inputRange: [0, 0.5, 1],
139
+ outputRange: [-25 * (height / 60), -35 * (height / 60), -25 * (height / 60)]
140
+ });
141
+ const dotStyle = {
142
+ width: dotWidth,
143
+ height: height / 6,
144
+ borderRadius: height / 12
145
+ };
146
+ return /*#__PURE__*/_react.default.createElement(_reactNative.Animated.View, {
147
+ style: hideAnimation.animatedStyle
148
+ }, /*#__PURE__*/_react.default.createElement(_reactNative.Animated.View, {
149
+ style: [styleSheet.container, {
150
+ height,
151
+ width: height,
152
+ transform: [{
153
+ scaleX: interpolatedScale
154
+ }, {
155
+ scaleY: interpolatedScale
156
+ }, {
157
+ rotateZ: interpolatedRotation
158
+ }]
159
+ }]
160
+ }, /*#__PURE__*/_react.default.createElement(_reactNative.Animated.View, {
161
+ style: [styleSheet.dot, color ? {
162
+ backgroundColor: color
163
+ } : styleSheet.red, dotStyle, {
164
+ transform: [{
165
+ rotateZ: '45deg'
166
+ }, {
167
+ translateX: dotTranslate
168
+ }]
169
+ }]
170
+ }), /*#__PURE__*/_react.default.createElement(_reactNative.Animated.View, {
171
+ style: [styleSheet.dot, color ? {
172
+ backgroundColor: color
173
+ } : styleSheet.green, dotStyle, {
174
+ transform: [{
175
+ rotateZ: '135deg'
176
+ }, {
177
+ translateX: dotTranslate
178
+ }]
179
+ }]
180
+ }), /*#__PURE__*/_react.default.createElement(_reactNative.Animated.View, {
181
+ style: [styleSheet.dot, color ? {
182
+ backgroundColor: color
183
+ } : styleSheet.yellow, dotStyle, {
184
+ transform: [{
185
+ rotateZ: '225deg'
186
+ }, {
187
+ translateX: dotTranslate
188
+ }]
189
+ }]
190
+ }), /*#__PURE__*/_react.default.createElement(_reactNative.Animated.View, {
191
+ style: [styleSheet.dot, color ? {
192
+ backgroundColor: color
193
+ } : styleSheet.blue, dotStyle, {
194
+ transform: [{
195
+ rotateZ: '315deg'
196
+ }, {
197
+ translateX: dotTranslate
198
+ }]
199
+ }]
200
+ })));
201
+ };
202
+
203
+ var _default = Loader;
204
+ exports.default = _default;
205
+ //# sourceMappingURL=index.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.native.js","names":["createStyleSheet","theme","StyleSheet","create","container","alignItems","justifyContent","dot","position","blue","backgroundColor","colors","cta","red","negative","green","positive","yellow","battle","CYCLE_DURATION","MIN_TIME","Loader","props","templateContext","useTemplateContext","styleSheet","setStylesheet","useState","visible","setVisible","minTimeIsSpent","setMinTimeSpent","rotation","useRef","Animated","Value","current","scale","hideAnimation","useAnimateProp","property","fromValue","toValue","height","color","readyToHide","useEffect","_stylesheet","start","setTimeout","_animation","parallel","loop","sequence","timing","duration","useNativeDriver","easing","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;;AACA;;AACA;;AACA;;;;;;AAYA,MAAMA,gBAAgB,GAAIC,KAAD,IACvBC,uBAAA,CAAWC,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,EAAET,KAAK,CAACU,MAAN,CAAaC;EAD1B,CARU;EAWhBC,GAAG,EAAE;IACHH,eAAe,EAAET,KAAK,CAACU,MAAN,CAAaG;EAD3B,CAXW;EAchBC,KAAK,EAAE;IACLL,eAAe,EAAET,KAAK,CAACU,MAAN,CAAaK;EADzB,CAdS;EAiBhBC,MAAM,EAAE;IACNP,eAAe,EAAET,KAAK,CAACU,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,GAAG,IAAAC,mCAAA,GAAxB;EACA,MAAM;IAACvB;EAAD,IAAUsB,eAAhB;EAEA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AACI,SAAS,EAAE,CAAC;QAACG,OAAO,EAAE;MAAV,CAAD,EAAsB;QAACC,UAAU,EAAET;MAAb,CAAtB;IAAZ,CAJK;EADT,EAtBF,eA8BE,6BAAC,qBAAD,CAAU,IAAV;IACE,KAAK,EAAE,CACL3C,UAAU,CAAClB,GADN,EAELqC,KAAK,GAAG;MAAClC,eAAe,EAAEkC;IAAlB,CAAH,GAA8BnB,UAAU,CAACR,MAFzC,EAGLoD,QAHK,EAIL;MAACI,SAAS,EAAE,CAAC;QAACG,OAAO,EAAE;MAAV,CAAD,EAAsB;QAACC,UAAU,EAAET;MAAb,CAAtB;IAAZ,CAJK;EADT,EA9BF,eAsCE,6BAAC,qBAAD,CAAU,IAAV;IACE,KAAK,EAAE,CACL3C,UAAU,CAAClB,GADN,EAELqC,KAAK,GAAG;MAAClC,eAAe,EAAEkC;IAAlB,CAAH,GAA8BnB,UAAU,CAAChB,IAFzC,EAGL4D,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;;eAuKe/C,M"}
@@ -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":";;;;;;;;AAwDA,qEA4KC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atom/select/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AA2DA,qEAqLC"}
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  exports.__esModule = true;
4
- exports.default = exports.SelectOptionPropTypes = void 0;
4
+ exports.default = exports.SelectOptionPropTypes = exports.SelectOptionGroupPropTypes = void 0;
5
5
 
6
6
  var _react = _interopRequireWildcard(require("react"));
7
7
 
@@ -9,16 +9,22 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
9
9
 
10
10
  var _classnames = _interopRequireDefault(require("classnames"));
11
11
 
12
+ var _concat = _interopRequireDefault(require("lodash/fp/concat"));
13
+
12
14
  var _filter = _interopRequireDefault(require("lodash/fp/filter"));
13
15
 
14
16
  var _find = _interopRequireDefault(require("lodash/fp/find"));
15
17
 
18
+ var _flatMapDeep = _interopRequireDefault(require("lodash/fp/flatMapDeep"));
19
+
16
20
  var _get = _interopRequireDefault(require("lodash/fp/get"));
17
21
 
18
22
  var _getOr = _interopRequireDefault(require("lodash/fp/getOr"));
19
23
 
20
24
  var _includes = _interopRequireDefault(require("lodash/fp/includes"));
21
25
 
26
+ var _isEmpty = _interopRequireDefault(require("lodash/fp/isEmpty"));
27
+
22
28
  var _keys = _interopRequireDefault(require("lodash/fp/keys"));
23
29
 
24
30
  var _map = _interopRequireDefault(require("lodash/fp/map"));
@@ -82,6 +88,7 @@ const Select = (props, legacyContext) => {
82
88
  const {
83
89
  name,
84
90
  options = [],
91
+ optgroups = [],
85
92
  className,
86
93
  borderClassName,
87
94
  onChange,
@@ -100,12 +107,20 @@ const Select = (props, legacyContext) => {
100
107
  const [isArrowUp, setIsArrowUp] = (0, _react.useState)(false);
101
108
  const handleSelectOnFocus = (0, _react.useCallback)(() => setIsArrowUp(true), []);
102
109
  const handleSelectOnBlur = (0, _react.useCallback)(() => setIsArrowUp(false), []);
103
- const optionList = options && options.map((option, index) => {
110
+
111
+ const selectOption = (option, index) => {
104
112
  return /*#__PURE__*/_react.default.createElement("option", {
105
113
  key: index,
106
114
  value: option.value,
107
115
  className: _style.default.selectOption
108
116
  }, option.name);
117
+ };
118
+
119
+ const optionList = !(0, _isEmpty.default)(options) ? options.map((option, index) => selectOption(option, index)) : optgroups.map((optgroup, index) => {
120
+ return /*#__PURE__*/_react.default.createElement("optgroup", {
121
+ key: index,
122
+ label: optgroup.label
123
+ }, optgroup.options && optgroup.options.map((option, i) => selectOption(option, i)));
109
124
  });
110
125
  const titleView = title ? /*#__PURE__*/_react.default.createElement("span", {
111
126
  className: _style.default.title
@@ -114,12 +129,12 @@ const Select = (props, legacyContext) => {
114
129
  selected: true
115
130
  }, options)) : (0, _get.default)('value', (0, _find.default)({
116
131
  selected: true
117
- }, options)), [multiple, options]);
132
+ }, (0, _concat.default)(options, (0, _flatMapDeep.default)('options', optgroups)))), [multiple, options, optgroups]);
118
133
  const selectedLabel = (0, _react.useMemo)(() => multiple ? (0, _map.default)((0, _get.default)('name'), (0, _filter.default)({
119
134
  selected: true
120
- }, options)) : (0, _get.default)('name', (0, _find.default)({
135
+ }, options)) : (0, _get.default)('value', (0, _find.default)({
121
136
  selected: true
122
- }, options)), [multiple, options]);
137
+ }, (0, _concat.default)(options, (0, _flatMapDeep.default)('options', optgroups)))), [multiple, options, optgroups]);
123
138
  const isSelectedInValidOption = (0, _react.useMemo)(() => theme === 'player' && (0, _getOr.default)(false, 'name', (0, _find.default)({
124
139
  validOption: false,
125
140
  selected: true
@@ -188,6 +203,11 @@ const SelectOptionPropTypes = {
188
203
  validOption: _propTypes.default.bool
189
204
  };
190
205
  exports.SelectOptionPropTypes = SelectOptionPropTypes;
206
+ const SelectOptionGroupPropTypes = {
207
+ label: _propTypes.default.string.isRequired,
208
+ options: _propTypes.default.arrayOf(_propTypes.default.shape(SelectOptionPropTypes))
209
+ };
210
+ exports.SelectOptionGroupPropTypes = SelectOptionGroupPropTypes;
191
211
  Select.contextTypes = {
192
212
  skin: _provider.default.childContextTypes.skin
193
213
  };
@@ -203,6 +223,7 @@ Select.propTypes = process.env.NODE_ENV !== "production" ? {
203
223
  onChange: _propTypes.default.func,
204
224
  theme: _propTypes.default.oneOf((0, _keys.default)(themeStyle)),
205
225
  options: _propTypes.default.arrayOf(_propTypes.default.shape(SelectOptionPropTypes)),
226
+ optgroups: _propTypes.default.arrayOf(_propTypes.default.shape(SelectOptionGroupPropTypes)),
206
227
  modified: _propTypes.default.bool,
207
228
  error: _propTypes.default.bool,
208
229
  'aria-label': _propTypes.default.string
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["themeStyle","filter","style","invalid","header","mooc","question","sort","thematiques","player","template","coorpmanager","ArrowView","shouldRender","isArrowUp","ariaLabel","arrowClass","arrowColor","props","useMemo","color","className","Select","legacyContext","name","options","borderClassName","onChange","multiple","disabled","required","description","theme","modified","error","title","propTitle","skin","GetSkinFromContext","setIsArrowUp","useState","handleSelectOnFocus","useCallback","handleSelectOnBlur","optionList","map","option","index","value","selectOption","titleView","selected","get","find","selectedLabel","isSelectedInValidOption","getOr","validOption","handleChange","e","target","selectedOptions","black","isThemeOneOfQuestionTemplateOrPlayer","includes","shouldUseSkinFontColor","undefined","behaviorClassName","getClassState","default","composedClassName","classnames","unselected","labelSize","size","isLongLabel","selectWrapper","selectSpan","noLabelCommon","longLabel","selectedArrow","arrow","selectBox","SelectOptionPropTypes","PropTypes","string","isRequired","oneOfType","number","bool","contextTypes","Provider","childContextTypes","propTypes","func","oneOf","keys","arrayOf","shape"],"sources":["../../../src/atom/select/index.js"],"sourcesContent":["import React, {useCallback, useMemo, useState} 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 {\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 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 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 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\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;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAIA;;AACA;;AACA;;;;;;;;;;AAEA,MAAMA,UAAU,GAAG;EACjBC,MAAM,EAAEC,cAAA,CAAMD,MADG;EAEjBE,OAAO,EAAED,cAAA,CAAMC,OAFE;EAGjBC,MAAM,EAAEF,cAAA,CAAME,MAHG;EAIjBC,IAAI,EAAEH,cAAA,CAAMG,IAJK;EAKjBC,QAAQ,EAAEJ,cAAA,CAAMI,QALC;EAMjBC,IAAI,EAAEL,cAAA,CAAMK,IANK;EAOjBC,WAAW,EAAEN,cAAA,CAAMM,WAPF;EAQjBC,MAAM,EAAEP,cAAA,CAAMO,MARG;EASjBC,QAAQ,EAAER,cAAA,CAAMQ,QATC;EAUjBC,YAAY,EAAE;AAVG,CAAnB;;AAaA,MAAMC,SAAS,GAAG,CAAC;EAACC,YAAD;EAAeC,SAAf;EAA0BC,SAA1B;EAAqCC,UAArC;EAAiDC;AAAjD,CAAD,KAAkE;EAClF,MAAMC,KAAK,GAAG,IAAAC,cAAA,EACZ,mBACMJ,SAAS,GACX;IACE,cAAcA;EADhB,CAFJ,EAKME,UAAU,GACZ;IACEG,KAAK,EAAEH;EADT,CANJ;IASEI,SAAS,EAAEL;EATb,EADY,EAYZ,CAACD,SAAD,EAAYC,UAAZ,EAAwBC,UAAxB,CAZY,CAAd;;EAcA,IAAIJ,YAAJ,EAAkB;IAChB,OAAOC,SAAS,gBACd,6BAAC,4CA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tB;AAIAf,MAAM,CAACuE,SAAP,2CAAmB;EACjB1D,KAAK,EAAEiD,kBAAA,CAAUC,MADA;EAEjB7D,IAAI,EAAE4D,kBAAA,CAAUC,MAFC;EAGjBhE,SAAS,EAAE+D,kBAAA,CAAUC,MAHJ;EAIjB3D,eAAe,EAAE0D,kBAAA,CAAUC,MAJV;EAKjBxD,QAAQ,EAAEuD,kBAAA,CAAUK,IALH;EAMjB7D,QAAQ,EAAEwD,kBAAA,CAAUK,IANH;EAOjB1D,WAAW,EAAEqD,kBAAA,CAAUC,MAPN;EAQjBvD,QAAQ,EAAEsD,kBAAA,CAAUK,IARH;EASjB9D,QAAQ,EAAEyD,kBAAA,CAAUU,IATH;EAUjB9D,KAAK,EAAEoD,kBAAA,CAAUW,KAAV,CAAgB,IAAAC,aAAA,EAAKhG,UAAL,CAAhB,CAVU;EAWjByB,OAAO,EAAE2D,kBAAA,CAAUa,OAAV,CAAkBb,kBAAA,CAAUc,KAAV,CAAgBf,qBAAhB,CAAlB,CAXQ;EAYjBlD,QAAQ,EAAEmD,kBAAA,CAAUK,IAZH;EAajBvD,KAAK,EAAEkD,kBAAA,CAAUK,IAbA;EAcjB,cAAcL,kBAAA,CAAUC;AAdP,CAAnB;eAiBe/D,M"}
1
+ {"version":3,"file":"index.js","names":["themeStyle","filter","style","invalid","header","mooc","question","sort","thematiques","player","template","coorpmanager","ArrowView","shouldRender","isArrowUp","ariaLabel","arrowClass","arrowColor","props","useMemo","color","className","Select","legacyContext","name","options","optgroups","borderClassName","onChange","multiple","disabled","required","description","theme","modified","error","title","propTitle","skin","GetSkinFromContext","setIsArrowUp","useState","handleSelectOnFocus","useCallback","handleSelectOnBlur","selectOption","option","index","value","optionList","isEmpty","map","optgroup","label","i","titleView","selected","get","find","concat","flatMapDeep","selectedLabel","isSelectedInValidOption","getOr","validOption","handleChange","e","target","selectedOptions","black","isThemeOneOfQuestionTemplateOrPlayer","includes","shouldUseSkinFontColor","undefined","behaviorClassName","getClassState","default","composedClassName","classnames","unselected","labelSize","size","isLongLabel","selectWrapper","selectSpan","noLabelCommon","longLabel","selectedArrow","arrow","selectBox","SelectOptionPropTypes","PropTypes","string","isRequired","oneOfType","number","bool","SelectOptionGroupPropTypes","arrayOf","shape","contextTypes","Provider","childContextTypes","propTypes","func","oneOf","keys"],"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': PropTypes.string\n};\n\nexport default Select;\n"],"mappings":";;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAIA;;AACA;;AACA;;;;;;;;;;AAEA,MAAMA,UAAU,GAAG;EACjBC,MAAM,EAAEC,cAAA,CAAMD,MADG;EAEjBE,OAAO,EAAED,cAAA,CAAMC,OAFE;EAGjBC,MAAM,EAAEF,cAAA,CAAME,MAHG;EAIjBC,IAAI,EAAEH,cAAA,CAAMG,IAJK;EAKjBC,QAAQ,EAAEJ,cAAA,CAAMI,QALC;EAMjBC,IAAI,EAAEL,cAAA,CAAMK,IANK;EAOjBC,WAAW,EAAEN,cAAA,CAAMM,WAPF;EAQjBC,MAAM,EAAEP,cAAA,CAAMO,MARG;EASjBC,QAAQ,EAAER,cAAA,CAAMQ,QATC;EAUjBC,YAAY,EAAE;AAVG,CA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ACpB9D,IAAI,EAAE+D,iBAAA,CAASC,iBAAT,CAA2BhE;AADb,CAAtB;AAIAhB,MAAM,CAACiF,SAAP,2CAAmB;EACjBnE,KAAK,EAAEuD,kBAAA,CAAUC,MADA;EAEjBpE,IAAI,EAAEmE,kBAAA,CAAUC,MAFC;EAGjBvE,SAAS,EAAEsE,kBAAA,CAAUC,MAHJ;EAIjBjE,eAAe,EAAEgE,kBAAA,CAAUC,MAJV;EAKjB9D,QAAQ,EAAE6D,kBAAA,CAAUK,IALH;EAMjBnE,QAAQ,EAAE8D,kBAAA,CAAUK,IANH;EAOjBhE,WAAW,EAAE2D,kBAAA,CAAUC,MAPN;EAQjB7D,QAAQ,EAAE4D,kBAAA,CAAUK,IARH;EASjBpE,QAAQ,EAAE+D,kBAAA,CAAUa,IATH;EAUjBvE,KAAK,EAAE0D,kBAAA,CAAUc,KAAV,CAAgB,IAAAC,aAAA,EAAK1G,UAAL,CAAhB,CAVU;EAWjByB,OAAO,EAAEkE,kBAAA,CAAUO,OAAV,CAAkBP,kBAAA,CAAUQ,KAAV,CAAgBT,qBAAhB,CAAlB,CAXQ;EAYjBhE,SAAS,EAAEiE,kBAAA,CAAUO,OAAV,CAAkBP,kBAAA,CAAUQ,KAAV,CAAgBF,0BAAhB,CAAlB,CAZM;EAajB/D,QAAQ,EAAEyD,kBAAA,CAAUK,IAbH;EAcjB7D,KAAK,EAAEwD,kBAAA,CAAUK,IAdA;EAejB,cAAcL,kBAAA,CAAUC;AAfP,CAAnB;eAkBetE,M"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/molecule/answer/index.js"],"names":[],"mappings":";AAuEA,iDASC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/molecule/answer/index.js"],"names":[],"mappings":";AAwEA,iDASC"}
@@ -25,6 +25,8 @@ var _template = _interopRequireDefault(require("../questions/template"));
25
25
 
26
26
  var _audio = _interopRequireDefault(require("../audio"));
27
27
 
28
+ var _provider = require("../../atom/provider");
29
+
28
30
  var _style = _interopRequireDefault(require("./style.css"));
29
31
 
30
32
  var _propTypes = _interopRequireWildcard(require("./prop-types"));
@@ -90,30 +92,42 @@ const Switch = ({
90
92
  const {
91
93
  type
92
94
  } = model;
95
+ const translate = (0, _provider.GetTranslateFromContext)();
93
96
 
94
97
  switch (type) {
95
98
  case 'qcmDrag':
96
99
  return /*#__PURE__*/_react.default.createElement(_qcmDrag.default, _extends({}, model, {
97
- help: help
100
+ help: help,
101
+ groupAriaLabel: translate('answer_the_question')
98
102
  }));
99
103
 
100
104
  case 'qcm':
101
- return /*#__PURE__*/_react.default.createElement(_qcm.default, model);
105
+ return /*#__PURE__*/_react.default.createElement(_qcm.default, _extends({}, model, {
106
+ groupAriaLabel: translate('answer_the_question')
107
+ }));
102
108
 
103
109
  case 'qcmGraphic':
104
- return /*#__PURE__*/_react.default.createElement(_qcmGraphic.default, model);
110
+ return /*#__PURE__*/_react.default.createElement(_qcmGraphic.default, _extends({}, model, {
111
+ groupAriaLabel: translate('answer_the_question')
112
+ }));
105
113
 
106
114
  case 'freeText':
107
115
  return /*#__PURE__*/_react.default.createElement(_freeText.default, model);
108
116
 
109
117
  case 'dropDown':
110
- return /*#__PURE__*/_react.default.createElement(_dropDown.default, model);
118
+ return /*#__PURE__*/_react.default.createElement(_dropDown.default, _extends({}, model, {
119
+ groupAriaLabel: translate('answer_the_question')
120
+ }));
111
121
 
112
122
  case 'slider':
113
- return /*#__PURE__*/_react.default.createElement(_questionRange.default, model);
123
+ return /*#__PURE__*/_react.default.createElement(_questionRange.default, _extends({}, model, {
124
+ groupAriaLabel: translate('answer_the_question')
125
+ }));
114
126
 
115
127
  case 'template':
116
- return /*#__PURE__*/_react.default.createElement(_template.default, model);
128
+ return /*#__PURE__*/_react.default.createElement(_template.default, _extends({}, model, {
129
+ groupAriaLabel: translate('answer_the_question')
130
+ }));
117
131
  }
118
132
  };
119
133
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["MediaView","media","videoId","type","childProps","TYPE_IMAGE","style","backgroundImage","url","TYPE_VIDEO","video","TYPE_AUDIO","audio","propTypes","MediaViewPropTypes","Switch","model","help","Answer","props","wrapper"],"sources":["../../../src/molecule/answer/index.js"],"sourcesContent":["import React from 'react';\nimport {omit} from 'lodash/fp';\nimport VideoPlayer from '../video-player';\nimport DropDown from '../questions/drop-down';\nimport FreeText from '../questions/free-text';\nimport QcmDrag from '../questions/qcm-drag';\nimport Qcm from '../questions/qcm';\nimport QcmGraphic from '../questions/qcm-graphic';\nimport QuestionRange from '../questions/question-range';\nimport Template from '../questions/template';\nimport Audio from '../audio';\nimport style from './style.css';\nimport propTypes, {MediaViewPropTypes, TYPE_AUDIO, TYPE_IMAGE, TYPE_VIDEO} from './prop-types';\n\nconst MediaView = ({media}) => {\n const {videoId, type, ...childProps} = media;\n switch (type) {\n case TYPE_IMAGE:\n return (\n <div\n className={style.media}\n style={{\n backgroundImage: `url(${media.url})`\n }}\n />\n );\n case TYPE_VIDEO:\n return (\n <div className={style.video}>\n <VideoPlayer {...omit('id', childProps)} id={videoId} height=\"100%\" width=\"100%\" />\n </div>\n );\n case TYPE_AUDIO:\n return (\n <div className={style.audio}>\n <Audio {...omit('id', childProps)} height=\"100%\" width=\"100%\" />\n </div>\n );\n default:\n return null;\n }\n};\n\nMediaView.propTypes = MediaViewPropTypes;\n\nconst Switch = ({model, help}) => {\n const {type} = model;\n\n switch (type) {\n case 'qcmDrag':\n return <QcmDrag {...model} help={help} />;\n case 'qcm':\n return <Qcm {...model} />;\n case 'qcmGraphic':\n return <QcmGraphic {...model} />;\n case 'freeText':\n return <FreeText {...model} />;\n case 'dropDown':\n return <DropDown {...model} />;\n case 'slider':\n return <QuestionRange {...model} />;\n case 'template':\n return <Template {...model} />;\n }\n};\n\nSwitch.propTypes = {\n model: propTypes.model,\n help: propTypes.help\n};\n\nconst Answer = props => {\n const {model, media, help} = props;\n\n return (\n <div data-name=\"answer\" className={style.wrapper}>\n {media ? <MediaView media={media} /> : null}\n <Switch model={model} help={help} />\n </div>\n );\n};\n\nAnswer.propTypes = propTypes;\n\nexport default Answer;\n"],"mappings":";;;;;;;AAAA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;AAEA,MAAMA,SAAS,GAAG,CAAC;EAACC;AAAD,CAAD,KAAa;EAC7B,MAAM;IAACC,OAAD;IAAUC;EAAV,IAAiCF,KAAvC;EAAA,MAAyBG,UAAzB,iCAAuCH,KAAvC;;EACA,QAAQE,IAAR;IACE,KAAKE,qBAAL;MACE,oBACE;QACE,SAAS,EAAEC,cAAA,CAAML,KADnB;QAEE,KAAK,EAAE;UACLM,eAAe,EAAG,OAAMN,KAAK,CAACO,GAAI;QAD7B;MAFT,EADF;;IAQF,KAAKC,qBAAL;MACE,oBACE;QAAK,SAAS,EAAEH,cAAA,CAAMI;MAAtB,gBACE,6BAAC,oBAAD,eAAiB,oBAAK,IAAL,EAAWN,UAAX,CAAjB;QAAyC,EAAE,EAAEF,OAA7C;QAAsD,MAAM,EAAC,MAA7D;QAAoE,KAAK,EAAC;MAA1E,GADF,CADF;;IAKF,KAAKS,qBAAL;MACE,oBACE;QAAK,SAAS,EAAEL,cAAA,CAAMM;MAAtB,gBACE,6BAAC,cAAD,eAAW,oBAAK,IAAL,EAAWR,UAAX,CAAX;QAAmC,MAAM,EAAC,MAA1C;QAAiD,KAAK,EAAC;MAAvD,GADF,CADF;;IAKF;MACE,OAAO,IAAP;EAvBJ;AAyBD,CA3BD;;AA6BAJ,SAAS,CAACa,SAAV,2CAAsBC,6BAAtB;;AAEA,MAAMC,MAAM,GAAG,CAAC;EAACC,KAAD;EAAQC;AAAR,CAAD,KAAmB;EAChC,MAAM;IAACd;EAAD,IAASa,KAAf;;EAEA,QAAQb,IAAR;IACE,KAAK,SAAL;MACE,oBAAO,6BAAC,gBAAD,eAAaa,KAAb;QAAoB,IAAI,EAAEC;MAA1B,GAAP;;IACF,KAAK,KAAL;MACE,oBAAO,6BAAC,YAAD,EAASD,KAAT,CAAP;;IACF,KAAK,YAAL;MACE,oBAAO,6BAAC,mBAAD,EAAgBA,KAAhB,CAAP;;IACF,KAAK,UAAL;MACE,oBAAO,6BAAC,iBAAD,EAAcA,KAAd,CAAP;;IACF,KAAK,UAAL;MACE,oBAAO,6BAAC,iBAAD,EAAcA,KAAd,CAAP;;IACF,KAAK,QAAL;MACE,oBAAO,6BAAC,sBAAD,EAAmBA,KAAnB,CAAP;;IACF,KAAK,UAAL;MACE,oBAAO,6BAAC,iBAAD,EAAcA,KAAd,CAAP;EAdJ;AAgBD,CAnBD;;AAqBAD,MAAM,CAACF,SAAP,2CAAmB;EACjBG,KAAK,EAAEH,kBAAA,CAAUG,KADA;EAEjBC,IAAI,EAAEJ,kBAAA,CAAUI;AAFC,CAAnB;;AAKA,MAAMC,MAAM,GAAGC,KAAK,IAAI;EACtB,MAAM;IAACH,KAAD;IAAQf,KAAR;IAAegB;EAAf,IAAuBE,KAA7B;EAEA,oBACE;IAAK,aAAU,QAAf;IAAwB,SAAS,EAAEb,cAAA,CAAMc;EAAzC,GACGnB,KAAK,gBAAG,6BAAC,SAAD;IAAW,KAAK,EAAEA;EAAlB,EAAH,GAAiC,IADzC,eAEE,6BAAC,MAAD;IAAQ,KAAK,EAAEe,KAAf;IAAsB,IAAI,EAAEC;EAA5B,EAFF,CADF;AAMD,CATD;;AAWAC,MAAM,CAACL,SAAP,2CAAmBA,kBAAnB;eAEeK,M"}
1
+ {"version":3,"file":"index.js","names":["MediaView","media","videoId","type","childProps","TYPE_IMAGE","style","backgroundImage","url","TYPE_VIDEO","video","TYPE_AUDIO","audio","propTypes","MediaViewPropTypes","Switch","model","help","translate","GetTranslateFromContext","Answer","props","wrapper"],"sources":["../../../src/molecule/answer/index.js"],"sourcesContent":["import React from 'react';\nimport {omit} from 'lodash/fp';\nimport VideoPlayer from '../video-player';\nimport DropDown from '../questions/drop-down';\nimport FreeText from '../questions/free-text';\nimport QcmDrag from '../questions/qcm-drag';\nimport Qcm from '../questions/qcm';\nimport QcmGraphic from '../questions/qcm-graphic';\nimport QuestionRange from '../questions/question-range';\nimport Template from '../questions/template';\nimport Audio from '../audio';\nimport {GetTranslateFromContext} from '../../atom/provider';\nimport style from './style.css';\nimport propTypes, {MediaViewPropTypes, TYPE_AUDIO, TYPE_IMAGE, TYPE_VIDEO} from './prop-types';\n\nconst MediaView = ({media}) => {\n const {videoId, type, ...childProps} = media;\n switch (type) {\n case TYPE_IMAGE:\n return (\n <div\n className={style.media}\n style={{\n backgroundImage: `url(${media.url})`\n }}\n />\n );\n case TYPE_VIDEO:\n return (\n <div className={style.video}>\n <VideoPlayer {...omit('id', childProps)} id={videoId} height=\"100%\" width=\"100%\" />\n </div>\n );\n case TYPE_AUDIO:\n return (\n <div className={style.audio}>\n <Audio {...omit('id', childProps)} height=\"100%\" width=\"100%\" />\n </div>\n );\n default:\n return null;\n }\n};\n\nMediaView.propTypes = MediaViewPropTypes;\n\nconst Switch = ({model, help}) => {\n const {type} = model;\n const translate = GetTranslateFromContext();\n switch (type) {\n case 'qcmDrag':\n return <QcmDrag {...model} help={help} groupAriaLabel={translate('answer_the_question')} />;\n case 'qcm':\n return <Qcm {...model} groupAriaLabel={translate('answer_the_question')} />;\n case 'qcmGraphic':\n return <QcmGraphic {...model} groupAriaLabel={translate('answer_the_question')} />;\n case 'freeText':\n return <FreeText {...model} />;\n case 'dropDown':\n return <DropDown {...model} groupAriaLabel={translate('answer_the_question')} />;\n case 'slider':\n return <QuestionRange {...model} groupAriaLabel={translate('answer_the_question')} />;\n case 'template':\n return <Template {...model} groupAriaLabel={translate('answer_the_question')} />;\n }\n};\n\nSwitch.propTypes = {\n model: propTypes.model,\n help: propTypes.help\n};\n\nconst Answer = props => {\n const {model, media, help} = props;\n\n return (\n <div data-name=\"answer\" className={style.wrapper}>\n {media ? <MediaView media={media} /> : null}\n <Switch model={model} help={help} />\n </div>\n );\n};\n\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 +96,15 @@ declare namespace BrandFormGroup {
96
96
  selected: PropTypes.Requireable<boolean>;
97
97
  validOption: PropTypes.Requireable<boolean>;
98
98
  }> | null | undefined)[]>;
99
+ optgroups: PropTypes.Requireable<(PropTypes.InferProps<{
100
+ label: PropTypes.Validator<string>;
101
+ options: PropTypes.Requireable<(PropTypes.InferProps<{
102
+ name: PropTypes.Validator<string>;
103
+ value: PropTypes.Requireable<NonNullable<string | number | null | undefined>>;
104
+ selected: PropTypes.Requireable<boolean>;
105
+ validOption: PropTypes.Requireable<boolean>;
106
+ }> | null | undefined)[]>;
107
+ }> | null | undefined)[]>;
99
108
  modified: PropTypes.Requireable<boolean>;
100
109
  error: PropTypes.Requireable<boolean>;
101
110
  'aria-label': PropTypes.Requireable<string>;
@@ -200,6 +209,15 @@ declare namespace BrandFormGroup {
200
209
  selected: PropTypes.Requireable<boolean>;
201
210
  validOption: PropTypes.Requireable<boolean>;
202
211
  }> | null | undefined)[]>;
212
+ optgroups: PropTypes.Requireable<(PropTypes.InferProps<{
213
+ label: PropTypes.Validator<string>;
214
+ options: PropTypes.Requireable<(PropTypes.InferProps<{
215
+ name: PropTypes.Validator<string>;
216
+ value: PropTypes.Requireable<NonNullable<string | number | null | undefined>>;
217
+ selected: PropTypes.Requireable<boolean>;
218
+ validOption: PropTypes.Requireable<boolean>;
219
+ }> | null | undefined)[]>;
220
+ }> | null | undefined)[]>;
203
221
  modified: PropTypes.Requireable<boolean>;
204
222
  error: PropTypes.Requireable<boolean>;
205
223
  'aria-label': PropTypes.Requireable<string>;
@@ -7,6 +7,7 @@ declare namespace FiltersWapper {
7
7
  type: PropTypes.Validator<string>;
8
8
  fieldName: PropTypes.Validator<string>;
9
9
  }> | null | undefined)[]>;
10
+ const filterGroupAriaLabel: PropTypes.Requireable<string>;
10
11
  }
11
12
  }
12
13
  import PropTypes from "prop-types";
@@ -1 +1 @@
1
- {"version":3,"file":"filters-wrapper.d.ts","sourceRoot":"","sources":["../../../src/molecule/filters/filters-wrapper.js"],"names":[],"mappings":";AAUA,sEAuDC"}
1
+ {"version":3,"file":"filters-wrapper.d.ts","sourceRoot":"","sources":["../../../src/molecule/filters/filters-wrapper.js"],"names":[],"mappings":";AAUA,sEA6DC"}
@@ -30,7 +30,8 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
30
30
  const FiltersWapper = (props, context) => {
31
31
  const {
32
32
  filters,
33
- className
33
+ className,
34
+ filterGroupAriaLabel
34
35
  } = props;
35
36
 
36
37
  const buildFilter = (filter, idx) => {
@@ -94,9 +95,11 @@ const FiltersWapper = (props, context) => {
94
95
  })(buildFilter, filters);
95
96
 
96
97
  const emptyFilters = (0, _isEmpty2.default)(filters);
97
- return /*#__PURE__*/_react.default.createElement("div", {
98
- className: (0, _classnames.default)(className, emptyFilters ? _filtersWapper.default.wrapperNone : _filtersWapper.default.wrapper)
99
- }, filtersList);
98
+ return /*#__PURE__*/_react.default.createElement("form", null, /*#__PURE__*/_react.default.createElement("div", {
99
+ className: (0, _classnames.default)(className, emptyFilters ? _filtersWapper.default.wrapperNone : _filtersWapper.default.wrapper),
100
+ role: "group",
101
+ "aria-label": filterGroupAriaLabel
102
+ }, filtersList));
100
103
  };
101
104
 
102
105
  FiltersWapper.propTypes = process.env.NODE_ENV !== "production" ? {
@@ -104,7 +107,8 @@ FiltersWapper.propTypes = process.env.NODE_ENV !== "production" ? {
104
107
  filters: _propTypes.default.arrayOf(_propTypes.default.shape({
105
108
  type: _propTypes.default.oneOf(['select', 'range', 'radio', 'switch']).isRequired,
106
109
  fieldName: _propTypes.default.string.isRequired
107
- }))
110
+ })),
111
+ filterGroupAriaLabel: _propTypes.default.string
108
112
  } : {};
109
113
  var _default = FiltersWapper;
110
114
  exports.default = _default;