@nucleux/hover-card 0.2.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Nucleux
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,26 @@
1
+ # @nucleux/hover-card
2
+
3
+ Hover-triggered content card — Nucleux agentic UI for React.
4
+
5
+ Part of **[Nucleux](https://github.com/intelligaia-open-labs/nucleux)** — agentic UI components for React. Install a single component, or the full kit via [`@nucleux/react`](https://www.npmjs.com/package/@nucleux/react).
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ pnpm add @nucleux/hover-card @nucleux/tokens
11
+ ```
12
+
13
+ `react` / `react-dom` are peer dependencies.
14
+
15
+ ## Usage
16
+
17
+ ```tsx
18
+ import { HoverCard } from "@nucleux/hover-card";
19
+ ```
20
+
21
+ Requires the theme once in your app: `import "@nucleux/tokens/styles.css";`
22
+ and the Tailwind preset from `@nucleux/tokens/preset`.
23
+
24
+ ## License
25
+
26
+ MIT © Nucleux
package/dist/index.cjs ADDED
@@ -0,0 +1,87 @@
1
+ "use client";
2
+ 'use strict';
3
+
4
+ var React = require('react');
5
+ var utils = require('@nucleux/utils');
6
+ var jsxRuntime = require('react/jsx-runtime');
7
+
8
+ function _interopNamespace(e) {
9
+ if (e && e.__esModule) return e;
10
+ var n = Object.create(null);
11
+ if (e) {
12
+ Object.keys(e).forEach(function (k) {
13
+ if (k !== 'default') {
14
+ var d = Object.getOwnPropertyDescriptor(e, k);
15
+ Object.defineProperty(n, k, d.get ? d : {
16
+ enumerable: true,
17
+ get: function () { return e[k]; }
18
+ });
19
+ }
20
+ });
21
+ }
22
+ n.default = e;
23
+ return Object.freeze(n);
24
+ }
25
+
26
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
27
+
28
+ // src/index.tsx
29
+ var alignClass = {
30
+ start: "left-0",
31
+ center: "left-1/2 -translate-x-1/2",
32
+ end: "right-0"
33
+ };
34
+ var HoverCard = React__namespace.forwardRef(
35
+ ({
36
+ trigger,
37
+ content,
38
+ side = "top",
39
+ align = "center",
40
+ openDelay = 200,
41
+ closeDelay = 150,
42
+ className,
43
+ ...props
44
+ }, ref) => {
45
+ const [open, setOpen] = React__namespace.useState(false);
46
+ const timer = React__namespace.useRef();
47
+ const schedule = (next, delay) => {
48
+ clearTimeout(timer.current);
49
+ timer.current = setTimeout(() => setOpen(next), delay);
50
+ };
51
+ React__namespace.useEffect(() => () => clearTimeout(timer.current), []);
52
+ return /* @__PURE__ */ jsxRuntime.jsxs(
53
+ "div",
54
+ {
55
+ ref,
56
+ className: utils.cn("relative inline-block", className),
57
+ onMouseEnter: () => schedule(true, openDelay),
58
+ onMouseLeave: () => schedule(false, closeDelay),
59
+ onFocusCapture: () => setOpen(true),
60
+ onBlurCapture: (e) => {
61
+ if (!e.currentTarget.contains(e.relatedTarget)) setOpen(false);
62
+ },
63
+ ...props,
64
+ children: [
65
+ trigger,
66
+ open && /* @__PURE__ */ jsxRuntime.jsx(
67
+ "div",
68
+ {
69
+ role: "tooltip",
70
+ className: utils.cn(
71
+ "absolute z-50 w-64 animate-nx-fade-in rounded-md border border-border bg-background p-4 text-sm text-foreground shadow-md",
72
+ side === "top" ? "bottom-full mb-2" : "top-full mt-2",
73
+ alignClass[align]
74
+ ),
75
+ children: content
76
+ }
77
+ )
78
+ ]
79
+ }
80
+ );
81
+ }
82
+ );
83
+ HoverCard.displayName = "HoverCard";
84
+
85
+ exports.HoverCard = HoverCard;
86
+ //# sourceMappingURL=index.cjs.map
87
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.tsx"],"names":["React","jsxs","cn","jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBA,IAAM,UAAA,GAAmE;AAAA,EACvE,KAAA,EAAO,QAAA;AAAA,EACP,MAAA,EAAQ,2BAAA;AAAA,EACR,GAAA,EAAK;AACP,CAAA;AAGO,IAAM,SAAA,GAAkBA,gBAAA,CAAA,UAAA;AAAA,EAC7B,CACE;AAAA,IACE,OAAA;AAAA,IACA,OAAA;AAAA,IACA,IAAA,GAAO,KAAA;AAAA,IACP,KAAA,GAAQ,QAAA;AAAA,IACR,SAAA,GAAY,GAAA;AAAA,IACZ,UAAA,GAAa,GAAA;AAAA,IACb,SAAA;AAAA,IACA,GAAG;AAAA,KAEL,GAAA,KACG;AACH,IAAA,MAAM,CAAC,IAAA,EAAM,OAAO,CAAA,GAAUA,0BAAS,KAAK,CAAA;AAC5C,IAAA,MAAM,QAAcA,gBAAA,CAAA,MAAA,EAAsC;AAE1D,IAAA,MAAM,QAAA,GAAW,CAAC,IAAA,EAAe,KAAA,KAAkB;AACjD,MAAA,YAAA,CAAa,MAAM,OAAO,CAAA;AAC1B,MAAA,KAAA,CAAM,UAAU,UAAA,CAAW,MAAM,OAAA,CAAQ,IAAI,GAAG,KAAK,CAAA;AAAA,IACvD,CAAA;AAEA,IAAMA,gBAAA,CAAA,SAAA,CAAU,MAAM,MAAM,YAAA,CAAa,MAAM,OAAO,CAAA,EAAG,EAAE,CAAA;AAE3D,IAAA,uBACEC,eAAA;AAAA,MAAC,KAAA;AAAA,MAAA;AAAA,QACC,GAAA;AAAA,QACA,SAAA,EAAWC,QAAA,CAAG,uBAAA,EAAyB,SAAS,CAAA;AAAA,QAChD,YAAA,EAAc,MAAM,QAAA,CAAS,IAAA,EAAM,SAAS,CAAA;AAAA,QAC5C,YAAA,EAAc,MAAM,QAAA,CAAS,KAAA,EAAO,UAAU,CAAA;AAAA,QAC9C,cAAA,EAAgB,MAAM,OAAA,CAAQ,IAAI,CAAA;AAAA,QAClC,aAAA,EAAe,CAAC,CAAA,KAAM;AACpB,UAAA,IAAI,CAAC,EAAE,aAAA,CAAc,QAAA,CAAS,EAAE,aAAqB,CAAA,UAAW,KAAK,CAAA;AAAA,QACvE,CAAA;AAAA,QACC,GAAG,KAAA;AAAA,QAEH,QAAA,EAAA;AAAA,UAAA,OAAA;AAAA,UACA,IAAA,oBACCC,cAAA;AAAA,YAAC,KAAA;AAAA,YAAA;AAAA,cACC,IAAA,EAAK,SAAA;AAAA,cACL,SAAA,EAAWD,QAAA;AAAA,gBACT,2HAAA;AAAA,gBACA,IAAA,KAAS,QAAQ,kBAAA,GAAqB,eAAA;AAAA,gBACtC,WAAW,KAAK;AAAA,eAClB;AAAA,cAEC,QAAA,EAAA;AAAA;AAAA;AACH;AAAA;AAAA,KAEJ;AAAA,EAEJ;AACF;AACA,SAAA,CAAU,WAAA,GAAc,WAAA","file":"index.cjs","sourcesContent":["import * as React from \"react\";\nimport { cn } from \"@nucleux/utils\";\n\nexport interface HoverCardProps extends Omit<React.HTMLAttributes<HTMLDivElement>, \"content\"> {\n /** The element that reveals the card on hover/focus. */\n trigger: React.ReactNode;\n /** The floating card content. */\n content: React.ReactNode;\n side?: \"top\" | \"bottom\";\n align?: \"start\" | \"center\" | \"end\";\n /** Delay in ms before opening on hover. */\n openDelay?: number;\n /** Delay in ms before closing after leaving. */\n closeDelay?: number;\n}\n\nconst alignClass: Record<NonNullable<HoverCardProps[\"align\"]>, string> = {\n start: \"left-0\",\n center: \"left-1/2 -translate-x-1/2\",\n end: \"right-0\",\n};\n\n/** Reveals a floating card when its trigger is hovered or focused. */\nexport const HoverCard = React.forwardRef<HTMLDivElement, HoverCardProps>(\n (\n {\n trigger,\n content,\n side = \"top\",\n align = \"center\",\n openDelay = 200,\n closeDelay = 150,\n className,\n ...props\n },\n ref,\n ) => {\n const [open, setOpen] = React.useState(false);\n const timer = React.useRef<ReturnType<typeof setTimeout>>();\n\n const schedule = (next: boolean, delay: number) => {\n clearTimeout(timer.current);\n timer.current = setTimeout(() => setOpen(next), delay);\n };\n\n React.useEffect(() => () => clearTimeout(timer.current), []);\n\n return (\n <div\n ref={ref}\n className={cn(\"relative inline-block\", className)}\n onMouseEnter={() => schedule(true, openDelay)}\n onMouseLeave={() => schedule(false, closeDelay)}\n onFocusCapture={() => setOpen(true)}\n onBlurCapture={(e) => {\n if (!e.currentTarget.contains(e.relatedTarget as Node)) setOpen(false);\n }}\n {...props}\n >\n {trigger}\n {open && (\n <div\n role=\"tooltip\"\n className={cn(\n \"absolute z-50 w-64 animate-nx-fade-in rounded-md border border-border bg-background p-4 text-sm text-foreground shadow-md\",\n side === \"top\" ? \"bottom-full mb-2\" : \"top-full mt-2\",\n alignClass[align],\n )}\n >\n {content}\n </div>\n )}\n </div>\n );\n },\n);\nHoverCard.displayName = \"HoverCard\";\n"]}
@@ -0,0 +1,18 @@
1
+ import * as React from 'react';
2
+
3
+ interface HoverCardProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "content"> {
4
+ /** The element that reveals the card on hover/focus. */
5
+ trigger: React.ReactNode;
6
+ /** The floating card content. */
7
+ content: React.ReactNode;
8
+ side?: "top" | "bottom";
9
+ align?: "start" | "center" | "end";
10
+ /** Delay in ms before opening on hover. */
11
+ openDelay?: number;
12
+ /** Delay in ms before closing after leaving. */
13
+ closeDelay?: number;
14
+ }
15
+ /** Reveals a floating card when its trigger is hovered or focused. */
16
+ declare const HoverCard: React.ForwardRefExoticComponent<HoverCardProps & React.RefAttributes<HTMLDivElement>>;
17
+
18
+ export { HoverCard, type HoverCardProps };
@@ -0,0 +1,18 @@
1
+ import * as React from 'react';
2
+
3
+ interface HoverCardProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "content"> {
4
+ /** The element that reveals the card on hover/focus. */
5
+ trigger: React.ReactNode;
6
+ /** The floating card content. */
7
+ content: React.ReactNode;
8
+ side?: "top" | "bottom";
9
+ align?: "start" | "center" | "end";
10
+ /** Delay in ms before opening on hover. */
11
+ openDelay?: number;
12
+ /** Delay in ms before closing after leaving. */
13
+ closeDelay?: number;
14
+ }
15
+ /** Reveals a floating card when its trigger is hovered or focused. */
16
+ declare const HoverCard: React.ForwardRefExoticComponent<HoverCardProps & React.RefAttributes<HTMLDivElement>>;
17
+
18
+ export { HoverCard, type HoverCardProps };
package/dist/index.js ADDED
@@ -0,0 +1,65 @@
1
+ "use client";
2
+ import * as React from 'react';
3
+ import { cn } from '@nucleux/utils';
4
+ import { jsxs, jsx } from 'react/jsx-runtime';
5
+
6
+ // src/index.tsx
7
+ var alignClass = {
8
+ start: "left-0",
9
+ center: "left-1/2 -translate-x-1/2",
10
+ end: "right-0"
11
+ };
12
+ var HoverCard = React.forwardRef(
13
+ ({
14
+ trigger,
15
+ content,
16
+ side = "top",
17
+ align = "center",
18
+ openDelay = 200,
19
+ closeDelay = 150,
20
+ className,
21
+ ...props
22
+ }, ref) => {
23
+ const [open, setOpen] = React.useState(false);
24
+ const timer = React.useRef();
25
+ const schedule = (next, delay) => {
26
+ clearTimeout(timer.current);
27
+ timer.current = setTimeout(() => setOpen(next), delay);
28
+ };
29
+ React.useEffect(() => () => clearTimeout(timer.current), []);
30
+ return /* @__PURE__ */ jsxs(
31
+ "div",
32
+ {
33
+ ref,
34
+ className: cn("relative inline-block", className),
35
+ onMouseEnter: () => schedule(true, openDelay),
36
+ onMouseLeave: () => schedule(false, closeDelay),
37
+ onFocusCapture: () => setOpen(true),
38
+ onBlurCapture: (e) => {
39
+ if (!e.currentTarget.contains(e.relatedTarget)) setOpen(false);
40
+ },
41
+ ...props,
42
+ children: [
43
+ trigger,
44
+ open && /* @__PURE__ */ jsx(
45
+ "div",
46
+ {
47
+ role: "tooltip",
48
+ className: cn(
49
+ "absolute z-50 w-64 animate-nx-fade-in rounded-md border border-border bg-background p-4 text-sm text-foreground shadow-md",
50
+ side === "top" ? "bottom-full mb-2" : "top-full mt-2",
51
+ alignClass[align]
52
+ ),
53
+ children: content
54
+ }
55
+ )
56
+ ]
57
+ }
58
+ );
59
+ }
60
+ );
61
+ HoverCard.displayName = "HoverCard";
62
+
63
+ export { HoverCard };
64
+ //# sourceMappingURL=index.js.map
65
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.tsx"],"names":[],"mappings":";;;;;AAgBA,IAAM,UAAA,GAAmE;AAAA,EACvE,KAAA,EAAO,QAAA;AAAA,EACP,MAAA,EAAQ,2BAAA;AAAA,EACR,GAAA,EAAK;AACP,CAAA;AAGO,IAAM,SAAA,GAAkB,KAAA,CAAA,UAAA;AAAA,EAC7B,CACE;AAAA,IACE,OAAA;AAAA,IACA,OAAA;AAAA,IACA,IAAA,GAAO,KAAA;AAAA,IACP,KAAA,GAAQ,QAAA;AAAA,IACR,SAAA,GAAY,GAAA;AAAA,IACZ,UAAA,GAAa,GAAA;AAAA,IACb,SAAA;AAAA,IACA,GAAG;AAAA,KAEL,GAAA,KACG;AACH,IAAA,MAAM,CAAC,IAAA,EAAM,OAAO,CAAA,GAAU,eAAS,KAAK,CAAA;AAC5C,IAAA,MAAM,QAAc,KAAA,CAAA,MAAA,EAAsC;AAE1D,IAAA,MAAM,QAAA,GAAW,CAAC,IAAA,EAAe,KAAA,KAAkB;AACjD,MAAA,YAAA,CAAa,MAAM,OAAO,CAAA;AAC1B,MAAA,KAAA,CAAM,UAAU,UAAA,CAAW,MAAM,OAAA,CAAQ,IAAI,GAAG,KAAK,CAAA;AAAA,IACvD,CAAA;AAEA,IAAM,KAAA,CAAA,SAAA,CAAU,MAAM,MAAM,YAAA,CAAa,MAAM,OAAO,CAAA,EAAG,EAAE,CAAA;AAE3D,IAAA,uBACE,IAAA;AAAA,MAAC,KAAA;AAAA,MAAA;AAAA,QACC,GAAA;AAAA,QACA,SAAA,EAAW,EAAA,CAAG,uBAAA,EAAyB,SAAS,CAAA;AAAA,QAChD,YAAA,EAAc,MAAM,QAAA,CAAS,IAAA,EAAM,SAAS,CAAA;AAAA,QAC5C,YAAA,EAAc,MAAM,QAAA,CAAS,KAAA,EAAO,UAAU,CAAA;AAAA,QAC9C,cAAA,EAAgB,MAAM,OAAA,CAAQ,IAAI,CAAA;AAAA,QAClC,aAAA,EAAe,CAAC,CAAA,KAAM;AACpB,UAAA,IAAI,CAAC,EAAE,aAAA,CAAc,QAAA,CAAS,EAAE,aAAqB,CAAA,UAAW,KAAK,CAAA;AAAA,QACvE,CAAA;AAAA,QACC,GAAG,KAAA;AAAA,QAEH,QAAA,EAAA;AAAA,UAAA,OAAA;AAAA,UACA,IAAA,oBACC,GAAA;AAAA,YAAC,KAAA;AAAA,YAAA;AAAA,cACC,IAAA,EAAK,SAAA;AAAA,cACL,SAAA,EAAW,EAAA;AAAA,gBACT,2HAAA;AAAA,gBACA,IAAA,KAAS,QAAQ,kBAAA,GAAqB,eAAA;AAAA,gBACtC,WAAW,KAAK;AAAA,eAClB;AAAA,cAEC,QAAA,EAAA;AAAA;AAAA;AACH;AAAA;AAAA,KAEJ;AAAA,EAEJ;AACF;AACA,SAAA,CAAU,WAAA,GAAc,WAAA","file":"index.js","sourcesContent":["import * as React from \"react\";\nimport { cn } from \"@nucleux/utils\";\n\nexport interface HoverCardProps extends Omit<React.HTMLAttributes<HTMLDivElement>, \"content\"> {\n /** The element that reveals the card on hover/focus. */\n trigger: React.ReactNode;\n /** The floating card content. */\n content: React.ReactNode;\n side?: \"top\" | \"bottom\";\n align?: \"start\" | \"center\" | \"end\";\n /** Delay in ms before opening on hover. */\n openDelay?: number;\n /** Delay in ms before closing after leaving. */\n closeDelay?: number;\n}\n\nconst alignClass: Record<NonNullable<HoverCardProps[\"align\"]>, string> = {\n start: \"left-0\",\n center: \"left-1/2 -translate-x-1/2\",\n end: \"right-0\",\n};\n\n/** Reveals a floating card when its trigger is hovered or focused. */\nexport const HoverCard = React.forwardRef<HTMLDivElement, HoverCardProps>(\n (\n {\n trigger,\n content,\n side = \"top\",\n align = \"center\",\n openDelay = 200,\n closeDelay = 150,\n className,\n ...props\n },\n ref,\n ) => {\n const [open, setOpen] = React.useState(false);\n const timer = React.useRef<ReturnType<typeof setTimeout>>();\n\n const schedule = (next: boolean, delay: number) => {\n clearTimeout(timer.current);\n timer.current = setTimeout(() => setOpen(next), delay);\n };\n\n React.useEffect(() => () => clearTimeout(timer.current), []);\n\n return (\n <div\n ref={ref}\n className={cn(\"relative inline-block\", className)}\n onMouseEnter={() => schedule(true, openDelay)}\n onMouseLeave={() => schedule(false, closeDelay)}\n onFocusCapture={() => setOpen(true)}\n onBlurCapture={(e) => {\n if (!e.currentTarget.contains(e.relatedTarget as Node)) setOpen(false);\n }}\n {...props}\n >\n {trigger}\n {open && (\n <div\n role=\"tooltip\"\n className={cn(\n \"absolute z-50 w-64 animate-nx-fade-in rounded-md border border-border bg-background p-4 text-sm text-foreground shadow-md\",\n side === \"top\" ? \"bottom-full mb-2\" : \"top-full mt-2\",\n alignClass[align],\n )}\n >\n {content}\n </div>\n )}\n </div>\n );\n },\n);\nHoverCard.displayName = \"HoverCard\";\n"]}
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@nucleux/hover-card",
3
+ "version": "0.2.0",
4
+ "type": "module",
5
+ "sideEffects": false,
6
+ "description": "Hover-triggered content card — Nucleux agentic UI for React.",
7
+ "keywords": [
8
+ "nucleux",
9
+ "react",
10
+ "ui",
11
+ "components",
12
+ "agentic",
13
+ "ai",
14
+ "tailwind",
15
+ "hover-card"
16
+ ],
17
+ "main": "./dist/index.cjs",
18
+ "module": "./dist/index.js",
19
+ "types": "./dist/index.d.ts",
20
+ "exports": {
21
+ ".": {
22
+ "types": "./dist/index.d.ts",
23
+ "import": "./dist/index.js",
24
+ "require": "./dist/index.cjs"
25
+ }
26
+ },
27
+ "files": [
28
+ "dist",
29
+ "README.md"
30
+ ],
31
+ "peerDependencies": {
32
+ "react": ">=18",
33
+ "react-dom": ">=18"
34
+ },
35
+ "dependencies": {
36
+ "@nucleux/utils": "0.2.0"
37
+ },
38
+ "devDependencies": {
39
+ "tsup": "^8.3.5",
40
+ "typescript": "^5.7.2",
41
+ "@types/react": "^18.3.18",
42
+ "react": "^18.3.1",
43
+ "lucide-react": "^0.469.0"
44
+ },
45
+ "publishConfig": {
46
+ "access": "public"
47
+ },
48
+ "license": "MIT",
49
+ "repository": {
50
+ "type": "git",
51
+ "url": "git+https://github.com/intelligaia-open-labs/nucleux.git",
52
+ "directory": "packages/hover-card"
53
+ },
54
+ "homepage": "https://github.com/intelligaia-open-labs/nucleux#readme",
55
+ "scripts": {
56
+ "build": "tsup"
57
+ }
58
+ }