@herca/rn-kit 0.1.10 → 0.1.12
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 +1 -1
- package/lib/module/Alert/Alert.js +2 -2
- package/lib/module/Alert/Alert.js.map +1 -1
- package/lib/module/Alert/README.md +1 -1
- package/lib/module/Chip/Chip.js +10 -5
- package/lib/module/Chip/Chip.js.map +1 -1
- package/lib/module/Drawing/Drawing.js +33 -12
- package/lib/module/Drawing/Drawing.js.map +1 -1
- package/lib/module/Drawing/README.md +33 -0
- package/lib/module/Drawing/type.js +2 -0
- package/lib/module/Drawing/type.js.map +1 -0
- package/lib/module/FileView/PdfView.js +12 -19
- package/lib/module/FileView/PdfView.js.map +1 -1
- package/lib/module/Icon/Icon.js +4 -4
- package/lib/module/Icon/Icon.js.map +1 -1
- package/lib/module/Icon/icons/Download.js +2 -2
- package/lib/module/Icon/icons/Download.js.map +1 -1
- package/lib/module/Icon/icons/{ExlmationMark.js → ExclamationMark.js} +3 -3
- package/lib/module/Icon/icons/ExclamationMark.js.map +1 -0
- package/lib/module/Provider/FooterProvider.js +4 -1
- package/lib/module/Provider/FooterProvider.js.map +1 -1
- package/lib/module/Select/Select.js +20 -13
- package/lib/module/Select/Select.js.map +1 -1
- package/lib/module/Tab/TabItem.js +1 -5
- package/lib/module/Tab/TabItem.js.map +1 -1
- package/lib/module/Toast/README.md +1 -1
- package/lib/module/Toast/Toast.js +1 -1
- package/lib/module/Toast/Toast.js.map +1 -1
- package/lib/module/Toast/ToastContext.js +1 -1
- package/lib/module/Ui/Footer.js +11 -9
- package/lib/module/Ui/Footer.js.map +1 -1
- package/lib/module/hooks/useOptionalFocusEffect.js +19 -0
- package/lib/module/hooks/useOptionalFocusEffect.js.map +1 -0
- package/lib/typescript/src/Chip/Chip.d.ts.map +1 -1
- package/lib/typescript/src/Chip/type.d.ts +2 -0
- package/lib/typescript/src/Chip/type.d.ts.map +1 -1
- package/lib/typescript/src/Drawing/Drawing.d.ts +4 -2
- package/lib/typescript/src/Drawing/Drawing.d.ts.map +1 -1
- package/lib/typescript/src/Drawing/type.d.ts +1 -0
- package/lib/typescript/src/Drawing/type.d.ts.map +1 -0
- package/lib/typescript/src/FileView/PdfView.d.ts +11 -1
- package/lib/typescript/src/FileView/PdfView.d.ts.map +1 -1
- package/lib/typescript/src/Icon/Icon.d.ts.map +1 -1
- package/lib/typescript/src/Icon/icons/Download.d.ts +2 -2
- package/lib/typescript/src/Icon/icons/Download.d.ts.map +1 -1
- package/lib/typescript/src/Icon/icons/ExclamationMark.d.ts +9 -0
- package/lib/typescript/src/Icon/icons/ExclamationMark.d.ts.map +1 -0
- package/lib/typescript/src/Icon/type.d.ts +1 -1
- package/lib/typescript/src/Icon/type.d.ts.map +1 -1
- package/lib/typescript/src/Provider/FooterProvider.d.ts.map +1 -1
- package/lib/typescript/src/Select/Select.d.ts +1 -1
- package/lib/typescript/src/Select/Select.d.ts.map +1 -1
- package/lib/typescript/src/Select/type.d.ts +2 -0
- package/lib/typescript/src/Select/type.d.ts.map +1 -1
- package/lib/typescript/src/Tab/TabItem.d.ts +3 -1
- package/lib/typescript/src/Tab/TabItem.d.ts.map +1 -1
- package/lib/typescript/src/Ui/Footer.d.ts +1 -1
- package/lib/typescript/src/Ui/Footer.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useOptionalFocusEffect.d.ts +2 -0
- package/lib/typescript/src/hooks/useOptionalFocusEffect.d.ts.map +1 -0
- package/package.json +14 -16
- package/src/Alert/Alert.tsx +2 -2
- package/src/Alert/README.md +1 -1
- package/src/Chip/Chip.tsx +9 -3
- package/src/Chip/type.tsx +2 -0
- package/src/Drawing/Drawing.tsx +44 -17
- package/src/Drawing/README.md +33 -0
- package/src/Drawing/type.tsx +0 -0
- package/src/FileView/PdfView.tsx +22 -19
- package/src/Icon/Icon.tsx +4 -4
- package/src/Icon/icons/Download.tsx +2 -2
- package/src/Icon/icons/{ExlmationMark.tsx → ExclamationMark.tsx} +2 -2
- package/src/Icon/type.tsx +1 -1
- package/src/Provider/FooterProvider.tsx +2 -1
- package/src/Select/Select.tsx +20 -11
- package/src/Select/type.tsx +2 -0
- package/src/Tab/TabItem.tsx +3 -4
- package/src/Toast/README.md +1 -1
- package/src/Toast/Toast.tsx +1 -1
- package/src/Toast/ToastContext.tsx +1 -1
- package/src/Ui/Footer.tsx +14 -9
- package/src/hooks/useOptionalFocusEffect.ts +18 -0
- package/lib/module/Icon/icons/ExlmationMark.js.map +0 -1
- package/lib/typescript/src/Icon/icons/ExlmationMark.d.ts +0 -9
- package/lib/typescript/src/Icon/icons/ExlmationMark.d.ts.map +0 -1
|
@@ -7,7 +7,7 @@ interface Props {
|
|
|
7
7
|
style?: object;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
const
|
|
10
|
+
const Download: React.FC<Props> = ({ size = 24, color = '#000', style }) => (
|
|
11
11
|
<Svg width={size} height={size} viewBox="0 0 13 16" fill="none" style={style}>
|
|
12
12
|
<Path
|
|
13
13
|
d="M8.2915 3V1.125L12.0415 4.875H10.1665C8.84984 4.875 8.2915 4.31667 8.2915 3ZM12.6665 6.125V13C12.6665 14.6667 11.8332 15.5 10.1665 15.5H2.6665C0.999837 15.5 0.166504 14.6667 0.166504 13V3C0.166504 1.33333 0.999837 0.5 2.6665 0.5H7.0415V3C7.0415 5.01667 8.14984 6.125 10.1665 6.125H12.6665ZM7.27486 10.0583C7.03069 9.81417 6.63483 9.81417 6.39067 10.0583L5.79069 10.6583V8C5.79069 7.655 5.51069 7.375 5.16569 7.375C4.82069 7.375 4.54069 7.655 4.54069 8V10.6575L3.94071 10.0575C3.69655 9.81333 3.30069 9.81333 3.05652 10.0575C2.81235 10.3017 2.81235 10.6975 3.05652 10.9417L4.72319 12.6083C4.78068 12.6658 4.84977 12.7117 4.92643 12.7433C5.0031 12.775 5.08402 12.7917 5.16569 12.7917C5.24736 12.7917 5.32808 12.775 5.40474 12.7433C5.48141 12.7117 5.55069 12.6658 5.60819 12.6083L7.27486 10.9417C7.51903 10.6983 7.51903 10.3017 7.27486 10.0583Z"
|
|
@@ -16,4 +16,4 @@ const Downnload: React.FC<Props> = ({ size = 24, color = '#000', style }) => (
|
|
|
16
16
|
</Svg>
|
|
17
17
|
);
|
|
18
18
|
|
|
19
|
-
export default
|
|
19
|
+
export default Download;
|
|
@@ -7,7 +7,7 @@ interface Props {
|
|
|
7
7
|
style?: object;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
const
|
|
10
|
+
const ExclamationMark: React.FC<Props> = ({
|
|
11
11
|
size = 24,
|
|
12
12
|
color = '#909090',
|
|
13
13
|
style,
|
|
@@ -20,4 +20,4 @@ const ExlamationMark: React.FC<Props> = ({
|
|
|
20
20
|
</Svg>
|
|
21
21
|
);
|
|
22
22
|
|
|
23
|
-
export default
|
|
23
|
+
export default ExclamationMark;
|
package/src/Icon/type.tsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createContext, useContext, useState, type ReactNode } from 'react';
|
|
2
|
+
import LayoutWithFooter from './LayoutWithFooter';
|
|
2
3
|
|
|
3
4
|
interface FooterContextType {
|
|
4
5
|
footer: ReactNode | null;
|
|
@@ -12,7 +13,7 @@ export const FooterProvider = ({ children }: { children: ReactNode }) => {
|
|
|
12
13
|
|
|
13
14
|
return (
|
|
14
15
|
<FooterContext.Provider value={{ footer, setFooter }}>
|
|
15
|
-
{children}
|
|
16
|
+
<LayoutWithFooter>{children}</LayoutWithFooter>
|
|
16
17
|
</FooterContext.Provider>
|
|
17
18
|
);
|
|
18
19
|
};
|
package/src/Select/Select.tsx
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
TouchableWithoutFeedback,
|
|
5
5
|
Keyboard,
|
|
6
6
|
} from 'react-native';
|
|
7
|
-
import { useState,
|
|
7
|
+
import { useState, useCallback } from 'react';
|
|
8
8
|
import { type SelectProps } from './type';
|
|
9
9
|
import BottomSheet from '../BottomSheet/BottomSheet';
|
|
10
10
|
import Button from '../Button/Button';
|
|
@@ -27,24 +27,31 @@ export default function Select({
|
|
|
27
27
|
height,
|
|
28
28
|
onRefresh,
|
|
29
29
|
refreshing,
|
|
30
|
+
footer,
|
|
31
|
+
onEndReached,
|
|
30
32
|
}: SelectProps) {
|
|
31
|
-
const [isOpenSelect, setIsOpenSelect] = useState<boolean | undefined>(false);
|
|
33
|
+
// const [isOpenSelect, setIsOpenSelect] = useState<boolean | undefined>(false);
|
|
32
34
|
const [selected, setSelected] = useState<ChipSelectedProps>();
|
|
33
35
|
const { show } = useToast();
|
|
34
|
-
useEffect(() => {
|
|
35
|
-
|
|
36
|
-
}, [isOpen]);
|
|
36
|
+
// useEffect(() => {
|
|
37
|
+
// setIsOpenSelect(isOpen);
|
|
38
|
+
// }, [isOpen]);
|
|
37
39
|
|
|
38
|
-
const handleOnCloseBottom = (
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
const handleOnCloseBottom = useCallback(
|
|
41
|
+
(val: boolean) => {
|
|
42
|
+
if (onClose) {
|
|
43
|
+
onClose?.(val);
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
[onClose]
|
|
47
|
+
);
|
|
41
48
|
|
|
42
49
|
const handleOnPresSubmitSelect = (): boolean => {
|
|
43
50
|
if (required && (!selected || selected.length === 0)) {
|
|
44
51
|
show('Please fill a item');
|
|
45
52
|
return false;
|
|
46
53
|
}
|
|
47
|
-
setIsOpenSelect(false);
|
|
54
|
+
// setIsOpenSelect(false);
|
|
48
55
|
onSubmit?.(selected ? selected : []);
|
|
49
56
|
return true;
|
|
50
57
|
};
|
|
@@ -56,8 +63,8 @@ export default function Select({
|
|
|
56
63
|
};
|
|
57
64
|
return (
|
|
58
65
|
<BottomSheet
|
|
59
|
-
onClose={handleOnCloseBottom}
|
|
60
|
-
isOpen={
|
|
66
|
+
onClose={(val: boolean) => handleOnCloseBottom(val)}
|
|
67
|
+
isOpen={isOpen}
|
|
61
68
|
height={height}
|
|
62
69
|
footer={
|
|
63
70
|
<Button
|
|
@@ -91,12 +98,14 @@ export default function Select({
|
|
|
91
98
|
selected={selected}
|
|
92
99
|
multiple={multiple}
|
|
93
100
|
onSelect={setSelected}
|
|
101
|
+
onEndReached={onEndReached}
|
|
94
102
|
color="primary"
|
|
95
103
|
size="large"
|
|
96
104
|
renderItem={renderItem}
|
|
97
105
|
onRefresh={onRefresh}
|
|
98
106
|
block
|
|
99
107
|
refreshing={refreshing}
|
|
108
|
+
footer={footer}
|
|
100
109
|
/>
|
|
101
110
|
)}
|
|
102
111
|
</View>
|
package/src/Select/type.tsx
CHANGED
package/src/Tab/TabItem.tsx
CHANGED
package/src/Toast/README.md
CHANGED
|
@@ -60,7 +60,7 @@ Menyediakan context global toast. Harus membungkus komponen root Anda.
|
|
|
60
60
|
| Option | Type | Default | Description |
|
|
61
61
|
| ---------- | ------------------ | ------------------ | ---------------------------------- |
|
|
62
62
|
| `color` | `ColorVariantType` | `'default'` | Warna latar belakang dan teks. |
|
|
63
|
-
| `icon` | `IconNameProps` | `'
|
|
63
|
+
| `icon` | `IconNameProps` | `'ExclamationMark'` | Ikon di samping pesan. |
|
|
64
64
|
| `duration` | `number` (ms) | `3000` | Waktu tampil Toast sebelum hilang. |
|
|
65
65
|
|
|
66
66
|
## ❗ Error Handling
|
package/src/Toast/Toast.tsx
CHANGED
|
@@ -19,7 +19,7 @@ export const ToastProvider = ({ children }: { children: ReactNode }) => {
|
|
|
19
19
|
const [visible, setVisible] = useState(false);
|
|
20
20
|
const [message, setMessage] = useState<string>('');
|
|
21
21
|
const [options, setOptions] = useState<ToastOptions>({
|
|
22
|
-
icon: '
|
|
22
|
+
icon: 'ExclamationMark',
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
const show = (msg: string, opts?: ToastOptions) => {
|
package/src/Ui/Footer.tsx
CHANGED
|
@@ -1,24 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import type
|
|
4
|
-
import Color from '../Color/Color';
|
|
1
|
+
// Footer.tsx
|
|
2
|
+
import React, { useMemo } from 'react';
|
|
3
|
+
import { SafeAreaView, StyleSheet, type ViewStyle } from 'react-native';
|
|
5
4
|
import { useFooter } from '../Provider/Provider';
|
|
5
|
+
import Color from '../Color/Color';
|
|
6
|
+
import { useOptionalFocusEffect } from '../hooks/useOptionalFocusEffect';
|
|
6
7
|
|
|
7
8
|
interface FooterProps {
|
|
8
9
|
children: React.ReactNode;
|
|
9
10
|
style?: ViewStyle;
|
|
10
11
|
}
|
|
12
|
+
|
|
11
13
|
const Footer: React.FC<FooterProps> = ({ children, style }) => {
|
|
12
14
|
const { setFooter } = useFooter();
|
|
13
15
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
const footerElement = useMemo(
|
|
17
|
+
() => (
|
|
16
18
|
<SafeAreaView style={[styles.container, style]}>{children}</SafeAreaView>
|
|
17
|
-
)
|
|
18
|
-
|
|
19
|
+
),
|
|
20
|
+
[children, style]
|
|
21
|
+
);
|
|
19
22
|
|
|
23
|
+
useOptionalFocusEffect(() => {
|
|
24
|
+
setFooter(footerElement);
|
|
20
25
|
return () => setFooter(null);
|
|
21
|
-
}
|
|
26
|
+
});
|
|
22
27
|
|
|
23
28
|
return null;
|
|
24
29
|
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// src/hooks/useOptionalFocusEffect.ts
|
|
2
|
+
import { useContext, useEffect, useCallback } from 'react';
|
|
3
|
+
import { NavigationContext, useFocusEffect } from '@react-navigation/native';
|
|
4
|
+
|
|
5
|
+
export function useOptionalFocusEffect(callback: () => void | (() => void)) {
|
|
6
|
+
const navigation = useContext(NavigationContext);
|
|
7
|
+
|
|
8
|
+
const effect = useCallback(callback, [callback]);
|
|
9
|
+
|
|
10
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
11
|
+
if (navigation) {
|
|
12
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
13
|
+
useFocusEffect(effect);
|
|
14
|
+
} else {
|
|
15
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
16
|
+
useEffect(() => effect(), [effect]);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["React","Svg","Path","jsx","_jsx","ExlamationMark","size","color","style","width","height","viewBox","fill","children","d"],"sourceRoot":"../../../../src","sources":["Icon/icons/ExlmationMark.tsx"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,GAAG,IAAIC,IAAI,QAAQ,kBAAkB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAQ7C,MAAMC,cAA+B,GAAGA,CAAC;EACvCC,IAAI,GAAG,EAAE;EACTC,KAAK,GAAG,SAAS;EACjBC;AACF,CAAC,kBACCJ,IAAA,CAACH,GAAG;EAACQ,KAAK,EAAEH,IAAK;EAACI,MAAM,EAAEJ,IAAK;EAACK,OAAO,EAAC,WAAW;EAACC,IAAI,EAAC,MAAM;EAACJ,KAAK,EAAEA,KAAM;EAAAK,QAAA,eAC3ET,IAAA,CAACF,IAAI;IACHY,CAAC,EAAC,oiBAAoiB;IACtiBF,IAAI,EAAE,GAAGL,KAAK;EAAG,CAClB;AAAC,CACC,CACN;AAED,eAAeF,cAAc","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ExlmationMark.d.ts","sourceRoot":"","sources":["../../../../../src/Icon/icons/ExlmationMark.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,UAAU,KAAK;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,QAAA,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAWnC,CAAC;AAEF,eAAe,cAAc,CAAC"}
|