vueform / multiselect

Vue 3 multiselect component with single select, multiselect and tagging options (+Tailwind CSS support).
https://vueform.com
MIT License
807 stars 150 forks source link

Type is missing API methods #303

Closed FichteFoll closed 1 year ago

FichteFoll commented 1 year ago

Version

Description

The exported Multiselect type does not have any API methods defined, only various $emit overloads.

Furthermore, from the source there appear to be a few more methods than are currently mentioned in the README, such as focus, activate, or blur.

I have added the following to my project for now, but it would be nice to have a complete list of the intended public API upstream:

declare module '@vueform/multiselect/dist/multiselect.vue2.js' {
    import Multiselect from '@vueform/multiselect';

    interface Multiselect {
        readonly deactivate(): void;
        readonly focus(): void;
        readonly activate(): void;
        readonly blur(): void;

        readonly open(): void;
        readonly close(): void;
        readonly select(option): void;
        readonly deselect(option): void;
        readonly remove(option): void;
        readonly selectAll(): void;
        readonly clear(): void;
        readonly clearSearch(): void;
        readonly refreshOptions(): void;
        readonly setPointer(option): void;
    }
    export default Multiselect;
}
FichteFoll commented 1 year ago

After reading a bit more on the topic, I realized that this is not the way to go about it. The properties defined here do not properly get translated to the instance that is created when such a component is constructed.

See also:

FichteFoll commented 1 year ago

No idea what is right or wrong anymore because typings of Vue constructors (basically anything involving defineComponent) reads like magic.

It generally seems that the Multiselect type as defined in Multiselect.d.ts is lacking.