primefaces / primevue

Next Generation Vue UI Component Library
https://primevue.org
MIT License
9.75k stars 1.17k forks source link

Docs: Add method definitions to component API docs #4702

Open FlipWarthog opened 10 months ago

FlipWarthog commented 10 months ago

Describe the feature you would like to see added

Component methods are not current documented in the API docs, e.g., show and hide methods of AutoComplete can only be known by looking at the PrimeVue source: https://primevue.org/autocomplete/#api.autocomplete

Both PrimeFaces and PrimeReact document such methods: PrimeFaces example PrimeReact example

This was discussed in the PrimeLand discord; I'm not sure if it's a difference in best practices between the frameworks/libraries or something that should be added.

Is your feature request related to a problem?

Some solutions to community problems have involved using methods not documented in the component API.

Describe the solution you'd like

No response

Describe alternatives you have considered

No response

Additional context

No response

BenJackGill commented 2 months ago

I agree. The AutoComplete docs have show and hide in the emits section of the docs. This is correct since those are events are emitted when the suggestions are shown or hidden. But I also needed a way to programatically hide the suggestions and I didn't realise there was also a useful hide method that I could call until stumbling upon this issue and then went digging into the source code to find this.

I'm sure all the other components also need their docs updated in this regard. As I can't remember seeing a Methods section in any of those docs. Quasar documents their component methods well and I would love to see the same here in PrimeVue.

Note, I am using TypeScript so we also need the appropriate Types added to avoid use of @ts-expect-error everywhere. Without that TypeScript errors will show. Example below:

const autoCompleteElement = ref<AutoComplete | null>(null);

const handleAddLocationManually = async () => {
  // @ts-expect-error - using this to avoid TypeScript errors because hide() method has not been added to the AutoComplete definition yet
  autoCompleteElement.value?.hide();
};