@rn-components-dropdown/dropdown 1.0.27 → 1.0.29
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/dist/components/dropdown/Dropdown.js +113 -148
- package/dist/components/dropdown/DropdownStyle.d.ts +11 -11
- package/dist/components/dropdown/DropdownStyle.js +20 -24
- package/dist/components/dropdown/component/chip/Chip.js +14 -19
- package/dist/components/dropdown/component/chip/ChipStyle.d.ts +8 -18
- package/dist/components/dropdown/component/chip/ChipStyle.js +8 -10
- package/dist/components/dropdown/component/input/TextInput.js +12 -50
- package/dist/components/dropdown/component/input/TextInputStyle.d.ts +4 -4
- package/dist/components/dropdown/component/input/TextInputStyle.js +7 -11
- package/dist/components/dropdown/hooks/useDetectDevice.js +6 -9
- package/dist/components/dropdown/hooks/useDropdown.d.ts +8 -4
- package/dist/components/dropdown/hooks/useDropdown.js +48 -53
- package/dist/components/dropdown/hooks/useOrientation.js +7 -10
- package/dist/components/dropdown/interface/ChipInterface.js +1 -2
- package/dist/components/dropdown/interface/DropdownInterface.d.ts +4 -4
- package/dist/components/dropdown/interface/DropdownInterface.js +1 -2
- package/dist/components/dropdown/interface/InputProps.js +1 -2
- package/dist/components/svgButton/SvgButton.js +8 -13
- package/dist/components/svgButton/SvgButtonStyle.d.ts +2 -2
- package/dist/components/svgButton/SvgButtonStyle.js +7 -11
- package/dist/components/text/AppText.js +8 -16
- package/dist/components/text/AppTextStyle.d.ts +3 -156
- package/dist/components/text/AppTextStyle.js +8 -13
- package/dist/components/textInput/AppTextInput.js +19 -57
- package/dist/components/textInput/AppTextInputStyle.d.ts +4 -4
- package/dist/components/textInput/AppTextInputStyle.js +16 -20
- package/dist/controller/dropDownController/DropdownController.d.ts +4 -5
- package/dist/controller/dropDownController/DropdownController.js +13 -18
- package/dist/controller/dropDownController/DropdownControllerStyle.d.ts +3 -3
- package/dist/controller/dropDownController/DropdownControllerStyle.js +10 -14
- package/dist/index.js +2 -10
- package/dist/interface/colors.interface.js +1 -2
- package/dist/interface/svg.interface.js +1 -2
- package/dist/style/colors.js +6 -9
- package/dist/style/index.js +6 -23
- package/dist/style/shadow.d.ts +0 -149
- package/dist/style/shadow.js +1 -147
- package/dist/style/spacing.d.ts +0 -12
- package/dist/style/spacing.js +2 -17
- package/package.json +1 -1
- package/src/components/dropdown/Dropdown.tsx +28 -26
- package/src/components/dropdown/hooks/useDropdown.ts +14 -3
- package/src/components/dropdown/interface/DropdownInterface.ts +4 -4
- package/src/components/text/AppText.tsx +0 -3
- package/src/components/text/AppTextStyle.ts +1 -3
- package/src/controller/dropDownController/DropdownController.tsx +18 -17
- package/src/style/shadow.ts +0 -143
- package/src/style/spacing.ts +1 -13
- package/tsconfig.json +8 -4
|
@@ -1,108 +1,68 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
/* eslint-disable react-hooks/exhaustive-deps */
|
|
40
|
-
const react_native_1 = require("react-native");
|
|
41
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
42
|
-
const AppText_1 = __importDefault(require("../text/AppText"));
|
|
43
|
-
const Chip_1 = __importDefault(require("./component/chip/Chip"));
|
|
44
|
-
const react_1 = __importStar(require("react"));
|
|
45
|
-
const useDropdown_1 = __importDefault(require("./hooks/useDropdown"));
|
|
46
|
-
const SvgButton_1 = __importDefault(require("../svgButton/SvgButton"));
|
|
47
|
-
const DropdownStyle_1 = require("./DropdownStyle");
|
|
48
|
-
const CheckIcon_1 = __importDefault(require("../../assets/svg/CheckIcon"));
|
|
49
|
-
const svg_1 = require("../../assets/svg");
|
|
50
|
-
const TextInput_1 = __importDefault(require("./component/input/TextInput"));
|
|
1
|
+
import { View, Modal, FlatList, StyleSheet, ScrollView, TouchableHighlight, TouchableWithoutFeedback, } from 'react-native';
|
|
2
|
+
import _ from 'lodash';
|
|
3
|
+
import AppText from '../text/AppText';
|
|
4
|
+
import Chip from './component/chip/Chip';
|
|
5
|
+
import React, { useCallback } from 'react';
|
|
6
|
+
import useDropdown from './hooks/useDropdown';
|
|
7
|
+
import SvgButton from '../svgButton/SvgButton';
|
|
8
|
+
import { useDropdownStyle } from './DropdownStyle';
|
|
9
|
+
import { ArrowDown, ArrowUp, CheckIcon } from '../../assets/svg';
|
|
10
|
+
import SearchInput from './component/input/TextInput';
|
|
51
11
|
const DropdownComponent = (props) => {
|
|
52
|
-
const { label, testID, iconStyle, renderItem, style = {}, subfixIcon, labelField, valueField, onChangeText, itemTextStyle, flatListProps, minHeight = 0, containerStyle, search = false, renderLeftIcon, checkIconColor, radioIconColor, multiSelectIcon, itemTestIDField, maxHeight = 300, inverted = true, renderRightIcon,
|
|
12
|
+
const { label, testID, iconStyle, renderItem, style = {}, subfixIcon, labelField, valueField, onChangeText, itemTextStyle, flatListProps, minHeight = 0, containerStyle, search = false, renderLeftIcon, checkIconColor, radioIconColor, multiSelectIcon, itemTestIDField, maxHeight = 300, inverted = true, renderRightIcon, placeholderStyle, inputSearchStyle, searchPlaceholder, selectedTextStyle, renderInputSearch, iconColor = 'gray', accessibilityLabel, itemContainerStyle, labelContainer = {}, labelTextStyle = {}, selectedTextProps = {}, chipContainerProps = {}, keyboardAvoiding = true, selectionType = 'single', activeColor = 'lightGray', dropdownPosition = 'auto', itemAccessibilityLabelField, placeholder = 'Please select', showsVerticalScrollIndicator = true, } = props;
|
|
53
13
|
const { chipColor, clearIcon, textColor, onClearPress: onClear, } = chipContainerProps;
|
|
54
|
-
const { styles, colors } =
|
|
14
|
+
const { styles, colors } = useDropdownStyle({
|
|
55
15
|
checkIconColor: checkIconColor,
|
|
56
16
|
radioIconColor: radioIconColor,
|
|
57
17
|
});
|
|
58
|
-
const { ref, font, visible, refList, position, onSelect, listData, onSearch, onMeasure, searchText, showOrClose, scrollIndex, currentValue, onCheckPress, onClearPress, setSearchText, keyboardHeight, } = (
|
|
18
|
+
const { ref, font, visible, refList, position, onSelect, listData, onSearch, onMeasure, searchText, showOrClose, scrollIndex, currentValue, onCheckPress, onClearPress, setSearchText, keyboardHeight, } = useDropdown({ ...props });
|
|
59
19
|
const renderRight = () => {
|
|
60
|
-
return renderRightIcon ? (renderRightIcon(visible)) : (<
|
|
20
|
+
return renderRightIcon ? (renderRightIcon(visible)) : (<SvgButton icon={subfixIcon ? (subfixIcon) : visible ? (<ArrowUp color={iconColor}/>) : (<ArrowDown color={iconColor}/>)} onPress={showOrClose} style={StyleSheet.flatten([
|
|
61
21
|
iconStyle,
|
|
62
22
|
styles.icon,
|
|
63
23
|
{ tintColor: iconColor },
|
|
64
24
|
])}/>);
|
|
65
25
|
};
|
|
66
26
|
const _renderDropdown = () => {
|
|
67
|
-
const isSelected = currentValue &&
|
|
68
|
-
return (<
|
|
69
|
-
<
|
|
27
|
+
const isSelected = currentValue && _.get(currentValue, valueField);
|
|
28
|
+
return (<TouchableWithoutFeedback testID={testID} accessible={!!accessibilityLabel} accessibilityLabel={accessibilityLabel} onPress={() => (selectionType === 'single' ? showOrClose() : null)}>
|
|
29
|
+
<View style={styles.dropdown}>
|
|
70
30
|
{renderLeftIcon?.(visible)}
|
|
71
|
-
{selectionType === 'single' ? (<
|
|
31
|
+
{selectionType === 'single' ? (<AppText style={[
|
|
72
32
|
styles.textItem,
|
|
73
33
|
isSelected !== null ? selectedTextStyle : placeholderStyle,
|
|
74
34
|
font(),
|
|
75
35
|
]} {...selectedTextProps}>
|
|
76
36
|
{isSelected !== null
|
|
77
|
-
?
|
|
37
|
+
? _.get(currentValue, labelField)
|
|
78
38
|
: placeholder}
|
|
79
|
-
</
|
|
39
|
+
</AppText>) : currentValue?.length === 0 ? (<AppText style={[styles.textItem, placeholderStyle, font()]} {...selectedTextProps}>
|
|
80
40
|
{placeholder}
|
|
81
|
-
</
|
|
82
|
-
<
|
|
83
|
-
<
|
|
84
|
-
{currentValue?.map?.((i) => (<
|
|
41
|
+
</AppText>) : (<View style={styles.showMultiSelectContainer}>
|
|
42
|
+
<ScrollView showsVerticalScrollIndicator={false}>
|
|
43
|
+
<View style={styles.wraps}>
|
|
44
|
+
{currentValue?.map?.((i) => (<Chip chipColor={chipColor || 'red'} textColor={textColor || 'white'} clearIcon={clearIcon} key={i?.[valueField]} label={i?.[labelField]} onClearPress={() => {
|
|
85
45
|
onClear?.();
|
|
86
46
|
onClearPress?.(i);
|
|
87
47
|
}}/>))}
|
|
88
|
-
</
|
|
89
|
-
</
|
|
90
|
-
</
|
|
48
|
+
</View>
|
|
49
|
+
</ScrollView>
|
|
50
|
+
</View>)}
|
|
91
51
|
{renderRight()}
|
|
92
|
-
</
|
|
93
|
-
</
|
|
52
|
+
</View>
|
|
53
|
+
</TouchableWithoutFeedback>);
|
|
94
54
|
};
|
|
95
|
-
const renderRadio =
|
|
96
|
-
return (<
|
|
97
|
-
{selected && <
|
|
98
|
-
</
|
|
55
|
+
const renderRadio = useCallback((selected) => {
|
|
56
|
+
return (<View style={styles.itemIconContainer}>
|
|
57
|
+
{selected && <View style={styles.iconSubContainer}/>}
|
|
58
|
+
</View>);
|
|
99
59
|
}, [styles]);
|
|
100
|
-
const renderCheckItem =
|
|
101
|
-
const isSelected =
|
|
102
|
-
return (<
|
|
103
|
-
<
|
|
104
|
-
{renderItem ? (renderItem(item, isSelected, labelField, valueField)) : (<
|
|
105
|
-
<
|
|
60
|
+
const renderCheckItem = useCallback(({ item, index }) => {
|
|
61
|
+
const isSelected = _.some(currentValue, (h) => _.isEqual(_.get(h, valueField), _.get(item, valueField)));
|
|
62
|
+
return (<TouchableHighlight key={index.toString()} testID={_.get(item, itemTestIDField || labelField)} accessible={!!accessibilityLabel} accessibilityLabel={_.get(item, itemAccessibilityLabelField || labelField)} underlayColor={activeColor} onPress={() => onCheckPress(item)}>
|
|
63
|
+
<View style={StyleSheet.flatten([itemContainerStyle])}>
|
|
64
|
+
{renderItem ? (renderItem(item, isSelected, labelField, valueField)) : (<View style={styles.item}>
|
|
65
|
+
<SvgButton icon={multiSelectIcon ? (multiSelectIcon) : (<CheckIcon color={colors.white}/>)} onPress={() => onCheckPress(item)} style={[
|
|
106
66
|
styles.checkContainer,
|
|
107
67
|
{
|
|
108
68
|
backgroundColor: isSelected
|
|
@@ -112,52 +72,54 @@ const DropdownComponent = (props) => {
|
|
|
112
72
|
: colors.white,
|
|
113
73
|
},
|
|
114
74
|
]}/>
|
|
115
|
-
<
|
|
75
|
+
<AppText style={StyleSheet.flatten([
|
|
116
76
|
styles.textItem,
|
|
117
77
|
itemTextStyle,
|
|
118
78
|
font(),
|
|
119
79
|
])}>
|
|
120
|
-
{
|
|
121
|
-
</
|
|
122
|
-
</
|
|
123
|
-
</
|
|
124
|
-
</
|
|
80
|
+
{_.get(item, labelField)}
|
|
81
|
+
</AppText>
|
|
82
|
+
</View>)}
|
|
83
|
+
</View>
|
|
84
|
+
</TouchableHighlight>);
|
|
125
85
|
}, [
|
|
126
|
-
font,
|
|
127
|
-
colors,
|
|
128
|
-
styles,
|
|
129
|
-
labelField,
|
|
130
|
-
renderItem,
|
|
131
|
-
valueField,
|
|
132
|
-
activeColor,
|
|
133
86
|
currentValue,
|
|
134
|
-
itemTextStyle,
|
|
135
87
|
itemTestIDField,
|
|
88
|
+
labelField,
|
|
136
89
|
accessibilityLabel,
|
|
137
|
-
itemContainerStyle,
|
|
138
90
|
itemAccessibilityLabelField,
|
|
91
|
+
activeColor,
|
|
92
|
+
itemContainerStyle,
|
|
93
|
+
renderItem,
|
|
94
|
+
valueField,
|
|
95
|
+
styles,
|
|
96
|
+
multiSelectIcon,
|
|
97
|
+
colors,
|
|
98
|
+
checkIconColor,
|
|
99
|
+
itemTextStyle,
|
|
100
|
+
font,
|
|
101
|
+
onCheckPress,
|
|
139
102
|
]);
|
|
140
|
-
const _renderItem =
|
|
141
|
-
const isSelected = currentValue &&
|
|
142
|
-
const selected =
|
|
143
|
-
|
|
144
|
-
return (<
|
|
145
|
-
<
|
|
146
|
-
{renderItem ? (renderItem(item, selected, labelField, valueField)) : (<
|
|
103
|
+
const _renderItem = useCallback(({ item, index }) => {
|
|
104
|
+
const isSelected = currentValue && _.get(currentValue, valueField);
|
|
105
|
+
const selected = _.isEqual(_.get(item, valueField), isSelected);
|
|
106
|
+
_.assign(item, { _index: index });
|
|
107
|
+
return (<TouchableHighlight key={index.toString()} testID={_.get(item, itemTestIDField || labelField)} accessible={!!accessibilityLabel} accessibilityLabel={_.get(item, itemAccessibilityLabelField || labelField)} underlayColor={activeColor} onPress={() => onSelect(item)}>
|
|
108
|
+
<View style={StyleSheet.flatten([itemContainerStyle])}>
|
|
109
|
+
{renderItem ? (renderItem(item, selected, labelField, valueField)) : (<View style={styles.item}>
|
|
147
110
|
{renderRadio(selected)}
|
|
148
|
-
<
|
|
111
|
+
<AppText style={StyleSheet.flatten([
|
|
149
112
|
styles.textItem,
|
|
150
113
|
itemTextStyle,
|
|
151
114
|
font(),
|
|
152
115
|
])}>
|
|
153
|
-
{
|
|
154
|
-
</
|
|
155
|
-
</
|
|
156
|
-
</
|
|
157
|
-
</
|
|
116
|
+
{_.get(item, labelField)}
|
|
117
|
+
</AppText>
|
|
118
|
+
</View>)}
|
|
119
|
+
</View>
|
|
120
|
+
</TouchableHighlight>);
|
|
158
121
|
}, [
|
|
159
122
|
font,
|
|
160
|
-
colors,
|
|
161
123
|
styles,
|
|
162
124
|
onSelect,
|
|
163
125
|
labelField,
|
|
@@ -172,7 +134,7 @@ const DropdownComponent = (props) => {
|
|
|
172
134
|
itemContainerStyle,
|
|
173
135
|
itemAccessibilityLabelField,
|
|
174
136
|
]);
|
|
175
|
-
const renderSearch =
|
|
137
|
+
const renderSearch = useCallback(() => {
|
|
176
138
|
if (search) {
|
|
177
139
|
if (renderInputSearch) {
|
|
178
140
|
return renderInputSearch(text => {
|
|
@@ -184,7 +146,7 @@ const DropdownComponent = (props) => {
|
|
|
184
146
|
});
|
|
185
147
|
}
|
|
186
148
|
else {
|
|
187
|
-
return (<
|
|
149
|
+
return (<SearchInput value={searchText} autoCorrect={false} testID={testID + ' input'} placeholderTextColor={colors.black} style={[styles.input, inputSearchStyle]} accessibilityLabel={accessibilityLabel + ' input'} placeholder={searchPlaceholder || 'Write here for search...'} onChangeText={(e) => {
|
|
188
150
|
if (onChangeText) {
|
|
189
151
|
setSearchText(e);
|
|
190
152
|
onChangeText(e);
|
|
@@ -196,42 +158,46 @@ const DropdownComponent = (props) => {
|
|
|
196
158
|
return null;
|
|
197
159
|
}, [
|
|
198
160
|
search,
|
|
161
|
+
renderInputSearch,
|
|
162
|
+
onChangeText,
|
|
163
|
+
onSearch,
|
|
164
|
+
setSearchText,
|
|
165
|
+
searchText,
|
|
199
166
|
testID,
|
|
200
167
|
colors,
|
|
201
168
|
styles,
|
|
202
|
-
onSearch,
|
|
203
|
-
searchText,
|
|
204
|
-
onChangeText,
|
|
205
169
|
inputSearchStyle,
|
|
206
|
-
renderInputSearch,
|
|
207
|
-
searchPlaceholder,
|
|
208
170
|
accessibilityLabel,
|
|
171
|
+
searchPlaceholder,
|
|
209
172
|
]);
|
|
210
|
-
const _renderList =
|
|
173
|
+
const _renderList = useCallback((isTopPosition) => {
|
|
211
174
|
const isInverted = !inverted ? false : isTopPosition;
|
|
212
175
|
const _renderListHelper = () => {
|
|
213
|
-
return (<
|
|
176
|
+
return (<FlatList ref={refList} data={listData} {...flatListProps} testID={testID + ' flatlist'} keyboardShouldPersistTaps="handled" onScrollToIndexFailed={scrollIndex} inverted={isTopPosition ? inverted : false} keyExtractor={(_item, index) => index.toString()} accessibilityLabel={accessibilityLabel + ' flatlist'} showsVerticalScrollIndicator={showsVerticalScrollIndicator} renderItem={selectionType === 'single' ? _renderItem : renderCheckItem}/>);
|
|
214
177
|
};
|
|
215
|
-
return (<
|
|
216
|
-
<
|
|
178
|
+
return (<TouchableWithoutFeedback>
|
|
179
|
+
<View style={styles.flexShrink}>
|
|
217
180
|
{isInverted && _renderListHelper()}
|
|
218
181
|
{renderSearch()}
|
|
219
182
|
{!isInverted && _renderListHelper()}
|
|
220
|
-
</
|
|
221
|
-
</
|
|
183
|
+
</View>
|
|
184
|
+
</TouchableWithoutFeedback>);
|
|
222
185
|
}, [
|
|
223
|
-
styles,
|
|
224
|
-
testID,
|
|
225
186
|
inverted,
|
|
226
|
-
|
|
227
|
-
scrollIndex,
|
|
187
|
+
styles,
|
|
228
188
|
renderSearch,
|
|
189
|
+
refList,
|
|
190
|
+
listData,
|
|
229
191
|
flatListProps,
|
|
230
|
-
|
|
192
|
+
testID,
|
|
193
|
+
scrollIndex,
|
|
231
194
|
accessibilityLabel,
|
|
232
195
|
showsVerticalScrollIndicator,
|
|
196
|
+
selectionType,
|
|
197
|
+
_renderItem,
|
|
198
|
+
renderCheckItem,
|
|
233
199
|
]);
|
|
234
|
-
const _renderModal =
|
|
200
|
+
const _renderModal = useCallback(() => {
|
|
235
201
|
if (visible && position) {
|
|
236
202
|
const { isFull, width, height, top, bottom, left } = position;
|
|
237
203
|
const onAutoPosition = () => {
|
|
@@ -257,14 +223,14 @@ const DropdownComponent = (props) => {
|
|
|
257
223
|
dropdownPosition === 'auto') {
|
|
258
224
|
extendHeight = keyboardHeight;
|
|
259
225
|
}
|
|
260
|
-
return (<
|
|
261
|
-
<
|
|
262
|
-
<
|
|
226
|
+
return (<Modal transparent visible={visible} statusBarTranslucent onRequestClose={showOrClose} supportedOrientations={['landscape', 'portrait']}>
|
|
227
|
+
<TouchableWithoutFeedback onPress={showOrClose}>
|
|
228
|
+
<View style={StyleSheet.flatten([
|
|
263
229
|
styles.flex1,
|
|
264
230
|
isFull && styles.styleContainerVertical,
|
|
265
231
|
keyboardStyle,
|
|
266
232
|
])}>
|
|
267
|
-
<
|
|
233
|
+
<View style={StyleSheet.flatten([
|
|
268
234
|
styles.flex1,
|
|
269
235
|
!isTopPosition
|
|
270
236
|
? { paddingTop: extendHeight }
|
|
@@ -274,7 +240,7 @@ const DropdownComponent = (props) => {
|
|
|
274
240
|
},
|
|
275
241
|
isFull && styles.fullScreen,
|
|
276
242
|
])}>
|
|
277
|
-
<
|
|
243
|
+
<View style={StyleSheet.flatten([
|
|
278
244
|
styles.container,
|
|
279
245
|
isFull ? styles.styleHorizontal : styleVertical,
|
|
280
246
|
{
|
|
@@ -283,11 +249,11 @@ const DropdownComponent = (props) => {
|
|
|
283
249
|
containerStyle,
|
|
284
250
|
])}>
|
|
285
251
|
{_renderList(isTopPosition)}
|
|
286
|
-
</
|
|
287
|
-
</
|
|
288
|
-
</
|
|
289
|
-
</
|
|
290
|
-
</
|
|
252
|
+
</View>
|
|
253
|
+
</View>
|
|
254
|
+
</View>
|
|
255
|
+
</TouchableWithoutFeedback>
|
|
256
|
+
</Modal>);
|
|
291
257
|
}
|
|
292
258
|
return null;
|
|
293
259
|
}
|
|
@@ -303,23 +269,22 @@ const DropdownComponent = (props) => {
|
|
|
303
269
|
_renderList,
|
|
304
270
|
keyboardHeight,
|
|
305
271
|
containerStyle,
|
|
306
|
-
backgroundColor,
|
|
307
272
|
dropdownPosition,
|
|
308
273
|
keyboardAvoiding,
|
|
309
274
|
]);
|
|
310
|
-
const _renderLabel =
|
|
311
|
-
return label ? (<
|
|
312
|
-
<
|
|
275
|
+
const _renderLabel = useCallback(() => {
|
|
276
|
+
return label ? (<View style={[styles.labelContainer, labelContainer]}>
|
|
277
|
+
<AppText style={[styles.labelTextStyle, labelTextStyle]}>
|
|
313
278
|
{label}
|
|
314
|
-
</
|
|
315
|
-
</
|
|
279
|
+
</AppText>
|
|
280
|
+
</View>) : (<></>);
|
|
316
281
|
}, [label, labelContainer, labelTextStyle, styles]);
|
|
317
|
-
return (<
|
|
282
|
+
return (<View style={styles.mainContainer}>
|
|
318
283
|
{_renderLabel()}
|
|
319
|
-
<
|
|
284
|
+
<View ref={ref} onLayout={onMeasure} style={StyleSheet.flatten([styles.mainWrap, style])}>
|
|
320
285
|
{_renderDropdown()}
|
|
321
286
|
{_renderModal()}
|
|
322
|
-
</
|
|
323
|
-
</
|
|
287
|
+
</View>
|
|
288
|
+
</View>);
|
|
324
289
|
};
|
|
325
|
-
|
|
290
|
+
export default DropdownComponent;
|
|
@@ -5,9 +5,9 @@ interface Props {
|
|
|
5
5
|
checkIconColor?: ColorValue;
|
|
6
6
|
}
|
|
7
7
|
export declare const useDropdownStyle: (props: Props) => {
|
|
8
|
-
styles: {
|
|
8
|
+
styles: Readonly<{
|
|
9
9
|
mainContainer: {
|
|
10
|
-
width:
|
|
10
|
+
width: string;
|
|
11
11
|
};
|
|
12
12
|
mainWrap: {
|
|
13
13
|
borderWidth: number;
|
|
@@ -98,16 +98,16 @@ export declare const useDropdownStyle: (props: Props) => {
|
|
|
98
98
|
alignItems: "center";
|
|
99
99
|
justifyContent: "center";
|
|
100
100
|
padding: number;
|
|
101
|
-
borderColor:
|
|
101
|
+
borderColor: string | number | import("react-native").NativeColorValue;
|
|
102
102
|
};
|
|
103
103
|
iconSubContainer: {
|
|
104
|
-
width:
|
|
105
|
-
height:
|
|
104
|
+
width: string;
|
|
105
|
+
height: string;
|
|
106
106
|
borderRadius: number;
|
|
107
|
-
backgroundColor:
|
|
107
|
+
backgroundColor: string | number | import("react-native").NativeColorValue;
|
|
108
108
|
};
|
|
109
109
|
styleHorizontal: {
|
|
110
|
-
width:
|
|
110
|
+
width: string | number;
|
|
111
111
|
alignSelf: "center";
|
|
112
112
|
};
|
|
113
113
|
styleContainerVertical: {
|
|
@@ -122,11 +122,11 @@ export declare const useDropdownStyle: (props: Props) => {
|
|
|
122
122
|
height: number;
|
|
123
123
|
alignItems: "center";
|
|
124
124
|
justifyContent: "center";
|
|
125
|
-
borderColor:
|
|
125
|
+
borderColor: string | number | import("react-native").NativeColorValue;
|
|
126
126
|
};
|
|
127
127
|
showMultiSelectContainer: {
|
|
128
|
-
width:
|
|
129
|
-
height:
|
|
128
|
+
width: string;
|
|
129
|
+
height: string;
|
|
130
130
|
maxHeight: number;
|
|
131
131
|
};
|
|
132
132
|
wraps: {
|
|
@@ -135,7 +135,7 @@ export declare const useDropdownStyle: (props: Props) => {
|
|
|
135
135
|
flexDirection: "row";
|
|
136
136
|
paddingHorizontal: number;
|
|
137
137
|
};
|
|
138
|
-
}
|
|
138
|
+
}>;
|
|
139
139
|
colors: {
|
|
140
140
|
blue: string;
|
|
141
141
|
gray: string;
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const useDropdownStyle = (props) => {
|
|
9
|
-
const { ...colors } = style_1.LIGHT_COLORS;
|
|
10
|
-
const orientation = (0, useOrientation_1.useDeviceOrientation)();
|
|
1
|
+
import { SPACING, LIGHT_COLORS, SCREEN_WIDTH, DEFAULT_COLORS, } from '../../style';
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import { I18nManager, StyleSheet } from 'react-native';
|
|
4
|
+
import { useDeviceOrientation } from './hooks/useOrientation';
|
|
5
|
+
export const useDropdownStyle = (props) => {
|
|
6
|
+
const { ...colors } = LIGHT_COLORS;
|
|
7
|
+
const orientation = useDeviceOrientation();
|
|
11
8
|
const { size = 16, radioIconColor, checkIconColor } = props;
|
|
12
|
-
const styles =
|
|
13
|
-
return
|
|
9
|
+
const styles = useMemo(() => {
|
|
10
|
+
return StyleSheet.create({
|
|
14
11
|
mainContainer: {
|
|
15
12
|
width: '100%',
|
|
16
13
|
},
|
|
@@ -49,13 +46,13 @@ const useDropdownStyle = (props) => {
|
|
|
49
46
|
maxHeight: 170,
|
|
50
47
|
alignItems: 'center',
|
|
51
48
|
justifyContent: 'space-between',
|
|
52
|
-
flexDirection:
|
|
49
|
+
flexDirection: I18nManager.isRTL ? 'row-reverse' : 'row',
|
|
53
50
|
},
|
|
54
51
|
title: {
|
|
55
52
|
fontSize: 16,
|
|
56
53
|
color: colors.gray,
|
|
57
|
-
marginVertical:
|
|
58
|
-
writingDirection:
|
|
54
|
+
marginVertical: SPACING.s6,
|
|
55
|
+
writingDirection: I18nManager.isRTL ? 'rtl' : 'ltr',
|
|
59
56
|
},
|
|
60
57
|
item: {
|
|
61
58
|
padding: 17,
|
|
@@ -63,13 +60,13 @@ const useDropdownStyle = (props) => {
|
|
|
63
60
|
borderBottomWidth: 0.5,
|
|
64
61
|
borderColor: colors.lightGray,
|
|
65
62
|
justifyContent: 'space-between',
|
|
66
|
-
flexDirection:
|
|
63
|
+
flexDirection: I18nManager.isRTL ? 'row-reverse' : 'row',
|
|
67
64
|
},
|
|
68
65
|
textItem: {
|
|
69
66
|
flex: 1,
|
|
70
67
|
fontSize: 16,
|
|
71
68
|
color: colors.gray,
|
|
72
|
-
writingDirection:
|
|
69
|
+
writingDirection: I18nManager.isRTL ? 'rtl' : 'ltr',
|
|
73
70
|
},
|
|
74
71
|
icon: {
|
|
75
72
|
width: 20,
|
|
@@ -80,16 +77,16 @@ const useDropdownStyle = (props) => {
|
|
|
80
77
|
height: 45,
|
|
81
78
|
borderWidth: 0.5,
|
|
82
79
|
borderColor: '#DDDDDD',
|
|
83
|
-
marginBottom:
|
|
84
|
-
paddingHorizontal:
|
|
80
|
+
marginBottom: SPACING.s8,
|
|
81
|
+
paddingHorizontal: SPACING.s8,
|
|
85
82
|
},
|
|
86
83
|
fullScreen: {
|
|
87
84
|
alignItems: 'center',
|
|
88
85
|
justifyContent: 'center',
|
|
89
86
|
},
|
|
90
87
|
labelContainer: {
|
|
91
|
-
marginBottom:
|
|
92
|
-
paddingVertical:
|
|
88
|
+
marginBottom: SPACING.s6,
|
|
89
|
+
paddingVertical: SPACING.s6,
|
|
93
90
|
},
|
|
94
91
|
labelTextStyle: {
|
|
95
92
|
color: colors.gray,
|
|
@@ -112,12 +109,12 @@ const useDropdownStyle = (props) => {
|
|
|
112
109
|
backgroundColor: radioIconColor || colors.gray,
|
|
113
110
|
},
|
|
114
111
|
styleHorizontal: {
|
|
115
|
-
width: orientation === 'LANDSCAPE' ?
|
|
112
|
+
width: orientation === 'LANDSCAPE' ? SCREEN_WIDTH / 2 : '100%',
|
|
116
113
|
alignSelf: 'center',
|
|
117
114
|
},
|
|
118
115
|
styleContainerVertical: {
|
|
119
116
|
alignItems: 'center',
|
|
120
|
-
backgroundColor:
|
|
117
|
+
backgroundColor: DEFAULT_COLORS.blackOpacity,
|
|
121
118
|
},
|
|
122
119
|
checkContainer: {
|
|
123
120
|
borderWidth: 2,
|
|
@@ -147,4 +144,3 @@ const useDropdownStyle = (props) => {
|
|
|
147
144
|
colors,
|
|
148
145
|
};
|
|
149
146
|
};
|
|
150
|
-
exports.useDropdownStyle = useDropdownStyle;
|
|
@@ -1,23 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
const react_native_1 = require("react-native");
|
|
7
|
-
const ChipStyle_1 = __importDefault(require("./ChipStyle"));
|
|
8
|
-
const AppText_1 = __importDefault(require("../../../text/AppText"));
|
|
9
|
-
const svg_1 = require("../../../../assets/svg");
|
|
10
|
-
const SvgButton_1 = __importDefault(require("../../../svgButton/SvgButton"));
|
|
1
|
+
import { View } from 'react-native';
|
|
2
|
+
import useChipStyle from './ChipStyle';
|
|
3
|
+
import AppText from '../../../text/AppText';
|
|
4
|
+
import { ClearIcon } from '../../../../assets/svg';
|
|
5
|
+
import SvgButton from '../../../svgButton/SvgButton';
|
|
11
6
|
const Chip = (props) => {
|
|
12
|
-
const { styles, colors } = (
|
|
7
|
+
const { styles, colors } = useChipStyle({ ...props });
|
|
13
8
|
const { label, onClearPress, textColor, clearIcon } = props;
|
|
14
|
-
return (<
|
|
15
|
-
<
|
|
9
|
+
return (<View style={styles.box}>
|
|
10
|
+
<AppText size={12} fontFamily={'semiBold'} style={styles.chipText} color={textColor ? textColor : 'gray'}>
|
|
16
11
|
{label}
|
|
17
|
-
</
|
|
18
|
-
{clearIcon ? (clearIcon) : (<
|
|
19
|
-
<
|
|
20
|
-
</
|
|
21
|
-
</
|
|
12
|
+
</AppText>
|
|
13
|
+
{clearIcon ? (clearIcon) : (<View style={styles.clearContainer}>
|
|
14
|
+
<SvgButton icon={<ClearIcon size={8} color={textColor ? textColor : colors.white}/>} onPress={onClearPress} style={styles.clearIcon}/>
|
|
15
|
+
</View>)}
|
|
16
|
+
</View>);
|
|
22
17
|
};
|
|
23
|
-
|
|
18
|
+
export default Chip;
|