@herca/rn-kit 0.1.48 → 0.1.49
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/lib/module/Input/Input.js +7 -4
- package/lib/module/Input/Input.js.map +1 -1
- package/lib/module/Input/README_INPUT.md +17 -16
- package/lib/module/LabelForm/LabelForm.js +11 -4
- package/lib/module/LabelForm/LabelForm.js.map +1 -1
- package/lib/typescript/src/Input/Input.d.ts +2 -1
- package/lib/typescript/src/Input/Input.d.ts.map +1 -1
- package/lib/typescript/src/Input/type.d.ts +1 -0
- package/lib/typescript/src/Input/type.d.ts.map +1 -1
- package/lib/typescript/src/LabelForm/LabelForm.d.ts +5 -2
- package/lib/typescript/src/LabelForm/LabelForm.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/Input/Input.tsx +98 -90
- package/src/Input/README_INPUT.md +17 -16
- package/src/Input/type.tsx +1 -0
- package/src/LabelForm/LabelForm.tsx +13 -2
|
@@ -7,7 +7,7 @@ import Color from "../Color/Color.js";
|
|
|
7
7
|
import LabelForm from "../LabelForm/LabelForm.js";
|
|
8
8
|
import Typography from "../Typography/Typography.js";
|
|
9
9
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
|
-
const Input = ({
|
|
10
|
+
const Input = /*#__PURE__*/React.forwardRef(({
|
|
11
11
|
icon,
|
|
12
12
|
iconRight,
|
|
13
13
|
label,
|
|
@@ -22,8 +22,9 @@ const Input = ({
|
|
|
22
22
|
secureTextEntry = false,
|
|
23
23
|
iconRightColor,
|
|
24
24
|
prefix,
|
|
25
|
+
required = false,
|
|
25
26
|
...rest
|
|
26
|
-
}) => {
|
|
27
|
+
}, ref) => {
|
|
27
28
|
const [inputValue, setInputValue] = useState(value || '');
|
|
28
29
|
const handleClear = () => {
|
|
29
30
|
setInputValue('');
|
|
@@ -42,7 +43,8 @@ const Input = ({
|
|
|
42
43
|
return /*#__PURE__*/_jsxs(View, {
|
|
43
44
|
style: styles.gap,
|
|
44
45
|
children: [label ? /*#__PURE__*/_jsx(LabelForm, {
|
|
45
|
-
title: label
|
|
46
|
+
title: label,
|
|
47
|
+
required: required
|
|
46
48
|
}) : null, /*#__PURE__*/_jsxs(View, {
|
|
47
49
|
style: [styles.container, {
|
|
48
50
|
borderColor: hasError ? Color.danger[500] : Color.gray[100]
|
|
@@ -60,6 +62,7 @@ const Input = ({
|
|
|
60
62
|
children: prefix
|
|
61
63
|
}), /*#__PURE__*/_jsx(TextInput, {
|
|
62
64
|
...rest,
|
|
65
|
+
ref: ref,
|
|
63
66
|
style: [styles.input, style],
|
|
64
67
|
secureTextEntry: secureTextEntry,
|
|
65
68
|
value: inputValue,
|
|
@@ -92,7 +95,7 @@ const Input = ({
|
|
|
92
95
|
children: hint
|
|
93
96
|
}) : null]
|
|
94
97
|
});
|
|
95
|
-
};
|
|
98
|
+
});
|
|
96
99
|
const styles = StyleSheet.create({
|
|
97
100
|
gap: {
|
|
98
101
|
gap: 4
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useEffect","useState","TextInput","View","StyleSheet","TouchableOpacity","Icon","Color","LabelForm","Typography","jsx","_jsx","jsxs","_jsxs","Input","icon","iconRight","label","style","value","clearButton","hasError","hint","onChangeText","onPressIconLeft","onPressIconRight","secureTextEntry","iconRightColor","prefix","rest","inputValue","setInputValue","handleClear","handleChange","text","showRightIcons","undefined","styles","gap","children","title","container","borderColor","danger","gray","onPress","hitSlop","name","size","color","prefixContainer","input","placeholderTextColor","rightContainer","mr8","variant","weight","create","position","height","borderRadius","paddingHorizontal","borderWidth","backgroundColor","base","white100","justifyContent","flexDirection","alignItems","paddingTop","paddingBottom","fontSize","flex","marginRight"],"sourceRoot":"../../../src","sources":["Input/Input.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAClD,SAASC,SAAS,EAAEC,IAAI,EAAEC,UAAU,EAAEC,gBAAgB,QAAQ,cAAc;AAC5E,SAASC,IAAI,QAAQ,kBAAS;AAC9B,OAAOC,KAAK,MAAM,mBAAgB;AAClC,OAAOC,SAAS,MAAM,2BAAwB;AAC9C,OAAOC,UAAU,MAAM,6BAA0B;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAGlD,MAAMC,
|
|
1
|
+
{"version":3,"names":["React","useEffect","useState","TextInput","View","StyleSheet","TouchableOpacity","Icon","Color","LabelForm","Typography","jsx","_jsx","jsxs","_jsxs","Input","forwardRef","icon","iconRight","label","style","value","clearButton","hasError","hint","onChangeText","onPressIconLeft","onPressIconRight","secureTextEntry","iconRightColor","prefix","required","rest","ref","inputValue","setInputValue","handleClear","handleChange","text","showRightIcons","undefined","styles","gap","children","title","container","borderColor","danger","gray","onPress","hitSlop","name","size","color","prefixContainer","input","placeholderTextColor","rightContainer","mr8","variant","weight","create","position","height","borderRadius","paddingHorizontal","borderWidth","backgroundColor","base","white100","justifyContent","flexDirection","alignItems","paddingTop","paddingBottom","fontSize","flex","marginRight"],"sourceRoot":"../../../src","sources":["Input/Input.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAClD,SAASC,SAAS,EAAEC,IAAI,EAAEC,UAAU,EAAEC,gBAAgB,QAAQ,cAAc;AAC5E,SAASC,IAAI,QAAQ,kBAAS;AAC9B,OAAOC,KAAK,MAAM,mBAAgB;AAClC,OAAOC,SAAS,MAAM,2BAAwB;AAC9C,OAAOC,UAAU,MAAM,6BAA0B;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAGlD,MAAMC,KAAK,gBAAGf,KAAK,CAACgB,UAAU,CAC5B,CACE;EACEC,IAAI;EACJC,SAAS;EACTC,KAAK;EACLC,KAAK;EACLC,KAAK;EACLC,WAAW,GAAG,KAAK;EACnBC,QAAQ,GAAG,KAAK;EAChBC,IAAI;EACJC,YAAY;EACZC,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T2C,KAAK,EAAE9B,QAAQ,GAAGf,KAAK,CAACuC,MAAM,CAAC,GAAG,CAAC,GAAGvC,KAAK,CAACwC,IAAI,CAAC,GAAG,CAAE;MACtDW,OAAO,EAAC,IAAI;MACZC,MAAM,EAAC,QAAQ;MAAAjB,QAAA,EAEdnB;IAAI,CACK,CAAC,GACX,IAAI;EAAA,CACJ,CAAC;AAEX,CACF,CAAC;AAED,MAAMiB,MAAM,GAAGpC,UAAU,CAACwD,MAAM,CAAC;EAC/BnB,GAAG,EAAE;IACHA,GAAG,EAAE;EACP,CAAC;EACDG,SAAS,EAAE;IACTiB,QAAQ,EAAE,UAAU;IACpBC,MAAM,EAAE,EAAE;IACVC,YAAY,EAAE,CAAC;IACftB,GAAG,EAAE,CAAC;IACNuB,iBAAiB,EAAE,EAAE;IACrBC,WAAW,EAAE,CAAC;IACdC,eAAe,EAAE3D,KAAK,CAAC4D,IAAI,CAACC,QAAQ;IACpCC,cAAc,EAAE,QAAQ;IACxBC,aAAa,EAAE,KAAK;IACpBC,UAAU,EAAE;EACd,CAAC;EACDjB,KAAK,EAAE;IACLQ,MAAM,EAAE,EAAE;IACVU,UAAU,EAAE,CAAC;IACbC,aAAa,EAAE,CAAC;IAChBC,QAAQ,EAAE,EAAE;IACZtB,KAAK,EAAE,MAAM;IACbuB,IAAI,EAAE;EACR,CAAC;EACDnB,cAAc,EAAE;IACdc,aAAa,EAAE,KAAK;IACpBC,UAAU,EAAE;EACd,CAAC;EACDlB,eAAe,EAAE;IACfgB,cAAc,EAAE,QAAQ;IACxBC,aAAa,EAAE;EACjB,CAAC;EACDb,GAAG,EAAE;IACHmB,WAAW,EAAE;EACf;AACF,CAAC,CAAC;AAEF,eAAe9D,KAAK","ignoreList":[]}
|
|
@@ -6,22 +6,23 @@ Komponen `Input` ini adalah komponen input teks yang dapat dikustomisasi dengan
|
|
|
6
6
|
|
|
7
7
|
## 🔧 Props
|
|
8
8
|
|
|
9
|
-
| Prop | Tipe | Deskripsi
|
|
10
|
-
| ------------------ | ------------------------- |
|
|
11
|
-
| `label` | `string` | Label yang ditampilkan di atas input
|
|
12
|
-
| `value` | `string` | Nilai dari input (kontrol dari luar)
|
|
13
|
-
| `onChange` | `(value: string) => void` | Fungsi yang dipanggil saat nilai berubah
|
|
14
|
-
| `icon` | `string` | Nama ikon (kiri) dari library `Icon`
|
|
15
|
-
| `iconRight` | `string` | Nama ikon kanan dari library `Icon`
|
|
16
|
-
| `clearButton` | `boolean` | Menampilkan tombol `x` untuk menghapus input
|
|
17
|
-
| `hasError` | `boolean` | Menandai input error, border akan berubah merah
|
|
18
|
-
| `hint` | `string` | Menampilkan teks kecil di bawah input, bisa untuk error atau petunjuk
|
|
19
|
-
| `onPressIconLeft` | `() => void` | Fungsi saat ikon kiri diklik
|
|
20
|
-
| `onPressIconRight` | `() => void` | Fungsi saat ikon kanan diklik
|
|
21
|
-
| `secureTextEntry` | `boolean` | Jika `true`, menyembunyikan input (untuk password)
|
|
22
|
-
| `style` | `ViewStyle` | Style tambahan untuk input
|
|
23
|
-
| `prefix` | `React.ReactNode` | Slot `react node` yang bisa diisi oleh seluruh komponen react
|
|
24
|
-
|
|
|
9
|
+
| Prop | Tipe | Deskripsi |
|
|
10
|
+
| ------------------ | ------------------------- | ---------------------------------------------------------------------- |
|
|
11
|
+
| `label` | `string` | Label yang ditampilkan di atas input |
|
|
12
|
+
| `value` | `string` | Nilai dari input (kontrol dari luar) |
|
|
13
|
+
| `onChange` | `(value: string) => void` | Fungsi yang dipanggil saat nilai berubah |
|
|
14
|
+
| `icon` | `string` | Nama ikon (kiri) dari library `Icon` |
|
|
15
|
+
| `iconRight` | `string` | Nama ikon kanan dari library `Icon` |
|
|
16
|
+
| `clearButton` | `boolean` | Menampilkan tombol `x` untuk menghapus input |
|
|
17
|
+
| `hasError` | `boolean` | Menandai input error, border akan berubah merah |
|
|
18
|
+
| `hint` | `string` | Menampilkan teks kecil di bawah input, bisa untuk error atau petunjuk |
|
|
19
|
+
| `onPressIconLeft` | `() => void` | Fungsi saat ikon kiri diklik |
|
|
20
|
+
| `onPressIconRight` | `() => void` | Fungsi saat ikon kanan diklik |
|
|
21
|
+
| `secureTextEntry` | `boolean` | Jika `true`, menyembunyikan input (untuk password) |
|
|
22
|
+
| `style` | `ViewStyle` | Style tambahan untuk input |
|
|
23
|
+
| `prefix` | `React.ReactNode` | Slot `react node` yang bisa diisi oleh seluruh komponen react |
|
|
24
|
+
| `required` | `boolean` | Jika `true` maka akan menampilkan bintang berwarna merah setelah label |
|
|
25
|
+
| `...rest` | `TextInputProps` | Props lain dari React Native `TextInput` |
|
|
25
26
|
|
|
26
27
|
---
|
|
27
28
|
|
|
@@ -2,15 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
import { View } from 'react-native';
|
|
4
4
|
import Typography from "../Typography/Typography.js";
|
|
5
|
-
import
|
|
5
|
+
import Color from "../Color/Color.js";
|
|
6
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
7
|
export default function LabelForm({
|
|
7
|
-
title
|
|
8
|
+
title,
|
|
9
|
+
required
|
|
8
10
|
}) {
|
|
9
11
|
return /*#__PURE__*/_jsx(View, {
|
|
10
|
-
children: /*#__PURE__*/
|
|
12
|
+
children: /*#__PURE__*/_jsxs(Typography, {
|
|
11
13
|
variant: "t2",
|
|
12
14
|
weight: "semibold",
|
|
13
|
-
children: title
|
|
15
|
+
children: [title, ' ', required && /*#__PURE__*/_jsx(Typography, {
|
|
16
|
+
variant: "t2",
|
|
17
|
+
weight: "semibold",
|
|
18
|
+
color: Color.danger[500],
|
|
19
|
+
children: "*"
|
|
20
|
+
})]
|
|
14
21
|
})
|
|
15
22
|
});
|
|
16
23
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["View","Typography","jsx","_jsx","LabelForm","title","children","variant","weight"],"sourceRoot":"../../../src","sources":["LabelForm/LabelForm.tsx"],"mappings":";;AAAA,SAASA,IAAI,QAAQ,cAAc;AACnC,OAAOC,UAAU,MAAM,6BAA0B;AAAC,SAAAC,GAAA,IAAAC,IAAA;
|
|
1
|
+
{"version":3,"names":["View","Typography","Color","jsx","_jsx","jsxs","_jsxs","LabelForm","title","required","children","variant","weight","color","danger"],"sourceRoot":"../../../src","sources":["LabelForm/LabelForm.tsx"],"mappings":";;AAAA,SAASA,IAAI,QAAQ,cAAc;AACnC,OAAOC,UAAU,MAAM,6BAA0B;AACjD,OAAOC,KAAK,MAAM,mBAAgB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAOnC,eAAe,SAASC,SAASA,CAAC;EAAEC,KAAK;EAAEC;AAAgB,CAAC,EAAE;EAC5D,oBACEL,IAAA,CAACJ,IAAI;IAAAU,QAAA,eACHJ,KAAA,CAACL,UAAU;MAACU,OAAO,EAAC,IAAI;MAACC,MAAM,EAAC,UAAU;MAAAF,QAAA,GACvCF,KAAK,EAAE,GAAG,EACVC,QAAQ,iBACPL,IAAA,CAACH,UAAU;QAACU,OAAO,EAAC,IAAI;QAACC,MAAM,EAAC,UAAU;QAACC,KAAK,EAAEX,KAAK,CAACY,MAAM,CAAC,GAAG,CAAE;QAAAJ,QAAA,EAAC;MAErE,CAAY,CACb;IAAA,CACS;EAAC,CACT,CAAC;AAEX","ignoreList":[]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { TextInput } from 'react-native';
|
|
2
3
|
import type { InputProps } from './type';
|
|
3
|
-
declare const Input: React.
|
|
4
|
+
declare const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<TextInput>>;
|
|
4
5
|
export default Input;
|
|
5
6
|
//# sourceMappingURL=Input.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.d.ts","sourceRoot":"","sources":["../../../../src/Input/Input.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Input.d.ts","sourceRoot":"","sources":["../../../../src/Input/Input.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AACnD,OAAO,EAAE,SAAS,EAAsC,MAAM,cAAc,CAAC;AAK7E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEzC,QAAA,MAAM,KAAK,8EA0GV,CAAC;AAuCF,eAAe,KAAK,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../../../src/Input/type.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC1E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,MAAM,WAAW,UAAW,SAAQ,cAAc;IAChD,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,eAAe,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,qBAAqB,KAAK,IAAI,CAAC;IACxD,gBAAgB,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,qBAAqB,KAAK,IAAI,CAAC;IACzD,YAAY,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../../../src/Input/type.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC1E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,MAAM,WAAW,UAAW,SAAQ,cAAc;IAChD,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,eAAe,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,qBAAqB,KAAK,IAAI,CAAC;IACxD,gBAAgB,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,qBAAqB,KAAK,IAAI,CAAC;IACzD,YAAY,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,aAAc,SAAQ,UAAU;IAC/C,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
interface Props {
|
|
2
2
|
title: string;
|
|
3
|
-
|
|
3
|
+
required?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export default function LabelForm({ title, required }: Props): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export {};
|
|
4
7
|
//# sourceMappingURL=LabelForm.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LabelForm.d.ts","sourceRoot":"","sources":["../../../../src/LabelForm/LabelForm.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"LabelForm.d.ts","sourceRoot":"","sources":["../../../../src/LabelForm/LabelForm.tsx"],"names":[],"mappings":"AAIA,UAAU,KAAK;IACb,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,KAAK,2CAa3D"}
|
package/package.json
CHANGED
package/src/Input/Input.tsx
CHANGED
|
@@ -6,105 +6,113 @@ import LabelForm from '../LabelForm/LabelForm';
|
|
|
6
6
|
import Typography from '../Typography/Typography';
|
|
7
7
|
import type { InputProps } from './type';
|
|
8
8
|
|
|
9
|
-
const Input
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
9
|
+
const Input = React.forwardRef<TextInput, InputProps>(
|
|
10
|
+
(
|
|
11
|
+
{
|
|
12
|
+
icon,
|
|
13
|
+
iconRight,
|
|
14
|
+
label,
|
|
15
|
+
style,
|
|
16
|
+
value,
|
|
17
|
+
clearButton = false,
|
|
18
|
+
hasError = false,
|
|
19
|
+
hint,
|
|
20
|
+
onChangeText,
|
|
21
|
+
onPressIconLeft,
|
|
22
|
+
onPressIconRight,
|
|
23
|
+
secureTextEntry = false,
|
|
24
|
+
iconRightColor,
|
|
25
|
+
prefix,
|
|
26
|
+
required = false,
|
|
27
|
+
...rest
|
|
28
|
+
},
|
|
29
|
+
ref
|
|
30
|
+
) => {
|
|
31
|
+
const [inputValue, setInputValue] = useState(value || '');
|
|
27
32
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
33
|
+
const handleClear = () => {
|
|
34
|
+
setInputValue('');
|
|
35
|
+
onChangeText?.('');
|
|
36
|
+
};
|
|
32
37
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
38
|
+
const handleChange = (text: string) => {
|
|
39
|
+
setInputValue(text);
|
|
40
|
+
onChangeText?.(text);
|
|
41
|
+
};
|
|
37
42
|
|
|
38
|
-
|
|
43
|
+
const showRightIcons = (clearButton && inputValue !== '') || iconRight;
|
|
39
44
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
return (
|
|
46
|
-
<View style={styles.gap}>
|
|
47
|
-
{label ? <LabelForm title={label} /> : null}
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
if (value !== undefined) {
|
|
47
|
+
setInputValue(value);
|
|
48
|
+
}
|
|
49
|
+
}, [value]);
|
|
48
50
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
{
|
|
53
|
-
borderColor: hasError ? Color.danger[500] : Color.gray[100],
|
|
54
|
-
},
|
|
55
|
-
]}
|
|
56
|
-
>
|
|
57
|
-
{icon && (
|
|
58
|
-
<TouchableOpacity onPress={onPressIconLeft} hitSlop={10}>
|
|
59
|
-
<Icon name={icon} size={20} color="#888" />
|
|
60
|
-
</TouchableOpacity>
|
|
61
|
-
)}
|
|
51
|
+
return (
|
|
52
|
+
<View style={styles.gap}>
|
|
53
|
+
{label ? <LabelForm title={label} required={required} /> : null}
|
|
62
54
|
|
|
63
|
-
|
|
55
|
+
<View
|
|
56
|
+
style={[
|
|
57
|
+
styles.container,
|
|
58
|
+
{
|
|
59
|
+
borderColor: hasError ? Color.danger[500] : Color.gray[100],
|
|
60
|
+
},
|
|
61
|
+
]}
|
|
62
|
+
>
|
|
63
|
+
{icon && (
|
|
64
|
+
<TouchableOpacity onPress={onPressIconLeft} hitSlop={10}>
|
|
65
|
+
<Icon name={icon} size={20} color="#888" />
|
|
66
|
+
</TouchableOpacity>
|
|
67
|
+
)}
|
|
68
|
+
|
|
69
|
+
{prefix && <View style={styles.prefixContainer}>{prefix}</View>}
|
|
64
70
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
<TextInput
|
|
72
|
+
{...rest}
|
|
73
|
+
ref={ref}
|
|
74
|
+
style={[styles.input, style]}
|
|
75
|
+
secureTextEntry={secureTextEntry}
|
|
76
|
+
value={inputValue}
|
|
77
|
+
onChangeText={handleChange}
|
|
78
|
+
placeholderTextColor={Color.gray[400]}
|
|
79
|
+
/>
|
|
73
80
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
81
|
+
{showRightIcons && (
|
|
82
|
+
<View style={styles.rightContainer}>
|
|
83
|
+
{clearButton && inputValue !== '' && (
|
|
84
|
+
<TouchableOpacity
|
|
85
|
+
onPress={handleClear}
|
|
86
|
+
style={iconRight && styles.mr8}
|
|
87
|
+
>
|
|
88
|
+
<Icon name="x-circle" size={20} color="#aaa" />
|
|
89
|
+
</TouchableOpacity>
|
|
90
|
+
)}
|
|
91
|
+
{iconRight && (
|
|
92
|
+
<TouchableOpacity onPress={onPressIconRight} hitSlop={10}>
|
|
93
|
+
<Icon
|
|
94
|
+
name={iconRight}
|
|
95
|
+
size={20}
|
|
96
|
+
color={iconRightColor ?? '#888'}
|
|
97
|
+
/>
|
|
98
|
+
</TouchableOpacity>
|
|
99
|
+
)}
|
|
100
|
+
</View>
|
|
101
|
+
)}
|
|
102
|
+
</View>
|
|
103
|
+
{hint ? (
|
|
104
|
+
<Typography
|
|
105
|
+
color={hasError ? Color.danger[500] : Color.gray[700]}
|
|
106
|
+
variant="t3"
|
|
107
|
+
weight="medium"
|
|
108
|
+
>
|
|
109
|
+
{hint}
|
|
110
|
+
</Typography>
|
|
111
|
+
) : null}
|
|
95
112
|
</View>
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
variant="t3"
|
|
100
|
-
weight="medium"
|
|
101
|
-
>
|
|
102
|
-
{hint}
|
|
103
|
-
</Typography>
|
|
104
|
-
) : null}
|
|
105
|
-
</View>
|
|
106
|
-
);
|
|
107
|
-
};
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
);
|
|
108
116
|
|
|
109
117
|
const styles = StyleSheet.create({
|
|
110
118
|
gap: {
|
|
@@ -6,22 +6,23 @@ Komponen `Input` ini adalah komponen input teks yang dapat dikustomisasi dengan
|
|
|
6
6
|
|
|
7
7
|
## 🔧 Props
|
|
8
8
|
|
|
9
|
-
| Prop | Tipe | Deskripsi
|
|
10
|
-
| ------------------ | ------------------------- |
|
|
11
|
-
| `label` | `string` | Label yang ditampilkan di atas input
|
|
12
|
-
| `value` | `string` | Nilai dari input (kontrol dari luar)
|
|
13
|
-
| `onChange` | `(value: string) => void` | Fungsi yang dipanggil saat nilai berubah
|
|
14
|
-
| `icon` | `string` | Nama ikon (kiri) dari library `Icon`
|
|
15
|
-
| `iconRight` | `string` | Nama ikon kanan dari library `Icon`
|
|
16
|
-
| `clearButton` | `boolean` | Menampilkan tombol `x` untuk menghapus input
|
|
17
|
-
| `hasError` | `boolean` | Menandai input error, border akan berubah merah
|
|
18
|
-
| `hint` | `string` | Menampilkan teks kecil di bawah input, bisa untuk error atau petunjuk
|
|
19
|
-
| `onPressIconLeft` | `() => void` | Fungsi saat ikon kiri diklik
|
|
20
|
-
| `onPressIconRight` | `() => void` | Fungsi saat ikon kanan diklik
|
|
21
|
-
| `secureTextEntry` | `boolean` | Jika `true`, menyembunyikan input (untuk password)
|
|
22
|
-
| `style` | `ViewStyle` | Style tambahan untuk input
|
|
23
|
-
| `prefix` | `React.ReactNode` | Slot `react node` yang bisa diisi oleh seluruh komponen react
|
|
24
|
-
|
|
|
9
|
+
| Prop | Tipe | Deskripsi |
|
|
10
|
+
| ------------------ | ------------------------- | ---------------------------------------------------------------------- |
|
|
11
|
+
| `label` | `string` | Label yang ditampilkan di atas input |
|
|
12
|
+
| `value` | `string` | Nilai dari input (kontrol dari luar) |
|
|
13
|
+
| `onChange` | `(value: string) => void` | Fungsi yang dipanggil saat nilai berubah |
|
|
14
|
+
| `icon` | `string` | Nama ikon (kiri) dari library `Icon` |
|
|
15
|
+
| `iconRight` | `string` | Nama ikon kanan dari library `Icon` |
|
|
16
|
+
| `clearButton` | `boolean` | Menampilkan tombol `x` untuk menghapus input |
|
|
17
|
+
| `hasError` | `boolean` | Menandai input error, border akan berubah merah |
|
|
18
|
+
| `hint` | `string` | Menampilkan teks kecil di bawah input, bisa untuk error atau petunjuk |
|
|
19
|
+
| `onPressIconLeft` | `() => void` | Fungsi saat ikon kiri diklik |
|
|
20
|
+
| `onPressIconRight` | `() => void` | Fungsi saat ikon kanan diklik |
|
|
21
|
+
| `secureTextEntry` | `boolean` | Jika `true`, menyembunyikan input (untuk password) |
|
|
22
|
+
| `style` | `ViewStyle` | Style tambahan untuk input |
|
|
23
|
+
| `prefix` | `React.ReactNode` | Slot `react node` yang bisa diisi oleh seluruh komponen react |
|
|
24
|
+
| `required` | `boolean` | Jika `true` maka akan menampilkan bintang berwarna merah setelah label |
|
|
25
|
+
| `...rest` | `TextInputProps` | Props lain dari React Native `TextInput` |
|
|
25
26
|
|
|
26
27
|
---
|
|
27
28
|
|
package/src/Input/type.tsx
CHANGED
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
import { View } from 'react-native';
|
|
2
2
|
import Typography from '../Typography/Typography';
|
|
3
|
+
import Color from '../Color/Color';
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
interface Props {
|
|
6
|
+
title: string;
|
|
7
|
+
required?: boolean;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export default function LabelForm({ title, required }: Props) {
|
|
5
11
|
return (
|
|
6
12
|
<View>
|
|
7
13
|
<Typography variant="t2" weight="semibold">
|
|
8
|
-
{title}
|
|
14
|
+
{title}{' '}
|
|
15
|
+
{required && (
|
|
16
|
+
<Typography variant="t2" weight="semibold" color={Color.danger[500]}>
|
|
17
|
+
*
|
|
18
|
+
</Typography>
|
|
19
|
+
)}
|
|
9
20
|
</Typography>
|
|
10
21
|
</View>
|
|
11
22
|
);
|