-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
try refactoring list type definition
- Loading branch information
Showing
11 changed files
with
190 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,77 @@ | ||
import React, { ReactNode } from 'react'; | ||
import React from 'react'; | ||
import ReactNative from 'react-native'; | ||
|
||
export interface ListProps { | ||
renderHeader?: Function | JSX.Element; | ||
renderFooter?: Function | JSX.Element; | ||
children?: JSX.Element | JSX.Element[]; | ||
style?: React.CSSProperties | {} | Array<{}>; | ||
/* for web */ | ||
} | ||
|
||
export interface ListWebProps extends ListProps, React.HTMLProps<HTMLDivElement> { | ||
prefixCls?: string; | ||
className?: string; | ||
role?: string; | ||
/* for native */ | ||
} | ||
|
||
export interface ListNativeProps extends ListProps, ReactNative.ViewProperties { | ||
ref?: any | ||
styles?: { | ||
Header?: {}; | ||
Footer?: {}; | ||
Body?: {}; | ||
BodyBottomLine?: {}; | ||
Header?: ReactNative.TextStyle; | ||
Footer?: ReactNative.TextStyle; | ||
Body?: ReactNative.ViewStyle; | ||
BodyBottomLine?: ReactNative.ViewStyle; | ||
}; | ||
} | ||
|
||
export interface ListItemProps { | ||
align?: 'top'|'middle'|'bottom'; | ||
disabled?: boolean; | ||
multipleLine?: boolean; | ||
children?: ReactNode; | ||
thumb?: ReactNode | null; | ||
extra?: ReactNode; | ||
thumb?: React.ReactNode; | ||
extra?: React.ReactNode; | ||
arrow?: 'horizontal'|'down'|'up'|'empty'|''; | ||
wrap?: boolean; | ||
onClick?: (e?: any) => void; | ||
style?: React.CSSProperties | {} | Array<{}>; | ||
/* for web */ | ||
prefixCls?: string; | ||
className?: string; | ||
} | ||
|
||
role?: string; | ||
export interface ListItemWebProps extends ListItemProps, React.HTMLProps<HTMLDivElement> { | ||
prefixCls?: string; | ||
activeStyle?: React.CSSProperties; | ||
error?: boolean; | ||
platform?: 'android' | 'ios' | 'cross'; | ||
// wrap?: boolean; // overwrite React.HTMLAttributes.wrap: string | ||
} | ||
|
||
/* for native */ | ||
export interface ListItemNativeProps extends ListItemProps, | ||
ReactNative.ViewProperties, | ||
Pick<ReactNative.TouchableHighlightProperties, 'onPressIn' | 'onPressOut'> { | ||
ref?: any | ||
wrap?: boolean; | ||
styles?: { | ||
underlayColor: {}, | ||
Content: {}, | ||
column: {}, | ||
Extra: {}, | ||
Arrow: {}, | ||
ArrowV: {}, | ||
Item: {}, | ||
Thumb: {}, | ||
multipleThumb: {}, | ||
Line: {}, | ||
multipleLine: {}, | ||
underlayColor: string, | ||
Content: ReactNative.TextStyle, | ||
column: ReactNative.ViewStyle, | ||
Extra: ReactNative.TextStyle, | ||
Arrow: ReactNative.ImageStyle, | ||
ArrowV: ReactNative.ImageStyle, | ||
Item: ReactNative.ViewStyle, | ||
Thumb: ReactNative.ImageStyle, | ||
multipleThumb: ReactNative.ImageStyle, | ||
Line: ReactNative.ViewStyle, | ||
multipleLine: ReactNative.ViewStyle, | ||
}; | ||
onPressIn?: () => void; | ||
onPressOut?: () => void; | ||
onClick?: ReactNative.TouchableHighlightProperties['onPress']; | ||
} | ||
|
||
export interface BriefProps { | ||
children?: ReactNode; | ||
wrap?: boolean; | ||
style?: React.CSSProperties | {} | Array<{}>; | ||
|
||
/* for web */ | ||
prefixCls?: string; | ||
className?: string; | ||
} | ||
|
||
export interface BriefWebProps extends BriefProps, | ||
Pick<React.HTMLProps<HTMLDivElement>, 'style'> { | ||
|
||
role?: string; | ||
/* for native */ | ||
styles: { | ||
Brief: {}, | ||
BriefText: {}, | ||
} | ||
|
||
export interface BriefNativeProps extends BriefProps, | ||
Pick<ReactNative.TextProperties, 'style'> { | ||
wrap?: boolean; | ||
styles?: { | ||
Brief: ReactNative.ViewStyle, | ||
BriefText: ReactNative.TextStyle, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import List from 'antd-mobile/lib/list'; | ||
|
||
const noop = () => { }; | ||
const style = { rotation: 0 }; | ||
|
||
const list = () => ( | ||
<List | ||
renderHeader={noop} | ||
renderFooter={noop} | ||
onTouchEnd={noop} | ||
styles={{ | ||
Header: style, | ||
Body: style, | ||
BodyBottomLine: style, | ||
Footer: style, | ||
}} | ||
> | ||
<br /> | ||
<List.Item | ||
align='top' | ||
disabled | ||
multipleLine | ||
thumb='/' | ||
extra='/' | ||
arrow='' | ||
wrap | ||
styles={{ | ||
underlayColor: '', | ||
Content: style, | ||
column: style, | ||
Extra: style, | ||
Arrow: style, | ||
ArrowV: style, | ||
Item: style, | ||
Thumb: style, | ||
multipleThumb: style, | ||
Line: style, | ||
multipleLine: style | ||
}} | ||
onClick={noop} | ||
onTouchEnd={noop} | ||
> | ||
<br /> | ||
<List.Item.Brief | ||
wrap | ||
style={style} | ||
styles={{ | ||
Brief: style, | ||
BriefText: style | ||
}} | ||
> | ||
<br /> | ||
</List.Item.Brief> | ||
</List.Item> | ||
</List> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"extends": "../../../tsconfig", | ||
"compilerOptions": { | ||
"noUnusedLocals": false, | ||
"noEmit": true, | ||
"skipLibCheck": true, | ||
"pretty": true, | ||
"baseUrl": "../../../", | ||
"paths": { | ||
"antd-mobile": ["./components/native"], | ||
"antd-mobile/lib/*": ["./components/*"] | ||
} | ||
}, | ||
"files": [ | ||
"./native.tsx" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"extends": "../../../tsconfig", | ||
"compilerOptions": { | ||
"noUnusedLocals": false, | ||
"noEmit": true, | ||
"skipLibCheck": true, | ||
"pretty": true, | ||
"baseUrl": "../../../", | ||
"paths": { | ||
"antd-mobile": ["./components"], | ||
"antd-mobile/lib/*": ["./components/*/index.web"] | ||
} | ||
}, | ||
"files": [ | ||
"./web.tsx" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import List from 'antd-mobile/lib/list'; | ||
|
||
const noop = () => { }; | ||
const style = { color: 'silver' }; | ||
|
||
const list = () => ( | ||
<List | ||
renderHeader={noop} | ||
renderFooter={noop} | ||
prefixCls='' | ||
onClick={noop} | ||
> | ||
<br /> | ||
<List.Item | ||
align='top' | ||
disabled | ||
multipleLine | ||
thumb='/' | ||
extra='/' | ||
arrow='' | ||
wrap='soft' | ||
prefixCls='' | ||
activeStyle={style} | ||
error | ||
platform='cross' | ||
onTouchEnd={noop} | ||
> | ||
<br /> | ||
<List.Item.Brief style={style}> | ||
<br /> | ||
</List.Item.Brief> | ||
</List.Item> | ||
</List> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,8 @@ | |
"exclude": [ | ||
"node_modules", | ||
"lib", | ||
"es" | ||
"es", | ||
"tests" | ||
], | ||
"compileOnSave": false | ||
} |