@radix-ui/react-tooltip
Advanced tools
Comparing version 0.0.15 to 0.0.16
@@ -1,2 +0,2 @@ | ||
var e,t=require("@radix-ui/react-id").useId,o=C({},require("@radix-ui/react-visually-hidden")),n=require("@radix-ui/react-slot").Slottable,r=require("@radix-ui/react-portal").Portal,i=C({},require("@radix-ui/react-popper")),a=require("@radix-ui/react-primitive"),s=a.Primitive,l=a.extendPrimitive,u=require("@radix-ui/react-presence").Presence,c=require("@radix-ui/react-use-rect").useRect,d=require("@radix-ui/react-use-previous").usePrevious,p=require("@radix-ui/react-use-layout-effect").useLayoutEffect,f=require("@radix-ui/react-use-escape-keydown").useEscapeKeydown,g=require("@radix-ui/react-use-controllable-state").useControllableState,y=require("@radix-ui/react-context").createContext,E=require("@radix-ui/react-compose-refs").useComposedRefs,x=require("@radix-ui/primitive").composeEventHandlers,m=C({},require("react")),v=(e=require("@babel/runtime/helpers/extends"))&&e.__esModule?e.default:e;function C(e,t){return Object.keys(t).forEach((function(o){"default"!==o&&"__esModule"!==o&&Object.defineProperty(e,o,{enumerable:!0,get:function(){return t[o]}})})),e}function b(e){return{type:"machine.actions.assign",assign:e}}let T,D;const w=b(((e,t)=>{var o;return{...e,id:null!==(o=t.id)&&void 0!==o?o:e.id}})),R=function(e,{debug:t=!1,warnOnUnknownTransitions:o=!1}={}){let n=e.initial,r=e.context;const i=[],a=s=>{var l,u;const c=e.states[n],d=s.type,p=null===(l=e.on)||void 0===l?void 0:l[d],f=null===(u=c.on)||void 0===u?void 0:u[d],g=null!=p?p:f;if(void 0===g)o&&console.warn(`From state: "${n}", event "${d}" has no transition to any state`);else{const{target:o,actions:l=[],cond:u=(()=>!0)}=g,d=o?e.states[o]:{};if(u(r,s)){const e=(c.exit||[]).concat(l,d.entry||[]);r=function(e,t,o){let n=o;return null==e||e.forEach((e=>{"function"==typeof e?e(n,t,a):"machine.actions.assign"===e.type&&(n=e.assign(n,t))})),n}(e,s,r),o&&(n=o,t&&(console.group("event:",s),console.log("state:",n),console.log("context:",r),console.groupEnd()),i.forEach((e=>e({state:n,context:r}))))}}};return{subscribe:function(e){return i.push(e),()=>{i.splice(i.indexOf(e),1)}},send:a,getContext:function(){return r}}}({initial:"closed",context:{id:null,delayed:!1},on:{FOCUS:{target:"open"}},states:{closed:{entry:[b((e=>({...e,id:null})))],on:{OPEN:{target:"opening"}}},opening:{entry:[(e,t,o)=>{const n=t.delayDuration,r=()=>o({type:"DELAY_TIMER_END"});void 0===n?r():T=window.setTimeout(r,n)},w,b((e=>({...e,delayed:!0})))],exit:[()=>clearTimeout(T)],on:{DELAY_TIMER_END:{target:"open"},CLOSE:{target:"closed"}}},open:{entry:[w],exit:[b((e=>({...e,delayed:!1})))],on:{OPEN:{target:"open"},CLOSE:{target:"closing",cond:(e,t)=>e.id===t.id}}},closing:{entry:[(e,t,o)=>{var n;const r=null!==(n=t.skipDelayDuration)&&void 0!==n?n:300;D=window.setTimeout((()=>o({type:"SKIP_DELAY_TIMER_END"})),r)}],exit:[()=>clearTimeout(D)],on:{OPEN:{target:"open"},SKIP_DELAY_TIMER_END:{target:"closed"}}}}}),[O,q]=y("Tooltip"),h=e=>{const{children:o,open:n,defaultOpen:r=!1,onOpenChange:i,delayDuration:a=700,skipDelayDuration:s=300}=e,l=m.useRef(null),u=t(),[c=!1,d]=g({prop:n,defaultProp:r,onChange:i}),[f,y]=m.useState(n?"instant-open":"closed");m.useEffect((()=>R.subscribe((({state:e,context:t})=>{"open"===e&&t.id===u?d(!0):d(!1)}))),[u,d]),m.useEffect((()=>R.subscribe((({state:e,context:t})=>{t.id===u?y("open"===e?t.delayed?"delayed-open":"instant-open":"closed"):y("closed")}))),[u]);const E=m.useCallback((()=>R.send({type:"FOCUS",id:u})),[u]),x=m.useCallback((()=>R.send({type:"OPEN",id:u,delayDuration:a})),[u,a]),v=m.useCallback((()=>R.send({type:"CLOSE",id:u,skipDelayDuration:s})),[s,u]);return m.useEffect((()=>()=>v()),[v]),p((()=>{!0===n&&R.send({type:"OPEN",id:u})}),[u,n]),m.createElement(O,{triggerRef:l,contentId:u,open:c,stateAttribute:f,onFocus:E,onOpen:x,onClose:v},o)};exports.Tooltip=h,h.displayName="Tooltip";const M="button",P=m.forwardRef(((e,t)=>{const{as:o=M,...n}=e,r=q("TooltipTrigger"),i=E(t,r.triggerRef);return m.createElement(s,v({type:"button","aria-describedby":r.open?r.contentId:void 0,"data-state":r.stateAttribute},n,{as:o,ref:i,onMouseEnter:x(e.onMouseEnter,r.onOpen),onMouseLeave:x(e.onMouseLeave,r.onClose),onMouseDown:x(e.onMouseDown,r.onClose),onFocus:x(e.onFocus,r.onFocus),onBlur:x(e.onBlur,r.onClose),onKeyDown:x(e.onKeyDown,(e=>{"Enter"!==e.key&&" "!==e.key||r.onClose()}))}))}));exports.TooltipTrigger=P,P.displayName="TooltipTrigger";const _=m.forwardRef(((e,t)=>{const{forceMount:o,...n}=e,r=q("TooltipContent");return m.createElement(u,{present:o||r.open},m.createElement(N,v({ref:t},n)))}));exports.TooltipContent=_;const N=m.forwardRef(((e,t)=>{const{children:a,"aria-label":s,anchorRef:l,portalled:u=!0,...c}=e,d=q("TooltipContent"),p=u?r:m.Fragment;return f((()=>d.onClose())),m.createElement(p,null,m.createElement(A,null),m.createElement(i.Root,v({"data-state":d.stateAttribute},c,{ref:t,anchorRef:l||d.triggerRef,style:{...c.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)"}}),m.createElement(n,null,a),m.createElement(o.Root,{id:d.contentId,role:"tooltip"},s||a)))}));_.displayName="TooltipContent";const k=l(i.Arrow,{displayName:"TooltipArrow"});function A(){const e=q("CheckTriggerMoved"),t=c(e.triggerRef),o=null==t?void 0:t.left,n=d(o),r=null==t?void 0:t.top,i=d(r),a=e.onClose;return m.useEffect((()=>{(void 0!==n&&n!==o||void 0!==i&&i!==r)&&a()}),[a,n,i,o,r]),null}exports.TooltipArrow=k;const I=h;exports.Root=I;const L=P;exports.Trigger=L;const S=_;exports.Content=S;const F=k;exports.Arrow=F; | ||
var e,t=require("@radix-ui/react-id").useId,o=b({},require("@radix-ui/react-visually-hidden")),n=require("@radix-ui/react-slot").Slottable,r=require("@radix-ui/react-portal").Portal,i=b({},require("@radix-ui/react-popper")),a=require("@radix-ui/react-primitive"),s=a.Primitive,u=a.extendPrimitive,l=require("@radix-ui/react-presence").Presence,c=require("@radix-ui/react-use-rect").useRect,d=require("@radix-ui/react-use-previous").usePrevious,p=require("@radix-ui/react-use-layout-effect").useLayoutEffect,f=require("@radix-ui/react-use-escape-keydown").useEscapeKeydown,g=require("@radix-ui/react-use-controllable-state").useControllableState,y=require("@radix-ui/react-context").createContext,E=require("@radix-ui/react-compose-refs").useComposedRefs,x=require("@radix-ui/primitive").composeEventHandlers,v=b({},require("react")),m=(e=require("@babel/runtime/helpers/extends"))&&e.__esModule?e.default:e;function b(e,t){return Object.keys(t).forEach((function(o){"default"!==o&&"__esModule"!==o&&Object.defineProperty(e,o,{enumerable:!0,get:function(){return t[o]}})})),e}function C(e){return{type:"machine.actions.assign",assign:e}}let T,D;const w=C(((e,t)=>{var o;return{...e,id:null!==(o=t.id)&&void 0!==o?o:e.id}})),R=function(e,{debug:t=!1,warnOnUnknownTransitions:o=!1}={}){let n=e.initial,r=e.context;const i=[],a=s=>{var u,l;const c=e.states[n],d=s.type,p=null===(u=e.on)||void 0===u?void 0:u[d],f=null===(l=c.on)||void 0===l?void 0:l[d],g=null!=p?p:f;if(void 0===g)o&&console.warn(`From state: "${n}", event "${d}" has no transition to any state`);else{const{target:o,actions:u=[],cond:l=(()=>!0)}=g,d=o?e.states[o]:{};if(l(r,s)){const e=(c.exit||[]).concat(u,d.entry||[]);r=function(e,t,o){let n=o;return null==e||e.forEach((e=>{"function"==typeof e?e(n,t,a):"machine.actions.assign"===e.type&&(n=e.assign(n,t))})),n}(e,s,r),o&&(n=o,t&&(console.group("event:",s),console.log("state:",n),console.log("context:",r),console.groupEnd()),i.forEach((e=>e({state:n,context:r}))))}}};return{subscribe:function(e){return i.push(e),()=>{i.splice(i.indexOf(e),1)}},send:a,getContext:function(){return r}}}({initial:"closed",context:{id:null,delayed:!1},on:{FOCUS:{target:"open"}},states:{closed:{entry:[C((e=>({...e,id:null})))],on:{OPEN:{target:"opening"}}},opening:{entry:[(e,t,o)=>{const n=t.delayDuration,r=()=>o({type:"DELAY_TIMER_END"});void 0===n?r():T=window.setTimeout(r,n)},w,C((e=>({...e,delayed:!0})))],exit:[()=>clearTimeout(T)],on:{DELAY_TIMER_END:{target:"open"},CLOSE:{target:"closed"}}},open:{entry:[w],exit:[C((e=>({...e,delayed:!1})))],on:{OPEN:{target:"open"},CLOSE:{target:"closing",cond:(e,t)=>e.id===t.id}}},closing:{entry:[(e,t,o)=>{var n;const r=null!==(n=t.skipDelayDuration)&&void 0!==n?n:300;D=window.setTimeout((()=>o({type:"SKIP_DELAY_TIMER_END"})),r)}],exit:[()=>clearTimeout(D)],on:{OPEN:{target:"open"},SKIP_DELAY_TIMER_END:{target:"closed"}}}}}),[O,q]=y("Tooltip"),h=e=>{const{children:o,open:n,defaultOpen:r=!1,onOpenChange:i,delayDuration:a=700,skipDelayDuration:s=300}=e,u=v.useRef(null),l=t(),[c=!1,d]=g({prop:n,defaultProp:r,onChange:i}),[f,y]=v.useState(n?"instant-open":"closed");v.useEffect((()=>R.subscribe((({state:e,context:t})=>{"open"===e&&t.id===l?d(!0):d(!1)}))),[l,d]),v.useEffect((()=>R.subscribe((({state:e,context:t})=>{t.id===l?y("open"===e?t.delayed?"delayed-open":"instant-open":"closed"):y("closed")}))),[l]);const E=v.useCallback((()=>R.send({type:"FOCUS",id:l})),[l]),x=v.useCallback((()=>R.send({type:"OPEN",id:l,delayDuration:a})),[l,a]),m=v.useCallback((()=>R.send({type:"CLOSE",id:l,skipDelayDuration:s})),[s,l]);return v.useEffect((()=>()=>m()),[m]),p((()=>{!0===n&&R.send({type:"OPEN",id:l})}),[l,n]),/*#__PURE__*/v.createElement(O,{triggerRef:u,contentId:l,open:c,stateAttribute:f,onFocus:E,onOpen:x,onClose:m},o)};exports.Tooltip=h;const M="button",P=/*#__PURE__*/v.forwardRef(((e,t)=>{const{as:o=M,...n}=e,r=q("TooltipTrigger"),i=E(t,r.triggerRef);/*#__PURE__*/return v.createElement(s,m({type:"button","aria-describedby":r.open?r.contentId:void 0,"data-state":r.stateAttribute},n,{as:o,ref:i,onMouseEnter:x(e.onMouseEnter,r.onOpen),onMouseLeave:x(e.onMouseLeave,r.onClose),onMouseDown:x(e.onMouseDown,r.onClose),onFocus:x(e.onFocus,r.onFocus),onBlur:x(e.onBlur,r.onClose),onKeyDown:x(e.onKeyDown,(e=>{"Enter"!==e.key&&" "!==e.key||r.onClose()}))}))}));exports.TooltipTrigger=P;const _=/*#__PURE__*/v.forwardRef(((e,t)=>{const{forceMount:o,...n}=e,r=q("TooltipContent");/*#__PURE__*/return v.createElement(l,{present:o||r.open},/*#__PURE__*/v.createElement(k,m({ref:t},n)))}));exports.TooltipContent=_;const k=/*#__PURE__*/v.forwardRef(((e,t)=>{const{children:a,"aria-label":s,anchorRef:u,portalled:l=!0,...c}=e,d=q("TooltipContent"),p=l?r:v.Fragment;return f((()=>d.onClose())),/*#__PURE__*/v.createElement(p,null,/*#__PURE__*/v.createElement(I,null),/*#__PURE__*/v.createElement(i.Root,m({"data-state":d.stateAttribute},c,{ref:t,anchorRef:u||d.triggerRef,style:{...c.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)"}}),/*#__PURE__*/v.createElement(n,null,a),/*#__PURE__*/v.createElement(o.Root,{id:d.contentId,role:"tooltip"},s||a)))})),A=u(i.Arrow,{displayName:"TooltipArrow"});/*#__PURE__*/function I(){const e=q("CheckTriggerMoved"),t=c(e.triggerRef),o=null==t?void 0:t.left,n=d(o),r=null==t?void 0:t.top,i=d(r),a=e.onClose;return v.useEffect((()=>{(void 0!==n&&n!==o||void 0!==i&&i!==r)&&a()}),[a,n,i,o,r]),null}exports.TooltipArrow=A;const L=h;exports.Root=L;const N=P;exports.Trigger=N;const S=_;exports.Content=S;const F=A;exports.Arrow=F; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
import{useId as e}from"@radix-ui/react-id";import*as t from"@radix-ui/react-visually-hidden";import{Slottable as o}from"@radix-ui/react-slot";import{Portal as n}from"@radix-ui/react-portal";import*as r from"@radix-ui/react-popper";import{Primitive as i,extendPrimitive as a}from"@radix-ui/react-primitive";import{Presence as s}from"@radix-ui/react-presence";import{useRect as l}from"@radix-ui/react-use-rect";import{usePrevious as c}from"@radix-ui/react-use-previous";import{useLayoutEffect as p}from"@radix-ui/react-use-layout-effect";import{useEscapeKeydown as u}from"@radix-ui/react-use-escape-keydown";import{useControllableState as d}from"@radix-ui/react-use-controllable-state";import{createContext as f}from"@radix-ui/react-context";import{useComposedRefs as m}from"@radix-ui/react-compose-refs";import{composeEventHandlers as g}from"@radix-ui/primitive";import*as y from"react";import x from"@babel/runtime/helpers/esm/extends";function E(e){return{type:"machine.actions.assign",assign:e}}let T,v;const C=E(((e,t)=>{var o;return{...e,id:null!==(o=t.id)&&void 0!==o?o:e.id}})),b=function(e,{debug:t=!1,warnOnUnknownTransitions:o=!1}={}){let n=e.initial,r=e.context;const i=[],a=s=>{var l,c;const p=e.states[n],u=s.type,d=null===(l=e.on)||void 0===l?void 0:l[u],f=null===(c=p.on)||void 0===c?void 0:c[u],m=null!=d?d:f;if(void 0===m)o&&console.warn(`From state: "${n}", event "${u}" has no transition to any state`);else{const{target:o,actions:l=[],cond:c=(()=>!0)}=m,u=o?e.states[o]:{};if(c(r,s)){const e=(p.exit||[]).concat(l,u.entry||[]);r=function(e,t,o){let n=o;return null==e||e.forEach((e=>{"function"==typeof e?e(n,t,a):"machine.actions.assign"===e.type&&(n=e.assign(n,t))})),n}(e,s,r),o&&(n=o,t&&(console.group("event:",s),console.log("state:",n),console.log("context:",r),console.groupEnd()),i.forEach((e=>e({state:n,context:r}))))}}};return{subscribe:function(e){return i.push(e),()=>{i.splice(i.indexOf(e),1)}},send:a,getContext:function(){return r}}}({initial:"closed",context:{id:null,delayed:!1},on:{FOCUS:{target:"open"}},states:{closed:{entry:[E((e=>({...e,id:null})))],on:{OPEN:{target:"opening"}}},opening:{entry:[(e,t,o)=>{const n=t.delayDuration,r=()=>o({type:"DELAY_TIMER_END"});void 0===n?r():T=window.setTimeout(r,n)},C,E((e=>({...e,delayed:!0})))],exit:[()=>clearTimeout(T)],on:{DELAY_TIMER_END:{target:"open"},CLOSE:{target:"closed"}}},open:{entry:[C],exit:[E((e=>({...e,delayed:!1})))],on:{OPEN:{target:"open"},CLOSE:{target:"closing",cond:(e,t)=>e.id===t.id}}},closing:{entry:[(e,t,o)=>{var n;const r=null!==(n=t.skipDelayDuration)&&void 0!==n?n:300;v=window.setTimeout((()=>o({type:"SKIP_DELAY_TIMER_END"})),r)}],exit:[()=>clearTimeout(v)],on:{OPEN:{target:"open"},SKIP_DELAY_TIMER_END:{target:"closed"}}}}}),[D,w]=f("Tooltip");export const Tooltip=t=>{const{children:o,open:n,defaultOpen:r=!1,onOpenChange:i,delayDuration:a=700,skipDelayDuration:s=300}=t,l=y.useRef(null),c=e(),[u=!1,f]=d({prop:n,defaultProp:r,onChange:i}),[m,g]=y.useState(n?"instant-open":"closed");y.useEffect((()=>b.subscribe((({state:e,context:t})=>{"open"===e&&t.id===c?f(!0):f(!1)}))),[c,f]),y.useEffect((()=>b.subscribe((({state:e,context:t})=>{t.id===c?g("open"===e?t.delayed?"delayed-open":"instant-open":"closed"):g("closed")}))),[c]);const x=y.useCallback((()=>b.send({type:"FOCUS",id:c})),[c]),E=y.useCallback((()=>b.send({type:"OPEN",id:c,delayDuration:a})),[c,a]),T=y.useCallback((()=>b.send({type:"CLOSE",id:c,skipDelayDuration:s})),[s,c]);return y.useEffect((()=>()=>T()),[T]),p((()=>{!0===n&&b.send({type:"OPEN",id:c})}),[c,n]),y.createElement(D,{triggerRef:l,contentId:c,open:u,stateAttribute:m,onFocus:x,onOpen:E,onClose:T},o)};Tooltip.displayName="Tooltip";const R="button";export const TooltipTrigger=y.forwardRef(((e,t)=>{const{as:o=R,...n}=e,r=w("TooltipTrigger"),a=m(t,r.triggerRef);return y.createElement(i,x({type:"button","aria-describedby":r.open?r.contentId:void 0,"data-state":r.stateAttribute},n,{as:o,ref:a,onMouseEnter:g(e.onMouseEnter,r.onOpen),onMouseLeave:g(e.onMouseLeave,r.onClose),onMouseDown:g(e.onMouseDown,r.onClose),onFocus:g(e.onFocus,r.onFocus),onBlur:g(e.onBlur,r.onClose),onKeyDown:g(e.onKeyDown,(e=>{"Enter"!==e.key&&" "!==e.key||r.onClose()}))}))}));TooltipTrigger.displayName="TooltipTrigger";export const TooltipContent=y.forwardRef(((e,t)=>{const{forceMount:o,...n}=e,r=w("TooltipContent");return y.createElement(s,{present:o||r.open},y.createElement(O,x({ref:t},n)))}));const O=y.forwardRef(((e,i)=>{const{children:a,"aria-label":s,anchorRef:l,portalled:c=!0,...p}=e,d=w("TooltipContent"),f=c?n:y.Fragment;return u((()=>d.onClose())),y.createElement(f,null,y.createElement(h,null),y.createElement(r.Root,x({"data-state":d.stateAttribute},p,{ref:i,anchorRef:l||d.triggerRef,style:{...p.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)"}}),y.createElement(o,null,a),y.createElement(t.Root,{id:d.contentId,role:"tooltip"},s||a)))}));TooltipContent.displayName="TooltipContent";export const TooltipArrow=a(r.Arrow,{displayName:"TooltipArrow"});function h(){const e=w("CheckTriggerMoved"),t=l(e.triggerRef),o=null==t?void 0:t.left,n=c(o),r=null==t?void 0:t.top,i=c(r),a=e.onClose;return y.useEffect((()=>{(void 0!==n&&n!==o||void 0!==i&&i!==r)&&a()}),[a,n,i,o,r]),null}export const Root=Tooltip;export const Trigger=TooltipTrigger;export const Content=TooltipContent;export const Arrow=TooltipArrow; | ||
import{useId as e}from"@radix-ui/react-id";import*as t from"@radix-ui/react-visually-hidden";import{Slottable as o}from"@radix-ui/react-slot";import{Portal as n}from"@radix-ui/react-portal";import*as r from"@radix-ui/react-popper";import{Primitive as i,extendPrimitive as a}from"@radix-ui/react-primitive";import{Presence as s}from"@radix-ui/react-presence";import{useRect as l}from"@radix-ui/react-use-rect";import{usePrevious as c}from"@radix-ui/react-use-previous";import{useLayoutEffect as u}from"@radix-ui/react-use-layout-effect";import{useEscapeKeydown as p}from"@radix-ui/react-use-escape-keydown";import{useControllableState as d}from"@radix-ui/react-use-controllable-state";import{createContext as f}from"@radix-ui/react-context";import{useComposedRefs as m}from"@radix-ui/react-compose-refs";import{composeEventHandlers as g}from"@radix-ui/primitive";import*as x from"react";import y from"@babel/runtime/helpers/esm/extends";function E(e){return{type:"machine.actions.assign",assign:e}}let T,v;const C=E(((e,t)=>{var o;return{...e,id:null!==(o=t.id)&&void 0!==o?o:e.id}})),b=function(e,{debug:t=!1,warnOnUnknownTransitions:o=!1}={}){let n=e.initial,r=e.context;const i=[],a=s=>{var l,c;const u=e.states[n],p=s.type,d=null===(l=e.on)||void 0===l?void 0:l[p],f=null===(c=u.on)||void 0===c?void 0:c[p],m=null!=d?d:f;if(void 0===m)o&&console.warn(`From state: "${n}", event "${p}" has no transition to any state`);else{const{target:o,actions:l=[],cond:c=(()=>!0)}=m,p=o?e.states[o]:{};if(c(r,s)){const e=(u.exit||[]).concat(l,p.entry||[]);r=function(e,t,o){let n=o;return null==e||e.forEach((e=>{"function"==typeof e?e(n,t,a):"machine.actions.assign"===e.type&&(n=e.assign(n,t))})),n}(e,s,r),o&&(n=o,t&&(console.group("event:",s),console.log("state:",n),console.log("context:",r),console.groupEnd()),i.forEach((e=>e({state:n,context:r}))))}}};return{subscribe:function(e){return i.push(e),()=>{i.splice(i.indexOf(e),1)}},send:a,getContext:function(){return r}}}({initial:"closed",context:{id:null,delayed:!1},on:{FOCUS:{target:"open"}},states:{closed:{entry:[E((e=>({...e,id:null})))],on:{OPEN:{target:"opening"}}},opening:{entry:[(e,t,o)=>{const n=t.delayDuration,r=()=>o({type:"DELAY_TIMER_END"});void 0===n?r():T=window.setTimeout(r,n)},C,E((e=>({...e,delayed:!0})))],exit:[()=>clearTimeout(T)],on:{DELAY_TIMER_END:{target:"open"},CLOSE:{target:"closed"}}},open:{entry:[C],exit:[E((e=>({...e,delayed:!1})))],on:{OPEN:{target:"open"},CLOSE:{target:"closing",cond:(e,t)=>e.id===t.id}}},closing:{entry:[(e,t,o)=>{var n;const r=null!==(n=t.skipDelayDuration)&&void 0!==n?n:300;v=window.setTimeout((()=>o({type:"SKIP_DELAY_TIMER_END"})),r)}],exit:[()=>clearTimeout(v)],on:{OPEN:{target:"open"},SKIP_DELAY_TIMER_END:{target:"closed"}}}}}),[D,w]=f("Tooltip");export const Tooltip=t=>{const{children:o,open:n,defaultOpen:r=!1,onOpenChange:i,delayDuration:a=700,skipDelayDuration:s=300}=t,l=x.useRef(null),c=e(),[p=!1,f]=d({prop:n,defaultProp:r,onChange:i}),[m,g]=x.useState(n?"instant-open":"closed");x.useEffect((()=>b.subscribe((({state:e,context:t})=>{"open"===e&&t.id===c?f(!0):f(!1)}))),[c,f]),x.useEffect((()=>b.subscribe((({state:e,context:t})=>{t.id===c?g("open"===e?t.delayed?"delayed-open":"instant-open":"closed"):g("closed")}))),[c]);const y=x.useCallback((()=>b.send({type:"FOCUS",id:c})),[c]),E=x.useCallback((()=>b.send({type:"OPEN",id:c,delayDuration:a})),[c,a]),T=x.useCallback((()=>b.send({type:"CLOSE",id:c,skipDelayDuration:s})),[s,c]);return x.useEffect((()=>()=>T()),[T]),u((()=>{!0===n&&b.send({type:"OPEN",id:c})}),[c,n]),/*#__PURE__*/x.createElement(D,{triggerRef:l,contentId:c,open:p,stateAttribute:m,onFocus:y,onOpen:E,onClose:T},o)};/*#__PURE__*/const R="button";export const TooltipTrigger=/*#__PURE__*/x.forwardRef(((e,t)=>{const{as:o=R,...n}=e,r=w("TooltipTrigger"),a=m(t,r.triggerRef);/*#__PURE__*/return x.createElement(i,y({type:"button","aria-describedby":r.open?r.contentId:void 0,"data-state":r.stateAttribute},n,{as:o,ref:a,onMouseEnter:g(e.onMouseEnter,r.onOpen),onMouseLeave:g(e.onMouseLeave,r.onClose),onMouseDown:g(e.onMouseDown,r.onClose),onFocus:g(e.onFocus,r.onFocus),onBlur:g(e.onBlur,r.onClose),onKeyDown:g(e.onKeyDown,(e=>{"Enter"!==e.key&&" "!==e.key||r.onClose()}))}))}));/*#__PURE__*/export const TooltipContent=/*#__PURE__*/x.forwardRef(((e,t)=>{const{forceMount:o,...n}=e,r=w("TooltipContent");/*#__PURE__*/return x.createElement(s,{present:o||r.open},/*#__PURE__*/x.createElement(O,y({ref:t},n)))}));const O=/*#__PURE__*/x.forwardRef(((e,i)=>{const{children:a,"aria-label":s,anchorRef:l,portalled:c=!0,...u}=e,d=w("TooltipContent"),f=c?n:x.Fragment;return p((()=>d.onClose())),/*#__PURE__*/x.createElement(f,null,/*#__PURE__*/x.createElement(h,null),/*#__PURE__*/x.createElement(r.Root,y({"data-state":d.stateAttribute},u,{ref:i,anchorRef:l||d.triggerRef,style:{...u.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)"}}),/*#__PURE__*/x.createElement(o,null,a),/*#__PURE__*/x.createElement(t.Root,{id:d.contentId,role:"tooltip"},s||a)))}));/*#__PURE__*/export const TooltipArrow=a(r.Arrow,{displayName:"TooltipArrow"});function h(){const e=w("CheckTriggerMoved"),t=l(e.triggerRef),o=null==t?void 0:t.left,n=c(o),r=null==t?void 0:t.top,i=c(r),a=e.onClose;return x.useEffect((()=>{(void 0!==n&&n!==o||void 0!==i&&i!==r)&&a()}),[a,n,i,o,r]),null}export const Root=Tooltip;export const Trigger=TooltipTrigger;export const Content=TooltipContent;export const Arrow=TooltipArrow; | ||
//# sourceMappingURL=index.module.js.map |
{ | ||
"name": "@radix-ui/react-tooltip", | ||
"version": "0.0.15", | ||
"version": "0.0.16", | ||
"license": "MIT", | ||
@@ -21,18 +21,18 @@ "source": "src/index.ts", | ||
"@babel/runtime": "^7.13.10", | ||
"@radix-ui/primitive": "0.0.4", | ||
"@radix-ui/react-compose-refs": "0.0.4", | ||
"@radix-ui/react-context": "0.0.4", | ||
"@radix-ui/react-id": "0.0.4", | ||
"@radix-ui/react-polymorphic": "0.0.9", | ||
"@radix-ui/react-popper": "0.0.13", | ||
"@radix-ui/react-portal": "0.0.10", | ||
"@radix-ui/react-presence": "0.0.12", | ||
"@radix-ui/react-primitive": "0.0.10", | ||
"@radix-ui/react-slot": "0.0.8", | ||
"@radix-ui/react-use-controllable-state": "0.0.5", | ||
"@radix-ui/react-use-escape-keydown": "0.0.5", | ||
"@radix-ui/react-use-layout-effect": "0.0.4", | ||
"@radix-ui/react-use-previous": "0.0.4", | ||
"@radix-ui/react-use-rect": "0.0.5", | ||
"@radix-ui/react-visually-hidden": "0.0.10" | ||
"@radix-ui/primitive": "0.0.5", | ||
"@radix-ui/react-compose-refs": "0.0.5", | ||
"@radix-ui/react-context": "0.0.5", | ||
"@radix-ui/react-id": "0.0.5", | ||
"@radix-ui/react-polymorphic": "0.0.10", | ||
"@radix-ui/react-popper": "0.0.14", | ||
"@radix-ui/react-portal": "0.0.11", | ||
"@radix-ui/react-presence": "0.0.13", | ||
"@radix-ui/react-primitive": "0.0.11", | ||
"@radix-ui/react-slot": "0.0.9", | ||
"@radix-ui/react-use-controllable-state": "0.0.6", | ||
"@radix-ui/react-use-escape-keydown": "0.0.6", | ||
"@radix-ui/react-use-layout-effect": "0.0.5", | ||
"@radix-ui/react-use-previous": "0.0.5", | ||
"@radix-ui/react-use-rect": "0.0.6", | ||
"@radix-ui/react-visually-hidden": "0.0.11" | ||
}, | ||
@@ -39,0 +39,0 @@ "peerDependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
70444
+ Added@radix-ui/popper@0.0.10(transitive)
+ Added@radix-ui/primitive@0.0.5(transitive)
+ Added@radix-ui/react-arrow@0.0.11(transitive)
+ Added@radix-ui/react-compose-refs@0.0.5(transitive)
+ Added@radix-ui/react-context@0.0.5(transitive)
+ Added@radix-ui/react-id@0.0.5(transitive)
+ Added@radix-ui/react-polymorphic@0.0.10(transitive)
+ Added@radix-ui/react-popper@0.0.14(transitive)
+ Added@radix-ui/react-portal@0.0.11(transitive)
+ Added@radix-ui/react-presence@0.0.13(transitive)
+ Added@radix-ui/react-primitive@0.0.11(transitive)
+ Added@radix-ui/react-slot@0.0.9(transitive)
+ Added@radix-ui/react-use-callback-ref@0.0.5(transitive)
+ Added@radix-ui/react-use-controllable-state@0.0.6(transitive)
+ Added@radix-ui/react-use-escape-keydown@0.0.6(transitive)
+ Added@radix-ui/react-use-layout-effect@0.0.5(transitive)
+ Added@radix-ui/react-use-previous@0.0.5(transitive)
+ Added@radix-ui/react-use-rect@0.0.6(transitive)
+ Added@radix-ui/react-use-size@0.0.5(transitive)
+ Added@radix-ui/react-visually-hidden@0.0.11(transitive)
+ Added@radix-ui/rect@0.0.5(transitive)
- Removed@radix-ui/popper@0.0.9(transitive)
- Removed@radix-ui/primitive@0.0.4(transitive)
- Removed@radix-ui/react-arrow@0.0.10(transitive)
- Removed@radix-ui/react-compose-refs@0.0.4(transitive)
- Removed@radix-ui/react-context@0.0.4(transitive)
- Removed@radix-ui/react-id@0.0.4(transitive)
- Removed@radix-ui/react-polymorphic@0.0.9(transitive)
- Removed@radix-ui/react-popper@0.0.13(transitive)
- Removed@radix-ui/react-portal@0.0.10(transitive)
- Removed@radix-ui/react-presence@0.0.12(transitive)
- Removed@radix-ui/react-primitive@0.0.10(transitive)
- Removed@radix-ui/react-slot@0.0.8(transitive)
- Removed@radix-ui/react-use-callback-ref@0.0.4(transitive)
- Removed@radix-ui/react-use-controllable-state@0.0.5(transitive)
- Removed@radix-ui/react-use-escape-keydown@0.0.5(transitive)
- Removed@radix-ui/react-use-layout-effect@0.0.4(transitive)
- Removed@radix-ui/react-use-previous@0.0.4(transitive)
- Removed@radix-ui/react-use-rect@0.0.5(transitive)
- Removed@radix-ui/react-use-size@0.0.4(transitive)
- Removed@radix-ui/react-visually-hidden@0.0.10(transitive)
- Removed@radix-ui/rect@0.0.4(transitive)
Updated@radix-ui/primitive@0.0.5
Updated@radix-ui/react-id@0.0.5
Updated@radix-ui/react-slot@0.0.9