@data-slot/tooltip 0.2.31 → 0.2.33

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 CHANGED
@@ -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;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require(`@data-slot/core`),t=0;const n=[`top`,`right`,`bottom`,`left`],r=[`start`,`center`,`end`];function i(i,a={}){let o=(0,e.getPart)(i,`tooltip-trigger`),s=(0,e.getPart)(i,`tooltip-content`);if(!o||!s)throw Error(`Tooltip requires trigger and content slots`);let c=a.delay??(0,e.getDataNumber)(i,`delay`)??300,l=a.skipDelayDuration??(0,e.getDataNumber)(i,`skipDelayDuration`)??300,u=a.onOpenChange,d=a.side??(0,e.getDataEnum)(s,`side`,n)??(0,e.getDataEnum)(i,`side`,n)??`top`,f=a.align??(0,e.getDataEnum)(s,`align`,r)??(0,e.getDataEnum)(i,`align`,r)??`center`,p=!1,m=!1,h=null,g=[],_=(0,e.ensureId)(s,`tooltip-content`);s.setAttribute(`role`,`tooltip`),s.setAttribute(`data-side`,d),s.setAttribute(`data-align`,f);let v=()=>o.hasAttribute(`disabled`)||o.getAttribute(`aria-disabled`)===`true`,y=(t,n)=>{if(p===t)return;p=t;let r=p?`open`:`closed`;i.setAttribute(`data-state`,r),s.setAttribute(`data-state`,r),p?(o.setAttribute(`aria-describedby`,_),s.setAttribute(`aria-hidden`,`false`)):(o.removeAttribute(`aria-describedby`),s.setAttribute(`aria-hidden`,`true`)),(0,e.emit)(i,`tooltip:change`,{open:p,trigger:o,content:s,reason:n}),u?.(p)},b=e=>{if(h&&=(clearTimeout(h),null),Date.now()<t){y(!0,e);return}h=setTimeout(()=>{y(!0,e),h=null},c)},x=e=>{h&&=(clearTimeout(h),null),p&&l>0&&(t=Date.now()+l),y(!1,e)};return s.setAttribute(`aria-hidden`,`true`),i.setAttribute(`data-state`,`closed`),s.setAttribute(`data-state`,`closed`),g.push((0,e.on)(o,`pointerenter`,e=>{e.pointerType!==`touch`&&(v()||b(`pointer`))}),(0,e.on)(o,`pointerleave`,e=>{if(e.pointerType===`touch`||m)return;let t=e.relatedTarget;t&&s.contains(t)||x(`pointer`)}),(0,e.on)(o,`focus`,()=>{m=!0,!v()&&b(`focus`)}),(0,e.on)(o,`blur`,()=>{m=!1,x(`blur`)})),g.push((0,e.on)(s,`pointerleave`,e=>{if(e.pointerType===`touch`||m)return;let t=e.relatedTarget;t&&o.contains(t)||x(`pointer`)})),g.push((0,e.on)(i,`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),null),y(!0,`api`)}else x(`api`)})),g.push((0,e.createDismissLayer)({root:i,isOpen:()=>p,onDismiss:()=>x(`escape`),closeOnClickOutside:!1,closeOnEscape:!0,preventEscapeDefault:!1})),{show:()=>{v()||(h&&=(clearTimeout(h),null),y(!0,`api`))},hide:()=>x(`api`),get isOpen(){return p},destroy:()=>{h&&clearTimeout(h),g.forEach(e=>e()),g.length=0}}}const a=new WeakSet;function o(t=document){let n=[];for(let r of(0,e.getRoots)(t,`tooltip`))a.has(r)||(a.add(r),n.push(i(r)));return n}exports.create=o,exports.createTooltip=i;
package/dist/index.js CHANGED
@@ -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};
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),null),Date.now()<c){T(!0,e);return}x=setTimeout(()=>{T(!0,e),x=null},m)},D=e=>{x&&=(clearTimeout(x),null),y&&h>0&&(c=Date.now()+h),T(!1,e)};return 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),null),T(!0,`api`)}else D(`api`)})),S.push(e({root:o,isOpen:()=>y,onDismiss:()=>D(`escape`),closeOnClickOutside:!1,closeOnEscape:!0,preventEscapeDefault:!1})),{show:()=>{w()||(x&&=(clearTimeout(x),null),T(!0,`api`))},hide:()=>D(`api`),get isOpen(){return y},destroy:()=>{x&&clearTimeout(x),S.forEach(e=>e()),S.length=0}}}const f=new WeakSet;function p(e=document){let t=[];for(let n of o(e,`tooltip`))f.has(n)||(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.31",
3
+ "version": "0.2.33",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/index.cjs",
File without changes
File without changes