Skip to content
This repository was archived by the owner on Sep 28, 2024. It is now read-only.

Commit c1b72b6

Browse files
committed
Export types along with plugin
1 parent 1418e00 commit c1b72b6

File tree

8 files changed

+42
-4
lines changed

8 files changed

+42
-4
lines changed

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,33 @@ Pass any of the options listed below to `Vue.use(VueCustomTooltip, {...})` to cu
253253
>
254254
> The `color`, `background`, `borderRadius`, and `fontWeight` attributes listed below are set on the psuedo element using [CSS Variables (Custom Properties)](https://caniuse.com/#feat=css-variables), meaning they will fallback to their default values in unsupported browsers (e.g. Internet Explorer).
255255
256+
### Type Declarations for tooltip options
257+
258+
```ts
259+
export interface TooltipOptions {
260+
name?: string
261+
color?: string
262+
background?: string
263+
borderRadius?: number
264+
fontWeight?: number
265+
}
266+
```
267+
268+
You may import the TypeScript interface along with the plugin into your entry file as shown here:
269+
270+
```ts
271+
// main.ts
272+
273+
import VueCustomTooltip, { TooltipOptions } from '@adamdehaven/vue-custom-tooltip'
274+
275+
// Then, to import the plugin and use the interface
276+
const options: TooltipOptions = {
277+
background: '#0007ac1',
278+
}
279+
280+
Vue.use(VueCustomTooltip, options)
281+
```
282+
256283
### `name`
257284

258285
- Type: `String`

dist/index.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { Plugin } from 'vue';
22
import VueCustomTooltip from './VueCustomTooltip.vue';
3+
import { TooltipOptions } from './types';
34
declare type InstallableComponent = typeof VueCustomTooltip & {
45
install: Exclude<Plugin['install'], undefined>;
56
};
67
declare const _default: InstallableComponent;
78
export default _default;
8-
export { VueCustomTooltip };
9+
export { VueCustomTooltip, TooltipOptions };

dist/vue-custom-tooltip.cjs.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ var script = vue.defineComponent({
4747

4848
var tooltipOptions = vue.inject('vue-custom-tooltip', defaultTooltipOptions);
4949
var setCssVars = function () {
50+
if (!tooltipOptions || !defaultTooltipOptions) {
51+
return;
52+
}
5053
var htmlRoot = document && document.documentElement ? document.documentElement : null;
5154
if (htmlRoot) {
5255
/* eslint-disable @typescript-eslint/no-non-null-assertion */

dist/vue-custom-tooltip.esm.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ var script = defineComponent({
4343

4444
var tooltipOptions = inject('vue-custom-tooltip', defaultTooltipOptions);
4545
var setCssVars = function () {
46+
if (!tooltipOptions || !defaultTooltipOptions) {
47+
return;
48+
}
4649
var htmlRoot = document && document.documentElement ? document.documentElement : null;
4750
if (htmlRoot) {
4851
/* eslint-disable @typescript-eslint/no-non-null-assertion */

dist/vue-custom-tooltip.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@adamdehaven/vue-custom-tooltip",
3-
"version": "2.4.0",
3+
"version": "2.5.0",
44
"description": "A customizable, reusable, and reactive tooltip component for Vue 3 (including TypeScript) projects.",
55
"keywords": [
66
"Vue",

src/VueCustomTooltip.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ export default defineComponent({
3535
const tooltipOptions: TooltipOptions = inject('vue-custom-tooltip', defaultTooltipOptions)
3636
3737
const setCssVars = () => {
38+
if (!tooltipOptions || !defaultTooltipOptions) {
39+
return
40+
}
41+
3842
const htmlRoot: HTMLElement | null = document && document.documentElement ? document.documentElement : null
3943
if (htmlRoot) {
4044
/* eslint-disable @typescript-eslint/no-non-null-assertion */

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,4 @@ export default ((): InstallableComponent => {
5959
return installable
6060
})()
6161

62-
export { VueCustomTooltip }
62+
export { VueCustomTooltip, TooltipOptions }

0 commit comments

Comments
 (0)