@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
|
-
|
|
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
|
|
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
|
File without changes
|
|
File without changes
|