@herca/rn-kit 0.1.5 → 0.1.7
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 +27 -2
- package/lib/module/Accordion/README.md +14 -6
- package/lib/module/Alert/README.md +1 -1
- package/lib/module/DropDown/DropDown.js +49 -45
- package/lib/module/DropDown/DropDown.js.map +1 -1
- package/lib/module/DropDown/README.md +1 -0
- package/lib/module/List/README.md +49 -0
- package/lib/module/Modal/Modal.js +1 -1
- package/lib/module/Modal/Modal.js.map +1 -1
- package/lib/module/Modal/README.md +39 -0
- package/lib/module/Provider/Provider.js +2 -0
- package/lib/module/Provider/Provider.js.map +1 -1
- package/lib/module/Step/README.md +91 -0
- package/lib/module/Timeline/README.md +80 -0
- package/lib/module/Timeline/Timeline.js +7 -1
- package/lib/module/Timeline/Timeline.js.map +1 -1
- package/lib/module/Timeline/TimelineItem.js +15 -5
- package/lib/module/Timeline/TimelineItem.js.map +1 -1
- package/lib/module/Toast/README.md +71 -0
- package/lib/module/Ui/README_CARD.md +76 -0
- package/lib/module/Ui/README_CONTAINER.md +26 -0
- package/lib/module/index.js +0 -1
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/DropDown/DropDown.d.ts.map +1 -1
- package/lib/typescript/src/DropDown/type.d.ts +1 -1
- package/lib/typescript/src/DropDown/type.d.ts.map +1 -1
- package/lib/typescript/src/Provider/Provider.d.ts +2 -2
- package/lib/typescript/src/Provider/Provider.d.ts.map +1 -1
- package/lib/typescript/src/Provider/type.d.ts +2 -2
- package/lib/typescript/src/Provider/type.d.ts.map +1 -1
- package/lib/typescript/src/Timeline/TimelineItem.d.ts +1 -1
- package/lib/typescript/src/Timeline/TimelineItem.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +0 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/Accordion/README.md +14 -6
- package/src/Alert/README.md +1 -1
- package/src/DropDown/DropDown.tsx +54 -58
- package/src/DropDown/README.md +1 -0
- package/src/DropDown/type.tsx +1 -1
- package/src/List/README.md +49 -0
- package/src/Modal/Modal.tsx +2 -2
- package/src/Modal/README.md +39 -0
- package/src/Provider/Provider.tsx +4 -2
- package/src/Provider/type.tsx +2 -2
- package/src/Step/README.md +91 -0
- package/src/Timeline/README.md +80 -0
- package/src/Timeline/Timeline.tsx +8 -2
- package/src/Timeline/TimelineItem.tsx +16 -3
- package/src/Toast/README.md +71 -0
- package/src/Ui/README_CARD.md +76 -0
- package/src/Ui/README_CONTAINER.md +26 -0
- package/src/index.tsx +0 -1
- package/lib/module/SwitchButton/SwitchButton.js +0 -8
- package/lib/module/SwitchButton/SwitchButton.js.map +0 -1
- package/lib/module/TextArea/TextArea.js +0 -2
- package/lib/module/TextArea/TextArea.js.map +0 -1
- package/lib/typescript/src/SwitchButton/SwitchButton.d.ts +0 -2
- package/lib/typescript/src/SwitchButton/SwitchButton.d.ts.map +0 -1
- package/lib/typescript/src/TextArea/TextArea.d.ts +0 -1
- package/lib/typescript/src/TextArea/TextArea.d.ts.map +0 -1
- package/src/SwitchButton/SwitchButton.tsx +0 -5
- package/src/TextArea/TextArea.tsx +0 -0
- /package/lib/module/Input/{Input.md → README_INPUT.md} +0 -0
- /package/src/Input/{Input.md → README_INPUT.md} +0 -0
package/src/Modal/Modal.tsx
CHANGED
|
@@ -20,7 +20,7 @@ interface ModalPopUpProps {
|
|
|
20
20
|
onRequestClose?: () => void;
|
|
21
21
|
bgColor?: string;
|
|
22
22
|
width?: DimensionValue;
|
|
23
|
-
height?: DimensionValue;
|
|
23
|
+
height?: DimensionValue;
|
|
24
24
|
containerStyle?: ViewStyle;
|
|
25
25
|
modalStyle?: ViewStyle;
|
|
26
26
|
}
|
|
@@ -172,7 +172,7 @@ const styles = StyleSheet.create({
|
|
|
172
172
|
backgroundColor: '#ccc',
|
|
173
173
|
},
|
|
174
174
|
contentContainer: {
|
|
175
|
-
padding: 16,
|
|
175
|
+
padding: 16,
|
|
176
176
|
},
|
|
177
177
|
});
|
|
178
178
|
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# 🧊 ModalPopUp
|
|
2
|
+
ModalPopUp adalah komponen modal animasi dengan skala, dukungan backdrop, tombol close opsional, dan fleksibilitas ukuran serta gaya. Cocok untuk dialog, form, atau konfirmasi.
|
|
3
|
+
|
|
4
|
+
### 📦 Contoh Penggunaan
|
|
5
|
+
```tsx
|
|
6
|
+
import React, { useState } from 'react';
|
|
7
|
+
import { Text, Button } from 'react-native';
|
|
8
|
+
import ModalPopUp from '@herca/rn-kit/ModalPopUp';
|
|
9
|
+
|
|
10
|
+
export default function ExampleModal() {
|
|
11
|
+
const [visible, setVisible] = useState(false);
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<>
|
|
15
|
+
<Button title="Buka Modal" onPress={() => setVisible(true)} />
|
|
16
|
+
<ModalPopUp isOpen={visible} onClose={() => setVisible(false)}>
|
|
17
|
+
<Text style={{ fontSize: 18 }}>Ini adalah isi modal</Text>
|
|
18
|
+
</ModalPopUp>
|
|
19
|
+
</>
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## 🧩 API Reference
|
|
26
|
+
|
|
27
|
+
| Prop | Type | Default | Keterangan |
|
|
28
|
+
| ---------------- | ---------------------------- | ----------- | --------------------------------------------------------------------- |
|
|
29
|
+
| `isOpen` | `boolean` | — | Status untuk membuka/tutup modal. |
|
|
30
|
+
| `onClose` | `(isOpen?: boolean) => void` | `undefined` | Callback saat modal ditutup (baik via backdrop atau tombol close). |
|
|
31
|
+
| `children` | `ReactNode` | — | Konten utama modal. |
|
|
32
|
+
| `backdrop` | `boolean` | `true` | Apakah backdrop gelap ditampilkan di belakang modal. |
|
|
33
|
+
| `closable` | `boolean` | `true` | Apakah tombol close (lingkaran kecil di kanan atas) ditampilkan. |
|
|
34
|
+
| `onRequestClose` | `() => void` | `undefined` | Callback khusus saat backdrop ditekan (jika ingin override behavior). |
|
|
35
|
+
| `bgColor` | `string` | `"#fff"` | Warna latar belakang modal. |
|
|
36
|
+
| `width` | `DimensionValue` | `"90%"` | Lebar modal. Bisa `px`, `%`, atau nilai `number`. |
|
|
37
|
+
| `height` | `DimensionValue` | `undefined` | Tinggi modal (opsional, gunakan scroll jika tidak cukup). |
|
|
38
|
+
| `containerStyle` | `ViewStyle` | `undefined` | Gaya tambahan untuk wrapper container (pusat layar). |
|
|
39
|
+
| `modalStyle` | `ViewStyle` | `undefined` | Gaya tambahan untuk modal box. |
|
|
@@ -5,6 +5,7 @@ import LayoutWithFooter from './LayoutWithFooter';
|
|
|
5
5
|
import RequiredUpdateAppsProvider from './RequiredUpdateAppsProvider';
|
|
6
6
|
import { type ReactNode } from 'react';
|
|
7
7
|
import type { RequiredUpdateAppsProviderProps } from './type';
|
|
8
|
+
import Color from '../Color/Color';
|
|
8
9
|
|
|
9
10
|
interface FooterContextType {
|
|
10
11
|
footer: any | null;
|
|
@@ -13,8 +14,8 @@ interface FooterContextType {
|
|
|
13
14
|
|
|
14
15
|
interface ProviderProps {
|
|
15
16
|
children: ReactNode;
|
|
16
|
-
requiredUpdated
|
|
17
|
-
updateConfig
|
|
17
|
+
requiredUpdated?: boolean;
|
|
18
|
+
updateConfig?: RequiredUpdateAppsProviderProps;
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
const FooterContext = createContext<FooterContextType | undefined>(undefined);
|
|
@@ -48,6 +49,7 @@ export const useFooter = () => {
|
|
|
48
49
|
|
|
49
50
|
const styles = StyleSheet.create({
|
|
50
51
|
container: {
|
|
52
|
+
backgroundColor: Color.base.white100,
|
|
51
53
|
flex: 1,
|
|
52
54
|
},
|
|
53
55
|
});
|
package/src/Provider/type.tsx
CHANGED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# 🪜 Step & StepItem
|
|
2
|
+
Komponen Step menampilkan alur proses bertahap (wizard / progress indicator) dengan header horizontal yang dapat digeser, serta area konten untuk setiap langkah.
|
|
3
|
+
Setiap titik/langkah diwakili oleh StepItem.
|
|
4
|
+
|
|
5
|
+
## 📦 Contoh Penggunaan
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import React, { useState } from 'react';
|
|
9
|
+
import { View, Text } from 'react-native';
|
|
10
|
+
import Step from '@herca/rn-kit/Step';
|
|
11
|
+
import StepItem from '@herca/rn-kit/Step/StepItem';
|
|
12
|
+
|
|
13
|
+
export default function CheckoutWizard() {
|
|
14
|
+
const [currentStep, setCurrentStep] = useState(0);
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<Step current={currentStep} onChangeStep={(i) => setCurrentStep(i)}>
|
|
18
|
+
{/* Header & konten otomatis dipasangkan berdasarkan urutan */}
|
|
19
|
+
<StepItem title="Alamat">
|
|
20
|
+
<Text>Form Alamat Pengiriman</Text>
|
|
21
|
+
</StepItem>
|
|
22
|
+
|
|
23
|
+
<StepItem title="Pembayaran">
|
|
24
|
+
<Text>Metode Pembayaran</Text>
|
|
25
|
+
</StepItem>
|
|
26
|
+
|
|
27
|
+
<StepItem title="Konfirmasi">
|
|
28
|
+
<Text>Ringkasan & Konfirmasi Pesanan</Text>
|
|
29
|
+
</StepItem>
|
|
30
|
+
</Step>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
## 🧩 API Reference
|
|
36
|
+
|
|
37
|
+
### Step
|
|
38
|
+
| Prop | Type | Wajib | Default | Deskripsi |
|
|
39
|
+
| -------------- | -------------------------------------- | ----- | ------- | --------------------------------------------------------------------------- |
|
|
40
|
+
| `children` | `ReactElement<StepItemProps>` \| array | ✅ | — | Satu atau beberapa `StepItem`. |
|
|
41
|
+
| `current` | `number` | ✅ | — | Indeks langkah aktif (dimulai dari `0`). |
|
|
42
|
+
| `onChangeStep` | `(activeIndex: number) => void` | ✅ | — | Callback yang dipicu setiap kali nilai `current` berubah di dalam komponen. |
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
### StepItem
|
|
46
|
+
|
|
47
|
+
Digunakan dua kali:
|
|
48
|
+
|
|
49
|
+
Sebagai header (ikon lingkaran + garis) – otomatis di‐render oleh Step.
|
|
50
|
+
|
|
51
|
+
Sebagai konten – ditampilkan bila index-nya sama dengan current.
|
|
52
|
+
|
|
53
|
+
| Prop | Type | Wajib | Default | Deskripsi |
|
|
54
|
+
| ---------- | ------------------------------------------------------------- | ----- | ----------- | ------------------------------------------------------------------ |
|
|
55
|
+
| `children` | `ReactNode` | ✅ | — | Konten yang muncul ketika langkah ini aktif. |
|
|
56
|
+
| `color` | `'primary' \| 'success' \| 'warning' \| 'danger' \| 'purple'` | ❌ | `'primary'` | Warna lingkaran & garis pada header. |
|
|
57
|
+
| `title` | `string` | ❌ | `''` | (Opsional) Judul untuk ditampilkan di header (bisa dikustom lagi). |
|
|
58
|
+
|
|
59
|
+
## ⚙️ Cara Kerja
|
|
60
|
+
|
|
61
|
+
1. Header Scrollable
|
|
62
|
+
|
|
63
|
+
- Lebar setiap header item fix (stepWidth = 100).
|
|
64
|
+
|
|
65
|
+
- Jika total lebar < perangkat, item otomatis di-center; jika lebih, bisa digeser horizontal.
|
|
66
|
+
|
|
67
|
+
- Ketika current berubah, ScrollView.scrollTo() memastikan item aktif selalu di tengah layar.
|
|
68
|
+
|
|
69
|
+
2. Lingkaran Status
|
|
70
|
+
|
|
71
|
+
- isActive → lingkaran berwarna solid (Color.info[500]).
|
|
72
|
+
|
|
73
|
+
- isCompleted (index < current) → gaya sama dengan aktif (bisa diubah jika ingin beda).
|
|
74
|
+
|
|
75
|
+
- Item terakhir otomatis tanpa garis setelah lingkaran.
|
|
76
|
+
|
|
77
|
+
3. Konten
|
|
78
|
+
|
|
79
|
+
- Hanya langkah aktif yang dirender di area konten (childrenArray[current]).
|
|
80
|
+
|
|
81
|
+
- Jika konten berupa FlatList, properti nestedScrollEnabled diaktifkan agar scrolling mulus di nested list.
|
|
82
|
+
|
|
83
|
+
## 💡 Tips & Praktik Terbaik
|
|
84
|
+
|
|
85
|
+
| Kebutuhan | Saran Implementasi |
|
|
86
|
+
| ------------------------- | --------------------------------------------------------------------------------------------------- |
|
|
87
|
+
| **Navigasi Manual** | Ubah state `current` dari luar (`setCurrentStep`). |
|
|
88
|
+
| **Validasi Tiap Langkah** | Jalankan pengecekan sebelum menaikkan `current`; mis. pastikan form valid. |
|
|
89
|
+
| **Kustom Warna/Ikon** | Edit `COLOR_MAP` atau tambahkan prop `icon` pada `StepItem` jika ingin ikon berbeda di bullet. |
|
|
90
|
+
| **Langkah Dinamis** | Karena `children` berupa array, Anda bisa `.filter()` atau `.slice()` sebelum mem-pass ke `<Step>`. |
|
|
91
|
+
| **Tema Gelap** | Sesuaikan `Color.info[500]`, `Color.info[50]`, dll. |
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# 🗂️ Timeline & TimelineItem
|
|
2
|
+
Timeline menampilkan rangkaian peristiwa secara vertikal—mirip “stepper” atau “activity feed”.
|
|
3
|
+
Setiap node diwakili oleh TimelineItem yang menampilkan titik (bullet icon) dan garis vertikal terhubung.
|
|
4
|
+
|
|
5
|
+
## Contoh Penggunaan
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import React from 'react';
|
|
9
|
+
import { Text } from 'react-native';
|
|
10
|
+
import Timeline from '@herca/rn-kit/Timeline';
|
|
11
|
+
import TimelineItem from '@herca/rn-kit/Timeline/TimelineItem';
|
|
12
|
+
|
|
13
|
+
export default function OrderHistory() {
|
|
14
|
+
return (
|
|
15
|
+
<Timeline>
|
|
16
|
+
<TimelineItem color="success">
|
|
17
|
+
<Text>Pesanan dibuat • 10 Jan 2025</Text>
|
|
18
|
+
</TimelineItem>
|
|
19
|
+
|
|
20
|
+
<TimelineItem color="primary">
|
|
21
|
+
<Text>Dikemas • 11 Jan 2025</Text>
|
|
22
|
+
</TimelineItem>
|
|
23
|
+
|
|
24
|
+
<TimelineItem color="warning">
|
|
25
|
+
<Text>Dalam pengiriman • 12 Jan 2025</Text>
|
|
26
|
+
</TimelineItem>
|
|
27
|
+
|
|
28
|
+
<TimelineItem color="danger">
|
|
29
|
+
<Text>Gagal diterima • 14 Jan 2025</Text>
|
|
30
|
+
</TimelineItem>
|
|
31
|
+
</Timeline>
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Props
|
|
38
|
+
|
|
39
|
+
### Timeline
|
|
40
|
+
| Prop | Type | Wajib | Default | Deskripsi |
|
|
41
|
+
| ---------- | ----------- | ----- | ------- | ---------------------------------- |
|
|
42
|
+
| `children` | `ReactNode` | ✅ | — | Satu atau beberapa `TimelineItem`. |
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
### TimelineItem
|
|
46
|
+
| Prop | Type | Wajib | Default | Deskripsi |
|
|
47
|
+
| ---------- | ------------------------------------------------------------- | ----- | ----------- | ----------------------------------------------------- |
|
|
48
|
+
| `children` | `ReactNode` | ✅ | — | Konten untuk node timeline: teks, ikon tambahan, dsb. |
|
|
49
|
+
| `color` | `'primary' \| 'success' \| 'warning' \| 'danger' \| 'purple'` | ❌ | `'primary'` | Skema warna titik (`RadioButton`) dan garis vertikal. |
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
## ⚙️ Cara Kerja
|
|
53
|
+
|
|
54
|
+
1. Bullet & Line
|
|
55
|
+
|
|
56
|
+
- Bullet dirender dengan komponen Icon (name="RadioButton") memakai warna dari color.
|
|
57
|
+
|
|
58
|
+
- Garis vertikal (borderLeftWidth: 1) menggunakan borderStyle: 'dashed'. Tingginya dihitung secara dinamis (contentHeight - 20) agar garis mulai tepat di bawah bullet.
|
|
59
|
+
|
|
60
|
+
2. Penghitungan Tinggi
|
|
61
|
+
|
|
62
|
+
- onLayout pada wrapper konten mengukur tinggi aktual item.
|
|
63
|
+
|
|
64
|
+
- Hasil pengukuran dipakai untuk menyesuaikan panjang garis, menjaga visual konsisten meskipun konten memiliki tinggi berbeda.
|
|
65
|
+
|
|
66
|
+
3. Layout
|
|
67
|
+
|
|
68
|
+
- Komponen dibangun dengan flexDirection: 'row', bullet di kiri, konten di kanan (flex: 1).
|
|
69
|
+
|
|
70
|
+
- Margin horizontal (marginRight: 8) menjaga jarak antara bullet dan konten.
|
|
71
|
+
|
|
72
|
+
## 💡 Tips Penggunaan
|
|
73
|
+
- Item Terakhir Tanpa Garis
|
|
74
|
+
Bila ingin menghilangkan garis pada item terakhir, buat prop opsional mis. isLast dan kondisikan tinggi garis menjadi 0.
|
|
75
|
+
|
|
76
|
+
- Interaktif
|
|
77
|
+
Anda bebas menambahkan tombol, TouchableOpacity, atau ikon status di dalam children.
|
|
78
|
+
|
|
79
|
+
- Kustomisasi Warna
|
|
80
|
+
Untuk warna tambahan, update COLOR_MAP dan tipe ColorKey pada TimelineItem.
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
import { View } from 'react-native';
|
|
1
|
+
import { StyleSheet, View } from 'react-native';
|
|
2
2
|
|
|
3
3
|
interface Timeline {
|
|
4
4
|
children: React.ReactNode;
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
export default function Timeline({ children }: Timeline) {
|
|
8
|
-
return <View>{children}</View>;
|
|
8
|
+
return <View style={styles.gap14}>{children}</View>;
|
|
9
9
|
}
|
|
10
|
+
|
|
11
|
+
const styles = StyleSheet.create({
|
|
12
|
+
gap14: {
|
|
13
|
+
gap: 14,
|
|
14
|
+
},
|
|
15
|
+
});
|
|
@@ -14,7 +14,7 @@ type ColorKey = keyof typeof COLOR_MAP;
|
|
|
14
14
|
|
|
15
15
|
interface TimelineItemProps {
|
|
16
16
|
children: React.ReactNode;
|
|
17
|
-
color
|
|
17
|
+
color?: ColorKey;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
export default function TimelineItem({
|
|
@@ -22,12 +22,25 @@ export default function TimelineItem({
|
|
|
22
22
|
color = 'primary',
|
|
23
23
|
}: TimelineItemProps) {
|
|
24
24
|
const [contentHeight, setContentHeight] = useState(0);
|
|
25
|
+
const renderDashes = (count: number) => {
|
|
26
|
+
return Array.from({ length: count }).map((_, index) => (
|
|
27
|
+
<View
|
|
28
|
+
key={index}
|
|
29
|
+
style={{
|
|
30
|
+
width: 1,
|
|
31
|
+
height: 4,
|
|
32
|
+
backgroundColor: Color.gray[400],
|
|
33
|
+
marginVertical: 2,
|
|
34
|
+
}}
|
|
35
|
+
/>
|
|
36
|
+
));
|
|
37
|
+
};
|
|
25
38
|
|
|
26
39
|
return (
|
|
27
40
|
<View style={styles.container}>
|
|
28
41
|
<View style={styles.contentLeft}>
|
|
29
42
|
<Icon name="RadioButton" color={COLOR_MAP[color]} />
|
|
30
|
-
<View
|
|
43
|
+
<View>{renderDashes(Math.floor((contentHeight - 20) / 6))}</View>
|
|
31
44
|
</View>
|
|
32
45
|
<View
|
|
33
46
|
style={styles.flex}
|
|
@@ -52,10 +65,10 @@ const styles = StyleSheet.create({
|
|
|
52
65
|
},
|
|
53
66
|
border: {
|
|
54
67
|
width: 1,
|
|
68
|
+
borderWidth: 1,
|
|
55
69
|
borderLeftWidth: 1,
|
|
56
70
|
borderLeftColor: Color.gray[400],
|
|
57
71
|
borderStyle: 'dashed',
|
|
58
|
-
marginTop: 4,
|
|
59
72
|
},
|
|
60
73
|
flex: {
|
|
61
74
|
flex: 1,
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# 🌐 ToastProvider & useToast()
|
|
2
|
+
ToastProvider adalah context global untuk menampilkan notifikasi Toast dari bagian manapun dalam aplikasi Anda. Digunakan bersama dengan hook useToast() untuk memanggil toast secara imperatif.
|
|
3
|
+
|
|
4
|
+
## ⚙️ Setup
|
|
5
|
+
1. Bungkus aplikasi Anda dengan ToastProvider
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import React from 'react';
|
|
9
|
+
import { ToastProvider } from '@herca/rn-kit';
|
|
10
|
+
|
|
11
|
+
export default function App() {
|
|
12
|
+
return (
|
|
13
|
+
<ToastProvider>
|
|
14
|
+
{/* Seluruh aplikasi Anda */}
|
|
15
|
+
</ToastProvider>
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
2. Gunakan useToast() di dalam komponen
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
```tsx
|
|
25
|
+
import React from 'react';
|
|
26
|
+
import { Button } from '@herca/rn-kit';
|
|
27
|
+
import { useToast } from '@herca/rn-kit';
|
|
28
|
+
|
|
29
|
+
export default function Dashboard() {
|
|
30
|
+
const toast = useToast();
|
|
31
|
+
|
|
32
|
+
const handleSuccess = () => {
|
|
33
|
+
toast.show('Data berhasil disimpan', {
|
|
34
|
+
color: 'success',
|
|
35
|
+
icon: 'CheckCircle',
|
|
36
|
+
duration: 4000,
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
return <Button title="Simpan" onPress={handleSuccess} />;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## 🧩 API Reference
|
|
46
|
+
### ✅ ToastProvider
|
|
47
|
+
Menyediakan context global toast. Harus membungkus komponen root Anda.
|
|
48
|
+
|
|
49
|
+
| Prop | Type | Required | Description |
|
|
50
|
+
| ---------- | ----------- | -------- | --------------------------------- |
|
|
51
|
+
| `children` | `ReactNode` | ✅ | Semua komponen di dalam aplikasi. |
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
### useToast() Hook
|
|
55
|
+
| Function | Type |
|
|
56
|
+
| ------------------------- | --------------------------------------------------- |
|
|
57
|
+
| `show(message, options?)` | `(message: string, options?: ToastOptions) => void` |
|
|
58
|
+
|
|
59
|
+
### ToastOptions
|
|
60
|
+
| Option | Type | Default | Description |
|
|
61
|
+
| ---------- | ------------------ | ------------------ | ---------------------------------- |
|
|
62
|
+
| `color` | `ColorVariantType` | `'default'` | Warna latar belakang dan teks. |
|
|
63
|
+
| `icon` | `IconNameProps` | `'ExlamationMark'` | Ikon di samping pesan. |
|
|
64
|
+
| `duration` | `number` (ms) | `3000` | Waktu tampil Toast sebelum hilang. |
|
|
65
|
+
|
|
66
|
+
## ❗ Error Handling
|
|
67
|
+
Error: useToast must be used within a ToastProvider
|
|
68
|
+
```tsx
|
|
69
|
+
Error: useToast must be used within a ToastProvider
|
|
70
|
+
|
|
71
|
+
```
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# 🃏 Card
|
|
2
|
+
|
|
3
|
+
Komponen Card digunakan sebagai wadah tampilan (container) dengan desain yang konsisten seperti border, padding, dan optional background (warna atau gambar). Cocok digunakan untuk membungkus informasi atau konten secara visual terstruktur.
|
|
4
|
+
|
|
5
|
+
## Contoh Penggunaan
|
|
6
|
+
|
|
7
|
+
``` tsx
|
|
8
|
+
import { Card, Color, Container, Typography } from '@herca/rn-kit';
|
|
9
|
+
import { View } from 'react-native';
|
|
10
|
+
|
|
11
|
+
export default function CardScreen() {
|
|
12
|
+
return (
|
|
13
|
+
<View>
|
|
14
|
+
<Container>
|
|
15
|
+
<Typography variant="h4" weight="semibold">
|
|
16
|
+
Default
|
|
17
|
+
</Typography>
|
|
18
|
+
<Card>
|
|
19
|
+
<Typography color={Color.gray[800]} weight="bold">
|
|
20
|
+
What is Lorem Ipsum?
|
|
21
|
+
</Typography>
|
|
22
|
+
<Typography color={Color.gray[800]}>
|
|
23
|
+
Lorem Ipsum is simply dummy text of the printing and typesetting
|
|
24
|
+
industry. Lorem Ipsum has been the industry's standard dummy text
|
|
25
|
+
ever since the 1500s, when an unknown printer took a galley of type
|
|
26
|
+
and scrambled it to make a type specimen book. It has survived not
|
|
27
|
+
only five centuries, but also the leap into electronic typesetting,
|
|
28
|
+
remaining essentially unchanged.
|
|
29
|
+
</Typography>
|
|
30
|
+
</Card>
|
|
31
|
+
<Typography variant="h4" weight="semibold">
|
|
32
|
+
Background Image
|
|
33
|
+
</Typography>
|
|
34
|
+
<Card backgroundImage={require('../assets/sp_banner.png')}>
|
|
35
|
+
<Typography color={Color.base.white100} weight="bold">
|
|
36
|
+
What is Lorem Ipsum?
|
|
37
|
+
</Typography>
|
|
38
|
+
<Typography color={Color.base.white100}>
|
|
39
|
+
Lorem Ipsum is simply dummy text of
|
|
40
|
+
</Typography>
|
|
41
|
+
</Card>
|
|
42
|
+
<Typography variant="h4" weight="semibold">
|
|
43
|
+
Background Color
|
|
44
|
+
</Typography>
|
|
45
|
+
<Card backgroundColor={Color.primary[1000]}>
|
|
46
|
+
<Typography color={Color.base.white100} weight="bold">
|
|
47
|
+
What is Lorem Ipsum?
|
|
48
|
+
</Typography>
|
|
49
|
+
<Typography color={Color.base.white100}>
|
|
50
|
+
Lorem Ipsum is simply dummy text of the printing and typesetting
|
|
51
|
+
industry. Lorem Ipsum has been the industry's standard dummy text
|
|
52
|
+
ever since the 1500s,
|
|
53
|
+
</Typography>
|
|
54
|
+
</Card>
|
|
55
|
+
</Container>
|
|
56
|
+
</View>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Props
|
|
63
|
+
|
|
64
|
+
| Props | Tipe | Wajib | Default | Deskripsi |
|
|
65
|
+
| ----------------- | ----------------------------- | ----- | ------- | ---------------------------------------------------- |
|
|
66
|
+
| `children` | `ReactNode` | ✅ | - | Komponen atau konten di dalam Card. |
|
|
67
|
+
| `style` | `StyleProp<ViewStyle>` | ❌ | - | Gaya tambahan untuk Card (padding, margin, dsb). |
|
|
68
|
+
| `backgroundImage` | `ImageSourcePropType` (`any`) | ❌ | - | Gambar latar belakang menggunakan `ImageBackground`. |
|
|
69
|
+
| `backgroundColor` | `string` | ❌ | `#fff` | Warna latar belakang Card. |
|
|
70
|
+
|
|
71
|
+
## Catatan
|
|
72
|
+
- Saat backgroundImage digunakan, ImageBackground akan membungkus children dan otomatis mengikuti styling dari Card.
|
|
73
|
+
|
|
74
|
+
- Jika Anda ingin menambahkan padding pada konten dalam Card, pastikan Anda menambahkannya di level children atau buat pembungkus tambahan jika padding default tidak cukup.
|
|
75
|
+
|
|
76
|
+
- Kompatibel dengan semua komponen React Native seperti Text, Image, TouchableOpacity, dll.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# 📦 Container
|
|
2
|
+
Komponen Container adalah pembungkus layout umum yang memberikan padding horizontal dan vertikal secara konsisten untuk konten di dalamnya. Cocok digunakan untuk membungkus seluruh tampilan atau bagian utama dari layar.
|
|
3
|
+
|
|
4
|
+
## 📐 Contoh Penggunaan
|
|
5
|
+
|
|
6
|
+
```tsx
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import { Text } from 'react-native';
|
|
9
|
+
import Container from '@herca/rn-kit/Container';
|
|
10
|
+
|
|
11
|
+
export default function HomeScreen() {
|
|
12
|
+
return (
|
|
13
|
+
<Container>
|
|
14
|
+
<Text>Selamat datang di aplikasi kami!</Text>
|
|
15
|
+
</Container>
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## props
|
|
23
|
+
| Prop | Tipe | Wajib | Default | Deskripsi |
|
|
24
|
+
| ---------- | ---------------------- | ----- | ------- | ------------------------------------------------------------ |
|
|
25
|
+
| `children` | `ReactNode` | ✅ | - | Komponen atau tampilan yang dibungkus di dalam container. |
|
|
26
|
+
| `style` | `StyleProp<ViewStyle>` | ❌ | - | Tambahan gaya jika ingin menimpa atau menambah gaya default. |
|
package/src/index.tsx
CHANGED
|
@@ -37,7 +37,6 @@ export { default as Switch } from './Input/Switch';
|
|
|
37
37
|
export { default as CheckBox } from './CheckBox/CheckBox';
|
|
38
38
|
export { default as CheckBoxList } from './CheckBox/CheckBoxList';
|
|
39
39
|
export { default as RadioButton } from './RadioButton/RadioButton';
|
|
40
|
-
export { default as SwitchButton } from './SwitchButton/SwitchButton';
|
|
41
40
|
export { default as Icon } from './Icon/Icon';
|
|
42
41
|
export { default as Modal } from './Modal/Modal';
|
|
43
42
|
export { default as Label } from './Label/Label';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["View","jsx","_jsx","SwitchButton"],"sourceRoot":"../../../src","sources":["SwitchButton/SwitchButton.tsx"],"mappings":";;AAAA,SAASA,IAAI,QAAQ,cAAc;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAEpC,eAAe,SAASC,YAAYA,CAAA,EAAG;EACrC,oBAAOD,IAAA,CAACF,IAAI,IAAO,CAAC;AACtB","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["TextArea/TextArea.tsx"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SwitchButton.d.ts","sourceRoot":"","sources":["../../../../src/SwitchButton/SwitchButton.tsx"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,UAAU,YAAY,4CAEnC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=TextArea.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TextArea.d.ts","sourceRoot":"","sources":["../../../../src/TextArea/TextArea.tsx"],"names":[],"mappings":""}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|