@coorpacademy/components 10.22.4 → 10.22.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -5
- package/es/atom/choice/index.native.js +132 -0
- package/es/atom/choice/index.native.js.map +1 -0
- package/es/atom/gradient/index.native.js +46 -0
- package/es/atom/gradient/index.native.js.map +1 -0
- package/es/atom/html/index.native.js +9 -16
- package/es/atom/html/index.native.js.map +1 -1
- package/es/atom/image-background/index.native.js +90 -0
- package/es/atom/image-background/index.native.js.map +1 -0
- 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/build-query-string.js +9 -0
- package/es/util/build-query-string.js.map +1 -0
- package/es/util/get-clean-uri.js +4 -0
- package/es/util/get-clean-uri.js.map +1 -0
- package/es/util/get-resized-image.js +39 -0
- package/es/util/get-resized-image.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/es/variables/theme.native.js.map +1 -1
- package/lib/atom/choice/index.native.js +150 -0
- package/lib/atom/choice/index.native.js.map +1 -0
- package/lib/atom/gradient/index.native.js +56 -0
- package/lib/atom/gradient/index.native.js.map +1 -0
- package/lib/atom/html/index.native.js +8 -15
- package/lib/atom/html/index.native.js.map +1 -1
- package/lib/atom/image-background/index.native.js +105 -0
- package/lib/atom/image-background/index.native.js.map +1 -0
- 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/build-query-string.js +17 -0
- package/lib/util/build-query-string.js.map +1 -0
- package/lib/util/get-clean-uri.js +10 -0
- package/lib/util/get-clean-uri.js.map +1 -0
- package/lib/util/get-resized-image.js +49 -0
- package/lib/util/get-resized-image.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/lib/variables/theme.native.js.map +1 -1
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -99,7 +99,7 @@ Among the Lottie Atom's props, there are two *important* props: animationSrc & i
|
|
|
99
99
|
that need an additional step, the ie11ImageBackup is needed as it's name implies because ie11 doesn't
|
|
100
100
|
support Lottie (more specifically Web Components due to the Shadow DOM).
|
|
101
101
|
|
|
102
|
-
First, you must upload to AWS S3 any new animation, in one of the static buckets (depending on the desired env), ex:
|
|
102
|
+
First, you must upload to AWS S3 any new animation, in one of the static buckets (depending on the desired env), ex:
|
|
103
103
|
`https://static-staging.coorpacademy.com/animations/review/`.
|
|
104
104
|
|
|
105
105
|
This animation must be paired with a backup image (svg) that'll be used for the ie11 scenario.
|
|
@@ -144,7 +144,6 @@ const props = {
|
|
|
144
144
|
|
|
145
145
|
The props include classNames && size control to handle additional styling.
|
|
146
146
|
|
|
147
|
-
|
|
148
147
|
## Locally use in an external project
|
|
149
148
|
|
|
150
149
|
Link your dependencies:
|
|
@@ -160,13 +159,20 @@ Build modifications:
|
|
|
160
159
|
[@coorpacademy-components] > npm run build:es
|
|
161
160
|
```
|
|
162
161
|
|
|
163
|
-
|
|
164
162
|
## Use in mobile app
|
|
163
|
+
|
|
165
164
|
Run `npm run build:watch`
|
|
166
|
-
For more info see the mobile
|
|
165
|
+
For more info see the [mobile documentation](https://github.com/CoorpAcademy/mobile/blob/master/docs/local-sync.md)
|
|
166
|
+
|
|
167
|
+
You may need to install these optional libs depending on which native components you use:
|
|
168
|
+
|
|
169
|
+
- `color`
|
|
170
|
+
- `react-native-modal`
|
|
171
|
+
- `react-native-render-html`
|
|
172
|
+
- `react-native-linear-gradient`
|
|
167
173
|
|
|
168
174
|
## Troubleshooting
|
|
169
175
|
|
|
170
176
|
Error when trying to launch the storybook:
|
|
171
177
|
|
|
172
|
-
Try to delete your ```node_modules```, go to the project's root and launch: ```yarn && yarn bootstrap```
|
|
178
|
+
Try to delete your ```node_modules```, go to the project's root and launch: ```yarn && yarn bootstrap```
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import { View, StyleSheet } from 'react-native';
|
|
3
|
+
import Html from '../html/index.native';
|
|
4
|
+
import ImageBackground from '../image-background/index.native';
|
|
5
|
+
import getCleanUri from '../../util/get-clean-uri';
|
|
6
|
+
import Touchable from '../../hoc/touchable/index.native';
|
|
7
|
+
import { useTemplateContext } from '../../template/app-review/template-context';
|
|
8
|
+
|
|
9
|
+
const createStyleSheet = theme => StyleSheet.create({
|
|
10
|
+
boxShadow: {
|
|
11
|
+
shadowColor: '#000',
|
|
12
|
+
shadowOffset: {
|
|
13
|
+
width: 0,
|
|
14
|
+
height: 4
|
|
15
|
+
},
|
|
16
|
+
shadowOpacity: 0.12,
|
|
17
|
+
shadowRadius: 16,
|
|
18
|
+
elevation: 8,
|
|
19
|
+
backgroundColor: '#0000'
|
|
20
|
+
},
|
|
21
|
+
container: {
|
|
22
|
+
minHeight: 80,
|
|
23
|
+
backgroundColor: theme.colors.white,
|
|
24
|
+
borderRadius: theme.radius.regular,
|
|
25
|
+
overflow: 'hidden',
|
|
26
|
+
flexDirection: 'row',
|
|
27
|
+
alignItems: 'stretch'
|
|
28
|
+
},
|
|
29
|
+
textContainer: {
|
|
30
|
+
paddingHorizontal: 24,
|
|
31
|
+
paddingVertical: 12,
|
|
32
|
+
justifyContent: 'center',
|
|
33
|
+
alignItems: 'center',
|
|
34
|
+
flex: 1
|
|
35
|
+
},
|
|
36
|
+
squeezedTextContainer: {
|
|
37
|
+
padding: theme.spacing.small,
|
|
38
|
+
paddingLeft: undefined,
|
|
39
|
+
paddingVertical: undefined,
|
|
40
|
+
paddingRight: undefined,
|
|
41
|
+
flex: 0
|
|
42
|
+
},
|
|
43
|
+
text: {
|
|
44
|
+
fontWeight: theme.fontWeight.bold,
|
|
45
|
+
color: theme.colors.black
|
|
46
|
+
},
|
|
47
|
+
textSelected: {
|
|
48
|
+
color: theme.colors.white
|
|
49
|
+
},
|
|
50
|
+
unselectedImageContainer: {
|
|
51
|
+
borderRightColor: theme.colors.border
|
|
52
|
+
},
|
|
53
|
+
imageContainer: {
|
|
54
|
+
height: '100%',
|
|
55
|
+
width: '25%'
|
|
56
|
+
},
|
|
57
|
+
image: {
|
|
58
|
+
flex: 1
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
const Choice = ({
|
|
63
|
+
children,
|
|
64
|
+
isSelected = false,
|
|
65
|
+
squeezed = false,
|
|
66
|
+
isDisabled,
|
|
67
|
+
onPress,
|
|
68
|
+
media,
|
|
69
|
+
testID: prefixTestID,
|
|
70
|
+
style,
|
|
71
|
+
questionType
|
|
72
|
+
}) => {
|
|
73
|
+
const templateContext = useTemplateContext();
|
|
74
|
+
const {
|
|
75
|
+
theme,
|
|
76
|
+
brandTheme
|
|
77
|
+
} = templateContext;
|
|
78
|
+
const [styleSheet, setStylesheet] = useState(null);
|
|
79
|
+
useEffect(() => {
|
|
80
|
+
const _stylesheet = createStyleSheet(theme);
|
|
81
|
+
|
|
82
|
+
setStylesheet(_stylesheet);
|
|
83
|
+
}, [theme]);
|
|
84
|
+
|
|
85
|
+
if (!styleSheet) {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const selectedStyle = brandTheme && {
|
|
90
|
+
backgroundColor: brandTheme.colors.primary,
|
|
91
|
+
borderColor: brandTheme.colors.primary,
|
|
92
|
+
borderRadius: theme.radius.common
|
|
93
|
+
};
|
|
94
|
+
const selectedSuffix = prefixTestID && isSelected ? '-selected' : '';
|
|
95
|
+
const mediaType = media && media.type && media.type === 'img' && media.type.toLowerCase();
|
|
96
|
+
const url = media && media.type === 'img' && media.src && media.src.length > 0 && getCleanUri(media.src[0].url);
|
|
97
|
+
const source = {
|
|
98
|
+
uri: url ? getCleanUri(url) : undefined
|
|
99
|
+
};
|
|
100
|
+
const mediaSuffix = prefixTestID && mediaType ? `-${mediaType}` : '';
|
|
101
|
+
const htmlStyle = [styleSheet.text];
|
|
102
|
+
|
|
103
|
+
if (isSelected) {
|
|
104
|
+
htmlStyle.push(styleSheet.textSelected);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return /*#__PURE__*/React.createElement(Touchable, {
|
|
108
|
+
onPress: !isDisabled ? onPress : undefined,
|
|
109
|
+
style: style,
|
|
110
|
+
analyticsID: "question-choice",
|
|
111
|
+
analyticsParams: {
|
|
112
|
+
questionType
|
|
113
|
+
}
|
|
114
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
115
|
+
style: [styleSheet.boxShadow, styleSheet.container],
|
|
116
|
+
testID: prefixTestID && `${prefixTestID}${selectedSuffix}`
|
|
117
|
+
}, url ? /*#__PURE__*/React.createElement(View, {
|
|
118
|
+
style: styleSheet.imageContainer
|
|
119
|
+
}, /*#__PURE__*/React.createElement(ImageBackground, {
|
|
120
|
+
testID: prefixTestID && `${prefixTestID}${mediaSuffix}`,
|
|
121
|
+
source: source,
|
|
122
|
+
style: styleSheet.image
|
|
123
|
+
})) : null, /*#__PURE__*/React.createElement(View, {
|
|
124
|
+
style: [styleSheet.textContainer, squeezed && styleSheet.squeezedTextContainer, isSelected && selectedStyle]
|
|
125
|
+
}, /*#__PURE__*/React.createElement(Html, {
|
|
126
|
+
fontSize: squeezed ? theme.fontSize.medium : theme.fontSize.regular,
|
|
127
|
+
style: htmlStyle
|
|
128
|
+
}, children))));
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
export default Choice;
|
|
132
|
+
//# sourceMappingURL=index.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/atom/choice/index.native.tsx"],"names":["React","useEffect","useState","View","StyleSheet","Html","ImageBackground","getCleanUri","Touchable","useTemplateContext","createStyleSheet","theme","create","boxShadow","shadowColor","shadowOffset","width","height","shadowOpacity","shadowRadius","elevation","backgroundColor","container","minHeight","colors","white","borderRadius","radius","regular","overflow","flexDirection","alignItems","textContainer","paddingHorizontal","paddingVertical","justifyContent","flex","squeezedTextContainer","padding","spacing","small","paddingLeft","undefined","paddingRight","text","fontWeight","bold","color","black","textSelected","unselectedImageContainer","borderRightColor","border","imageContainer","image","Choice","children","isSelected","squeezed","isDisabled","onPress","media","testID","prefixTestID","style","questionType","templateContext","brandTheme","styleSheet","setStylesheet","_stylesheet","selectedStyle","primary","borderColor","common","selectedSuffix","mediaType","type","toLowerCase","url","src","length","source","uri","mediaSuffix","htmlStyle","push","fontSize","medium"],"mappings":"AAAA,OAAOA,KAAP,IAAeC,SAAf,EAA0BC,QAA1B,QAAyC,OAAzC;AACA,SAAQC,IAAR,EAAcC,UAAd,QAA0C,cAA1C;AAGA,OAAOC,IAAP,MAAiB,sBAAjB;AACA,OAAOC,eAAP,MAA4B,kCAA5B;AACA,OAAOC,WAAP,MAAwB,0BAAxB;AACA,OAAOC,SAAP,MAAsB,kCAAtB;AACA,SAAQC,kBAAR,QAAiC,4CAAjC;;AA2BA,MAAMC,gBAAgB,GAAIC,KAAD,IACvBP,UAAU,CAACQ,MAAX,CAAkB;AAChBC,EAAAA,SAAS,EAAE;AACTC,IAAAA,WAAW,EAAE,MADJ;AAETC,IAAAA,YAAY,EAAE;AAACC,MAAAA,KAAK,EAAE,CAAR;AAAWC,MAAAA,MAAM,EAAE;AAAnB,KAFL;AAGTC,IAAAA,aAAa,EAAE,IAHN;AAITC,IAAAA,YAAY,EAAE,EAJL;AAKTC,IAAAA,SAAS,EAAE,CALF;AAMTC,IAAAA,eAAe,EAAE;AANR,GADK;AAShBC,EAAAA,SAAS,EAAE;AACTC,IAAAA,SAAS,EAAE,EADF;AAETF,IAAAA,eAAe,EAAEV,KAAK,CAACa,MAAN,CAAaC,KAFrB;AAGTC,IAAAA,YAAY,EA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AAeC,MAAlB,GAA2B7E,KAAK,CAAC4E,QAAN,CAAe3D,OAD9D;AAEE,IAAA,KAAK,EAAEyD;AAFT,KAIG7B,QAJH,CAPF,CAbF,CANF,CADF;AAqCD,CAtFD;;AAwFA,eAAeD,MAAf","sourcesContent":["import React, {useEffect, useState} from 'react';\nimport {View, StyleSheet, ViewStyle} from 'react-native';\nimport type {Media, QuestionType} from '../../types/progression-engine';\n\nimport Html from '../html/index.native';\nimport ImageBackground from '../image-background/index.native';\nimport getCleanUri from '../../util/get-clean-uri';\nimport Touchable from '../../hoc/touchable/index.native';\nimport {useTemplateContext} from '../../template/app-review/template-context';\nimport {Theme} from '../../variables/theme.native';\n\nexport type Props = {\n isSelected?: boolean;\n onPress: () => void;\n children: string;\n isDisabled?: boolean;\n testID?: string;\n media?: Media;\n squeezed?: boolean;\n style?: ViewStyle;\n questionType: QuestionType;\n};\n\ntype StyleSheetType = {\n boxShadow: any;\n container: any;\n text: any;\n textSelected: any;\n textContainer: any;\n squeezedTextContainer: any;\n unselectedImageContainer: any;\n imageContainer: any;\n image: any;\n};\n\nconst createStyleSheet = (theme: Theme): StyleSheetType =>\n StyleSheet.create({\n boxShadow: {\n shadowColor: '#000',\n shadowOffset: {width: 0, height: 4},\n shadowOpacity: 0.12,\n shadowRadius: 16,\n elevation: 8,\n backgroundColor: '#0000'\n },\n container: {\n minHeight: 80,\n backgroundColor: theme.colors.white,\n borderRadius: theme.radius.regular,\n overflow: 'hidden',\n flexDirection: 'row',\n alignItems: 'stretch'\n },\n textContainer: {\n paddingHorizontal: 24,\n paddingVertical: 12,\n justifyContent: 'center',\n alignItems: 'center',\n flex: 1\n },\n squeezedTextContainer: {\n padding: theme.spacing.small,\n paddingLeft: undefined,\n paddingVertical: undefined,\n paddingRight: undefined,\n flex: 0\n },\n text: {\n fontWeight: theme.fontWeight.bold,\n color: theme.colors.black\n },\n textSelected: {\n color: theme.colors.white\n },\n unselectedImageContainer: {\n borderRightColor: theme.colors.border\n },\n imageContainer: {\n height: '100%',\n width: '25%'\n },\n image: {\n flex: 1\n }\n });\n\nconst Choice = ({\n children,\n isSelected = false,\n squeezed = false,\n isDisabled,\n onPress,\n media,\n testID: prefixTestID,\n style,\n questionType\n}: Props) => {\n const templateContext = useTemplateContext();\n const {theme, brandTheme} = templateContext;\n\n const [styleSheet, setStylesheet] = useState<StyleSheetType | null>(null);\n\n useEffect(() => {\n const _stylesheet = createStyleSheet(theme);\n setStylesheet(_stylesheet);\n }, [theme]);\n\n if (!styleSheet) {\n return null;\n }\n\n const selectedStyle = brandTheme && {\n backgroundColor: brandTheme.colors.primary,\n borderColor: brandTheme.colors.primary,\n borderRadius: theme.radius.common\n };\n\n const selectedSuffix = prefixTestID && isSelected ? '-selected' : '';\n const mediaType = media && media.type && media.type === 'img' && media.type.toLowerCase();\n const url =\n media &&\n media.type === 'img' &&\n media.src &&\n media.src.length > 0 &&\n getCleanUri(media.src[0].url);\n\n const source = {uri: url ? getCleanUri(url) : undefined};\n const mediaSuffix = prefixTestID && mediaType ? `-${mediaType}` : '';\n\n const htmlStyle: ViewStyle[] = [styleSheet.text];\n\n if (isSelected) {\n htmlStyle.push(styleSheet.textSelected);\n }\n\n return (\n <Touchable\n onPress={!isDisabled ? onPress : undefined}\n style={style}\n analyticsID=\"question-choice\"\n analyticsParams={{questionType}}\n >\n <View\n style={[styleSheet.boxShadow, styleSheet.container]}\n testID={prefixTestID && `${prefixTestID}${selectedSuffix}`}\n >\n {url ? (\n <View style={styleSheet.imageContainer}>\n <ImageBackground\n testID={prefixTestID && `${prefixTestID}${mediaSuffix}`}\n source={source}\n style={styleSheet.image}\n />\n </View>\n ) : null}\n <View\n style={[\n styleSheet.textContainer,\n squeezed && styleSheet.squeezedTextContainer,\n isSelected && selectedStyle\n ]}\n >\n <Html\n fontSize={squeezed ? theme.fontSize.medium : theme.fontSize.regular}\n style={htmlStyle}\n >\n {children}\n </Html>\n </View>\n </View>\n </Touchable>\n );\n};\n\nexport default Choice;\n"],"file":"index.native.js"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import LinearGradient from 'react-native-linear-gradient';
|
|
3
|
+
import Color from 'color';
|
|
4
|
+
|
|
5
|
+
const Gradient = ({
|
|
6
|
+
children,
|
|
7
|
+
colors,
|
|
8
|
+
transparencyPosition = 'top',
|
|
9
|
+
height,
|
|
10
|
+
style,
|
|
11
|
+
testID,
|
|
12
|
+
pointerEvents
|
|
13
|
+
}) => {
|
|
14
|
+
let calculatedColors = colors;
|
|
15
|
+
|
|
16
|
+
if (colors.length === 1) {
|
|
17
|
+
const {
|
|
18
|
+
r,
|
|
19
|
+
g,
|
|
20
|
+
b
|
|
21
|
+
} = Color(colors[0]).object();
|
|
22
|
+
calculatedColors = transparencyPosition === 'top' ? [`rgba(${r}, ${g}, ${b}, 0)`, colors[0], colors[0]] : [colors[0], colors[0], `rgba(${r}, ${g}, ${b}, 0)`];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const _style = [];
|
|
26
|
+
|
|
27
|
+
if (style) {
|
|
28
|
+
_style.push(style);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (height) {
|
|
32
|
+
_style.push({
|
|
33
|
+
height
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return /*#__PURE__*/React.createElement(LinearGradient, {
|
|
38
|
+
colors: calculatedColors,
|
|
39
|
+
style: _style,
|
|
40
|
+
pointerEvents: pointerEvents,
|
|
41
|
+
testID: testID
|
|
42
|
+
}, children);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export default Gradient;
|
|
46
|
+
//# sourceMappingURL=index.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/atom/gradient/index.native.tsx"],"names":["React","LinearGradient","Color","Gradient","children","colors","transparencyPosition","height","style","testID","pointerEvents","calculatedColors","length","r","g","b","object","_style","push"],"mappings":"AAAA,OAAOA,KAAP,MAA+B,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,QAAf","sourcesContent":["import React, {ReactNode} from 'react';\nimport {ViewStyle} from 'react-native';\nimport LinearGradient from 'react-native-linear-gradient';\nimport Color from 'color';\n\nexport type Props = {\n children?: ReactNode;\n colors: Array<string>;\n transparencyPosition?: 'top' | 'bottom';\n height?: number;\n style?: ViewStyle | ViewStyle[] | undefined;\n testID?: string;\n pointerEvents?: 'auto' | 'none' | 'box-none' | 'box-only' | undefined;\n};\n\nconst Gradient = ({\n children,\n colors,\n transparencyPosition = 'top',\n height,\n style,\n testID,\n pointerEvents\n}: Props) => {\n let calculatedColors = colors;\n if (colors.length === 1) {\n const {r, g, b} = Color(colors[0]).object();\n calculatedColors =\n transparencyPosition === 'top'\n ? [`rgba(${r}, ${g}, ${b}, 0)`, colors[0], colors[0]]\n : [colors[0], colors[0], `rgba(${r}, ${g}, ${b}, 0)`];\n }\n\n const _style = [];\n\n if (style) {\n _style.push(style);\n }\n if (height) {\n _style.push({height});\n }\n\n return (\n <LinearGradient\n colors={calculatedColors}\n style={_style}\n pointerEvents={pointerEvents}\n testID={testID}\n >\n {children}\n </LinearGradient>\n );\n};\n\nexport default Gradient;\n"],"file":"index.native.js"}
|
|
@@ -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,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AA,gBAAD;AAAmBC,MAAAA;AAAnB,KAJI,EAKJ;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: TextStyle['fontSize'];\n numberOfLines?: number;\n onLinkPress?: (url: string) => void;\n containerStyle?: ViewStyle;\n anchorTextColor?: string;\n imageStyle?: ImageStyle;\n style?: ViewStyle | ViewStyle[];\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"}
|
|
@@ -0,0 +1,90 @@
|
|
|
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
|
+
|
|
3
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { ImageBackground as ImageBackgroundBase, StyleSheet } from 'react-native';
|
|
7
|
+
import getCleanUri from '../../util/get-clean-uri';
|
|
8
|
+
import getResizedImage from '../../util/get-resized-image';
|
|
9
|
+
import Gradient from '../gradient/index.native';
|
|
10
|
+
const styles = StyleSheet.create({
|
|
11
|
+
image: {
|
|
12
|
+
width: '100%',
|
|
13
|
+
height: '100%'
|
|
14
|
+
},
|
|
15
|
+
gradient: {
|
|
16
|
+
flex: 1
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const ImageBackground = (_ref) => {
|
|
21
|
+
let {
|
|
22
|
+
source,
|
|
23
|
+
gradient,
|
|
24
|
+
gradientStyle,
|
|
25
|
+
style,
|
|
26
|
+
testID = 'image-background'
|
|
27
|
+
} = _ref,
|
|
28
|
+
props = _objectWithoutPropertiesLoose(_ref, ["source", "gradient", "gradientStyle", "style", "testID"]);
|
|
29
|
+
|
|
30
|
+
// @ts-ignore this statement is enough but type is too weak
|
|
31
|
+
let uri = source && source.uri;
|
|
32
|
+
|
|
33
|
+
if (uri) {
|
|
34
|
+
const {
|
|
35
|
+
width: _width,
|
|
36
|
+
height: _height,
|
|
37
|
+
resizeMode
|
|
38
|
+
} = props;
|
|
39
|
+
const {
|
|
40
|
+
width,
|
|
41
|
+
height
|
|
42
|
+
} = StyleSheet.flatten([{
|
|
43
|
+
width: _width,
|
|
44
|
+
height: _height
|
|
45
|
+
}, style]);
|
|
46
|
+
const maxHeight = typeof height === 'number' ? height : undefined;
|
|
47
|
+
const maxWidth = typeof width === 'number' ? width : undefined;
|
|
48
|
+
uri = getResizedImage(getCleanUri(uri), {
|
|
49
|
+
maxHeight,
|
|
50
|
+
maxWidth,
|
|
51
|
+
resizeMode
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const resizedSource = uri && {
|
|
56
|
+
uri
|
|
57
|
+
} || source;
|
|
58
|
+
|
|
59
|
+
if (gradient) {
|
|
60
|
+
const {
|
|
61
|
+
children
|
|
62
|
+
} = props,
|
|
63
|
+
remainingProps = _objectWithoutPropertiesLoose(props, ["children"]);
|
|
64
|
+
|
|
65
|
+
const _style = [styles.gradient];
|
|
66
|
+
|
|
67
|
+
if (gradientStyle) {
|
|
68
|
+
_style.push(gradientStyle);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return /*#__PURE__*/React.createElement(ImageBackgroundBase, _extends({}, remainingProps, {
|
|
72
|
+
source: resizedSource,
|
|
73
|
+
style: [styles.image, style],
|
|
74
|
+
testID: testID
|
|
75
|
+
}), /*#__PURE__*/React.createElement(Gradient, {
|
|
76
|
+
testID: `${testID}-gradient`,
|
|
77
|
+
colors: gradient,
|
|
78
|
+
style: _style
|
|
79
|
+
}, children));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return /*#__PURE__*/React.createElement(ImageBackgroundBase, _extends({}, props, {
|
|
83
|
+
source: resizedSource,
|
|
84
|
+
style: [styles.image, style],
|
|
85
|
+
testID: testID
|
|
86
|
+
}));
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export default ImageBackground;
|
|
90
|
+
//# sourceMappingURL=index.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/atom/image-background/index.native.tsx"],"names":["React","ImageBackground","ImageBackgroundBase","StyleSheet","getCleanUri","getResizedImage","Gradient","styles","create","image","width","height","gradient","flex","source","gradientStyle","style","testID","props","uri","_width","_height","resizeMode","flatten","maxHeight","undefined","maxWidth","resizedSource","children","remainingProps","_style","push"],"mappings":";;;;AAAA,OAAOA,KAAP,MAA+B,OAA/B;AACA,SACEC,eAAe,IAAIC,mBADrB,EAEEC,UAFF,QAKO,cALP;AAOA,OAAOC,WAAP,MAAwB,0BAAxB;AAEA,OAAOC,eAAP,MAA4B,8BAA5B;AACA,OAAOC,QAAP,MAAqB,0BAArB;AAEA,MAAMC,MAAM,GAAGJ,UAAU,CAACK,MAAX,CAAkB;AAC/BC,EAAAA,KAAK,EAAE;AACLC,IAAAA,KAAK,EAAE,MADF;AAELC,IAAAA,MAAM,EAAE;AAFH,GADwB;AAK/BC,EAAAA,QAAQ,EAAE;AACRC,IAAAA,IAAI,EAAE;AADE;AALqB,CAAlB,CAAf;;AAmBA,MAAMZ,eAAe,GAAG,UAOX;AAAA,MAPY;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AC,mBAAD,eACMc,cADN;AAEE,MAAA,MAAM,EAAEF,aAFV;AAGE,MAAA,KAAK,EAAE,CAACpB,MAAM,CAACE,KAAR,EAAeO,KAAf,CAHT;AAIE,MAAA,MAAM,EAAEC;AAJV,qBAME,oBAAC,QAAD;AAAU,MAAA,MAAM,EAAG,GAAEA,MAAO,WAA5B;AAAwC,MAAA,MAAM,EAAEL,QAAhD;AAA0D,MAAA,KAAK,EAAEkB;AAAjE,OACGF,QADH,CANF,CADF;AAYD;;AAED,sBACE,oBAAC,mBAAD,eACMV,KADN;AAEE,IAAA,MAAM,EAAES,aAFV;AAGE,IAAA,KAAK,EAAE,CAACpB,MAAM,CAACE,KAAR,EAAeO,KAAf,CAHT;AAIE,IAAA,MAAM,EAAEC;AAJV,KADF;AAQD,CAxDD;;AA0DA,eAAehB,eAAf","sourcesContent":["import React, {ReactNode} from 'react';\nimport {\n ImageBackground as ImageBackgroundBase,\n StyleSheet,\n ViewStyle,\n ImageStyle\n} from 'react-native';\n\nimport getCleanUri from '../../util/get-clean-uri';\n\nimport getResizedImage from '../../util/get-resized-image';\nimport Gradient from '../gradient/index.native';\n\nconst styles = StyleSheet.create({\n image: {\n width: '100%',\n height: '100%'\n },\n gradient: {\n flex: 1\n }\n});\n\nexport type Props = ImageStyle & {\n children?: ReactNode;\n gradient?: Array<string>;\n gradientStyle?: ViewStyle;\n testID?: string;\n source: {uri: string | undefined};\n style?: ViewStyle;\n};\n\nconst ImageBackground = ({\n source,\n gradient,\n gradientStyle,\n style,\n testID = 'image-background',\n ...props\n}: Props) => {\n // @ts-ignore this statement is enough but type is too weak\n let uri: string | undefined = source && source.uri;\n\n if (uri) {\n const {width: _width, height: _height, resizeMode} = props;\n const {width, height} = StyleSheet.flatten([{width: _width, height: _height}, style]);\n const maxHeight: number | undefined = typeof height === 'number' ? height : undefined;\n const maxWidth: number | undefined = typeof width === 'number' ? width : undefined;\n\n uri = getResizedImage(getCleanUri(uri), {\n maxHeight,\n maxWidth,\n resizeMode\n });\n }\n\n const resizedSource = (uri && {uri}) || source;\n\n if (gradient) {\n const {children, ...remainingProps} = props;\n const _style: ViewStyle[] = [styles.gradient];\n\n if (gradientStyle) {\n _style.push(gradientStyle);\n }\n\n return (\n <ImageBackgroundBase\n {...remainingProps}\n source={resizedSource}\n style={[styles.image, style]}\n testID={testID}\n >\n <Gradient testID={`${testID}-gradient`} colors={gradient} style={_style}>\n {children}\n </Gradient>\n </ImageBackgroundBase>\n );\n }\n\n return (\n <ImageBackgroundBase\n {...props}\n source={resizedSource}\n style={[styles.image, style]}\n testID={testID}\n />\n );\n};\n\nexport default ImageBackground;\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;AAWJC,IAAAA,OAAO,GAAG,EAXN;AAYJC,IAAAA,iBAAiB,GAAG;AAZhB,MAaFZ,KAbJ;;AAeA,QAAMa,QAAQ,GAAGV,EAAE,IAAI,UAAS,eAAT,CAAvB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AAV,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"}
|