Skip to content

Commit

Permalink
feat: expose toggleTooltip function
Browse files Browse the repository at this point in the history
  • Loading branch information
abdul-alhasany committed Oct 22, 2023
1 parent 98a568c commit c8d7305
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
4 changes: 3 additions & 1 deletion docs/guide/usage/composition-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ const VuePopperOptions = {
const {
popperInstance,
triggerElement,
tooltipElement
tooltipElement,
toggleTooltip
} = useVuePopper(VuePopperOptions);
</script>
```
Expand All @@ -23,6 +24,7 @@ As you notice, the `useVuePopper` returns an object with three properties:
- `popperInstance`: The popper instance. It will give you access to the popper instance.
- `triggerElement`: The trigger element. Use this to add the trigger element.
- `tooltipElement`: The tooltip element. Use this to add the tooltip element.
- `toggleTooltip`: A function to toggle the tooltip visibility. Optionally pass a value of ('hide' or 'show') to force the tooltip to hide or show.

We can use these in template to add the trigger and tooltip elements. Like this:

Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@kalimahapps/vue-popper",
"description": "vue3 tooltip component based on popperjs",
"version": "1.1.8",
"version": "1.1.9",
"sideEffects": false,
"repository": {
"type": "git",
Expand Down Expand Up @@ -29,7 +29,6 @@
"author": "khr2003",
"license": "MIT",
"dependencies": {
"@kalimahapps/vue-popper": "^1.1.7",
"@popperjs/core": "^2.11.8",
"@vueuse/core": "^10.4.1"
},
Expand Down
3 changes: 2 additions & 1 deletion src/VuePopper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ if (Object.keys(props.popperOptions).length > 0) {
console.warn('@kalimahapps/vue-popper: popperOptions is deprecated. Use the individual props instead.');
}
const { popperInstance, triggerElement, tooltipElement, isOpened } = useVuePopper({
const { popperInstance, triggerElement, tooltipElement, isOpened, toggleTooltip } = useVuePopper({
hover: props.hover,
disableClickOutside: props.disableClickOutside,
openDelay: props.openDelay,
Expand Down Expand Up @@ -183,5 +183,6 @@ defineExpose({
isOpened: computed(() => {
return isOpened.value;
}),
toggleTooltip,
});
</script>
1 change: 1 addition & 0 deletions src/composable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,7 @@ const useVuePopper = function (suppliedOptions: Options = {}) {
triggerElement,
tooltipElement,
popperInstance,
toggleTooltip,
isOpened: computed(() => { return isOpened.value; }),
};
};
Expand Down

0 comments on commit c8d7305

Please sign in to comment.