@herca/rn-kit 0.1.35 → 0.1.36

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.
@@ -94,6 +94,7 @@ Setiap tab dibungkus dalam `ScrollView` vertikal, sehingga bisa discroll ke bawa
94
94
  | `children` | `React.ReactNode` | Daftar elemen `<TabItem />` |
95
95
  | `current?` | `number` | Indeks tab aktif (default: 0) |
96
96
  | `onChangeTab?` | `(index: number) => void` | Callback saat tab berpindah |
97
+ | `renderHeader` | `React.ReactElement` | tambahan react element di atas tab |
97
98
 
98
99
  ### `TabItemProps`
99
100
 
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  import React, { useCallback, useState, useEffect, useRef, Children, isValidElement } from 'react';
4
- import { View, Pressable, StyleSheet } from 'react-native';
4
+ import { View, Pressable, StyleSheet, ScrollView } from 'react-native';
5
5
  import PagerView from 'react-native-pager-view';
6
6
  import Color from "../Color/Color.js";
7
7
  import Typography from "../Typography/Typography.js";
@@ -9,7 +9,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
9
9
  const Tab = ({
10
10
  children,
11
11
  current = 0,
12
- onChangeTab
12
+ onChangeTab,
13
+ renderHeader
13
14
  }) => {
14
15
  const items = Children.toArray(children).filter(isValidElement);
15
16
  const [activeIndex, setActiveIndex] = useState(current);
@@ -29,40 +30,54 @@ const Tab = ({
29
30
  updateActive(index);
30
31
  };
31
32
  if (items.length === 0) return null;
32
- return /*#__PURE__*/_jsxs(View, {
33
+ return /*#__PURE__*/_jsx(View, {
33
34
  style: styles.container,
34
- children: [/*#__PURE__*/_jsx(View, {
35
- style: styles.headerContainer,
36
- children: items.map((item, index) => {
37
- const isActive = index === activeIndex;
38
- return /*#__PURE__*/_jsx(Pressable, {
39
- style: [styles.tabButton, isActive ? styles.tabActive : styles.tabInactive],
40
- onPress: () => handleHeaderPress(index),
41
- children: /*#__PURE__*/_jsx(Typography, {
42
- center: true,
43
- variant: "t2",
44
- weight: "semibold",
45
- color: isActive ? Color.base.white100 : Color.gray[700],
46
- children: item.props.name
35
+ children: /*#__PURE__*/_jsxs(ScrollView, {
36
+ stickyHeaderIndices: [renderHeader ? 1 : 0] // bikin tabBar sticky
37
+ ,
38
+ contentContainerStyle: {
39
+ flexGrow: 1
40
+ },
41
+ children: [renderHeader ? renderHeader : null, /*#__PURE__*/_jsx(ScrollView, {
42
+ horizontal: true,
43
+ showsHorizontalScrollIndicator: false,
44
+ style: styles.tabBarWrapper,
45
+ children: /*#__PURE__*/_jsx(View, {
46
+ style: styles.tabBar,
47
+ children: items.map((item, index) => {
48
+ const isActive = index === activeIndex;
49
+ return /*#__PURE__*/_jsx(Pressable, {
50
+ style: [styles.tabButton, isActive ? styles.tabActive : styles.tabInactive],
51
+ onPress: () => handleHeaderPress(index),
52
+ children: /*#__PURE__*/_jsx(Typography, {
53
+ center: true,
54
+ variant: "t2",
55
+ weight: "semibold",
56
+ color: isActive ? Color.base.white100 : Color.gray[700],
57
+ children: item.props.name
58
+ })
59
+ }, index);
47
60
  })
48
- }, index);
49
- })
50
- }), /*#__PURE__*/_jsx(PagerView, {
51
- ref: pagerRef,
52
- style: styles.pager,
53
- initialPage: current,
54
- onPageSelected: e => updateActive(e.nativeEvent.position),
55
- children: items.map((item, index) => {
56
- const Comp = item.props.component;
57
- return /*#__PURE__*/_jsx(View, {
58
- collapsable: false,
59
- style: {
60
- flex: 1
61
- },
62
- children: Comp ? /*#__PURE__*/_jsx(Comp, {}) : null
63
- }, index);
64
- })
65
- })]
61
+ })
62
+ }), /*#__PURE__*/_jsx(View, {
63
+ style: {
64
+ flex: 1
65
+ },
66
+ children: /*#__PURE__*/_jsx(PagerView, {
67
+ ref: pagerRef,
68
+ style: styles.pager,
69
+ initialPage: current,
70
+ onPageSelected: e => updateActive(e.nativeEvent.position),
71
+ children: items.map((item, index) => /*#__PURE__*/_jsx(View, {
72
+ collapsable: false,
73
+ style: {
74
+ flex: 1
75
+ },
76
+ children: item?.props?.children
77
+ }, index))
78
+ })
79
+ })]
80
+ })
66
81
  });
67
82
  };
68
83
  export default Tab;
@@ -70,19 +85,23 @@ const styles = StyleSheet.create({
70
85
  container: {
71
86
  flex: 1
72
87
  },
73
- headerContainer: {
74
- flexDirection: 'row',
88
+ tabBarWrapper: {
75
89
  backgroundColor: Color.gray[100],
90
+ borderRadius: 8
91
+ },
92
+ tabBar: {
93
+ flexDirection: 'row',
94
+ // tetap row
76
95
  padding: 4,
77
96
  borderRadius: 8
78
97
  },
79
98
  tabButton: {
80
- flex: 1,
81
99
  borderRadius: 8,
82
100
  paddingVertical: 6,
83
101
  paddingHorizontal: 16,
84
102
  justifyContent: 'center',
85
- alignItems: 'center'
103
+ alignItems: 'center',
104
+ marginRight: 8
86
105
  },
87
106
  tabActive: {
88
107
  backgroundColor: Color.primary[1000]
@@ -91,7 +110,8 @@ const styles = StyleSheet.create({
91
110
  backgroundColor: Color.gray[100]
92
111
  },
93
112
  pager: {
94
- flex: 1
113
+ flex: 1,
114
+ minHeight: 800
95
115
  }
96
116
  });
97
117
  //# sourceMappingURL=Tab.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["React","useCallback","useState","useEffect","useRef","Children","isValidElement","View","Pressable","StyleSheet","PagerView","Color","Typography","jsx","_jsx","jsxs","_jsxs","Tab","children","current","onChangeTab","items","toArray","filter","activeIndex","setActiveIndex","pagerRef","setPageWithoutAnimation","updateActive","index","handleHeaderPress","setPage","length","style","styles","container","headerContainer","map","item","isActive","tabButton","tabActive","tabInactive","onPress","center","variant","weight","color","base","white100","gray","props","name","ref","pager","initialPage","onPageSelected","e","nativeEvent","position","Comp","component","collapsable","flex","create","flexDirection","backgroundColor","padding","borderRadius","paddingVertical","paddingHorizontal","justifyContent","alignItems","primary"],"sourceRoot":"../../../src","sources":["Tab/Tab.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IACVC,WAAW,EACXC,QAAQ,EACRC,SAAS,EACTC,MAAM,EACNC,QAAQ,EACRC,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9C,IAAA,CAAC8C,IAAI,IAAE,CAAC,GAAG;QAAI,GADd/B,KAEL,CAAC;MAEX,CAAC;IAAC,CACO,CAAC;EAAA,CACR,CAAC;AAEX,CAAC;AAED,eAAeZ,GAAG;AAElB,MAAMiB,MAAM,GAAGzB,UAAU,CAACuD,MAAM,CAAC;EAC/B7B,SAAS,EAAE;IAAE4B,IAAI,EAAE;EAAE,CAAC;EACtB3B,eAAe,EAAE;IACf6B,aAAa,EAAE,KAAK;IACpBC,eAAe,EAAEvD,KAAK,CAACuC,IAAI,CAAC,GAAG,CAAC;IAChCiB,OAAO,EAAE,CAAC;IACVC,YAAY,EAAE;EAChB,CAAC;EACD5B,SAAS,EAAE;IACTuB,IAAI,EAAE,CAAC;IACPK,YAAY,EAAE,CAAC;IACfC,eAAe,EAAE,CAAC;IAClBC,iBAAiB,EAAE,EAAE;IACrBC,cAAc,EAAE,QAAQ;IACxBC,UAAU,EAAE;EACd,CAAC;EACD/B,SAAS,EAAE;IAAEyB,eAAe,EAAEvD,KAAK,CAAC8D,OAAO,CAAC,IAAI;EAAE,CAAC;EACnD/B,WAAW,EAAE;IAAEwB,eAAe,EAAEvD,KAAK,CAACuC,IAAI,CAAC,GAAG;EAAE,CAAC;EACjDI,KAAK,EAAE;IAAES,IAAI,EAAE;EAAE;AACnB,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["React","useCallback","useState","useEffect","useRef","Children","isValidElement","View","Pressable","StyleSheet","ScrollView","PagerView","Color","Typography","jsx","_jsx","jsxs","_jsxs","Tab","children","current","onChangeTab","renderHeader","items","toArray","filter","activeIndex","setActiveIndex","pagerRef","setPageWithoutAnimation","updateActive","index","handleHeaderPress","setPage","length","style","styles","container","stickyHeaderIndices","contentContainerStyle","flexGrow","horizontal","showsHorizontalScrollIndicator","tabBarWrapper","tabBar","map","item","isActive","tabButton","tabActive","tabInactive","onPress","center","variant","weight","color","base","white100","gray","props","name","flex","ref","pager","initialPage","onPageSelected","e","nativeEvent","position","collapsable","create","backgroundColor","borderRadius","flexDirection","padding","paddingVertical","paddingHorizontal","justifyContent","alignItems","marginRight","primary","minHeight"],"sourceRoot":"../../../src","sources":["Tab/Tab.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IACVC,WAAW,EACXC,QAAQ,EACRC,SAAS,EACTC,MAAM,EACNC,QAAQ,EACRC,cAAc,QACT,OAAO;AACd,SAASC,IAAI,EAAEC,SAAS,EAAEC,UAAU,EAAEC,UAAU,QAAQ,cAAc;AACtE,OAAOC,SAAS,MAAM,yBAAyB;AAC/C,OAAOC,KAAK,MAAM,mBAAgB;AAClC,OAAOC,UAAU,MAAM,6BAA0B;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAGlD,MAAMC,GAAuB,GAAGA,CAAC;EAC/BC,QAAQ;EACRC,OAAO,GAAG,CAAC;EACXC,WAAW;EACXC;AACF,CAAC,KAAK;EACJ,MAAMC,KAAK,GAAGlB,QAAQ,CAACmB,OAAO,CAACL,QAAQ,CAAC,CAACM,MAAM,CAC7CnB,cACF,CAAuC;EAEvC,MAAM,CAACoB,WAAW,EAAEC,cAAc,CAAC,GAAGzB,QAAQ,CAASkB,OAAO,CAAC;EAC/D,MAAMQ,QAAQ,GAAGxB,MAAM,CAAY,IAAI,CAAC;EAExCD,SAAS,CAAC,MAAM;IACdwB,cAAc,CAACP,OAAO,CAAC;IACvBQ,QAAQ,CAACR,OAAO,EAAES,uBAAuB,CAACT,OAAO,CAAC;EACpD,CAAC,EAAE,CAACA,OAAO,CAAC,CAAC;EAEb,MAAMU,YAAY,GAAG7B,WAAW,CAC7B8B,KAAa,IAAK;IACjB,IAAIA,KAAK,KAAKL,WAAW,EAAE;MACzBC,cAAc,CAACI,KAAK,CAAC;MACrBV,WAAW,GAAGU,KAAK,CAAC;IACtB;EACF,CAAC,EACD,CAACL,WAAW,EAAEL,WAAW,CAC3B,CAAC;EAED,MAAMW,iBAAiB,GAAID,KAAa,IAAK;IAC3C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E;EACf,CAAC;EACD9B,SAAS,EAAE;IAAEsB,eAAe,EAAE3D,KAAK,CAACoE,OAAO,CAAC,IAAI;EAAE,CAAC;EACnD9B,WAAW,EAAE;IAAEqB,eAAe,EAAE3D,KAAK,CAAC8C,IAAI,CAAC,GAAG;EAAE,CAAC;EACjDK,KAAK,EAAE;IAAEF,IAAI,EAAE,CAAC;IAAEoB,SAAS,EAAE;EAAI;AACnC,CAAC,CAAC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"Tab.d.ts","sourceRoot":"","sources":["../../../../src/Tab/Tab.tsx"],"names":[],"mappings":"AAAA,OAAO,KAON,MAAM,OAAO,CAAC;AAKf,OAAO,KAAK,EAAgB,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAErD,QAAA,MAAM,GAAG,EAAE,KAAK,CAAC,EAAE,CAAC,QAAQ,CA0E3B,CAAC;AAEF,eAAe,GAAG,CAAC"}
1
+ {"version":3,"file":"Tab.d.ts","sourceRoot":"","sources":["../../../../src/Tab/Tab.tsx"],"names":[],"mappings":"AAAA,OAAO,KAON,MAAM,OAAO,CAAC;AAKf,OAAO,KAAK,EAAgB,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAErD,QAAA,MAAM,GAAG,EAAE,KAAK,CAAC,EAAE,CAAC,QAAQ,CA8F3B,CAAC;AAEF,eAAe,GAAG,CAAC"}
@@ -1,11 +1,12 @@
1
1
  import React, { type ReactElement } from 'react';
2
2
  export interface TabItemProps {
3
3
  name: string | number;
4
- component: React.ComponentType<any>;
4
+ children: React.ReactElement<any>;
5
5
  }
6
6
  export interface TabProps {
7
7
  children: ReactElement<TabItemProps> | ReactElement<TabItemProps>[];
8
8
  current?: number;
9
+ renderHeader?: React.ReactElement;
9
10
  onChangeTab?: (e: any) => void;
10
11
  }
11
12
  //# sourceMappingURL=type.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../../../src/Tab/type.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,KAAK,YAAY,EAAE,MAAM,OAAO,CAAC;AAEjD,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IACtB,SAAS,EAAE,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;CACrC;AACD,MAAM,WAAW,QAAQ;IACvB,QAAQ,EAAE,YAAY,CAAC,YAAY,CAAC,GAAG,YAAY,CAAC,YAAY,CAAC,EAAE,CAAC;IACpE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;CAChC"}
1
+ {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../../../src/Tab/type.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,KAAK,YAAY,EAAE,MAAM,OAAO,CAAC;AAEjD,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IACtB,QAAQ,EAAE,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;CACnC;AACD,MAAM,WAAW,QAAQ;IACvB,QAAQ,EAAE,YAAY,CAAC,YAAY,CAAC,GAAG,YAAY,CAAC,YAAY,CAAC,EAAE,CAAC;IACpE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC;IAClC,WAAW,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;CAChC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@herca/rn-kit",
3
- "version": "0.1.35",
3
+ "version": "0.1.36",
4
4
  "description": "React Native UI Kit",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",
package/src/Tab/README.md CHANGED
@@ -94,6 +94,7 @@ Setiap tab dibungkus dalam `ScrollView` vertikal, sehingga bisa discroll ke bawa
94
94
  | `children` | `React.ReactNode` | Daftar elemen `<TabItem />` |
95
95
  | `current?` | `number` | Indeks tab aktif (default: 0) |
96
96
  | `onChangeTab?` | `(index: number) => void` | Callback saat tab berpindah |
97
+ | `renderHeader` | `React.ReactElement` | tambahan react element di atas tab |
97
98
 
98
99
  ### `TabItemProps`
99
100
 
package/src/Tab/Tab.tsx CHANGED
@@ -6,13 +6,18 @@ import React, {
6
6
  Children,
7
7
  isValidElement,
8
8
  } from 'react';
9
- import { View, Pressable, StyleSheet } from 'react-native';
9
+ import { View, Pressable, StyleSheet, ScrollView } from 'react-native';
10
10
  import PagerView from 'react-native-pager-view';
11
11
  import Color from '../Color/Color';
12
12
  import Typography from '../Typography/Typography';
13
13
  import type { TabItemProps, TabProps } from './type';
14
14
 
15
- const Tab: React.FC<TabProps> = ({ children, current = 0, onChangeTab }) => {
15
+ const Tab: React.FC<TabProps> = ({
16
+ children,
17
+ current = 0,
18
+ onChangeTab,
19
+ renderHeader,
20
+ }) => {
16
21
  const items = Children.toArray(children).filter(
17
22
  isValidElement
18
23
  ) as React.ReactElement<TabItemProps>[];
@@ -44,46 +49,61 @@ const Tab: React.FC<TabProps> = ({ children, current = 0, onChangeTab }) => {
44
49
 
45
50
  return (
46
51
  <View style={styles.container}>
47
- {/* Header */}
48
- <View style={styles.headerContainer}>
49
- {items.map((item, index) => {
50
- const isActive = index === activeIndex;
51
- return (
52
- <Pressable
53
- key={index}
54
- style={[
55
- styles.tabButton,
56
- isActive ? styles.tabActive : styles.tabInactive,
57
- ]}
58
- onPress={() => handleHeaderPress(index)}
59
- >
60
- <Typography
61
- center
62
- variant="t2"
63
- weight="semibold"
64
- color={isActive ? Color.base.white100 : Color.gray[700]}
65
- >
66
- {item.props.name}
67
- </Typography>
68
- </Pressable>
69
- );
70
- })}
71
- </View>
72
- <PagerView
73
- ref={pagerRef}
74
- style={styles.pager}
75
- initialPage={current}
76
- onPageSelected={(e) => updateActive(e.nativeEvent.position)}
52
+ <ScrollView
53
+ stickyHeaderIndices={[renderHeader ? 1 : 0]} // bikin tabBar sticky
54
+ contentContainerStyle={{ flexGrow: 1 }}
77
55
  >
78
- {items.map((item, index) => {
79
- const Comp = item.props.component;
80
- return (
81
- <View key={index} collapsable={false} style={{ flex: 1 }}>
82
- {Comp ? <Comp /> : null}
83
- </View>
84
- );
85
- })}
86
- </PagerView>
56
+ {/* Header */}
57
+ {renderHeader ? renderHeader : null}
58
+
59
+ {/* TabBar (sticky + horizontal scroll) */}
60
+ <ScrollView
61
+ horizontal
62
+ showsHorizontalScrollIndicator={false}
63
+ style={styles.tabBarWrapper}
64
+ >
65
+ <View style={styles.tabBar}>
66
+ {items.map((item, index) => {
67
+ const isActive = index === activeIndex;
68
+ return (
69
+ <Pressable
70
+ key={index}
71
+ style={[
72
+ styles.tabButton,
73
+ isActive ? styles.tabActive : styles.tabInactive,
74
+ ]}
75
+ onPress={() => handleHeaderPress(index)}
76
+ >
77
+ <Typography
78
+ center
79
+ variant="t2"
80
+ weight="semibold"
81
+ color={isActive ? Color.base.white100 : Color.gray[700]}
82
+ >
83
+ {item.props.name}
84
+ </Typography>
85
+ </Pressable>
86
+ );
87
+ })}
88
+ </View>
89
+ </ScrollView>
90
+
91
+ {/* Konten */}
92
+ <View style={{ flex: 1 }}>
93
+ <PagerView
94
+ ref={pagerRef}
95
+ style={styles.pager}
96
+ initialPage={current}
97
+ onPageSelected={(e) => updateActive(e.nativeEvent.position)}
98
+ >
99
+ {items.map((item, index) => (
100
+ <View key={index} collapsable={false} style={{ flex: 1 }}>
101
+ {item?.props?.children}
102
+ </View>
103
+ ))}
104
+ </PagerView>
105
+ </View>
106
+ </ScrollView>
87
107
  </View>
88
108
  );
89
109
  };
@@ -92,21 +112,24 @@ export default Tab;
92
112
 
93
113
  const styles = StyleSheet.create({
94
114
  container: { flex: 1 },
95
- headerContainer: {
96
- flexDirection: 'row',
115
+ tabBarWrapper: {
97
116
  backgroundColor: Color.gray[100],
117
+ borderRadius: 8,
118
+ },
119
+ tabBar: {
120
+ flexDirection: 'row', // tetap row
98
121
  padding: 4,
99
122
  borderRadius: 8,
100
123
  },
101
124
  tabButton: {
102
- flex: 1,
103
125
  borderRadius: 8,
104
126
  paddingVertical: 6,
105
127
  paddingHorizontal: 16,
106
128
  justifyContent: 'center',
107
129
  alignItems: 'center',
130
+ marginRight: 8,
108
131
  },
109
132
  tabActive: { backgroundColor: Color.primary[1000] },
110
133
  tabInactive: { backgroundColor: Color.gray[100] },
111
- pager: { flex: 1 },
134
+ pager: { flex: 1, minHeight: 800 },
112
135
  });
package/src/Tab/type.tsx CHANGED
@@ -2,10 +2,11 @@ import React, { type ReactElement } from 'react';
2
2
 
3
3
  export interface TabItemProps {
4
4
  name: string | number;
5
- component: React.ComponentType<any>;
5
+ children: React.ReactElement<any>;
6
6
  }
7
7
  export interface TabProps {
8
8
  children: ReactElement<TabItemProps> | ReactElement<TabItemProps>[];
9
9
  current?: number;
10
+ renderHeader?: React.ReactElement;
10
11
  onChangeTab?: (e: any) => void;
11
12
  }