feat: add popup ref

pull/948/head
tanjinzhou 2019-07-04 18:12:52 +08:00
parent 0d67fc1966
commit f9373e44ce
8 changed files with 61 additions and 4 deletions

View File

@ -55,7 +55,15 @@ const AutoComplete = {
prop: 'value',
event: 'change',
},
provide() {
return {
savePopupRef: this.savePopupRef,
};
},
methods: {
savePopupRef(ref) {
this.popupRef = ref;
},
getInputElement() {
const { $slots } = this;
const children = filterEmpty($slots.default);

View File

@ -141,6 +141,11 @@ const Cascader = {
prop: 'value',
event: 'change',
},
provide() {
return {
savePopupRef: this.savePopupRef,
};
},
inject: {
configProvider: { default: () => ({}) },
localeData: { default: () => ({}) },
@ -177,6 +182,9 @@ const Cascader = {
},
},
methods: {
savePopupRef(ref) {
this.popupRef = ref;
},
highlightKeyword(str, keyword, prefixCls) {
return str
.split(keyword)

View File

@ -37,7 +37,11 @@ export default function wrapPicker(Picker, props, defaultFormat) {
prop: 'value',
event: 'change',
},
provide() {
return {
savePopupRef: this.savePopupRef,
};
},
mounted() {
const { autoFocus, disabled } = this;
if (autoFocus && !disabled) {
@ -47,6 +51,9 @@ export default function wrapPicker(Picker, props, defaultFormat) {
}
},
methods: {
savePopupRef(ref) {
this.popupRef = ref;
},
handleOpenChange(open) {
this.$emit('openChange', open);
},

View File

@ -25,7 +25,18 @@ export default {
event: 'visibleChange',
},
props: DropdownButtonProps,
provide() {
return {
savePopupRef: this.savePopupRef,
};
},
inject: {
configProvider: { default: () => ({}) },
},
methods: {
savePopupRef(ref) {
this.popupRef = ref;
},
onClick(e) {
this.$emit('click', e);
},
@ -33,9 +44,6 @@ export default {
this.$emit('visibleChange', val);
},
},
inject: {
configProvider: { default: () => ({}) },
},
render() {
const {
type,

View File

@ -20,10 +20,18 @@ const Dropdown = {
prop: 'visible',
event: 'visibleChange',
},
provide() {
return {
savePopupRef: this.savePopupRef,
};
},
inject: {
configProvider: { default: () => ({}) },
},
methods: {
savePopupRef(ref) {
this.popupRef = ref;
},
getTransitionName() {
const { placement = '', transitionName } = this.$props;
if (transitionName !== undefined) {

View File

@ -106,6 +106,11 @@ const Select = {
prop: 'value',
event: 'change',
},
provide() {
return {
savePopupRef: this.savePopupRef,
};
},
inject: {
configProvider: { default: () => ({}) },
},
@ -118,6 +123,9 @@ const Select = {
);
},
methods: {
savePopupRef(ref) {
this.popupRef = ref;
},
focus() {
this.$refs.vcSelect.focus();
},

View File

@ -86,6 +86,11 @@ const TimePicker = {
prop: 'value',
event: 'change',
},
provide() {
return {
savePopupRef: this.savePopupRef,
};
},
inject: {
configProvider: { default: () => ({}) },
},
@ -104,6 +109,9 @@ const TimePicker = {
},
},
methods: {
savePopupRef(ref) {
this.popupRef = ref;
},
handleChange(value) {
if (!hasProp(this, 'value')) {
this.setState({ sValue: value });

View File

@ -77,6 +77,7 @@ export default {
},
inject: {
vcTriggerContext: { default: () => ({}) },
savePopupRef: { default: () => noop },
},
data() {
const props = this.$props;
@ -350,6 +351,7 @@ export default {
},
savePopup(node) {
this._component = node;
this.savePopupRef(node);
},
getComponent() {
const self = this;