@herca/rn-kit 0.1.17 → 0.1.19
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 -0
- package/lib/module/BottomSheet/BottomSheet.js +1 -0
- package/lib/module/BottomSheet/BottomSheet.js.map +1 -1
- package/lib/module/Chip/Chip.js +6 -6
- package/lib/module/Chip/Chip.js.map +1 -1
- package/lib/module/CounterButton/CounterButton.js +130 -0
- package/lib/module/CounterButton/CounterButton.js.map +1 -0
- package/lib/module/CounterButton/README.md +76 -0
- package/lib/module/CounterButton/type.js +2 -0
- package/lib/module/CounterButton/type.js.map +1 -0
- package/lib/module/DatePicker/DatePicker.js +51 -47
- package/lib/module/DatePicker/DatePicker.js.map +1 -1
- package/lib/module/DatePicker/README_DATEPICKER.md +1 -0
- package/lib/module/Icon/Icon.js +2 -0
- package/lib/module/Icon/Icon.js.map +1 -1
- package/lib/module/Icon/icons/Minus.js +22 -0
- package/lib/module/Icon/icons/Minus.js.map +1 -0
- package/lib/module/Select/README_Select.md +2 -0
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/Calendar/CalendarPropsType.d.ts +4 -3
- package/lib/typescript/src/Calendar/CalendarPropsType.d.ts.map +1 -1
- package/lib/typescript/src/Chip/type.d.ts +2 -2
- package/lib/typescript/src/Chip/type.d.ts.map +1 -1
- package/lib/typescript/src/CounterButton/CounterButton.d.ts +3 -0
- package/lib/typescript/src/CounterButton/CounterButton.d.ts.map +1 -0
- package/lib/typescript/src/CounterButton/type.d.ts +10 -0
- package/lib/typescript/src/CounterButton/type.d.ts.map +1 -0
- package/lib/typescript/src/DatePicker/DatePicker.d.ts +1 -1
- package/lib/typescript/src/DatePicker/DatePicker.d.ts.map +1 -1
- package/lib/typescript/src/Icon/Icon.d.ts.map +1 -1
- package/lib/typescript/src/Icon/icons/Minus.d.ts +9 -0
- package/lib/typescript/src/Icon/icons/Minus.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/Select/type.d.ts +2 -2
- package/lib/typescript/src/Select/type.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +1 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/BottomSheet/BottomSheet.tsx +1 -0
- package/src/Calendar/CalendarPropsType.tsx +4 -3
- package/src/Chip/Chip.tsx +4 -4
- package/src/Chip/type.tsx +2 -2
- package/src/CounterButton/CounterButton.tsx +176 -0
- package/src/CounterButton/README.md +76 -0
- package/src/CounterButton/type.tsx +9 -0
- package/src/DatePicker/DatePicker.tsx +62 -41
- package/src/DatePicker/README_DATEPICKER.md +1 -0
- package/src/Icon/Icon.tsx +2 -0
- package/src/Icon/icons/Minus.tsx +25 -0
- package/src/Icon/type.tsx +1 -0
- package/src/Select/README_Select.md +2 -0
- package/src/Select/type.tsx +2 -2
- package/src/index.tsx +1 -0
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { useCallback, useState, useEffect } from 'react';
|
|
2
2
|
import { StyleSheet, View } from 'react-native';
|
|
3
3
|
import BottomSheet from '../BottomSheet/BottomSheet';
|
|
4
|
-
import Calendar from '../Calendar/Calendar';
|
|
4
|
+
import Calendar, { formatDate } from '../Calendar/Calendar';
|
|
5
5
|
import Button from '../Button/Button';
|
|
6
6
|
import Alert from '../Alert/Alert';
|
|
7
7
|
import {
|
|
8
|
+
type CalendarMarkDatesType,
|
|
8
9
|
type CalendarModeType,
|
|
9
10
|
type DateRangeProps,
|
|
10
11
|
} from '../Calendar/CalendarPropsType';
|
|
12
|
+
import Color from '../Color/Color';
|
|
11
13
|
|
|
12
14
|
interface DatePickerProps {
|
|
13
15
|
onChange: (selectedDate: DateRangeProps) => void;
|
|
@@ -31,53 +33,30 @@ export default function DatePicker({
|
|
|
31
33
|
onHasError,
|
|
32
34
|
hint,
|
|
33
35
|
mode,
|
|
34
|
-
|
|
36
|
+
value,
|
|
35
37
|
...calendarProps
|
|
36
38
|
}: DatePickerProps) {
|
|
37
39
|
const [errorValidate, setErrorValidate] = useState<boolean>(false);
|
|
38
|
-
|
|
39
|
-
const [
|
|
40
|
+
const [markDates, setMarkDates] = useState<CalendarMarkDatesType>();
|
|
41
|
+
const [valueDatepicker, setValueDatepicker] = useState<DateRangeProps>({
|
|
40
42
|
startDate: null,
|
|
41
43
|
endDate: null,
|
|
42
44
|
date: null,
|
|
43
45
|
});
|
|
44
|
-
// const [valueSelected, setValueSelected] = useState<DateRangeProps>({
|
|
45
|
-
// startDate: null,
|
|
46
|
-
// endDate: null,
|
|
47
|
-
// date: null,
|
|
48
|
-
// });
|
|
49
46
|
|
|
50
47
|
const handleOnChangeCalendar = useCallback((value: DateRangeProps) => {
|
|
51
|
-
|
|
52
|
-
|
|
48
|
+
setMarkDates({});
|
|
49
|
+
setValueDatepicker(value);
|
|
53
50
|
setErrorValidate(false);
|
|
54
51
|
}, []);
|
|
55
52
|
|
|
56
|
-
// const setDefaultValue = () => {
|
|
57
|
-
// if (mode === 'single' && valueOnChange.date) {
|
|
58
|
-
// setMarkDates({
|
|
59
|
-
// [formatDate(valueOnChange.date)]: { selected: true },
|
|
60
|
-
// });
|
|
61
|
-
// } else if (
|
|
62
|
-
// (mode === 'range' || mode === 'multiple') &&
|
|
63
|
-
// valueOnChange.startDate &&
|
|
64
|
-
// valueOnChange.endDate
|
|
65
|
-
// ) {
|
|
66
|
-
// const start = new Date(valueOnChange.startDate);
|
|
67
|
-
// const end = new Date(valueOnChange.endDate);
|
|
68
|
-
// const marks: Record<string, any> = {};
|
|
69
|
-
// for (let d = new Date(start); d <= end; d.setDate(d.getDate() + 1)) {
|
|
70
|
-
// const key = formatDate(new Date(d));
|
|
71
|
-
// marks[key] = { selected: true };
|
|
72
|
-
// }
|
|
73
|
-
// setMarkDates(marks);
|
|
74
|
-
// }
|
|
75
|
-
// };
|
|
76
|
-
|
|
77
53
|
const handleOnPressSubmitButton = useCallback(() => {
|
|
78
|
-
const { startDate, endDate, date } =
|
|
54
|
+
const { startDate, endDate, date } = valueDatepicker;
|
|
55
|
+
|
|
79
56
|
const isEmpty = !startDate && !endDate && !date;
|
|
57
|
+
|
|
80
58
|
const isRangeMode = mode === 'range';
|
|
59
|
+
|
|
81
60
|
const isInvalidRange = isRangeMode && (!startDate || !endDate);
|
|
82
61
|
|
|
83
62
|
if ((required && isEmpty) || isInvalidRange) {
|
|
@@ -86,11 +65,9 @@ export default function DatePicker({
|
|
|
86
65
|
return;
|
|
87
66
|
}
|
|
88
67
|
|
|
89
|
-
onChange?.(
|
|
68
|
+
onChange?.(valueDatepicker);
|
|
90
69
|
onClose?.();
|
|
91
|
-
|
|
92
|
-
// setValueSelected(valueOnChange);
|
|
93
|
-
}, [required, mode, valueOnChange, onChange, onClose, onHasError]);
|
|
70
|
+
}, [required, mode, valueDatepicker, onChange, onClose, onHasError]);
|
|
94
71
|
|
|
95
72
|
const handleOnPressCancelButton = useCallback(() => {
|
|
96
73
|
onClose?.();
|
|
@@ -100,9 +77,53 @@ export default function DatePicker({
|
|
|
100
77
|
setErrorValidate(hasError);
|
|
101
78
|
}, [hasError]);
|
|
102
79
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
80
|
+
useEffect(() => {
|
|
81
|
+
if (!isOpen) return;
|
|
82
|
+
|
|
83
|
+
let updatedMarkDates: CalendarMarkDatesType = {};
|
|
84
|
+
|
|
85
|
+
if (mode === 'single' && value?.date) {
|
|
86
|
+
updatedMarkDates = {
|
|
87
|
+
[formatDate(value.date) as string]: { selected: true },
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (mode === 'range' && value?.startDate && value?.endDate) {
|
|
92
|
+
const start = new Date(value.startDate);
|
|
93
|
+
const end = new Date(value.endDate);
|
|
94
|
+
const dates: CalendarMarkDatesType = {};
|
|
95
|
+
|
|
96
|
+
for (let dt = new Date(start); dt <= end; dt.setDate(dt.getDate() + 1)) {
|
|
97
|
+
const dateStr = formatDate(dt);
|
|
98
|
+
let backgroundColor = Color.primary[50];
|
|
99
|
+
let textColor = Color.gray[600];
|
|
100
|
+
|
|
101
|
+
if (dateStr === formatDate(start) || dateStr === formatDate(end)) {
|
|
102
|
+
backgroundColor = Color.primary[1000];
|
|
103
|
+
textColor = Color.base.white100;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (dateStr) {
|
|
107
|
+
dates[dateStr] = {
|
|
108
|
+
selected: true,
|
|
109
|
+
backgroundColor: backgroundColor,
|
|
110
|
+
textColor: textColor,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
updatedMarkDates = dates;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
setMarkDates(updatedMarkDates);
|
|
119
|
+
setValueDatepicker(
|
|
120
|
+
value || {
|
|
121
|
+
startDate: null,
|
|
122
|
+
endDate: null,
|
|
123
|
+
date: null,
|
|
124
|
+
}
|
|
125
|
+
);
|
|
126
|
+
}, [isOpen, value, mode]);
|
|
106
127
|
|
|
107
128
|
return (
|
|
108
129
|
<View>
|
|
@@ -130,7 +151,7 @@ export default function DatePicker({
|
|
|
130
151
|
}
|
|
131
152
|
>
|
|
132
153
|
<Calendar
|
|
133
|
-
|
|
154
|
+
markedDates={markDates}
|
|
134
155
|
mode={mode}
|
|
135
156
|
onChange={handleOnChangeCalendar}
|
|
136
157
|
{...calendarProps}
|
|
@@ -25,6 +25,7 @@ Komponen ini extend dari Calendar, jadi kalian bisa menggunakan semua props yang
|
|
|
25
25
|
| `onClose` | `() => void` | Callback saat BottomSheet ditutup |
|
|
26
26
|
| `isOpen` | `boolean` | Menentukan apakah BottomSheet sedang terbuka |
|
|
27
27
|
| `hasError` | `boolean` | (Opsional) Menandai jika terjadi kesalahan validasi |
|
|
28
|
+
| `value` | DateRangeProps | (Opsional) set default value |
|
|
28
29
|
|
|
29
30
|
---
|
|
30
31
|
|
package/src/Icon/Icon.tsx
CHANGED
|
@@ -38,6 +38,7 @@ import ClipBoardList from './icons/ClipBoardList';
|
|
|
38
38
|
import Megaphone from './icons/Megaphone';
|
|
39
39
|
import Bell from './icons/Bell';
|
|
40
40
|
import BookmarkUser from './icons/BookmarkUser';
|
|
41
|
+
import Minus from './icons/Minus';
|
|
41
42
|
|
|
42
43
|
const icons: Record<
|
|
43
44
|
IconNameProps,
|
|
@@ -68,6 +69,7 @@ const icons: Record<
|
|
|
68
69
|
'ArrowDown': ArrowDown,
|
|
69
70
|
'ArrowUp': ArrowUp,
|
|
70
71
|
'Plus': Plus,
|
|
72
|
+
'Minus': Minus,
|
|
71
73
|
'Bell': Bell,
|
|
72
74
|
'file-list-check': FileListCheck,
|
|
73
75
|
'file-text': FileText,
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Svg, { Path } from 'react-native-svg';
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
size?: number;
|
|
6
|
+
color?: string;
|
|
7
|
+
style?: object;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const Minus: React.FC<Props> = ({ size = 24, color = '#000', style }) => (
|
|
11
|
+
<Svg
|
|
12
|
+
width={size}
|
|
13
|
+
height={size + 1}
|
|
14
|
+
viewBox="0 0 10 2"
|
|
15
|
+
fill="none"
|
|
16
|
+
style={style}
|
|
17
|
+
>
|
|
18
|
+
<Path
|
|
19
|
+
d="M9.08301 1.58341H0.916341C0.594341 1.58341 0.333008 1.32208 0.333008 1.00008C0.333008 0.678081 0.594341 0.416748 0.916341 0.416748H9.08301C9.40501 0.416748 9.66634 0.678081 9.66634 1.00008C9.66634 1.32208 9.40501 1.58341 9.08301 1.58341Z"
|
|
20
|
+
fill={color}
|
|
21
|
+
/>
|
|
22
|
+
</Svg>
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
export default Minus;
|
package/src/Icon/type.tsx
CHANGED
|
@@ -28,6 +28,8 @@ Komponen `Select` adalah komponen pemilihan data berbasis bottom sheet dengan du
|
|
|
28
28
|
| `delaySearch`| `number` | `300` | Delay pencarian dalam milidetik |
|
|
29
29
|
| `height` | `BottomSheetHeighProps` | - | Ukuran tinggi BottomSheet |
|
|
30
30
|
| `onRefresh` | `() => void` | - | Callback saat pull-to-refresh dilakukan |
|
|
31
|
+
| `header` | ReactElement| – | Jika ingin chip mempunyai header. |
|
|
32
|
+
| `footer` | ReactElement| – | Jika ingin chip mempunyai footer. |
|
|
31
33
|
|
|
32
34
|
## 📌 Contoh Penggunaan
|
|
33
35
|
|
package/src/Select/type.tsx
CHANGED
|
@@ -28,6 +28,6 @@ export interface SelectProps {
|
|
|
28
28
|
onRefresh?: () => void;
|
|
29
29
|
onEndReached?: () => void;
|
|
30
30
|
refreshing?: boolean;
|
|
31
|
-
footer?: React.
|
|
32
|
-
header?: React.
|
|
31
|
+
footer?: React.ComponentType<any> | React.ReactElement | null | undefined;
|
|
32
|
+
header?: React.ComponentType<any> | React.ReactElement | null | undefined;
|
|
33
33
|
}
|
package/src/index.tsx
CHANGED
|
@@ -42,6 +42,7 @@ export { default as InputOtp } from './Input/InputOtp';
|
|
|
42
42
|
export { default as Switch } from './Input/Switch';
|
|
43
43
|
export { default as CheckBox } from './CheckBox/CheckBox';
|
|
44
44
|
export { default as CheckBoxList } from './CheckBox/CheckBoxList';
|
|
45
|
+
export { default as CounterButton } from './CounterButton/CounterButton';
|
|
45
46
|
export { default as RadioButton } from './RadioButton/RadioButton';
|
|
46
47
|
export { default as Icon } from './Icon/Icon';
|
|
47
48
|
export { default as Modal } from './Modal/Modal';
|