@versini/ui-tooltip 3.1.1 → 4.0.0

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/README.md CHANGED
@@ -18,7 +18,7 @@ The Tooltip component provides contextual help and information with proper acces
18
18
  ## Features
19
19
 
20
20
  - **🧭 Smart Positioning**: Uses Floating UI for collision-aware placement & arrow positioning
21
- - **⏱️ Show Delay**: Configurable appearance delay (`delay` prop)
21
+ - **⏱️ Configurable Timing**: Show delay (`delay` prop) and fade-in duration (`animationDuration` prop)
22
22
  - **♿ Accessible**: Proper `role="tooltip"`, hover & focus behavior, optional disabling period
23
23
  - **🎨 Theming**: Supports light / dark / system / alt-system modes
24
24
  - **🪶 Lightweight**: Minimal DOM & style footprint; only renders when visible
@@ -59,17 +59,37 @@ function App() {
59
59
  </div>
60
60
  ```
61
61
 
62
- ### Custom Delay & Dark Mode
62
+ ### Custom Animation Duration & Dark Mode
63
63
 
64
64
  ```tsx
65
65
  <Tooltip
66
- label="Appears after 1s"
67
- delay={1000}
66
+ label="Smooth fade-in"
67
+ animationDuration={1000}
68
68
  mode="dark"
69
- trigger={<button>Delayed</button>}
69
+ trigger={<button>Slow animation</button>}
70
70
  />
71
71
  ```
72
72
 
73
+ ### Delayed Appearance
74
+
75
+ ```tsx
76
+ <Tooltip
77
+ label="Appears after 500ms"
78
+ delay={500}
79
+ trigger={<button>Hover and wait</button>}
80
+ />;
81
+
82
+ {
83
+ /* Combine delay and animation duration */
84
+ }
85
+ <Tooltip
86
+ label="Wait 300ms, then fade in over 800ms"
87
+ delay={300}
88
+ animationDuration={800}
89
+ trigger={<button>Delayed & animated</button>}
90
+ />;
91
+ ```
92
+
73
93
  ### Styling the Tooltip & Arrow
74
94
 
75
95
  ```tsx
@@ -85,15 +105,16 @@ function App() {
85
105
 
86
106
  ### Tooltip Props
87
107
 
88
- | Prop | Type | Default | Description |
89
- | ------------------ | --------------------------------------- | ------- | -------------------------------------------------- | ------------- | ---------- | ------------------------------ |
90
- | `label` | `string` | - | Text content of the tooltip. |
91
- | `trigger` | `React.ReactNode` | - | Element that the tooltip is anchored to. |
92
- | `placement` | `Placement` (from `@floating-ui/react`) | `"top"` | Preferred initial placement (auto flips / shifts). |
93
- | `mode` | `"dark" | "light" | "system" | "alt-system"` | `"system"` | Theme mode controlling colors. |
94
- | `delay` | `number` | `300` | Milliseconds before showing tooltip. |
95
- | `className` | `string` | - | Extra classes for outer wrapper. |
96
- | `tooltipClassName` | `string` | - | Extra classes for tooltip bubble. |
97
- | `arrowClassName` | `string` | - | Extra classes for tooltip arrow element. |
108
+ | Prop | Type | Default | Description |
109
+ | ------------------- | --------------------------------------- | ------- | -------------------------------------------------- | ------------- | ---------- | ------------------------------ |
110
+ | `label` | `string` | - | Text content of the tooltip. |
111
+ | `trigger` | `React.ReactNode` | - | Element that the tooltip is anchored to. |
112
+ | `placement` | `Placement` (from `@floating-ui/react`) | `"top"` | Preferred initial placement (auto flips / shifts). |
113
+ | `mode` | `"dark" | "light" | "system" | "alt-system"` | `"system"` | Theme mode controlling colors. |
114
+ | `delay` | `number` | `0` | Delay before showing tooltip (milliseconds). |
115
+ | `animationDuration` | `number` | `300` | Duration of fade-in animation (milliseconds). |
116
+ | `className` | `string` | - | Extra classes for outer wrapper. |
117
+ | `tooltipClassName` | `string` | - | Extra classes for tooltip bubble. |
118
+ | `arrowClassName` | `string` | - | Extra classes for tooltip arrow element. |
98
119
 
99
120
  > Tooltip appears on hover/focus, hides on leave/click, and temporarily disables after click to prevent flicker.
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { JSX } from 'react/jsx-runtime';
2
2
  import { Placement } from '@floating-ui/react';
3
3
 
4
- export declare const Tooltip: ({ trigger, label, placement, mode, delay, className, tooltipClassName, arrowClassName, }: TooltipTypes.Props) => JSX.Element;
4
+ export declare const Tooltip: ({ trigger, label, placement, mode, animationDuration, delay, className, tooltipClassName, arrowClassName, }: TooltipTypes.Props) => JSX.Element;
5
5
 
6
6
  export declare const TOOLTIP_ARROW_CLASSNAME = "av-tooltip-arrow";
7
7
 
@@ -43,9 +43,14 @@ declare namespace TooltipTypes {
43
43
  */
44
44
  mode?: "dark" | "light" | "system" | "alt-system";
45
45
  /**
46
- * The delay in milliseconds before showing the tooltip.
46
+ * The duration in milliseconds of the tooltip fade-in animation.
47
47
  * @default 300
48
48
  */
49
+ animationDuration?: number;
50
+ /**
51
+ * The delay in milliseconds before showing the tooltip after hovering.
52
+ * @default 0
53
+ */
49
54
  delay?: number;
50
55
  };
51
56
  }
package/dist/index.js CHANGED
@@ -1,12 +1,12 @@
1
1
  /*!
2
- @versini/ui-tooltip v3.1.1
2
+ @versini/ui-tooltip v4.0.0
3
3
  © 2025 gizmette.com
4
4
  */
5
5
  try {
6
6
  if (!window.__VERSINI_UI_TOOLTIP__) {
7
7
  window.__VERSINI_UI_TOOLTIP__ = {
8
- version: "3.1.1",
9
- buildTime: "11/16/2025 05:49 PM EST",
8
+ version: "4.0.0",
9
+ buildTime: "11/30/2025 06:54 PM EST",
10
10
  homepage: "https://github.com/aversini/ui-components",
11
11
  license: "MIT",
12
12
  };
@@ -79,9 +79,9 @@ const getTooltipClasses = ({ mode, className, tooltipClassName, arrowClassName }
79
79
  wrapper
80
80
  };
81
81
  };
82
- const getAnimationStyles = ({ delay = 300 })=>{
82
+ const getAnimationStyles = ({ animationDuration = 300 })=>{
83
83
  return {
84
- animation: `av-tooltip-fade-in ${delay}ms ease-in-out`
84
+ animation: `av-tooltip-fade-in ${animationDuration}ms ease-in-out`
85
85
  };
86
86
  };
87
87
 
@@ -92,12 +92,13 @@ const getAnimationStyles = ({ delay = 300 })=>{
92
92
 
93
93
 
94
94
  const DEFAULT_DEACTIVATION_DELAY = 5000;
95
- const Tooltip = ({ trigger, label, placement = "top", mode = "system", delay = 300, className, tooltipClassName, arrowClassName })=>{
95
+ const Tooltip = ({ trigger, label, placement = "top", mode = "system", animationDuration = 300, delay = 0, className, tooltipClassName, arrowClassName })=>{
96
96
  const referenceRef = useClickOutside(()=>{
97
97
  /* v8 ignore next 1 */ delayedRestartTooltip.stop(), setDisabled(false);
98
98
  });
99
99
  const floatingRef = useRef(null);
100
100
  const floatingArrowRef = useRef(null);
101
+ const showTimeoutRef = useRef(null);
101
102
  const [showTooltip, setShowTooltip] = useState(false);
102
103
  const [disabled, setDisabled] = useState(false);
103
104
  const delayedRestartTooltip = useInterval(()=>{
@@ -110,7 +111,7 @@ const Tooltip = ({ trigger, label, placement = "top", mode = "system", delay = 3
110
111
  arrowClassName
111
112
  });
112
113
  const animationStyles = getAnimationStyles({
113
- delay
114
+ animationDuration
114
115
  });
115
116
  const updatePosition = useCallback(async ()=>{
116
117
  if (referenceRef.current && floatingRef.current && floatingArrowRef.current) {
@@ -168,7 +169,18 @@ const Tooltip = ({ trigger, label, placement = "top", mode = "system", delay = 3
168
169
  updatePosition,
169
170
  showTooltip
170
171
  ]);
172
+ useEffect(()=>{
173
+ return ()=>{
174
+ if (showTimeoutRef.current) {
175
+ clearTimeout(showTimeoutRef.current);
176
+ }
177
+ };
178
+ }, []);
171
179
  const handleMouseClick = ()=>{
180
+ if (showTimeoutRef.current) {
181
+ clearTimeout(showTimeoutRef.current);
182
+ showTimeoutRef.current = null;
183
+ }
172
184
  setShowTooltip(false);
173
185
  setDisabled(true);
174
186
  // disabling tooltip for 5 seconds
@@ -176,10 +188,21 @@ const Tooltip = ({ trigger, label, placement = "top", mode = "system", delay = 3
176
188
  };
177
189
  const handleMouseEnter = ()=>{
178
190
  if (!disabled) {
179
- setShowTooltip(true);
191
+ if (delay > 0) {
192
+ showTimeoutRef.current = setTimeout(()=>{
193
+ setShowTooltip(true);
194
+ showTimeoutRef.current = null;
195
+ }, delay);
196
+ } else {
197
+ setShowTooltip(true);
198
+ }
180
199
  }
181
200
  };
182
201
  const handleMouseLeave = ()=>{
202
+ if (showTimeoutRef.current) {
203
+ clearTimeout(showTimeoutRef.current);
204
+ showTimeoutRef.current = null;
205
+ }
183
206
  if (!disabled) {
184
207
  setShowTooltip(false);
185
208
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@versini/ui-tooltip",
3
- "version": "3.1.1",
3
+ "version": "4.0.0",
4
4
  "license": "MIT",
5
5
  "author": "Arno Versini",
6
6
  "publishConfig": {
@@ -38,7 +38,7 @@
38
38
  },
39
39
  "devDependencies": {
40
40
  "@testing-library/jest-dom": "6.9.1",
41
- "@versini/ui-types": "6.0.2"
41
+ "@versini/ui-types": "7.0.0"
42
42
  },
43
43
  "dependencies": {
44
44
  "@floating-ui/react": "0.27.16",
@@ -50,5 +50,5 @@
50
50
  "sideEffects": [
51
51
  "**/*.css"
52
52
  ],
53
- "gitHead": "1d0bedfa3a84ea7f2f41d347a59de518f92e4cea"
53
+ "gitHead": "4795cf3239cceaf83dde13addc5254caa12dee6f"
54
54
  }