import { RadAutoCompleteTextView, SuggestionView, AutoCompleteViewType } from '..';
import RadAutoCompleteTextViewComp from './component';
const RadAutoCompletePlugin = {
    install(Vue, options) {
        Vue.registerElement('RadAutoCompleteTextView', () => RadAutoCompleteTextView, {
            component: RadAutoCompleteTextViewComp,
        });
        Vue.registerElement('SuggestionView', () => SuggestionView);
        Vue.directive('suggestionItemTemplate', {
            inserted: function (el, binding, vnode) {
                Vue.nextTick(() => {
                    // get the autocomplete View
                    const autocomplete = el.parentNode.parentNode.nativeView;
                    // listen for the itemLoading event, and patch the template
                    autocomplete.on('itemLoading', ({ index, data, view }) => {
                        const oldVnode = view['__vueVNodeRef__'];
                        el.$templates.patchTemplate('default', { item: data }, oldVnode);
                    });
                    // set the itemViewLoader to use the default template
                    autocomplete.itemViewLoader = function (viewType) {
                        switch (viewType) {
                            case AutoCompleteViewType.ItemView:
                                return el.$templates.patchTemplate('default', { item: {} });
                        }
                    };
                });
            }
        });
    }
};
export default RadAutoCompletePlugin;
//# sourceMappingURL=index.js.map