@herca/rn-kit 0.1.9 → 0.1.11

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 (61) hide show
  1. package/README.md +1 -1
  2. package/lib/module/CheckBox/CheckBox.js +21 -1
  3. package/lib/module/CheckBox/CheckBox.js.map +1 -1
  4. package/lib/module/Chip/Chip.js +10 -5
  5. package/lib/module/Chip/Chip.js.map +1 -1
  6. package/lib/module/Drawing/Drawing.js +104 -14
  7. package/lib/module/Drawing/Drawing.js.map +1 -1
  8. package/lib/module/Drawing/README.md +31 -0
  9. package/lib/module/Drawing/type.js +2 -0
  10. package/lib/module/Drawing/type.js.map +1 -0
  11. package/lib/module/FileView/PdfView.js +12 -19
  12. package/lib/module/FileView/PdfView.js.map +1 -1
  13. package/lib/module/Modal/Modal.js +19 -8
  14. package/lib/module/Modal/Modal.js.map +1 -1
  15. package/lib/module/Provider/FooterProvider.js +4 -1
  16. package/lib/module/Provider/FooterProvider.js.map +1 -1
  17. package/lib/module/Select/Select.js +20 -13
  18. package/lib/module/Select/Select.js.map +1 -1
  19. package/lib/module/Tab/TabItem.js +1 -5
  20. package/lib/module/Tab/TabItem.js.map +1 -1
  21. package/lib/module/Ui/Footer.js +11 -9
  22. package/lib/module/Ui/Footer.js.map +1 -1
  23. package/lib/module/hooks/useOptionalFocusEffect.js +19 -0
  24. package/lib/module/hooks/useOptionalFocusEffect.js.map +1 -0
  25. package/lib/typescript/src/CheckBox/CheckBox.d.ts.map +1 -1
  26. package/lib/typescript/src/Chip/Chip.d.ts.map +1 -1
  27. package/lib/typescript/src/Chip/type.d.ts +2 -0
  28. package/lib/typescript/src/Chip/type.d.ts.map +1 -1
  29. package/lib/typescript/src/Drawing/Drawing.d.ts +7 -1
  30. package/lib/typescript/src/Drawing/Drawing.d.ts.map +1 -1
  31. package/lib/typescript/src/Drawing/type.d.ts +1 -0
  32. package/lib/typescript/src/Drawing/type.d.ts.map +1 -0
  33. package/lib/typescript/src/FileView/PdfView.d.ts +11 -1
  34. package/lib/typescript/src/FileView/PdfView.d.ts.map +1 -1
  35. package/lib/typescript/src/Modal/Modal.d.ts.map +1 -1
  36. package/lib/typescript/src/Provider/FooterProvider.d.ts.map +1 -1
  37. package/lib/typescript/src/Select/Select.d.ts +1 -1
  38. package/lib/typescript/src/Select/Select.d.ts.map +1 -1
  39. package/lib/typescript/src/Select/type.d.ts +2 -0
  40. package/lib/typescript/src/Select/type.d.ts.map +1 -1
  41. package/lib/typescript/src/Tab/TabItem.d.ts +3 -1
  42. package/lib/typescript/src/Tab/TabItem.d.ts.map +1 -1
  43. package/lib/typescript/src/Ui/Footer.d.ts +1 -1
  44. package/lib/typescript/src/Ui/Footer.d.ts.map +1 -1
  45. package/lib/typescript/src/hooks/useOptionalFocusEffect.d.ts +2 -0
  46. package/lib/typescript/src/hooks/useOptionalFocusEffect.d.ts.map +1 -0
  47. package/package.json +1 -1
  48. package/src/CheckBox/CheckBox.tsx +21 -1
  49. package/src/Chip/Chip.tsx +9 -3
  50. package/src/Chip/type.tsx +2 -0
  51. package/src/Drawing/Drawing.tsx +114 -13
  52. package/src/Drawing/README.md +31 -0
  53. package/src/Drawing/type.tsx +0 -0
  54. package/src/FileView/PdfView.tsx +22 -19
  55. package/src/Modal/Modal.tsx +16 -7
  56. package/src/Provider/FooterProvider.tsx +2 -1
  57. package/src/Select/Select.tsx +20 -11
  58. package/src/Select/type.tsx +2 -0
  59. package/src/Tab/TabItem.tsx +3 -4
  60. package/src/Ui/Footer.tsx +14 -9
  61. package/src/hooks/useOptionalFocusEffect.ts +18 -0
@@ -4,7 +4,7 @@ import {
4
4
  TouchableWithoutFeedback,
5
5
  Keyboard,
6
6
  } from 'react-native';
7
- import { useState, useEffect } from 'react';
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
- setIsOpenSelect(isOpen);
36
- }, [isOpen]);
36
+ // useEffect(() => {
37
+ // setIsOpenSelect(isOpen);
38
+ // }, [isOpen]);
37
39
 
38
- const handleOnCloseBottom = (val: boolean) => {
39
- onClose?.(val);
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={isOpenSelect}
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>
@@ -26,5 +26,7 @@ export interface SelectProps {
26
26
  delaySearch?: number;
27
27
  height?: BottomSheetHeighProps;
28
28
  onRefresh?: () => void;
29
+ onEndReached?: () => void;
29
30
  refreshing?: boolean;
31
+ footer?: React.ReactElement;
30
32
  }
@@ -1,6 +1,5 @@
1
- import { View } from 'react-native';
1
+ import type { TabItemProps } from './type';
2
+ import React from 'react';
2
3
 
3
- const TabItem = () => {
4
- return <View></View>;
5
- };
4
+ const TabItem: React.FC<TabItemProps> = (_props) => null;
6
5
  export default TabItem;
package/src/Ui/Footer.tsx CHANGED
@@ -1,24 +1,29 @@
1
- import React, { useEffect } from 'react';
2
- import { StyleSheet, SafeAreaView } from 'react-native';
3
- import type { ViewStyle } from 'react-native';
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
- useEffect(() => {
15
- const footerElement = (
16
+ const footerElement = useMemo(
17
+ () => (
16
18
  <SafeAreaView style={[styles.container, style]}>{children}</SafeAreaView>
17
- );
18
- setFooter(footerElement);
19
+ ),
20
+ [children, style]
21
+ );
19
22
 
23
+ useOptionalFocusEffect(() => {
24
+ setFooter(footerElement);
20
25
  return () => setFooter(null);
21
- }, [children, style, setFooter]);
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
+ }