@data-slot/tooltip 0.2.29 → 0.2.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));const c=s(require(`@data-slot/core`));let l=0;const u=[`top`,`right`,`bottom`,`left`],d=[`start`,`center`,`end`];function f(e,t={}){let n=(0,c.getPart)(e,`tooltip-trigger`),r=(0,c.getPart)(e,`tooltip-content`);if(!n||!r)throw Error(`Tooltip requires trigger and content slots`);let i=t.delay??(0,c.getDataNumber)(e,`delay`)??300,a=t.skipDelayDuration??(0,c.getDataNumber)(e,`skipDelayDuration`)??300,o=t.onOpenChange,s=t.side??(0,c.getDataEnum)(r,`side`,u)??(0,c.getDataEnum)(e,`side`,u)??`top`,f=t.align??(0,c.getDataEnum)(r,`align`,d)??(0,c.getDataEnum)(e,`align`,d)??`center`,p=!1,m=!1,h=null,g=[],_=(0,c.ensureId)(r,`tooltip-content`);r.setAttribute(`role`,`tooltip`),r.setAttribute(`data-side`,s),r.setAttribute(`data-align`,f);let v=()=>n.hasAttribute(`disabled`)||n.getAttribute(`aria-disabled`)===`true`,y=(t,i)=>{if(p===t)return;p=t;let a=p?`open`:`closed`;e.setAttribute(`data-state`,a),r.setAttribute(`data-state`,a),p?(n.setAttribute(`aria-describedby`,_),r.setAttribute(`aria-hidden`,`false`)):(n.removeAttribute(`aria-describedby`),r.setAttribute(`aria-hidden`,`true`)),(0,c.emit)(e,`tooltip:change`,{open:p,trigger:n,content:r,reason:i}),o?.(p)},b=e=>{if(h&&(clearTimeout(h),h=null),Date.now()<l){y(!0,e);return}h=setTimeout(()=>{y(!0,e),h=null},i)},x=e=>{h&&(clearTimeout(h),h=null),p&&a>0&&(l=Date.now()+a),y(!1,e)};r.setAttribute(`aria-hidden`,`true`),e.setAttribute(`data-state`,`closed`),r.setAttribute(`data-state`,`closed`),g.push((0,c.on)(n,`pointerenter`,e=>{e.pointerType!==`touch`&&(v()||b(`pointer`))}),(0,c.on)(n,`pointerleave`,e=>{if(e.pointerType===`touch`||m)return;let t=e.relatedTarget;t&&r.contains(t)||x(`pointer`)}),(0,c.on)(n,`focus`,()=>{m=!0,!v()&&b(`focus`)}),(0,c.on)(n,`blur`,()=>{m=!1,x(`blur`)})),g.push((0,c.on)(r,`pointerleave`,e=>{if(e.pointerType===`touch`||m)return;let t=e.relatedTarget;t&&n.contains(t)||x(`pointer`)})),g.push((0,c.on)(e,`tooltip:set`,e=>{let t=e.detail,n;if(t?.open===void 0?t?.value!==void 0&&(n=t.value):n=t.open,typeof n==`boolean`)if(n){if(v())return;h&&(clearTimeout(h),h=null),y(!0,`api`)}else x(`api`)})),g.push((0,c.createDismissLayer)({root:e,isOpen:()=>p,onDismiss:()=>x(`escape`),closeOnClickOutside:!1,closeOnEscape:!0,preventEscapeDefault:!1}));let S={show:()=>{v()||(h&&(clearTimeout(h),h=null),y(!0,`api`))},hide:()=>x(`api`),get isOpen(){return p},destroy:()=>{h&&clearTimeout(h),g.forEach(e=>e()),g.length=0}};return S}const p=new WeakSet;function m(e=document){let t=[];for(let n of(0,c.getRoots)(e,`tooltip`)){if(p.has(n))continue;p.add(n),t.push(f(n))}return t}exports.create=m,exports.createTooltip=f;
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{createDismissLayer as e,emit as t,ensureId as n,getDataEnum as r,getDataNumber as i,getPart as a,getRoots as o,on as s}from"@data-slot/core";let c=0;const l=[`top`,`right`,`bottom`,`left`],u=[`start`,`center`,`end`];function d(o,d={}){let f=a(o,`tooltip-trigger`),p=a(o,`tooltip-content`);if(!f||!p)throw Error(`Tooltip requires trigger and content slots`);let m=d.delay??i(o,`delay`)??300,h=d.skipDelayDuration??i(o,`skipDelayDuration`)??300,g=d.onOpenChange,_=d.side??r(p,`side`,l)??r(o,`side`,l)??`top`,v=d.align??r(p,`align`,u)??r(o,`align`,u)??`center`,y=!1,b=!1,x=null,S=[],C=n(p,`tooltip-content`);p.setAttribute(`role`,`tooltip`),p.setAttribute(`data-side`,_),p.setAttribute(`data-align`,v);let w=()=>f.hasAttribute(`disabled`)||f.getAttribute(`aria-disabled`)===`true`,T=(e,n)=>{if(y===e)return;y=e;let r=y?`open`:`closed`;o.setAttribute(`data-state`,r),p.setAttribute(`data-state`,r),y?(f.setAttribute(`aria-describedby`,C),p.setAttribute(`aria-hidden`,`false`)):(f.removeAttribute(`aria-describedby`),p.setAttribute(`aria-hidden`,`true`)),t(o,`tooltip:change`,{open:y,trigger:f,content:p,reason:n}),g?.(y)},E=e=>{if(x&&(clearTimeout(x),x=null),Date.now()<c){T(!0,e);return}x=setTimeout(()=>{T(!0,e),x=null},m)},D=e=>{x&&(clearTimeout(x),x=null),y&&h>0&&(c=Date.now()+h),T(!1,e)};p.setAttribute(`aria-hidden`,`true`),o.setAttribute(`data-state`,`closed`),p.setAttribute(`data-state`,`closed`),S.push(s(f,`pointerenter`,e=>{e.pointerType!==`touch`&&(w()||E(`pointer`))}),s(f,`pointerleave`,e=>{if(e.pointerType===`touch`||b)return;let t=e.relatedTarget;t&&p.contains(t)||D(`pointer`)}),s(f,`focus`,()=>{b=!0,!w()&&E(`focus`)}),s(f,`blur`,()=>{b=!1,D(`blur`)})),S.push(s(p,`pointerleave`,e=>{if(e.pointerType===`touch`||b)return;let t=e.relatedTarget;t&&f.contains(t)||D(`pointer`)})),S.push(s(o,`tooltip:set`,e=>{let t=e.detail,n;if(t?.open===void 0?t?.value!==void 0&&(n=t.value):n=t.open,typeof n==`boolean`)if(n){if(w())return;x&&(clearTimeout(x),x=null),T(!0,`api`)}else D(`api`)})),S.push(e({root:o,isOpen:()=>y,onDismiss:()=>D(`escape`),closeOnClickOutside:!1,closeOnEscape:!0,preventEscapeDefault:!1}));let O={show:()=>{w()||(x&&(clearTimeout(x),x=null),T(!0,`api`))},hide:()=>D(`api`),get isOpen(){return y},destroy:()=>{x&&clearTimeout(x),S.forEach(e=>e()),S.length=0}};return O}const f=new WeakSet;function p(e=document){let t=[];for(let n of o(e,`tooltip`)){if(f.has(n))continue;f.add(n),t.push(d(n))}return t}export{p as create,d as createTooltip};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@data-slot/tooltip",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.31",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -24,9 +24,6 @@
|
|
|
24
24
|
"scripts": {
|
|
25
25
|
"build": "tsdown"
|
|
26
26
|
},
|
|
27
|
-
"devDependencies": {
|
|
28
|
-
"@data-slot/core": "workspace:*"
|
|
29
|
-
},
|
|
30
27
|
"repository": {
|
|
31
28
|
"type": "git",
|
|
32
29
|
"url": "https://github.com/bejamas/data-slot",
|
|
@@ -39,5 +36,8 @@
|
|
|
39
36
|
"vanilla",
|
|
40
37
|
"data-slot"
|
|
41
38
|
],
|
|
42
|
-
"license": "MIT"
|
|
39
|
+
"license": "MIT",
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@data-slot/core": "workspace:*"
|
|
42
|
+
}
|
|
43
43
|
}
|