@jamsrui/tooltip 0.0.12 → 0.0.14

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.mts CHANGED
@@ -1,9 +1,33 @@
1
- export { Tooltip } from './tooltip.mjs';
1
+ import * as react from 'react';
2
+ import * as react_jsx_runtime from 'react/jsx-runtime';
3
+ import { Tooltip as Tooltip$1 } from './tooltip.mjs';
4
+ import { TooltipArrow } from './tooltip-arrow.mjs';
5
+ import { TooltipContent } from './tooltip-content.mjs';
6
+ import { TooltipTrigger } from './tooltip-trigger.mjs';
2
7
  export { TooltipConfig, useTooltipConfig } from './tooltip-config.mjs';
8
+ import { FloatingDelayGroup } from '@floating-ui/react';
3
9
  export { FloatingDelayGroup as TooltipGroup } from '@floating-ui/react';
4
- import 'react/jsx-runtime';
5
10
  import './use-tooltip.mjs';
6
- import 'react';
7
11
  import '@jamsrui/utils';
8
12
  import './styles.mjs';
9
13
  import '@jamsrui/core';
14
+
15
+ declare const Tooltip: ((props: Tooltip$1.Props) => react_jsx_runtime.JSX.Element) & {
16
+ Root: (props: Tooltip$1.Props) => react_jsx_runtime.JSX.Element;
17
+ Arrow: (props: TooltipArrow.Props) => react_jsx_runtime.JSX.Element | null;
18
+ Content: (props: TooltipContent.Props) => react.ReactElement<unknown, string | react.JSXElementConstructor<any>> | null;
19
+ Trigger: (props: TooltipTrigger.Props) => react_jsx_runtime.JSX.Element;
20
+ Group: typeof FloatingDelayGroup;
21
+ };
22
+ declare namespace Tooltip {
23
+ interface Props extends Tooltip$1.Props {
24
+ }
25
+ interface Arrow extends TooltipArrow.Props {
26
+ }
27
+ interface Content extends TooltipContent.Props {
28
+ }
29
+ interface Trigger extends TooltipTrigger.Props {
30
+ }
31
+ }
32
+
33
+ export { Tooltip };
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- "use client";import{a as p,b as t}from"./chunk-C2D5NMEG.mjs";import{a as o}from"./chunk-5G2K5ACL.mjs";import"./chunk-W4XHOOE2.mjs";import"./chunk-WKDVTYCD.mjs";import{FloatingDelayGroup as f}from"@floating-ui/react";export{o as Tooltip,p as TooltipConfig,f as TooltipGroup,t as useTooltipConfig};
1
+ import{TooltipGroup as t,Tooltip as o}from"./tooltip.mjs";import{TooltipArrow as r}from"./tooltip-arrow.mjs";import{TooltipContent as e}from"./tooltip-content.mjs";import{TooltipTrigger as p}from"./tooltip-trigger.mjs";import{TooltipConfig as g,useTooltipConfig as m}from"./tooltip-config.mjs";import{TooltipGroup as c}from"./tooltip.mjs";const s=Object.assign(o,{Root:o,Arrow:r,Content:e,Trigger:p,Group:t});export{s as Tooltip,g as TooltipConfig,c as TooltipGroup,m as useTooltipConfig};
package/dist/styles.d.mts CHANGED
@@ -13,7 +13,7 @@ declare const tooltipVariants: _jamsrui_utils.TVReturnType<{
13
13
  none: {};
14
14
  };
15
15
  }, {
16
- root: string;
16
+ content: string;
17
17
  arrow: string;
18
18
  }, undefined, {
19
19
  radius: {
@@ -27,7 +27,7 @@ declare const tooltipVariants: _jamsrui_utils.TVReturnType<{
27
27
  none: {};
28
28
  };
29
29
  }, {
30
- root: string;
30
+ content: string;
31
31
  arrow: string;
32
32
  }, _jamsrui_utils.TVReturnType<{
33
33
  radius: {
@@ -41,7 +41,7 @@ declare const tooltipVariants: _jamsrui_utils.TVReturnType<{
41
41
  none: {};
42
42
  };
43
43
  }, {
44
- root: string;
44
+ content: string;
45
45
  arrow: string;
46
46
  }, undefined, unknown, unknown, undefined>>;
47
47
  type TooltipVariants = VariantProps<typeof tooltipVariants>;
package/dist/styles.mjs CHANGED
@@ -1 +1 @@
1
- import{a}from"./chunk-WKDVTYCD.mjs";export{a as tooltipVariants};
1
+ import{radiusVariant as t,tv as o}from"@jamsrui/utils";const a=o({slots:{content:"bg-surface inline-flex px-3 py-1 text-sm font-medium text-foreground",arrow:"fill-background-secondary"},variants:{radius:t("content")},defaultVariants:{radius:"md"}});export{a as tooltipVariants};
@@ -0,0 +1,10 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { FloatingArrowProps } from '@floating-ui/react';
3
+
4
+ declare const TooltipArrow: (props: TooltipArrow.Props) => react_jsx_runtime.JSX.Element | null;
5
+ declare namespace TooltipArrow {
6
+ interface Props extends Omit<FloatingArrowProps, "context"> {
7
+ }
8
+ }
9
+
10
+ export { TooltipArrow };
@@ -0,0 +1 @@
1
+ "use client";import{jsx as p}from"react/jsx-runtime";import{FloatingArrow as e}from"@floating-ui/react";import{useTooltipContext as n}from"./tooltip-context.mjs";const w=o=>{const{getArrowProps:r,isOpen:t}=n();return t?p(e,{...r(o),...o}):null};export{w as TooltipArrow};
@@ -1,11 +1,12 @@
1
- import { Tooltip } from './tooltip.mjs';
2
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
3
2
  import { GlobalConfigProps } from '@jamsrui/core';
4
- import '@floating-ui/react';
3
+ import { Tooltip } from './tooltip.mjs';
5
4
  import './use-tooltip.mjs';
6
- import 'react';
5
+ import '@floating-ui/react';
7
6
  import '@jamsrui/utils';
7
+ import 'react';
8
8
  import './styles.mjs';
9
+ import './tooltip-content.mjs';
9
10
 
10
11
  declare const useTooltipConfig: () => TooltipConfig.Props;
11
12
  declare const TooltipConfig: (props: Omit<Partial<TooltipConfig.Props>, "children"> & {
@@ -1 +1 @@
1
- import{a,b}from"./chunk-C2D5NMEG.mjs";export{a as TooltipConfig,b as useTooltipConfig};
1
+ "use client";import{createConfigContext as o}from"@jamsrui/utils";const[p,i]=o({displayName:"TooltipConfigContext"});export{p as TooltipConfig,i as useTooltipConfig};
@@ -0,0 +1,10 @@
1
+ import * as react from 'react';
2
+ import { PropsWithChildren } from 'react';
3
+
4
+ declare const TooltipContent: (props: TooltipContent.Props) => react.ReactElement<unknown, string | react.JSXElementConstructor<any>> | null;
5
+ declare namespace TooltipContent {
6
+ interface Props extends PropsWithChildren {
7
+ }
8
+ }
9
+
10
+ export { TooltipContent };
@@ -0,0 +1 @@
1
+ "use client";import{useRenderElement as r}from"@jamsrui/hooks";import{useTooltipContext as p}from"./tooltip-context.mjs";const l=t=>{const{isOpen:e,getContentProps:o}=p(),n=r("div",{props:[o(t)]});return e?n:null};export{l as TooltipContent};
@@ -0,0 +1,15 @@
1
+ import * as react from 'react';
2
+ import { useTooltip } from './use-tooltip.mjs';
3
+ import '@floating-ui/react';
4
+ import '@jamsrui/utils';
5
+ import './styles.mjs';
6
+ import './tooltip-content.mjs';
7
+
8
+ declare const useTooltipContext: () => TooltipContext.Props;
9
+ declare const TooltipContext: react.Context<TooltipContext.Props | null>;
10
+ declare namespace TooltipContext {
11
+ interface Props extends ReturnType<typeof useTooltip> {
12
+ }
13
+ }
14
+
15
+ export { TooltipContext, useTooltipContext };
@@ -0,0 +1 @@
1
+ "use client";import{createContext as o,use as e}from"react";const p=o(null),n=()=>{const t=e(p);if(!t)throw new Error("useTooltipContext must be used within a TooltipContext.Provider");return t};export{p as TooltipContext,n as useTooltipContext};
@@ -0,0 +1,10 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+
3
+ declare const TooltipTrigger: (props: TooltipTrigger.Props) => react_jsx_runtime.JSX.Element;
4
+ declare namespace TooltipTrigger {
5
+ interface Props {
6
+ children: React.ReactElement;
7
+ }
8
+ }
9
+
10
+ export { TooltipTrigger };
@@ -0,0 +1 @@
1
+ "use client";import{Fragment as l,jsx as c}from"react/jsx-runtime";import{cloneElement as n}from"react";import{useTooltipContext as p}from"./tooltip-context.mjs";const T=r=>{const{children:e}=r,{getTriggerProps:o,isDisabled:t}=p();if(t)return e;const i=n(e,o());return c(l,{children:i})};export{T as TooltipTrigger};
@@ -1,9 +1,10 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { useTooltip } from './use-tooltip.mjs';
3
- import 'react';
4
- import '@floating-ui/react';
3
+ export { FloatingDelayGroup as TooltipGroup } from '@floating-ui/react';
5
4
  import '@jamsrui/utils';
5
+ import 'react';
6
6
  import './styles.mjs';
7
+ import './tooltip-content.mjs';
7
8
 
8
9
  declare const Tooltip: (props: Tooltip.Props) => react_jsx_runtime.JSX.Element;
9
10
  declare namespace Tooltip {
package/dist/tooltip.mjs CHANGED
@@ -1 +1 @@
1
- import{a}from"./chunk-5G2K5ACL.mjs";import"./chunk-W4XHOOE2.mjs";import"./chunk-WKDVTYCD.mjs";export{a as Tooltip};
1
+ "use client";import{jsx as i}from"react/jsx-runtime";import{TooltipContext as p}from"./tooltip-context.mjs";import{useTooltip as r}from"./use-tooltip.mjs";const s=o=>{const{children:t}=o,e=r(o);return i(p,{value:e,children:t})};import{FloatingDelayGroup as x}from"@floating-ui/react";export{s as Tooltip,x as TooltipGroup};
@@ -1,28 +1,25 @@
1
- import * as react from 'react';
2
- import { ReactElement } from 'react';
3
1
  import { FloatingArrowProps, Placement, Delay } from '@floating-ui/react';
4
- import { PropGetter, UIProps, SlotsToClassNames } from '@jamsrui/utils';
5
- import { TooltipVariants, TooltipSlots } from './styles.mjs';
2
+ import { PropGetter } from '@jamsrui/utils';
3
+ import { PropsWithChildren } from 'react';
4
+ import { TooltipVariants } from './styles.mjs';
5
+ import { TooltipContent } from './tooltip-content.mjs';
6
6
 
7
7
  declare const useTooltip: (props: useTooltip.Props) => {
8
- getRootProps: PropGetter<UIProps<"div">>;
9
- getArrowProps: () => FloatingArrowProps;
8
+ getContentProps: PropGetter<TooltipContent.Props>;
9
+ getArrowProps: (props: Partial<FloatingArrowProps>) => FloatingArrowProps;
10
10
  isOpen: boolean;
11
- children: ReactElement<unknown, string | react.JSXElementConstructor<any>>;
12
- title: string;
13
11
  showArrow: boolean;
12
+ getTriggerProps: () => {
13
+ [x: string]: unknown;
14
+ };
15
+ isDisabled: boolean;
14
16
  };
15
17
  declare namespace useTooltip {
16
- interface Props extends TooltipVariants {
17
- title: string;
18
+ interface Props extends PropsWithChildren, TooltipVariants {
18
19
  placement?: Placement;
19
- isDisabled?: boolean;
20
+ disabled?: boolean;
20
21
  offset?: number;
21
- showArrow?: boolean;
22
22
  delay?: Delay;
23
- className?: string;
24
- classNames?: SlotsToClassNames<TooltipSlots>;
25
- children: ReactElement<unknown>;
26
23
  isOpen?: boolean;
27
24
  onOpenChange?: (open: boolean) => void;
28
25
  defaultOpen?: boolean;
@@ -1 +1 @@
1
- import{a}from"./chunk-W4XHOOE2.mjs";import"./chunk-WKDVTYCD.mjs";export{a as useTooltip};
1
+ import{useCallback as c,useMemo as V,useState as N}from"react";import{arrow as j,autoUpdate as k,flip as H,offset as I,safePolygon as M,shift as W,useDelayGroup as U,useDismiss as q,useFloating as z,useFocus as B,useHover as J,useInteractions as K,useRole as L}from"@floating-ui/react";import{useControlledState as Q}from"@jamsrui/hooks";import{tooltipVariants as X}from"./styles.mjs";const oe=h=>{const{delay:r,offset:w=4,placement:C="top",radius:O,defaultOpen:D,isOpen:F,onOpenChange:T,disabled:f=!1,...Y}=h,[p,A]=Q({defaultProp:D,onChange:T,prop:F}),[m,x]=N(null),i=!!m,G=i?7:0,{refs:n,floatingStyles:u,context:e}=z({open:p,onOpenChange:A,placement:C,whileElementsMounted:k,middleware:[I(w+G),H({fallbackAxisSideDirection:"start"}),W(),j({element:m})]}),{delay:o}=U(e);let t=400,s=100;typeof r=="number"?(t=r,s=r):typeof r=="object"&&(t=r.open??t,s=r.close??s),typeof o=="number"&&o>0?(t=o,s=o):typeof o=="object"&&(t=o.open??t,s=o.close??s);const S=J(e,{move:!1,handleClose:M({blockPointerEvents:!0}),delay:{close:s,open:t}}),v=B(e),E=q(e),R=L(e,{role:"tooltip"}),{getReferenceProps:d,getFloatingProps:y}=K([S,v,E,R]),l=X({radius:O}),P=c(a=>({...a,className:l.content(),style:u,ref:n.setFloating,...y()}),[u,y,n.setFloating,l]),g=c(a=>({tipRadius:4,...a,context:e,ref:x,className:l.arrow({className:a.className})}),[e,l]),b=c(()=>({...d({ref:n.setReference})}),[d,n.setReference]);return V(()=>({getContentProps:P,getArrowProps:g,isOpen:p,showArrow:i,getTriggerProps:b,isDisabled:f}),[P,g,p,i,b,f])};export{oe as useTooltip};
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@jamsrui/tooltip",
3
- "version": "0.0.12",
3
+ "version": "0.0.14",
4
4
  "peerDependencies": {
5
5
  "react": ">=19"
6
6
  },
7
7
  "dependencies": {
8
8
  "@floating-ui/react": ">=0.27",
9
- "@jamsrui/hooks": "^0.0.12",
10
- "@jamsrui/core": "^0.0.10",
11
- "@jamsrui/utils": "^0.0.12"
9
+ "@jamsrui/hooks": "^0.0.14",
10
+ "@jamsrui/utils": "^0.0.14",
11
+ "@jamsrui/core": "^0.0.12"
12
12
  },
13
13
  "exports": {
14
14
  ".": {
@@ -1 +0,0 @@
1
- import{a as t}from"./chunk-W4XHOOE2.mjs";import{useMemo as P}from"react";import{FloatingArrow as f,FloatingPortal as g}from"@floating-ui/react";import{useRenderElement as u}from"@jamsrui/hooks";import{Fragment as n,jsx as p,jsxs as i}from"react/jsx-runtime";var A=s=>{let{children:l,getArrowProps:o,getRootProps:m,isOpen:c,title:r,showArrow:e}=t(s),d=P(()=>i(n,{children:[!!e&&p(f,{...o()}),r]}),[o,e,r]),a=u("div",{props:[m({}),{children:d}]});return i(n,{children:[l,!!c&&p(g,{children:a})]})};export{A as a};
@@ -1 +0,0 @@
1
- import{createConfigContext as o}from"@jamsrui/utils";var[p,i]=o({displayName:"TooltipConfigContext"});export{p as a,i as b};
@@ -1 +0,0 @@
1
- import{a as h}from"./chunk-WKDVTYCD.mjs";import{cloneElement as j,useCallback as C,useMemo as U,useRef as H}from"react";import{arrow as M,autoUpdate as q,flip as z,offset as B,safePolygon as J,shift as K,useDelayGroup as L,useDismiss as Q,useFloating as W,useFocus as X,useHover as Y,useInteractions as Z,useRole as _}from"@floating-ui/react";import{useControlledState as $}from"@jamsrui/hooks";import{cn as N}from"@jamsrui/utils";var re=O=>{let{title:f,isDisabled:u=!1,delay:l,offset:D=4,placement:S="top",radius:T,showArrow:r=!1,className:n,classNames:a,children:p,defaultOpen:R,isOpen:F,onOpenChange:v}=O,[c,x]=$({defaultProp:R,onChange:v,prop:F}),d=H(null),A=r?7:0,{refs:m,floatingStyles:y,context:e}=W({open:c,onOpenChange:x,placement:S,whileElementsMounted:q,middleware:[B(D+A),z({fallbackAxisSideDirection:"start"}),K(),r?M({element:d}):null]}),{delay:o}=L(e),t=400,s=100;typeof l=="number"?(t=l,s=l):typeof l=="object"&&(t=l.open??t,s=l.close??s),typeof o=="number"&&o>0?(t=o,s=o):typeof o=="object"&&(t=o.open??t,s=o.close??s);let E=Y(e,{move:!1,handleClose:J({blockPointerEvents:!0}),delay:{close:s,open:t}}),G=X(e),V=Q(e),k=_(e,{role:"tooltip"}),{getReferenceProps:I,getFloatingProps:g}=Z([E,G,V,k]),i=h({radius:T}),P=j(p,I({ref:m.setReference})),w=C(()=>({className:i.root({className:N(a?.root,n)}),style:y,ref:m.setFloating,...g()}),[n,a?.root,y,g,m.setFloating,i]),b=C(()=>({context:e,ref:d,className:i.arrow({className:N(a?.arrow,n)})}),[n,a?.arrow,e,i]);return U(()=>({getRootProps:w,getArrowProps:b,isOpen:c,children:u?p:P,title:f,showArrow:r}),[p,b,w,u,c,r,f,P])};export{re as a};
@@ -1 +0,0 @@
1
- import{radiusVariant as t,tv as o}from"@jamsrui/utils";var a=o({slots:{root:"bg-surface inline-flex px-3 py-1 text-sm font-medium text-foreground",arrow:"fill-background-secondary"},variants:{radius:t("root")},defaultVariants:{radius:"md"}});export{a};