Skip to content

Commit 5688bc2

Browse files
committed
Merge branch 'feature-form'
2 parents c70baf8 + e9a96dd commit 5688bc2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+7205
-215
lines changed

antd-tools/getBabelCommonConfig.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ module.exports = function (modules) {
77
require.resolve('babel-plugin-transform-es3-property-literals'),
88
require.resolve('babel-plugin-transform-object-assign'),
99
require.resolve('babel-plugin-transform-object-rest-spread'),
10+
require.resolve('babel-plugin-transform-class-properties'),
1011
]
1112
plugins.push([require.resolve('babel-plugin-transform-runtime'), {
1213
polyfill: false,

components/_util/ContainerRender.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11

22
import Vue from 'vue'
33
import PropTypes from './vue-types'
4+
import antRefDirective from './antRefDirective'
5+
Vue.use(antRefDirective)
46

57
export default {
68
props: {

components/_util/antRefDirective.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
export default {
2+
install: (Vue, options) => {
3+
Vue.directive('ant-ref', {
4+
bind: function (el, binding, vnode) {
5+
binding.value(vnode)
6+
},
7+
unbind: function (el, binding, vnode) {
8+
binding.value()
9+
},
10+
})
11+
},
12+
}

components/_util/props-util.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import isPlainObject from 'lodash/isPlainObject'
22

3+
function getType (fn) {
4+
const match = fn && fn.toString().match(/^\s*function (\w+)/)
5+
return match ? match[1] : ''
6+
}
7+
38
const camelizeRE = /-(\w)/g
49
const camelize = (str) => {
510
return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : '')
@@ -40,9 +45,9 @@ const filterProps = (props, propsData = {}) => {
4045
return res
4146
}
4247
const getSlots = (ele) => {
43-
let componentOptions = ele.componentOptions
48+
let componentOptions = ele.componentOptions || {}
4449
if (ele.$vnode) {
45-
componentOptions = ele.$vnode.componentOptions
50+
componentOptions = ele.$vnode.componentOptions || {}
4651
}
4752
const children = componentOptions.children || []
4853
const slots = {}
@@ -67,8 +72,11 @@ const getOptionProps = (instance) => {
6772
const props = (Ctor.options || {}).props || {}
6873
const res = {}
6974
for (const [k, v] of Object.entries(props)) {
70-
if (v.default !== undefined) {
71-
res[k] = typeof v.default === 'function' ? v.default() : v.default
75+
const def = v.default
76+
if (def !== undefined) {
77+
res[k] = typeof def === 'function' && getType(v.type) !== 'Function'
78+
? def.call(instance)
79+
: def
7280
}
7381
}
7482
return { ...res, ...propsData }

components/_util/vnode.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export function cloneElement (n, nodeProps, deep) {
6060
return null
6161
}
6262
const node = cloneVNode(ele, deep)
63-
const { props = {}, key, on = {}, children } = nodeProps
63+
const { props = {}, key, on = {}, children, directives = [] } = nodeProps
6464
const data = node.data || {}
6565
let cls = {}
6666
let style = {}
@@ -101,6 +101,7 @@ export function cloneElement (n, nodeProps, deep) {
101101
class: cls,
102102
domProps: { ...data.domProps, ...domProps },
103103
scopedSlots: { ...data.scopedSlots, ...scopedSlots },
104+
directives: [...(data.directives || []), ...directives],
104105
})
105106

106107
if (node.componentOptions) {

components/auto-complete/index.jsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Select, { AbstractSelectProps, SelectValue } from '../select'
44
import Input from '../input'
55
import InputElement from './InputElement'
66
import PropTypes from '../_util/vue-types'
7-
import { getComponentFromProp, getOptionProps, filterEmpty } from '../_util/props-util'
7+
import { getComponentFromProp, getOptionProps, filterEmpty, isValidElement, getEvents, getStyle, getClass } from '../_util/props-util'
88

99
const DataSourceItemObject = PropTypes.shape({
1010
value: String,
@@ -24,7 +24,7 @@ const AutoCompleteProps = {
2424
...AbstractSelectProps,
2525
value: SelectValue,
2626
defaultValue: SelectValue,
27-
dataSource: PropTypes.arrayOf(DataSourceItemType),
27+
dataSource: PropTypes.array,
2828
optionLabelProp: String,
2929
dropdownMatchSelectWidth: PropTypes.bool,
3030
// onChange?: (value: SelectValue) => void;
@@ -57,6 +57,13 @@ export default {
5757
const { $slots } = this
5858
const children = filterEmpty($slots.default)
5959
const element = children.length ? children[0] : <Input />
60+
console.log(element)
61+
const eleProps = {
62+
props: getOptionProps(element),
63+
on: getEvents(element),
64+
style: getStyle(element),
65+
class: getClass(element),
66+
}
6067
return (
6168
<InputElement>{element}</InputElement>
6269
)
@@ -97,6 +104,9 @@ export default {
97104
options = childArray
98105
} else {
99106
options = dataSource ? dataSource.map((item) => {
107+
if (isValidElement(item)) {
108+
return item
109+
}
100110
switch (typeof item) {
101111
case 'string':
102112
return <Option key={item}>{item}</Option>

components/cascader/index.jsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import omit from 'omit.js'
77
import KeyCode from '../_util/KeyCode'
88
import Input from '../input'
99
import Icon from '../icon'
10-
import { hasProp, filterEmpty, getOptionProps } from '../_util/props-util'
10+
import { hasProp, filterEmpty, getOptionProps, getStyle, getClass, getAttrs } from '../_util/props-util'
1111
import BaseMixin from '../_util/BaseMixin'
1212

1313
const CascaderOptionType = PropTypes.shape({
@@ -83,6 +83,7 @@ function defaultSortFilteredOption (a, b, inputValue) {
8383
const defaultDisplayRender = ({ labels }) => labels.join(' / ')
8484

8585
export default {
86+
inheritAttrs: false,
8687
name: 'ACascader',
8788
mixins: [BaseMixin],
8889
props: CascaderProps,
@@ -280,6 +281,7 @@ export default {
280281
[`${prefixCls}-picker-arrow-expand`]: sPopupVisible,
281282
})
282283
const pickerCls = classNames(
284+
getClass(this),
283285
`${prefixCls}-picker`, {
284286
[`${prefixCls}-picker-with-value`]: inputValue,
285287
[`${prefixCls}-picker-disabled`]: disabled,
@@ -345,11 +347,13 @@ export default {
345347
keydown: this.handleKeyDown,
346348
change: showSearch ? this.handleInputChange : noop,
347349
},
350+
attrs: getAttrs(this),
348351
}
349352
const children = filterEmpty($slots.default)
350353
const input = children.length ? children : (
351354
<span
352355
class={pickerCls}
356+
style={getStyle(this)}
353357
>
354358
{ showSearch ? <span class={`${prefixCls}-picker-label`}>
355359
{this.getLabel()}

components/checkbox/Checkbox.jsx

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
2-
import hasProp from '../_util/props-util'
1+
import classNames from 'classnames'
2+
import hasProp, { getClass, getStyle } from '../_util/props-util'
3+
import PropTypes from '../_util/vue-types'
34
export default {
5+
inheritAttrs: false,
46
name: 'ACheckbox',
57
props: {
68
prefixCls: {
@@ -14,6 +16,7 @@ export default {
1416
value: [String, Number, Boolean],
1517
name: String,
1618
indeterminate: Boolean,
19+
type: PropTypes.string.def('checkbox'),
1720
},
1821
model: {
1922
prop: 'checked',
@@ -52,14 +55,13 @@ export default {
5255
handleChange (event) {
5356
const targetChecked = event.target.checked
5457
this.$emit('input', targetChecked)
55-
const { name, value, checked, checkboxGroupContext, sChecked } = this
58+
const { checked, checkboxGroupContext } = this
5659
if ((checked === undefined && !checkboxGroupContext) || (checkboxGroupContext && checkboxGroupContext.sValue === undefined)) {
5760
this.sChecked = targetChecked
5861
}
5962
const target = {
60-
name,
61-
value,
62-
checked: !sChecked,
63+
...this.$props,
64+
checked: targetChecked,
6365
}
6466
this.$emit('change', {
6567
target,
@@ -103,9 +105,13 @@ export default {
103105
onChange = () => checkboxGroupContext.toggleOption({ value: props.value })
104106
disabled = props.disabled || checkboxGroupContext.disabled
105107
}
108+
const classString = classNames(getClass(this), {
109+
[`${prefixCls}-wrapper`]: true,
110+
})
106111
return (
107112
<label
108-
class={`${prefixCls}-wrapper`}
113+
class={classString}
114+
style={getStyle(this)}
109115
onMouseenter={this.onMouseEnter}
110116
onMouseleave={this.onMouseLeave}
111117
>

0 commit comments

Comments
 (0)