@radix-ui/react-tooltip 0.0.14 → 0.0.18

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.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import * as React from "react";
2
- import { Primitive } from "@radix-ui/react-primitive";
3
2
  import * as PopperPrimitive from "@radix-ui/react-popper";
4
3
  import * as Polymorphic from "@radix-ui/react-polymorphic";
5
4
  type TooltipOwnProps = {
@@ -19,8 +18,8 @@ type TooltipOwnProps = {
19
18
  };
20
19
  export const Tooltip: React.FC<TooltipOwnProps>;
21
20
  declare const TRIGGER_DEFAULT_TAG = "button";
22
- type TooltipTriggerOwnProps = Polymorphic.OwnProps<typeof Primitive>;
23
- type TooltipTriggerPrimitive = Polymorphic.ForwardRefComponent<typeof TRIGGER_DEFAULT_TAG, TooltipTriggerOwnProps>;
21
+ type TooltipTriggerOwnProps = Omit<Polymorphic.OwnProps<typeof PopperPrimitive.Anchor>, 'virtualRef'>;
22
+ export type TooltipTriggerPrimitive = Polymorphic.ForwardRefComponent<typeof TRIGGER_DEFAULT_TAG, TooltipTriggerOwnProps>;
24
23
  export const TooltipTrigger: TooltipTriggerPrimitive;
25
24
  type TooltipContentOwnProps = Polymorphic.Merge<Polymorphic.OwnProps<typeof TooltipContentImpl>, {
26
25
  /**
@@ -29,31 +28,25 @@ type TooltipContentOwnProps = Polymorphic.Merge<Polymorphic.OwnProps<typeof Tool
29
28
  */
30
29
  forceMount?: true;
31
30
  }>;
32
- type TooltipContentPrimitive = Polymorphic.ForwardRefComponent<Polymorphic.IntrinsicElement<typeof TooltipContentImpl>, TooltipContentOwnProps>;
31
+ export type TooltipContentPrimitive = Polymorphic.ForwardRefComponent<Polymorphic.IntrinsicElement<typeof TooltipContentImpl>, TooltipContentOwnProps>;
33
32
  export const TooltipContent: TooltipContentPrimitive;
34
- type PopperPrimitiveOwnProps = Polymorphic.OwnProps<typeof PopperPrimitive.Root>;
35
- type TooltipContentImplOwnProps = Polymorphic.Merge<PopperPrimitiveOwnProps, {
33
+ type TooltipContentImplOwnProps = Polymorphic.Merge<Polymorphic.OwnProps<typeof PopperPrimitive.Content>, {
36
34
  /**
37
35
  * A more descriptive label for accessibility purpose
38
36
  */
39
37
  'aria-label'?: string;
40
- anchorRef?: PopperPrimitiveOwnProps['anchorRef'];
41
38
  /**
42
39
  * Whether the Tooltip should render in a Portal
43
40
  * (default: `true`)
44
41
  */
45
42
  portalled?: boolean;
46
43
  }>;
47
- type TooltipContentImplPrimitive = Polymorphic.ForwardRefComponent<Polymorphic.IntrinsicElement<typeof PopperPrimitive.Root>, TooltipContentImplOwnProps>;
44
+ type TooltipContentImplPrimitive = Polymorphic.ForwardRefComponent<Polymorphic.IntrinsicElement<typeof PopperPrimitive.Content>, TooltipContentImplOwnProps>;
48
45
  declare const TooltipContentImpl: TooltipContentImplPrimitive;
49
- export const TooltipArrow: Polymorphic.ForwardRefComponent<"svg", Polymorphic.Merge<{}, {
50
- offset?: number | undefined;
51
- }>>;
46
+ export const TooltipArrow: import("@radix-ui/react-primitive").ExtendedPrimitive<PopperPrimitive.PopperArrowPrimitive, "svg">;
52
47
  export const Root: React.FC<TooltipOwnProps>;
53
48
  export const Trigger: TooltipTriggerPrimitive;
54
49
  export const Content: TooltipContentPrimitive;
55
- export const Arrow: Polymorphic.ForwardRefComponent<"svg", Polymorphic.Merge<{}, {
56
- offset?: number | undefined;
57
- }>>;
50
+ export const Arrow: import("@radix-ui/react-primitive").ExtendedPrimitive<PopperPrimitive.PopperArrowPrimitive, "svg">;
58
51
 
59
52
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"mappings":"A;A;A;A;AE8CA,uBAAuB;IACrB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IAEvC;A;A;OAGG;IACH,aAAa,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react/tooltip/src/packages/react/tooltip/src/createStateMachine.tsx","./packages/react/tooltip/src/packages/react/tooltip/src/tooltipStateChart.tsx","./packages/react/tooltip/src/packages/react/tooltip/src/Tooltip.tsx","./packages/react/tooltip/src/packages/react/tooltip/src/index.ts"],"sourcesContent":[null,null,null,null],"names":[],"version":3,"file":"index.d.ts.map"}
1
+ {"mappings":"A;A;A;AE+CA,uBAAuB;IACrB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IAEvC;A;A;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;A;A;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,OAAA,MAAM,SAAS,MAAM,EAAE,CAAC,eAAe,CAyFtC,CAAC;AASF,QAAA,MAAM,8BAA8B,CAAC;AAErC,8BAA8B,IAAI,CAChC,YAAY,QAAQ,CAAC,OAAO,gBAAgB,MAAM,CAAC,EACnD,YAAY,CACb,CAAC;AACF,sCAA+B,YAAY,mBAAmB,CAC5D,0BAA0B,EAC1B,sBAAsB,CACvB,CAAC;AAEF,OAAA,MAAM,uCAyBuB,CAAC;AAU9B,8BAA8B,YAAY,KAAK,CAC7C,YAAY,QAAQ,CAAC,yBAAyB,CAAC,EAC/C;IACE;A;A;OAGG;IACH,UAAU,CAAC,EAAE,IAAI,CAAC;CACnB,CACF,CAAC;AAEF,sCAA+B,YAAY,mBAAmB,CAC5D,YAAY,gBAAgB,CAAC,yBAAyB,CAAC,EACvD,sBAAsB,CACvB,CAAC;AAEF,OAAA,MAAM,uCAQuB,CAAC;AAE9B,kCAAkC,YAAY,KAAK,CACjD,YAAY,QAAQ,CAAC,OAAO,gBAAgB,OAAO,CAAC,EACpD;IACE;A;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;A;A;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CACF,CAAC;AAEF,mCAAmC,YAAY,mBAAmB,CAChE,YAAY,gBAAgB,CAAC,OAAO,gBAAgB,OAAO,CAAC,EAC5D,0BAA0B,CAC3B,CAAC;AAEF,QAAA,MAAM,+CA2B2B,CAAC;AAMlC,OAAA,MAAM,oIAAsF,CAAC;AA4B7F,OAAA,MAAM,+BAAc,CAAC;AACrB,OAAA,MAAM,gCAAwB,CAAC;AAC/B,OAAA,MAAM,gCAAwB,CAAC;AAC/B,OAAA,MAAM,6HAAoB,CAAC","sources":["./packages/react/tooltip/src/packages/react/tooltip/src/createStateMachine.tsx","./packages/react/tooltip/src/packages/react/tooltip/src/tooltipStateChart.tsx","./packages/react/tooltip/src/packages/react/tooltip/src/Tooltip.tsx","./packages/react/tooltip/src/packages/react/tooltip/src/index.ts"],"sourcesContent":[null,null,null,null],"names":[],"version":3,"file":"index.d.ts.map"}
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- 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;
1
+ var e,t=require("@radix-ui/react-id").useId,o=v({},require("@radix-ui/react-visually-hidden")),n=require("@radix-ui/react-slot").Slottable,r=require("@radix-ui/react-portal").Portal,i=v({},require("@radix-ui/react-popper")),a=require("@radix-ui/react-primitive").extendPrimitive,s=require("@radix-ui/react-presence").Presence,u=require("@radix-ui/react-use-rect").useRect,l=require("@radix-ui/react-use-previous").usePrevious,c=require("@radix-ui/react-use-layout-effect").useLayoutEffect,d=require("@radix-ui/react-use-escape-keydown").useEscapeKeydown,p=require("@radix-ui/react-use-controllable-state").useControllableState,f=require("@radix-ui/react-context").createContext,g=require("@radix-ui/react-compose-refs").useComposedRefs,E=require("@radix-ui/primitive").composeEventHandlers,y=v({},require("react")),x=(e=require("@babel/runtime/helpers/extends"))&&e.__esModule?e.default:e;function v(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 m(e){return{type:"machine.actions.assign",assign:e}}let C,b;const T=m(((e,t)=>{var o;return{...e,id:null!==(o=t.id)&&void 0!==o?o:e.id}})),D=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:[m((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():C=window.setTimeout(r,n)},T,m((e=>({...e,delayed:!0})))],exit:[()=>clearTimeout(C)],on:{DELAY_TIMER_END:{target:"open"},CLOSE:{target:"closed"}}},open:{entry:[T],exit:[m((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;b=window.setTimeout((()=>o({type:"SKIP_DELAY_TIMER_END"})),r)}],exit:[()=>clearTimeout(b)],on:{OPEN:{target:"open"},SKIP_DELAY_TIMER_END:{target:"closed"}}}}}),[w,O]=f("Tooltip"),h=e=>{const{children:o,open:n,defaultOpen:r=!1,onOpenChange:a,delayDuration:s=700,skipDelayDuration:u=300}=e,[l,d]=y.useState(null),f=t(),[g=!1,E]=p({prop:n,defaultProp:r,onChange:a}),[x,v]=y.useState(n?"instant-open":"closed");y.useEffect((()=>D.subscribe((({state:e,context:t})=>{"open"===e&&t.id===f?E(!0):E(!1)}))),[f,E]),y.useEffect((()=>D.subscribe((({state:e,context:t})=>{t.id===f?v("open"===e?t.delayed?"delayed-open":"instant-open":"closed"):v("closed")}))),[f]);const m=y.useCallback((()=>D.send({type:"FOCUS",id:f})),[f]),C=y.useCallback((()=>D.send({type:"OPEN",id:f,delayDuration:s})),[f,s]),b=y.useCallback((()=>D.send({type:"CLOSE",id:f,skipDelayDuration:u})),[u,f]);return y.useEffect((()=>()=>b()),[b]),c((()=>{!0===n&&D.send({type:"OPEN",id:f})}),[f,n]),/*#__PURE__*/y.createElement(i.Root,null,/*#__PURE__*/y.createElement(w,{contentId:f,open:g,stateAttribute:x,trigger:l,onTriggerChange:d,onFocus:m,onOpen:C,onClose:b},o))};exports.Tooltip=h;const q="button",M=/*#__PURE__*/y.forwardRef(((e,t)=>{const{as:o=q,...n}=e,r=O("TooltipTrigger"),a=g(t,(e=>r.onTriggerChange(e)));/*#__PURE__*/return y.createElement(i.Anchor,x({type:"button","aria-describedby":r.open?r.contentId:void 0,"data-state":r.stateAttribute},n,{as:o,ref:a,onMouseEnter:E(e.onMouseEnter,r.onOpen),onMouseLeave:E(e.onMouseLeave,r.onClose),onMouseDown:E(e.onMouseDown,r.onClose),onFocus:E(e.onFocus,r.onFocus),onBlur:E(e.onBlur,r.onClose),onKeyDown:E(e.onKeyDown,(e=>{"Enter"!==e.key&&" "!==e.key||r.onClose()}))}))}));exports.TooltipTrigger=M;const _=/*#__PURE__*/y.forwardRef(((e,t)=>{const{forceMount:o,...n}=e,r=O("TooltipContent");/*#__PURE__*/return y.createElement(s,{present:o||r.open},/*#__PURE__*/y.createElement(P,x({ref:t},n)))}));exports.TooltipContent=_;const P=/*#__PURE__*/y.forwardRef(((e,t)=>{const{children:a,"aria-label":s,portalled:u=!0,...l}=e,c=O("TooltipContent"),p=u?r:y.Fragment;return d((()=>c.onClose())),/*#__PURE__*/y.createElement(p,null,/*#__PURE__*/y.createElement(A,null),/*#__PURE__*/y.createElement(i.Content,x({"data-state":c.stateAttribute},l,{ref:t,style:{...l.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)"}}),/*#__PURE__*/y.createElement(n,null,a),/*#__PURE__*/y.createElement(o.Root,{id:c.contentId,role:"tooltip"},s||a)))})),k=a(i.Arrow,{displayName:"TooltipArrow"});/*#__PURE__*/function A(){const e=O("CheckTriggerMoved"),t=u(e.trigger),o=null==t?void 0:t.left,n=l(o),r=null==t?void 0:t.top,i=l(r),a=e.onClose;return y.useEffect((()=>{(void 0!==n&&n!==o||void 0!==i&&i!==r)&&a()}),[a,n,i,o,r]),null}exports.TooltipArrow=k;const R=h;exports.Root=R;const S=M;exports.Trigger=S;const I=_;exports.Content=I;const L=k;exports.Arrow=L;
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":"IAAgCA,g0BAAAA,8CAClBA,EAAEC,WAAaD,EAAEE,QAAUF,EAWzC,SAASG,EAAuBC,EAAMC,GAcpC,OAbAC,OAAOC,KAAKF,GAAQG,SAAQ,SAASC,GACvB,YAARA,GAA6B,eAARA,GAIzBH,OAAOI,eAAeN,EAAMK,EAAK,CAC/BE,YAAY,EACZC,IAAK,WACH,OAAOP,EAAOI,SAKbL,ECoGT,SAASS,EACPC,GAEA,MAAO,CAAEC,KAjIgB,yBAiIUF,OAAQC,GC9G7C,IAAIE,EACAC,EAEJ,MAsBMC,EAAuBC,GAAO,CAACC,EAASC,KAAV,IAAAC,EAAA,MAAqB,IACpDF,EACHG,GAAE,QAAAD,EAAGD,EAAcE,UAAjB,IAAAD,EAAAA,EAAuBF,EAAQG,OCpB7BC,EFSN,SACEC,GACAC,MAAEA,GAAQ,EAAVC,yBAAiBA,GAA2B,GAAkB,IAE9D,IAAIC,EA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FpE,EAAUiE,EAtDG,kBAuDbgE,EAAgBD,EAAYE,EAASxD,EAAMyD,SAIjD,OAFAC,GAAiB,IAAMpI,EAAQiG,YAG7BL,EAAAC,cAACoC,EAAD,KACErC,EAAAC,cAACwC,EAAD,MACAzC,EAAAC,cAACyC,EAAgBC,KAAjB3B,EAAA,CACEE,aAAY9G,EAAQmF,gBAChBqC,EAFN,CAGET,IAAKT,EACLyB,UAAWA,GAAa/H,EAAQyE,WAChC+D,MAAO,IACFhB,EAAagB,MAEhBC,2CAAqD,0CAGvD7C,EAAAC,cAAC6C,EAAD,KAAYrE,GACZuB,EAAAC,cAAC8C,EAAwBJ,KAAzB,CAA8BpI,GAAIH,EAAQ4E,UAAWgE,KAAK,WACvDd,GAAazD,QAOxBiD,EAAepB,YAlFM,iBAsFrB,MAAM2C,EAAeC,EAAgBC,EAAgBC,MAAO,CAAE9C,YAAa,iBAI3E,SAAS+C,IACP,MAAMjJ,EAAUiE,EAAkB,qBAE5BiF,EAAcC,EAAQnJ,EAAQyE,YAC9B2E,EAAcF,MAAAA,OAAH,EAAGA,EAAaG,KAC3BC,EAAsBC,EAAYH,GAClCI,EAAaN,MAAAA,OAAH,EAAGA,EAAaO,IAC1BC,EAAqBH,EAAYC,GACjC9D,EAAc1F,EAAQiG,QAa5B,OAXAvB,EAAMY,WAAU,WAGajE,IAAxBiI,GAAqCA,IAAwBF,QACtC/H,IAAvBqI,GAAoCA,IAAuBF,IAG5D9D,MAED,CAACA,EAAa4D,EAAqBI,EAAoBN,EAAaI,IAEhE,4BAGT,MAAMjB,EAAOpE,iBACb,MAAMwF,EAAUvD,oBAChB,MAAMwD,EAAUtC,oBAChB,MAAM0B,EAAQH","sources":["./node_modules/@parcel/scope-hoisting/lib/helpers.js","./packages/react/tooltip/src/createStateMachine.tsx","./packages/react/tooltip/src/tooltipStateChart.tsx","./packages/react/tooltip/src/Tooltip.tsx"],"sourcesContent":["function $parcel$interopDefault(a) {\n return a && a.__esModule ? a.default : a;\n}\n\nfunction $parcel$defineInteropFlag(a) {\n Object.defineProperty(a, '__esModule', {value: true});\n}\n\nfunction $parcel$reexport(e, n, v) {\n Object.defineProperty(e, n, {get: v, enumerable: true});\n}\n\nfunction $parcel$exportWildcard(dest, source) {\n Object.keys(source).forEach(function(key) {\n if (key === 'default' || key === '__esModule') {\n return;\n }\n\n Object.defineProperty(dest, key, {\n enumerable: true,\n get: function get() {\n return source[key];\n },\n });\n });\n\n return dest;\n}\n\nfunction $parcel$missingModule(name) {\n var err = new Error(\"Cannot find module '\" + name + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n}\n\nvar $parcel$global =\n typeof globalThis !== 'undefined'\n ? globalThis\n : typeof self !== 'undefined'\n ? self\n : typeof window !== 'undefined'\n ? window\n : typeof global !== 'undefined'\n ? global\n : {};\n","const ASSIGN_ACTION_TYPE = 'machine.actions.assign' as const;\n\nconst isProduction = process.env.NODE_ENV === 'production';\n\ntype StateChart<State extends string, Context, Event extends { type: string }> = {\n initial: State;\n context: Context;\n on?: {\n [eventType in Event['type']]?: Transition<State, Context, Event>;\n };\n states: {\n [stateValue in State]: {\n on?: {\n [eventType in Event['type']]?: Transition<State, Context, Event>;\n };\n entry?: Array<Action<Context, Event>>;\n exit?: Array<Action<Context, Event>>;\n };\n };\n};\n\ntype Transition<State extends string, Context, Event> = {\n target?: State;\n actions?: Array<Action<Context, Event>>;\n cond?: (context: Context, Event: Event) => boolean;\n};\n\ntype Action<Context, Event> = ActionFunction<Context, Event> | AssignAction<Context, Event>;\n\ntype ActionFunction<Context, Event> = (\n context: Context,\n event: Event,\n send: (event: Event) => void\n) => void;\n\nfunction createStateMachine<State extends string, Context, Event extends { type: string }>(\n stateChart: StateChart<State, Context, Event>,\n { debug = false, warnOnUnknownTransitions = !isProduction } = {}\n) {\n let currentState = stateChart.initial;\n let currentContext = stateChart.context;\n\n type CallbackFn = (args: { state: State; context: Context }) => void;\n const subscriptions: Array<CallbackFn> = [];\n\n function subscribe(callback: CallbackFn) {\n subscriptions.push(callback);\n return () => {\n subscriptions.splice(subscriptions.indexOf(callback), 1);\n };\n }\n\n function notify() {\n subscriptions.forEach((callback) => callback({ state: currentState, context: currentContext }));\n }\n\n const send = (event: Event) => {\n const stateDefinition = stateChart.states[currentState];\n const type: Event['type'] | undefined = event.type;\n const topLevelTransition: Transition<State, Context, Event> | undefined = stateChart.on?.[type];\n const stateTransition: Transition<State, Context, Event> | undefined =\n stateDefinition.on?.[type];\n const transition = topLevelTransition ?? stateTransition;\n\n if (transition === undefined) {\n if (warnOnUnknownTransitions) {\n console.warn(\n `From state: \"${currentState}\", event \"${type}\" has no transition to any state`\n );\n }\n } else {\n const { target: nextState, actions = [], cond = () => true } = transition;\n const nextStateDefinition = nextState ? stateChart.states[nextState] : {};\n\n if (cond(currentContext, event)) {\n // execute actions\n const allActions = (stateDefinition.exit || []).concat(\n actions,\n nextStateDefinition.entry || []\n );\n currentContext = executeActions(allActions, event, currentContext);\n\n if (nextState) {\n currentState = nextState;\n\n if (debug) {\n console.group('event:', event);\n console.log('state:', currentState);\n console.log('context:', currentContext);\n console.groupEnd();\n }\n\n notify();\n }\n }\n }\n };\n\n function getContext() {\n return currentContext;\n }\n\n function executeActions(\n actions: Array<Action<Context, Event>>,\n event: Event,\n context: Context\n ): Context {\n let nextContext = context;\n actions?.forEach((action) => {\n if (typeof action === 'function') {\n action(nextContext, event, send);\n } else if (action.type === ASSIGN_ACTION_TYPE) {\n nextContext = action.assign(nextContext, event);\n }\n });\n return nextContext;\n }\n\n return { subscribe, send, getContext };\n}\n\ntype AssignAction<Context, Event> = {\n type: typeof ASSIGN_ACTION_TYPE;\n assign(context: Context, event: Event): Context;\n};\n\nfunction assign<Context, Event>(\n assignFn: AssignAction<Context, Event>['assign']\n): AssignAction<Context, Event> {\n return { type: ASSIGN_ACTION_TYPE, assign: assignFn };\n}\n\nexport { createStateMachine, assign };\nexport type { StateChart, Action };\n","import { assign } from './createStateMachine';\n\nimport type { StateChart, Action } from './createStateMachine';\n\ntype TooltipState = 'closed' | 'opening' | 'open' | 'closing';\n\ntype TooltipEvent =\n | { type: 'OPEN'; id: string; delayDuration?: number }\n | { type: 'CLOSE'; id: string; skipDelayDuration: number }\n | { type: 'FOCUS'; id: string }\n | { type: 'DELAY_TIMER_END' }\n | { type: 'SKIP_DELAY_TIMER_END' };\n\ntype TooltipContext = { id: string | null; delayed: boolean };\n\ntype TooltipStateChart = StateChart<TooltipState, TooltipContext, TooltipEvent>;\ntype TooltipAction = Action<TooltipContext, TooltipEvent>;\n\n// actions\nlet delayTimerId: number;\nlet skipDelayTimerId: number;\n\nconst startDelayTimer: TooltipAction = (context, event, send) => {\n const delayDuration: number | undefined = (event as any).delayDuration;\n const sendTimerEnd = () => send({ type: 'DELAY_TIMER_END' });\n if (delayDuration === undefined) {\n sendTimerEnd();\n } else {\n delayTimerId = window.setTimeout(sendTimerEnd, delayDuration);\n }\n};\n\nconst cancelDelayTimer: TooltipAction = () => clearTimeout(delayTimerId);\n\nconst startSkipDelayTimer: TooltipAction = (context, event, send) => {\n const skipDelayDuration: number = (event as any).skipDelayDuration ?? 300;\n skipDelayTimerId = window.setTimeout(\n () => send({ type: 'SKIP_DELAY_TIMER_END' }),\n skipDelayDuration\n );\n};\n\nconst cancelSkipDelayTimer: TooltipAction = () => clearTimeout(skipDelayTimerId);\n\nconst setId: TooltipAction = assign((context, event) => ({\n ...context,\n id: (event as any).id ?? context.id,\n}));\nconst resetId: TooltipAction = assign((context) => ({ ...context, id: null }));\nconst setDelayed: TooltipAction = assign((context) => ({ ...context, delayed: true }));\nconst resetDelayed: TooltipAction = assign((context) => ({ ...context, delayed: false }));\n\nconst tooltipStateChart: TooltipStateChart = {\n initial: 'closed',\n context: { id: null, delayed: false },\n on: {\n FOCUS: { target: 'open' },\n },\n states: {\n closed: {\n entry: [resetId],\n on: {\n OPEN: { target: 'opening' },\n },\n },\n\n opening: {\n entry: [startDelayTimer, setId, setDelayed],\n exit: [cancelDelayTimer],\n on: {\n DELAY_TIMER_END: { target: 'open' },\n CLOSE: { target: 'closed' },\n },\n },\n\n open: {\n entry: [setId],\n exit: [resetDelayed],\n on: {\n OPEN: { target: 'open' },\n CLOSE: {\n target: 'closing',\n cond: (context, event) => context.id === (event as any).id,\n },\n },\n },\n\n closing: {\n entry: [startSkipDelayTimer],\n exit: [cancelSkipDelayTimer],\n on: {\n OPEN: { target: 'open' },\n SKIP_DELAY_TIMER_END: { target: 'closed' },\n },\n },\n },\n};\n\nexport { tooltipStateChart };\n","import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createContext } from '@radix-ui/react-context';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport { useEscapeKeydown } from '@radix-ui/react-use-escape-keydown';\nimport { useLayoutEffect } from '@radix-ui/react-use-layout-effect';\nimport { usePrevious } from '@radix-ui/react-use-previous';\nimport { useRect } from '@radix-ui/react-use-rect';\nimport { Presence } from '@radix-ui/react-presence';\nimport { Primitive, extendPrimitive } from '@radix-ui/react-primitive';\nimport * as PopperPrimitive from '@radix-ui/react-popper';\nimport { Portal } from '@radix-ui/react-portal';\nimport { Slottable } from '@radix-ui/react-slot';\nimport * as VisuallyHiddenPrimitive from '@radix-ui/react-visually-hidden';\nimport { useId } from '@radix-ui/react-id';\nimport { createStateMachine } from './createStateMachine';\nimport { tooltipStateChart } from './tooltipStateChart';\n\nimport type * as Polymorphic from '@radix-ui/react-polymorphic';\n\n/* -------------------------------------------------------------------------------------------------\n * State machine\n * -----------------------------------------------------------------------------------------------*/\n\ntype StateAttribute = 'closed' | 'delayed-open' | 'instant-open';\nconst stateMachine = createStateMachine(tooltipStateChart);\n\n/* -------------------------------------------------------------------------------------------------\n * Tooltip\n * -----------------------------------------------------------------------------------------------*/\n\nconst TOOLTIP_NAME = 'Tooltip';\n\ntype TooltipContextValue = {\n triggerRef: React.RefObject<HTMLButtonElement>;\n contentId: string;\n open: boolean;\n stateAttribute: StateAttribute;\n onFocus(): void;\n onOpen(): void;\n onClose(): void;\n};\n\nconst [TooltipProvider, useTooltipContext] = createContext<TooltipContextValue>(TOOLTIP_NAME);\n\ntype TooltipOwnProps = {\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n\n /**\n * The duration from when the mouse enters the trigger until the tooltip gets opened.\n * (default: 700)\n */\n delayDuration?: number;\n\n /**\n * How much time a user has to enter another trigger without incurring a delay again.\n * (default: 300)\n */\n skipDelayDuration?: number;\n};\n\nconst Tooltip: React.FC<TooltipOwnProps> = (props) => {\n const {\n children,\n open: openProp,\n defaultOpen = false,\n onOpenChange,\n delayDuration = 700,\n skipDelayDuration = 300,\n } = props;\n const triggerRef = React.useRef<HTMLButtonElement>(null);\n const contentId = useId();\n const [open = false, setOpen] = useControllableState({\n prop: openProp,\n defaultProp: defaultOpen,\n onChange: onOpenChange,\n });\n const [stateAttribute, setStateAttribute] = React.useState<StateAttribute>(\n openProp ? 'instant-open' : 'closed'\n );\n\n // control open state using state machine subscription\n React.useEffect(() => {\n const unsubscribe = stateMachine.subscribe(({ state, context }) => {\n if (state === 'open' && context.id === contentId) {\n setOpen(true);\n } else {\n setOpen(false);\n }\n });\n\n return unsubscribe;\n }, [contentId, setOpen]);\n\n // sync state attribute with using state machine subscription\n React.useEffect(() => {\n const unsubscribe = stateMachine.subscribe(({ state, context }) => {\n if (context.id === contentId) {\n if (state === 'open') {\n setStateAttribute(context.delayed ? 'delayed-open' : 'instant-open');\n } else {\n setStateAttribute('closed');\n }\n } else {\n setStateAttribute('closed');\n }\n });\n\n return unsubscribe;\n }, [contentId]);\n\n const handleFocus = React.useCallback(() => stateMachine.send({ type: 'FOCUS', id: contentId }), [\n contentId,\n ]);\n const handleOpen = React.useCallback(\n () => stateMachine.send({ type: 'OPEN', id: contentId, delayDuration }),\n [contentId, delayDuration]\n );\n const handleClose = React.useCallback(\n () => stateMachine.send({ type: 'CLOSE', id: contentId, skipDelayDuration }),\n [skipDelayDuration, contentId]\n );\n\n // send transition if the component unmounts\n React.useEffect(() => () => handleClose(), [handleClose]);\n\n // if we're controlling the component\n // put the state machine in the appropriate state\n useLayoutEffect(() => {\n if (openProp === true) {\n stateMachine.send({ type: 'OPEN', id: contentId });\n }\n }, [contentId, openProp]);\n\n return (\n <TooltipProvider\n triggerRef={triggerRef}\n contentId={contentId}\n open={open}\n stateAttribute={stateAttribute}\n onFocus={handleFocus}\n onOpen={handleOpen}\n onClose={handleClose}\n >\n {children}\n </TooltipProvider>\n );\n};\n\nTooltip.displayName = TOOLTIP_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * TooltipTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'TooltipTrigger';\nconst TRIGGER_DEFAULT_TAG = 'button';\n\ntype TooltipTriggerOwnProps = Polymorphic.OwnProps<typeof Primitive>;\ntype TooltipTriggerPrimitive = Polymorphic.ForwardRefComponent<\n typeof TRIGGER_DEFAULT_TAG,\n TooltipTriggerOwnProps\n>;\n\nconst TooltipTrigger = React.forwardRef((props, forwardedRef) => {\n const { as = TRIGGER_DEFAULT_TAG, ...triggerProps } = props;\n const context = useTooltipContext(TRIGGER_NAME);\n const composedTriggerRef = useComposedRefs(forwardedRef, context.triggerRef);\n\n return (\n <Primitive\n type=\"button\"\n aria-describedby={context.open ? context.contentId : undefined}\n data-state={context.stateAttribute}\n {...triggerProps}\n as={as}\n ref={composedTriggerRef}\n onMouseEnter={composeEventHandlers(props.onMouseEnter, context.onOpen)}\n onMouseLeave={composeEventHandlers(props.onMouseLeave, context.onClose)}\n onMouseDown={composeEventHandlers(props.onMouseDown, context.onClose)}\n onFocus={composeEventHandlers(props.onFocus, context.onFocus)}\n onBlur={composeEventHandlers(props.onBlur, context.onClose)}\n onKeyDown={composeEventHandlers(props.onKeyDown, (event) => {\n if (event.key === 'Enter' || event.key === ' ') {\n context.onClose();\n }\n })}\n />\n );\n}) as TooltipTriggerPrimitive;\n\nTooltipTrigger.displayName = TRIGGER_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * TooltipContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'TooltipContent';\n\ntype TooltipContentOwnProps = Polymorphic.Merge<\n Polymorphic.OwnProps<typeof TooltipContentImpl>,\n {\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true;\n }\n>;\n\ntype TooltipContentPrimitive = Polymorphic.ForwardRefComponent<\n Polymorphic.IntrinsicElement<typeof TooltipContentImpl>,\n TooltipContentOwnProps\n>;\n\nconst TooltipContent = React.forwardRef((props, forwardedRef) => {\n const { forceMount, ...contentProps } = props;\n const context = useTooltipContext(CONTENT_NAME);\n return (\n <Presence present={forceMount || context.open}>\n <TooltipContentImpl ref={forwardedRef} {...contentProps} />\n </Presence>\n );\n}) as TooltipContentPrimitive;\n\ntype PopperPrimitiveOwnProps = Polymorphic.OwnProps<typeof PopperPrimitive.Root>;\ntype TooltipContentImplOwnProps = Polymorphic.Merge<\n PopperPrimitiveOwnProps,\n {\n /**\n * A more descriptive label for accessibility purpose\n */\n 'aria-label'?: string;\n\n anchorRef?: PopperPrimitiveOwnProps['anchorRef'];\n\n /**\n * Whether the Tooltip should render in a Portal\n * (default: `true`)\n */\n portalled?: boolean;\n }\n>;\n\ntype TooltipContentImplPrimitive = Polymorphic.ForwardRefComponent<\n Polymorphic.IntrinsicElement<typeof PopperPrimitive.Root>,\n TooltipContentImplOwnProps\n>;\n\nconst TooltipContentImpl = React.forwardRef((props, forwardedRef) => {\n const { children, 'aria-label': ariaLabel, anchorRef, portalled = true, ...contentProps } = props;\n const context = useTooltipContext(CONTENT_NAME);\n const PortalWrapper = portalled ? Portal : React.Fragment;\n\n useEscapeKeydown(() => context.onClose());\n\n return (\n <PortalWrapper>\n <CheckTriggerMoved />\n <PopperPrimitive.Root\n data-state={context.stateAttribute}\n {...contentProps}\n ref={forwardedRef}\n anchorRef={anchorRef || context.triggerRef}\n style={{\n ...contentProps.style,\n // re-namespace exposed content custom property\n ['--radix-tooltip-content-transform-origin' as any]: 'var(--radix-popper-transform-origin)',\n }}\n >\n <Slottable>{children}</Slottable>\n <VisuallyHiddenPrimitive.Root id={context.contentId} role=\"tooltip\">\n {ariaLabel || children}\n </VisuallyHiddenPrimitive.Root>\n </PopperPrimitive.Root>\n </PortalWrapper>\n );\n}) as TooltipContentImplPrimitive;\n\nTooltipContent.displayName = CONTENT_NAME;\n\n/* ---------------------------------------------------------------------------------------------- */\n\nconst TooltipArrow = extendPrimitive(PopperPrimitive.Arrow, { displayName: 'TooltipArrow' });\n\n/* -----------------------------------------------------------------------------------------------*/\n\nfunction CheckTriggerMoved() {\n const context = useTooltipContext('CheckTriggerMoved');\n\n const triggerRect = useRect(context.triggerRef);\n const triggerLeft = triggerRect?.left;\n const previousTriggerLeft = usePrevious(triggerLeft);\n const triggerTop = triggerRect?.top;\n const previousTriggerTop = usePrevious(triggerTop);\n const handleClose = context.onClose;\n\n React.useEffect(() => {\n // checking if the user has scrolled…\n const hasTriggerMoved =\n (previousTriggerLeft !== undefined && previousTriggerLeft !== triggerLeft) ||\n (previousTriggerTop !== undefined && previousTriggerTop !== triggerTop);\n\n if (hasTriggerMoved) {\n handleClose();\n }\n }, [handleClose, previousTriggerLeft, previousTriggerTop, triggerLeft, triggerTop]);\n\n return null;\n}\n\nconst Root = Tooltip;\nconst Trigger = TooltipTrigger;\nconst Content = TooltipContent;\nconst Arrow = TooltipArrow;\n\nexport {\n Tooltip,\n TooltipTrigger,\n TooltipContent,\n TooltipArrow,\n //\n Root,\n Trigger,\n Content,\n Arrow,\n};\n"],"names":["a","__esModule","default","$parcel$exportWildcard","dest","source","Object","keys","forEach","key","defineProperty","enumerable","get","assign","assignFn","type","delayTimerId","skipDelayTimerId","setId","$fb910db130fc9c6f19b2800f728d3b10$export$assign","context","event","_id","id","stateMachine","stateChart","debug","warnOnUnknownTransitions","currentState","initial","currentContext","subscriptions","send","_stateChart$on","_stateDefinition$on","stateDefinition","states","topLevelTransition","on","stateTransition","transition","undefined","console","warn","target","nextState","actions","cond","nextStateDefinition","allActions","exit","concat","entry","nextContext","action","executeActions","group","log","groupEnd","callback","state","subscribe","push","splice","indexOf","getContext","$fb910db130fc9c6f19b2800f728d3b10$export$createStateMachine","delayed","FOCUS","closed","OPEN","opening","delayDuration","sendTimerEnd","window","setTimeout","clearTimeout","DELAY_TIMER_END","CLOSE","open","closing","_skipDelayDuration","skipDelayDuration","SKIP_DELAY_TIMER_END","TooltipProvider","useTooltipContext","createContext","Tooltip","props","children","openProp","defaultOpen","onOpenChange","triggerRef","React","useRef","contentId","useId","setOpen","useControllableState","prop","defaultProp","onChange","stateAttribute","setStateAttribute","useState","useEffect","handleFocus","useCallback","handleOpen","handleClose","useLayoutEffect","_react","createElement","$bfd2ef98f93cfd0786881e49eeb6a4$var$TooltipProvider","onFocus","onOpen","onClose","displayName","TRIGGER_DEFAULT_TAG","TooltipTrigger","forwardRef","forwardedRef","as","triggerProps","composedTriggerRef","useComposedRefs","Primitive","_babelRuntimeHelpersExtends","aria-describedby","data-state","ref","onMouseEnter","composeEventHandlers","onMouseLeave","onMouseDown","onBlur","onKeyDown","TooltipContent","forceMount","contentProps","Presence","present","$bfd2ef98f93cfd0786881e49eeb6a4$var$TooltipContentImpl","TooltipContentImpl","aria-label","ariaLabel","anchorRef","portalled","PortalWrapper","Portal","Fragment","useEscapeKeydown","$bfd2ef98f93cfd0786881e49eeb6a4$var$CheckTriggerMoved","_radixUiReactPopper","Root","style","--radix-tooltip-content-transform-origin","Slottable","_radixUiReactVisuallyHidden","role","TooltipArrow","extendPrimitive","PopperPrimitive","Arrow","CheckTriggerMoved","triggerRect","useRect","triggerLeft","left","previousTriggerLeft","usePrevious","triggerTop","top","previousTriggerTop","Trigger","Content"],"version":3,"file":"index.js.map"}
1
+ {"mappings":"IAAgCA,8yBAAAA,8CAClBA,EAAEC,WAAaD,EAAEE,QAAUF,EAWzC,SAASG,EAAuBC,E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ACjChE,EAAc1F,EAAQoG,QAa5B,OAXAzB,EAAMW,WAAU,WAGajE,IAAxBmI,GAAqCA,IAAwBF,QACtCjI,IAAvBuI,GAAoCA,IAAuBF,IAG5DhE,MAED,CAACA,EAAa8D,EAAqBI,EAAoBN,EAAaI,IAEhE,4BAGT,MAAM3D,EAAO5B,iBACb,MAAM0F,EAAUvD,oBAChB,MAAMkC,EAAUf,oBAChB,MAAMwB,EAAQH","sources":["./node_modules/@parcel/scope-hoisting/lib/helpers.js","./packages/react/tooltip/src/createStateMachine.tsx","./packages/react/tooltip/src/tooltipStateChart.tsx","./packages/react/tooltip/src/Tooltip.tsx"],"sourcesContent":["function $parcel$interopDefault(a) {\n return a && a.__esModule ? a.default : a;\n}\n\nfunction $parcel$defineInteropFlag(a) {\n Object.defineProperty(a, '__esModule', {value: true});\n}\n\nfunction $parcel$reexport(e, n, v) {\n Object.defineProperty(e, n, {get: v, enumerable: true});\n}\n\nfunction $parcel$exportWildcard(dest, source) {\n Object.keys(source).forEach(function(key) {\n if (key === 'default' || key === '__esModule') {\n return;\n }\n\n Object.defineProperty(dest, key, {\n enumerable: true,\n get: function get() {\n return source[key];\n },\n });\n });\n\n return dest;\n}\n\nfunction $parcel$missingModule(name) {\n var err = new Error(\"Cannot find module '\" + name + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n}\n\nvar $parcel$global =\n typeof globalThis !== 'undefined'\n ? globalThis\n : typeof self !== 'undefined'\n ? self\n : typeof window !== 'undefined'\n ? window\n : typeof global !== 'undefined'\n ? global\n : {};\n","const ASSIGN_ACTION_TYPE = 'machine.actions.assign' as const;\n\nconst isProduction = process.env.NODE_ENV === 'production';\n\ntype StateChart<State extends string, Context, Event extends { type: string }> = {\n initial: State;\n context: Context;\n on?: {\n [eventType in Event['type']]?: Transition<State, Context, Event>;\n };\n states: {\n [stateValue in State]: {\n on?: {\n [eventType in Event['type']]?: Transition<State, Context, Event>;\n };\n entry?: Array<Action<Context, Event>>;\n exit?: Array<Action<Context, Event>>;\n };\n };\n};\n\ntype Transition<State extends string, Context, Event> = {\n target?: State;\n actions?: Array<Action<Context, Event>>;\n cond?: (context: Context, Event: Event) => boolean;\n};\n\ntype Action<Context, Event> = ActionFunction<Context, Event> | AssignAction<Context, Event>;\n\ntype ActionFunction<Context, Event> = (\n context: Context,\n event: Event,\n send: (event: Event) => void\n) => void;\n\nfunction createStateMachine<State extends string, Context, Event extends { type: string }>(\n stateChart: StateChart<State, Context, Event>,\n { debug = false, warnOnUnknownTransitions = !isProduction } = {}\n) {\n let currentState = stateChart.initial;\n let currentContext = stateChart.context;\n\n type CallbackFn = (args: { state: State; context: Context }) => void;\n const subscriptions: Array<CallbackFn> = [];\n\n function subscribe(callback: CallbackFn) {\n subscriptions.push(callback);\n return () => {\n subscriptions.splice(subscriptions.indexOf(callback), 1);\n };\n }\n\n function notify() {\n subscriptions.forEach((callback) => callback({ state: currentState, context: currentContext }));\n }\n\n const send = (event: Event) => {\n const stateDefinition = stateChart.states[currentState];\n const type: Event['type'] | undefined = event.type;\n const topLevelTransition: Transition<State, Context, Event> | undefined = stateChart.on?.[type];\n const stateTransition: Transition<State, Context, Event> | undefined =\n stateDefinition.on?.[type];\n const transition = topLevelTransition ?? stateTransition;\n\n if (transition === undefined) {\n if (warnOnUnknownTransitions) {\n console.warn(\n `From state: \"${currentState}\", event \"${type}\" has no transition to any state`\n );\n }\n } else {\n const { target: nextState, actions = [], cond = () => true } = transition;\n const nextStateDefinition = nextState ? stateChart.states[nextState] : {};\n\n if (cond(currentContext, event)) {\n // execute actions\n const allActions = (stateDefinition.exit || []).concat(\n actions,\n nextStateDefinition.entry || []\n );\n currentContext = executeActions(allActions, event, currentContext);\n\n if (nextState) {\n currentState = nextState;\n\n if (debug) {\n console.group('event:', event);\n console.log('state:', currentState);\n console.log('context:', currentContext);\n console.groupEnd();\n }\n\n notify();\n }\n }\n }\n };\n\n function getContext() {\n return currentContext;\n }\n\n function executeActions(\n actions: Array<Action<Context, Event>>,\n event: Event,\n context: Context\n ): Context {\n let nextContext = context;\n actions?.forEach((action) => {\n if (typeof action === 'function') {\n action(nextContext, event, send);\n } else if (action.type === ASSIGN_ACTION_TYPE) {\n nextContext = action.assign(nextContext, event);\n }\n });\n return nextContext;\n }\n\n return { subscribe, send, getContext };\n}\n\ntype AssignAction<Context, Event> = {\n type: typeof ASSIGN_ACTION_TYPE;\n assign(context: Context, event: Event): Context;\n};\n\nfunction assign<Context, Event>(\n assignFn: AssignAction<Context, Event>['assign']\n): AssignAction<Context, Event> {\n return { type: ASSIGN_ACTION_TYPE, assign: assignFn };\n}\n\nexport { createStateMachine, assign };\nexport type { StateChart, Action };\n","import { assign } from './createStateMachine';\n\nimport type { StateChart, Action } from './createStateMachine';\n\ntype TooltipState = 'closed' | 'opening' | 'open' | 'closing';\n\ntype TooltipEvent =\n | { type: 'OPEN'; id: string; delayDuration?: number }\n | { type: 'CLOSE'; id: string; skipDelayDuration: number }\n | { type: 'FOCUS'; id: string }\n | { type: 'DELAY_TIMER_END' }\n | { type: 'SKIP_DELAY_TIMER_END' };\n\ntype TooltipContext = { id: string | null; delayed: boolean };\n\ntype TooltipStateChart = StateChart<TooltipState, TooltipContext, TooltipEvent>;\ntype TooltipAction = Action<TooltipContext, TooltipEvent>;\n\n// actions\nlet delayTimerId: number;\nlet skipDelayTimerId: number;\n\nconst startDelayTimer: TooltipAction = (context, event, send) => {\n const delayDuration: number | undefined = (event as any).delayDuration;\n const sendTimerEnd = () => send({ type: 'DELAY_TIMER_END' });\n if (delayDuration === undefined) {\n sendTimerEnd();\n } else {\n delayTimerId = window.setTimeout(sendTimerEnd, delayDuration);\n }\n};\n\nconst cancelDelayTimer: TooltipAction = () => clearTimeout(delayTimerId);\n\nconst startSkipDelayTimer: TooltipAction = (context, event, send) => {\n const skipDelayDuration: number = (event as any).skipDelayDuration ?? 300;\n skipDelayTimerId = window.setTimeout(\n () => send({ type: 'SKIP_DELAY_TIMER_END' }),\n skipDelayDuration\n );\n};\n\nconst cancelSkipDelayTimer: TooltipAction = () => clearTimeout(skipDelayTimerId);\n\nconst setId: TooltipAction = assign((context, event) => ({\n ...context,\n id: (event as any).id ?? context.id,\n}));\nconst resetId: TooltipAction = assign((context) => ({ ...context, id: null }));\nconst setDelayed: TooltipAction = assign((context) => ({ ...context, delayed: true }));\nconst resetDelayed: TooltipAction = assign((context) => ({ ...context, delayed: false }));\n\nconst tooltipStateChart: TooltipStateChart = {\n initial: 'closed',\n context: { id: null, delayed: false },\n on: {\n FOCUS: { target: 'open' },\n },\n states: {\n closed: {\n entry: [resetId],\n on: {\n OPEN: { target: 'opening' },\n },\n },\n\n opening: {\n entry: [startDelayTimer, setId, setDelayed],\n exit: [cancelDelayTimer],\n on: {\n DELAY_TIMER_END: { target: 'open' },\n CLOSE: { target: 'closed' },\n },\n },\n\n open: {\n entry: [setId],\n exit: [resetDelayed],\n on: {\n OPEN: { target: 'open' },\n CLOSE: {\n target: 'closing',\n cond: (context, event) => context.id === (event as any).id,\n },\n },\n },\n\n closing: {\n entry: [startSkipDelayTimer],\n exit: [cancelSkipDelayTimer],\n on: {\n OPEN: { target: 'open' },\n SKIP_DELAY_TIMER_END: { target: 'closed' },\n },\n },\n },\n};\n\nexport { tooltipStateChart };\n","import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createContext } from '@radix-ui/react-context';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport { useEscapeKeydown } from '@radix-ui/react-use-escape-keydown';\nimport { useLayoutEffect } from '@radix-ui/react-use-layout-effect';\nimport { usePrevious } from '@radix-ui/react-use-previous';\nimport { useRect } from '@radix-ui/react-use-rect';\nimport { Presence } from '@radix-ui/react-presence';\nimport { extendPrimitive } from '@radix-ui/react-primitive';\nimport * as PopperPrimitive from '@radix-ui/react-popper';\nimport { Portal } from '@radix-ui/react-portal';\nimport { Slottable } from '@radix-ui/react-slot';\nimport * as VisuallyHiddenPrimitive from '@radix-ui/react-visually-hidden';\nimport { useId } from '@radix-ui/react-id';\nimport { createStateMachine } from './createStateMachine';\nimport { tooltipStateChart } from './tooltipStateChart';\n\nimport type * as Polymorphic from '@radix-ui/react-polymorphic';\n\n/* -------------------------------------------------------------------------------------------------\n * State machine\n * -----------------------------------------------------------------------------------------------*/\n\ntype StateAttribute = 'closed' | 'delayed-open' | 'instant-open';\nconst stateMachine = createStateMachine(tooltipStateChart);\n\n/* -------------------------------------------------------------------------------------------------\n * Tooltip\n * -----------------------------------------------------------------------------------------------*/\n\nconst TOOLTIP_NAME = 'Tooltip';\n\ntype TooltipContextValue = {\n contentId: string;\n open: boolean;\n stateAttribute: StateAttribute;\n trigger: React.ElementRef<typeof TooltipTrigger> | null;\n onTriggerChange(trigger: React.ElementRef<typeof TooltipTrigger> | null): void;\n onFocus(): void;\n onOpen(): void;\n onClose(): void;\n};\n\nconst [TooltipProvider, useTooltipContext] = createContext<TooltipContextValue>(TOOLTIP_NAME);\n\ntype TooltipOwnProps = {\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n\n /**\n * The duration from when the mouse enters the trigger until the tooltip gets opened.\n * (default: 700)\n */\n delayDuration?: number;\n\n /**\n * How much time a user has to enter another trigger without incurring a delay again.\n * (default: 300)\n */\n skipDelayDuration?: number;\n};\n\nconst Tooltip: React.FC<TooltipOwnProps> = (props) => {\n const {\n children,\n open: openProp,\n defaultOpen = false,\n onOpenChange,\n delayDuration = 700,\n skipDelayDuration = 300,\n } = props;\n const [trigger, setTrigger] = React.useState<HTMLButtonElement | null>(null);\n const contentId = useId();\n const [open = false, setOpen] = useControllableState({\n prop: openProp,\n defaultProp: defaultOpen,\n onChange: onOpenChange,\n });\n const [stateAttribute, setStateAttribute] = React.useState<StateAttribute>(\n openProp ? 'instant-open' : 'closed'\n );\n\n // control open state using state machine subscription\n React.useEffect(() => {\n const unsubscribe = stateMachine.subscribe(({ state, context }) => {\n if (state === 'open' && context.id === contentId) {\n setOpen(true);\n } else {\n setOpen(false);\n }\n });\n\n return unsubscribe;\n }, [contentId, setOpen]);\n\n // sync state attribute with using state machine subscription\n React.useEffect(() => {\n const unsubscribe = stateMachine.subscribe(({ state, context }) => {\n if (context.id === contentId) {\n if (state === 'open') {\n setStateAttribute(context.delayed ? 'delayed-open' : 'instant-open');\n } else {\n setStateAttribute('closed');\n }\n } else {\n setStateAttribute('closed');\n }\n });\n\n return unsubscribe;\n }, [contentId]);\n\n const handleFocus = React.useCallback(() => stateMachine.send({ type: 'FOCUS', id: contentId }), [\n contentId,\n ]);\n const handleOpen = React.useCallback(\n () => stateMachine.send({ type: 'OPEN', id: contentId, delayDuration }),\n [contentId, delayDuration]\n );\n const handleClose = React.useCallback(\n () => stateMachine.send({ type: 'CLOSE', id: contentId, skipDelayDuration }),\n [skipDelayDuration, contentId]\n );\n\n // send transition if the component unmounts\n React.useEffect(() => () => handleClose(), [handleClose]);\n\n // if we're controlling the component\n // put the state machine in the appropriate state\n useLayoutEffect(() => {\n if (openProp === true) {\n stateMachine.send({ type: 'OPEN', id: contentId });\n }\n }, [contentId, openProp]);\n\n return (\n <PopperPrimitive.Root>\n <TooltipProvider\n contentId={contentId}\n open={open}\n stateAttribute={stateAttribute}\n trigger={trigger}\n onTriggerChange={setTrigger}\n onFocus={handleFocus}\n onOpen={handleOpen}\n onClose={handleClose}\n >\n {children}\n </TooltipProvider>\n </PopperPrimitive.Root>\n );\n};\n\nTooltip.displayName = TOOLTIP_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * TooltipTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'TooltipTrigger';\nconst TRIGGER_DEFAULT_TAG = 'button';\n\ntype TooltipTriggerOwnProps = Omit<\n Polymorphic.OwnProps<typeof PopperPrimitive.Anchor>,\n 'virtualRef'\n>;\ntype TooltipTriggerPrimitive = Polymorphic.ForwardRefComponent<\n typeof TRIGGER_DEFAULT_TAG,\n TooltipTriggerOwnProps\n>;\n\nconst TooltipTrigger = React.forwardRef((props, forwardedRef) => {\n const { as = TRIGGER_DEFAULT_TAG, ...triggerProps } = props;\n const context = useTooltipContext(TRIGGER_NAME);\n const composedTriggerRef = useComposedRefs(forwardedRef, (node) => context.onTriggerChange(node));\n\n return (\n <PopperPrimitive.Anchor\n type=\"button\"\n aria-describedby={context.open ? context.contentId : undefined}\n data-state={context.stateAttribute}\n {...triggerProps}\n as={as}\n ref={composedTriggerRef}\n onMouseEnter={composeEventHandlers(props.onMouseEnter, context.onOpen)}\n onMouseLeave={composeEventHandlers(props.onMouseLeave, context.onClose)}\n onMouseDown={composeEventHandlers(props.onMouseDown, context.onClose)}\n onFocus={composeEventHandlers(props.onFocus, context.onFocus)}\n onBlur={composeEventHandlers(props.onBlur, context.onClose)}\n onKeyDown={composeEventHandlers(props.onKeyDown, (event) => {\n if (event.key === 'Enter' || event.key === ' ') {\n context.onClose();\n }\n })}\n />\n );\n}) as TooltipTriggerPrimitive;\n\nTooltipTrigger.displayName = TRIGGER_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * TooltipContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'TooltipContent';\n\ntype TooltipContentOwnProps = Polymorphic.Merge<\n Polymorphic.OwnProps<typeof TooltipContentImpl>,\n {\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true;\n }\n>;\n\ntype TooltipContentPrimitive = Polymorphic.ForwardRefComponent<\n Polymorphic.IntrinsicElement<typeof TooltipContentImpl>,\n TooltipContentOwnProps\n>;\n\nconst TooltipContent = React.forwardRef((props, forwardedRef) => {\n const { forceMount, ...contentProps } = props;\n const context = useTooltipContext(CONTENT_NAME);\n return (\n <Presence present={forceMount || context.open}>\n <TooltipContentImpl ref={forwardedRef} {...contentProps} />\n </Presence>\n );\n}) as TooltipContentPrimitive;\n\ntype TooltipContentImplOwnProps = Polymorphic.Merge<\n Polymorphic.OwnProps<typeof PopperPrimitive.Content>,\n {\n /**\n * A more descriptive label for accessibility purpose\n */\n 'aria-label'?: string;\n\n /**\n * Whether the Tooltip should render in a Portal\n * (default: `true`)\n */\n portalled?: boolean;\n }\n>;\n\ntype TooltipContentImplPrimitive = Polymorphic.ForwardRefComponent<\n Polymorphic.IntrinsicElement<typeof PopperPrimitive.Content>,\n TooltipContentImplOwnProps\n>;\n\nconst TooltipContentImpl = React.forwardRef((props, forwardedRef) => {\n const { children, 'aria-label': ariaLabel, portalled = true, ...contentProps } = props;\n const context = useTooltipContext(CONTENT_NAME);\n const PortalWrapper = portalled ? Portal : React.Fragment;\n\n useEscapeKeydown(() => context.onClose());\n\n return (\n <PortalWrapper>\n <CheckTriggerMoved />\n <PopperPrimitive.Content\n data-state={context.stateAttribute}\n {...contentProps}\n ref={forwardedRef}\n style={{\n ...contentProps.style,\n // re-namespace exposed content custom property\n ['--radix-tooltip-content-transform-origin' as any]: 'var(--radix-popper-transform-origin)',\n }}\n >\n <Slottable>{children}</Slottable>\n <VisuallyHiddenPrimitive.Root id={context.contentId} role=\"tooltip\">\n {ariaLabel || children}\n </VisuallyHiddenPrimitive.Root>\n </PopperPrimitive.Content>\n </PortalWrapper>\n );\n}) as TooltipContentImplPrimitive;\n\nTooltipContent.displayName = CONTENT_NAME;\n\n/* ---------------------------------------------------------------------------------------------- */\n\nconst TooltipArrow = extendPrimitive(PopperPrimitive.Arrow, { displayName: 'TooltipArrow' });\n\n/* -----------------------------------------------------------------------------------------------*/\n\nfunction CheckTriggerMoved() {\n const context = useTooltipContext('CheckTriggerMoved');\n\n const triggerRect = useRect(context.trigger);\n const triggerLeft = triggerRect?.left;\n const previousTriggerLeft = usePrevious(triggerLeft);\n const triggerTop = triggerRect?.top;\n const previousTriggerTop = usePrevious(triggerTop);\n const handleClose = context.onClose;\n\n React.useEffect(() => {\n // checking if the user has scrolled…\n const hasTriggerMoved =\n (previousTriggerLeft !== undefined && previousTriggerLeft !== triggerLeft) ||\n (previousTriggerTop !== undefined && previousTriggerTop !== triggerTop);\n\n if (hasTriggerMoved) {\n handleClose();\n }\n }, [handleClose, previousTriggerLeft, previousTriggerTop, triggerLeft, triggerTop]);\n\n return null;\n}\n\nconst Root = Tooltip;\nconst Trigger = TooltipTrigger;\nconst Content = TooltipContent;\nconst Arrow = TooltipArrow;\n\nexport {\n Tooltip,\n TooltipTrigger,\n TooltipContent,\n TooltipArrow,\n //\n Root,\n Trigger,\n Content,\n Arrow,\n};\nexport type { TooltipTriggerPrimitive, TooltipContentPrimitive };\n"],"names":["a","__esModule","default","$parcel$exportWildcard","dest","source","Object","keys","forEach","key","defineProperty","enumerable","get","assign","assignFn","type","delayTimerId","skipDelayTimerId","setId","$fb910db130fc9c6f19b2800f728d3b10$export$assign","context","event","_id","id","stateMachine","stateChart","debug","warnOnUnknownTransitions","currentState","initial","currentContext","subscriptions","send","_stateChart$on","_stateDefinition$on","stateDefinition","states","topLevelTransition","on","stateTransition","transition","undefined","console","warn","target","nextState","actions","cond","nextStateDefinition","allActions","exit","concat","entry","nextContext","action","executeActions","group","log","groupEnd","callback","state","subscribe","push","splice","indexOf","getContext","$fb910db130fc9c6f19b2800f728d3b10$export$createStateMachine","delayed","FOCUS","closed","OPEN","opening","delayDuration","sendTimerEnd","window","setTimeout","clearTimeout","DELAY_TIMER_END","CLOSE","open","closing","_skipDelayDuration","skipDelayDuration","SKIP_DELAY_TIMER_END","TooltipProvider","useTooltipContext","createContext","Tooltip","props","children","openProp","defaultOpen","onOpenChange","trigger","setTrigger","React","useState","contentId","useId","setOpen","useControllableState","prop","defaultProp","onChange","stateAttribute","setStateAttribute","useEffect","handleFocus","useCallback","handleOpen","handleClose","useLayoutEffect","_react","createElement","_radixUiReactPopper","Root","$bfd2ef98f93cfd0786881e49eeb6a4$var$TooltipProvider","onTriggerChange","onFocus","onOpen","onClose","TRIGGER_DEFAULT_TAG","TooltipTrigger","forwardRef","forwardedRef","as","triggerProps","composedTriggerRef","useComposedRefs","node","Anchor","_babelRuntimeHelpersExtends","aria-describedby","data-state","ref","onMouseEnter","composeEventHandlers","onMouseLeave","onMouseDown","onBlur","onKeyDown","TooltipContent","forceMount","contentProps","Presence","present","$bfd2ef98f93cfd0786881e49eeb6a4$var$TooltipContentImpl","TooltipContentImpl","aria-label","ariaLabel","portalled","PortalWrapper","Portal","Fragment","useEscapeKeydown","$bfd2ef98f93cfd0786881e49eeb6a4$var$CheckTriggerMoved","Content","style","--radix-tooltip-content-transform-origin","Slottable","_radixUiReactVisuallyHidden","role","TooltipArrow","extendPrimitive","PopperPrimitive","Arrow","displayName","CheckTriggerMoved","triggerRect","useRect","triggerLeft","left","previousTriggerLeft","usePrevious","triggerTop","top","previousTriggerTop","Trigger"],"version":3,"file":"index.js.map"}
@@ -1,2 +1,2 @@
1
- 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;
1
+ 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{extendPrimitive as i}from"@radix-ui/react-primitive";import{Presence as a}from"@radix-ui/react-presence";import{useRect as s}from"@radix-ui/react-use-rect";import{usePrevious as l}from"@radix-ui/react-use-previous";import{useLayoutEffect as c}from"@radix-ui/react-use-layout-effect";import{useEscapeKeydown as u}from"@radix-ui/react-use-escape-keydown";import{useControllableState as p}from"@radix-ui/react-use-controllable-state";import{createContext as d}from"@radix-ui/react-context";import{useComposedRefs as m}from"@radix-ui/react-compose-refs";import{composeEventHandlers as f}from"@radix-ui/primitive";import*as g from"react";import E from"@babel/runtime/helpers/esm/extends";function x(e){return{type:"machine.actions.assign",assign:e}}let y,T;const C=x(((e,t)=>{var o;return{...e,id:null!==(o=t.id)&&void 0!==o?o:e.id}})),v=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],m=null===(c=u.on)||void 0===c?void 0:c[p],f=null!=d?d:m;if(void 0===f)o&&console.warn(`From state: "${n}", event "${p}" has no transition to any state`);else{const{target:o,actions:l=[],cond:c=(()=>!0)}=f,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:[x((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():y=window.setTimeout(r,n)},C,x((e=>({...e,delayed:!0})))],exit:[()=>clearTimeout(y)],on:{DELAY_TIMER_END:{target:"open"},CLOSE:{target:"closed"}}},open:{entry:[C],exit:[x((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;T=window.setTimeout((()=>o({type:"SKIP_DELAY_TIMER_END"})),r)}],exit:[()=>clearTimeout(T)],on:{OPEN:{target:"open"},SKIP_DELAY_TIMER_END:{target:"closed"}}}}}),[b,D]=d("Tooltip");export const Tooltip=t=>{const{children:o,open:n,defaultOpen:i=!1,onOpenChange:a,delayDuration:s=700,skipDelayDuration:l=300}=t,[u,d]=g.useState(null),m=e(),[f=!1,E]=p({prop:n,defaultProp:i,onChange:a}),[x,y]=g.useState(n?"instant-open":"closed");g.useEffect((()=>v.subscribe((({state:e,context:t})=>{"open"===e&&t.id===m?E(!0):E(!1)}))),[m,E]),g.useEffect((()=>v.subscribe((({state:e,context:t})=>{t.id===m?y("open"===e?t.delayed?"delayed-open":"instant-open":"closed"):y("closed")}))),[m]);const T=g.useCallback((()=>v.send({type:"FOCUS",id:m})),[m]),C=g.useCallback((()=>v.send({type:"OPEN",id:m,delayDuration:s})),[m,s]),D=g.useCallback((()=>v.send({type:"CLOSE",id:m,skipDelayDuration:l})),[l,m]);return g.useEffect((()=>()=>D()),[D]),c((()=>{!0===n&&v.send({type:"OPEN",id:m})}),[m,n]),/*#__PURE__*/g.createElement(r.Root,null,/*#__PURE__*/g.createElement(b,{contentId:m,open:f,stateAttribute:x,trigger:u,onTriggerChange:d,onFocus:T,onOpen:C,onClose:D},o))};/*#__PURE__*/const w="button";export const TooltipTrigger=/*#__PURE__*/g.forwardRef(((e,t)=>{const{as:o=w,...n}=e,i=D("TooltipTrigger"),a=m(t,(e=>i.onTriggerChange(e)));/*#__PURE__*/return g.createElement(r.Anchor,E({type:"button","aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute},n,{as:o,ref:a,onMouseEnter:f(e.onMouseEnter,i.onOpen),onMouseLeave:f(e.onMouseLeave,i.onClose),onMouseDown:f(e.onMouseDown,i.onClose),onFocus:f(e.onFocus,i.onFocus),onBlur:f(e.onBlur,i.onClose),onKeyDown:f(e.onKeyDown,(e=>{"Enter"!==e.key&&" "!==e.key||i.onClose()}))}))}));/*#__PURE__*/export const TooltipContent=/*#__PURE__*/g.forwardRef(((e,t)=>{const{forceMount:o,...n}=e,r=D("TooltipContent");/*#__PURE__*/return g.createElement(a,{present:o||r.open},/*#__PURE__*/g.createElement(h,E({ref:t},n)))}));const h=/*#__PURE__*/g.forwardRef(((e,i)=>{const{children:a,"aria-label":s,portalled:l=!0,...c}=e,p=D("TooltipContent"),d=l?n:g.Fragment;return u((()=>p.onClose())),/*#__PURE__*/g.createElement(d,null,/*#__PURE__*/g.createElement(O,null),/*#__PURE__*/g.createElement(r.Content,E({"data-state":p.stateAttribute},c,{ref:i,style:{...c.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)"}}),/*#__PURE__*/g.createElement(o,null,a),/*#__PURE__*/g.createElement(t.Root,{id:p.contentId,role:"tooltip"},s||a)))}));/*#__PURE__*/export const TooltipArrow=i(r.Arrow,{displayName:"TooltipArrow"});function O(){const e=D("CheckTriggerMoved"),t=s(e.trigger),o=null==t?void 0:t.left,n=l(o),r=null==t?void 0:t.top,i=l(r),a=e.onClose;return g.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;
2
2
  //# sourceMappingURL=index.module.js.map
@@ -1 +1 @@
1
- {"mappings":"w6BA8HA,SAASA,EACPC,GAEA,MAAO,CAAEC,KAjIgB,yBAiIUF,OAAQC,GC9G7C,IAAIE,EACAC,EAEJ,MAsBMC,EAAuBC,GAAO,CAACC,EAASC,KAAV,IAAAC,EAAA,MAAqB,IACpDF,EACHG,GAAE,QAAAD,EAAGD,EAAcE,UAAjB,IAAAD,EAAAA,EAAuBF,EAAQG,OCpB7BC,EFSN,SACEC,GACAC,MAAEA,GAAQ,EAAVC,yBAAiBA,GAA2B,GAAkB,IAE9D,IAAIC,EAAeH,EAAWI,QAC1BC,EAAiBL,EAAWL,QAGhC,MAAMW,EAAmC,GAanCC,EAAQX,IAAiB,IAAAY,EAAAC,EAC7B,MAAMC,EAAkBV,EAAWW,OAAOR,GACpCb,EAAkCM,EAAMN,KACxCsB,EAAiE,QAAAJ,EAAGR,EAAWa,UAAd,IAAAL,OAAA,EAAGA,EAAgBlB,GACpFwB,EAA8D,QAAAL,EAClEC,EAAgBG,UADkD,IAAAJ,OAAA,EAClEA,EAAqBnB,GACjByB,EAAaH,MAAAA,EAAAA,EAAsBE,EAEzC,QAAmBE,IAAfD,EACEb,GACFe,QAAQC,KACL,gBAAef,cAAyBb,yCAGxC,CACL,MAAQ6B,OAAQC,EAAVC,QAAqBA,EAAU,GAA/BC,KAAmCA,EAAO,MAAM,IAASP,EACzDQ,EAAsBH,EAAYpB,EAAWW,OAAOS,GAAa,GAEvE,GAAIE,EAAKjB,EAAgBT,GAAQ,CAE/B,MAAM4B,GAAcd,EAAgBe,MAAQ,IAAIC,OAC9C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AcC,EAAQrJ,EAAQ0E,YAC9B4E,EAAcF,MAAAA,OAAH,EAAGA,EAAaG,KAC3BC,EAAsBC,EAAYH,GAClCI,EAAaN,MAAAA,OAAH,EAAGA,EAAaO,IAC1BC,EAAqBH,EAAYC,GACjC/D,EAAc3F,EAAQkG,QAa5B,OAXAvB,EAAMY,WAAU,WAGalE,IAAxBmI,GAAqCA,IAAwBF,QACtCjI,IAAvBuI,GAAoCA,IAAuBF,IAG5D/D,MAED,CAACA,EAAa6D,EAAqBI,EAAoBN,EAAaI,IAEhE,YAGT,MAAMjB,KAAOrE,eACb,MAAMyF,QAAUxD,sBAChB,MAAMyD,QAAUtC,sBAChB,MAAM0B,MAAQH","sources":["./packages/react/tooltip/src/createStateMachine.tsx","./packages/react/tooltip/src/tooltipStateChart.tsx","./packages/react/tooltip/src/Tooltip.tsx"],"sourcesContent":["const ASSIGN_ACTION_TYPE = 'machine.actions.assign' as const;\n\nconst isProduction = process.env.NODE_ENV === 'production';\n\ntype StateChart<State extends string, Context, Event extends { type: string }> = {\n initial: State;\n context: Context;\n on?: {\n [eventType in Event['type']]?: Transition<State, Context, Event>;\n };\n states: {\n [stateValue in State]: {\n on?: {\n [eventType in Event['type']]?: Transition<State, Context, Event>;\n };\n entry?: Array<Action<Context, Event>>;\n exit?: Array<Action<Context, Event>>;\n };\n };\n};\n\ntype Transition<State extends string, Context, Event> = {\n target?: State;\n actions?: Array<Action<Context, Event>>;\n cond?: (context: Context, Event: Event) => boolean;\n};\n\ntype Action<Context, Event> = ActionFunction<Context, Event> | AssignAction<Context, Event>;\n\ntype ActionFunction<Context, Event> = (\n context: Context,\n event: Event,\n send: (event: Event) => void\n) => void;\n\nfunction createStateMachine<State extends string, Context, Event extends { type: string }>(\n stateChart: StateChart<State, Context, Event>,\n { debug = false, warnOnUnknownTransitions = !isProduction } = {}\n) {\n let currentState = stateChart.initial;\n let currentContext = stateChart.context;\n\n type CallbackFn = (args: { state: State; context: Context }) => void;\n const subscriptions: Array<CallbackFn> = [];\n\n function subscribe(callback: CallbackFn) {\n subscriptions.push(callback);\n return () => {\n subscriptions.splice(subscriptions.indexOf(callback), 1);\n };\n }\n\n function notify() {\n subscriptions.forEach((callback) => callback({ state: currentState, context: currentContext }));\n }\n\n const send = (event: Event) => {\n const stateDefinition = stateChart.states[currentState];\n const type: Event['type'] | undefined = event.type;\n const topLevelTransition: Transition<State, Context, Event> | undefined = stateChart.on?.[type];\n const stateTransition: Transition<State, Context, Event> | undefined =\n stateDefinition.on?.[type];\n const transition = topLevelTransition ?? stateTransition;\n\n if (transition === undefined) {\n if (warnOnUnknownTransitions) {\n console.warn(\n `From state: \"${currentState}\", event \"${type}\" has no transition to any state`\n );\n }\n } else {\n const { target: nextState, actions = [], cond = () => true } = transition;\n const nextStateDefinition = nextState ? stateChart.states[nextState] : {};\n\n if (cond(currentContext, event)) {\n // execute actions\n const allActions = (stateDefinition.exit || []).concat(\n actions,\n nextStateDefinition.entry || []\n );\n currentContext = executeActions(allActions, event, currentContext);\n\n if (nextState) {\n currentState = nextState;\n\n if (debug) {\n console.group('event:', event);\n console.log('state:', currentState);\n console.log('context:', currentContext);\n console.groupEnd();\n }\n\n notify();\n }\n }\n }\n };\n\n function getContext() {\n return currentContext;\n }\n\n function executeActions(\n actions: Array<Action<Context, Event>>,\n event: Event,\n context: Context\n ): Context {\n let nextContext = context;\n actions?.forEach((action) => {\n if (typeof action === 'function') {\n action(nextContext, event, send);\n } else if (action.type === ASSIGN_ACTION_TYPE) {\n nextContext = action.assign(nextContext, event);\n }\n });\n return nextContext;\n }\n\n return { subscribe, send, getContext };\n}\n\ntype AssignAction<Context, Event> = {\n type: typeof ASSIGN_ACTION_TYPE;\n assign(context: Context, event: Event): Context;\n};\n\nfunction assign<Context, Event>(\n assignFn: AssignAction<Context, Event>['assign']\n): AssignAction<Context, Event> {\n return { type: ASSIGN_ACTION_TYPE, assign: assignFn };\n}\n\nexport { createStateMachine, assign };\nexport type { StateChart, Action };\n","import { assign } from './createStateMachine';\n\nimport type { StateChart, Action } from './createStateMachine';\n\ntype TooltipState = 'closed' | 'opening' | 'open' | 'closing';\n\ntype TooltipEvent =\n | { type: 'OPEN'; id: string; delayDuration?: number }\n | { type: 'CLOSE'; id: string; skipDelayDuration: number }\n | { type: 'FOCUS'; id: string }\n | { type: 'DELAY_TIMER_END' }\n | { type: 'SKIP_DELAY_TIMER_END' };\n\ntype TooltipContext = { id: string | null; delayed: boolean };\n\ntype TooltipStateChart = StateChart<TooltipState, TooltipContext, TooltipEvent>;\ntype TooltipAction = Action<TooltipContext, TooltipEvent>;\n\n// actions\nlet delayTimerId: number;\nlet skipDelayTimerId: number;\n\nconst startDelayTimer: TooltipAction = (context, event, send) => {\n const delayDuration: number | undefined = (event as any).delayDuration;\n const sendTimerEnd = () => send({ type: 'DELAY_TIMER_END' });\n if (delayDuration === undefined) {\n sendTimerEnd();\n } else {\n delayTimerId = window.setTimeout(sendTimerEnd, delayDuration);\n }\n};\n\nconst cancelDelayTimer: TooltipAction = () => clearTimeout(delayTimerId);\n\nconst startSkipDelayTimer: TooltipAction = (context, event, send) => {\n const skipDelayDuration: number = (event as any).skipDelayDuration ?? 300;\n skipDelayTimerId = window.setTimeout(\n () => send({ type: 'SKIP_DELAY_TIMER_END' }),\n skipDelayDuration\n );\n};\n\nconst cancelSkipDelayTimer: TooltipAction = () => clearTimeout(skipDelayTimerId);\n\nconst setId: TooltipAction = assign((context, event) => ({\n ...context,\n id: (event as any).id ?? context.id,\n}));\nconst resetId: TooltipAction = assign((context) => ({ ...context, id: null }));\nconst setDelayed: TooltipAction = assign((context) => ({ ...context, delayed: true }));\nconst resetDelayed: TooltipAction = assign((context) => ({ ...context, delayed: false }));\n\nconst tooltipStateChart: TooltipStateChart = {\n initial: 'closed',\n context: { id: null, delayed: false },\n on: {\n FOCUS: { target: 'open' },\n },\n states: {\n closed: {\n entry: [resetId],\n on: {\n OPEN: { target: 'opening' },\n },\n },\n\n opening: {\n entry: [startDelayTimer, setId, setDelayed],\n exit: [cancelDelayTimer],\n on: {\n DELAY_TIMER_END: { target: 'open' },\n CLOSE: { target: 'closed' },\n },\n },\n\n open: {\n entry: [setId],\n exit: [resetDelayed],\n on: {\n OPEN: { target: 'open' },\n CLOSE: {\n target: 'closing',\n cond: (context, event) => context.id === (event as any).id,\n },\n },\n },\n\n closing: {\n entry: [startSkipDelayTimer],\n exit: [cancelSkipDelayTimer],\n on: {\n OPEN: { target: 'open' },\n SKIP_DELAY_TIMER_END: { target: 'closed' },\n },\n },\n },\n};\n\nexport { tooltipStateChart };\n","import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createContext } from '@radix-ui/react-context';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport { useEscapeKeydown } from '@radix-ui/react-use-escape-keydown';\nimport { useLayoutEffect } from '@radix-ui/react-use-layout-effect';\nimport { usePrevious } from '@radix-ui/react-use-previous';\nimport { useRect } from '@radix-ui/react-use-rect';\nimport { Presence } from '@radix-ui/react-presence';\nimport { Primitive, extendPrimitive } from '@radix-ui/react-primitive';\nimport * as PopperPrimitive from '@radix-ui/react-popper';\nimport { Portal } from '@radix-ui/react-portal';\nimport { Slottable } from '@radix-ui/react-slot';\nimport * as VisuallyHiddenPrimitive from '@radix-ui/react-visually-hidden';\nimport { useId } from '@radix-ui/react-id';\nimport { createStateMachine } from './createStateMachine';\nimport { tooltipStateChart } from './tooltipStateChart';\n\nimport type * as Polymorphic from '@radix-ui/react-polymorphic';\n\n/* -------------------------------------------------------------------------------------------------\n * State machine\n * -----------------------------------------------------------------------------------------------*/\n\ntype StateAttribute = 'closed' | 'delayed-open' | 'instant-open';\nconst stateMachine = createStateMachine(tooltipStateChart);\n\n/* -------------------------------------------------------------------------------------------------\n * Tooltip\n * -----------------------------------------------------------------------------------------------*/\n\nconst TOOLTIP_NAME = 'Tooltip';\n\ntype TooltipContextValue = {\n triggerRef: React.RefObject<HTMLButtonElement>;\n contentId: string;\n open: boolean;\n stateAttribute: StateAttribute;\n onFocus(): void;\n onOpen(): void;\n onClose(): void;\n};\n\nconst [TooltipProvider, useTooltipContext] = createContext<TooltipContextValue>(TOOLTIP_NAME);\n\ntype TooltipOwnProps = {\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n\n /**\n * The duration from when the mouse enters the trigger until the tooltip gets opened.\n * (default: 700)\n */\n delayDuration?: number;\n\n /**\n * How much time a user has to enter another trigger without incurring a delay again.\n * (default: 300)\n */\n skipDelayDuration?: number;\n};\n\nconst Tooltip: React.FC<TooltipOwnProps> = (props) => {\n const {\n children,\n open: openProp,\n defaultOpen = false,\n onOpenChange,\n delayDuration = 700,\n skipDelayDuration = 300,\n } = props;\n const triggerRef = React.useRef<HTMLButtonElement>(null);\n const contentId = useId();\n const [open = false, setOpen] = useControllableState({\n prop: openProp,\n defaultProp: defaultOpen,\n onChange: onOpenChange,\n });\n const [stateAttribute, setStateAttribute] = React.useState<StateAttribute>(\n openProp ? 'instant-open' : 'closed'\n );\n\n // control open state using state machine subscription\n React.useEffect(() => {\n const unsubscribe = stateMachine.subscribe(({ state, context }) => {\n if (state === 'open' && context.id === contentId) {\n setOpen(true);\n } else {\n setOpen(false);\n }\n });\n\n return unsubscribe;\n }, [contentId, setOpen]);\n\n // sync state attribute with using state machine subscription\n React.useEffect(() => {\n const unsubscribe = stateMachine.subscribe(({ state, context }) => {\n if (context.id === contentId) {\n if (state === 'open') {\n setStateAttribute(context.delayed ? 'delayed-open' : 'instant-open');\n } else {\n setStateAttribute('closed');\n }\n } else {\n setStateAttribute('closed');\n }\n });\n\n return unsubscribe;\n }, [contentId]);\n\n const handleFocus = React.useCallback(() => stateMachine.send({ type: 'FOCUS', id: contentId }), [\n contentId,\n ]);\n const handleOpen = React.useCallback(\n () => stateMachine.send({ type: 'OPEN', id: contentId, delayDuration }),\n [contentId, delayDuration]\n );\n const handleClose = React.useCallback(\n () => stateMachine.send({ type: 'CLOSE', id: contentId, skipDelayDuration }),\n [skipDelayDuration, contentId]\n );\n\n // send transition if the component unmounts\n React.useEffect(() => () => handleClose(), [handleClose]);\n\n // if we're controlling the component\n // put the state machine in the appropriate state\n useLayoutEffect(() => {\n if (openProp === true) {\n stateMachine.send({ type: 'OPEN', id: contentId });\n }\n }, [contentId, openProp]);\n\n return (\n <TooltipProvider\n triggerRef={triggerRef}\n contentId={contentId}\n open={open}\n stateAttribute={stateAttribute}\n onFocus={handleFocus}\n onOpen={handleOpen}\n onClose={handleClose}\n >\n {children}\n </TooltipProvider>\n );\n};\n\nTooltip.displayName = TOOLTIP_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * TooltipTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'TooltipTrigger';\nconst TRIGGER_DEFAULT_TAG = 'button';\n\ntype TooltipTriggerOwnProps = Polymorphic.OwnProps<typeof Primitive>;\ntype TooltipTriggerPrimitive = Polymorphic.ForwardRefComponent<\n typeof TRIGGER_DEFAULT_TAG,\n TooltipTriggerOwnProps\n>;\n\nconst TooltipTrigger = React.forwardRef((props, forwardedRef) => {\n const { as = TRIGGER_DEFAULT_TAG, ...triggerProps } = props;\n const context = useTooltipContext(TRIGGER_NAME);\n const composedTriggerRef = useComposedRefs(forwardedRef, context.triggerRef);\n\n return (\n <Primitive\n type=\"button\"\n aria-describedby={context.open ? context.contentId : undefined}\n data-state={context.stateAttribute}\n {...triggerProps}\n as={as}\n ref={composedTriggerRef}\n onMouseEnter={composeEventHandlers(props.onMouseEnter, context.onOpen)}\n onMouseLeave={composeEventHandlers(props.onMouseLeave, context.onClose)}\n onMouseDown={composeEventHandlers(props.onMouseDown, context.onClose)}\n onFocus={composeEventHandlers(props.onFocus, context.onFocus)}\n onBlur={composeEventHandlers(props.onBlur, context.onClose)}\n onKeyDown={composeEventHandlers(props.onKeyDown, (event) => {\n if (event.key === 'Enter' || event.key === ' ') {\n context.onClose();\n }\n })}\n />\n );\n}) as TooltipTriggerPrimitive;\n\nTooltipTrigger.displayName = TRIGGER_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * TooltipContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'TooltipContent';\n\ntype TooltipContentOwnProps = Polymorphic.Merge<\n Polymorphic.OwnProps<typeof TooltipContentImpl>,\n {\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true;\n }\n>;\n\ntype TooltipContentPrimitive = Polymorphic.ForwardRefComponent<\n Polymorphic.IntrinsicElement<typeof TooltipContentImpl>,\n TooltipContentOwnProps\n>;\n\nconst TooltipContent = React.forwardRef((props, forwardedRef) => {\n const { forceMount, ...contentProps } = props;\n const context = useTooltipContext(CONTENT_NAME);\n return (\n <Presence present={forceMount || context.open}>\n <TooltipContentImpl ref={forwardedRef} {...contentProps} />\n </Presence>\n );\n}) as TooltipContentPrimitive;\n\ntype PopperPrimitiveOwnProps = Polymorphic.OwnProps<typeof PopperPrimitive.Root>;\ntype TooltipContentImplOwnProps = Polymorphic.Merge<\n PopperPrimitiveOwnProps,\n {\n /**\n * A more descriptive label for accessibility purpose\n */\n 'aria-label'?: string;\n\n anchorRef?: PopperPrimitiveOwnProps['anchorRef'];\n\n /**\n * Whether the Tooltip should render in a Portal\n * (default: `true`)\n */\n portalled?: boolean;\n }\n>;\n\ntype TooltipContentImplPrimitive = Polymorphic.ForwardRefComponent<\n Polymorphic.IntrinsicElement<typeof PopperPrimitive.Root>,\n TooltipContentImplOwnProps\n>;\n\nconst TooltipContentImpl = React.forwardRef((props, forwardedRef) => {\n const { children, 'aria-label': ariaLabel, anchorRef, portalled = true, ...contentProps } = props;\n const context = useTooltipContext(CONTENT_NAME);\n const PortalWrapper = portalled ? Portal : React.Fragment;\n\n useEscapeKeydown(() => context.onClose());\n\n return (\n <PortalWrapper>\n <CheckTriggerMoved />\n <PopperPrimitive.Root\n data-state={context.stateAttribute}\n {...contentProps}\n ref={forwardedRef}\n anchorRef={anchorRef || context.triggerRef}\n style={{\n ...contentProps.style,\n // re-namespace exposed content custom property\n ['--radix-tooltip-content-transform-origin' as any]: 'var(--radix-popper-transform-origin)',\n }}\n >\n <Slottable>{children}</Slottable>\n <VisuallyHiddenPrimitive.Root id={context.contentId} role=\"tooltip\">\n {ariaLabel || children}\n </VisuallyHiddenPrimitive.Root>\n </PopperPrimitive.Root>\n </PortalWrapper>\n );\n}) as TooltipContentImplPrimitive;\n\nTooltipContent.displayName = CONTENT_NAME;\n\n/* ---------------------------------------------------------------------------------------------- */\n\nconst TooltipArrow = extendPrimitive(PopperPrimitive.Arrow, { displayName: 'TooltipArrow' });\n\n/* -----------------------------------------------------------------------------------------------*/\n\nfunction CheckTriggerMoved() {\n const context = useTooltipContext('CheckTriggerMoved');\n\n const triggerRect = useRect(context.triggerRef);\n const triggerLeft = triggerRect?.left;\n const previousTriggerLeft = usePrevious(triggerLeft);\n const triggerTop = triggerRect?.top;\n const previousTriggerTop = usePrevious(triggerTop);\n const handleClose = context.onClose;\n\n React.useEffect(() => {\n // checking if the user has scrolled…\n const hasTriggerMoved =\n (previousTriggerLeft !== undefined && previousTriggerLeft !== triggerLeft) ||\n (previousTriggerTop !== undefined && previousTriggerTop !== triggerTop);\n\n if (hasTriggerMoved) {\n handleClose();\n }\n }, [handleClose, previousTriggerLeft, previousTriggerTop, triggerLeft, triggerTop]);\n\n return null;\n}\n\nconst Root = Tooltip;\nconst Trigger = TooltipTrigger;\nconst Content = TooltipContent;\nconst Arrow = TooltipArrow;\n\nexport {\n Tooltip,\n TooltipTrigger,\n TooltipContent,\n TooltipArrow,\n //\n Root,\n Trigger,\n Content,\n Arrow,\n};\n"],"names":["assign","assignFn","type","delayTimerId","skipDelayTimerId","setId","$ef54466d8a95ecaa234e3ec978fbe68$export$assign","context","event","_id","id","stateMachine","stateChart","debug","warnOnUnknownTransitions","currentState","initial","currentContext","subscriptions","send","_stateChart$on","_stateDefinition$on","stateDefinition","states","topLevelTransition","on","stateTransition","transition","undefined","console","warn","target","nextState","actions","cond","nextStateDefinition","allActions","exit","concat","entry","nextContext","forEach","action","executeActions","group","log","groupEnd","callback","state","subscribe","push","splice","indexOf","getContext","$ef54466d8a95ecaa234e3ec978fbe68$export$createStateMachine","delayed","FOCUS","closed","OPEN","opening","delayDuration","sendTimerEnd","window","setTimeout","clearTimeout","DELAY_TIMER_END","CLOSE","open","closing","_skipDelayDuration","skipDelayDuration","SKIP_DELAY_TIMER_END","TooltipProvider","useTooltipContext","createContext","Tooltip","props","children","openProp","defaultOpen","onOpenChange","triggerRef","React","useRef","contentId","useId","setOpen","useControllableState","prop","defaultProp","onChange","stateAttribute","setStateAttribute","useState","useEffect","handleFocus","useCallback","handleOpen","handleClose","useLayoutEffect","_react","createElement","$badf5d6f88b7e9fa4e0bb85d71c0396a$var$TooltipProvider","onFocus","onOpen","onClose","displayName","TRIGGER_DEFAULT_TAG","TooltipTrigger","forwardRef","forwardedRef","as","triggerProps","composedTriggerRef","useComposedRefs","Primitive","_babelRuntimeHelpersEsmExtends","aria-describedby","data-state","ref","onMouseEnter","composeEventHandlers","onMouseLeave","onMouseDown","onBlur","onKeyDown","key","TooltipContent","forceMount","contentProps","Presence","present","$badf5d6f88b7e9fa4e0bb85d71c0396a$var$TooltipContentImpl","TooltipContentImpl","aria-label","ariaLabel","anchorRef","portalled","PortalWrapper","Portal","Fragment","useEscapeKeydown","$badf5d6f88b7e9fa4e0bb85d71c0396a$var$CheckTriggerMoved","_radixUiReactPopper","Root","style","--radix-tooltip-content-transform-origin","Slottable","_radixUiReactVisuallyHidden","role","TooltipArrow","extendPrimitive","PopperPrimitive","Arrow","CheckTriggerMoved","triggerRect","useRect","triggerLeft","left","previousTriggerLeft","usePrevious","triggerTop","top","previousTriggerTop","Trigger","Content"],"version":3,"file":"index.module.js.map"}
1
+ {"mappings":"y5BA8HA,SAASA,EACPC,GAEA,MAAO,CAAEC,KAjIgB,yBAiIUF,OAAQC,GC9G7C,IAAIE,EACAC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MmC,QAAUf,sBAChB,MAAMwB,MAAQH","sources":["./packages/react/tooltip/src/createStateMachine.tsx","./packages/react/tooltip/src/tooltipStateChart.tsx","./packages/react/tooltip/src/Tooltip.tsx"],"sourcesContent":["const ASSIGN_ACTION_TYPE = 'machine.actions.assign' as const;\n\nconst isProduction = process.env.NODE_ENV === 'production';\n\ntype StateChart<State extends string, Context, Event extends { type: string }> = {\n initial: State;\n context: Context;\n on?: {\n [eventType in Event['type']]?: Transition<State, Context, Event>;\n };\n states: {\n [stateValue in State]: {\n on?: {\n [eventType in Event['type']]?: Transition<State, Context, Event>;\n };\n entry?: Array<Action<Context, Event>>;\n exit?: Array<Action<Context, Event>>;\n };\n };\n};\n\ntype Transition<State extends string, Context, Event> = {\n target?: State;\n actions?: Array<Action<Context, Event>>;\n cond?: (context: Context, Event: Event) => boolean;\n};\n\ntype Action<Context, Event> = ActionFunction<Context, Event> | AssignAction<Context, Event>;\n\ntype ActionFunction<Context, Event> = (\n context: Context,\n event: Event,\n send: (event: Event) => void\n) => void;\n\nfunction createStateMachine<State extends string, Context, Event extends { type: string }>(\n stateChart: StateChart<State, Context, Event>,\n { debug = false, warnOnUnknownTransitions = !isProduction } = {}\n) {\n let currentState = stateChart.initial;\n let currentContext = stateChart.context;\n\n type CallbackFn = (args: { state: State; context: Context }) => void;\n const subscriptions: Array<CallbackFn> = [];\n\n function subscribe(callback: CallbackFn) {\n subscriptions.push(callback);\n return () => {\n subscriptions.splice(subscriptions.indexOf(callback), 1);\n };\n }\n\n function notify() {\n subscriptions.forEach((callback) => callback({ state: currentState, context: currentContext }));\n }\n\n const send = (event: Event) => {\n const stateDefinition = stateChart.states[currentState];\n const type: Event['type'] | undefined = event.type;\n const topLevelTransition: Transition<State, Context, Event> | undefined = stateChart.on?.[type];\n const stateTransition: Transition<State, Context, Event> | undefined =\n stateDefinition.on?.[type];\n const transition = topLevelTransition ?? stateTransition;\n\n if (transition === undefined) {\n if (warnOnUnknownTransitions) {\n console.warn(\n `From state: \"${currentState}\", event \"${type}\" has no transition to any state`\n );\n }\n } else {\n const { target: nextState, actions = [], cond = () => true } = transition;\n const nextStateDefinition = nextState ? stateChart.states[nextState] : {};\n\n if (cond(currentContext, event)) {\n // execute actions\n const allActions = (stateDefinition.exit || []).concat(\n actions,\n nextStateDefinition.entry || []\n );\n currentContext = executeActions(allActions, event, currentContext);\n\n if (nextState) {\n currentState = nextState;\n\n if (debug) {\n console.group('event:', event);\n console.log('state:', currentState);\n console.log('context:', currentContext);\n console.groupEnd();\n }\n\n notify();\n }\n }\n }\n };\n\n function getContext() {\n return currentContext;\n }\n\n function executeActions(\n actions: Array<Action<Context, Event>>,\n event: Event,\n context: Context\n ): Context {\n let nextContext = context;\n actions?.forEach((action) => {\n if (typeof action === 'function') {\n action(nextContext, event, send);\n } else if (action.type === ASSIGN_ACTION_TYPE) {\n nextContext = action.assign(nextContext, event);\n }\n });\n return nextContext;\n }\n\n return { subscribe, send, getContext };\n}\n\ntype AssignAction<Context, Event> = {\n type: typeof ASSIGN_ACTION_TYPE;\n assign(context: Context, event: Event): Context;\n};\n\nfunction assign<Context, Event>(\n assignFn: AssignAction<Context, Event>['assign']\n): AssignAction<Context, Event> {\n return { type: ASSIGN_ACTION_TYPE, assign: assignFn };\n}\n\nexport { createStateMachine, assign };\nexport type { StateChart, Action };\n","import { assign } from './createStateMachine';\n\nimport type { StateChart, Action } from './createStateMachine';\n\ntype TooltipState = 'closed' | 'opening' | 'open' | 'closing';\n\ntype TooltipEvent =\n | { type: 'OPEN'; id: string; delayDuration?: number }\n | { type: 'CLOSE'; id: string; skipDelayDuration: number }\n | { type: 'FOCUS'; id: string }\n | { type: 'DELAY_TIMER_END' }\n | { type: 'SKIP_DELAY_TIMER_END' };\n\ntype TooltipContext = { id: string | null; delayed: boolean };\n\ntype TooltipStateChart = StateChart<TooltipState, TooltipContext, TooltipEvent>;\ntype TooltipAction = Action<TooltipContext, TooltipEvent>;\n\n// actions\nlet delayTimerId: number;\nlet skipDelayTimerId: number;\n\nconst startDelayTimer: TooltipAction = (context, event, send) => {\n const delayDuration: number | undefined = (event as any).delayDuration;\n const sendTimerEnd = () => send({ type: 'DELAY_TIMER_END' });\n if (delayDuration === undefined) {\n sendTimerEnd();\n } else {\n delayTimerId = window.setTimeout(sendTimerEnd, delayDuration);\n }\n};\n\nconst cancelDelayTimer: TooltipAction = () => clearTimeout(delayTimerId);\n\nconst startSkipDelayTimer: TooltipAction = (context, event, send) => {\n const skipDelayDuration: number = (event as any).skipDelayDuration ?? 300;\n skipDelayTimerId = window.setTimeout(\n () => send({ type: 'SKIP_DELAY_TIMER_END' }),\n skipDelayDuration\n );\n};\n\nconst cancelSkipDelayTimer: TooltipAction = () => clearTimeout(skipDelayTimerId);\n\nconst setId: TooltipAction = assign((context, event) => ({\n ...context,\n id: (event as any).id ?? context.id,\n}));\nconst resetId: TooltipAction = assign((context) => ({ ...context, id: null }));\nconst setDelayed: TooltipAction = assign((context) => ({ ...context, delayed: true }));\nconst resetDelayed: TooltipAction = assign((context) => ({ ...context, delayed: false }));\n\nconst tooltipStateChart: TooltipStateChart = {\n initial: 'closed',\n context: { id: null, delayed: false },\n on: {\n FOCUS: { target: 'open' },\n },\n states: {\n closed: {\n entry: [resetId],\n on: {\n OPEN: { target: 'opening' },\n },\n },\n\n opening: {\n entry: [startDelayTimer, setId, setDelayed],\n exit: [cancelDelayTimer],\n on: {\n DELAY_TIMER_END: { target: 'open' },\n CLOSE: { target: 'closed' },\n },\n },\n\n open: {\n entry: [setId],\n exit: [resetDelayed],\n on: {\n OPEN: { target: 'open' },\n CLOSE: {\n target: 'closing',\n cond: (context, event) => context.id === (event as any).id,\n },\n },\n },\n\n closing: {\n entry: [startSkipDelayTimer],\n exit: [cancelSkipDelayTimer],\n on: {\n OPEN: { target: 'open' },\n SKIP_DELAY_TIMER_END: { target: 'closed' },\n },\n },\n },\n};\n\nexport { tooltipStateChart };\n","import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createContext } from '@radix-ui/react-context';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport { useEscapeKeydown } from '@radix-ui/react-use-escape-keydown';\nimport { useLayoutEffect } from '@radix-ui/react-use-layout-effect';\nimport { usePrevious } from '@radix-ui/react-use-previous';\nimport { useRect } from '@radix-ui/react-use-rect';\nimport { Presence } from '@radix-ui/react-presence';\nimport { extendPrimitive } from '@radix-ui/react-primitive';\nimport * as PopperPrimitive from '@radix-ui/react-popper';\nimport { Portal } from '@radix-ui/react-portal';\nimport { Slottable } from '@radix-ui/react-slot';\nimport * as VisuallyHiddenPrimitive from '@radix-ui/react-visually-hidden';\nimport { useId } from '@radix-ui/react-id';\nimport { createStateMachine } from './createStateMachine';\nimport { tooltipStateChart } from './tooltipStateChart';\n\nimport type * as Polymorphic from '@radix-ui/react-polymorphic';\n\n/* -------------------------------------------------------------------------------------------------\n * State machine\n * -----------------------------------------------------------------------------------------------*/\n\ntype StateAttribute = 'closed' | 'delayed-open' | 'instant-open';\nconst stateMachine = createStateMachine(tooltipStateChart);\n\n/* -------------------------------------------------------------------------------------------------\n * Tooltip\n * -----------------------------------------------------------------------------------------------*/\n\nconst TOOLTIP_NAME = 'Tooltip';\n\ntype TooltipContextValue = {\n contentId: string;\n open: boolean;\n stateAttribute: StateAttribute;\n trigger: React.ElementRef<typeof TooltipTrigger> | null;\n onTriggerChange(trigger: React.ElementRef<typeof TooltipTrigger> | null): void;\n onFocus(): void;\n onOpen(): void;\n onClose(): void;\n};\n\nconst [TooltipProvider, useTooltipContext] = createContext<TooltipContextValue>(TOOLTIP_NAME);\n\ntype TooltipOwnProps = {\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n\n /**\n * The duration from when the mouse enters the trigger until the tooltip gets opened.\n * (default: 700)\n */\n delayDuration?: number;\n\n /**\n * How much time a user has to enter another trigger without incurring a delay again.\n * (default: 300)\n */\n skipDelayDuration?: number;\n};\n\nconst Tooltip: React.FC<TooltipOwnProps> = (props) => {\n const {\n children,\n open: openProp,\n defaultOpen = false,\n onOpenChange,\n delayDuration = 700,\n skipDelayDuration = 300,\n } = props;\n const [trigger, setTrigger] = React.useState<HTMLButtonElement | null>(null);\n const contentId = useId();\n const [open = false, setOpen] = useControllableState({\n prop: openProp,\n defaultProp: defaultOpen,\n onChange: onOpenChange,\n });\n const [stateAttribute, setStateAttribute] = React.useState<StateAttribute>(\n openProp ? 'instant-open' : 'closed'\n );\n\n // control open state using state machine subscription\n React.useEffect(() => {\n const unsubscribe = stateMachine.subscribe(({ state, context }) => {\n if (state === 'open' && context.id === contentId) {\n setOpen(true);\n } else {\n setOpen(false);\n }\n });\n\n return unsubscribe;\n }, [contentId, setOpen]);\n\n // sync state attribute with using state machine subscription\n React.useEffect(() => {\n const unsubscribe = stateMachine.subscribe(({ state, context }) => {\n if (context.id === contentId) {\n if (state === 'open') {\n setStateAttribute(context.delayed ? 'delayed-open' : 'instant-open');\n } else {\n setStateAttribute('closed');\n }\n } else {\n setStateAttribute('closed');\n }\n });\n\n return unsubscribe;\n }, [contentId]);\n\n const handleFocus = React.useCallback(() => stateMachine.send({ type: 'FOCUS', id: contentId }), [\n contentId,\n ]);\n const handleOpen = React.useCallback(\n () => stateMachine.send({ type: 'OPEN', id: contentId, delayDuration }),\n [contentId, delayDuration]\n );\n const handleClose = React.useCallback(\n () => stateMachine.send({ type: 'CLOSE', id: contentId, skipDelayDuration }),\n [skipDelayDuration, contentId]\n );\n\n // send transition if the component unmounts\n React.useEffect(() => () => handleClose(), [handleClose]);\n\n // if we're controlling the component\n // put the state machine in the appropriate state\n useLayoutEffect(() => {\n if (openProp === true) {\n stateMachine.send({ type: 'OPEN', id: contentId });\n }\n }, [contentId, openProp]);\n\n return (\n <PopperPrimitive.Root>\n <TooltipProvider\n contentId={contentId}\n open={open}\n stateAttribute={stateAttribute}\n trigger={trigger}\n onTriggerChange={setTrigger}\n onFocus={handleFocus}\n onOpen={handleOpen}\n onClose={handleClose}\n >\n {children}\n </TooltipProvider>\n </PopperPrimitive.Root>\n );\n};\n\nTooltip.displayName = TOOLTIP_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * TooltipTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'TooltipTrigger';\nconst TRIGGER_DEFAULT_TAG = 'button';\n\ntype TooltipTriggerOwnProps = Omit<\n Polymorphic.OwnProps<typeof PopperPrimitive.Anchor>,\n 'virtualRef'\n>;\ntype TooltipTriggerPrimitive = Polymorphic.ForwardRefComponent<\n typeof TRIGGER_DEFAULT_TAG,\n TooltipTriggerOwnProps\n>;\n\nconst TooltipTrigger = React.forwardRef((props, forwardedRef) => {\n const { as = TRIGGER_DEFAULT_TAG, ...triggerProps } = props;\n const context = useTooltipContext(TRIGGER_NAME);\n const composedTriggerRef = useComposedRefs(forwardedRef, (node) => context.onTriggerChange(node));\n\n return (\n <PopperPrimitive.Anchor\n type=\"button\"\n aria-describedby={context.open ? context.contentId : undefined}\n data-state={context.stateAttribute}\n {...triggerProps}\n as={as}\n ref={composedTriggerRef}\n onMouseEnter={composeEventHandlers(props.onMouseEnter, context.onOpen)}\n onMouseLeave={composeEventHandlers(props.onMouseLeave, context.onClose)}\n onMouseDown={composeEventHandlers(props.onMouseDown, context.onClose)}\n onFocus={composeEventHandlers(props.onFocus, context.onFocus)}\n onBlur={composeEventHandlers(props.onBlur, context.onClose)}\n onKeyDown={composeEventHandlers(props.onKeyDown, (event) => {\n if (event.key === 'Enter' || event.key === ' ') {\n context.onClose();\n }\n })}\n />\n );\n}) as TooltipTriggerPrimitive;\n\nTooltipTrigger.displayName = TRIGGER_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * TooltipContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'TooltipContent';\n\ntype TooltipContentOwnProps = Polymorphic.Merge<\n Polymorphic.OwnProps<typeof TooltipContentImpl>,\n {\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true;\n }\n>;\n\ntype TooltipContentPrimitive = Polymorphic.ForwardRefComponent<\n Polymorphic.IntrinsicElement<typeof TooltipContentImpl>,\n TooltipContentOwnProps\n>;\n\nconst TooltipContent = React.forwardRef((props, forwardedRef) => {\n const { forceMount, ...contentProps } = props;\n const context = useTooltipContext(CONTENT_NAME);\n return (\n <Presence present={forceMount || context.open}>\n <TooltipContentImpl ref={forwardedRef} {...contentProps} />\n </Presence>\n );\n}) as TooltipContentPrimitive;\n\ntype TooltipContentImplOwnProps = Polymorphic.Merge<\n Polymorphic.OwnProps<typeof PopperPrimitive.Content>,\n {\n /**\n * A more descriptive label for accessibility purpose\n */\n 'aria-label'?: string;\n\n /**\n * Whether the Tooltip should render in a Portal\n * (default: `true`)\n */\n portalled?: boolean;\n }\n>;\n\ntype TooltipContentImplPrimitive = Polymorphic.ForwardRefComponent<\n Polymorphic.IntrinsicElement<typeof PopperPrimitive.Content>,\n TooltipContentImplOwnProps\n>;\n\nconst TooltipContentImpl = React.forwardRef((props, forwardedRef) => {\n const { children, 'aria-label': ariaLabel, portalled = true, ...contentProps } = props;\n const context = useTooltipContext(CONTENT_NAME);\n const PortalWrapper = portalled ? Portal : React.Fragment;\n\n useEscapeKeydown(() => context.onClose());\n\n return (\n <PortalWrapper>\n <CheckTriggerMoved />\n <PopperPrimitive.Content\n data-state={context.stateAttribute}\n {...contentProps}\n ref={forwardedRef}\n style={{\n ...contentProps.style,\n // re-namespace exposed content custom property\n ['--radix-tooltip-content-transform-origin' as any]: 'var(--radix-popper-transform-origin)',\n }}\n >\n <Slottable>{children}</Slottable>\n <VisuallyHiddenPrimitive.Root id={context.contentId} role=\"tooltip\">\n {ariaLabel || children}\n </VisuallyHiddenPrimitive.Root>\n </PopperPrimitive.Content>\n </PortalWrapper>\n );\n}) as TooltipContentImplPrimitive;\n\nTooltipContent.displayName = CONTENT_NAME;\n\n/* ---------------------------------------------------------------------------------------------- */\n\nconst TooltipArrow = extendPrimitive(PopperPrimitive.Arrow, { displayName: 'TooltipArrow' });\n\n/* -----------------------------------------------------------------------------------------------*/\n\nfunction CheckTriggerMoved() {\n const context = useTooltipContext('CheckTriggerMoved');\n\n const triggerRect = useRect(context.trigger);\n const triggerLeft = triggerRect?.left;\n const previousTriggerLeft = usePrevious(triggerLeft);\n const triggerTop = triggerRect?.top;\n const previousTriggerTop = usePrevious(triggerTop);\n const handleClose = context.onClose;\n\n React.useEffect(() => {\n // checking if the user has scrolled…\n const hasTriggerMoved =\n (previousTriggerLeft !== undefined && previousTriggerLeft !== triggerLeft) ||\n (previousTriggerTop !== undefined && previousTriggerTop !== triggerTop);\n\n if (hasTriggerMoved) {\n handleClose();\n }\n }, [handleClose, previousTriggerLeft, previousTriggerTop, triggerLeft, triggerTop]);\n\n return null;\n}\n\nconst Root = Tooltip;\nconst Trigger = TooltipTrigger;\nconst Content = TooltipContent;\nconst Arrow = TooltipArrow;\n\nexport {\n Tooltip,\n TooltipTrigger,\n TooltipContent,\n TooltipArrow,\n //\n Root,\n Trigger,\n Content,\n Arrow,\n};\nexport type { TooltipTriggerPrimitive, TooltipContentPrimitive };\n"],"names":["assign","assignFn","type","delayTimerId","skipDelayTimerId","setId","$ef54466d8a95ecaa234e3ec978fbe68$export$assign","context","event","_id","id","stateMachine","stateChart","debug","warnOnUnknownTransitions","currentState","initial","currentContext","subscriptions","send","_stateChart$on","_stateDefinition$on","stateDefinition","states","topLevelTransition","on","stateTransition","transition","undefined","console","warn","target","nextState","actions","cond","nextStateDefinition","allActions","exit","concat","entry","nextContext","forEach","action","executeActions","group","log","groupEnd","callback","state","subscribe","push","splice","indexOf","getContext","$ef54466d8a95ecaa234e3ec978fbe68$export$createStateMachine","delayed","FOCUS","closed","OPEN","opening","delayDuration","sendTimerEnd","window","setTimeout","clearTimeout","DELAY_TIMER_END","CLOSE","open","closing","_skipDelayDuration","skipDelayDuration","SKIP_DELAY_TIMER_END","TooltipProvider","useTooltipContext","createContext","Tooltip","props","children","openProp","defaultOpen","onOpenChange","trigger","setTrigger","React","useState","contentId","useId","setOpen","useControllableState","prop","defaultProp","onChange","stateAttribute","setStateAttribute","useEffect","handleFocus","useCallback","handleOpen","handleClose","useLayoutEffect","_react","createElement","_radixUiReactPopper","Root","$badf5d6f88b7e9fa4e0bb85d71c0396a$var$TooltipProvider","onTriggerChange","onFocus","onOpen","onClose","TRIGGER_DEFAULT_TAG","TooltipTrigger","forwardRef","forwardedRef","as","triggerProps","composedTriggerRef","useComposedRefs","node","Anchor","_babelRuntimeHelpersEsmExtends","aria-describedby","data-state","ref","onMouseEnter","composeEventHandlers","onMouseLeave","onMouseDown","onBlur","onKeyDown","key","TooltipContent","forceMount","contentProps","Presence","present","$badf5d6f88b7e9fa4e0bb85d71c0396a$var$TooltipContentImpl","TooltipContentImpl","aria-label","ariaLabel","portalled","PortalWrapper","Portal","Fragment","useEscapeKeydown","$badf5d6f88b7e9fa4e0bb85d71c0396a$var$CheckTriggerMoved","Content","style","--radix-tooltip-content-transform-origin","Slottable","_radixUiReactVisuallyHidden","role","TooltipArrow","extendPrimitive","PopperPrimitive","Arrow","displayName","CheckTriggerMoved","triggerRect","useRect","triggerLeft","left","previousTriggerLeft","usePrevious","triggerTop","top","previousTriggerTop","Trigger"],"version":3,"file":"index.module.js.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@radix-ui/react-tooltip",
3
- "version": "0.0.14",
3
+ "version": "0.0.18",
4
4
  "license": "MIT",
5
5
  "source": "src/index.ts",
6
6
  "main": "dist/index.js",
@@ -18,25 +18,26 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "@babel/runtime": "^7.13.10",
21
- "@radix-ui/primitive": "0.0.4",
22
- "@radix-ui/react-compose-refs": "0.0.4",
23
- "@radix-ui/react-context": "0.0.4",
24
- "@radix-ui/react-id": "0.0.4",
25
- "@radix-ui/react-polymorphic": "0.0.9",
26
- "@radix-ui/react-popper": "0.0.13",
27
- "@radix-ui/react-portal": "0.0.10",
28
- "@radix-ui/react-presence": "0.0.12",
29
- "@radix-ui/react-primitive": "0.0.10",
30
- "@radix-ui/react-slot": "0.0.8",
31
- "@radix-ui/react-use-controllable-state": "0.0.5",
32
- "@radix-ui/react-use-escape-keydown": "0.0.5",
33
- "@radix-ui/react-use-layout-effect": "0.0.4",
34
- "@radix-ui/react-use-previous": "0.0.4",
35
- "@radix-ui/react-use-rect": "0.0.5",
36
- "@radix-ui/react-visually-hidden": "0.0.10"
21
+ "@radix-ui/primitive": "0.0.5",
22
+ "@radix-ui/react-compose-refs": "0.0.5",
23
+ "@radix-ui/react-context": "0.0.5",
24
+ "@radix-ui/react-id": "0.0.6",
25
+ "@radix-ui/react-polymorphic": "0.0.11",
26
+ "@radix-ui/react-popper": "0.0.16",
27
+ "@radix-ui/react-portal": "0.0.13",
28
+ "@radix-ui/react-presence": "0.0.14",
29
+ "@radix-ui/react-primitive": "0.0.13",
30
+ "@radix-ui/react-slot": "0.0.10",
31
+ "@radix-ui/react-use-controllable-state": "0.0.6",
32
+ "@radix-ui/react-use-escape-keydown": "0.0.6",
33
+ "@radix-ui/react-use-layout-effect": "0.0.5",
34
+ "@radix-ui/react-use-previous": "0.0.5",
35
+ "@radix-ui/react-use-rect": "0.0.7",
36
+ "@radix-ui/react-visually-hidden": "0.0.13"
37
37
  },
38
38
  "peerDependencies": {
39
- "react": "^16.8 || ^17.0"
39
+ "react": "^16.8 || ^17.0",
40
+ "react-dom": "^16.8 || ^17.0"
40
41
  },
41
42
  "homepage": "https://radix-ui.com/primitives",
42
43
  "repository": {