@adiraku/react-native-ui 0.1.17 → 0.2.1
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 +38 -59
- package/lib/commonjs/components/Appbar/Appbar.component.js +9 -6
- package/lib/commonjs/components/Appbar/Appbar.component.js.map +1 -1
- package/lib/commonjs/components/BottomSheet/BottomSheet.component.js +9 -6
- package/lib/commonjs/components/BottomSheet/BottomSheet.component.js.map +1 -1
- package/lib/commonjs/components/CheckBoxInput/CheckBoxInput.component.js +1 -3
- package/lib/commonjs/components/CheckBoxInput/CheckBoxInput.component.js.map +1 -1
- package/lib/commonjs/components/RadioInput/RadioInput.component.js +1 -3
- package/lib/commonjs/components/RadioInput/RadioInput.component.js.map +1 -1
- package/lib/commonjs/components/Snackbar/Snackbar.component.js +49 -1
- package/lib/commonjs/components/Snackbar/Snackbar.component.js.map +1 -1
- package/lib/commonjs/components/Snackbar/Snakbar.style.js +4 -0
- package/lib/commonjs/components/Snackbar/Snakbar.style.js.map +1 -1
- package/lib/commonjs/components/TextInput/TextInput.component.js +3 -7
- package/lib/commonjs/components/TextInput/TextInput.component.js.map +1 -1
- package/lib/commonjs/components/button/button.component.js +8 -3
- package/lib/commonjs/components/button/button.component.js.map +1 -1
- package/lib/commonjs/components/countdown/countdown.component.js +45 -47
- package/lib/commonjs/components/countdown/countdown.component.js.map +1 -1
- package/lib/commonjs/components/countdown/countdown.style.js +2 -1
- package/lib/commonjs/components/countdown/countdown.style.js.map +1 -1
- package/lib/commonjs/components/index.js +6 -0
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/module/components/Appbar/Appbar.component.js +9 -6
- package/lib/module/components/Appbar/Appbar.component.js.map +1 -1
- package/lib/module/components/BottomSheet/BottomSheet.component.js +9 -6
- package/lib/module/components/BottomSheet/BottomSheet.component.js.map +1 -1
- package/lib/module/components/CheckBoxInput/CheckBoxInput.component.js +1 -3
- package/lib/module/components/CheckBoxInput/CheckBoxInput.component.js.map +1 -1
- package/lib/module/components/RadioInput/RadioInput.component.js +1 -3
- package/lib/module/components/RadioInput/RadioInput.component.js.map +1 -1
- package/lib/module/components/Snackbar/Snackbar.component.js +48 -2
- package/lib/module/components/Snackbar/Snackbar.component.js.map +1 -1
- package/lib/module/components/Snackbar/Snakbar.style.js +4 -0
- package/lib/module/components/Snackbar/Snakbar.style.js.map +1 -1
- package/lib/module/components/TextInput/TextInput.component.js +3 -7
- package/lib/module/components/TextInput/TextInput.component.js.map +1 -1
- package/lib/module/components/button/button.component.js +8 -3
- package/lib/module/components/button/button.component.js.map +1 -1
- package/lib/module/components/countdown/countdown.component.js +45 -47
- package/lib/module/components/countdown/countdown.component.js.map +1 -1
- package/lib/module/components/countdown/countdown.style.js +2 -1
- package/lib/module/components/countdown/countdown.style.js.map +1 -1
- package/lib/module/components/index.js +1 -1
- package/lib/module/components/index.js.map +1 -1
- package/lib/typescript/components/Appbar/Appbar.component.d.ts.map +1 -1
- package/lib/typescript/components/Appbar/Appbar.type.d.ts +4 -0
- package/lib/typescript/components/Appbar/Appbar.type.d.ts.map +1 -1
- package/lib/typescript/components/BottomSheet/BottomSheet.component.d.ts.map +1 -1
- package/lib/typescript/components/BottomSheet/BottomSheet.type.d.ts +4 -0
- package/lib/typescript/components/BottomSheet/BottomSheet.type.d.ts.map +1 -1
- package/lib/typescript/components/CheckBoxInput/CheckBoxInput.component.d.ts.map +1 -1
- package/lib/typescript/components/RadioInput/RadioInput.component.d.ts.map +1 -1
- package/lib/typescript/components/Snackbar/Snackbar.component.d.ts +10 -3
- package/lib/typescript/components/Snackbar/Snackbar.component.d.ts.map +1 -1
- package/lib/typescript/components/Snackbar/Snakbar.style.d.ts +1 -0
- package/lib/typescript/components/Snackbar/Snakbar.style.d.ts.map +1 -1
- package/lib/typescript/components/TextInput/TextInput.component.d.ts.map +1 -1
- package/lib/typescript/components/button/button.component.d.ts.map +1 -1
- package/lib/typescript/components/countdown/countdown.component.d.ts.map +1 -1
- package/lib/typescript/components/countdown/countdown.style.d.ts.map +1 -1
- package/lib/typescript/components/countdown/countdown.type.d.ts +5 -0
- package/lib/typescript/components/countdown/countdown.type.d.ts.map +1 -1
- package/lib/typescript/components/index.d.ts +1 -1
- package/lib/typescript/components/index.d.ts.map +1 -1
- package/package.json +5 -3
- package/src/components/Appbar/Appbar.component.tsx +9 -1
- package/src/components/Appbar/Appbar.type.ts +7 -0
- package/src/components/BottomSheet/BottomSheet.component.tsx +9 -3
- package/src/components/BottomSheet/BottomSheet.type.ts +8 -0
- package/src/components/CheckBoxInput/CheckBoxInput.component.tsx +0 -1
- package/src/components/RadioInput/RadioInput.component.tsx +0 -1
- package/src/components/Snackbar/Snackbar.component.tsx +53 -2
- package/src/components/Snackbar/Snakbar.style.tsx +6 -0
- package/src/components/TextInput/TextInput.component.tsx +3 -7
- package/src/components/button/button.component.tsx +8 -3
- package/src/components/countdown/countdown.component.tsx +44 -43
- package/src/components/countdown/countdown.style.tsx +1 -0
- package/src/components/countdown/countdown.type.ts +6 -0
- package/src/components/index.ts +1 -1
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { View } from 'react-native';
|
|
3
|
+
import RNToast, {
|
|
4
|
+
ToastProps,
|
|
5
|
+
ToastShowParams,
|
|
6
|
+
ToastHideParams,
|
|
7
|
+
} from 'react-native-toast-message';
|
|
3
8
|
|
|
4
9
|
import { Typography } from '../typography/typography.component';
|
|
5
10
|
import { getStyle } from './Snakbar.style';
|
|
6
11
|
|
|
7
12
|
import type { SnackbarProps } from './Snackbar.type';
|
|
8
13
|
|
|
9
|
-
const
|
|
14
|
+
const SnackbarUI: React.FunctionComponent<SnackbarProps> = (props) => {
|
|
10
15
|
const { message = '', action = null, containerStyle } = props;
|
|
11
16
|
|
|
12
17
|
const computedStyle = getStyle();
|
|
@@ -25,4 +30,50 @@ const Snackbar: React.FunctionComponent<SnackbarProps> = (props) => {
|
|
|
25
30
|
);
|
|
26
31
|
};
|
|
27
32
|
|
|
28
|
-
|
|
33
|
+
function SnackbarComponent(props: ToastProps) {
|
|
34
|
+
const computedStyle = getStyle();
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<RNToast
|
|
38
|
+
{...props}
|
|
39
|
+
config={{
|
|
40
|
+
...props.config,
|
|
41
|
+
// eslint-disable-next-line react/no-unstable-nested-components
|
|
42
|
+
aleph_toast: ({ props: toastProps }: { props: SnackbarProps }) => {
|
|
43
|
+
const { message, action } = toastProps;
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<View style={[computedStyle.snackbarWrapper]}>
|
|
47
|
+
<SnackbarUI message={message} action={action} />
|
|
48
|
+
</View>
|
|
49
|
+
);
|
|
50
|
+
},
|
|
51
|
+
}}
|
|
52
|
+
type="aleph_toast"
|
|
53
|
+
position="bottom"
|
|
54
|
+
/>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const Snackbar = {
|
|
59
|
+
show: (
|
|
60
|
+
params: Omit<ToastShowParams, 'props' | 'text1' | 'text2' | 'type'> & {
|
|
61
|
+
message: string;
|
|
62
|
+
action?: React.ReactNode;
|
|
63
|
+
}
|
|
64
|
+
) => {
|
|
65
|
+
const { message = '', action } = params;
|
|
66
|
+
RNToast.show({
|
|
67
|
+
...params,
|
|
68
|
+
props: {
|
|
69
|
+
message,
|
|
70
|
+
action,
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
},
|
|
74
|
+
hide: (params: ToastHideParams) => {
|
|
75
|
+
RNToast.hide(params);
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export { Snackbar, SnackbarComponent };
|
|
@@ -6,6 +6,7 @@ import type { ViewStyle, TextStyle } from 'react-native';
|
|
|
6
6
|
|
|
7
7
|
interface ComputedStyleProps {
|
|
8
8
|
container?: ViewStyle;
|
|
9
|
+
snackbarWrapper?: ViewStyle;
|
|
9
10
|
message?: TextStyle;
|
|
10
11
|
actionWrapper?: ViewStyle;
|
|
11
12
|
}
|
|
@@ -23,6 +24,11 @@ export const getStyle = () => {
|
|
|
23
24
|
...Shadow['shadow-elevation-1'],
|
|
24
25
|
};
|
|
25
26
|
|
|
27
|
+
computedStyle.snackbarWrapper = {
|
|
28
|
+
width: '100%',
|
|
29
|
+
paddingHorizontal: Spacing[16],
|
|
30
|
+
};
|
|
31
|
+
|
|
26
32
|
computedStyle.message = {
|
|
27
33
|
flex: 1,
|
|
28
34
|
};
|
|
@@ -50,27 +50,23 @@ const TextInput: React.FunctionComponent<TextInputProps> = (props) => {
|
|
|
50
50
|
}).start();
|
|
51
51
|
|
|
52
52
|
React.useEffect(() => {
|
|
53
|
-
if (value) {
|
|
53
|
+
if (focused || !!value) {
|
|
54
54
|
animate(1);
|
|
55
55
|
} else {
|
|
56
56
|
animate(0);
|
|
57
57
|
}
|
|
58
|
-
}, [value]);
|
|
58
|
+
}, [value, focused]);
|
|
59
59
|
|
|
60
60
|
const handleOnFocus = (
|
|
61
61
|
event: NativeSyntheticEvent<TextInputFocusEventData>
|
|
62
62
|
) => {
|
|
63
|
-
animate(1);
|
|
64
63
|
setFocused(true);
|
|
65
64
|
onBlur(event);
|
|
66
65
|
};
|
|
67
66
|
const handleOnBlur = (
|
|
68
67
|
event: NativeSyntheticEvent<TextInputFocusEventData>
|
|
69
68
|
) => {
|
|
70
|
-
|
|
71
|
-
animate(0);
|
|
72
|
-
onFocus(event);
|
|
73
|
-
}
|
|
69
|
+
onFocus(event);
|
|
74
70
|
setFocused(false);
|
|
75
71
|
};
|
|
76
72
|
|
|
@@ -12,20 +12,25 @@ const Button: React.FC<ButtonProps> = (props) => {
|
|
|
12
12
|
onPress = () => {},
|
|
13
13
|
variant = 'primary',
|
|
14
14
|
label = 'Default',
|
|
15
|
-
size = '
|
|
15
|
+
size = 'small',
|
|
16
16
|
containerStyles,
|
|
17
17
|
textStyles,
|
|
18
18
|
...rest
|
|
19
19
|
} = props;
|
|
20
20
|
|
|
21
|
-
const computedStyle = getStyle(
|
|
21
|
+
const computedStyle = getStyle({
|
|
22
|
+
...props,
|
|
23
|
+
variant,
|
|
24
|
+
label,
|
|
25
|
+
size,
|
|
26
|
+
});
|
|
22
27
|
|
|
23
28
|
return (
|
|
24
29
|
<TouchableHighlight
|
|
25
30
|
onPress={onPress}
|
|
26
31
|
style={[computedStyle.container, containerStyles]}
|
|
27
32
|
underlayColor={
|
|
28
|
-
variant
|
|
33
|
+
variant !== 'primary' ? Palettes.blue[50] : Palettes.black[800]
|
|
29
34
|
}
|
|
30
35
|
{...rest}
|
|
31
36
|
>
|
|
@@ -7,7 +7,15 @@ import type { CountdownProps } from './countdown.type';
|
|
|
7
7
|
import { getStyle } from './countdown.style';
|
|
8
8
|
|
|
9
9
|
const Countdown: React.FunctionComponent<CountdownProps> = (props) => {
|
|
10
|
-
const {
|
|
10
|
+
const {
|
|
11
|
+
targetDateTime,
|
|
12
|
+
formats = [
|
|
13
|
+
{ type: 'd', trailingString: ' hari' },
|
|
14
|
+
{ type: 'h' },
|
|
15
|
+
{ type: 'm' },
|
|
16
|
+
{ type: 's' },
|
|
17
|
+
],
|
|
18
|
+
} = props;
|
|
11
19
|
|
|
12
20
|
const computedStyle = getStyle();
|
|
13
21
|
|
|
@@ -21,59 +29,52 @@ const Countdown: React.FunctionComponent<CountdownProps> = (props) => {
|
|
|
21
29
|
}, 1000);
|
|
22
30
|
|
|
23
31
|
return () => clearInterval(timer);
|
|
24
|
-
}, []);
|
|
32
|
+
}, [targetDateTime]);
|
|
25
33
|
|
|
26
34
|
const formatTime = (time: number) => {
|
|
27
35
|
if (time <= 0) {
|
|
28
36
|
return {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
37
|
+
d: appendZero(0),
|
|
38
|
+
h: appendZero(0),
|
|
39
|
+
m: appendZero(0),
|
|
40
|
+
s: appendZero(0),
|
|
33
41
|
};
|
|
34
42
|
}
|
|
35
43
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
44
|
+
time /= 1000;
|
|
45
|
+
let day = Math.floor(time / (24 * 3600));
|
|
46
|
+
let remainingSeconds = time % (24 * 3600);
|
|
47
|
+
let hour = Math.floor(remainingSeconds / 3600);
|
|
48
|
+
remainingSeconds %= 3600;
|
|
49
|
+
let minute = Math.floor(remainingSeconds / 60);
|
|
50
|
+
let second = remainingSeconds % 60;
|
|
51
|
+
|
|
52
|
+
return {
|
|
53
|
+
d: Math.floor(day),
|
|
54
|
+
h: Math.floor(hour),
|
|
55
|
+
m: Math.floor(minute),
|
|
56
|
+
s: Math.floor(second),
|
|
57
|
+
};
|
|
42
58
|
};
|
|
43
59
|
|
|
44
60
|
return (
|
|
45
61
|
<View style={[computedStyle.container]}>
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
<Typography variant="overline">:</Typography>
|
|
63
|
-
</View>
|
|
64
|
-
<View style={[computedStyle.textContainer]}>
|
|
65
|
-
<Typography variant="overline" style={[computedStyle.textLabel]}>
|
|
66
|
-
{formatTime(timeLeft).minutes}
|
|
67
|
-
</Typography>
|
|
68
|
-
</View>
|
|
69
|
-
<View style={[computedStyle.dividerContainer]}>
|
|
70
|
-
<Typography variant="overline">:</Typography>
|
|
71
|
-
</View>
|
|
72
|
-
<View style={[computedStyle.textContainer]}>
|
|
73
|
-
<Typography variant="overline" style={[computedStyle.textLabel]}>
|
|
74
|
-
{formatTime(timeLeft).seconds}
|
|
75
|
-
</Typography>
|
|
76
|
-
</View>
|
|
62
|
+
{formats.map(({ type, leadingString = '', trailingString = '' }, idx) => {
|
|
63
|
+
return (
|
|
64
|
+
<>
|
|
65
|
+
<View style={[computedStyle.textContainer]}>
|
|
66
|
+
<Typography variant="overline" style={[computedStyle.textLabel]}>
|
|
67
|
+
{leadingString + formatTime(timeLeft)?.[type] + trailingString}
|
|
68
|
+
</Typography>
|
|
69
|
+
</View>
|
|
70
|
+
{idx !== formats.length - 1 ? (
|
|
71
|
+
<View style={[computedStyle.dividerContainer]}>
|
|
72
|
+
<Typography variant="overline">:</Typography>
|
|
73
|
+
</View>
|
|
74
|
+
) : null}
|
|
75
|
+
</>
|
|
76
|
+
);
|
|
77
|
+
})}
|
|
77
78
|
</View>
|
|
78
79
|
);
|
|
79
80
|
};
|
package/src/components/index.ts
CHANGED
|
@@ -16,7 +16,7 @@ export { RadioInput } from './RadioInput/RadioInput.component';
|
|
|
16
16
|
export { CheckBoxInput } from './CheckBoxInput/CheckBoxInput.component';
|
|
17
17
|
export { Checkbox } from './Checkbox/Checkbox.component';
|
|
18
18
|
export { Appbar } from './Appbar/Appbar.component';
|
|
19
|
-
export { Snackbar } from './Snackbar/Snackbar.component';
|
|
19
|
+
export { Snackbar, SnackbarComponent } from './Snackbar/Snackbar.component';
|
|
20
20
|
export { Switch } from './switch/switch.component';
|
|
21
21
|
export { Dot } from './dot/dot.component';
|
|
22
22
|
export { InformationBox } from './information-box/information-box.component';
|