@fto-consult/expo-ui 5.5.0 → 5.6.0
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/bin/init.js +1 -1
- package/package.json +4 -4
- package/src/components/AppBar/utils.js +1 -0
- package/src/components/BottomSheet/Menu.js +8 -10
- package/src/components/Button/index.js +54 -56
- package/src/components/Datagrid/IndexComponent.js +0 -3
- package/src/components/Dialog/DialogActions.js +3 -2
- package/src/components/Dialog/RNPDialogActions.js +53 -0
- package/src/components/Dialog/confirm/showConfirmOrAlertOrPrompt.js +3 -1
- package/src/components/Form/Fields/SelectTableData/Component.js +0 -1
- package/src/components/Icon/Font.js +3 -3
- package/src/components/Icon/Icon.js +3 -1
- package/src/components/Icon/IconButton.js +3 -2
- package/src/components/Link/Browser.js +1 -1
- package/src/components/Link/getUrlCallback.js +1 -1
- package/src/components/Menu/Menu.js +7 -5
- package/src/components/Modal/index.js +0 -1
- package/src/components/StatusBar/Component/index.web.js +1 -1
- package/src/components/Tooltip/Popover/index.web.js +2 -2
- package/src/components/Tooltip/index.js +0 -1
- package/src/components/WebView/index.js +1 -1
- package/src/index.js +2 -2
- package/src/components/Dialog/confirm/Alert/Alert.old/Alert.web.js +0 -360
- package/src/components/Dialog/confirm/Alert/Alert.old/index.js +0 -2
package/bin/init.js
CHANGED
|
@@ -31,8 +31,8 @@ module.exports = ({
|
|
|
31
31
|
"package" : "npx expo-ui electron package",
|
|
32
32
|
"compile2package" : "npx expo-ui electron package compile"
|
|
33
33
|
}
|
|
34
|
+
projectRootPackage.name = projectRootPackage.name.trim().toUpperCase();
|
|
34
35
|
projectRootPackage.realAppName = typeof projectRootPackage.realAppName =="string" && projectRootPackage.realAppName || projectRootPackage.name;
|
|
35
|
-
projectRootPackage.name = projectRootPackage.name.trim();
|
|
36
36
|
if(!projectRootPackage.name.endsWith(appSuffix)){
|
|
37
37
|
projectRootPackage.name +=appSuffix;
|
|
38
38
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fto-consult/expo-ui",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.6.0",
|
|
4
4
|
"description": "Bibliothèque de composants UI Expo,react-native",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"@emotion/native": "^11.10.0",
|
|
62
62
|
"@expo/html-elements": "^0.2.0",
|
|
63
63
|
"@expo/vector-icons": "^13.0.0",
|
|
64
|
-
"@fto-consult/common": "^3.
|
|
64
|
+
"@fto-consult/common": "^3.8.11",
|
|
65
65
|
"@gorhom/portal": "^1.0.14",
|
|
66
66
|
"@react-native-async-storage/async-storage": "^1.17.11",
|
|
67
67
|
"@react-native-community/datetimepicker": "^6.7.3",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"@react-navigation/native": "^6.1.1",
|
|
71
71
|
"@react-navigation/native-stack": "^6.9.7",
|
|
72
72
|
"@shopify/flash-list": "^1.4.0",
|
|
73
|
-
"expo": "^48.0.
|
|
73
|
+
"expo": "^48.0.9",
|
|
74
74
|
"expo-camera": "~13.2.1",
|
|
75
75
|
"expo-clipboard": "~4.1.1",
|
|
76
76
|
"expo-font": "~11.1.1",
|
|
@@ -84,7 +84,6 @@
|
|
|
84
84
|
"fs-extra": "^11.1.0",
|
|
85
85
|
"google-libphonenumber": "^3.2.31",
|
|
86
86
|
"htmlparser2-without-node-native": "^3.9.2",
|
|
87
|
-
"mongo-parse": "^2.1.0",
|
|
88
87
|
"process": "^0.11.10",
|
|
89
88
|
"prop-types": "^15.8.1",
|
|
90
89
|
"react": "^18.2.0",
|
|
@@ -95,6 +94,7 @@
|
|
|
95
94
|
"react-native-big-list": "^1.6.0",
|
|
96
95
|
"react-native-blob-util": "^0.17.0",
|
|
97
96
|
"react-native-gesture-handler": "~2.9.0",
|
|
97
|
+
"react-native-iphone-x-helper": "^1.3.1",
|
|
98
98
|
"react-native-mime-types": "^2.3.0",
|
|
99
99
|
"react-native-paper": "^5.4.1",
|
|
100
100
|
"react-native-paper-dates": "^0.15.1",
|
|
@@ -26,6 +26,7 @@ const renderAction = ({action,isAlert,actionProps,opts,isAppBarAction,isAppBarAc
|
|
|
26
26
|
rest = Object.assign({},rest);
|
|
27
27
|
rest.accessibilityLabel = defaultStr(rest.accessibilityLabel,rest.title,rest.text,rest.label,rest.children);
|
|
28
28
|
const color = theme.colors.primaryText;
|
|
29
|
+
|
|
29
30
|
rest.style = {...defaultObj(StyleSheet.flatten(actionProps.style)),elevation:0,...defaultObj(StyleSheet.flatten(rest.style))};
|
|
30
31
|
if(isAppBarActionStyle !== false && (isAppBarAction || opts.isAppBarAction)){
|
|
31
32
|
rest.color = defaultVal(color);
|
|
@@ -6,6 +6,7 @@ import {defaultObj,defaultDecimal,defaultStr,isDecimal,defaultBool} from "$utils
|
|
|
6
6
|
import View from "$ecomponents/View";
|
|
7
7
|
import PropTypes from "prop-types";
|
|
8
8
|
import {getContentHeight} from "./utils";
|
|
9
|
+
import Dimensions from "$dimensions";
|
|
9
10
|
|
|
10
11
|
const BottomSheetMenuComponent = React.forwardRef((props,ref)=>{
|
|
11
12
|
let {anchor,anchorProps,screenIndent,height:customHeight,bindResizeEvent,onDismiss,testID,visible:customVisible,controlled,mobile,animateOnClose,renderMenuContent,sheet,children,...rest} = props;
|
|
@@ -15,24 +16,22 @@ const BottomSheetMenuComponent = React.forwardRef((props,ref)=>{
|
|
|
15
16
|
visible : false,
|
|
16
17
|
height : undefined,
|
|
17
18
|
});
|
|
19
|
+
const [key,setKey] = React.useState(false);
|
|
18
20
|
const visible = isControlled ? customVisible : state.visible;
|
|
19
21
|
let height = state.height;
|
|
20
22
|
const isMounted = React.useIsMounted();
|
|
21
23
|
const anchorRef = React.useRef(null);
|
|
22
|
-
const
|
|
23
|
-
let isMob = isMobile();
|
|
24
|
+
const isMob = mobile || sheet === true || renderMenuContent === false || Dimensions.isMobileOrTabletMedia() ? true : false;
|
|
24
25
|
testID = defaultStr(testID,'RN_BottomSheetMenuComponent');
|
|
25
26
|
const innerRef = React.useRef(null);
|
|
26
27
|
const open = (event)=>{
|
|
27
|
-
if(!isMobile()) return;
|
|
28
28
|
React.stopEventPropagation(event);
|
|
29
|
-
if(!isMounted()
|
|
29
|
+
if(!isMounted()) return;
|
|
30
30
|
getContentHeight(anchorRef,({height})=>{
|
|
31
31
|
setState({...state,visible:true,height});
|
|
32
32
|
},screenIndent);
|
|
33
|
-
}, close = (
|
|
34
|
-
if(
|
|
35
|
-
if(!isMounted() || (force !== true && !visible)) return;
|
|
33
|
+
}, close = ()=>{
|
|
34
|
+
if(!isMounted()) return;
|
|
36
35
|
if(isControlled){
|
|
37
36
|
if(onDismiss){
|
|
38
37
|
onDismiss({});
|
|
@@ -79,7 +78,7 @@ const BottomSheetMenuComponent = React.forwardRef((props,ref)=>{
|
|
|
79
78
|
React.useEffect(()=>{
|
|
80
79
|
const closeModal = ()=>{
|
|
81
80
|
if(!isMounted()) return;
|
|
82
|
-
|
|
81
|
+
setKey(!key);
|
|
83
82
|
}
|
|
84
83
|
if(bindResizeEvent !== false){
|
|
85
84
|
APP.on(APP.EVENTS.RESIZE_PAGE,closeModal);
|
|
@@ -98,7 +97,7 @@ const BottomSheetMenuComponent = React.forwardRef((props,ref)=>{
|
|
|
98
97
|
{isMob && React.isValidElement(anchor)? anchor : null}
|
|
99
98
|
<Component
|
|
100
99
|
{...rest}
|
|
101
|
-
|
|
100
|
+
key = {isMob?"mobile":"desktop"}
|
|
102
101
|
testID = {testID}
|
|
103
102
|
height = {controlled?customHeight:height}
|
|
104
103
|
ref = {React.useMergeRefs(innerRef,ref)}
|
|
@@ -107,7 +106,6 @@ const BottomSheetMenuComponent = React.forwardRef((props,ref)=>{
|
|
|
107
106
|
children = {visible && (React.isValidElement(children) || Array.isArray(children))?children:undefined}
|
|
108
107
|
/>
|
|
109
108
|
</>
|
|
110
|
-
|
|
111
109
|
})
|
|
112
110
|
|
|
113
111
|
BottomSheetMenuComponent.propTypes = {
|
|
@@ -14,53 +14,54 @@ import Label from "$ecomponents/Label";
|
|
|
14
14
|
import {defaultObj,defaultVal,defaultDecimal,defaultStr} from "$utils";
|
|
15
15
|
|
|
16
16
|
import PropTypes from "prop-types";
|
|
17
|
-
const white = "white"
|
|
17
|
+
const white = "white";
|
|
18
18
|
|
|
19
|
-
const ButtonComponent = React.forwardRef(({
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
19
|
+
const ButtonComponent = React.forwardRef((prs,ref) => {
|
|
20
|
+
let {
|
|
21
|
+
disabled:customDisabled,
|
|
22
|
+
compact,
|
|
23
|
+
mode = 'text',
|
|
24
|
+
dark,
|
|
25
|
+
loading,
|
|
26
|
+
icon,
|
|
27
|
+
color: buttonColor,
|
|
28
|
+
children,
|
|
29
|
+
text,
|
|
30
|
+
label,
|
|
31
|
+
isCancelButton,
|
|
32
|
+
error,
|
|
33
|
+
upperCase = true,
|
|
34
|
+
accessibilityLabel,
|
|
35
|
+
onPress,
|
|
36
|
+
iconPosition,
|
|
37
|
+
iconBefore,
|
|
38
|
+
onLongPress,
|
|
39
|
+
style:customStyle,
|
|
40
|
+
contentStyle,
|
|
41
|
+
contentProps,
|
|
42
|
+
labelStyle,
|
|
43
|
+
labelProps,
|
|
44
|
+
testID,
|
|
45
|
+
iconSize,
|
|
46
|
+
iconProps,
|
|
47
|
+
left,
|
|
48
|
+
elevation : customElevation,
|
|
49
|
+
right,
|
|
50
|
+
accessible,
|
|
51
|
+
backgroundColor,
|
|
52
|
+
borderColor,
|
|
53
|
+
accessibilityRole,
|
|
54
|
+
contentContainerProps,
|
|
55
|
+
loadingProps,
|
|
56
|
+
rounded,
|
|
57
|
+
containerProps,
|
|
58
|
+
disableRipple,
|
|
59
|
+
noPadding,
|
|
60
|
+
noMargin,
|
|
61
|
+
isAlert,
|
|
62
|
+
borderRadius,
|
|
63
|
+
...rest
|
|
64
|
+
} = prs;
|
|
64
65
|
isCancelButton = isCancelButton || error && true || false;
|
|
65
66
|
children = defaultVal(children,label,text);
|
|
66
67
|
testID = defaultStr(testID,'RN_ButtonComponent');
|
|
@@ -140,25 +141,22 @@ const ButtonComponent = React.forwardRef(({
|
|
|
140
141
|
};
|
|
141
142
|
contentContainerProps = defaultObj(contentContainerProps);
|
|
142
143
|
containerProps = defaultObj(containerProps);
|
|
143
|
-
style =
|
|
144
|
+
const style = StyleSheet.flatten(customStyle) || {};
|
|
145
|
+
|
|
144
146
|
labelStyle = StyleSheet.flatten([labelStyle]);
|
|
145
147
|
const disabled = isDisabled || isLoading;
|
|
146
|
-
let textColor = Colors.isValid(
|
|
148
|
+
let textColor = Colors.isValid(style.color)? style.color : Colors.isValid(buttonColor)?buttonColor : isCancelButton? theme.colors.errorText : Colors.isValid(labelStyle.color) ? labelStyle.color : theme.colors.primary,
|
|
147
149
|
borderWidth;
|
|
148
150
|
const restButtonStyle = {
|
|
149
151
|
opacity : disabled ? DISABLED_OPACITY : undefined
|
|
150
|
-
|
|
151
|
-
|
|
152
|
+
};
|
|
153
|
+
|
|
152
154
|
iconProps = defaultObj(iconProps);
|
|
153
155
|
labelProps = defaultObj(labelProps);
|
|
154
156
|
contentProps = defaultObj(contentProps);
|
|
155
|
-
if(isCancelButton){
|
|
156
|
-
style.backgroundColor = theme.colors.error;
|
|
157
|
-
style.color = theme.styles.errorText ;
|
|
158
|
-
}
|
|
159
157
|
if (!disabled && hasElevation) {
|
|
160
|
-
backgroundColor = Colors.isValid(backgroundColor)?
|
|
161
|
-
borderColor = Colors.isValid(
|
|
158
|
+
backgroundColor = Colors.isValid(style.backgroundColor)?style.backgroundColor : Colors.isValid(backgroundColor)? backgroundColor : isCancelButton ? style.backgroundColor = theme.colors.error : undefined;
|
|
159
|
+
borderColor = Colors.isValid(style.borderColor)? style.borderColor : isCancelButton ? theme.styles.errorText : Colors.isValid(borderColor)? borderColor : undefined;
|
|
162
160
|
}
|
|
163
161
|
if(theme.isDark() && !hasElevation){
|
|
164
162
|
textColor = white;
|
|
@@ -40,7 +40,4 @@ DatagridMainComponent.displayName = "DatagridMainComponent";
|
|
|
40
40
|
DatagridMainComponent.propTypes = {
|
|
41
41
|
...DatagridTableData.propTypes
|
|
42
42
|
}
|
|
43
|
-
|
|
44
|
-
DatagridMainComponent.getDBName = DatagridTableData.getDBName;
|
|
45
|
-
|
|
46
43
|
DatagridMainComponent.LinesProgressBar = DatagridMainComponent.LineProgressBar = DatagridTableData.LineProgressBar;
|
|
@@ -6,6 +6,7 @@ import {MORE_ICON} from "$ecomponents/Icon/utils";
|
|
|
6
6
|
import {renderActions} from "./utils";
|
|
7
7
|
import View from "$ecomponents/View";
|
|
8
8
|
import { StyleSheet } from "react-native";
|
|
9
|
+
import DialogActions from "./RNPDialogActions";
|
|
9
10
|
|
|
10
11
|
const DialogActionsComponent = React.forwardRef(({actions,isAlert,onAlertRequestClose,testID,containerProps,actionMutator,actionProps,cancelButton,responsive,isFullScreen,fullScreen,actionsProps,menuProps,...rest},ref)=>{
|
|
11
12
|
const forceRender = React.useForceRender();
|
|
@@ -35,7 +36,7 @@ const DialogActionsComponent = React.forwardRef(({actions,isAlert,onAlertRequest
|
|
|
35
36
|
testID = testID||'DialogComponent_Actions';
|
|
36
37
|
if(menuActions && (menuActions.actions.length || menuActions.menus.length)){
|
|
37
38
|
return <View testID={testID} {...containerProps} style={[styles.container,containerProps.style]} ref={ref}>
|
|
38
|
-
<
|
|
39
|
+
<DialogActions testID={testID+"_ActionsContainer"} {...rest} style={[styles.actions,rest.style]}>
|
|
39
40
|
{menuActions.actions}
|
|
40
41
|
{menuActions.menus.length ? <Menu
|
|
41
42
|
testID = {testID+"_MenuWrapper"}
|
|
@@ -47,7 +48,7 @@ const DialogActionsComponent = React.forwardRef(({actions,isAlert,onAlertRequest
|
|
|
47
48
|
}}
|
|
48
49
|
items = {menuActions.menus}
|
|
49
50
|
/>: null}
|
|
50
|
-
</
|
|
51
|
+
</DialogActions>
|
|
51
52
|
</View>
|
|
52
53
|
}
|
|
53
54
|
return null;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { StyleSheet, View,} from 'react-native';
|
|
3
|
+
import PropTypes from "prop-types";
|
|
4
|
+
import { StyleProp } from '$theme';
|
|
5
|
+
import {defaultStr} from "$utils";
|
|
6
|
+
|
|
7
|
+
const DialogActions = ({testID,...props}) => {
|
|
8
|
+
testID = defaultStr(testID,"RNP_DialogActionsComponent")
|
|
9
|
+
return (
|
|
10
|
+
<View
|
|
11
|
+
{...props}
|
|
12
|
+
testID = {testID}
|
|
13
|
+
style={[styles.container, props.style]}
|
|
14
|
+
>
|
|
15
|
+
{React.Children.map(props.children, (child, i) =>
|
|
16
|
+
React.isValidElement(child)
|
|
17
|
+
? React.cloneElement(child, {
|
|
18
|
+
compact: true,
|
|
19
|
+
testID : defaultStr(child?.props?.testID,testID+"_Action"),
|
|
20
|
+
//style: child?.props?.style,
|
|
21
|
+
})
|
|
22
|
+
: child
|
|
23
|
+
)}
|
|
24
|
+
</View>
|
|
25
|
+
);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
DialogActions.displayName = 'Dialog.Actions';
|
|
29
|
+
|
|
30
|
+
const styles = StyleSheet.create({
|
|
31
|
+
container: {
|
|
32
|
+
flexDirection: 'row',
|
|
33
|
+
alignItems: 'center',
|
|
34
|
+
justifyContent: 'flex-end',
|
|
35
|
+
padding: 8,
|
|
36
|
+
},
|
|
37
|
+
v3Container: {
|
|
38
|
+
flexDirection: 'row',
|
|
39
|
+
flexGrow: 1,
|
|
40
|
+
alignItems: 'center',
|
|
41
|
+
justifyContent: 'flex-end',
|
|
42
|
+
paddingBottom: 24,
|
|
43
|
+
paddingHorizontal: 24,
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
export default DialogActions;
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
DialogActions.propTypes = {
|
|
51
|
+
children: PropTypes.node,
|
|
52
|
+
style : StyleProp,
|
|
53
|
+
}
|
|
@@ -56,6 +56,7 @@ export default function showConfirm (p,cb){
|
|
|
56
56
|
if(isNonNullString(yes)){
|
|
57
57
|
yes = {text:yes}
|
|
58
58
|
}
|
|
59
|
+
testID = defaultStr(testID,"RN_AlertDialogComponent");
|
|
59
60
|
buttons = defaultVal(buttons,actions);
|
|
60
61
|
if(buttons !== false && buttons !== null){
|
|
61
62
|
if(!isArray(buttons)){
|
|
@@ -67,6 +68,7 @@ export default function showConfirm (p,cb){
|
|
|
67
68
|
if(!alert && no !== false){
|
|
68
69
|
no.text = defaultStr(no.text,'Non');
|
|
69
70
|
const {onPress} = no;
|
|
71
|
+
no.testID = testID+"_NoCancelButton";
|
|
70
72
|
no.style = [{color:theme.colors.errorText,backgroundColor:theme.colors.error},no.style];
|
|
71
73
|
no.onPress = (args)=>{
|
|
72
74
|
args = React.getOnPressArgs(args);
|
|
@@ -80,6 +82,7 @@ export default function showConfirm (p,cb){
|
|
|
80
82
|
if(yes !== false){
|
|
81
83
|
yes = defaultObj(yes,ok)
|
|
82
84
|
yes.text = defaultStr(yes.text,alert?'OK':'Oui');
|
|
85
|
+
yes.testID = testID+"_YesOkButton";
|
|
83
86
|
yes.style = [{color:theme.colors.primaryText,backgroundColor:theme.colors.primary},yes.style]
|
|
84
87
|
const {onPress} = yes;
|
|
85
88
|
yes.onPress = (args)=>{
|
|
@@ -98,7 +101,6 @@ export default function showConfirm (p,cb){
|
|
|
98
101
|
if(confirm){
|
|
99
102
|
alert = true;
|
|
100
103
|
}
|
|
101
|
-
testID = defaultStr(testID,"RN_AlertDialogComponent");
|
|
102
104
|
const messageContent = React.isValidElement(message,true)?<Label testID={testID+"_Message"} {...messageProps} style={[theme.styles.fs15,theme.styles.pb1,messageProps.style]} >{message}</Label> :null;
|
|
103
105
|
if(alert){
|
|
104
106
|
return Alert.alert({
|
|
@@ -12,7 +12,6 @@ import fetch from "$capi"
|
|
|
12
12
|
import {willConvertFiltersToSQL} from "$ecomponents/Datagrid/utils";
|
|
13
13
|
import React from "$react";
|
|
14
14
|
import appConfig from "$appConfig";
|
|
15
|
-
import {isJSON,parseJSON} from "$utils/json";
|
|
16
15
|
|
|
17
16
|
/*** la tabledataSelectField permet de faire des requêtes distantes pour rechercher les données
|
|
18
17
|
* Elle doit prendre en paramètre et de manière requis : les props suivante :
|
|
@@ -32,11 +32,11 @@ import Zocial from "@expo/vector-icons/Zocial";
|
|
|
32
32
|
* simple-line - pour l'iconSet SimpleLinesIcons
|
|
33
33
|
* zocial - pour l'iconSet Zocial
|
|
34
34
|
*/
|
|
35
|
-
const FontIcon = React.forwardRef(({icon,name,testID,color,iconStyle,backgroundColor,style,...props},ref)=>{
|
|
35
|
+
const FontIcon = React.forwardRef(({icon,name,testID,color,iconColor,iconStyle,backgroundColor,style,...props},ref)=>{
|
|
36
36
|
icon = defaultStr(icon,name).trim();
|
|
37
37
|
testID = defaultStr(testID,"RN_FontIconComponent");
|
|
38
38
|
const fStyle = StyleSheet.flatten(style) || {};
|
|
39
|
-
color = theme.Colors.isValid(color)? color : fStyle.color || theme.colors.text;
|
|
39
|
+
color = theme.Colors.isValid(color)? color : Colors.isValid(iconColor)?iconColor : fStyle.color || theme.colors.text;
|
|
40
40
|
backgroundColor = theme.Colors.isValid(backgroundColor)? backgroundColor : fStyle.backgroundColor || 'transparent';
|
|
41
41
|
const isMaterial = isIcon(name,"material");
|
|
42
42
|
const isFa = isIcon(name,"fa");
|
|
@@ -65,11 +65,11 @@ const FontIcon = React.forwardRef(({icon,name,testID,color,iconStyle,backgroundC
|
|
|
65
65
|
.ltrim("fa-").ltrim("ant-").ltrim("fontisto-")
|
|
66
66
|
.ltrim("foundation-").ltrim("ionic-").ltrim("octicons-")
|
|
67
67
|
.ltrim("simple-line-").ltrim("zocial-").trim();
|
|
68
|
-
|
|
69
68
|
return <Icon {...props}
|
|
70
69
|
ref = {ref}
|
|
71
70
|
testID = {testID}
|
|
72
71
|
color={color}
|
|
72
|
+
iconColor = {iconColor}
|
|
73
73
|
name = {iconName}
|
|
74
74
|
backgroundColor = {backgroundColor}
|
|
75
75
|
/>
|
|
@@ -22,10 +22,12 @@ const IconComponentRef = React.forwardRef((props,ref)=>{
|
|
|
22
22
|
if(button === false){
|
|
23
23
|
flattenedStyle.borderRadius = 0;
|
|
24
24
|
}
|
|
25
|
+
const iconColor = Colors.isValid(color) ? color : Colors.isValid(rest.iconColor)? rest.iconColor : Colors.isValid(flattenedStyle.color)? flattenedStyle.color : theme.colors.text
|
|
25
26
|
return <Tooltip
|
|
26
27
|
animated
|
|
27
28
|
{...rest}
|
|
28
|
-
color={
|
|
29
|
+
color={iconColor}
|
|
30
|
+
iconColor = {iconColor}
|
|
29
31
|
style = {flattenedStyle}
|
|
30
32
|
Component={React.isComponent(Component)?Component:IconButton}
|
|
31
33
|
ref = {ref}
|
|
@@ -24,6 +24,7 @@ const IconButtonComponent = ({
|
|
|
24
24
|
containerProps,
|
|
25
25
|
style,
|
|
26
26
|
testID,
|
|
27
|
+
color,
|
|
27
28
|
...rest
|
|
28
29
|
}) => {
|
|
29
30
|
const IconComponent = animated ? CrossFadeIcon : IconButton;
|
|
@@ -31,11 +32,11 @@ const IconButtonComponent = ({
|
|
|
31
32
|
containerProps = defaultObj(containerProps);
|
|
32
33
|
const containerStyle = StyleSheet.flatten(containerProps.style) || {};
|
|
33
34
|
const backgroundColor = Colors.isValid(containerColor)? containerColor : Colors.isValid(containerStyle.color) ? containerStyle.color : undefined;
|
|
34
|
-
const iconColor = Colors.isValid(customIconColor)? customIconColor : theme.colors.text;
|
|
35
|
+
const iconColor = Colors.isValid(customIconColor)? customIconColor : Colors.isValid(color)? color : theme.colors.text;
|
|
35
36
|
const borderColor = theme.colors.outline || theme.colors.divider;
|
|
36
37
|
const rippleColor = Colors.setAlpha(iconColor,0.32);
|
|
37
38
|
const buttonSize = size * 1.5;
|
|
38
|
-
|
|
39
|
+
console.log(iconColor, " is conndddd ",color,rest);
|
|
39
40
|
const borderStyles = {
|
|
40
41
|
borderWidth: 0,
|
|
41
42
|
borderRadius: buttonSize / 2,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isValidUrl, isNonNullString,uniqid,defaultObj,defaultStr} from "$utils";
|
|
2
2
|
import getCallbackUrl from "./getUrlCallback";
|
|
3
|
-
import { getQueryParams,setQueryParams} from "$
|
|
3
|
+
import { getQueryParams,setQueryParams} from "$cutils/uri";
|
|
4
4
|
const BROWSERS_EVENTS = {};
|
|
5
5
|
const callbackURIID = "callbackURIIDDD";
|
|
6
6
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defaultStr } from "$utils";
|
|
2
|
-
import { getCurrentURI,getNativeMobileAppURI } from "$
|
|
2
|
+
import { getCurrentURI,getNativeMobileAppURI } from "$cutils/uri";
|
|
3
3
|
export default function getCallbackUrl (url){
|
|
4
4
|
let cUrl = undefined;
|
|
5
5
|
if (typeof window !== 'undefined' && window) {
|
|
@@ -124,9 +124,11 @@ class _Menu extends AppComponent {
|
|
|
124
124
|
};
|
|
125
125
|
|
|
126
126
|
handleDismiss = () => {
|
|
127
|
-
|
|
128
|
-
this.props.
|
|
129
|
-
|
|
127
|
+
this.hide(()=>{
|
|
128
|
+
if (this.props.visible) {
|
|
129
|
+
this.props.onDismiss();
|
|
130
|
+
}
|
|
131
|
+
});
|
|
130
132
|
return true;
|
|
131
133
|
};
|
|
132
134
|
|
|
@@ -225,7 +227,7 @@ class _Menu extends AppComponent {
|
|
|
225
227
|
);
|
|
226
228
|
};
|
|
227
229
|
|
|
228
|
-
hide = () => {
|
|
230
|
+
hide = (cb) => {
|
|
229
231
|
this.removeListeners();
|
|
230
232
|
if(!this._isMounted()) return;
|
|
231
233
|
const animation = theme.animation;
|
|
@@ -236,7 +238,7 @@ class _Menu extends AppComponent {
|
|
|
236
238
|
useNativeDriver: true,
|
|
237
239
|
}).start(({ finished }) => {
|
|
238
240
|
if (finished) {
|
|
239
|
-
this.setState({ menuLayout: { width: 0, height: 0 }});
|
|
241
|
+
this.setState({ menuLayout: { width: 0, height: 0 }},(e)=>{if(typeof cb ==='function') cb();});
|
|
240
242
|
this.state.scaleAnimation.setValue({ x: 0, y: 0 });
|
|
241
243
|
this.focusFirstDOMNode(this.anchor);
|
|
242
244
|
}
|
|
@@ -2,7 +2,7 @@ import React from "$react";
|
|
|
2
2
|
//import { StatusBar } from 'expo-status-bar';
|
|
3
3
|
import theme,{getStatusBarStyle,Colors} from "$theme"
|
|
4
4
|
import {isTouchDevice,uniqid} from "$utils";
|
|
5
|
-
import {isDOMElement,removeClassName,addClassName} from "$
|
|
5
|
+
import {isDOMElement,removeClassName,addClassName} from "$cutils/dom";
|
|
6
6
|
import { StyleSheet } from "react-native";
|
|
7
7
|
|
|
8
8
|
const styleId = uniqid("dynamic-css-style-id");
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import tippy from 'tippy.js';
|
|
2
2
|
import 'tippy.js/dist/tippy.css';
|
|
3
3
|
import React from "$react";
|
|
4
|
-
import {getMaxZindex} from "$
|
|
4
|
+
import {getMaxZindex} from "$cutils/dom";
|
|
5
5
|
import PropTypes from "prop-types";
|
|
6
6
|
import Label from "$ecomponents/Label";
|
|
7
7
|
import { TIPPY_THEME } from '$theme/updateNative/utils';
|
|
8
|
-
import {isDOMElement} from "$
|
|
8
|
+
import {isDOMElement} from "$cutils/dom";
|
|
9
9
|
import {uniqid,defaultStr,defaultObj} from "$utils";
|
|
10
10
|
|
|
11
11
|
const TippyTooltipComponent = React.forwardRef((props,ref)=>{
|
|
@@ -13,7 +13,6 @@ export const positions = {top:"top",right:"right",bottom:"bottom",left:"left"}
|
|
|
13
13
|
|
|
14
14
|
const TooltipComponent = React.forwardRef((props,ref)=>{
|
|
15
15
|
let {tooltipProps,position,Component,children,strictPosition,...rest} = props;
|
|
16
|
-
rest = defaultObj(rest);
|
|
17
16
|
tooltipProps = defaultObj(tooltipProps);
|
|
18
17
|
Component = React.isComponent(tooltipProps.Component) ? tooltipProps.Component : React.isComponent(Component) ? Component : Label;
|
|
19
18
|
delete tooltipProps.position;
|
|
@@ -6,7 +6,7 @@ import WebView from "./Component";
|
|
|
6
6
|
import {defaultStr} from "$utils";
|
|
7
7
|
import React from "$react";
|
|
8
8
|
import PropTypes from "prop-types";
|
|
9
|
-
import {isValidUrl} from "$
|
|
9
|
+
import {isValidUrl} from "$cutils/uri";
|
|
10
10
|
import FileSystem from "$file-system";
|
|
11
11
|
|
|
12
12
|
const WebViewComponent = React.forwardRef(({children,source,style,testID,...props},ref)=>{
|
package/src/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import APP from "$capp";
|
|
|
5
5
|
import {AppStateService,trackIDLE,stop as stopIDLE} from "$capp/idle";
|
|
6
6
|
import { NavigationContainer} from '@react-navigation/native';
|
|
7
7
|
import {navigationRef} from "$cnavigation"
|
|
8
|
-
import NetInfo from '$
|
|
8
|
+
import NetInfo from '$cutils/NetInfo';
|
|
9
9
|
import Auth from "$cauth";
|
|
10
10
|
import {isNativeMobile,isElectron} from "$cplatform";
|
|
11
11
|
import Navigation from "./navigation";
|
|
@@ -14,7 +14,7 @@ import { showConfirm } from "$ecomponents/Dialog";
|
|
|
14
14
|
import {close as closePreloader, isVisible as isPreloaderVisible} from "$epreloader";
|
|
15
15
|
import SplashScreen from "$ecomponents/SplashScreen";
|
|
16
16
|
import {notify} from "$ecomponents/Dialog";
|
|
17
|
-
import {decycle} from "$
|
|
17
|
+
import {decycle} from "$cutils/json";
|
|
18
18
|
import init from "$capp/init";
|
|
19
19
|
import { setIsInitialized} from "$capp/utils";
|
|
20
20
|
import {isObj,isNonNullString,isPromise,defaultObj,defaultStr} from "$cutils";
|
|
@@ -1,360 +0,0 @@
|
|
|
1
|
-
import {uniqid,defaultStr,defaultObj} from "$utils";
|
|
2
|
-
import {addClassName, removeClassName} from "$utils/dom";
|
|
3
|
-
import theme from "$theme";
|
|
4
|
-
import {MAX_WIDTH} from "$ecomponents/Dialog/utils";
|
|
5
|
-
import {Elevations} from "$ecomponents/Surface";
|
|
6
|
-
import { StyleSheet } from "react-native";
|
|
7
|
-
import {Dimensions} from "react-native";
|
|
8
|
-
const domId = uniqid("alter-7-dom-id");
|
|
9
|
-
(function (Alert7) {
|
|
10
|
-
|
|
11
|
-
var _TYPE_DEFAULT = 0;
|
|
12
|
-
var _TYPE_CONFIRM = 1;
|
|
13
|
-
(function () {
|
|
14
|
-
Alert7 = window.Alert7 = Alert7 || _getInitialClass();
|
|
15
|
-
}());
|
|
16
|
-
|
|
17
|
-
function _getInitialClass() {
|
|
18
|
-
|
|
19
|
-
Alert7Class.TYPE_DEFAULT = _TYPE_DEFAULT;
|
|
20
|
-
Alert7Class.TYPE_CONFIRM = _TYPE_CONFIRM;
|
|
21
|
-
Alert7Class.alert = _staticAlert;
|
|
22
|
-
Alert7Class.break = _staticBreak;
|
|
23
|
-
_appendCSS();
|
|
24
|
-
return Alert7Class;
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function _staticAlert(_title, _message) {
|
|
29
|
-
|
|
30
|
-
var _tempAlert = new Alert7Class();
|
|
31
|
-
var _args = [].splice.call(arguments, 2);
|
|
32
|
-
_tempAlert.setTitle(_title);
|
|
33
|
-
_tempAlert.setMessage(_message);
|
|
34
|
-
while ( _args.length ) _tempAlert.addAction(_args.shift(), _args.shift());
|
|
35
|
-
_tempAlert.present();
|
|
36
|
-
return _tempAlert;
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function _staticBreak() {
|
|
41
|
-
|
|
42
|
-
throw null;
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function _appendCSS() {
|
|
47
|
-
let maxWidth = MAX_WIDTH;
|
|
48
|
-
const backgroundColor = theme.colors.surface+";",color=theme.colors.text+";";
|
|
49
|
-
const {width:windowWidth} = Dimensions.get("window");
|
|
50
|
-
if(typeof windowWidth <= maxWidth){
|
|
51
|
-
maxWidth = windowWidth*90/100;
|
|
52
|
-
}
|
|
53
|
-
var _styleElement = document.getElementById(domId);
|
|
54
|
-
if(!_styleElement){
|
|
55
|
-
_styleElement = document.createElement("style");
|
|
56
|
-
document.getElementsByTagName("head")[0].appendChild(_styleElement);
|
|
57
|
-
}
|
|
58
|
-
_styleElement.id = domId;
|
|
59
|
-
_styleElement.innerHTML = "" +
|
|
60
|
-
"#Alert7," +
|
|
61
|
-
"#Alert7::after," +
|
|
62
|
-
"#Alert7 .alert7-container {" +
|
|
63
|
-
"vertical-align: middle;" +
|
|
64
|
-
"}" +
|
|
65
|
-
"" +
|
|
66
|
-
"#Alert7 {" +
|
|
67
|
-
"position: fixed;" +
|
|
68
|
-
"top: 0;" +
|
|
69
|
-
"bottom: 0;" +
|
|
70
|
-
"left: 0;" +
|
|
71
|
-
"right: 0;" +
|
|
72
|
-
"z-index: 1001;" +
|
|
73
|
-
"background-color: " +theme.colors.backdrop+";"+
|
|
74
|
-
"text-align: center;" +
|
|
75
|
-
"font-size: 16px;" +
|
|
76
|
-
"-webkit-user-select: none;" +
|
|
77
|
-
" -moz-user-select: none;" +
|
|
78
|
-
" -ms-user-select: none;" +
|
|
79
|
-
" user-select: none;" +
|
|
80
|
-
"}" +
|
|
81
|
-
"" +
|
|
82
|
-
"#Alert7.alert7-confirm {" +
|
|
83
|
-
"}" +
|
|
84
|
-
"" +
|
|
85
|
-
"#Alert7::after," +
|
|
86
|
-
"#Alert7 .alert7-container {" +
|
|
87
|
-
"display: inline-block;" +
|
|
88
|
-
"}" +
|
|
89
|
-
"" +
|
|
90
|
-
"#Alert7::after {" +
|
|
91
|
-
"height: 100%;" +
|
|
92
|
-
"content: '';" +
|
|
93
|
-
"}" +
|
|
94
|
-
"#Alert7 .alert7-container {" +
|
|
95
|
-
"min-width:240px;"+
|
|
96
|
-
"max-width: "+maxWidth+(typeof maxWidth =='number'? "px":"")+";" +
|
|
97
|
-
"width: auto;" +
|
|
98
|
-
"box-sizing: border-box;" +
|
|
99
|
-
"background-color:"+backgroundColor+
|
|
100
|
-
"border-radius: 0px;" +
|
|
101
|
-
"max-height: calc(100% - 64px);"+
|
|
102
|
-
"overflow-y: auto;"+
|
|
103
|
-
"color:"+color+
|
|
104
|
-
"box-shadow:rgb(0 0 0 / 20%) 0px 11px 15px -7px, rgb(0 0 0 / 14%) 0px 24px 38px 3px, rgb(0 0 0 / 12%) 0px 9px 46px 8px"+
|
|
105
|
-
"}" +
|
|
106
|
-
"" +
|
|
107
|
-
"#Alert7 .alert7-title," +
|
|
108
|
-
"#Alert7 .alert7-message {" +
|
|
109
|
-
"font-family: Roboto, Helvetica, Arial, sans-serif;"+
|
|
110
|
-
"line-height: 1.6;"+
|
|
111
|
-
"letter-spacing: 0.0075em;"+
|
|
112
|
-
"padding:10px;"+
|
|
113
|
-
"text-align:left;"+
|
|
114
|
-
"}" +
|
|
115
|
-
"" +
|
|
116
|
-
"#Alert7 .alert7-title {" +
|
|
117
|
-
"font-size: 1.1em;" +
|
|
118
|
-
"font-weight: bolder;" +
|
|
119
|
-
//"line-height: 2rem;" +
|
|
120
|
-
"}" +
|
|
121
|
-
"" +
|
|
122
|
-
"#Alert7 .alert7-message {" +
|
|
123
|
-
"padding-bottom: 14px;" +
|
|
124
|
-
"font-size: 0.9em;" +
|
|
125
|
-
"}" +
|
|
126
|
-
"" +
|
|
127
|
-
"#Alert7 .alert7-actions {" +
|
|
128
|
-
"width:100%;"+
|
|
129
|
-
"text-align:right;"+
|
|
130
|
-
"padding-bottom:7px"+
|
|
131
|
-
"}" +
|
|
132
|
-
"" +
|
|
133
|
-
"#Alert7 .alert7-actions button.alert7-action-item {" +
|
|
134
|
-
"display: inline-block;"+
|
|
135
|
-
"position: relative;"+
|
|
136
|
-
"box-sizing: border-box;"+
|
|
137
|
-
"-webkit-tap-highlight-color: transparent;"+
|
|
138
|
-
"background-color: transparent;"+
|
|
139
|
-
"outline: 0px;"+
|
|
140
|
-
"border: 0px;"+
|
|
141
|
-
"margin: 0px;"+
|
|
142
|
-
"cursor: pointer;"+
|
|
143
|
-
"user-select: none;"+
|
|
144
|
-
"vertical-align: middle;"+
|
|
145
|
-
"appearance: none;"+
|
|
146
|
-
"text-decoration: none;"+
|
|
147
|
-
"font-family: Roboto, Helvetica, Arial, sans-serif;"+
|
|
148
|
-
"font-weight: 500;"+
|
|
149
|
-
"font-size: 0.875rem;"+
|
|
150
|
-
"line-height: 1.75;"+
|
|
151
|
-
"letter-spacing: 0.02857em;"+
|
|
152
|
-
"text-transform: uppercase;"+
|
|
153
|
-
"min-width: 64px;"+
|
|
154
|
-
"padding: 6px 8px;"+
|
|
155
|
-
"margin-right:7px;"+
|
|
156
|
-
"margin-bottom:4px;"+
|
|
157
|
-
"border-radius: 4px;"+
|
|
158
|
-
"transition: background-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, box-shadow 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, border-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;"+
|
|
159
|
-
"}" +
|
|
160
|
-
"" +
|
|
161
|
-
"#Alert7.alert7-confirm .alert7-actions button.alert7-action-item:first-of-type:last-of-type {" +
|
|
162
|
-
"width: 100%;" +
|
|
163
|
-
"}" +
|
|
164
|
-
"" +
|
|
165
|
-
"#Alert7.alert7-confirm .alert7-actions button.alert7-action-item:nth-of-type(n+3) {" +
|
|
166
|
-
"display: none;" +
|
|
167
|
-
"}" +
|
|
168
|
-
"@media only screen and (min-width: "+(MAX_WIDTH)+"px) {"+
|
|
169
|
-
"#Alert7 .alert7-container {"+
|
|
170
|
-
"max-width:"+(MAX_WIDTH-20)+"px!important;"+
|
|
171
|
-
"}"+
|
|
172
|
-
"}"+
|
|
173
|
-
"@media only screen and (max-width: "+MAX_WIDTH+"px) {"+
|
|
174
|
-
"#Alert7 .alert7-container {"+
|
|
175
|
-
"max-width:90%!important;"+
|
|
176
|
-
"}"+
|
|
177
|
-
"}"+
|
|
178
|
-
"";
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
function Alert7Class() {
|
|
182
|
-
|
|
183
|
-
this.title = "";
|
|
184
|
-
this.message = "";
|
|
185
|
-
this.type = _TYPE_DEFAULT;
|
|
186
|
-
this.actions = [];
|
|
187
|
-
_createAlertElement(this);
|
|
188
|
-
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
function _createAlertElement(_self) {
|
|
192
|
-
|
|
193
|
-
_self.instanceElement = document.createElement("div");
|
|
194
|
-
_self.instanceElement.id = "Alert7";
|
|
195
|
-
_self.alertElement = document.createElement("div");
|
|
196
|
-
_self.alertElement.className = "alert7-container";
|
|
197
|
-
_self.instanceElement.appendChild(_self.alertElement);
|
|
198
|
-
_self.titleElement = document.createElement("div");
|
|
199
|
-
_self.titleElement.className = "alert7-title";
|
|
200
|
-
_self.alertElement.appendChild(_self.titleElement);
|
|
201
|
-
_self.messageElement = document.createElement("div");
|
|
202
|
-
_self.messageElement.className = "alert7-message";
|
|
203
|
-
_self.alertElement.appendChild(_self.messageElement);
|
|
204
|
-
_self.actionsElement = document.createElement("div");
|
|
205
|
-
_self.actionsElement.className = "alert7-actions";
|
|
206
|
-
_self.alertElement.appendChild(_self.actionsElement);
|
|
207
|
-
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
Alert7Class.prototype.setTitle = function (_text) {
|
|
211
|
-
|
|
212
|
-
this.title = _text || "";
|
|
213
|
-
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
Alert7Class.prototype.setMessage = function (_text) {
|
|
217
|
-
this.message = _text || "";
|
|
218
|
-
};
|
|
219
|
-
|
|
220
|
-
Alert7Class.prototype.setType = function (_enum) {
|
|
221
|
-
|
|
222
|
-
this.type = _enum || _TYPE_DEFAULT;
|
|
223
|
-
|
|
224
|
-
};
|
|
225
|
-
|
|
226
|
-
Alert7Class.prototype.addAction = function (_text, _handler) {
|
|
227
|
-
|
|
228
|
-
this.actions.push({
|
|
229
|
-
text: _text,
|
|
230
|
-
handler: _handler
|
|
231
|
-
});
|
|
232
|
-
|
|
233
|
-
};
|
|
234
|
-
|
|
235
|
-
Alert7Class.prototype.present = function () {
|
|
236
|
-
this.titleElement.innerText = this.titleElement.textContent = this.title;
|
|
237
|
-
const isDark = theme.isDark();
|
|
238
|
-
_appendCSS();
|
|
239
|
-
removeClassName(this.titleElement,"alert7-title");
|
|
240
|
-
if(typeof this.title =="string" && this.title.length){
|
|
241
|
-
addClassName(this.titleElement,"alert7-title");
|
|
242
|
-
this.titleElement.style.background = isDark?theme.colors.surface : theme.colors.primary;
|
|
243
|
-
this.titleElement.style.color = isDark?theme.colors.surfaceText : theme.colors.primaryText;
|
|
244
|
-
this.titleElement.style.borderBottom = "1px solid "+theme.colors.divider;
|
|
245
|
-
}
|
|
246
|
-
this.messageElement.innerHTML = this.messageElement.textContent = defaultStr(this.message).replaceAll("\n","</br>");
|
|
247
|
-
switch ( this.type ) {
|
|
248
|
-
case _TYPE_CONFIRM: this.instanceElement.classList.add("alert7-confirm");
|
|
249
|
-
}
|
|
250
|
-
if ( !this.actions.length ) this.actions.push({});
|
|
251
|
-
_createActions(this);
|
|
252
|
-
document.querySelector("body").appendChild(this.instanceElement);
|
|
253
|
-
|
|
254
|
-
};
|
|
255
|
-
|
|
256
|
-
Alert7Class.prototype.dismiss = function () {
|
|
257
|
-
|
|
258
|
-
if ( !this.instanceElement.parentNode ) return;
|
|
259
|
-
this.instanceElement.parentNode.removeChild(this.instanceElement);
|
|
260
|
-
|
|
261
|
-
};
|
|
262
|
-
|
|
263
|
-
function _createActions(_self) {
|
|
264
|
-
|
|
265
|
-
var _actions = _self.actions;
|
|
266
|
-
var _numOfAction = _actions.length;
|
|
267
|
-
var _tempActionElement;
|
|
268
|
-
var _datum;
|
|
269
|
-
_self.actionsElement.innerHTML = "";
|
|
270
|
-
while ( _numOfAction-- ) {
|
|
271
|
-
_datum = _actions[_numOfAction];
|
|
272
|
-
const button = _datum.text;
|
|
273
|
-
if(typeof button =="text"){
|
|
274
|
-
button = {text:button};
|
|
275
|
-
} else button = defaultObj(button);
|
|
276
|
-
const text = defaultStr(button.text,button.label);
|
|
277
|
-
if(!text) _numOfAction--;
|
|
278
|
-
_tempActionElement = document.createElement("button");
|
|
279
|
-
_tempActionElement.className = "alert7-action-item";
|
|
280
|
-
_tempActionElement.innerText = _tempActionElement.textContent = text;// _datum.text || "OK";
|
|
281
|
-
const stylesInput = StyleSheet.flatten(button.style);
|
|
282
|
-
const style = _tempActionElement.style;
|
|
283
|
-
for(let i in stylesInput){
|
|
284
|
-
if(style.hasOwnProperty(i)){
|
|
285
|
-
style[i] = stylesInput[i];
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
_tempActionElement.addEventListener("click", _onClick(_datum.handler), false);
|
|
289
|
-
_self.actionsElement.insertBefore(_tempActionElement, _self.actionsElement.firstChild);
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
function _onClick(_handler) {
|
|
293
|
-
return function () {
|
|
294
|
-
try {
|
|
295
|
-
if ( _handler ) _handler();
|
|
296
|
-
_self.dismiss();
|
|
297
|
-
} catch (_error) {}
|
|
298
|
-
};
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
}(window.Alert7));
|
|
304
|
-
|
|
305
|
-
function escapeHTML(string) {
|
|
306
|
-
let pre = document.createElement('pre');
|
|
307
|
-
let text = document.createTextNode(string);
|
|
308
|
-
pre.appendChild(text);
|
|
309
|
-
return pre.innerHTML;
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
const Alert = {
|
|
313
|
-
alert(title, message='', callbackOrButtons=[{text:'OK', onPress : (f) => f}]) {
|
|
314
|
-
let alert = new Alert7();
|
|
315
|
-
alert.setTitle(title);
|
|
316
|
-
alert.setMessage(escapeHTML(message));
|
|
317
|
-
if (typeof callbackOrButtons === 'function') {
|
|
318
|
-
const callback = callbackOrButtons;
|
|
319
|
-
alert.addAction('OK', callback);
|
|
320
|
-
} else {
|
|
321
|
-
const buttons = callbackOrButtons;
|
|
322
|
-
buttons.forEach((button) => {
|
|
323
|
-
alert.addAction(button, button.onPress || (f=>f));
|
|
324
|
-
});
|
|
325
|
-
if (buttons.length === 2) {
|
|
326
|
-
alert.setType(Alert7.TYPE_CONFIRM);
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
alert.present();
|
|
330
|
-
},
|
|
331
|
-
|
|
332
|
-
prompt(title, message='', callbackOrButtons=(f) => f, type='plain-text', defaultValue='') {
|
|
333
|
-
const alertPromptId = uniqid('alert7-prompt-input')
|
|
334
|
-
function getInputCallback(callback) {
|
|
335
|
-
return () => {
|
|
336
|
-
const text = document.getElementById(alertPromptId).value;
|
|
337
|
-
return callback(text);
|
|
338
|
-
};
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
let alert = new Alert7();
|
|
342
|
-
alert.setTitle(title);
|
|
343
|
-
const msg = `<br/><input type="${(type==='secure-text'||type==='login-password')?'password':'text'}" value="${defaultValue}" id=${alertPromptId} style="width: 100%; height: 18px; border: 1px solid #ccc;" />`;
|
|
344
|
-
alert.setMessage(escapeHTML(message) + msg);
|
|
345
|
-
if (typeof callbackOrButtons === 'function') {
|
|
346
|
-
const callback = callbackOrButtons;
|
|
347
|
-
alert.addAction('OK', getInputCallback(callback));
|
|
348
|
-
} else {
|
|
349
|
-
const buttons = callbackOrButtons;
|
|
350
|
-
buttons.forEach((button) => {
|
|
351
|
-
alert.addAction(button, getInputCallback(button.onPress || (f=>f)));
|
|
352
|
-
});
|
|
353
|
-
if (buttons.length === 2) {
|
|
354
|
-
alert.setType(Alert7.TYPE_CONFIRM);
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
alert.present();
|
|
358
|
-
}
|
|
359
|
-
};
|
|
360
|
-
export default Alert;
|