From ed4cc9e5fd58a07e92972c9fa1e30880f1921446 Mon Sep 17 00:00:00 2001 From: ztplz Date: Thu, 22 Nov 2018 23:35:40 +0800 Subject: [PATCH] format (#13252) --- components/card/index.tsx | 9 +++++++++ components/checkbox/Group.tsx | 3 +++ components/drawer/index.tsx | 7 +++++++ 3 files changed, 19 insertions(+) diff --git a/components/card/index.tsx b/components/card/index.tsx index 7f52e40a91..27f46fdf7a 100644 --- a/components/card/index.tsx +++ b/components/card/index.tsx @@ -60,6 +60,7 @@ export default class Card extends React.Component { 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 { 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 { }); } } + 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 { }); return containGrid; } + getAction(actions: React.ReactNode[]) { if (!actions || !actions.length) { return null; @@ -125,6 +132,7 @@ export default class Card extends React.Component { ); return actionList; } + // For 2.x compatible getCompatibleHoverable() { const { noHovering, hoverable } = this.props; @@ -133,6 +141,7 @@ export default class Card extends React.Component { } return !!hoverable; } + render() { const { prefixCls = 'ant-card', className, extra, headStyle = {}, bodyStyle = {}, noHovering, hoverable, title, loading, diff --git a/components/checkbox/Group.tsx b/components/checkbox/Group.tsx index 237c648aa0..ab19372ad0 100644 --- a/components/checkbox/Group.tsx +++ b/components/checkbox/Group.tsx @@ -88,6 +88,7 @@ class CheckboxGroup extends React.Component { const optionIndex = this.state.value.indexOf(option.value); const value = [...this.state.value]; @@ -117,6 +119,7 @@ class CheckboxGroup extends React.Component { 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 { } } } + close = (e: EventType) => { if (this.props.visible !== undefined) { if (this.props.onClose) { @@ -99,22 +101,26 @@ export default class Drawer extends React.Component { 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 { return `translateY(${placement === 'top' ? 180 : -180}px)`; } } + // render drawer body dom renderBody = () => { if (this.destoryClose && !this.props.visible) {