@herca/rn-kit 0.1.7 → 0.1.8
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 +11 -7
- package/lib/module/Accordion/README.md +1 -0
- package/lib/module/Alert/README.md +1 -0
- package/lib/module/Avatar/README_AVATAR.md +1 -1
- package/lib/module/Avatar/README_AVATARGROUP.md +3 -1
- package/lib/module/BottomSheet/README.md +1 -1
- package/lib/module/Button/README.md +3 -1
- package/lib/module/Calendar/README.md +1 -0
- package/lib/module/Chip/README.md +2 -1
- package/lib/module/Color/README.md +97 -46
- package/lib/module/DatePicker/{README.md → README_DATEPICKER.md} +1 -0
- package/lib/module/DatePicker/README_MONTHPICKER.md +90 -0
- package/lib/module/DatePicker/README_TIMEPICKER.md +83 -0
- package/lib/module/DatePicker/README_YEARPICKER.md +106 -0
- package/lib/module/DropDown/README.md +107 -0
- package/lib/module/Label/README.md +65 -0
- package/lib/module/RadioButton/README.md +2 -1
- package/lib/module/Ui/README_DEVIDER.md +62 -0
- package/lib/module/Ui/README_FOOTER.md +0 -0
- package/package.json +1 -1
- package/src/Accordion/README.md +1 -0
- package/src/Alert/README.md +1 -0
- package/src/Avatar/README_AVATAR.md +1 -1
- package/src/Avatar/README_AVATARGROUP.md +3 -1
- package/src/BottomSheet/README.md +1 -1
- package/src/Button/README.md +3 -1
- package/src/Calendar/README.md +1 -0
- package/src/Chip/README.md +2 -1
- package/src/Color/README.md +97 -46
- package/src/DatePicker/{README.md → README_DATEPICKER.md} +1 -0
- package/src/DatePicker/README_MONTHPICKER.md +90 -0
- package/src/DatePicker/README_TIMEPICKER.md +83 -0
- package/src/DatePicker/README_YEARPICKER.md +106 -0
- package/src/DropDown/README.md +107 -0
- package/src/Label/README.md +65 -0
- package/src/RadioButton/README.md +2 -1
- package/src/Ui/README_DEVIDER.md +62 -0
- package/src/Ui/README_FOOTER.md +0 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# YearPicker
|
|
2
|
+
|
|
3
|
+
**YearPicker** adalah komponen pemilih tahun berbasis **React Native**. Dibandingkan dengan *MonthPicker*, komponen ini mendukung navigasi halaman (pagination) untuk deretan tahun dan dapat digunakan dalam tiga mode:
|
|
4
|
+
|
|
5
|
+
* **single** – memilih satu tahun.
|
|
6
|
+
* **range** – memilih rentang tahun.
|
|
7
|
+
* **multiple** – memilih beberapa tahun sekaligus.
|
|
8
|
+
|
|
9
|
+
Semua outputnya dibungkus dalam komponen **BottomSheet** untuk konsistensi UI.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## API Reference
|
|
14
|
+
|
|
15
|
+
| Prop | Tipe | Default | Deskripsi |
|
|
16
|
+
| ---------- | ------------------------------------------------------------------------------------- | ---------- | ------------------------------------------------------------------------------------ |
|
|
17
|
+
| `isOpen` | `boolean` | `false` | Menentukan apakah **BottomSheet** terbuka. |
|
|
18
|
+
| `onClose` | `() => void` | `-` | Dipanggil saat pengguna menutup picker atau menekan **Batal**. |
|
|
19
|
+
| `onChange` | `(value: number[] \| { startDate: number \| null; endDate: number \| null }) => void` | `-` | Dipanggil setelah pengguna menekan **Pilih**. Bentuk *value* bergantung pada `mode`. |
|
|
20
|
+
| `mode` | `'single' \| 'range' \| 'multiple'` | `'single'` | Menentukan mode pemilihan. |
|
|
21
|
+
|
|
22
|
+
### Bentuk *value* `onChange`
|
|
23
|
+
|
|
24
|
+
| `mode` | *value* |
|
|
25
|
+
| ---------- | ---------------------------------------------------------------------------------------------------------------------- |
|
|
26
|
+
| `single` | `number[]` – satu elemen, contoh `[2023]`. |
|
|
27
|
+
| `range` | `{ startDate: number \| null; endDate: number \| null }` – objek rentang, contoh `{ startDate: 2010, endDate: 2015 }`. |
|
|
28
|
+
| `multiple` | `number[]` – daftar tahun, contoh `[2018, 2020, 2022]`. |
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## Cara Kerja Singkat
|
|
33
|
+
|
|
34
|
+
1. **Daftar Tahun**
|
|
35
|
+
|
|
36
|
+
* Komponen membuat rentang tahun ±60 tahun ke belakang & depan dari tahun saat ini (total 121 tahun).
|
|
37
|
+
2. **Pagination**
|
|
38
|
+
|
|
39
|
+
* `pageSize` default 9 (3 kolom × 3 baris). Tombol panah mengubah `pageIndex` untuk melihat kelompok tahun selanjutnya atau sebelumnya.
|
|
40
|
+
3. **Seleksi & Highlight**
|
|
41
|
+
|
|
42
|
+
* Tahun yang dipilih diberi latar `Color.primary[50]` dan border `Color.primary[300]`.
|
|
43
|
+
4. **Logika Mode**
|
|
44
|
+
|
|
45
|
+
* *Single*: klik satu tahun.
|
|
46
|
+
* *Range*: klik awal & akhir; otomatis menukar jika urutan terbalik.
|
|
47
|
+
* *Multiple*: toggle checklist per tahun.
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Contoh Penggunaan
|
|
52
|
+
|
|
53
|
+
```tsx
|
|
54
|
+
import { useState } from 'react';
|
|
55
|
+
import { View, Button } from 'react-native';
|
|
56
|
+
import YearPicker from '@/components/YearPicker/YearPicker';
|
|
57
|
+
|
|
58
|
+
export default function YearPickerExample() {
|
|
59
|
+
const [open, setOpen] = useState(false);
|
|
60
|
+
const [yearRange, setYearRange] = useState<{ startDate: number | null; endDate: number | null }>({ startDate: null, endDate: null });
|
|
61
|
+
|
|
62
|
+
const label = yearRange.startDate && yearRange.endDate ? `${yearRange.startDate}–${yearRange.endDate}` : '—';
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<View style={{ flex: 1 }}>
|
|
66
|
+
<Button title={`Pilih Rentang Tahun (${label})`} onPress={() => setOpen(true)} />
|
|
67
|
+
|
|
68
|
+
<YearPicker
|
|
69
|
+
isOpen={open}
|
|
70
|
+
mode="range"
|
|
71
|
+
onClose={() => setOpen(false)}
|
|
72
|
+
onChange={(value) => {
|
|
73
|
+
if (!Array.isArray(value)) {
|
|
74
|
+
setYearRange(value);
|
|
75
|
+
}
|
|
76
|
+
setOpen(false);
|
|
77
|
+
}}
|
|
78
|
+
/>
|
|
79
|
+
</View>
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## Kustomisasi Tampilan & Perilaku
|
|
87
|
+
|
|
88
|
+
| Konstanta / Style | Fungsi | Cara Ubah |
|
|
89
|
+
| ----------------- | ------------------------------------------------ | ---------------------------------------- |
|
|
90
|
+
| `pageSize` | Jumlah tahun ditampilkan per halaman (grid 3×N). | Sesuaikan untuk menambah baris. |
|
|
91
|
+
| `buttonNav` | Style tombol panah. | Edit warna & radius pada file `styles`. |
|
|
92
|
+
| `optionSelected` | Warna highlight. | Ganti `backgroundColor` & `borderColor`. |
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## Tips Implementasi
|
|
97
|
+
|
|
98
|
+
* Ingin memulai dengan tahun tertentu? Setel `singleValue`, `rangeValue`, atau `multipleValue` melalui `useState` sebelum `isOpen` di-set `true`.
|
|
99
|
+
* Anda dapat memfilter rentang tahun dengan memodifikasi konstanta `total` & `start` di dalam `useMemo(years)`.
|
|
100
|
+
* Pastikan memanggil `onClose` setelah `onChange` untuk menutup picker.
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## Lisensi
|
|
105
|
+
|
|
106
|
+
Bagian dari library internal Anda; ikuti lisensi proyek.
|
package/src/DropDown/README.md
CHANGED
|
@@ -1 +1,108 @@
|
|
|
1
1
|
# Dropdown
|
|
2
|
+
|
|
3
|
+
**Dropdown** merupakan komponen menu pilihan (select) berbasis **React Native** yang menampilkan daftar opsi di atas modal transparan. Komponen ini otomatis men‐posisikan daftar ke kiri atau ke kanan bergantung pada posisi tombol pemicu agar tidak terpotong layar.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Instalasi
|
|
8
|
+
|
|
9
|
+
Komponen ini mengandalkan dependensi internal:
|
|
10
|
+
|
|
11
|
+
* `Color` – sistem warna.
|
|
12
|
+
* `ChipOptionProps` – tipe opsi.
|
|
13
|
+
|
|
14
|
+
Serta modul standar React Native: `Modal`, `ScrollView`, dll. Tidak memerlukan library eksternal.
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## API Reference
|
|
19
|
+
|
|
20
|
+
| Prop | Tipe | Default | Deskripsi |
|
|
21
|
+
| -------------- | ----------------------------------- | ----------- | ------------------------------------------------------------------- |
|
|
22
|
+
| `options` | `ChipOptionProps[]` | `[]` | Daftar objek `{ label, value }` yang akan ditampilkan sebagai opsi. |
|
|
23
|
+
| `maxHeight` | `number` | `200` | Tinggi maksimum daftar sebelum dapat di‐scroll. |
|
|
24
|
+
| `onSelect` | `(value: string \| number) => void` | `undefined` | Callback saat pengguna memilih opsi. |
|
|
25
|
+
| `renderButton` | `React.ReactNode` | **(wajib)** | Elemen yang dipakai sebagai tombol pemicu dropdown. |
|
|
26
|
+
|
|
27
|
+
### Struktur `ChipOptionProps`
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
interface ChipOptionProps {
|
|
31
|
+
label: string;
|
|
32
|
+
value: string | number;
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Cara Kerja Singkat
|
|
39
|
+
|
|
40
|
+
1. **Posisi & Alignment**
|
|
41
|
+
|
|
42
|
+
* Saat tombol ditekan, komponen mengukur posisi tombol (`UIManager.measureInWindow`).
|
|
43
|
+
* Jika titik tengah tombol berada di sisi kanan layar, daftar disejajarkan ke kanan; sebaliknya ke kiri.
|
|
44
|
+
2. **Modal & Pressable Overlay**
|
|
45
|
+
|
|
46
|
+
* Daftar opsi dibungkus `Modal` transparan.
|
|
47
|
+
* `Pressable` penuh layar di belakang daftar menangani klik di luar untuk menutup menu.
|
|
48
|
+
3. **Scroll & Batas Tinggi**
|
|
49
|
+
|
|
50
|
+
* Daftar opsi di dalam `ScrollView` dengan properti `nestedScrollEnabled` agar tetap dapat di‐scroll di dalam modalsheet lain.
|
|
51
|
+
4. **Highlight Opsi Terpilih**
|
|
52
|
+
|
|
53
|
+
* Opsi aktif diberi style `optionSelected` – background `Color.primary[50]` & border `Color.primary[300]`.
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## Contoh Penggunaan
|
|
58
|
+
|
|
59
|
+
```tsx
|
|
60
|
+
import { useState } from 'react';
|
|
61
|
+
import { View, Text } from 'react-native';
|
|
62
|
+
import Dropdown from '@/components/Dropdown/Dropdown';
|
|
63
|
+
|
|
64
|
+
const options = [
|
|
65
|
+
{ label: 'Apple', value: 'apple' },
|
|
66
|
+
{ label: 'Banana', value: 'banana' },
|
|
67
|
+
{ label: 'Cherry', value: 'cherry' },
|
|
68
|
+
];
|
|
69
|
+
|
|
70
|
+
export default function DropdownExample() {
|
|
71
|
+
const [fruit, setFruit] = useState<string | number>('apple');
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
|
|
75
|
+
<Dropdown
|
|
76
|
+
options={options}
|
|
77
|
+
maxHeight={150}
|
|
78
|
+
onSelect={(val) => setFruit(val)}
|
|
79
|
+
renderButton={
|
|
80
|
+
<View style={{ padding: 12, borderWidth: 1, borderRadius: 8 }}>
|
|
81
|
+
<Text>{options.find((o) => o.value === fruit)?.label}</Text>
|
|
82
|
+
</View>
|
|
83
|
+
}
|
|
84
|
+
/>
|
|
85
|
+
</View>
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## Kustomisasi Tampilan
|
|
93
|
+
|
|
94
|
+
| Style Key | Fungsi | Cara Ubah |
|
|
95
|
+
| ---------------- | ---------------------- | ------------------------------------------------- |
|
|
96
|
+
| `dropdownList` | Container daftar opsi. | Ubah `width`, `borderRadius`, `borderColor`, dll. |
|
|
97
|
+
| `option` | Setiap baris opsi. | Ubah `padding` atau `gap` sesuai kebutuhan. |
|
|
98
|
+
| `optionSelected` | Style opsi terpilih. | Sesuaikan warna highlight dengan brand. |
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## Tips Implementasi
|
|
103
|
+
|
|
104
|
+
* **Kontrol Render Button**: Anda bebas menggunakan komponen apa pun sebagai `renderButton` (ikon, input field, card, dll.). Dropdown akan menggunakan posisi & ukuran elemen ini.
|
|
105
|
+
* **Close on Scroll Parent**: Jika dropdown dipakai dalam layar yang di‐scroll, pertimbangkan menutup dropdown saat parent di‐scroll untuk mencegah posisi meleset.
|
|
106
|
+
* **Validasi**: Komponen tidak memaksa nilai default. Anda dapat men‐set `selected` manual via `useState` agar kontrol tetap ter‐sinkron.
|
|
107
|
+
|
|
108
|
+
---
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# Label
|
|
2
|
+
|
|
3
|
+
**Label** adalah komponen kecil berbentuk badge untuk menampilkan status, kategori, atau metadata ringkas. Komponen ini mendukung ikon, variasi warna, dan konten kustom.
|
|
4
|
+
|
|
5
|
+
## API Reference
|
|
6
|
+
|
|
7
|
+
| Prop | Tipe | Default | Deskripsi |
|
|
8
|
+
| ---------- | ------------------------------------------------------------------------------------------------ | ----------- | ------------------------------------------------------------------------------ |
|
|
9
|
+
| `label` | `string` | `''` | Teks yang ditampilkan jika `children` tidak disediakan. |
|
|
10
|
+
| `children` | `React.ReactNode` | `undefined` | Menampilkan elemen kustom sebagai isi label. Jika ada, `label` akan diabaikan. |
|
|
11
|
+
| `color` | `'default' \| 'success' \| 'danger' \| 'primary' \| 'warning' \| 'info' \| 'purple' \| 'orange'` | `'default'` | Variasi warna latar dan teks. |
|
|
12
|
+
| `icon` | `IconNameProps` | `undefined` | Menampilkan ikon di sebelah kiri teks. |
|
|
13
|
+
| `size` | `'small' \| 'medium'` | `'medium'` | (Belum digunakan – untuk ekspansi ukuran ke depan.) |
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Warna yang Didukung
|
|
18
|
+
|
|
19
|
+
| Warna | Background | Teks |
|
|
20
|
+
| --------- | ------------------- | -------------------- |
|
|
21
|
+
| `default` | `Color.gray[50]` | `Color.gray[900]` |
|
|
22
|
+
| `success` | `Color.success[50]` | `Color.success[300]` |
|
|
23
|
+
| `danger` | `Color.danger[50]` | `Color.danger[300]` |
|
|
24
|
+
| `primary` | `Color.primary[50]` | `Color.primary[300]` |
|
|
25
|
+
| `warning` | `Color.warning[50]` | `Color.warning[300]` |
|
|
26
|
+
| `info` | `Color.info[50]` | `Color.info[300]` |
|
|
27
|
+
| `purple` | `Color.purple[50]` | `Color.purple[300]` |
|
|
28
|
+
| `orange` | `Color.orange[50]` | `Color.orange[300]` |
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## Contoh Penggunaan
|
|
33
|
+
|
|
34
|
+
### Label Sederhana
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
<Label label="Active" color="success" />
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Label dengan Ikon
|
|
41
|
+
|
|
42
|
+
```tsx
|
|
43
|
+
<Label label="Error" color="danger" icon="AlertCircle" />
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Kustom Isi (Children)
|
|
47
|
+
|
|
48
|
+
```tsx
|
|
49
|
+
<Label color="primary">
|
|
50
|
+
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
|
51
|
+
<Icon name="Check" color={Color.primary[300]} size={12} />
|
|
52
|
+
<Text style={{ color: Color.primary[300], marginLeft: 4 }}>Custom</Text>
|
|
53
|
+
</View>
|
|
54
|
+
</Label>
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## Catatan Tambahan
|
|
60
|
+
|
|
61
|
+
* Jika Anda memberikan `children`, maka `label` dan `icon` akan diabaikan.
|
|
62
|
+
* Komponen ini menggunakan `alignSelf: 'flex-start'` agar ukuran label tidak penuh.
|
|
63
|
+
* Prop `size` belum aktif, namun sudah disiapkan jika ke depan ingin mendukung skala `small`/`large`.
|
|
64
|
+
|
|
65
|
+
---
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
# 📦 RadioButton – Komponen React Native
|
|
2
2
|
|
|
3
3
|
Komponen `RadioButton` ini digunakan untuk menampilkan daftar pilihan dalam bentuk radio button di aplikasi React Native.
|
|
4
|
-
|
|
4
|
+
<img src="../../assets/doc/RadioButton/RadioButton.png" width=200>
|
|
5
|
+
|
|
5
6
|
|
|
6
7
|
## 📄 Import
|
|
7
8
|
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# Divider
|
|
2
|
+
|
|
3
|
+
**Divider** adalah komponen garis horizontal sederhana yang digunakan untuk memisahkan konten secara visual dalam antarmuka pengguna.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Instalasi
|
|
8
|
+
|
|
9
|
+
Komponen ini tidak memerlukan dependensi eksternal. Hanya menggunakan:
|
|
10
|
+
|
|
11
|
+
* `Color` – untuk warna garis.
|
|
12
|
+
* `View` dan `StyleSheet` dari `react-native`.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## API Reference
|
|
17
|
+
|
|
18
|
+
Tidak memiliki properti (props) khusus. Komponen ini dapat digunakan langsung dan bisa dikustomisasi melalui `style` eksternal jika diperlukan.
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Contoh Penggunaan
|
|
23
|
+
|
|
24
|
+
### Divider Default
|
|
25
|
+
|
|
26
|
+
```tsx
|
|
27
|
+
import Divider from '@/components/Divider/Divider';
|
|
28
|
+
|
|
29
|
+
<View>
|
|
30
|
+
<Text>Bagian Atas</Text>
|
|
31
|
+
<Divider />
|
|
32
|
+
<Text>Bagian Bawah</Text>
|
|
33
|
+
</View>
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Divider dengan Margin
|
|
37
|
+
|
|
38
|
+
```tsx
|
|
39
|
+
<View style={{ marginVertical: 12 }}>
|
|
40
|
+
<Divider />
|
|
41
|
+
</View>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Divider yang Dikustomisasi
|
|
45
|
+
|
|
46
|
+
```tsx
|
|
47
|
+
<Divider style={{ backgroundColor: 'red', height: 2 }} />
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
> Catatan: Untuk mengubah gaya `Divider`, bungkus komponen dengan `View` tambahan atau tambahkan prop `style` melalui wrapper jika perlu.
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## Style Default
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
{
|
|
58
|
+
height: 1,
|
|
59
|
+
backgroundColor: Color.gray[200],
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
File without changes
|