@coorpacademy/components 10.22.4 → 10.22.5
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/es/atom/html/index.native.js +9 -16
- package/es/atom/html/index.native.js.map +1 -1
- package/es/atom/input-switch/index.js +43 -6
- package/es/atom/input-switch/index.js.map +1 -1
- package/es/atom/input-switch/style.css +56 -6
- package/es/atom/select-modal/index.native.js +6 -6
- package/es/atom/select-modal/index.native.js.map +1 -1
- package/es/atom/text/index.native.js +3 -1
- package/es/atom/text/index.native.js.map +1 -1
- package/es/hoc/modal/select/index.native.js +4 -3
- package/es/hoc/modal/select/index.native.js.map +1 -1
- package/es/molecule/answer/index.js +39 -32
- package/es/molecule/answer/index.js.map +1 -1
- package/es/molecule/cm-popin/index.js +101 -14
- package/es/molecule/cm-popin/index.js.map +1 -1
- package/es/molecule/cm-popin/style.css +153 -9
- package/es/molecule/questions/free-text/index.native.js +8 -8
- package/es/molecule/questions/free-text/index.native.js.map +1 -1
- package/es/molecule/questions/mobile/template/index.native.js +222 -0
- package/es/molecule/questions/mobile/template/index.native.js.map +1 -0
- package/es/template/app-review/template-context.js +1 -0
- package/es/template/app-review/template-context.js.map +1 -1
- package/es/template/common/dashboard/index.js +6 -3
- package/es/template/common/dashboard/index.js.map +1 -1
- package/es/types/app-review.d.js +2 -0
- package/es/types/app-review.d.js.map +1 -0
- package/es/types/translations.js +2 -0
- package/es/types/translations.js.map +1 -0
- package/es/util/parse-template-string.js +4 -2
- package/es/util/parse-template-string.js.map +1 -1
- package/es/variables/colors.css +1 -0
- package/lib/atom/html/index.native.js +8 -15
- package/lib/atom/html/index.native.js.map +1 -1
- package/lib/atom/input-switch/index.js +43 -6
- package/lib/atom/input-switch/index.js.map +1 -1
- package/lib/atom/input-switch/style.css +56 -6
- package/lib/atom/select-modal/index.native.js +5 -5
- package/lib/atom/select-modal/index.native.js.map +1 -1
- package/lib/atom/text/index.native.js +3 -1
- package/lib/atom/text/index.native.js.map +1 -1
- package/lib/hoc/modal/select/index.native.js +7 -5
- package/lib/hoc/modal/select/index.native.js.map +1 -1
- package/lib/molecule/answer/index.js +39 -32
- package/lib/molecule/answer/index.js.map +1 -1
- package/lib/molecule/cm-popin/index.js +102 -13
- package/lib/molecule/cm-popin/index.js.map +1 -1
- package/lib/molecule/cm-popin/style.css +153 -9
- package/lib/molecule/questions/free-text/index.native.js +7 -7
- package/lib/molecule/questions/free-text/index.native.js.map +1 -1
- package/lib/molecule/questions/mobile/template/index.native.js +243 -0
- package/lib/molecule/questions/mobile/template/index.native.js.map +1 -0
- package/lib/template/app-review/template-context.js +1 -0
- package/lib/template/app-review/template-context.js.map +1 -1
- package/lib/template/common/dashboard/index.js +7 -3
- package/lib/template/common/dashboard/index.js.map +1 -1
- package/lib/types/app-review.d.js +2 -0
- package/lib/types/app-review.d.js.map +1 -0
- package/lib/types/translations.js +2 -0
- package/lib/types/translations.js.map +1 -0
- package/lib/util/parse-template-string.js +4 -2
- package/lib/util/parse-template-string.js.map +1 -1
- package/lib/variables/colors.css +1 -0
- package/package.json +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign || 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, { useMemo, useState } from 'react';
|
|
4
4
|
import { View } from 'react-native';
|
|
5
5
|
import HtmlBase from 'react-native-render-html';
|
|
6
6
|
import { HTML_ANCHOR_TEXT_COLOR } from '../../variables/theme.native';
|
|
@@ -8,6 +8,7 @@ import { useTemplateContext } from '../../template/app-review/template-context';
|
|
|
8
8
|
import Text, { DEFAULT_STYLE as DEFAULT_TEXT_STYLE } from '../text/index.native';
|
|
9
9
|
|
|
10
10
|
const Html = props => {
|
|
11
|
+
const [disableBaseFontStyleColor, setDisableBaseFontStyleColor] = useState(false);
|
|
11
12
|
const templateContext = useTemplateContext();
|
|
12
13
|
const {
|
|
13
14
|
theme,
|
|
@@ -28,13 +29,7 @@ const Html = props => {
|
|
|
28
29
|
const handleLinkPress = useMemo(() => url => {
|
|
29
30
|
vibration?.vibrate();
|
|
30
31
|
onLinkPress && onLinkPress(url);
|
|
31
|
-
}, [onLinkPress, vibration]);
|
|
32
|
-
const state = {
|
|
33
|
-
disableBaseFontStyleColor: false
|
|
34
|
-
};
|
|
35
|
-
const {
|
|
36
|
-
disableBaseFontStyleColor
|
|
37
|
-
} = state; // Don't use StyleSheet there, it's not a react style
|
|
32
|
+
}, [onLinkPress, vibration]); // Don't use StyleSheet there, it's not a react style
|
|
38
33
|
|
|
39
34
|
const styles = {
|
|
40
35
|
p: {
|
|
@@ -96,11 +91,9 @@ const Html = props => {
|
|
|
96
91
|
|
|
97
92
|
const renderers = {
|
|
98
93
|
// eslint-disable-next-line react/display-name
|
|
99
|
-
font: (htmlAttribs,
|
|
94
|
+
font: (htmlAttribs, _children) => {
|
|
100
95
|
if (htmlAttribs.color) {
|
|
101
|
-
|
|
102
|
-
disableBaseFontStyleColor: true
|
|
103
|
-
});
|
|
96
|
+
setDisableBaseFontStyleColor(true);
|
|
104
97
|
}
|
|
105
98
|
|
|
106
99
|
return /*#__PURE__*/React.createElement(Text, {
|
|
@@ -108,18 +101,18 @@ const Html = props => {
|
|
|
108
101
|
style: _extends(_extends({}, baseFontStyle), {}, {
|
|
109
102
|
color: htmlAttribs.color
|
|
110
103
|
})
|
|
111
|
-
},
|
|
104
|
+
}, _children);
|
|
112
105
|
},
|
|
113
|
-
span: (_,
|
|
106
|
+
span: function Span(_, _children, convertedCSSStyles, {
|
|
114
107
|
allowFontScaling,
|
|
115
108
|
key
|
|
116
|
-
})
|
|
109
|
+
}) {
|
|
117
110
|
return /*#__PURE__*/React.createElement(Text, {
|
|
118
111
|
numberOfLines: numberOfLines,
|
|
119
112
|
allowFontScaling: allowFontScaling,
|
|
120
113
|
key: key,
|
|
121
114
|
style: convertedCSSStyles
|
|
122
|
-
},
|
|
115
|
+
}, _children);
|
|
123
116
|
}
|
|
124
117
|
};
|
|
125
118
|
return /*#__PURE__*/React.createElement(View, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/atom/html/index.native.tsx"],"names":["React","useMemo","View","HtmlBase","HTML_ANCHOR_TEXT_COLOR","useTemplateContext","Text","DEFAULT_STYLE","DEFAULT_TEXT_STYLE","Html","props","templateContext","theme","vibration","children","fontSize","containerStyle","imageStyle","style","testID","anchorTextColor","isTextCentered","numberOfLines","onLinkPress","handleLinkPress","url","vibrate","
|
|
1
|
+
{"version":3,"sources":["../../../src/atom/html/index.native.tsx"],"names":["React","useMemo","useState","View","HtmlBase","HTML_ANCHOR_TEXT_COLOR","useTemplateContext","Text","DEFAULT_STYLE","DEFAULT_TEXT_STYLE","Html","props","disableBaseFontStyleColor","setDisableBaseFontStyleColor","templateContext","theme","vibration","children","fontSize","containerStyle","imageStyle","style","testID","anchorTextColor","isTextCentered","numberOfLines","onLinkPress","handleLinkPress","url","vibrate","styles","p","marginVertical","textAlign","u","textDecorationLine","i","fontStyle","b","fontWeight","bold","s","tagsStyles","h1","h2","h3","h4","h5","h6","a","color","img","baseFontStyle","colors","black","Array","isArray","styleObject","reduce","result","child","renderers","font","htmlAttribs","_children","span","Span","_","convertedCSSStyles","allowFontScaling","key","html"],"mappings":";;AAAA,OAAOA,KAAP,IAAeC,OAAf,EAAwBC,QAAxB,QAAuC,OAAvC;AACA,SAAQC,IAAR,QAAqD,cAArD;AACA,OAAOC,QAAP,MAAqB,0BAArB;AAEA,SAAQC,sBAAR,QAAqC,8BAArC;AACA,SAAQC,kBAAR,QAAiC,4CAAjC;AACA,OAAOC,IAAP,IAAcC,aAAa,IAAIC,kBAA/B,QAAwD,sBAAxD;;AAeA,MAAMC,IAAI,GAAIC,KAAD,IAAkB;AAC7B,QAAM,CAACC,yBA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J;AACA,0BACE,oBAAC,IAAD;AACE,QAAA,aAAa,EAAE7C,aADjB;AAEE,QAAA,gBAAgB,EAAE4C,gBAFpB;AAGE,QAAA,GAAG,EAAEC,GAHP;AAIE,QAAA,KAAK,EAAEF;AAJT,SAMGJ,SANH,CADF;AAUD;AAlCe,GAAlB;AAqCA,sBACE,oBAAC,IAAD;AAAM,IAAA,MAAM,EAAE1C,MAAd;AAAsB,IAAA,KAAK,EAAEH;AAA7B,kBACE,oBAAC,QAAD,CACE;AACA;AACA;AACA;AAJF;AAKE,IAAA,MAAM,EAAE;AACN;AACAoD,MAAAA,IAAI,EAAE/C,cAAc,GACf,MAAKP,QAAS,MADC,GAEhBQ,aAAa,GACZ,SAAQR,QAAS,SADL,GAEZ,GAAEA,QAAS;AANV,KALV;AAaE,IAAA,UAAU,EAAEyB,UAbd;AAcE,IAAA,aAAa,wBACRU,aADQ;AAEXF,MAAAA,KAAK,EAAEtC,yBAAyB,GAAG,IAAH,GAAUwC,aAAa,CAACF;AAF7C,MAdf;AAkBE,IAAA,WAAW,EAAEvB,eAlBf;AAmBE,IAAA,SAAS,EAAEkC,SAnBb,CAoBE;AACA;AACA;AACA;AAvBF;AAwBE,IAAA,aAAa,EAAE,CAAC,OAAD,EAAU,QAAV,CAxBjB;AAyBE,IAAA,MAAM,EAAC;AAzBT,IADF,CADF;AA+BD,CAjJD;;AAmJA,eAAenD,IAAf","sourcesContent":["import React, {useMemo, useState} from 'react';\nimport {View, ViewStyle, ImageStyle, TextStyle} from 'react-native';\nimport HtmlBase from 'react-native-render-html';\n\nimport {HTML_ANCHOR_TEXT_COLOR} from '../../variables/theme.native';\nimport {useTemplateContext} from '../../template/app-review/template-context';\nimport Text, {DEFAULT_STYLE as DEFAULT_TEXT_STYLE} from '../text/index.native';\n\nexport type Props = {\n children: string;\n fontSize: number;\n numberOfLines?: number;\n onLinkPress?: (url: string) => void;\n containerStyle?: ViewStyle;\n anchorTextColor?: string;\n imageStyle?: ImageStyle;\n style?: TextStyle;\n testID?: string;\n isTextCentered?: boolean;\n};\n\nconst Html = (props: Props) => {\n const [disableBaseFontStyleColor, setDisableBaseFontStyleColor] = useState<boolean>(false);\n const templateContext = useTemplateContext();\n const {theme, vibration} = templateContext;\n const {\n children,\n fontSize,\n containerStyle,\n imageStyle,\n style,\n testID,\n anchorTextColor = HTML_ANCHOR_TEXT_COLOR,\n isTextCentered,\n numberOfLines,\n onLinkPress\n } = props;\n\n const handleLinkPress = useMemo(\n () => (url: string) => {\n vibration?.vibrate();\n\n onLinkPress && onLinkPress(url);\n },\n [onLinkPress, vibration]\n );\n\n // Don't use StyleSheet there, it's not a react style\n const styles = {\n p: {\n marginVertical: 0,\n textAlign: 'center'\n },\n u: {\n textDecorationLine: 'underline'\n },\n i: {\n fontStyle: 'italic'\n },\n b: {\n fontWeight: theme.fontWeight.bold\n },\n s: {\n textDecorationLine: 'line-through'\n }\n };\n\n const tagsStyles = {\n ...styles,\n h1: {fontSize},\n h2: {fontSize},\n h3: {fontSize},\n h4: {fontSize},\n h5: {fontSize},\n h6: {fontSize},\n a: {color: anchorTextColor},\n img: imageStyle\n };\n\n let baseFontStyle = {...DEFAULT_TEXT_STYLE, fontSize, color: theme.colors.black};\n if (style) {\n if (Array.isArray(style)) {\n const styleObject = style.reduce((result, child) => ({\n ...result,\n ...child\n }));\n baseFontStyle = {\n ...baseFontStyle,\n ...styleObject\n };\n } else {\n baseFontStyle = {\n ...baseFontStyle,\n ...style\n };\n }\n }\n\n const renderers = {\n // eslint-disable-next-line react/display-name\n font: (htmlAttribs, _children) => {\n if (htmlAttribs.color) {\n setDisableBaseFontStyleColor(true);\n }\n return (\n <Text\n key={1}\n style={{\n ...baseFontStyle,\n color: htmlAttribs.color\n }}\n >\n {_children}\n </Text>\n );\n },\n span: function Span(\n _: any,\n _children: any,\n convertedCSSStyles: any,\n {allowFontScaling, key}: any\n ) {\n return (\n <Text\n numberOfLines={numberOfLines}\n allowFontScaling={allowFontScaling}\n key={key}\n style={convertedCSSStyles}\n >\n {_children}\n </Text>\n );\n }\n };\n\n return (\n <View testID={testID} style={containerStyle}>\n <HtmlBase\n // to text-align center on android\n // we have to encapsulate between <p> tag\n // and use custom style define on <p>\n // definition in component style doesn't work\n source={{\n // eslint-disable-next-line no-nested-ternary\n html: isTextCentered\n ? `<p>${children}</p>`\n : numberOfLines\n ? `<span>${children}</span>`\n : `${children}`\n }}\n tagsStyles={tagsStyles}\n baseFontStyle={{\n ...baseFontStyle,\n color: disableBaseFontStyleColor ? null : baseFontStyle.color\n }}\n onLinkPress={handleLinkPress}\n renderers={renderers}\n // this is exceptionally for the onboarding course\n // is the only course that has a gif in the context but the img tag\n // comes with width & height attr and these makes this lib do not render the gif\n // so to avoid it, we decided to ignore these attr\n ignoredStyles={['width', 'height']}\n testID=\"html-base\"\n />\n </View>\n );\n};\n\nexport default Html;\n"],"file":"index.native.js"}
|
|
@@ -16,7 +16,9 @@ const InputSwitch = props => {
|
|
|
16
16
|
description,
|
|
17
17
|
modified = false,
|
|
18
18
|
theme = 'default',
|
|
19
|
-
titlePosition = 'left'
|
|
19
|
+
titlePosition = 'left',
|
|
20
|
+
details = '',
|
|
21
|
+
requiredSelection = false
|
|
20
22
|
} = props;
|
|
21
23
|
|
|
22
24
|
const idSwitch = id || _uniqueId('input-switch-');
|
|
@@ -29,13 +31,42 @@ const InputSwitch = props => {
|
|
|
29
31
|
const descriptionView = description ? /*#__PURE__*/React.createElement("div", {
|
|
30
32
|
className: style.description
|
|
31
33
|
}, description) : null;
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
+
|
|
35
|
+
const getClass = () => {
|
|
36
|
+
switch (theme) {
|
|
37
|
+
case 'coorpmanager':
|
|
38
|
+
return {
|
|
39
|
+
defaultClass: style.coorpmanager,
|
|
40
|
+
modifiedClass: style.coorpmanagerModified
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
case 'mooc':
|
|
44
|
+
return {
|
|
45
|
+
defaultClass: style.partielUncheck,
|
|
46
|
+
modifiedClass: style.coorpmanagerModified
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
default:
|
|
50
|
+
return {
|
|
51
|
+
defaultClass: style.default,
|
|
52
|
+
modifiedClass: style.modified
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const {
|
|
58
|
+
defaultClass,
|
|
59
|
+
modifiedClass
|
|
60
|
+
} = getClass();
|
|
34
61
|
const className = getClassState(defaultClass, modifiedClass, null, modified);
|
|
35
62
|
return /*#__PURE__*/React.createElement("div", {
|
|
36
63
|
className: className,
|
|
37
64
|
"data-name": `switch-input-${theme}`
|
|
38
|
-
}, titlePosition === 'left' ? titleView : null, /*#__PURE__*/React.createElement("
|
|
65
|
+
}, titlePosition === 'left' ? titleView : null, /*#__PURE__*/React.createElement("div", {
|
|
66
|
+
className: requiredSelection ? style.requiredSelection : null
|
|
67
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
68
|
+
className: style.btnSwitchContainer
|
|
69
|
+
}, /*#__PURE__*/React.createElement("input", {
|
|
39
70
|
type: "checkbox",
|
|
40
71
|
id: idSwitch,
|
|
41
72
|
name: name,
|
|
@@ -46,7 +77,11 @@ const InputSwitch = props => {
|
|
|
46
77
|
}), /*#__PURE__*/React.createElement("label", {
|
|
47
78
|
htmlFor: idSwitch,
|
|
48
79
|
"data-name": "input-switch-label"
|
|
49
|
-
}),
|
|
80
|
+
}))), /*#__PURE__*/React.createElement("div", {
|
|
81
|
+
className: !details ? style.alignedTextContainer : null
|
|
82
|
+
}, titlePosition === 'right' ? titleView : null, details ? /*#__PURE__*/React.createElement("div", {
|
|
83
|
+
className: style.detailsTxt
|
|
84
|
+
}, details) : null), descriptionView);
|
|
50
85
|
};
|
|
51
86
|
|
|
52
87
|
InputSwitch.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
@@ -59,7 +94,9 @@ InputSwitch.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
59
94
|
description: PropTypes.string,
|
|
60
95
|
modified: PropTypes.bool,
|
|
61
96
|
titlePosition: PropTypes.oneOf(['right', 'left']),
|
|
62
|
-
theme: PropTypes.oneOf(['default', 'coorpmanager'])
|
|
97
|
+
theme: PropTypes.oneOf(['default', 'coorpmanager', 'mooc']),
|
|
98
|
+
details: PropTypes.string,
|
|
99
|
+
requiredSelection: PropTypes.bool
|
|
63
100
|
} : {};
|
|
64
101
|
export default InputSwitch;
|
|
65
102
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/atom/input-switch/index.js"],"names":["React","useMemo","PropTypes","getClassState","style","InputSwitch","props","title","name","id","value","disabled","onChange","description","modified","theme","titlePosition","idSwitch","isDisabled","handleChange","e","target","checked","titleView","descriptionView","
|
|
1
|
+
{"version":3,"sources":["../../../src/atom/input-switch/index.js"],"names":["React","useMemo","PropTypes","getClassState","style","InputSwitch","props","title","name","id","value","disabled","onChange","description","modified","theme","titlePosition","details","requiredSelection","idSwitch","isDisabled","handleChange","e","target","checked","titleView","descriptionView","getClass","defaultClass","coorpmanager","modifiedClass","coorpmanagerModified","partielUncheck","default","className","btnSwitchContainer","checkbox","alignedTextContainer","detailsTxt","propTypes","string","bool","func","oneOf"],"mappings":";;AAAA,OAAOA,KAAP,IAAeC,OAAf,QAA6B,OAA7B;AACA,OAAOC,SAAP,MAAsB,YAAtB;AAEA,OAAOC,aAAP,MAA0B,4BAA1B;AACA,OAAOC,KAAP,MAAkB,aAAlB;;AAEA,MAAMC,WAAW,GAAGC,KAAK,IAAI;AAC3B,QAAM;AACJC,IAAAA,KADI;AAEJC,IAAAA,IAFI;AAGJC,IAAAA,EAHI;AAIJC,IAAAA,KAJI;AAKJC,IAAAA,QALI;AAMJC,IAAAA,QAAQ,QANJ;AAOJC,IAAAA,WAPI;AAQJC,IAAAA,QAAQ,GAAG,KARP;AASJC,IAAAA,KAAK,GAAG,SATJ;AAUJC,IAAAA,aAAa,GAAG,MAVZ;AAW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,CAACsC,MAPD;AAQtB1B,EAAAA,QAAQ,EAAEZ,SAAS,CAACuC,IARE;AAStBzB,EAAAA,aAAa,EAAEd,SAAS,CAACyC,KAAV,CAAgB,CAAC,OAAD,EAAU,MAAV,CAAhB,CATO;AAUtB5B,EAAAA,KAAK,EAAEb,SAAS,CAACyC,KAAV,CAAgB,CAAC,SAAD,EAAY,cAAZ,EAA4B,MAA5B,CAAhB,CAVe;AAWtB1B,EAAAA,OAAO,EAAEf,SAAS,CAACsC,MAXG;AAYtBtB,EAAAA,iBAAiB,EAAEhB,SAAS,CAACuC;AAZP,CAAxB;AAcA,eAAepC,WAAf","sourcesContent":["import React, {useMemo} from 'react';\nimport PropTypes from 'prop-types';\nimport {noop, uniqueId} from 'lodash/fp';\nimport getClassState from '../../util/get-class-state';\nimport style from './style.css';\n\nconst InputSwitch = props => {\n const {\n title,\n name,\n id,\n value,\n disabled,\n onChange = noop,\n description,\n modified = false,\n theme = 'default',\n titlePosition = 'left',\n details = '',\n requiredSelection = false\n } = props;\n\n const idSwitch = id || uniqueId('input-switch-');\n const isDisabled = disabled ? 'disabled' : '';\n const handleChange = useMemo(() => e => onChange(e.target.checked), [onChange]);\n\n const titleView = title ? <span className={style.title}>{`${title} `}</span> : null;\n\n const descriptionView = description ? (\n <div className={style.description}>{description}</div>\n ) : null;\n\n const getClass = () => {\n switch (theme) {\n case 'coorpmanager':\n return {\n defaultClass: style.coorpmanager,\n modifiedClass: style.coorpmanagerModified\n };\n case 'mooc':\n return {\n defaultClass: style.partielUncheck,\n modifiedClass: style.coorpmanagerModified\n };\n default:\n return {defaultClass: style.default, modifiedClass: style.modified};\n }\n };\n const {defaultClass, modifiedClass} = getClass();\n const className = getClassState(defaultClass, modifiedClass, null, modified);\n\n return (\n <div className={className} data-name={`switch-input-${theme}`}>\n {titlePosition === 'left' ? titleView : null}\n <div className={requiredSelection ? style.requiredSelection : null}>\n <div className={style.btnSwitchContainer}>\n <input\n type=\"checkbox\"\n id={idSwitch}\n name={name}\n onChange={handleChange}\n checked={value}\n disabled={isDisabled}\n className={style.checkbox}\n />\n <label htmlFor={idSwitch} data-name=\"input-switch-label\" />\n </div>\n </div>\n <div className={!details ? style.alignedTextContainer : null}>\n {titlePosition === 'right' ? titleView : null}\n {details ? <div className={style.detailsTxt}>{details}</div> : null}\n </div>\n {descriptionView}\n </div>\n );\n};\n\nInputSwitch.propTypes = {\n title: PropTypes.string,\n name: PropTypes.string,\n id: PropTypes.string,\n value: PropTypes.bool,\n disabled: PropTypes.bool,\n onChange: PropTypes.func,\n description: PropTypes.string,\n modified: PropTypes.bool,\n titlePosition: PropTypes.oneOf(['right', 'left']),\n theme: PropTypes.oneOf(['default', 'coorpmanager', 'mooc']),\n details: PropTypes.string,\n requiredSelection: PropTypes.bool\n};\nexport default InputSwitch;\n"],"file":"index.js"}
|
|
@@ -8,11 +8,10 @@
|
|
|
8
8
|
@value cm_grey_200 from colors;
|
|
9
9
|
@value black from colors;
|
|
10
10
|
@value cm_primary_blue from colors;
|
|
11
|
+
@value light_blue from colors;
|
|
11
12
|
|
|
12
13
|
.default {
|
|
13
14
|
display: flex;
|
|
14
|
-
align-items: center;
|
|
15
|
-
align-content: center;
|
|
16
15
|
}
|
|
17
16
|
|
|
18
17
|
.modified {
|
|
@@ -27,6 +26,10 @@
|
|
|
27
26
|
composes: modified;
|
|
28
27
|
}
|
|
29
28
|
|
|
29
|
+
.partielUncheck {
|
|
30
|
+
composes: coorpmanager;
|
|
31
|
+
}
|
|
32
|
+
|
|
30
33
|
.default label {
|
|
31
34
|
height: 30px;
|
|
32
35
|
position: relative;
|
|
@@ -97,12 +100,11 @@
|
|
|
97
100
|
font-size: 15px;
|
|
98
101
|
text-transform: none;
|
|
99
102
|
color: dark;
|
|
100
|
-
width: 180px;
|
|
101
103
|
margin-right: 20px;
|
|
102
|
-
min-height: 50px;
|
|
103
104
|
display: flex;
|
|
104
105
|
align-items: center;
|
|
105
106
|
align-content: center;
|
|
107
|
+
min-height: 24px;
|
|
106
108
|
}
|
|
107
109
|
|
|
108
110
|
.description {
|
|
@@ -118,7 +120,7 @@
|
|
|
118
120
|
width: 48px;
|
|
119
121
|
height: 24px;
|
|
120
122
|
border: solid 2px cm_grey_200;
|
|
121
|
-
margin-right:
|
|
123
|
+
margin-right: 16px;
|
|
122
124
|
background: cm_grey_200;
|
|
123
125
|
}
|
|
124
126
|
|
|
@@ -148,4 +150,52 @@
|
|
|
148
150
|
|
|
149
151
|
.coorpmanager .checkbox:disabled ~ label::after {
|
|
150
152
|
background: white;
|
|
151
|
-
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.partielUncheck label::after {
|
|
156
|
+
width: 19px;
|
|
157
|
+
height: 19px;
|
|
158
|
+
border: 3px solid cm_primary_blue;
|
|
159
|
+
margin-left: 8px;
|
|
160
|
+
}
|
|
161
|
+
.partielUncheck label {
|
|
162
|
+
width: 50px;
|
|
163
|
+
height: 26px;
|
|
164
|
+
background: light_blue;
|
|
165
|
+
border: 0px;
|
|
166
|
+
}
|
|
167
|
+
.partielUncheck .checkbox:checked ~ label {
|
|
168
|
+
background-color: cm_primary_blue;
|
|
169
|
+
border: 0px;
|
|
170
|
+
width: 50px;
|
|
171
|
+
height: 26px;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
.partielUncheck .checkbox:checked ~ label::after {
|
|
175
|
+
margin-left: 0px;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
.btnSwitchContainer {
|
|
179
|
+
display: flex;
|
|
180
|
+
align-items: center;
|
|
181
|
+
}
|
|
182
|
+
.alignedTextContainer {
|
|
183
|
+
display: flex;
|
|
184
|
+
align-items: center;
|
|
185
|
+
align-content: center;
|
|
186
|
+
}
|
|
187
|
+
.detailsTxt {
|
|
188
|
+
font-family: Gilroy;
|
|
189
|
+
font-weight: 500;
|
|
190
|
+
font-size: 14px;
|
|
191
|
+
line-height: 22px;
|
|
192
|
+
color: black;
|
|
193
|
+
font-style: normal;
|
|
194
|
+
white-space: pre-line;
|
|
195
|
+
margin-right: 24px;
|
|
196
|
+
}
|
|
197
|
+
.requiredSelection label, .requiredSelection .checkbox:disabled ~ label {
|
|
198
|
+
background-color: cm_primary_blue;
|
|
199
|
+
border-color: cm_primary_blue;
|
|
200
|
+
opacity: 0.4;
|
|
201
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useState, useEffect,
|
|
1
|
+
import React, { useState, useEffect, useCallback } from 'react';
|
|
2
2
|
import { View, StyleSheet } from 'react-native';
|
|
3
3
|
import { NovaCompositionNavigationArrowDown as ArrowDown } from '@coorpacademy/nova-icons';
|
|
4
4
|
import Modal from 'react-native-modal';
|
|
@@ -57,20 +57,20 @@ const Select = props => {
|
|
|
57
57
|
isDisabled = false,
|
|
58
58
|
testID = 'select'
|
|
59
59
|
} = props;
|
|
60
|
-
const handleFocus =
|
|
60
|
+
const handleFocus = useCallback(() => {
|
|
61
61
|
if (!onFocus) return;
|
|
62
62
|
analytics && logEvent(ANALYTICS_EVENT_TYPE.OPEN_SELECT, analyticsID, analytics, questionType);
|
|
63
63
|
onFocus();
|
|
64
64
|
}, [analytics, analyticsID, onFocus, questionType]);
|
|
65
|
-
const handleBlur =
|
|
65
|
+
const handleBlur = useCallback(() => {
|
|
66
66
|
if (!onBlur) return;
|
|
67
67
|
analytics && logEvent(ANALYTICS_EVENT_TYPE.CLOSE_SELECT, analyticsID, analytics, questionType);
|
|
68
68
|
onBlur();
|
|
69
69
|
}, [analytics, analyticsID, onBlur, questionType]);
|
|
70
|
-
const handleChange =
|
|
71
|
-
onChange(
|
|
70
|
+
const handleChange = useCallback(_value => {
|
|
71
|
+
onChange(_value);
|
|
72
72
|
handleBlur();
|
|
73
|
-
}, [
|
|
73
|
+
}, [onChange, handleBlur]);
|
|
74
74
|
|
|
75
75
|
if (!styleSheet) {
|
|
76
76
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/atom/select-modal/index.native.tsx"],"names":["React","useState","useEffect","
|
|
1
|
+
{"version":3,"sources":["../../../src/atom/select-modal/index.native.tsx"],"names":["React","useState","useEffect","useCallback","View","StyleSheet","NovaCompositionNavigationArrowDown","ArrowDown","Modal","Touchable","ANALYTICS_EVENT_TYPE","Space","Text","ModalSelect","useTemplateContext","ICON_WIDTH","createStyleSheet","theme","create","container","alignItems","flexDirection","text","flex","color","colors","gray","medium","textAlign","logEvent","eventName","analyticsID","analytics","questionType","id","Select","props","templateContext","styleSheet","setStylesheet","_stylesheet","onBlur","onFocus","onChange","values","placeholder","value","style","textStyle","isFocused","isDisabled","testID","handleFocus","OPEN_SELECT","handleBlur","CLOSE_SELECT","handleChange","_value","selectedItem","find","item","dark"],"mappings":"AAAA,OAAOA,KAAP,IAAeC,QAAf,EAAyBC,SAAzB,EAAoCC,WAApC,QAAsD,OAAtD;AACA,SAAQC,IAAR,EAAcC,UAAd,QAAyD,cAAzD;AACA,SAAQC,kCAAkC,IAAIC,SAA9C,QAA8D,0BAA9D;AACA,OAAOC,KAAP,MAAkB,oBAAlB;AACA,OAAOC,SAAP,MAAsB,kCAAtB;AAIA,SAAQC,oBAAR,QAA8C,2BAA9C;AACA,OAAOC,KAAP,MAAkB,uBAAlB;AACA,OAAOC,IAAP,MAAiB,sBAAjB;AACA,OAAOC,WAAP,MAA4C,qCAA5C;AACA,SAAQC,kBAAR,QAAiC,4CAAjC;AA+BA,MAAMC,UAAU,GAAG,EAAnB;;AAEA,MAAMC,gBAAgB,GAAIC,KAAD,IACvBZ,UAAU,CAACa,MAAX,CAAkB;AAChBC,EAAAA,SAAS,EAAE;AACTC,IAAAA,UAAU,EAAE,QADH;AAETC,IAAAA,aAAa,EAAE;AAFN,GADK;AAKhBC,EAAAA,IAAI,EAAE;AACJC,IAAAA,IAAI,EAAE,CADF;AAEJC,IAAAA,KAAK,EAAEP,KAAK,CAACQ,MAAN,CAAaC,IAAb,CAAkBC,MAFrB;AAGJC,IAAAA,SAAS,EAAE;AAHP;AALU,CAAlB,CAD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D;AAAO,IAAA,IAAI,EAAC;AAAZ,IAFF,eAGE,oBAAC,SAAD;AACE,IAAA,KAAK,EAAEE,KAAK,IAAIP,KAAK,CAACQ,MAAN,CAAaC,IAAb,CAAkBmC,IADpC;AAEE,IAAA,MAAM,EAAE9C,UAFV;AAGE,IAAA,KAAK,EAAEA;AAHT,IAHF,CANF,CADF,eAiBE,oBAAC,KAAD;AACE,IAAA,SAAS,EAAEkC,SADb;AAEE,IAAA,eAAe,EAAEK,UAFnB;AAGE,IAAA,eAAe,EAAEA,UAHnB;AAIE,IAAA,MAAM,EAAEH;AAJV,kBAME,oBAAC,WAAD;AACE,IAAA,KAAK,EAAEL,KADT;AAEE,IAAA,MAAM,EAAEF,MAFV;AAGE,IAAA,QAAQ,EAAEY,YAHZ;AAIE,IAAA,OAAO,EAAEF,UAJX;AAKE,IAAA,MAAM,EAAG,GAAEH,MAAO;AALpB,IANF,CAjBF,CADF;AAkCD,CA1FD;;AA4FA,eAAehB,MAAf","sourcesContent":["import React, {useState, useEffect, useCallback} from 'react';\nimport {View, StyleSheet, ViewStyle, FlexAlignType} from 'react-native';\nimport {NovaCompositionNavigationArrowDown as ArrowDown} from '@coorpacademy/nova-icons';\nimport Modal from 'react-native-modal';\nimport Touchable from '../../hoc/touchable/index.native';\nimport type {ChoiceItem, QuestionType} from '../../types/progression-engine.d';\nimport {Theme} from '../../variables/theme.native';\n\nimport {ANALYTICS_EVENT_TYPE, Analytics} from '../../variables/analytics';\nimport Space from '../space/index.native';\nimport Text from '../text/index.native';\nimport ModalSelect, {OnChangeFunction} from '../../hoc/modal/select/index.native';\nimport {useTemplateContext} from '../../template/app-review/template-context';\n\nexport type Props = {\n analyticsID: string;\n questionType: QuestionType;\n isDisabled?: boolean;\n isFocused?: boolean;\n values: Array<ChoiceItem>;\n value?: string;\n placeholder?: string;\n color?: string;\n onChange: OnChangeFunction;\n onFocus: () => void;\n onBlur: () => void;\n style?: ViewStyle;\n textStyle?: ViewStyle;\n testID?: string;\n};\n\ntype StyleSheetType = {\n container: {\n alignItems: FlexAlignType;\n flexDirection: 'row' | 'column' | 'row-reverse' | 'column-reverse' | undefined;\n };\n text: {\n flex: number;\n color: string;\n textAlign: string;\n };\n};\n\nconst ICON_WIDTH = 15;\n\nconst createStyleSheet = (theme: Theme) =>\n StyleSheet.create({\n container: {\n alignItems: 'center',\n flexDirection: 'row'\n },\n text: {\n flex: 1,\n color: theme.colors.gray.medium,\n textAlign: 'center'\n }\n });\n\nconst logEvent = (\n eventName: string,\n analyticsID: String,\n analytics: Analytics,\n questionType: QuestionType\n) => {\n analytics &&\n analytics.logEvent(eventName, {\n id: analyticsID,\n questionType\n });\n};\n\nconst Select = (props: Props) => {\n const templateContext = useTemplateContext();\n const {theme, analytics} = templateContext;\n const [styleSheet, setStylesheet] = useState<StyleSheetType | null>(null);\n\n useEffect(() => {\n const _stylesheet = createStyleSheet(theme);\n setStylesheet(_stylesheet);\n }, [theme]);\n\n const {\n analyticsID,\n onBlur,\n onFocus,\n onChange,\n values,\n placeholder,\n value,\n style,\n textStyle,\n color,\n questionType,\n isFocused = false,\n isDisabled = false,\n testID = 'select'\n } = props;\n\n const handleFocus = useCallback(() => {\n if (!onFocus) return;\n\n analytics && logEvent(ANALYTICS_EVENT_TYPE.OPEN_SELECT, analyticsID, analytics, questionType);\n onFocus();\n }, [analytics, analyticsID, onFocus, questionType]);\n\n const handleBlur = useCallback(() => {\n if (!onBlur) return;\n\n analytics && logEvent(ANALYTICS_EVENT_TYPE.CLOSE_SELECT, analyticsID, analytics, questionType);\n onBlur();\n }, [analytics, analyticsID, onBlur, questionType]);\n\n const handleChange = useCallback(\n _value => {\n onChange(_value);\n handleBlur();\n },\n [onChange, handleBlur]\n );\n\n if (!styleSheet) {\n return null;\n }\n\n const selectedItem = values.find(item => item.text === value);\n const text = (selectedItem && selectedItem.text) || placeholder || null;\n\n return (\n <>\n <Touchable\n disabled={isDisabled}\n onPress={handleFocus}\n analyticsID={analyticsID}\n testID={`${testID}-input`}\n >\n <View style={[styleSheet.container, style]}>\n <Text style={[styleSheet.text, textStyle, color && {color}]}>{text}</Text>\n <Space type=\"tiny\" />\n <ArrowDown\n color={color || theme.colors.gray.dark}\n height={ICON_WIDTH}\n width={ICON_WIDTH}\n />\n </View>\n </Touchable>\n <Modal\n isVisible={isFocused}\n onSwipeComplete={handleBlur}\n onBackdropPress={handleBlur}\n testID={testID}\n >\n <ModalSelect\n value={value}\n values={values}\n onChange={handleChange}\n onClose={handleBlur}\n testID={`${testID}-modal`}\n />\n </Modal>\n </>\n );\n};\n\nexport default Select;\n"],"file":"index.native.js"}
|
|
@@ -16,9 +16,11 @@ const Text = props => {
|
|
|
16
16
|
children,
|
|
17
17
|
style,
|
|
18
18
|
testID,
|
|
19
|
-
numberOfLines
|
|
19
|
+
numberOfLines,
|
|
20
|
+
allowFontScaling = true
|
|
20
21
|
} = props;
|
|
21
22
|
return /*#__PURE__*/React.createElement(TextBase, {
|
|
23
|
+
allowFontScaling: allowFontScaling,
|
|
22
24
|
style: [styles.text, style],
|
|
23
25
|
testID: testID,
|
|
24
26
|
numberOfLines: numberOfLines
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/atom/text/index.native.tsx"],"names":["React","Text","TextBase","Platform","StyleSheet","DEFAULT_STYLE","select","android","fontFamily","styles","create","text","props","children","style","testID","numberOfLines"],"mappings":";;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAAQC,IAAI,IAAIC,QAAhB,EAA0BC,QAA1B,EAAoCC,UAApC,QAAgE,cAAhE;
|
|
1
|
+
{"version":3,"sources":["../../../src/atom/text/index.native.tsx"],"names":["React","Text","TextBase","Platform","StyleSheet","DEFAULT_STYLE","select","android","fontFamily","styles","create","text","props","children","style","testID","numberOfLines","allowFontScaling"],"mappings":";;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAAQC,IAAI,IAAIC,QAAhB,EAA0BC,QAA1B,EAAoCC,UAApC,QAAgE,cAAhE;AAWA,OAAO,MAAMC,aAAa,gBACrBF,QAAQ,CAACG,MAAT,CAAgB;AACjBC,EAAAA,OAAO,EAAE;AACPC,IAAAA,UAAU,EAAE;AADL;AADQ,CAAhB,CADqB,CAAnB;AAQP,MAAMC,MAAM,GAAGL,UAAU,CAACM,MAAX,CAAkB;AAC/BC,EAAAA,IAAI,eACCN,aADD;AAD2B,CAAlB,CAAf;;AAMA,MAAMJ,IAAI,GAAIW,KAAD,IAAkB;AAC7B,QAAM;AAACC,IAAAA,QAAD;AAAWC,IAAAA,KAAX;AAAkBC,IAAAA,MAAlB;AAA0BC,IAAAA,aAA1B;AAAyCC,IAAAA,gBAAgB,GAAG;AAA5D,MAAoEL,KAA1E;AAEA,sBACE,oBAAC,QAAD;AACE,IAAA,gBAAgB,EAAEK,gBADpB;AAEE,IAAA,KAAK,EAAE,CAACR,MAAM,CAACE,IAAR,EAAcG,KAAd,CAFT;AAGE,IAAA,MAAM,EAAEC,MAHV;AAIE,IAAA,aAAa,EAAEC;AAJjB,KAMGH,QANH,CADF;AAUD,CAbD;;AAeA,eAAeZ,IAAf","sourcesContent":["import * as React from 'react';\nimport {Text as TextBase, Platform, StyleSheet, ViewStyle} from 'react-native';\n\nexport type Props = {\n // copied from node_modules/react-native/Libraries/Text/TextProps.js\n children: React.ReactNode;\n style?: ViewStyle | ViewStyle[];\n testID?: string;\n numberOfLines?: number;\n allowFontScaling?: boolean;\n};\n\nexport const DEFAULT_STYLE = {\n ...Platform.select({\n android: {\n fontFamily: 'Roboto'\n }\n })\n};\n\nconst styles = StyleSheet.create({\n text: {\n ...DEFAULT_STYLE\n }\n});\n\nconst Text = (props: Props) => {\n const {children, style, testID, numberOfLines, allowFontScaling = true} = props;\n\n return (\n <TextBase\n allowFontScaling={allowFontScaling}\n style={[styles.text, style]}\n testID={testID}\n numberOfLines={numberOfLines}\n >\n {children}\n </TextBase>\n );\n};\n\nexport default Text;\n"],"file":"index.native.js"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _noop from "lodash/fp/noop";
|
|
1
2
|
import React, { useState, useEffect, useMemo } from 'react';
|
|
2
3
|
import { View, FlatList, StyleSheet } from 'react-native';
|
|
3
4
|
import { useTemplateContext } from '../../../template/app-review/template-context';
|
|
@@ -48,10 +49,10 @@ const ModalSelect = props => {
|
|
|
48
49
|
theme
|
|
49
50
|
} = templateContext;
|
|
50
51
|
const {
|
|
51
|
-
value,
|
|
52
|
+
value = '',
|
|
52
53
|
values,
|
|
53
54
|
onChange,
|
|
54
|
-
onClose,
|
|
55
|
+
onClose = _noop,
|
|
55
56
|
testID = 'modal-select'
|
|
56
57
|
} = props;
|
|
57
58
|
useEffect(() => {
|
|
@@ -60,7 +61,7 @@ const ModalSelect = props => {
|
|
|
60
61
|
setStylesheet(_stylesheet);
|
|
61
62
|
}, [theme]);
|
|
62
63
|
const renderItem = useMemo(() => createRenderItem(value, testID, onChange), [value, testID, onChange]);
|
|
63
|
-
const renderSeparator = useMemo(() => createSeparator(styleSheet), [styleSheet]);
|
|
64
|
+
const renderSeparator = useMemo(() => styleSheet ? createSeparator(styleSheet) : null, [styleSheet]);
|
|
64
65
|
|
|
65
66
|
if (!styleSheet) {
|
|
66
67
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/hoc/modal/select/index.native.tsx"],"names":["React","useState","useEffect","useMemo","View","FlatList","StyleSheet","useTemplateContext","Modal","ModalSelectItem","createStyleSheet","theme","create","content","paddingHorizontal","separator","borderTopWidth","borderColor","colors","border","list","width","keyExtractor","item","index","createRenderItem","value","testID","onChange","handleChange","_value","text","createSeparator","styleSheet","ModalSelect","props","templateContext","setStylesheet","values","onClose","_stylesheet","renderItem","renderSeparator"],"mappings":"AAAA,OAAOA,KAAP,IAAeC,QAAf,EAAyBC,SAAzB,EAAoCC,OAApC,QAAkD,OAAlD;AACA,SAAQC,IAAR,EAAcC,QAAd,EAAwBC,UAAxB,QAAyC,cAAzC;
|
|
1
|
+
{"version":3,"sources":["../../../../src/hoc/modal/select/index.native.tsx"],"names":["React","useState","useEffect","useMemo","View","FlatList","StyleSheet","useTemplateContext","Modal","ModalSelectItem","createStyleSheet","theme","create","content","paddingHorizontal","separator","borderTopWidth","borderColor","colors","border","list","width","keyExtractor","item","index","createRenderItem","value","testID","onChange","handleChange","_value","text","createSeparator","styleSheet","ModalSelect","props","templateContext","setStylesheet","values","onClose","_stylesheet","renderItem","renderSeparator"],"mappings":";AAAA,OAAOA,KAAP,IAAeC,QAAf,EAAyBC,SAAzB,EAAoCC,OAApC,QAAkD,OAAlD;AACA,SAAQC,IAAR,EAAcC,QAAd,EAAwBC,UAAxB,QAAyC,cAAzC;AAMA,SAAQC,kBAAR,QAAiC,+CAAjC;AAEA,OAAOC,KAAP,MAAkB,iBAAlB;AACA,OAAOC,eAAP,MAA4B,6BAA5B;;AAyBA,MAAMC,gBAAgB,GAAIC,KAAD,IACvBL,UAAU,CAACM,MAAX,CAAkB;AAChBC,EAAAA,OAAO,EAAE;AACPC,IAAAA,iBAAiB,EAAE;AADZ,GADO;AAIhBC,EAAAA,SAAS,EAAE;AACTC,IAAAA,cAAc,EAAE,CADP;AAETC,IAAAA,WAAW,EAAEN,KAAK,CAACO,MAAN,CAAaC;AAFjB,GAJK;AAQhBC,EAAAA,IAAI,EAAE;AACJC,IAAAA,KAAK,EAAE;AADH;AARU,CAAlB,CADF;;AAcA,MAAMC,YAAY,GAAG,CAACC,IAAD,EAAmBC,KAAnB,KAA6C;AAChE,SAAQ,qBAAoBA,KAAK,GAAG,CAAE,EAAtC;AACD,CAFD;;AAIA,MAAMC,gBAAgB,GAAG,CAACC,KAAD,EAAgBC,MAAhB,EAAgCC,QAAhC,KAA+D,CAAC;AACvFL,EAAAA,IADuF;AAEvFC,EAAAA;AAFuF,CAAD,KAMlF;AACJ;AACA,QAAMK,YAAY,GAAIC,MAAD,IAAoB,MAAMF,QAAQ,CAACE,MAAD,CAAvD;;AAEA,sBACE,oBAAC,e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;AAIA,MAAI,CAACA,UAAL,EAAiB;AACf,WAAO,IAAP;AACD;;AAED,sBACE,oBAAC,KAAD;AAAO,IAAA,OAAO,EAAEM,OAAhB;AAAyB,IAAA,YAAY,EAAEN,UAAU,EAAEpB,OAAnD;AAA4D,IAAA,MAAM,EAAEc;AAApE,kBACE,oBAAC,QAAD;AACE,IAAA,IAAI,EAAEW,MADR;AAEE,IAAA,UAAU,EAAEG,UAFd;AAGE,IAAA,YAAY,EAAEnB,YAHhB;AAIE,IAAA,4BAA4B,EAAE,KAJhC;AAKE,IAAA,sBAAsB,EAAEoB,eAL1B;AAME,IAAA,KAAK,EAAET,UAAU,EAAEb,IANrB;AAOE,IAAA,MAAM,EAAG,GAAEO,MAAO;AAPpB,IADF,CADF;AAaD,CAtCD;;AAwCA,eAAeO,WAAf","sourcesContent":["import React, {useState, useEffect, useMemo} from 'react';\nimport {View, FlatList, StyleSheet} from 'react-native';\nimport {noop} from 'lodash/fp';\nimport type {PressEvent} from 'react-native/Libraries/Types/CoreEventTypes';\n\nimport type {ChoiceItem} from '../../../types/progression-engine.d';\nimport {Theme} from '../../../variables/theme.native';\nimport {useTemplateContext} from '../../../template/app-review/template-context';\n\nimport Modal from '../index.native';\nimport ModalSelectItem from '../select-item/index.native';\n\nexport type OnChangeFunction = (value: string) => void;\n\nexport type Props = {\n value?: string;\n values: Array<ChoiceItem>;\n onChange: OnChangeFunction;\n onClose?: (event: PressEvent) => void;\n testID?: string;\n};\n\ntype StyleSheetType = {\n content: {\n paddingHorizontal: number;\n };\n separator: {\n borderTopWidth: number;\n borderColor: string;\n };\n list: {\n width: string;\n };\n};\n\nconst createStyleSheet = (theme: Theme) =>\n StyleSheet.create({\n content: {\n paddingHorizontal: 0\n },\n separator: {\n borderTopWidth: 1,\n borderColor: theme.colors.border\n },\n list: {\n width: '100%'\n }\n });\n\nconst keyExtractor = (item: ChoiceItem, index: number): string => {\n return `modal-select-item-${index + 1}`;\n};\n\nconst createRenderItem = (value: string, testID: String, onChange: OnChangeFunction) => ({\n item,\n index\n}: {\n item: ChoiceItem;\n index: number;\n}) => {\n // eslint-disable-next-line unicorn/consistent-function-scoping\n const handleChange = (_value: string) => () => onChange(_value);\n\n return (\n <ModalSelectItem\n onPress={handleChange(item.text)}\n isSelected={value === item.text}\n testID={`${testID}-item-${index + 1}`}\n >\n {item.text}\n </ModalSelectItem>\n );\n};\n\nconst createSeparator = (styleSheet: StyleSheetType) => () => {\n return <View style={styleSheet?.separator} />;\n};\n\nconst ModalSelect = (props: Props) => {\n const templateContext = useTemplateContext();\n const [styleSheet, setStylesheet] = useState<StyleSheetType | null>(null);\n const {theme} = templateContext;\n const {value = '', values, onChange, onClose = noop, testID = 'modal-select'} = props;\n\n useEffect(() => {\n const _stylesheet = createStyleSheet(theme);\n setStylesheet(_stylesheet);\n }, [theme]);\n\n const renderItem = useMemo(() => createRenderItem(value, testID, onChange), [\n value,\n testID,\n onChange\n ]);\n\n const renderSeparator = useMemo(() => (styleSheet ? createSeparator(styleSheet) : null), [\n styleSheet\n ]);\n\n if (!styleSheet) {\n return null;\n }\n\n return (\n <Modal onClose={onClose} contentStyle={styleSheet?.content} testID={testID}>\n <FlatList\n data={values}\n renderItem={renderItem}\n keyExtractor={keyExtractor}\n showsVerticalScrollIndicator={false}\n ItemSeparatorComponent={renderSeparator}\n style={styleSheet?.list}\n testID={`${testID}-items`}\n />\n </Modal>\n );\n};\n\nexport default ModalSelect;\n"],"file":"index.native.js"}
|
|
@@ -59,53 +59,60 @@ const MediaView = ({
|
|
|
59
59
|
|
|
60
60
|
MediaView.propTypes = process.env.NODE_ENV !== "production" ? MediaViewPropTypes : {};
|
|
61
61
|
|
|
62
|
-
const
|
|
62
|
+
const Switch = ({
|
|
63
|
+
model,
|
|
64
|
+
help
|
|
65
|
+
}) => {
|
|
63
66
|
const {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
help
|
|
67
|
-
} = props;
|
|
67
|
+
type
|
|
68
|
+
} = model;
|
|
68
69
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
} = model;
|
|
70
|
+
switch (type) {
|
|
71
|
+
case 'qcmDrag':
|
|
72
|
+
return /*#__PURE__*/React.createElement(QcmDrag, _extends({}, model, {
|
|
73
|
+
help: help
|
|
74
|
+
}));
|
|
75
75
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
return /*#__PURE__*/React.createElement(QcmDrag, _extends({}, model, {
|
|
79
|
-
help: help
|
|
80
|
-
}));
|
|
76
|
+
case 'qcm':
|
|
77
|
+
return /*#__PURE__*/React.createElement(Qcm, model);
|
|
81
78
|
|
|
82
|
-
|
|
83
|
-
|
|
79
|
+
case 'qcmGraphic':
|
|
80
|
+
return /*#__PURE__*/React.createElement(QcmGraphic, model);
|
|
84
81
|
|
|
85
|
-
|
|
86
|
-
|
|
82
|
+
case 'freeText':
|
|
83
|
+
return /*#__PURE__*/React.createElement(FreeText, model);
|
|
87
84
|
|
|
88
|
-
|
|
89
|
-
|
|
85
|
+
case 'dropDown':
|
|
86
|
+
return /*#__PURE__*/React.createElement(DropDown, model);
|
|
90
87
|
|
|
91
|
-
|
|
92
|
-
|
|
88
|
+
case 'slider':
|
|
89
|
+
return /*#__PURE__*/React.createElement(QuestionRange, model);
|
|
93
90
|
|
|
94
|
-
|
|
95
|
-
|
|
91
|
+
case 'template':
|
|
92
|
+
return /*#__PURE__*/React.createElement(Template, model);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
96
95
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
96
|
+
Switch.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
97
|
+
model: propTypes.model,
|
|
98
|
+
help: propTypes.help
|
|
99
|
+
} : {};
|
|
101
100
|
|
|
102
|
-
|
|
101
|
+
const Answer = props => {
|
|
102
|
+
const {
|
|
103
|
+
model,
|
|
104
|
+
media,
|
|
105
|
+
help
|
|
106
|
+
} = props;
|
|
103
107
|
return /*#__PURE__*/React.createElement("div", {
|
|
104
108
|
"data-name": "answer",
|
|
105
109
|
className: style.wrapper
|
|
106
110
|
}, media ? /*#__PURE__*/React.createElement(MediaView, {
|
|
107
111
|
media: media
|
|
108
|
-
}) : null,
|
|
112
|
+
}) : null, /*#__PURE__*/React.createElement(Switch, {
|
|
113
|
+
model: model,
|
|
114
|
+
help: help
|
|
115
|
+
}));
|
|
109
116
|
};
|
|
110
117
|
|
|
111
118
|
Answer.propTypes = process.env.NODE_ENV !== "production" ? propTypes : {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/molecule/answer/index.js"],"names":["React","VideoPlayer","DropDown","FreeText","QcmDrag","Qcm","QcmGraphic","QuestionRange","Template","Audio","style","propTypes","MediaViewPropTypes","TYPE_AUDIO","TYPE_IMAGE","TYPE_VIDEO","MediaView","media","videoId","type","childProps","backgroundImage","url","video","audio","
|
|
1
|
+
{"version":3,"sources":["../../../src/molecule/answer/index.js"],"names":["React","VideoPlayer","DropDown","FreeText","QcmDrag","Qcm","QcmGraphic","QuestionRange","Template","Audio","style","propTypes","MediaViewPropTypes","TYPE_AUDIO","TYPE_IMAGE","TYPE_VIDEO","MediaView","media","videoId","type","childProps","backgroundImage","url","video","audio","Switch","model","help","Answer","props","wrapper"],"mappings":";;;;;;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AAEA,OAAOC,WAAP,MAAwB,iBAAxB;AACA,OAAOC,QAAP,MAAqB,wBAArB;AACA,OAAOC,QAAP,MAAqB,wBAArB;AACA,OAAOC,OAAP,MAAoB,uBAApB;AACA,OAAOC,GAAP,MAAgB,kBAAhB;AACA,OAAOC,UAAP,MAAuB,0BAAvB;AACA,OAAOC,aAAP,MAA0B,6BAA1B;AACA,OAAOC,QAAP,MAAqB,uBAArB;AACA,OAAOC,KAAP,MAAkB,UAAlB;AACA,OAAOC,KAAP,MAAkB,aAAlB;AACA,OAAOC,SAAP,IAAmBC,kBAAnB,EAAuCC,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AC,GAAD,EAASD,KAAT,CAAP;;AACF,SAAK,YAAL;AACE,0BAAO,oBAAC,UAAD,EAAgBA,KAAhB,CAAP;;AACF,SAAK,UAAL;AACE,0BAAO,oBAAC,QAAD,EAAcA,KAAd,CAAP;;AACF,SAAK,UAAL;AACE,0BAAO,oBAAC,QAAD,EAAcA,KAAd,CAAP;;AACF,SAAK,QAAL;AACE,0BAAO,oBAAC,aAAD,EAAmBA,KAAnB,CAAP;;AACF,SAAK,UAAL;AACE,0BAAO,oBAAC,QAAD,EAAcA,KAAd,CAAP;AAdJ;AAgBD,CAnBD;;AAqBAD,MAAM,CAACd,SAAP,2CAAmB;AACjBe,EAAAA,KAAK,EAAEf,SAAS,CAACe,KADA;AAEjBC,EAAAA,IAAI,EAAEhB,SAAS,CAACgB;AAFC,CAAnB;;AAKA,MAAMC,MAAM,GAAGC,KAAK,IAAI;AACtB,QAAM;AAACH,IAAAA,KAAD;AAAQT,IAAAA,KAAR;AAAeU,IAAAA;AAAf,MAAuBE,KAA7B;AAEA,sBACE;AAAK,iBAAU,QAAf;AAAwB,IAAA,SAAS,EAAEnB,KAAK,CAACoB;AAAzC,KACGb,KAAK,gBAAG,oBAAC,SAAD;AAAW,IAAA,KAAK,EAAEA;AAAlB,IAAH,GAAiC,IADzC,eAEE,oBAAC,MAAD;AAAQ,IAAA,KAAK,EAAES,KAAf;AAAsB,IAAA,IAAI,EAAEC;AAA5B,IAFF,CADF;AAMD,CATD;;AAWAC,MAAM,CAACjB,SAAP,2CAAmBA,SAAnB;AAEA,eAAeiB,MAAf","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"],"file":"index.js"}
|