@cleartrip/ct-design-dropdown 5.21.0-SNAPSHOT-native-main.1 → 5.21.0
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/Dropdown.native.d.ts.map +1 -1
- package/package.json +7 -7
- package/src/Dropdown.native.tsx +53 -43
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dropdown.native.d.ts","sourceRoot":"","sources":["../packages/components/Dropdown/src/Dropdown.native.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAE,aAAa,EAAQ,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"Dropdown.native.d.ts","sourceRoot":"","sources":["../packages/components/Dropdown/src/Dropdown.native.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAE,aAAa,EAAQ,MAAM,QAAQ,CAAC;AAsD7C,QAAA,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CAqLrC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cleartrip/ct-design-dropdown",
|
|
3
|
-
"version": "5.21.0
|
|
3
|
+
"version": "5.21.0",
|
|
4
4
|
"description": "Dropdown Component",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"main": "./dist/ct-design-dropdown.cjs.js",
|
|
@@ -24,12 +24,12 @@
|
|
|
24
24
|
"src"
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@cleartrip/ct-design-theme": "5.21.0
|
|
28
|
-
"@cleartrip/ct-design-types": "5.21.0
|
|
29
|
-
"@cleartrip/ct-design-
|
|
30
|
-
"@cleartrip/ct-design-
|
|
31
|
-
"@cleartrip/ct-design-icons": "
|
|
32
|
-
"@cleartrip/ct-design-style-manager": "5.21.0
|
|
27
|
+
"@cleartrip/ct-design-theme": "5.21.0",
|
|
28
|
+
"@cleartrip/ct-design-types": "5.21.0",
|
|
29
|
+
"@cleartrip/ct-design-typography": "5.21.0",
|
|
30
|
+
"@cleartrip/ct-design-container": "5.21.0",
|
|
31
|
+
"@cleartrip/ct-design-icons": "55.0.0",
|
|
32
|
+
"@cleartrip/ct-design-style-manager": "5.21.0"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"react": ">=16.8.0",
|
package/src/Dropdown.native.tsx
CHANGED
|
@@ -11,17 +11,24 @@ import { DropdownProps, Item } from './type';
|
|
|
11
11
|
const { height: screenHeight } = Dimensions.get('screen');
|
|
12
12
|
|
|
13
13
|
const staticStyle = makeStyles(() => ({
|
|
14
|
-
|
|
14
|
+
// Outer shell owns the shadow. iOS clips shadows when overflow:'hidden' is on
|
|
15
|
+
// the same view, so clipping stays on the inner container below.
|
|
16
|
+
dropDownItemListShadow: {
|
|
15
17
|
width: '100%',
|
|
16
|
-
maxHeight: screenHeight * 0.19,
|
|
17
|
-
borderRadius: 5,
|
|
18
18
|
position: 'absolute',
|
|
19
|
-
|
|
19
|
+
borderRadius: 5,
|
|
20
|
+
backgroundColor: 'white',
|
|
20
21
|
shadowColor: '#000',
|
|
21
22
|
shadowOffset: { width: 0, height: 1 },
|
|
22
23
|
shadowOpacity: 0.22,
|
|
23
24
|
shadowRadius: 2.22,
|
|
24
25
|
elevation: 3,
|
|
26
|
+
},
|
|
27
|
+
dropDownItemListContainer: {
|
|
28
|
+
width: '100%',
|
|
29
|
+
maxHeight: screenHeight * 0.19,
|
|
30
|
+
borderRadius: 5,
|
|
31
|
+
overflow: 'hidden',
|
|
25
32
|
backgroundColor: 'white',
|
|
26
33
|
},
|
|
27
34
|
modalBackground: {
|
|
@@ -31,6 +38,7 @@ const staticStyle = makeStyles(() => ({
|
|
|
31
38
|
overlayButtonWrapper: {
|
|
32
39
|
position: 'absolute',
|
|
33
40
|
alignItems: 'center',
|
|
41
|
+
overflow: 'visible',
|
|
34
42
|
},
|
|
35
43
|
dropDownItemContainer: {
|
|
36
44
|
width: '100%',
|
|
@@ -146,51 +154,53 @@ const Dropdown: React.FC<DropdownProps> = ({
|
|
|
146
154
|
<Container
|
|
147
155
|
styleConfig={{
|
|
148
156
|
root: [
|
|
149
|
-
staticStyle.
|
|
157
|
+
staticStyle.dropDownItemListShadow,
|
|
150
158
|
...dropDownItemListContainer,
|
|
151
159
|
isShowDropDownOnTop ? { bottom: -height } : { top: 0 },
|
|
152
160
|
],
|
|
153
161
|
}}
|
|
154
162
|
>
|
|
155
|
-
<
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
{
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
<Typography
|
|
183
|
-
styleConfig={dropDownItemTextContainer}
|
|
184
|
-
variant={TypographyVariant.HM4}
|
|
185
|
-
color={isSelected ? TypographyColor.NEUTRAL : TypographyColor.PRIMARY}
|
|
163
|
+
<Container styleConfig={{ root: [staticStyle.dropDownItemListContainer] }}>
|
|
164
|
+
<ScrollView
|
|
165
|
+
ref={scrollRef}
|
|
166
|
+
contentContainerStyle={[staticStyle.scrollContent]}
|
|
167
|
+
showsVerticalScrollIndicator={false}
|
|
168
|
+
>
|
|
169
|
+
{itemList.map((item, index) => {
|
|
170
|
+
const dropdownItem = renderItem?.(item, index) || item?.label;
|
|
171
|
+
const backgroundColor = index === singleSelectIndex ? '#1a1a1a' : 'white';
|
|
172
|
+
const isSelected = index === singleSelectIndex;
|
|
173
|
+
|
|
174
|
+
return (
|
|
175
|
+
<Pressable
|
|
176
|
+
key={`${item.value}-${index}`}
|
|
177
|
+
onLayout={(event: LayoutChangeEvent) => {
|
|
178
|
+
const layout = event.nativeEvent.layout;
|
|
179
|
+
itemsRef.current[index] = layout.y;
|
|
180
|
+
if (itemList.length - 1 === index && focus) {
|
|
181
|
+
scrollToIndex(singleSelectIndex);
|
|
182
|
+
}
|
|
183
|
+
}}
|
|
184
|
+
style={({ pressed }) => [
|
|
185
|
+
{ backgroundColor: pressed ? 'rgb(231, 231, 231)' : backgroundColor },
|
|
186
|
+
staticStyle.dropDownItemContainer,
|
|
187
|
+
...dropDownItemContainer,
|
|
188
|
+
]}
|
|
189
|
+
onPress={() => singleSelectClickHandler(item, index)}
|
|
186
190
|
>
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
191
|
+
<Typography
|
|
192
|
+
styleConfig={dropDownItemTextContainer}
|
|
193
|
+
variant={TypographyVariant.HM4}
|
|
194
|
+
color={isSelected ? TypographyColor.NEUTRAL : TypographyColor.PRIMARY}
|
|
195
|
+
>
|
|
196
|
+
{' '}
|
|
197
|
+
{dropdownItem}
|
|
198
|
+
</Typography>
|
|
199
|
+
</Pressable>
|
|
200
|
+
);
|
|
201
|
+
})}
|
|
202
|
+
</ScrollView>
|
|
203
|
+
</Container>
|
|
194
204
|
</Container>
|
|
195
205
|
);
|
|
196
206
|
|