@herca/rn-kit 0.1.59 → 0.1.61
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 +6 -4
- package/lib/module/BottomSheet/BottomSheet.js.map +1 -1
- package/lib/module/Input/InputSelect.js +125 -4
- package/lib/module/Input/InputSelect.js.map +1 -1
- package/lib/module/Input/README_INPUT_SELECT.md +392 -0
- package/lib/module/Modal/Modal.js +5 -5
- package/lib/module/Modal/Modal.js.map +1 -1
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/styles/border.js +42 -0
- package/lib/module/styles/border.js.map +1 -0
- package/lib/module/styles/layouting.js +71 -0
- package/lib/module/styles/layouting.js.map +1 -0
- package/lib/module/styles/sizing.js +22 -0
- package/lib/module/styles/sizing.js.map +1 -0
- package/lib/module/styles/spacing.js +166 -0
- package/lib/module/styles/spacing.js.map +1 -0
- package/lib/module/styles/theme.js +47 -0
- package/lib/module/styles/theme.js.map +1 -0
- package/lib/typescript/src/BottomSheet/BottomSheet.d.ts.map +1 -1
- package/lib/typescript/src/Input/InputSelect.d.ts +27 -1
- package/lib/typescript/src/Input/InputSelect.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +2 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/styles/border.d.ts +38 -0
- package/lib/typescript/src/styles/border.d.ts.map +1 -0
- package/lib/typescript/src/styles/layouting.d.ts +68 -0
- package/lib/typescript/src/styles/layouting.d.ts.map +1 -0
- package/lib/typescript/src/styles/sizing.d.ts +19 -0
- package/lib/typescript/src/styles/sizing.d.ts.map +1 -0
- package/lib/typescript/src/styles/spacing.d.ts +160 -0
- package/lib/typescript/src/styles/spacing.d.ts.map +1 -0
- package/lib/typescript/src/styles/theme.d.ts +43 -0
- package/lib/typescript/src/styles/theme.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/BottomSheet/BottomSheet.tsx +6 -4
- package/src/Input/InputSelect.tsx +183 -3
- package/src/Input/README_INPUT_SELECT.md +392 -0
- package/src/Modal/Modal.tsx +5 -5
- package/src/index.tsx +2 -0
- package/src/styles/border.ts +29 -0
- package/src/styles/layouting.ts +37 -0
- package/src/styles/sizing.ts +12 -0
- package/src/styles/spacing.ts +76 -0
- package/src/styles/theme.ts +46 -0
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
export declare const spacing: {
|
|
2
|
+
p: {
|
|
3
|
+
0: {
|
|
4
|
+
padding: number;
|
|
5
|
+
};
|
|
6
|
+
8: {
|
|
7
|
+
padding: number;
|
|
8
|
+
};
|
|
9
|
+
12: {
|
|
10
|
+
padding: number;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
px: {
|
|
14
|
+
0: {
|
|
15
|
+
paddingHorizontal: number;
|
|
16
|
+
};
|
|
17
|
+
4: {
|
|
18
|
+
paddingHorizontal: number;
|
|
19
|
+
};
|
|
20
|
+
8: {
|
|
21
|
+
paddingHorizontal: number;
|
|
22
|
+
};
|
|
23
|
+
12: {
|
|
24
|
+
paddingHorizontal: number;
|
|
25
|
+
};
|
|
26
|
+
24: {
|
|
27
|
+
paddingHorizontal: number;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
py: {
|
|
31
|
+
0: {
|
|
32
|
+
paddingVertical: number;
|
|
33
|
+
};
|
|
34
|
+
4: {
|
|
35
|
+
paddingVertical: number;
|
|
36
|
+
};
|
|
37
|
+
8: {
|
|
38
|
+
paddingVertical: number;
|
|
39
|
+
};
|
|
40
|
+
10: {
|
|
41
|
+
paddingVertical: number;
|
|
42
|
+
};
|
|
43
|
+
12: {
|
|
44
|
+
paddingVertical: number;
|
|
45
|
+
};
|
|
46
|
+
36: {
|
|
47
|
+
paddingVertical: number;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
pt: {
|
|
51
|
+
10: {
|
|
52
|
+
paddingTop: number;
|
|
53
|
+
};
|
|
54
|
+
12: {
|
|
55
|
+
paddingTop: number;
|
|
56
|
+
};
|
|
57
|
+
14: {
|
|
58
|
+
paddingTop: number;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
pb: {
|
|
62
|
+
0: {
|
|
63
|
+
paddingBottom: number;
|
|
64
|
+
};
|
|
65
|
+
8: {
|
|
66
|
+
paddingBottom: number;
|
|
67
|
+
};
|
|
68
|
+
12: {
|
|
69
|
+
paddingBottom: number;
|
|
70
|
+
};
|
|
71
|
+
14: {
|
|
72
|
+
paddingBottom: number;
|
|
73
|
+
};
|
|
74
|
+
24: {
|
|
75
|
+
paddingBottom: number;
|
|
76
|
+
};
|
|
77
|
+
32: {
|
|
78
|
+
paddingBottom: number;
|
|
79
|
+
};
|
|
80
|
+
46: {
|
|
81
|
+
paddingBottom: number;
|
|
82
|
+
};
|
|
83
|
+
215: {
|
|
84
|
+
paddingBottom: number;
|
|
85
|
+
};
|
|
86
|
+
262: {
|
|
87
|
+
paddingBottom: number;
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
pr: {
|
|
91
|
+
25: {
|
|
92
|
+
paddingRight: number;
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
mt: {
|
|
96
|
+
12: {
|
|
97
|
+
marginTop: number;
|
|
98
|
+
};
|
|
99
|
+
4: {
|
|
100
|
+
marginTop: number;
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
mb: {
|
|
104
|
+
10: {
|
|
105
|
+
marginBottom: number;
|
|
106
|
+
};
|
|
107
|
+
12: {
|
|
108
|
+
marginBottom: number;
|
|
109
|
+
};
|
|
110
|
+
20: {
|
|
111
|
+
marginBottom: number;
|
|
112
|
+
};
|
|
113
|
+
8: {
|
|
114
|
+
marginBottom: number;
|
|
115
|
+
};
|
|
116
|
+
4: {
|
|
117
|
+
marginBottom: number;
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
mr: {
|
|
121
|
+
8: {
|
|
122
|
+
marginRight: number;
|
|
123
|
+
};
|
|
124
|
+
16: {
|
|
125
|
+
marginRight: number;
|
|
126
|
+
};
|
|
127
|
+
22: {
|
|
128
|
+
marginRight: number;
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
my: {
|
|
132
|
+
12: {
|
|
133
|
+
marginVertical: number;
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
gap: {
|
|
137
|
+
16: {
|
|
138
|
+
gap: number;
|
|
139
|
+
};
|
|
140
|
+
12: {
|
|
141
|
+
gap: number;
|
|
142
|
+
};
|
|
143
|
+
10: {
|
|
144
|
+
gap: number;
|
|
145
|
+
};
|
|
146
|
+
8: {
|
|
147
|
+
gap: number;
|
|
148
|
+
};
|
|
149
|
+
6: {
|
|
150
|
+
gap: number;
|
|
151
|
+
};
|
|
152
|
+
4: {
|
|
153
|
+
gap: number;
|
|
154
|
+
};
|
|
155
|
+
2: {
|
|
156
|
+
gap: number;
|
|
157
|
+
};
|
|
158
|
+
};
|
|
159
|
+
};
|
|
160
|
+
//# sourceMappingURL=spacing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spacing.d.ts","sourceRoot":"","sources":["../../../../src/styles/spacing.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyEnB,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export declare const theme: {
|
|
2
|
+
chipFiltering: {
|
|
3
|
+
chipsSelectWrapper: {
|
|
4
|
+
flex: number;
|
|
5
|
+
};
|
|
6
|
+
chipFilterContainer: {
|
|
7
|
+
paddingLeft: number;
|
|
8
|
+
gap: number;
|
|
9
|
+
};
|
|
10
|
+
chipsWrapper: {
|
|
11
|
+
flexDirection: "row";
|
|
12
|
+
alignItems: "center";
|
|
13
|
+
};
|
|
14
|
+
chipFilterSelectWrapper: {
|
|
15
|
+
borderRightWidth: number;
|
|
16
|
+
paddingRight: number;
|
|
17
|
+
borderColor: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
loadData: {
|
|
21
|
+
loadMoreLoadingWrapper: {
|
|
22
|
+
alignItems: "center";
|
|
23
|
+
paddingVertical: number;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
ticketCard: {
|
|
27
|
+
ticketInfoWraper: {
|
|
28
|
+
flexDirection: "row";
|
|
29
|
+
alignItems: "center";
|
|
30
|
+
justifyContent: "space-between";
|
|
31
|
+
};
|
|
32
|
+
ticketFooter: {
|
|
33
|
+
marginTop: number;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
btn: {
|
|
37
|
+
iconBtn: {
|
|
38
|
+
padding: number;
|
|
39
|
+
borderRadius: number;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=theme.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../../src/styles/theme.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0CjB,CAAC"}
|
package/package.json
CHANGED
|
@@ -74,8 +74,10 @@ export default function BottomSheet({
|
|
|
74
74
|
duration: 300,
|
|
75
75
|
useNativeDriver: false,
|
|
76
76
|
}).start(() => {
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
requestAnimationFrame(() => {
|
|
78
|
+
setIsVisible(false);
|
|
79
|
+
onClose?.(false);
|
|
80
|
+
});
|
|
79
81
|
});
|
|
80
82
|
}
|
|
81
83
|
}, [closable, translateY, onClose]);
|
|
@@ -193,8 +195,8 @@ export default function BottomSheet({
|
|
|
193
195
|
{footer && (
|
|
194
196
|
<SafeAreaView
|
|
195
197
|
onLayout={(event) => {
|
|
196
|
-
const { height } = event.nativeEvent.layout;
|
|
197
|
-
setHeightFooter(
|
|
198
|
+
const { height: layoutHeight } = event.nativeEvent.layout;
|
|
199
|
+
setHeightFooter(layoutHeight);
|
|
198
200
|
}}
|
|
199
201
|
style={styles.footer}
|
|
200
202
|
>
|
|
@@ -1,5 +1,185 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
Badge,
|
|
3
|
+
Color,
|
|
4
|
+
Icon,
|
|
5
|
+
Select,
|
|
6
|
+
Typography,
|
|
7
|
+
type ChipOptionProps,
|
|
8
|
+
type IconNameProps,
|
|
9
|
+
} from '@herca/rn-kit';
|
|
10
|
+
import { useState, useEffect } from 'react';
|
|
11
|
+
import { Pressable, StyleSheet, TouchableOpacity, View } from 'react-native';
|
|
12
|
+
import { spacing } from '../styles/spacing';
|
|
13
|
+
import { border } from '../styles/border';
|
|
14
|
+
import { layouting } from '../styles/layouting';
|
|
15
|
+
import type { Variant } from '../Badge/type';
|
|
2
16
|
|
|
3
|
-
|
|
4
|
-
|
|
17
|
+
type SelectProps = React.ComponentProps<typeof Select>;
|
|
18
|
+
type SelectPropsWithoutData = Omit<SelectProps, 'data'>;
|
|
19
|
+
|
|
20
|
+
interface Props extends React.ComponentProps<typeof Pressable> {
|
|
21
|
+
label: string;
|
|
22
|
+
placeholder?: string;
|
|
23
|
+
options?: ChipOptionProps[];
|
|
24
|
+
selectProps?: SelectPropsWithoutData;
|
|
25
|
+
value?: string;
|
|
26
|
+
onSelectClick?: () => void;
|
|
27
|
+
onSelectClose?: () => void;
|
|
28
|
+
icon?: IconNameProps;
|
|
29
|
+
iconColor?: string;
|
|
30
|
+
hasError?: boolean;
|
|
31
|
+
hint?: string;
|
|
32
|
+
onClear?: () => void;
|
|
33
|
+
subtitle?: string;
|
|
34
|
+
badge?: {
|
|
35
|
+
value: string;
|
|
36
|
+
color: Variant;
|
|
37
|
+
};
|
|
38
|
+
useModal?: boolean;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export default function InputSelect({
|
|
42
|
+
label,
|
|
43
|
+
placeholder = 'Select here...',
|
|
44
|
+
selectProps,
|
|
45
|
+
options,
|
|
46
|
+
value,
|
|
47
|
+
onSelectClick,
|
|
48
|
+
onSelectClose,
|
|
49
|
+
icon,
|
|
50
|
+
iconColor,
|
|
51
|
+
hint,
|
|
52
|
+
hasError,
|
|
53
|
+
onClear,
|
|
54
|
+
subtitle,
|
|
55
|
+
badge,
|
|
56
|
+
useModal = true,
|
|
57
|
+
...props
|
|
58
|
+
}: Props) {
|
|
59
|
+
const [isSelectOpen, setSelectOpen] = useState<boolean>(false);
|
|
60
|
+
const [internalValue, setInternalValue] = useState(value);
|
|
61
|
+
|
|
62
|
+
function handleOpenSelect() {
|
|
63
|
+
useModal && setSelectOpen(true);
|
|
64
|
+
onSelectClick?.();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function handleCloseSelect() {
|
|
68
|
+
setSelectOpen(false);
|
|
69
|
+
onSelectClose?.();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function handleClear() {
|
|
73
|
+
setInternalValue('');
|
|
74
|
+
onClear?.();
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
useEffect(() => {
|
|
78
|
+
setInternalValue(value);
|
|
79
|
+
}, [value]);
|
|
80
|
+
|
|
81
|
+
return (
|
|
82
|
+
<View style={spacing.gap[4]}>
|
|
83
|
+
<Typography variant="t2" weight="semibold" color={Color.gray[900]}>
|
|
84
|
+
{label}
|
|
85
|
+
</Typography>
|
|
86
|
+
|
|
87
|
+
<View style={[spacing.gap[4], layouting.flex.grow]}>
|
|
88
|
+
<Pressable
|
|
89
|
+
style={[
|
|
90
|
+
styles.select,
|
|
91
|
+
hasError && border.color.danger[300],
|
|
92
|
+
internalValue !== '' && !hasError && border.color.primary[300],
|
|
93
|
+
]}
|
|
94
|
+
onPress={handleOpenSelect}
|
|
95
|
+
{...props}
|
|
96
|
+
>
|
|
97
|
+
{/* left icon, value and placeholder */}
|
|
98
|
+
<View
|
|
99
|
+
style={[
|
|
100
|
+
layouting.flex.rowCenter,
|
|
101
|
+
spacing.gap[12],
|
|
102
|
+
layouting.flex.shrink,
|
|
103
|
+
layouting.flex[1],
|
|
104
|
+
]}
|
|
105
|
+
>
|
|
106
|
+
{icon && <Icon name={icon} size={20} color={iconColor} />}
|
|
107
|
+
<View>
|
|
108
|
+
<View style={[layouting.flex.rowCenter, spacing.gap[4]]}>
|
|
109
|
+
<Typography
|
|
110
|
+
variant="t2"
|
|
111
|
+
color={Color.gray[900]}
|
|
112
|
+
weight="medium"
|
|
113
|
+
numberOfLines={1}
|
|
114
|
+
>
|
|
115
|
+
{!internalValue ? placeholder : internalValue}
|
|
116
|
+
</Typography>
|
|
117
|
+
{badge ? (
|
|
118
|
+
<Badge value={badge.value} size="small" color={badge.color} />
|
|
119
|
+
) : null}
|
|
120
|
+
</View>
|
|
121
|
+
|
|
122
|
+
{subtitle && (
|
|
123
|
+
<Typography
|
|
124
|
+
variant="t3"
|
|
125
|
+
color={Color.gray[700]}
|
|
126
|
+
weight="medium"
|
|
127
|
+
numberOfLines={1}
|
|
128
|
+
>
|
|
129
|
+
{subtitle}
|
|
130
|
+
</Typography>
|
|
131
|
+
)}
|
|
132
|
+
</View>
|
|
133
|
+
</View>
|
|
134
|
+
|
|
135
|
+
{/* right icon and action */}
|
|
136
|
+
<View style={[layouting.flex.rowCenter, spacing.gap[8]]}>
|
|
137
|
+
{onClear && internalValue && (
|
|
138
|
+
<TouchableOpacity activeOpacity={0.7} onPress={handleClear}>
|
|
139
|
+
<Icon name="x-circle" size={20} color="#aaa" />
|
|
140
|
+
</TouchableOpacity>
|
|
141
|
+
)}
|
|
142
|
+
<Icon
|
|
143
|
+
name={useModal ? 'ArrowDown' : 'ArrowRight'}
|
|
144
|
+
size={useModal ? 14 : 12}
|
|
145
|
+
color={Color.gray[700]}
|
|
146
|
+
/>
|
|
147
|
+
</View>
|
|
148
|
+
</Pressable>
|
|
149
|
+
|
|
150
|
+
{hint && (
|
|
151
|
+
<Typography
|
|
152
|
+
variant="t3"
|
|
153
|
+
color={hasError ? Color.danger[500] : Color.gray[700]}
|
|
154
|
+
weight="medium"
|
|
155
|
+
numberOfLines={1}
|
|
156
|
+
>
|
|
157
|
+
{hint}
|
|
158
|
+
</Typography>
|
|
159
|
+
)}
|
|
160
|
+
</View>
|
|
161
|
+
|
|
162
|
+
{useModal && (
|
|
163
|
+
<Select
|
|
164
|
+
isOpen={isSelectOpen}
|
|
165
|
+
{...selectProps}
|
|
166
|
+
data={options ?? []}
|
|
167
|
+
onClose={handleCloseSelect}
|
|
168
|
+
/>
|
|
169
|
+
)}
|
|
170
|
+
</View>
|
|
171
|
+
);
|
|
5
172
|
}
|
|
173
|
+
|
|
174
|
+
const styles = StyleSheet.create({
|
|
175
|
+
select: {
|
|
176
|
+
paddingVertical: 10,
|
|
177
|
+
paddingHorizontal: 12,
|
|
178
|
+
borderRadius: 8,
|
|
179
|
+
flexDirection: 'row',
|
|
180
|
+
alignItems: 'center',
|
|
181
|
+
borderWidth: 1,
|
|
182
|
+
borderColor: Color.gray[200],
|
|
183
|
+
gap: 8,
|
|
184
|
+
},
|
|
185
|
+
});
|