Skip to content

Commit

Permalink
refactor: remove unused props
Browse files Browse the repository at this point in the history
  • Loading branch information
BANG88 committed Dec 13, 2018
1 parent 283d91d commit 01e96ef
Show file tree
Hide file tree
Showing 21 changed files with 69 additions and 123 deletions.
2 changes: 0 additions & 2 deletions components/date-picker-view/date-picker-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ export default class DatePickerView extends React.Component<
static defaultProps = {
mode: 'datetime',
// extra: '请选择',
prefixCls: 'am-picker',
pickerPrefixCls: 'am-picker-col',
minuteStep: 1,
use12Hours: false,
};
Expand Down
1 change: 1 addition & 0 deletions components/date-picker/PropsType.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export interface DatePickerPropsType {
onChange?: (value: Date) => void;
onValueChange?: (vals: any, index: number) => void;
visible?: boolean;
use12Hours?: boolean;
onDismiss?: () => void;
locale?: {
okText: string;
Expand Down
25 changes: 5 additions & 20 deletions components/date-picker/datepicker/DatePicker.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import MultiPicker from '../../picker/MultiPicker';
import Picker from '../../picker/Picker';
import IDatePickerProps from './IDatePickerProps';
import DatePickerProps from './DatePickerProps';
import defaultLocale from './locale/en_US';

function getDaysInMonth(date: any) {
Expand Down Expand Up @@ -33,7 +33,7 @@ const MONTH = 'month';
const YEAR = 'year';
const ONE_DAY = 24 * 60 * 60 * 1000;

class DatePicker extends React.Component<IDatePickerProps, any> {
class DatePicker extends React.Component<DatePickerProps, any> {
static defaultProps = {
prefixCls: 'rmc-date-picker',
pickerPrefixCls: 'rmc-picker',
Expand Down Expand Up @@ -495,26 +495,12 @@ class DatePicker extends React.Component<IDatePickerProps, any> {

render() {
const { value, cols } = this.getValueCols();
const {
disabled,
pickerPrefixCls,
prefixCls,
rootNativeProps,
className,
style,
itemStyle,
} = this.props;
const multiStyle = {
flexDirection: 'row',
alignItems: 'center',
...style,
};
const { disabled, rootNativeProps, style, itemStyle } = this.props;

return (
<MultiPicker
style={multiStyle}
style={[{ flexDirection: 'row', alignItems: 'center' }, style]}
rootNativeProps={rootNativeProps}
className={className}
prefixCls={prefixCls}
selectedValue={value}
onValueChange={this.onValueChange}
onScrollChange={this.onScrollChange}
Expand All @@ -524,7 +510,6 @@ class DatePicker extends React.Component<IDatePickerProps, any> {
style={{ flex: 1 }}
key={p.key}
disabled={disabled}
prefixCls={pickerPrefixCls}
itemStyle={itemStyle}
>
{p.props.children.map((item: any) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
interface IDatePickerProps {
import { StyleProp, ViewStyle } from "react-native";

interface DatePickerProps {
date?: any;
defaultDate?: any;
minDate?: any;
Expand All @@ -11,16 +13,11 @@ interface IDatePickerProps {
formatDay?: (day: number, date?: any) => any;
onDateChange?: (date: any) => void;
onValueChange?: (vals: any, index: number) => void;
itemStyle?: any;
style?: any;
/** web only */
prefixCls?: string;
/** web only */
itemStyle?: StyleProp<ViewStyle>;
style?: StyleProp<ViewStyle>;
onScrollChange?: (date: any, vals: any, index: number) => void;
rootNativeProps?: {};
pickerPrefixCls?: string;
className?: string;
use12Hours?: boolean;
}

export default IDatePickerProps;
export default DatePickerProps;
10 changes: 5 additions & 5 deletions components/date-picker/datepicker/Popup.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import React from 'react';
import PopupPicker from '../../picker/Popup';
import { IPopupPickerProps } from '../../picker/PopupPickerTypes';
import IDatePickerProps from './IDatePickerProps';
import { PopupPickerProps } from '../../picker/PopupPickerTypes';
import DatePickerProps from './DatePickerProps';

export interface IPopupDatePickerProps extends IPopupPickerProps {
datePicker: React.ReactElement<IDatePickerProps>;
export interface PopupDatePickerProps extends PopupPickerProps {
datePicker: React.ReactElement<DatePickerProps>;
onChange?: (date?: any) => void;
date?: any;
}

class PopupDatePicker extends React.Component<IPopupDatePickerProps, any> {
class PopupDatePicker extends React.Component<PopupDatePickerProps, any> {
static defaultProps = {
pickerValueProp: 'date',
pickerValueChangeProp: 'onDateChange',
Expand Down
2 changes: 1 addition & 1 deletion components/date-picker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export interface DatePickerProps
export default class DatePicker extends React.Component<DatePickerProps> {
static defaultProps = {
mode: 'datetime',
triggerType: 'onClick',
triggerType: 'onPress',
minuteStep: 1,
};
static contextTypes = {
Expand Down
15 changes: 4 additions & 11 deletions components/picker-view/PickerView.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@

import React from 'react';
import { StyleProp, ViewStyle } from 'react-native';
import RMCCascader from '../picker/cascader';
import MultiPicker from '../picker/MultiPicker';
import RMCPicker from '../picker/Picker';
import { PickerData } from '../picker/PropsType';

function getDefaultProps() {
return {
prefixCls: 'am-picker',
pickerPrefixCls: 'am-picker-col',
cols: 3,
cascade: true,
value: [],
Expand All @@ -17,29 +16,26 @@ function getDefaultProps() {
}

export interface PickerViewProps {
prefixCls?: string;
pickerPrefixCls?: string;
cols?: number;
cascade?: boolean;
value?: any[];
data?: PickerData[] | PickerData[][];
styles?: any;
onChange?: (value?: any) => void;
onScrollChange?: (value?: any) => void;
indicatorStyle?: any;
itemStyle?: any;
indicatorStyle?: StyleProp<ViewStyle>;
itemStyle?: StyleProp<ViewStyle>;
}

export default class PickerView extends React.Component<PickerViewProps, any> {
static defaultProps = getDefaultProps();

getCol = () => {
const { data, pickerPrefixCls, indicatorStyle, itemStyle } = this.props;
const { data, indicatorStyle, itemStyle } = this.props;
return (data as PickerData[][]).map((col, index) => {
return (
<RMCPicker
key={index}
prefixCls={pickerPrefixCls}
style={{ flex: 1 }}
indicatorStyle={indicatorStyle}
itemStyle={itemStyle}
Expand All @@ -62,8 +58,6 @@ export default class PickerView extends React.Component<PickerViewProps, any> {
if (props.cascade) {
picker = (
<RMCCascader
prefixCls={props.prefixCls}
pickerPrefixCls={props.pickerPrefixCls}
data={props.data as PickerData[]}
value={props.value}
onChange={props.onChange}
Expand All @@ -76,7 +70,6 @@ export default class PickerView extends React.Component<PickerViewProps, any> {
} else {
picker = (
<MultiPicker
prefixCls={props.prefixCls}
selectedValue={props.value}
onValueChange={props.onChange}
onScrollChange={props.onScrollChange}
Expand Down
4 changes: 2 additions & 2 deletions components/picker/MultiPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { View } from 'react-native';
import MultiPickerMixin from './MultiPickerMixin';
import MultiPickerProps from './MultiPickerProps';

export interface IMultiPickerProp {
export interface MultiPickerProp {
getValue: Function;
}

const MultiPicker = (props: IMultiPickerProp & MultiPickerProps) => {
const MultiPicker = (props: MultiPickerProp & MultiPickerProps) => {
const { children, style } = props;
const selectedValue = props.getValue();
const colElements = React.Children.map(children, (col: any, i) => {
Expand Down
6 changes: 3 additions & 3 deletions components/picker/MultiPickerProps.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { StyleProp, ViewStyle } from "react-native";

export interface PickerCol {
key?: string;
props?: any;
}

interface MultiPickerProps {
prefixCls?: string;
selectedValue?: any[];
className?: string;
rootNativeProps?: any;
onValueChange?: (v?: any, i?: number) => void;
children?: any;
style?: any;
style?: StyleProp<ViewStyle>;
onScrollChange?: (v?: any, i?: number) => void;
}

Expand Down
2 changes: 1 addition & 1 deletion components/picker/Picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Picker extends React.Component<PickerProps, {}> {
children: [],
};

static Item(): any {}
static Item: any = () => {};

getValue() {
if ('selectedValue' in this.props) {
Expand Down
5 changes: 2 additions & 3 deletions components/picker/PickerMixin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
import React from 'react';
import { PickerProps } from './PickerTypes';

type IItemProps = {
className?: string;
type ItemProps = {
value: any;
};

const Item = (_props: IItemProps) => null;
const Item = (_props: ItemProps) => null;

export default function(ComposedComponent: any) {
return class extends React.Component<PickerProps, any> {
Expand Down
11 changes: 5 additions & 6 deletions components/picker/PickerTypes.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { StyleProp, ViewStyle } from "react-native";

export type PickerProps = {
disabled?: boolean;
selectedValue?: any;
onValueChange?: (value: any) => void;
itemStyle?: any;
/** web only */
prefixCls?: string;
indicatorStyle?: any;
itemStyle?: StyleProp<ViewStyle>;
indicatorStyle?: StyleProp<ViewStyle>;
indicatorClassName?: string;
className?: string;
defaultSelectedValue?: any;
style?: any;
style?: StyleProp<ViewStyle>;
onScrollChange?: (value: any) => void;
noAnimate?: boolean;
};
6 changes: 3 additions & 3 deletions components/picker/PopupMixin.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { View } from 'react-native';
import { IPopupPickerProps } from './PopupPickerTypes';
import { PopupPickerProps } from './PopupPickerTypes';

export default function PopupMixin(
getModal: (
Expand All @@ -16,7 +16,7 @@ export default function PopupMixin(
WrapComponent: View;
},
) {
return class extends React.Component<IPopupPickerProps, any> {
return class extends React.Component<PopupPickerProps, any> {
static defaultProps = {
onVisibleChange(_: any) {},
okText: 'Ok',
Expand All @@ -29,7 +29,7 @@ export default function PopupMixin(

picker: any;

constructor(props: Readonly<IPopupPickerProps>) {
constructor(props: Readonly<PopupPickerProps>) {
super(props);

this.state = {
Expand Down
6 changes: 1 addition & 5 deletions components/picker/PopupPickerTypes.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

export type IPopupPickerProps = {
export type PopupPickerProps = {
picker?: any;
value?: any;
triggerType?: string;
Expand All @@ -15,14 +15,10 @@ export type IPopupPickerProps = {
onVisibleChange?: (visible: boolean) => void;
content?: React.ReactElement<any> | string;
onDismiss?: () => void;
/** react-native only */
styles?: any;
actionTextUnderlayColor?: string;
actionTextActiveOpacity?: number;
/** web only */
wrapStyle?: React.CSSProperties;
prefixCls?: string;
className?: string;
pickerValueProp?: string;
pickerValueChangeProp?: string;
transitionName?: string;
Expand Down
9 changes: 5 additions & 4 deletions components/picker/PropsType.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { StyleProp, ViewStyle } from 'react-native';
import { Omit } from 'utility-types';
import { CascaderValue } from './cascader/CascaderTypes';
import { IPopupPickerProps } from './PopupPickerTypes';
import { PopupPickerProps } from './PopupPickerTypes';
export interface PickerData {
value: string | number;
label: string;
children?: PickerData[];
}
export interface PickerPropsType extends Omit<IPopupPickerProps, 'styles'> {
export interface PickerPropsType extends Omit<PopupPickerProps, 'styles'> {
data: PickerData[] | PickerData[][];
cascade?: boolean;
value?: Array<string | number>;
Expand All @@ -15,6 +16,6 @@ export interface PickerPropsType extends Omit<IPopupPickerProps, 'styles'> {
extra?: string;
onChange?: (date?: CascaderValue) => void;
onPickerChange?: (value: CascaderValue) => void;
itemStyle?: any;
indicatorStyle?: any;
itemStyle?: StyleProp<ViewStyle>;
indicatorStyle?: StyleProp<ViewStyle>;
}
Loading

0 comments on commit 01e96ef

Please sign in to comment.