-
Notifications
You must be signed in to change notification settings - Fork 753
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(components): 修复组件中 this 丢失的问题 完善组件的 defaultProps 和 d.ts 的逻辑
- Loading branch information
Showing
20 changed files
with
197 additions
and
67 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,26 +1,34 @@ | ||
import { MouseEvent, ComponentClass } from 'react' | ||
import { BaseEventFunction } from '@tarojs/components/types/common' | ||
|
||
export interface AtList { | ||
hasBorder?: boolean | ||
} | ||
|
||
export interface AtListItemProps { | ||
note: string | ||
hasBorder?: boolean | ||
|
||
title: string | ||
note?: string | ||
|
||
thumb: string | ||
title?: string | ||
|
||
isSwitch: boolean | ||
thumb?: string | ||
|
||
extraText: string | ||
isSwitch?: boolean | ||
|
||
extraThumb: string | ||
extraText?: string | ||
|
||
arrow: 'up' | 'down' | 'right' | ||
extraThumb?: string | ||
|
||
onClick: BaseEventFunction | ||
arrow?: 'up' | 'down' | 'right' | ||
|
||
onSwitchChange: BaseEventFunction | ||
onClick?: BaseEventFunction | ||
|
||
onSwitchChange?: BaseEventFunction | ||
} | ||
|
||
export const AtList: ComponentClass<AtList> | ||
|
||
declare const AtListItem: ComponentClass<AtListItemProps> | ||
|
||
export default AtListItem |
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
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
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,3 +1,5 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`List Snap render completed List -- no border 1`] = `"<div class=\\"at-list at-list--no-border\\"><div class=\\"at-list__item at-list__item--no-border\\">undefined<div class=\\"at-list__item-content item-content\\"><div class=\\"item-content__info\\"><div class=\\"item-content__info-title\\">标题文字</div>undefined</div></div><div class=\\"at-list__item-extra item-extra\\">undefinedundefinedundefinedundefined</div></div><div class=\\"at-list__item at-list__item--no-border\\">undefined<div class=\\"at-list__item-content item-content\\"><div class=\\"item-content__info\\"><div class=\\"item-content__info-title\\">标题文字</div>undefined</div></div><div class=\\"at-list__item-extra item-extra\\">undefinedundefinedundefinedundefined</div></div></div>"`; | ||
exports[`List Snap render completed List 1`] = `"<div class=\\"at-list\\"><div class=\\"at-list__item\\">undefined<div class=\\"at-list__item-content item-content\\"><div class=\\"item-content__info\\"><div class=\\"item-content__info-title\\">标题文字</div>undefined</div></div><div class=\\"at-list__item-extra item-extra\\">undefinedundefinedundefinedundefined</div></div><div class=\\"at-list__item\\">undefined<div class=\\"at-list__item-content item-content\\"><div class=\\"item-content__info\\"><div class=\\"item-content__info-title\\">标题文字</div>undefined</div></div><div class=\\"at-list__item-extra item-extra\\">undefinedundefinedundefined<div class=\\"item-extra__icon\\"><span style=\\"font-size:24px;color:#c7c7cc;\\" class=\\"taro-text at-icon at-icon-chevron-right\\"></span></div></div></div><div class=\\"at-list__item at-list__item--multiple\\">undefined<div class=\\"at-list__item-content item-content\\"><div class=\\"item-content__info\\"><div class=\\"item-content__info-title\\">标题文字</div><div class=\\"item-content__info-note\\">描述信息</div></div></div><div class=\\"at-list__item-extra item-extra\\">undefinedundefinedundefinedundefined</div></div><div class=\\"at-list__item at-list__item--multiple\\">undefined<div class=\\"at-list__item-content item-content\\"><div class=\\"item-content__info\\"><div class=\\"item-content__info-title\\">标题文字</div><div class=\\"item-content__info-note\\">描述信息</div></div></div><div class=\\"at-list__item-extra item-extra\\">undefinedundefinedundefined<div class=\\"item-extra__icon\\"><span style=\\"font-size:24px;color:#c7c7cc;\\" class=\\"taro-text at-icon at-icon-chevron-right\\"></span></div></div></div><div class=\\"at-list__item\\">undefined<div class=\\"at-list__item-content item-content\\"><div class=\\"item-content__info\\"><div class=\\"item-content__info-title\\">标题文字</div>undefined</div></div><div class=\\"at-list__item-extra item-extra\\"><div class=\\"item-extra__info\\">详细信息</div>undefinedundefined<div class=\\"item-extra__icon\\"><span style=\\"font-size:24px;color:#c7c7cc;\\" class=\\"taro-text at-icon at-icon-chevron-right\\"></span></div></div></div><div class=\\"at-list__item at-list__item--multiple\\">undefined<div class=\\"at-list__item-content item-content\\"><div class=\\"item-content__info\\"><div class=\\"item-content__info-title\\">标题文字标题文字标题文字标题文字标题文字</div><div class=\\"item-content__info-note\\">描述信息</div></div></div><div class=\\"at-list__item-extra item-extra\\"><div class=\\"item-extra__info\\">详细信息详细信息详细信息详细信息</div>undefinedundefined<div class=\\"item-extra__icon\\"><span style=\\"font-size:24px;color:#c7c7cc;\\" class=\\"taro-text at-icon at-icon-chevron-right\\"></span></div></div></div><div class=\\"at-list__item at-list__item--thumb at-list__item--multiple\\"><div class=\\"at-list__item-thumb item-thumb\\"><div class=\\"taro-img item-thumb-info\\"><img class=\\"taro-img__mode-scaletofill\\" src=\\"http://img12.360buyimg.com/jdphoto/s72x72_jfs/t10660/330/203667368/1672/801735d7/59c85643N31e68303.png\\"/></div></div><div class=\\"at-list__item-content item-content\\"><div class=\\"item-content__info\\"><div class=\\"item-content__info-title\\">标题文字</div><div class=\\"item-content__info-note\\">描述信息</div></div></div><div class=\\"at-list__item-extra item-extra\\"><div class=\\"item-extra__info\\">详细信息</div>undefinedundefined<div class=\\"item-extra__icon\\"><span style=\\"font-size:24px;color:#c7c7cc;\\" class=\\"taro-text at-icon at-icon-chevron-right\\"></span></div></div></div><div class=\\"at-list__item\\">undefined<div class=\\"at-list__item-content item-content\\"><div class=\\"item-content__info\\"><div class=\\"item-content__info-title\\">标题文字</div>undefined</div></div><div class=\\"at-list__item-extra item-extra\\">undefinedundefined<div class=\\"item-extra__switch\\"><input color=\\"#6190E8\\" class=\\"weui-switch\\" type=\\"checkbox\\"/></div>undefined</div></div></div>"`; |
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,10 +1,25 @@ | ||
import Taro, { Component } from '@tarojs/taro' | ||
import { View } from '@tarojs/components' | ||
|
||
import PropTypes from 'prop-types' | ||
|
||
import './index.scss' | ||
|
||
export default class AtList extends Component { | ||
render () { | ||
return <View className='at-list'>{this.props.children}</View> | ||
const rootClass = ['at-list'] | ||
|
||
if (!this.props.hasBorder) { | ||
rootClass.push('at-list--no-border') | ||
} | ||
return <View className={rootClass}>{this.props.children}</View> | ||
} | ||
} | ||
|
||
AtList.defaultProps = { | ||
hasBorder: true | ||
} | ||
|
||
AtList.propTypes = { | ||
hasBorder: PropTypes.bool | ||
} |
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
Oops, something went wrong.