@@ -1,73 +0,0 @@
1−import tippy from 'tippy.js';
2−// import DocLink from '@/docs/DocLink.svelte'; // TODO try to add a link in the tooltip somehow or something, like:
3−// const app = new DocLink({
4−// target: document.getElementBySelector('.tippy')
7−const defaultParams = {
12−function getParams(paramsOrContent:any = {}, overrides = {}) {
13− let params = paramsOrContent;
14− if (typeof paramsOrContent === 'string') {
15− params = { content: paramsOrContent };
24−export default function tooltip(node, paramsOrContent: any = {}) {
25− const onTrigger = () => {
26− console.log('triggered');
27− node.dispatchEvent(new CustomEvent("tooltipTriggered"));
29− const onUntrigger = () => {
30− console.log('untriggered');
31− node.dispatchEvent(new CustomEvent("tooltipUntriggered"));
33− const onClickOutside = (_, e) => {
42− const params = getParams(paramsOrContent, listeners);
43− const { content } = params;
45− // Let's make sure the "aria-label" attribute
46− // is set so our element is accessible:
47− // https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_aria-label_attribute
48− if (!node.getAttribute("aria-label")) node.setAttribute("aria-label", content);
51− // Support any of the Tippy props by forwarding all "params":
52− // https://atomiks.github.io/tippyjs/v6/all-props/
53− const tip: any = tippy(node, params);
54− const hideTip = (e) => {
55− if (tip.state.isShown) {
57− // e.stopPropagation();
60− node.addEventListener('click', hideTip);
64− // If the props change, let's update the Tippy instance:
65− update: (newParams) => tip.setProps(getParams(newParams)),
67− // Clean up the Tippy instance on unmount:
69− node.removeEventListener('click', hideTip);