Browse Source

format (#13252)

pull/13254/head
ztplz 6 years ago
committed by 偏右
parent
commit
ed4cc9e5fd
  1. 9
      components/card/index.tsx
  2. 3
      components/checkbox/Group.tsx
  3. 7
      components/drawer/index.tsx

9
components/card/index.tsx

@ -60,6 +60,7 @@ export default class Card extends React.Component<CardProps, CardState> {
private resizeEvent: any;
private updateWiderPaddingCalled: boolean = false;
private container: HTMLDivElement;
componentDidMount() {
this.updateWiderPadding();
this.resizeEvent = addEventListener(window, 'resize', this.updateWiderPadding);
@ -72,12 +73,14 @@ export default class Card extends React.Component<CardProps, CardState> {
warning(!!this.props.noHovering, '`noHovering={false}` of Card is deprecated, use `hoverable` instead.');
}
}
componentWillUnmount() {
if (this.resizeEvent) {
this.resizeEvent.remove();
}
(this.updateWiderPadding as any).cancel();
}
@throttleByAnimationFrameDecorator()
updateWiderPadding() {
if (!this.container) {
@ -96,14 +99,17 @@ export default class Card extends React.Component<CardProps, CardState> {
});
}
}
onTabChange = (key: string) => {
if (this.props.onTabChange) {
this.props.onTabChange(key);
}
}
saveRef = (node: HTMLDivElement) => {
this.container = node;
}
isContainGrid() {
let containGrid;
React.Children.forEach(this.props.children, (element: JSX.Element) => {
@ -113,6 +119,7 @@ export default class Card extends React.Component<CardProps, CardState> {
});
return containGrid;
}
getAction(actions: React.ReactNode[]) {
if (!actions || !actions.length) {
return null;
@ -125,6 +132,7 @@ export default class Card extends React.Component<CardProps, CardState> {
);
return actionList;
}
// For 2.x compatible
getCompatibleHoverable() {
const { noHovering, hoverable } = this.props;
@ -133,6 +141,7 @@ export default class Card extends React.Component<CardProps, CardState> {
}
return !!hoverable;
}
render() {
const {
prefixCls = 'ant-card', className, extra, headStyle = {}, bodyStyle = {}, noHovering, hoverable, title, loading,

3
components/checkbox/Group.tsx

@ -88,6 +88,7 @@ class CheckboxGroup extends React.Component<CheckboxGroupProps, CheckboxGroupSta
return !shallowEqual(this.props, nextProps) ||
!shallowEqual(this.state, nextState);
}
getOptions() {
const { options } = this.props;
// https://github.com/Microsoft/TypeScript/issues/7960
@ -101,6 +102,7 @@ class CheckboxGroup extends React.Component<CheckboxGroupProps, CheckboxGroupSta
return option;
});
}
toggleOption = (option: CheckboxOptionType) => {
const optionIndex = this.state.value.indexOf(option.value);
const value = [...this.state.value];
@ -117,6 +119,7 @@ class CheckboxGroup extends React.Component<CheckboxGroupProps, CheckboxGroupSta
onChange(value);
}
}
render() {
const { props, state } = this;
const { prefixCls, className, style, options, ...restProps } = props;

7
components/drawer/index.tsx

@ -82,6 +82,7 @@ export default class Drawer extends React.Component<DrawerProps, IDrawerState> {
parentDrawer: Drawer;
destoryClose: boolean;
public componentDidUpdate(preProps: DrawerProps) {
if (preProps.visible !== this.props.visible && this.parentDrawer) {
if (this.props.visible) {
@ -91,6 +92,7 @@ export default class Drawer extends React.Component<DrawerProps, IDrawerState> {
}
}
}
close = (e: EventType) => {
if (this.props.visible !== undefined) {
if (this.props.onClose) {
@ -99,22 +101,26 @@ export default class Drawer extends React.Component<DrawerProps, IDrawerState> {
return;
}
}
onMaskClick = (e: EventType) => {
if (!this.props.maskClosable) {
return;
}
this.close(e);
}
push = () => {
this.setState({
push: true,
});
}
pull = () => {
this.setState({
push: false,
});
}
onDestoryTransitionEnd = () => {
const isDestroyOnClose = this.getDestoryOnClose();
if (!isDestroyOnClose) {
@ -137,6 +143,7 @@ export default class Drawer extends React.Component<DrawerProps, IDrawerState> {
return `translateY(${placement === 'top' ? 180 : -180}px)`;
}
}
// render drawer body dom
renderBody = () => {
if (this.destoryClose && !this.props.visible) {

Loading…
Cancel
Save