diff --git a/.gitignore b/.gitignore index 9c887521b..ee76b414f 100644 --- a/.gitignore +++ b/.gitignore @@ -55,6 +55,7 @@ typings/ .yarn-integrity # dotenv environment variables file +.vscode .env .idea .DS_Store diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 8090fa64a..000000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,42 +0,0 @@ -// 将设置放入此文件中以覆盖默认值和用户设置。 -{ - "eslint.enable": true, - "eslint.options": { - "extensions": [ - ".js", - ".jsx", - ".vue" - ], - "configFile": ".eslintrc" - }, - "eslint.validate": [ - { - "language": "html", - "autoFix": true - }, - { - "language": "vue", - "autoFix": true - }, - { - "language": "javascript", - "autoFix": true - }, - { - "language": "javascriptreact", - "autoFix": true - } - ], - "emmet.syntaxProfiles": { - "vue-html": "html", - "vue": "html" - }, - "eslint.autoFixOnSave": true, - "vetur.validation.template": true, - "vetur.format.html.wrap_line_length": 60, - "vetur.format.js.InsertSpaceBeforeFunctionParenthesis": true, - "stylefmt.config": { - "fix": true - }, - "editor.tabSize": 2 -} diff --git a/CHANGELOG.en-US.md b/CHANGELOG.en-US.md index ab4516d4f..64dba783b 100644 --- a/CHANGELOG.en-US.md +++ b/CHANGELOG.en-US.md @@ -2,6 +2,33 @@ --- +## 0.5.1 + +`2018-05-10` + +- 🐞 `Table`: Fix `customRow` events not working[#16](https://github.com/vueComponent/ant-design/issues/16) + +## 0.5.0 + +`2018-05-08` + +- 🌟 `Form`: add Form component +- 💄 `Upload.Dragger`: Modify `name` name to `a-upload-dragger` +- 🐞 `Upload`: Fix `name` prop not working + +## 0.4.3 + +`2018-05-02` + +- 🐞 Fix component style loss problem +- 🌟 site add babel-polyfill + +## 0.4.2 + +`2018-04-24` + +- 🐞 fix menu click bug + ## 0.4.1 #### bug diff --git a/CHANGELOG.zh-CN.md b/CHANGELOG.zh-CN.md index 7cc218217..deb35c341 100644 --- a/CHANGELOG.zh-CN.md +++ b/CHANGELOG.zh-CN.md @@ -2,6 +2,34 @@ --- +## 0.5.1 + +`2018-05-10` + +- 🐞 `Table`: 修复 `customRow` 自定义事件不生效问题[#16](https://github.com/vueComponent/ant-design/issues/16) + +## 0.5.0 + +`2018-05-08` + +- 🌟 `Form `新增Form表单组件 +- 💄 `Upload.Dragger`: 修改组件name名称为`a-upload-dragger` +- 🐞 `Upload`: 修复Upload name属性失效问题 + + +## 0.4.3 + +`2018-05-02` + +- 🐞 修复组件样式丢失问题 +- 🌟 站点添加babel-polyfill + +## 0.4.2 + +`2018-04-24` + +- 🐞 修复menu 非 inline 模式下的 click bug + ## 0.4.1 #### bug diff --git a/README-zh_CN.md b/README-zh_CN.md index f461570c2..2fead4df9 100644 --- a/README-zh_CN.md +++ b/README-zh_CN.md @@ -13,6 +13,7 @@ Ant Design 3.X 的 Vue 实现,开发和服务于企业级后台产品。 +[官网国内镜像](http://tangjinzhou.gitee.io/ant-design/docs/vue/introduce-cn/) [README in English](README.md) diff --git a/README.md b/README.md index fad50ae1e..70c435791 100644 --- a/README.md +++ b/README.md @@ -14,12 +14,14 @@ An enterprise-class UI components based on Ant Design 3.X and Vue. +[官网国内镜像](http://tangjinzhou.gitee.io/ant-design/docs/vue/introduce-cn/) + [中文 README](README-zh_CN.md) ## Features - An enterprise-class UI design system for desktop applications. -- A set of high-quality React components out of the box. +- A set of high-quality Vue components out of the box. - Shared [Ant Design of React](https://ant.design/docs/spec/introduce) design resources. diff --git a/antd-tools/getBabelCommonConfig.js b/antd-tools/getBabelCommonConfig.js index 2267edcd3..e840044ec 100644 --- a/antd-tools/getBabelCommonConfig.js +++ b/antd-tools/getBabelCommonConfig.js @@ -7,6 +7,7 @@ module.exports = function (modules) { require.resolve('babel-plugin-transform-es3-property-literals'), require.resolve('babel-plugin-transform-object-assign'), require.resolve('babel-plugin-transform-object-rest-spread'), + require.resolve('babel-plugin-transform-class-properties'), ] plugins.push([require.resolve('babel-plugin-transform-runtime'), { polyfill: false, diff --git a/antd-tools/gulpfile.js b/antd-tools/gulpfile.js index c340cbddf..0bffc5751 100644 --- a/antd-tools/gulpfile.js +++ b/antd-tools/gulpfile.js @@ -78,12 +78,12 @@ function babelify (js, modules) { let stream = js.pipe(babel(babelConfig)) .pipe(through2.obj(function z (file, encoding, next) { this.push(file.clone()) - if (file.path.match(/\/style\/index\.js/)) { + if (file.path.match(/\/style\/index\.(js|jsx)$/)) { const content = file.contents.toString(encoding) file.contents = Buffer.from(content .replace(/\/style\/?'/g, '/style/css\'') .replace(/\.less/g, '.css')) - file.path = file.path.replace(/index\.js/, 'css.js') + file.path = file.path.replace(/index\.(js|jsx)$/, 'css.js') this.push(file) next() } else { @@ -238,15 +238,25 @@ function pub (done) { gulp.task('dist', ['compile'], (done) => { dist(done) }) -gulp.task('compile', ['compile-with-es'], () => { +gulp.task('compile', ['compile-with-es'], (done) => { compile() + .on('finish', function () { + done() + }) }) -gulp.task('compile-with-es', () => { +gulp.task('compile-with-es', (done) => { compile(false) + .on('finish', function () { + done() + }) }) gulp.task('pub', ['check-git', 'compile'], (done) => { - pub(done) + if (!process.env.GITHUB_TOKEN) { + console.log('no GitHub token found, skip') + } else { + pub(done) + } }) function reportError () { diff --git a/components/_util/ContainerRender.jsx b/components/_util/ContainerRender.jsx index 9540e6db4..523922b95 100644 --- a/components/_util/ContainerRender.jsx +++ b/components/_util/ContainerRender.jsx @@ -1,6 +1,8 @@ import Vue from 'vue' import PropTypes from './vue-types' +import antRefDirective from './antRefDirective' +Vue.use(antRefDirective) export default { props: { diff --git a/components/_util/antRefDirective.js b/components/_util/antRefDirective.js new file mode 100644 index 000000000..c7d0afde4 --- /dev/null +++ b/components/_util/antRefDirective.js @@ -0,0 +1,12 @@ +export default { + install: (Vue, options) => { + Vue.directive('ant-ref', { + bind: function (el, binding, vnode) { + binding.value(vnode) + }, + unbind: function (el, binding, vnode) { + binding.value() + }, + }) + }, +} diff --git a/components/_util/props-util.js b/components/_util/props-util.js index 6211c7bc5..a78030095 100644 --- a/components/_util/props-util.js +++ b/components/_util/props-util.js @@ -1,5 +1,10 @@ import isPlainObject from 'lodash/isPlainObject' +function getType (fn) { + const match = fn && fn.toString().match(/^\s*function (\w+)/) + return match ? match[1] : '' +} + const camelizeRE = /-(\w)/g const camelize = (str) => { return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : '') @@ -40,9 +45,9 @@ const filterProps = (props, propsData = {}) => { return res } const getSlots = (ele) => { - let componentOptions = ele.componentOptions + let componentOptions = ele.componentOptions || {} if (ele.$vnode) { - componentOptions = ele.$vnode.componentOptions + componentOptions = ele.$vnode.componentOptions || {} } const children = componentOptions.children || [] const slots = {} @@ -67,8 +72,11 @@ const getOptionProps = (instance) => { const props = (Ctor.options || {}).props || {} const res = {} for (const [k, v] of Object.entries(props)) { - if (v.default !== undefined) { - res[k] = typeof v.default === 'function' ? v.default() : v.default + const def = v.default + if (def !== undefined) { + res[k] = typeof def === 'function' && getType(v.type) !== 'Function' + ? def.call(instance) + : def } } return { ...res, ...propsData } diff --git a/components/_util/vnode.js b/components/_util/vnode.js index 4f7e91e0c..a7e40ec98 100644 --- a/components/_util/vnode.js +++ b/components/_util/vnode.js @@ -60,7 +60,7 @@ export function cloneElement (n, nodeProps, deep) { return null } const node = cloneVNode(ele, deep) - const { props = {}, key, on = {}, children } = nodeProps + const { props = {}, key, on = {}, children, directives = [] } = nodeProps const data = node.data || {} let cls = {} let style = {} @@ -101,6 +101,7 @@ export function cloneElement (n, nodeProps, deep) { class: cls, domProps: { ...data.domProps, ...domProps }, scopedSlots: { ...data.scopedSlots, ...scopedSlots }, + directives: [...(data.directives || []), ...directives], }) if (node.componentOptions) { diff --git a/components/auto-complete/index.jsx b/components/auto-complete/index.jsx index 94d0c5033..0001d782b 100644 --- a/components/auto-complete/index.jsx +++ b/components/auto-complete/index.jsx @@ -4,7 +4,7 @@ import Select, { AbstractSelectProps, SelectValue } from '../select' import Input from '../input' import InputElement from './InputElement' import PropTypes from '../_util/vue-types' -import { getComponentFromProp, getOptionProps, filterEmpty } from '../_util/props-util' +import { getComponentFromProp, getOptionProps, filterEmpty, isValidElement, getEvents, getStyle, getClass } from '../_util/props-util' const DataSourceItemObject = PropTypes.shape({ value: String, @@ -24,7 +24,7 @@ const AutoCompleteProps = { ...AbstractSelectProps, value: SelectValue, defaultValue: SelectValue, - dataSource: PropTypes.arrayOf(DataSourceItemType), + dataSource: PropTypes.array, optionLabelProp: String, dropdownMatchSelectWidth: PropTypes.bool, // onChange?: (value: SelectValue) => void; @@ -57,6 +57,13 @@ export default { const { $slots } = this const children = filterEmpty($slots.default) const element = children.length ? children[0] : + console.log(element) + const eleProps = { + props: getOptionProps(element), + on: getEvents(element), + style: getStyle(element), + class: getClass(element), + } return ( {element} ) @@ -97,6 +104,9 @@ export default { options = childArray } else { options = dataSource ? dataSource.map((item) => { + if (isValidElement(item)) { + return item + } switch (typeof item) { case 'string': return diff --git a/components/cascader/index.jsx b/components/cascader/index.jsx index 69727cff7..b73dd7213 100644 --- a/components/cascader/index.jsx +++ b/components/cascader/index.jsx @@ -7,7 +7,7 @@ import omit from 'omit.js' import KeyCode from '../_util/KeyCode' import Input from '../input' import Icon from '../icon' -import { hasProp, filterEmpty, getOptionProps } from '../_util/props-util' +import { hasProp, filterEmpty, getOptionProps, getStyle, getClass, getAttrs } from '../_util/props-util' import BaseMixin from '../_util/BaseMixin' const CascaderOptionType = PropTypes.shape({ @@ -83,6 +83,7 @@ function defaultSortFilteredOption (a, b, inputValue) { const defaultDisplayRender = ({ labels }) => labels.join(' / ') export default { + inheritAttrs: false, name: 'ACascader', mixins: [BaseMixin], props: CascaderProps, @@ -280,6 +281,7 @@ export default { [`${prefixCls}-picker-arrow-expand`]: sPopupVisible, }) const pickerCls = classNames( + getClass(this), `${prefixCls}-picker`, { [`${prefixCls}-picker-with-value`]: inputValue, [`${prefixCls}-picker-disabled`]: disabled, @@ -345,11 +347,13 @@ export default { keydown: this.handleKeyDown, change: showSearch ? this.handleInputChange : noop, }, + attrs: getAttrs(this), } const children = filterEmpty($slots.default) const input = children.length ? children : ( { showSearch ? {this.getLabel()} diff --git a/components/checkbox/Checkbox.jsx b/components/checkbox/Checkbox.jsx index af96818ae..f9508a8c3 100644 --- a/components/checkbox/Checkbox.jsx +++ b/components/checkbox/Checkbox.jsx @@ -1,6 +1,8 @@ - -import hasProp from '../_util/props-util' +import classNames from 'classnames' +import hasProp, { getClass, getStyle } from '../_util/props-util' +import PropTypes from '../_util/vue-types' export default { + inheritAttrs: false, name: 'ACheckbox', props: { prefixCls: { @@ -14,6 +16,7 @@ export default { value: [String, Number, Boolean], name: String, indeterminate: Boolean, + type: PropTypes.string.def('checkbox'), }, model: { prop: 'checked', @@ -52,14 +55,13 @@ export default { handleChange (event) { const targetChecked = event.target.checked this.$emit('input', targetChecked) - const { name, value, checked, checkboxGroupContext, sChecked } = this + const { checked, checkboxGroupContext } = this if ((checked === undefined && !checkboxGroupContext) || (checkboxGroupContext && checkboxGroupContext.sValue === undefined)) { this.sChecked = targetChecked } const target = { - name, - value, - checked: !sChecked, + ...this.$props, + checked: targetChecked, } this.$emit('change', { target, @@ -103,9 +105,13 @@ export default { onChange = () => checkboxGroupContext.toggleOption({ value: props.value }) disabled = props.disabled || checkboxGroupContext.disabled } + const classString = classNames(getClass(this), { + [`${prefixCls}-wrapper`]: true, + }) return (