react-native-umui 1.4.11 → 1.4.21
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/lib/commonjs/Accordion.js +5 -7
- package/lib/commonjs/Accordion.js.map +1 -1
- package/lib/commonjs/Badge.js +3 -3
- package/lib/commonjs/Badge.js.map +1 -1
- package/lib/commonjs/Button.js +3 -2
- package/lib/commonjs/Button.js.map +1 -1
- package/lib/commonjs/Checkbox.js +2 -4
- package/lib/commonjs/Checkbox.js.map +1 -1
- package/lib/commonjs/Divider.js +1 -2
- package/lib/commonjs/Divider.js.map +1 -1
- package/lib/commonjs/EasyIn.js +2 -5
- package/lib/commonjs/EasyIn.js.map +1 -1
- package/lib/commonjs/FlatList.js +3 -6
- package/lib/commonjs/FlatList.js.map +1 -1
- package/lib/commonjs/FlatPanel.js +1 -2
- package/lib/commonjs/FlatPanel.js.map +1 -1
- package/lib/commonjs/Grid.js +3 -6
- package/lib/commonjs/Grid.js.map +1 -1
- package/lib/commonjs/InputField.js +4 -6
- package/lib/commonjs/InputField.js.map +1 -1
- package/lib/commonjs/Line.js +1 -1
- package/lib/commonjs/Line.js.map +1 -1
- package/lib/commonjs/Load.js +3 -6
- package/lib/commonjs/Load.js.map +1 -1
- package/lib/commonjs/Numeral.js +33 -10
- package/lib/commonjs/Numeral.js.map +1 -1
- package/lib/commonjs/PanelRK.js +2 -3
- package/lib/commonjs/PanelRK.js.map +1 -1
- package/lib/commonjs/Phone.js +13 -15
- package/lib/commonjs/Phone.js.map +1 -1
- package/lib/commonjs/Press.js +1 -2
- package/lib/commonjs/Press.js.map +1 -1
- package/lib/commonjs/Radio.js +3 -4
- package/lib/commonjs/Radio.js.map +1 -1
- package/lib/commonjs/Scroll.js +7 -11
- package/lib/commonjs/Scroll.js.map +1 -1
- package/lib/commonjs/Tab.js +6 -10
- package/lib/commonjs/Tab.js.map +1 -1
- package/lib/commonjs/Text.js +9 -26
- package/lib/commonjs/Text.js.map +1 -1
- package/lib/commonjs/TextInput.js +6 -8
- package/lib/commonjs/TextInput.js.map +1 -1
- package/lib/commonjs/common.js +3 -6
- package/lib/commonjs/common.js.map +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/regions.js +9 -7
- package/lib/commonjs/regions.js.map +1 -1
- package/lib/commonjs/shadows.js +2 -3
- package/lib/commonjs/shadows.js.map +1 -1
- package/lib/module/Accordion.js +4 -4
- package/lib/module/Accordion.js.map +1 -1
- package/lib/module/Badge.js +2 -2
- package/lib/module/Badge.js.map +1 -1
- package/lib/module/Button.js +2 -1
- package/lib/module/Button.js.map +1 -1
- package/lib/module/Checkbox.js +1 -2
- package/lib/module/Checkbox.js.map +1 -1
- package/lib/module/Divider.js +0 -1
- package/lib/module/Divider.js.map +1 -1
- package/lib/module/EasyIn.js +1 -3
- package/lib/module/EasyIn.js.map +1 -1
- package/lib/module/FlatList.js +1 -2
- package/lib/module/FlatList.js.map +1 -1
- package/lib/module/FlatPanel.js +0 -1
- package/lib/module/FlatPanel.js.map +1 -1
- package/lib/module/Grid.js +2 -4
- package/lib/module/Grid.js.map +1 -1
- package/lib/module/InputField.js +3 -5
- package/lib/module/InputField.js.map +1 -1
- package/lib/module/Line.js.map +1 -1
- package/lib/module/Load.js +2 -4
- package/lib/module/Load.js.map +1 -1
- package/lib/module/Numeral.js +32 -7
- package/lib/module/Numeral.js.map +1 -1
- package/lib/module/PanelRK.js +1 -2
- package/lib/module/PanelRK.js.map +1 -1
- package/lib/module/Phone.js +10 -10
- package/lib/module/Phone.js.map +1 -1
- package/lib/module/Press.js +0 -1
- package/lib/module/Press.js.map +1 -1
- package/lib/module/Radio.js +2 -3
- package/lib/module/Radio.js.map +1 -1
- package/lib/module/Scroll.js +4 -5
- package/lib/module/Scroll.js.map +1 -1
- package/lib/module/Tab.js +5 -8
- package/lib/module/Tab.js.map +1 -1
- package/lib/module/Text.js +7 -23
- package/lib/module/Text.js.map +1 -1
- package/lib/module/TextInput.js +5 -6
- package/lib/module/TextInput.js.map +1 -1
- package/lib/module/common.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/regions.js +6 -1
- package/lib/module/regions.js.map +1 -1
- package/lib/module/shadows.js +1 -1
- package/lib/module/shadows.js.map +1 -1
- package/lib/typescript/src/Accordion.d.ts.map +1 -1
- package/lib/typescript/src/Badge.d.ts.map +1 -1
- package/lib/typescript/src/Button.d.ts.map +1 -1
- package/lib/typescript/src/Checkbox.d.ts.map +1 -1
- package/lib/typescript/src/Divider.d.ts.map +1 -1
- package/lib/typescript/src/EasyIn.d.ts.map +1 -1
- package/lib/typescript/src/FlatList.d.ts.map +1 -1
- package/lib/typescript/src/FlatPanel.d.ts.map +1 -1
- package/lib/typescript/src/Grid.d.ts.map +1 -1
- package/lib/typescript/src/InputField.d.ts +2 -1
- package/lib/typescript/src/InputField.d.ts.map +1 -1
- package/lib/typescript/src/Load.d.ts.map +1 -1
- package/lib/typescript/src/Numeral.d.ts.map +1 -1
- package/lib/typescript/src/PanelRK.d.ts.map +1 -1
- package/lib/typescript/src/Phone.d.ts.map +1 -1
- package/lib/typescript/src/Press.d.ts.map +1 -1
- package/lib/typescript/src/Radio.d.ts +1 -0
- package/lib/typescript/src/Radio.d.ts.map +1 -1
- package/lib/typescript/src/Scroll.d.ts.map +1 -1
- package/lib/typescript/src/Tab.d.ts.map +1 -1
- package/lib/typescript/src/Text.d.ts.map +1 -1
- package/lib/typescript/src/TextInput.d.ts.map +1 -1
- package/lib/typescript/src/regions.d.ts +5 -0
- package/lib/typescript/src/regions.d.ts.map +1 -1
- package/lib/typescript/src/shadows.d.ts.map +1 -1
- package/package.json +3 -5
- package/src/Accordion.tsx +0 -1
- package/src/Badge.tsx +0 -1
- package/src/Button.tsx +0 -142
- package/src/Checkbox.tsx +0 -1
- package/src/Divider.tsx +0 -1
- package/src/EasyIn.tsx +0 -1
- package/src/FlatList.tsx +0 -1
- package/src/FlatPanel.tsx +0 -1
- package/src/Grid.tsx +0 -1
- package/src/InputField.tsx +0 -1
- package/src/Line.tsx +0 -16
- package/src/Load.tsx +0 -68
- package/src/Numeral.tsx +0 -242
- package/src/PanelRK.tsx +0 -1
- package/src/Phone.tsx +0 -284
- package/src/Press.tsx +0 -1
- package/src/Radio.tsx +0 -1
- package/src/Scroll.tsx +0 -1
- package/src/Tab.tsx +0 -309
- package/src/Text.tsx +0 -21
- package/src/TextInput.tsx +0 -1
- package/src/common.tsx +0 -3439
- package/src/index.tsx +0 -22
- package/src/regions.ts +0 -258
- package/src/shadows.ts +0 -1
package/src/Button.tsx
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import React, { ReactNode } from "react";
|
|
2
|
-
import { ActivityIndicator, StyleProp, TouchableOpacity, ViewStyle } from "react-native";
|
|
3
|
-
import { MText } from "./Text";
|
|
4
|
-
|
|
5
|
-
const colorsBg = {
|
|
6
|
-
"primary": "#3b82f6",
|
|
7
|
-
"success": "#22c55e",
|
|
8
|
-
"warning": "#f97316",
|
|
9
|
-
"secondary": "#14b8a6",
|
|
10
|
-
"danger": "#ca251a",
|
|
11
|
-
"light": "white",
|
|
12
|
-
"smokelight": "#f7f7f7",
|
|
13
|
-
"navy": "#3e4b67",
|
|
14
|
-
"orange": "#ff4e02",
|
|
15
|
-
"darksky": "#004d6c",
|
|
16
|
-
"metalic": "#43484b"
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const colorsBr = {
|
|
20
|
-
"primary": "#3b82f6",
|
|
21
|
-
"success": "#22c55e",
|
|
22
|
-
"warning": "#f97316",
|
|
23
|
-
"secondary": "#14b8a6",
|
|
24
|
-
"danger": "#ca251a",
|
|
25
|
-
"light": "#dadce0",
|
|
26
|
-
"smokelight": "white",
|
|
27
|
-
"navy": "#3e4b67",
|
|
28
|
-
"orange": "#ff4e02",
|
|
29
|
-
"darksky": "#004d6c",
|
|
30
|
-
"metalic": "#43484b"
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
const colorTxt = {
|
|
34
|
-
"primary": "white",
|
|
35
|
-
"success": "white",
|
|
36
|
-
"warning": "white",
|
|
37
|
-
"secondary": "white",
|
|
38
|
-
"danger": "white",
|
|
39
|
-
"light": "black",
|
|
40
|
-
"smokelight": "black",
|
|
41
|
-
"navy": "white",
|
|
42
|
-
"orange": "white",
|
|
43
|
-
"darksky": "white",
|
|
44
|
-
"metalic": "white"
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const colorTxtOutline = {
|
|
48
|
-
"primary": "#3b82f6",
|
|
49
|
-
"success": "#22c55e",
|
|
50
|
-
"warning": "#f97316",
|
|
51
|
-
"secondary": "#14b8a6",
|
|
52
|
-
"danger": "#ca251a",
|
|
53
|
-
"light": "black",
|
|
54
|
-
"smokelight": "black",
|
|
55
|
-
"navy": "#3e4b67",
|
|
56
|
-
"orange": "#ff4e02",
|
|
57
|
-
"darksky": "#004d6c",
|
|
58
|
-
"metalic": "#43484b"
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
interface MButtonProps {
|
|
63
|
-
testID?: string;
|
|
64
|
-
size?: "xs" | "sm" | "md" | "nm";
|
|
65
|
-
noSizeLimit?: boolean;
|
|
66
|
-
style?: StyleProp<ViewStyle>;
|
|
67
|
-
label?: string;
|
|
68
|
-
textAlign?: "center" | "left" | "right";
|
|
69
|
-
disabled?: boolean;
|
|
70
|
-
outline?: boolean;
|
|
71
|
-
noborder?: boolean;
|
|
72
|
-
loading?: boolean;
|
|
73
|
-
btnType: "primary" | "success" | "warning" | "secondary" | "danger" | "light" | "navy" | "smokelight" | "orange" | "darksky" | "metalic";
|
|
74
|
-
fontWeight?: 'normal' | 'bold' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900' | undefined;
|
|
75
|
-
onPress?: () => void;
|
|
76
|
-
children?: ReactNode;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export function MButton({
|
|
80
|
-
testID,
|
|
81
|
-
size = "md",
|
|
82
|
-
noSizeLimit = false,
|
|
83
|
-
style,
|
|
84
|
-
label,
|
|
85
|
-
textAlign = "center",
|
|
86
|
-
fontWeight = "500",
|
|
87
|
-
disabled,
|
|
88
|
-
outline,
|
|
89
|
-
noborder,
|
|
90
|
-
loading,
|
|
91
|
-
btnType,
|
|
92
|
-
onPress,
|
|
93
|
-
children
|
|
94
|
-
}: MButtonProps) {
|
|
95
|
-
return (
|
|
96
|
-
<TouchableOpacity
|
|
97
|
-
testID={testID}
|
|
98
|
-
style={[
|
|
99
|
-
disabled || loading ? { opacity: 0.55 } : {},
|
|
100
|
-
{
|
|
101
|
-
flex: 1,
|
|
102
|
-
height: noSizeLimit ? null : size === "nm" ? 49 : size === "md" ? 45 : size === "xs" ? 27 : 33,
|
|
103
|
-
minHeight: noSizeLimit ? null : size === "nm" ? 49 : size === "md" ? 45 : size === "xs" ? 27 : 33,
|
|
104
|
-
maxHeight: noSizeLimit ? null : size === "nm" ? 49 : size === "md" ? 45 : size === "xs" ? 27 : 33,
|
|
105
|
-
backgroundColor: "purple",
|
|
106
|
-
display: "flex",
|
|
107
|
-
flexDirection: "row",
|
|
108
|
-
justifyContent: "center",
|
|
109
|
-
alignItems: "center",
|
|
110
|
-
borderRadius: 2
|
|
111
|
-
},
|
|
112
|
-
{ backgroundColor: outline && btnType !== "smokelight" ? "white" : colorsBg[btnType] },
|
|
113
|
-
outline ? { borderWidth: 1, borderColor: colorsBr[btnType] } : {},
|
|
114
|
-
style,
|
|
115
|
-
noborder ? { borderWidth: 0 } : {}
|
|
116
|
-
]}
|
|
117
|
-
activeOpacity={0.85}
|
|
118
|
-
disabled={disabled || loading}
|
|
119
|
-
onPress={onPress}
|
|
120
|
-
>
|
|
121
|
-
{loading ? (
|
|
122
|
-
<ActivityIndicator size={21} color="purple" style={{ flex: 1, marginLeft: 9, marginRight: 9 }} />
|
|
123
|
-
) : (
|
|
124
|
-
label ? (
|
|
125
|
-
<MText
|
|
126
|
-
style={{
|
|
127
|
-
flex: 1,
|
|
128
|
-
textAlign: textAlign,
|
|
129
|
-
color: outline ? colorTxtOutline[btnType] : colorTxt[btnType],
|
|
130
|
-
fontSize: size === "nm" ? 18 : size === "md" ? 16 : size === "xs" ? 11 : 14,
|
|
131
|
-
paddingHorizontal: 11,
|
|
132
|
-
fontWeight: fontWeight
|
|
133
|
-
}}>
|
|
134
|
-
{label}
|
|
135
|
-
</MText>
|
|
136
|
-
) : (
|
|
137
|
-
children
|
|
138
|
-
)
|
|
139
|
-
)}
|
|
140
|
-
</TouchableOpacity>
|
|
141
|
-
)
|
|
142
|
-
}
|
package/src/Checkbox.tsx
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import React, { TextStyle, TouchableHighlight, TouchableHighlightProps, View } from "react-native"; import { MText } from "./Text"; interface MCheckboxProps extends TouchableHighlightProps { name?: string; value: string | number | boolean; checked?: boolean; size?: number; color: string; label: string; labelStyle?: TextStyle; onChange?: (values: string | number | boolean, checked: boolean, name?: string) => void; }; export function MCheckbox({ name = "", value, checked, color, label, size = 26, labelStyle, style, onChange, ...props }: MCheckboxProps) { return (<TouchableHighlight activeOpacity={0.85} {...props} onPress={() => { if (onChange) { onChange(checked ? "" : value, !checked, name); } }} underlayColor="transparent" style={[{ flex: 1, maxHeight: size }, style]}><View style={{ flexDirection: "row", alignItems: "center" }}><View style={{ padding: 4, width: size, minHeight: size, height: size, borderWidth: 1, borderColor: color, backgroundColor: "white", display: "flex", justifyContent: "center", alignItems: "center" }}><View style={{ width: size - 8, minHeight: size - 8, height: size - 8, backgroundColor: checked ? color : "white" }} /></View><MText style={[{ fontSize: 16, paddingLeft: 11 }, labelStyle]}>{label}</MText></View></TouchableHighlight>) }
|
package/src/Divider.tsx
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import React, { ReactNode } from "react"; import { StyleProp, TextStyle, View } from "react-native"; import { MText } from "./Text"; interface MDividerProps { testID?: string; label: string; description?: string; labelStyle?: StyleProp<TextStyle>; descStyle?: StyleProp<TextStyle>; children?: ReactNode; }; export function MDivider(props: MDividerProps) { return (<View testID={props.testID} style={{ padding: 3, paddingVertical: 15, borderBottomWidth: 1, borderBottomColor: "#dadce0" }}><MText style={[{ color: "grey", fontSize: 15 }, props.labelStyle]}>{props.label}</MText><View style={{ marginTop: 5 }}>{props.description?<MText style={[{ width: "100%", color: "black", fontSize: 15, fontWeight: "500" }, props.descStyle]}>{props.description}</MText>:(props.children || <MText style={[{ width: "100%", color: "black", fontSize: 15, fontWeight: "500" }, props.descStyle]}>-</MText>)}</View></View> ) }
|
package/src/EasyIn.tsx
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import React, { FC, useEffect } from "react"; import { Animated, StyleProp, Text, TextStyle, ViewProps } from "react-native"; type MEasyInProps = ViewProps & { direction?: "vr" | "hr"; from?: number; to?: number; duration?: number; children?: React.ReactNode; }; export const MEasyIn: FC<MEasyInProps> = ({ style, direction = "hr", from = 85, to = 0, duration = 500, children, ...props }) => { const popAnim = React.useRef(new Animated.Value(from)).current; useEffect(() => { Animated.timing(popAnim, { toValue: to, duration: duration, useNativeDriver: true, }).start(); }, []); return (<Animated.View {...props} style={[style, { transform: [direction === "hr" ? { translateX: popAnim } : { translateY: popAnim }] }]}>{children}</Animated.View>); }; type MOpacityProps = ViewProps & { from?: number; to?: number; duration?: number; children?: React.ReactNode; }; export function MOpacity({ style, from = 0, to = 1, duration = 500, children, ...props }: MOpacityProps) { const popAnim = React.useRef(new Animated.Value(from)).current; useEffect(() => { Animated.timing(popAnim, { toValue: to, duration: duration, useNativeDriver: true, }).start(); }, []); return (<Animated.View {...props} style={[style, { opacity: popAnim }]}>{children}</Animated.View>); }; interface MEmptyProps { size?: number; style?: StyleProp<TextStyle>; }; export function MEmpty({ size = 35, style }: MEmptyProps) { return (<Text style={[{ fontSize: size, textAlign: "center", letterSpacing: 0.63 }, style]}>📥</Text>); } export function MIPlay({ size = 19, style }: MEmptyProps) { return (<Text style={[{ fontSize: size, textAlign: "center", letterSpacing: 0.63 }, style]}>►</Text>); } export function MIPause({ size = 19, style }: MEmptyProps) { return (<Text style={[{ fontSize: size, textAlign: "center", letterSpacing: 0.63 }, style]}>📥</Text>); } export function MIStop({ size = 19, style }: MEmptyProps) { return (<Text style={[{ fontSize: size, textAlign: "center", letterSpacing: 0.63 }, style]}>📥</Text>); }
|
package/src/FlatList.tsx
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import React, { forwardRef } from "react"; import { FlatList, FlatListProps } from "react-native"; interface MFlatListProps<T> extends FlatListProps<T> { initialNumToRender?: number; }; export const MFlatList = forwardRef<FlatList, MFlatListProps<any>>(({ contentContainerStyle, ...props }, ref) => { return (<FlatList ref={ref} scrollEnabled={true} initialNumToRender={15} {...props} contentContainerStyle={[{ flexGrow: 1, paddingBottom: 125 }, contentContainerStyle]} />); })
|
package/src/FlatPanel.tsx
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import React, { ReactNode } from "react"; import { Dimensions, StyleProp, View, ViewStyle } from "react-native"; interface IFlatPanelProps { position: "top-left" | "top-right" | "bottom-left" | "bottom-right" | "left-center" | "right-center" | "top- center" | "bottom-center"; style?: StyleProp<ViewStyle>; children?: ReactNode; }; const positionconstains = { "top-left": { top: 9, left: 9 }, "top-right": { top: 9, right: 9 }, "top-center": { top: 0, left: 9, right: 9,display: "flex", flexDirection: "row", justifyContent: "center" }, "bottom-left": { bottom: 9, left: 9 }, "bottom-right": { bottom: 9, right: 9 }, "bottom-center": { bottom: 0, left: 9, right: 9, display: "flex", flexDirection: "row", justifyContent: "center" }, "left-center": { top: Dimensions.get("window").height / 2.0, left: 9 }, "right-center": { top: Dimensions.get("window").height / 2.0, right: 9 }, }; export function MFlatPanel(props: IFlatPanelProps) { return (<View style={[ { position: "absolute", zIndex: 99, backgroundColor: "transparent", alignItems: props.position.includes("right") ? "flex-end" : "flex-start", }, positionconstains[props.position] || positionconstains["top-center"], props.style ]}>{props.children}</View>) }
|
package/src/Grid.tsx
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import React, { ReactElement, useMemo } from "react"; import { StyleProp, View, ViewStyle } from "react-native"; interface IColProps { colSpan: number; style?: StyleProp<ViewStyle>; children?: React.ReactNode; }; export function MCol({ }: IColProps) { return (<React.Fragment></React.Fragment>); } interface IMGridProps { testID?: string; cols?: number; content?: "flex-start" | "flex-end" | "center" | "space-between" | "space-around" | "space-evenly"; items?: "flex-start" | "flex-end" | "center" | "stretch" | "baseline"; style?: StyleProp<ViewStyle>; gap?: number; children: ReactElement<IColProps> | Array<ReactElement<IColProps>>; }; function calc(cols: number = 12) { let _cols = Number(cols) || 12; _cols = _cols <= 0 ? 12 : cols; return Number((100.0 / _cols).toFixed(5)); }; export function MGrid(props: IMGridProps) { const span = useMemo(() => { return calc(props.cols); }, [props.cols]); return (<View testID={props.testID} style={[ { display: "flex", flexDirection: "row", flexWrap: "wrap", justifyContent: props.content, alignItems: props.items, columnGap: props.gap }, props.style, ]}>{(Array.isArray(props.children) ? props.children : [props.children])?.map(k => {return(<View style={[k.props.style, { flex: (span * k.props.colSpan) || 0 }]}>{k.props.children}</View>);})}</View>) }
|
package/src/InputField.tsx
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import React, { ReactNode } from "react"; import { TextStyle, View, ViewStyle, StyleProp } from "react-native"; import { MText } from "./Text"; interface InputFieldProps { testID?: string; label?: string; containerStyle?: StyleProp<ViewStyle>; labelStyle?: StyleProp<TextStyle>; children?: ReactNode; }; export function MInputField(props: InputFieldProps) {return (<View testID={props.testID} style={[{ width: "100%", marginVertical: 5 }, props.containerStyle]}>{props.label?<MText style={[{ color: "black", marginBottom: 3, fontSize: 15, paddingHorizontal: 3, fontWeight: "500" }, props.labelStyle]}>{props.label}</MText>:<React.Fragment></React.Fragment>}<View>{props.children}</View></View>); }; type MInputSetFieldProps = InputFieldProps & { noBackground?: boolean, border?: boolean }; export function MInputSetField(props: MInputSetFieldProps) { return (<View testID={props.testID} style={[{ width: "100%", marginVertical: 5 }, props.border ? { borderWidth: 1, borderColor: "#dadce0" } : {}, props.containerStyle]}>{props.label?<MText style={[ { color: "black", fontWeight: "500", marginBottom: 3, paddingHorizontal: 7, paddingVertical: 1, fontSize: 15, top: -11.5, left: 7, zIndex: 105, position: "absolute", borderLeftWidth: 1, borderRightWidth: 1, borderColor: "#dadce0" }, props.noBackground ? {} : { backgroundColor: "white" }, props.labelStyle ]}>{props.label}</MText>:<React.Fragment></React.Fragment>}<View>{props.children}</View></View>); }
|
package/src/Line.tsx
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import React from "react"
|
|
2
|
-
import { StyleProp, View, ViewStyle } from "react-native"
|
|
3
|
-
|
|
4
|
-
interface HrProps {
|
|
5
|
-
margin?: number
|
|
6
|
-
direction?: "w" | "h"
|
|
7
|
-
style?: StyleProp<ViewStyle>
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export function MLine({ direction = "w", margin = 5, style }: HrProps) {
|
|
11
|
-
return (<View style={[
|
|
12
|
-
direction === "w" ? { flex: 1, height: 1, maxHeight: 1, marginVertical: margin } : { flex: 1, width: 1, maxWidth: 1, marginHorizontal: margin },
|
|
13
|
-
{ backgroundColor: "#dadce0" },
|
|
14
|
-
style
|
|
15
|
-
]} />)
|
|
16
|
-
}
|
package/src/Load.tsx
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import React, { ComponentProps, useCallback, useEffect, useRef, useState } from "react";
|
|
2
|
-
import { ActivityIndicator, View } from "react-native";
|
|
3
|
-
|
|
4
|
-
function LoadActivity() {
|
|
5
|
-
return (
|
|
6
|
-
<View style={{ flex: 1, display: "flex", justifyContent: "center", alignItems: "center" }}>
|
|
7
|
-
<ActivityIndicator size={45} color="#016db6" />
|
|
8
|
-
</View>
|
|
9
|
-
);
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
interface MLoadProps extends ComponentProps<any> {
|
|
13
|
-
loadId: string;
|
|
14
|
-
showLoading?: boolean;
|
|
15
|
-
name?: string;
|
|
16
|
-
delay?: number;
|
|
17
|
-
load: () => Promise<{}>;
|
|
18
|
-
onLoaded?: () => void;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export function MLoad({ loadId, showLoading, name = "default", delay, load, ...props }: MLoadProps) {
|
|
22
|
-
const [loaded, setLoaded] = useState<boolean>(false);
|
|
23
|
-
const loadIfRef = useRef<string>();
|
|
24
|
-
const timeRef = useRef<any>();
|
|
25
|
-
const ref = useRef<any>();
|
|
26
|
-
|
|
27
|
-
const loadCmp = useCallback(async () => {
|
|
28
|
-
try {
|
|
29
|
-
if (!timeRef.current) {
|
|
30
|
-
setLoaded(false);
|
|
31
|
-
|
|
32
|
-
timeRef.current = setTimeout(async () => {
|
|
33
|
-
try {
|
|
34
|
-
ref.current = await load();
|
|
35
|
-
if (props.onLoaded) {
|
|
36
|
-
props.onLoaded();
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
clearTimeout(timeRef.current);
|
|
40
|
-
timeRef.current = undefined;
|
|
41
|
-
loadIfRef.current = loadId;
|
|
42
|
-
setLoaded(true);
|
|
43
|
-
} catch (error) {
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
}, delay || 25);
|
|
47
|
-
}
|
|
48
|
-
} catch (error) {
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
}, [timeRef, loadId, props.load, props.name]);
|
|
52
|
-
|
|
53
|
-
useEffect(() => {
|
|
54
|
-
loadCmp();
|
|
55
|
-
return () => {
|
|
56
|
-
clearTimeout(timeRef.current)
|
|
57
|
-
};
|
|
58
|
-
}, [loadCmp]);
|
|
59
|
-
|
|
60
|
-
if (showLoading && !loaded) {
|
|
61
|
-
return (<LoadActivity />);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const Component = ref.current && ref.current[name] ? ref.current[name] : LoadActivity;
|
|
65
|
-
|
|
66
|
-
return (
|
|
67
|
-
<Component key={loadIfRef.current} {...props} />);
|
|
68
|
-
}
|
package/src/Numeral.tsx
DELETED
|
@@ -1,242 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { cts, stc } from "./common";
|
|
3
|
-
/**
|
|
4
|
-
* @param fraction default 2
|
|
5
|
-
* @param thousandSeperator default true
|
|
6
|
-
*/
|
|
7
|
-
export interface INumeralOptions {
|
|
8
|
-
fraction?: number;
|
|
9
|
-
thousandSeperator?: boolean;
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* @param gte >= Y
|
|
13
|
-
* @param gt > Y
|
|
14
|
-
* @param lte <= Y
|
|
15
|
-
* @param lt < Y
|
|
16
|
-
*/
|
|
17
|
-
export interface NumeralValidity {
|
|
18
|
-
gte?: number;
|
|
19
|
-
gt?: number;
|
|
20
|
-
lte?: number;
|
|
21
|
-
lt?: number;
|
|
22
|
-
};
|
|
23
|
-
export interface NumeralUtil {
|
|
24
|
-
/**
|
|
25
|
-
* @param code country iat code or currency symbol, if it is empty set it geves from global
|
|
26
|
-
* @returns
|
|
27
|
-
*/
|
|
28
|
-
setCode: (code?: string) => void;
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* @param code country iat code or currency symbol, if it is empty set it geves from global
|
|
32
|
-
* @returns
|
|
33
|
-
*/
|
|
34
|
-
currency: (value: number, code?: string | null, thousandSeperator?: boolean | null, fraction?: number, direction?: "ltr" | "rtl") => string;
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* @param code country iat code or currency symbol, if it is empty set it geves from global
|
|
38
|
-
* @returns
|
|
39
|
-
*/
|
|
40
|
-
format: (value: number, code?: string | null, thousandSeperator?: boolean | null, fraction?: number) => string;
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* @param code country iat code or currency symbol, if it is empty set it geves from global
|
|
44
|
-
* @returns
|
|
45
|
-
*/
|
|
46
|
-
parseRaw: (value: string, code?: string | null, fraction?: number) => string;
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
*
|
|
50
|
-
* @returns
|
|
51
|
-
*/
|
|
52
|
-
toNumber: (value: string | number, fraction?: number) => number;
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
*
|
|
56
|
-
* @returns
|
|
57
|
-
*/
|
|
58
|
-
toFloat: (value: string | number, fraction?: number) => number;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* @param code country iat code or currency symbol, if it is empty set it geves from global
|
|
62
|
-
*/
|
|
63
|
-
export interface ICurrencySlotProps {
|
|
64
|
-
direction?: "ltr" | "ltr";
|
|
65
|
-
value: number;
|
|
66
|
-
code?: string;
|
|
67
|
-
thousandSeperator?: boolean | null;
|
|
68
|
-
fraction?: number;
|
|
69
|
-
};
|
|
70
|
-
/**
|
|
71
|
-
* @param code country iat code or currency symbol, if it is empty set it geves from global
|
|
72
|
-
*/
|
|
73
|
-
export interface NumeralSlotProps {
|
|
74
|
-
value: number;
|
|
75
|
-
code?: string;
|
|
76
|
-
thousandSeperator?: boolean | null;
|
|
77
|
-
fraction?: number;
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
const fractionDefault: number = 2;
|
|
81
|
-
const isopt = (k: any) => k == undefined || k === null;
|
|
82
|
-
const setFraction = (defaultval: number, fraction?: number) => isopt(fraction) ? defaultval : fraction;
|
|
83
|
-
const decOptions = (fraction?: number) => {
|
|
84
|
-
const value = setFraction(fractionDefault, fraction)
|
|
85
|
-
return { minimumFractionDigits: value, maximumFractionDigits: value };
|
|
86
|
-
}
|
|
87
|
-
const fraction = (value: number, fraction: number) => fraction === 0 ? Math.floor(value) : value;
|
|
88
|
-
const cache = {
|
|
89
|
-
code: "",
|
|
90
|
-
countryCode: null,
|
|
91
|
-
symbol: "",
|
|
92
|
-
separatorThousands: "",
|
|
93
|
-
separatorDecimal: "",
|
|
94
|
-
regexThousands: /[]/g,
|
|
95
|
-
regexDecimal: /[]/g
|
|
96
|
-
};
|
|
97
|
-
class Numeral {
|
|
98
|
-
private fraction?: number;
|
|
99
|
-
private thousandSeperator: boolean = false;
|
|
100
|
-
|
|
101
|
-
static new() {
|
|
102
|
-
return new Numeral();
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
static convert(value: number | string, fraction?: number): number {
|
|
106
|
-
if (isopt(fraction)) {
|
|
107
|
-
return Number(value);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
return Number(Number((value || "").toString().replace(",", ".")).toFixed(fraction));
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
init(code?: string) {
|
|
114
|
-
if (code !== cache.code) {
|
|
115
|
-
cache.code = code;
|
|
116
|
-
cache.countryCode = stc[code] || cts[code];
|
|
117
|
-
if (stc[code]) {
|
|
118
|
-
cache.countryCode = stc[code];
|
|
119
|
-
} else if (cts[code]) {
|
|
120
|
-
cache.countryCode = code;
|
|
121
|
-
}
|
|
122
|
-
cache.symbol = cts[cache.countryCode] || "?";
|
|
123
|
-
cache.separatorThousands = new Intl.NumberFormat(cache.countryCode, { style: "decimal" }).format(1111).replace(/\d/g, "");
|
|
124
|
-
cache.separatorDecimal = new Intl.NumberFormat(cache.countryCode, { style: "decimal" }).format(11.11).replace(/\d/g, "");
|
|
125
|
-
|
|
126
|
-
cache.regexThousands = new RegExp(`[${cache.separatorThousands}]`, "g");
|
|
127
|
-
cache.regexDecimal = new RegExp(`[${cache.separatorDecimal}]`, "g");
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
return this;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
setFraction(val?: number) {
|
|
134
|
-
this.fraction = val;
|
|
135
|
-
return this;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
setThousandSeperator(val: boolean = false) {
|
|
139
|
-
this.thousandSeperator = val;
|
|
140
|
-
return this;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
format(value: number): string {
|
|
144
|
-
try {
|
|
145
|
-
const amount = fraction(Number(value), this.fraction);
|
|
146
|
-
const stt = decOptions(this.fraction);
|
|
147
|
-
const amountformat = new Intl.NumberFormat(cache.countryCode, stt).format(amount);
|
|
148
|
-
return this.thousandSeperator ? amountformat.replace(cache.regexThousands, "") : amountformat;
|
|
149
|
-
} catch (error) {
|
|
150
|
-
return "";
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
inputFormat(value: number): string {
|
|
155
|
-
try {
|
|
156
|
-
const amountformat = this.format(value);
|
|
157
|
-
return amountformat.replace(cache.regexThousands, "");
|
|
158
|
-
} catch (error) {
|
|
159
|
-
return "";
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
currency(value: number, direction: "ltr" | "rtl" = "ltr") {
|
|
164
|
-
try {
|
|
165
|
-
const amountformat = this.format(value);
|
|
166
|
-
return direction === "ltr" ? `${amountformat}${cache.symbol}` : `${cache.symbol}${amountformat}`;
|
|
167
|
-
} catch (error) {
|
|
168
|
-
return "";
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
parseRawFormat(value: string) {
|
|
173
|
-
const stringNumber = (value || "")
|
|
174
|
-
.replace(cache.regexThousands, "")
|
|
175
|
-
.replace(cache.regexDecimal, ".")
|
|
176
|
-
.replace(new RegExp(`[${cache.symbol}]`, "g"), "");
|
|
177
|
-
|
|
178
|
-
const amount = fraction(parseFloat(stringNumber), this.fraction);
|
|
179
|
-
|
|
180
|
-
return stringNumber ? amount.toFixed(setFraction(fractionDefault, this.fraction)) : stringNumber;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
export const numeral: NumeralUtil = (() => {
|
|
184
|
-
let _code: string = null;
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* @param code country iat code or currency symbol, if it is empty set it geves from global
|
|
188
|
-
* @returns
|
|
189
|
-
*/
|
|
190
|
-
function setCode(code?: string) {
|
|
191
|
-
_code = code;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* @param code country iat code or currency symbol, if it is empty set it geves from global
|
|
196
|
-
*/
|
|
197
|
-
function currency(value: number, code?: string | null, thousandSeperator?: boolean | null, fraction?: number, direction: "ltr" | "rtl" = "ltr") {
|
|
198
|
-
return Numeral.new().init(code || _code).setFraction(fraction).setThousandSeperator(thousandSeperator).currency(value, direction);
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* @param code country iat code or currency symbol, if it is empty set it geves from global
|
|
203
|
-
*/
|
|
204
|
-
function format(value: number, code?: string | null, thousandSeperator?: boolean | null, fraction?: number) {
|
|
205
|
-
return Numeral.new().init(code || _code).setFraction(fraction).setThousandSeperator(thousandSeperator).format(value);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
/**
|
|
209
|
-
* @param code country iat code or currency symbol, if it is empty set it geves from global
|
|
210
|
-
*/
|
|
211
|
-
function parseRaw(value: string, code?: string | null, fraction?: number) {
|
|
212
|
-
return Numeral.new().init(code || _code).setFraction(fraction).parseRawFormat(value);
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
/**
|
|
216
|
-
*
|
|
217
|
-
* @param value
|
|
218
|
-
* @param fraction
|
|
219
|
-
* @returns
|
|
220
|
-
*/
|
|
221
|
-
function toNumber(value: string | number, fraction?: number): number {
|
|
222
|
-
return Numeral.convert(value, fraction);
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
*
|
|
227
|
-
* @param value
|
|
228
|
-
* @param fraction
|
|
229
|
-
* @returns
|
|
230
|
-
*/
|
|
231
|
-
function toFloat(value: string | number, fraction: number = 2): number {
|
|
232
|
-
return Numeral.convert(value, fraction);
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
return { setCode, currency, format, parseRaw, toNumber, toFloat };
|
|
236
|
-
})();
|
|
237
|
-
export function CurrencySlot(props: ICurrencySlotProps) {
|
|
238
|
-
return (<React.Fragment>{numeral.currency(props.value, props.code, props.thousandSeperator, props.fraction)}</React.Fragment>)
|
|
239
|
-
}
|
|
240
|
-
export function NumeralSlot(props: NumeralSlotProps) {
|
|
241
|
-
return (<React.Fragment>{numeral.format(props.value, props.code, props.thousandSeperator, props.fraction)}</React.Fragment>)
|
|
242
|
-
}
|
package/src/PanelRK.tsx
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import React from "react"; import { TouchableOpacity, TouchableOpacityProps } from "react-native"; interface MPanelRkProps extends TouchableOpacityProps { children?: React.ReactNode; }; export function MPanelRK({ style, children, ...props }: MPanelRkProps) { return (<TouchableOpacity style={[ { backgroundColor: "white", height: 53, borderWidth: 1, borderColor: "gray", marginTop: 7, marginBottom: 7, padding: 11, paddingHorizontal: 9, display: "flex", flexDirection: "row", alignItems: "center" }, style ]} {...props}>{children}</TouchableOpacity>); }
|