pull/9/head
tangjinzhou 2018-03-19 10:47:23 +08:00
parent 0d3ff16090
commit 7c8450a2a4
51 changed files with 192 additions and 232 deletions

15
.vscode/settings.json vendored
View File

@ -4,16 +4,27 @@
"eslint.options": { "eslint.options": {
"extensions": [ "extensions": [
".js", ".js",
".jsx",
".vue" ".vue"
], ],
"configFile": ".eslintrc" "configFile": ".eslintrc"
}, },
"eslint.validate": [ "eslint.validate": [
"javascript", {
"javascriptreact", "language": "html",
"autoFix": true
},
{ {
"language": "vue", "language": "vue",
"autoFix": true "autoFix": true
},
{
"language": "javascript",
"autoFix": true
},
{
"language": "javascriptreact",
"autoFix": true
} }
], ],
"emmet.syntaxProfiles": { "emmet.syntaxProfiles": {

View File

@ -85,4 +85,3 @@ export default {
}, },
} }

View File

@ -242,4 +242,3 @@ export default {
}, },
} }

View File

@ -130,4 +130,3 @@ export default {
}, },
} }

View File

@ -125,4 +125,3 @@ export default {
}, },
} }

View File

@ -52,4 +52,3 @@ export default {
}, },
} }

View File

@ -134,4 +134,3 @@ export default {
}, },
} }

View File

@ -131,4 +131,3 @@ export default {
}, },
} }

View File

@ -111,4 +111,3 @@ export default {
}, },
} }

View File

@ -135,4 +135,3 @@ export default {
}, },
} }

View File

@ -87,4 +87,3 @@ export default {
}, },
} }

View File

@ -1,33 +1,33 @@
import PropTypes from '../_util/vue-types' import PropTypes from '../_util/vue-types'
import { hasProp, getComponentFromProp } from '../_util/props-util' import { hasProp, getComponentFromProp } from '../_util/props-util'
export default { export default {
name: 'BreadcrumbItem', name: 'BreadcrumbItem',
__ANT_BREADCRUMB_ITEM: true, __ANT_BREADCRUMB_ITEM: true,
props: { props: {
prefixCls: PropTypes.string.def('ant-breadcrumb'), prefixCls: PropTypes.string.def('ant-breadcrumb'),
href: PropTypes.string, href: PropTypes.string,
separator: PropTypes.any, separator: PropTypes.any,
}, },
render () { render () {
const { prefixCls, $slots } = this const { prefixCls, $slots } = this
const children = $slots.default const children = $slots.default
let link let link
if (hasProp(this, 'href')) { if (hasProp(this, 'href')) {
link = <a class={`${prefixCls}-link`}>{children}</a> link = <a class={`${prefixCls}-link`}>{children}</a>
} else { } else {
link = <span class={`${prefixCls}-link`}>{children}</span> link = <span class={`${prefixCls}-link`}>{children}</span>
} }
if (children) { if (children) {
return ( return (
<span> <span>
{link} {link}
<span class={`${prefixCls}-separator`}>{getComponentFromProp(this, 'separator') || '/'}</span> <span class={`${prefixCls}-separator`}>{getComponentFromProp(this, 'separator') || '/'}</span>
</span> </span>
) )
} }
return null return null
}, },
} }

View File

@ -1,164 +1,164 @@
import Tabs from '../tabs' import Tabs from '../tabs'
import PropTypes from '../_util/vue-types' import PropTypes from '../_util/vue-types'
import addEventListener from '../_util/Dom/addEventListener' import addEventListener from '../_util/Dom/addEventListener'
import { getComponentFromProp, getComponentName } from '../_util/props-util' import { getComponentFromProp, getComponentName } from '../_util/props-util'
import throttleByAnimationFrame from '../_util/throttleByAnimationFrame' import throttleByAnimationFrame from '../_util/throttleByAnimationFrame'
import BaseMixin from '../_util/BaseMixin' import BaseMixin from '../_util/BaseMixin'
const { TabPane } = Tabs const { TabPane } = Tabs
export default { export default {
name: 'Card', name: 'Card',
mixins: [BaseMixin], mixins: [BaseMixin],
props: { props: {
prefixCls: PropTypes.string.def('ant-card'), prefixCls: PropTypes.string.def('ant-card'),
title: PropTypes.string, title: PropTypes.string,
extra: PropTypes.any, extra: PropTypes.any,
bordered: PropTypes.bool.def(true), bordered: PropTypes.bool.def(true),
bodyStyle: PropTypes.object, bodyStyle: PropTypes.object,
loading: PropTypes.bool.def(false), loading: PropTypes.bool.def(false),
hoverable: PropTypes.bool.def(false), hoverable: PropTypes.bool.def(false),
type: PropTypes.string, type: PropTypes.string,
actions: PropTypes.any, actions: PropTypes.any,
tabList: PropTypes.array, tabList: PropTypes.array,
}, },
data () { data () {
this.updateWiderPaddingCalled = false this.updateWiderPaddingCalled = false
return { return {
widerPadding: false, widerPadding: false,
}
},
beforeMount () {
this.updateWiderPadding = throttleByAnimationFrame(this.updateWiderPadding)
},
mounted () {
this.updateWiderPadding()
this.resizeEvent = addEventListener(window, 'resize', this.updateWiderPadding)
},
beforeDestroy () {
if (this.resizeEvent) {
this.resizeEvent.remove()
}
this.updateWiderPadding.cancel && this.updateWiderPadding.cancel()
},
methods: {
updateWiderPadding () {
const cardContainerRef = this.$refs.cardContainerRef
if (!cardContainerRef) {
return
}
// 936 is a magic card width pixer number indicated by designer
const WIDTH_BOUDARY_PX = 936
if (cardContainerRef.offsetWidth >= WIDTH_BOUDARY_PX && !this.widerPadding) {
this.setState({ widerPadding: true }, () => {
this.updateWiderPaddingCalled = true // first render without css transition
})
}
if (cardContainerRef.offsetWidth < WIDTH_BOUDARY_PX && this.widerPadding) {
this.setState({ widerPadding: false }, () => {
this.updateWiderPaddingCalled = true // first render without css transition
})
} }
}, },
beforeMount () { onHandleTabChange (key) {
this.updateWiderPadding = throttleByAnimationFrame(this.updateWiderPadding) this.$emit('tabChange', key)
}, },
mounted () { isContainGrid (obj = []) {
this.updateWiderPadding() let containGrid
this.resizeEvent = addEventListener(window, 'resize', this.updateWiderPadding) obj.forEach((element) => {
}, if (
beforeDestroy () { element &&
if (this.resizeEvent) {
this.resizeEvent.remove()
}
this.updateWiderPadding.cancel && this.updateWiderPadding.cancel()
},
methods: {
updateWiderPadding () {
const cardContainerRef = this.$refs.cardContainerRef
if (!cardContainerRef) {
return
}
// 936 is a magic card width pixer number indicated by designer
const WIDTH_BOUDARY_PX = 936
if (cardContainerRef.offsetWidth >= WIDTH_BOUDARY_PX && !this.widerPadding) {
this.setState({ widerPadding: true }, () => {
this.updateWiderPaddingCalled = true // first render without css transition
})
}
if (cardContainerRef.offsetWidth < WIDTH_BOUDARY_PX && this.widerPadding) {
this.setState({ widerPadding: false }, () => {
this.updateWiderPaddingCalled = true // first render without css transition
})
}
},
onHandleTabChange (key) {
this.$emit('tabChange', key)
},
isContainGrid (obj = []) {
let containGrid
obj.forEach((element) => {
if (
element &&
element.componentOptions && element.componentOptions &&
getComponentName(element.componentOptions) === 'Grid' getComponentName(element.componentOptions) === 'Grid'
) { ) {
containGrid = true containGrid = true
} }
}) })
return containGrid return containGrid
},
}, },
render () { },
const { render () {
prefixCls = 'ant-card', extra, bodyStyle, title, loading, const {
bordered = true, type, tabList, hoverable, prefixCls = 'ant-card', extra, bodyStyle, title, loading,
} = this.$props bordered = true, type, tabList, hoverable,
} = this.$props
const { $slots } = this const { $slots } = this
const classString = { const classString = {
[`${prefixCls}`]: true, [`${prefixCls}`]: true,
[`${prefixCls}-loading`]: loading, [`${prefixCls}-loading`]: loading,
[`${prefixCls}-bordered`]: bordered, [`${prefixCls}-bordered`]: bordered,
[`${prefixCls}-hoverable`]: !!hoverable, [`${prefixCls}-hoverable`]: !!hoverable,
[`${prefixCls}-wider-padding`]: this.widerPadding, [`${prefixCls}-wider-padding`]: this.widerPadding,
[`${prefixCls}-padding-transition`]: this.updateWiderPaddingCalled, [`${prefixCls}-padding-transition`]: this.updateWiderPaddingCalled,
[`${prefixCls}-contain-grid`]: this.isContainGrid($slots.default), [`${prefixCls}-contain-grid`]: this.isContainGrid($slots.default),
[`${prefixCls}-contain-tabs`]: tabList && tabList.length, [`${prefixCls}-contain-tabs`]: tabList && tabList.length,
[`${prefixCls}-type-${type}`]: !!type, [`${prefixCls}-type-${type}`]: !!type,
} }
const loadingBlock = ( const loadingBlock = (
<div class={`${prefixCls}-loading-content`}> <div class={`${prefixCls}-loading-content`}>
<p class={`${prefixCls}-loading-block`} style={{ width: '94%' }} /> <p class={`${prefixCls}-loading-block`} style={{ width: '94%' }} />
<p> <p>
<span class={`${prefixCls}-loading-block`} style={{ width: '28%' }} /> <span class={`${prefixCls}-loading-block`} style={{ width: '28%' }} />
<span class={`${prefixCls}-loading-block`} style={{ width: '62%' }} /> <span class={`${prefixCls}-loading-block`} style={{ width: '62%' }} />
</p> </p>
<p> <p>
<span class={`${prefixCls}-loading-block`} style={{ width: '22%' }} /> <span class={`${prefixCls}-loading-block`} style={{ width: '22%' }} />
<span class={`${prefixCls}-loading-block`} style={{ width: '66%' }} /> <span class={`${prefixCls}-loading-block`} style={{ width: '66%' }} />
</p> </p>
<p> <p>
<span class={`${prefixCls}-loading-block`} style={{ width: '56%' }} /> <span class={`${prefixCls}-loading-block`} style={{ width: '56%' }} />
<span class={`${prefixCls}-loading-block`} style={{ width: '39%' }} /> <span class={`${prefixCls}-loading-block`} style={{ width: '39%' }} />
</p> </p>
<p> <p>
<span class={`${prefixCls}-loading-block`} style={{ width: '21%' }} /> <span class={`${prefixCls}-loading-block`} style={{ width: '21%' }} />
<span class={`${prefixCls}-loading-block`} style={{ width: '15%' }} /> <span class={`${prefixCls}-loading-block`} style={{ width: '15%' }} />
<span class={`${prefixCls}-loading-block`} style={{ width: '40%' }} /> <span class={`${prefixCls}-loading-block`} style={{ width: '40%' }} />
</p> </p>
</div> </div>
) )
let head let head
const tabs = tabList && tabList.length ? ( const tabs = tabList && tabList.length ? (
<Tabs class={`${prefixCls}-head-tabs`} size='large' onChange={this.onHandleTabChange}> <Tabs class={`${prefixCls}-head-tabs`} size='large' onChange={this.onHandleTabChange}>
{tabList.map(item => <TabPane tab={item.tab} key={item.key} />)} {tabList.map(item => <TabPane tab={item.tab} key={item.key} />)}
</Tabs> </Tabs>
) : null ) : null
const titleDom = title || getComponentFromProp(this, 'title') const titleDom = title || getComponentFromProp(this, 'title')
const extraDom = extra || getComponentFromProp(this, 'extra') const extraDom = extra || getComponentFromProp(this, 'extra')
if (titleDom || extraDom || tabs) { if (titleDom || extraDom || tabs) {
head = ( head = (
<div class={`${prefixCls}-head`}> <div class={`${prefixCls}-head`}>
<div class={`${prefixCls}-head-wrapper`}> <div class={`${prefixCls}-head-wrapper`}>
{titleDom && <div class={`${prefixCls}-head-title`}>{titleDom}</div>} {titleDom && <div class={`${prefixCls}-head-title`}>{titleDom}</div>}
{extraDom && <div class={`${prefixCls}-extra`}>{extraDom}</div>} {extraDom && <div class={`${prefixCls}-extra`}>{extraDom}</div>}
</div>
{tabs}
</div> </div>
) {tabs}
}
const children = $slots.default
const cover = getComponentFromProp(this, 'cover')
const coverDom = cover ? <div class={`${prefixCls}-cover`}>{cover}</div> : null
const body = (
<div class={`${prefixCls}-body`} style={bodyStyle}>
{loading ? loadingBlock : children}
</div> </div>
) )
const actions = getComponentFromProp(this, 'actions') }
const actionDom = actions || null
return ( const children = $slots.default
<div class={classString} ref='cardContainerRef'> const cover = getComponentFromProp(this, 'cover')
{head} const coverDom = cover ? <div class={`${prefixCls}-cover`}>{cover}</div> : null
{coverDom} const body = (
{children ? body : null} <div class={`${prefixCls}-body`} style={bodyStyle}>
{actionDom} {loading ? loadingBlock : children}
</div> </div>
) )
}, const actions = getComponentFromProp(this, 'actions')
} const actionDom = actions || null
return (
<div class={classString} ref='cardContainerRef'>
{head}
{coverDom}
{children ? body : null}
{actionDom}
</div>
)
},
}

View File

@ -382,4 +382,3 @@ export default {
}, },
} }

View File

@ -80,4 +80,3 @@ export default {
}, },
} }

View File

@ -74,4 +74,3 @@ Dropdown.Button = DropdownButton
export default Dropdown export default Dropdown
export { DropdownProps } export { DropdownProps }

View File

@ -147,4 +147,3 @@ export default {
}, },
} }

View File

@ -68,5 +68,3 @@ export default {
}, },
} }

View File

@ -148,4 +148,3 @@ export default {
}, },
} }

View File

@ -1,5 +1,4 @@
export default { export default {
name: 'InputGruop', name: 'InputGruop',
props: { props: {

View File

@ -42,4 +42,3 @@ export default {
}, },
} }

View File

@ -69,4 +69,3 @@ export default {
}, },
} }

View File

@ -50,4 +50,3 @@ export default {
}, },
} }

View File

@ -251,4 +251,3 @@ export default {
}, },
} }

View File

@ -67,4 +67,3 @@ export default {
}, },
} }

View File

@ -68,4 +68,3 @@ export default {
}, },
} }

View File

@ -155,4 +155,3 @@ export default {
}, },
} }

View File

@ -114,4 +114,3 @@ export default {
}, },
} }

View File

@ -58,4 +58,3 @@ export default {
}, },
} }

View File

@ -171,4 +171,3 @@ export default {
}, },
} }

View File

@ -15,4 +15,3 @@ export default {
}, },
} }

View File

@ -14,4 +14,3 @@ export default {
}, },
} }

View File

@ -1,5 +1,4 @@
export default { export default {
name: 'CheckableTag', name: 'CheckableTag',
model: { model: {

View File

@ -25,4 +25,3 @@ export default {
}, },
} }

View File

@ -228,5 +228,3 @@ export default {
}, },
} }

View File

@ -25,4 +25,3 @@ export default {
}, },
} }

View File

@ -548,4 +548,3 @@ export default {
}, },
} }

View File

@ -320,4 +320,3 @@ export default {
}, },
} }

View File

@ -414,4 +414,3 @@ export default {
}, },
} }

View File

@ -84,4 +84,3 @@ const DialogWrap = {
export default DialogWrap export default DialogWrap

View File

@ -17,5 +17,3 @@ export default {
}, },
} }

View File

@ -39,4 +39,3 @@ export default {
}, },
} }

View File

@ -65,4 +65,3 @@ export default {
}, },
} }

View File

@ -146,4 +146,3 @@ Notification.newInstance = function newNotificationInstance (properties, callbac
export default Notification export default Notification

View File

@ -179,4 +179,3 @@ export default {
}, },
} }

View File

@ -1567,4 +1567,3 @@ export default {
}, },
} }

View File

@ -208,4 +208,3 @@ export default {
}, },
} }

View File

@ -4,7 +4,6 @@ import BaseMixin from '../_util/BaseMixin'
import debounce from 'lodash/debounce' import debounce from 'lodash/debounce'
import isFlexSupported from '../_util/isFlexSupported' import isFlexSupported from '../_util/isFlexSupported'
import { import {
getOptionProps,
filterEmpty, filterEmpty,
getEvents, getEvents,
getPropsData, getPropsData,

View File

@ -191,4 +191,3 @@ const Combobox = {
export default Combobox export default Combobox

View File

@ -96,4 +96,3 @@ export default {
}, },
} }

View File

@ -25,7 +25,7 @@
"test": "karma start test/karma.conf.js --single-run", "test": "karma start test/karma.conf.js --single-run",
"build": "sh build.sh", "build": "sh build.sh",
"dist": "node antd-tools/cli/run.js dist", "dist": "node antd-tools/cli/run.js dist",
"lint": "eslint -c ./.eslintrc --fix --ext .js ./components/time-picker/locale", "lint": "eslint -c ./.eslintrc --fix --ext .jsx ./components",
"lint:style": "stylelint \"./examples/**/*.less\" --fix --syntax less" "lint:style": "stylelint \"./examples/**/*.less\" --fix --syntax less"
}, },
"repository": { "repository": {
@ -38,7 +38,6 @@
}, },
"homepage": "https://github.com/vueComponent/ant-design", "homepage": "https://github.com/vueComponent/ant-design",
"pre-commit": [ "pre-commit": [
"lint",
"lint:style" "lint:style"
], ],
"devDependencies": { "devDependencies": {