@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.
Files changed (80) hide show
  1. package/README.md +38 -59
  2. package/lib/commonjs/components/Appbar/Appbar.component.js +9 -6
  3. package/lib/commonjs/components/Appbar/Appbar.component.js.map +1 -1
  4. package/lib/commonjs/components/BottomSheet/BottomSheet.component.js +9 -6
  5. package/lib/commonjs/components/BottomSheet/BottomSheet.component.js.map +1 -1
  6. package/lib/commonjs/components/CheckBoxInput/CheckBoxInput.component.js +1 -3
  7. package/lib/commonjs/components/CheckBoxInput/CheckBoxInput.component.js.map +1 -1
  8. package/lib/commonjs/components/RadioInput/RadioInput.component.js +1 -3
  9. package/lib/commonjs/components/RadioInput/RadioInput.component.js.map +1 -1
  10. package/lib/commonjs/components/Snackbar/Snackbar.component.js +49 -1
  11. package/lib/commonjs/components/Snackbar/Snackbar.component.js.map +1 -1
  12. package/lib/commonjs/components/Snackbar/Snakbar.style.js +4 -0
  13. package/lib/commonjs/components/Snackbar/Snakbar.style.js.map +1 -1
  14. package/lib/commonjs/components/TextInput/TextInput.component.js +3 -7
  15. package/lib/commonjs/components/TextInput/TextInput.component.js.map +1 -1
  16. package/lib/commonjs/components/button/button.component.js +8 -3
  17. package/lib/commonjs/components/button/button.component.js.map +1 -1
  18. package/lib/commonjs/components/countdown/countdown.component.js +45 -47
  19. package/lib/commonjs/components/countdown/countdown.component.js.map +1 -1
  20. package/lib/commonjs/components/countdown/countdown.style.js +2 -1
  21. package/lib/commonjs/components/countdown/countdown.style.js.map +1 -1
  22. package/lib/commonjs/components/index.js +6 -0
  23. package/lib/commonjs/components/index.js.map +1 -1
  24. package/lib/module/components/Appbar/Appbar.component.js +9 -6
  25. package/lib/module/components/Appbar/Appbar.component.js.map +1 -1
  26. package/lib/module/components/BottomSheet/BottomSheet.component.js +9 -6
  27. package/lib/module/components/BottomSheet/BottomSheet.component.js.map +1 -1
  28. package/lib/module/components/CheckBoxInput/CheckBoxInput.component.js +1 -3
  29. package/lib/module/components/CheckBoxInput/CheckBoxInput.component.js.map +1 -1
  30. package/lib/module/components/RadioInput/RadioInput.component.js +1 -3
  31. package/lib/module/components/RadioInput/RadioInput.component.js.map +1 -1
  32. package/lib/module/components/Snackbar/Snackbar.component.js +48 -2
  33. package/lib/module/components/Snackbar/Snackbar.component.js.map +1 -1
  34. package/lib/module/components/Snackbar/Snakbar.style.js +4 -0
  35. package/lib/module/components/Snackbar/Snakbar.style.js.map +1 -1
  36. package/lib/module/components/TextInput/TextInput.component.js +3 -7
  37. package/lib/module/components/TextInput/TextInput.component.js.map +1 -1
  38. package/lib/module/components/button/button.component.js +8 -3
  39. package/lib/module/components/button/button.component.js.map +1 -1
  40. package/lib/module/components/countdown/countdown.component.js +45 -47
  41. package/lib/module/components/countdown/countdown.component.js.map +1 -1
  42. package/lib/module/components/countdown/countdown.style.js +2 -1
  43. package/lib/module/components/countdown/countdown.style.js.map +1 -1
  44. package/lib/module/components/index.js +1 -1
  45. package/lib/module/components/index.js.map +1 -1
  46. package/lib/typescript/components/Appbar/Appbar.component.d.ts.map +1 -1
  47. package/lib/typescript/components/Appbar/Appbar.type.d.ts +4 -0
  48. package/lib/typescript/components/Appbar/Appbar.type.d.ts.map +1 -1
  49. package/lib/typescript/components/BottomSheet/BottomSheet.component.d.ts.map +1 -1
  50. package/lib/typescript/components/BottomSheet/BottomSheet.type.d.ts +4 -0
  51. package/lib/typescript/components/BottomSheet/BottomSheet.type.d.ts.map +1 -1
  52. package/lib/typescript/components/CheckBoxInput/CheckBoxInput.component.d.ts.map +1 -1
  53. package/lib/typescript/components/RadioInput/RadioInput.component.d.ts.map +1 -1
  54. package/lib/typescript/components/Snackbar/Snackbar.component.d.ts +10 -3
  55. package/lib/typescript/components/Snackbar/Snackbar.component.d.ts.map +1 -1
  56. package/lib/typescript/components/Snackbar/Snakbar.style.d.ts +1 -0
  57. package/lib/typescript/components/Snackbar/Snakbar.style.d.ts.map +1 -1
  58. package/lib/typescript/components/TextInput/TextInput.component.d.ts.map +1 -1
  59. package/lib/typescript/components/button/button.component.d.ts.map +1 -1
  60. package/lib/typescript/components/countdown/countdown.component.d.ts.map +1 -1
  61. package/lib/typescript/components/countdown/countdown.style.d.ts.map +1 -1
  62. package/lib/typescript/components/countdown/countdown.type.d.ts +5 -0
  63. package/lib/typescript/components/countdown/countdown.type.d.ts.map +1 -1
  64. package/lib/typescript/components/index.d.ts +1 -1
  65. package/lib/typescript/components/index.d.ts.map +1 -1
  66. package/package.json +5 -3
  67. package/src/components/Appbar/Appbar.component.tsx +9 -1
  68. package/src/components/Appbar/Appbar.type.ts +7 -0
  69. package/src/components/BottomSheet/BottomSheet.component.tsx +9 -3
  70. package/src/components/BottomSheet/BottomSheet.type.ts +8 -0
  71. package/src/components/CheckBoxInput/CheckBoxInput.component.tsx +0 -1
  72. package/src/components/RadioInput/RadioInput.component.tsx +0 -1
  73. package/src/components/Snackbar/Snackbar.component.tsx +53 -2
  74. package/src/components/Snackbar/Snakbar.style.tsx +6 -0
  75. package/src/components/TextInput/TextInput.component.tsx +3 -7
  76. package/src/components/button/button.component.tsx +8 -3
  77. package/src/components/countdown/countdown.component.tsx +44 -43
  78. package/src/components/countdown/countdown.style.tsx +1 -0
  79. package/src/components/countdown/countdown.type.ts +6 -0
  80. 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 Snackbar: React.FunctionComponent<SnackbarProps> = (props) => {
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
- export { Snackbar };
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
- if (value === '') {
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 = 'large',
15
+ size = 'small',
16
16
  containerStyles,
17
17
  textStyles,
18
18
  ...rest
19
19
  } = props;
20
20
 
21
- const computedStyle = getStyle(props);
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 === 'primary' ? Palettes.black[800] : Palettes.blue[50]
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 { targetDateTime } = props;
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
- days: `0 hari`,
30
- hours: appendZero(0),
31
- minutes: appendZero(0),
32
- seconds: appendZero(0),
37
+ d: appendZero(0),
38
+ h: appendZero(0),
39
+ m: appendZero(0),
40
+ s: appendZero(0),
33
41
  };
34
42
  }
35
43
 
36
- const days = Math.floor(time / (1000 * 60 * 60 * 24));
37
- const hours = appendZero(Math.floor((time / (1000 * 60 * 60)) % 24));
38
- const minutes = appendZero(Math.floor((time / 1000 / 60) % 60));
39
- const seconds = appendZero(Math.floor((time / 1000) % 60));
40
-
41
- return { days: `${days} hari`, hours, minutes, seconds };
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
- <View style={[computedStyle.textContainer]}>
47
- <Typography variant="overline" style={[computedStyle.textLabel]}>
48
- {formatTime(timeLeft).days}
49
- </Typography>
50
- </View>
51
-
52
- <View style={[computedStyle.dividerContainer]}>
53
- <Typography variant="overline">:</Typography>
54
- </View>
55
-
56
- <View style={[computedStyle.textContainer]}>
57
- <Typography variant="overline" style={[computedStyle.textLabel]}>
58
- {formatTime(timeLeft).hours}
59
- </Typography>
60
- </View>
61
- <View style={[computedStyle.dividerContainer]}>
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
  };
@@ -16,6 +16,7 @@ export const getStyle = () => {
16
16
 
17
17
  computedStyle.container = {
18
18
  flexDirection: 'row',
19
+ alignSelf: 'flex-start',
19
20
  };
20
21
 
21
22
  computedStyle.textLabel = {
@@ -3,4 +3,10 @@ export interface CountdownProps {
3
3
  * The target time in Date format, ex: 'YYYY-MM-DD hh:mm:ss'
4
4
  */
5
5
  targetDateTime: string | number | Date;
6
+
7
+ formats?: {
8
+ type: 'd' | 'h' | 'm' | 's';
9
+ trailingString?: string;
10
+ leadingString?: string;
11
+ }[];
6
12
  }
@@ -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';