@versini/ui-tooltip 1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Arno Versini
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,3 @@
1
+ # @versini/ui-card
2
+
3
+ A simple tooltip component for React.
@@ -0,0 +1,7 @@
1
+ import "react/jsx-runtime";
2
+ import "@floating-ui/react";
3
+ import "react";
4
+ import { Tooltip as m } from "../../index.js";
5
+ export {
6
+ m as Tooltip
7
+ };
@@ -0,0 +1,9 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { TooltipTypes } from '@versini/ui-types';
3
+
4
+ declare const TOOLTIP_CLASSNAME = "av-tooltip";
5
+ declare const TOOLTIP_ARROW_CLASSNAME = "av-tooltip-arrow";
6
+
7
+ declare const Tooltip: ({ trigger, label, placement, mode, }: TooltipTypes.Props) => react_jsx_runtime.JSX.Element;
8
+
9
+ export { TOOLTIP_ARROW_CLASSNAME, TOOLTIP_CLASSNAME, Tooltip };
package/dist/index.js ADDED
@@ -0,0 +1,117 @@
1
+ import { jsxs as c, Fragment as _, jsx as f } from "react/jsx-runtime";
2
+ import { useFloating as w, autoUpdate as C, arrow as I, offset as O, flip as S, shift as A, useTransitionStyles as R, useHover as v, useFocus as E, useDismiss as P, useRole as F, useInteractions as L, FloatingPortal as N, FloatingArrow as M } from "@floating-ui/react";
3
+ import { useState as U, useRef as j, cloneElement as B } from "react";
4
+ import e from "clsx";
5
+ /*!
6
+ @versini/ui-tooltip v1.0.0
7
+ © 2025 gizmette.com
8
+ */
9
+ try {
10
+ window.__VERSINI_UI_TOOLTIP__ || (window.__VERSINI_UI_TOOLTIP__ = {
11
+ version: "1.0.0",
12
+ buildTime: "01/13/2025 07:45 PM EST",
13
+ homepage: "https://github.com/aversini/ui-components",
14
+ license: "MIT"
15
+ });
16
+ } catch {
17
+ }
18
+ const D = "av-tooltip", V = "av-tooltip-arrow", H = () => e("w-max py-1 px-2 rounded text-sm"), W = ({
19
+ mode: t
20
+ }) => e({
21
+ "bg-surface-darker": t === "dark" || t === "system",
22
+ "bg-surface-light": t === "light" || t === "alt-system",
23
+ "dark:bg-surface-light": t === "system",
24
+ "dark:bg-surface-darker": t === "alt-system"
25
+ }), q = ({
26
+ mode: t
27
+ }) => e({
28
+ "text-copy-light": t === "dark" || t === "system",
29
+ "text-copy-dark": t === "light" || t === "alt-system",
30
+ "dark:text-copy-dark": t === "system",
31
+ "dark:text-copy-light": t === "alt-system"
32
+ }), z = ({
33
+ mode: t
34
+ }) => e({
35
+ "fill-surface-darker [&>path:first-of-type]:bg-surface-darker [&>path:last-of-type]:bg-surface-darker": t === "dark" || t === "system",
36
+ "fill-surface-light [&>path:first-of-type]:bg-surface-light [&>path:last-of-type]:bg-surface-light": t === "light" || t === "alt-system",
37
+ "dark:fill-surface-light dark:[&>path:first-of-type]:bg-surface-light dark:[&>path:last-of-type]:bg-surface-light": t === "system",
38
+ "dark:fill-surface-darker dark:[&>path:first-of-type]:bg-surface-darker dark:[&>path:last-of-type]:bg-surface-darker": t === "alt-system"
39
+ }), G = ({
40
+ mode: t
41
+ }) => {
42
+ const r = e(
43
+ D,
44
+ H(),
45
+ W({ mode: t }),
46
+ q({ mode: t })
47
+ ), a = e(
48
+ V,
49
+ z({ mode: t })
50
+ );
51
+ return { tooltip: r, arrow: a };
52
+ }, Y = ({
53
+ trigger: t,
54
+ label: r,
55
+ placement: a = "top",
56
+ mode: p = "system"
57
+ }) => {
58
+ const [o, g] = U(!1), l = j(null), { refs: i, floatingStyles: u, context: s } = w({
59
+ open: o,
60
+ onOpenChange: g,
61
+ placement: a,
62
+ // Make sure the tooltip stays on the screen
63
+ whileElementsMounted: C,
64
+ middleware: [
65
+ I({
66
+ element: l
67
+ }),
68
+ O(10),
69
+ S({
70
+ crossAxis: a.includes("-"),
71
+ fallbackAxisSideDirection: "start"
72
+ }),
73
+ A()
74
+ ]
75
+ }), { styles: y } = R(s), n = G({ mode: p }), h = v(s, { move: !1, delay: { open: 300 } }), d = E(s), k = P(s), m = F(s, { role: "tooltip" }), { getReferenceProps: T, getFloatingProps: b } = L([
76
+ h,
77
+ d,
78
+ k,
79
+ m
80
+ ]), x = B(
81
+ t,
82
+ {
83
+ "aria-label": r,
84
+ "data-open": String(o),
85
+ ref: i.setReference,
86
+ ...T()
87
+ }
88
+ );
89
+ return /* @__PURE__ */ c(_, { children: [
90
+ x,
91
+ /* @__PURE__ */ f(N, { children: o && /* @__PURE__ */ c(
92
+ "div",
93
+ {
94
+ className: n.tooltip,
95
+ ref: i.setFloating,
96
+ style: { ...u, ...y },
97
+ ...b(),
98
+ children: [
99
+ /* @__PURE__ */ f(
100
+ M,
101
+ {
102
+ ref: l,
103
+ context: s,
104
+ className: n.arrow
105
+ }
106
+ ),
107
+ r
108
+ ]
109
+ }
110
+ ) })
111
+ ] });
112
+ };
113
+ export {
114
+ V as TOOLTIP_ARROW_CLASSNAME,
115
+ D as TOOLTIP_CLASSNAME,
116
+ Y as Tooltip
117
+ };
package/dist/style.css ADDED
@@ -0,0 +1 @@
1
+ *,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::-ms-backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-ms-input-placeholder,textarea::-ms-input-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}@keyframes blink{50%{fill:transparent}}.w-max{width:-webkit-max-content;width:-moz-max-content;width:max-content}.rounded{border-radius:.25rem}.bg-surface-darker{--tw-bg-opacity: 1;background-color:var(--av-surface-darker, rgb(15 23 42 / var(--tw-bg-opacity, 1)))}.bg-surface-light{--tw-bg-opacity: 1;background-color:var(--av-surface-light, rgb(203 213 225 / var(--tw-bg-opacity, 1)))}.fill-surface-darker{fill:var(--av-surface-darker, rgb(15 23 42 / 1))}.fill-surface-light{fill:var(--av-surface-light, rgb(203 213 225 / 1))}.px-2{padding-left:.5rem;padding-right:.5rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-copy-dark{--tw-text-opacity: 1;color:var(--av-copy-dark, rgb(15 23 42 / var(--tw-text-opacity, 1)))}.text-copy-light{--tw-text-opacity: 1;color:var(--av-copy-light, rgb(226 232 240 / var(--tw-text-opacity, 1)))}@media (prefers-color-scheme: dark){.dark\:bg-surface-darker{--tw-bg-opacity: 1;background-color:var(--av-surface-darker, rgb(15 23 42 / var(--tw-bg-opacity, 1)))}.dark\:bg-surface-light{--tw-bg-opacity: 1;background-color:var(--av-surface-light, rgb(203 213 225 / var(--tw-bg-opacity, 1)))}.dark\:fill-surface-darker{fill:var(--av-surface-darker, rgb(15 23 42 / 1))}.dark\:fill-surface-light{fill:var(--av-surface-light, rgb(203 213 225 / 1))}.dark\:text-copy-dark{--tw-text-opacity: 1;color:var(--av-copy-dark, rgb(15 23 42 / var(--tw-text-opacity, 1)))}.dark\:text-copy-light{--tw-text-opacity: 1;color:var(--av-copy-light, rgb(226 232 240 / var(--tw-text-opacity, 1)))}}.\[\&\>path\:first-of-type\]\:bg-surface-darker>path:first-of-type{--tw-bg-opacity: 1;background-color:var(--av-surface-darker, rgb(15 23 42 / var(--tw-bg-opacity, 1)))}.\[\&\>path\:first-of-type\]\:bg-surface-light>path:first-of-type{--tw-bg-opacity: 1;background-color:var(--av-surface-light, rgb(203 213 225 / var(--tw-bg-opacity, 1)))}@media (prefers-color-scheme: dark){.dark\:\[\&\>path\:first-of-type\]\:bg-surface-darker>path:first-of-type{--tw-bg-opacity: 1;background-color:var(--av-surface-darker, rgb(15 23 42 / var(--tw-bg-opacity, 1)))}.dark\:\[\&\>path\:first-of-type\]\:bg-surface-light>path:first-of-type{--tw-bg-opacity: 1;background-color:var(--av-surface-light, rgb(203 213 225 / var(--tw-bg-opacity, 1)))}}.\[\&\>path\:last-of-type\]\:bg-surface-darker>path:last-of-type{--tw-bg-opacity: 1;background-color:var(--av-surface-darker, rgb(15 23 42 / var(--tw-bg-opacity, 1)))}.\[\&\>path\:last-of-type\]\:bg-surface-light>path:last-of-type{--tw-bg-opacity: 1;background-color:var(--av-surface-light, rgb(203 213 225 / var(--tw-bg-opacity, 1)))}@media (prefers-color-scheme: dark){.dark\:\[\&\>path\:last-of-type\]\:bg-surface-darker>path:last-of-type{--tw-bg-opacity: 1;background-color:var(--av-surface-darker, rgb(15 23 42 / var(--tw-bg-opacity, 1)))}.dark\:\[\&\>path\:last-of-type\]\:bg-surface-light>path:last-of-type{--tw-bg-opacity: 1;background-color:var(--av-surface-light, rgb(203 213 225 / var(--tw-bg-opacity, 1)))}}
package/dist/style.js ADDED
File without changes
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@versini/ui-tooltip",
3
+ "version": "1.0.0",
4
+ "license": "MIT",
5
+ "author": "Arno Versini",
6
+ "publishConfig": {
7
+ "access": "public"
8
+ },
9
+ "homepage": "https://github.com/aversini/ui-components",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git@github.com:aversini/ui-components.git"
13
+ },
14
+ "type": "module",
15
+ "main": "dist/index.js",
16
+ "types": "dist/index.d.ts",
17
+ "files": [
18
+ "dist"
19
+ ],
20
+ "scripts": {
21
+ "build:check": "tsc",
22
+ "build:js": "vite build",
23
+ "build:types": "tsup",
24
+ "build": "npm-run-all --serial clean build:check build:js build:types",
25
+ "clean": "rimraf dist tmp",
26
+ "dev:js": "vite build --watch --mode development",
27
+ "dev:types": "tsup --watch src",
28
+ "dev": "npm-run-all clean --parallel dev:js dev:types",
29
+ "lint": "biome lint src",
30
+ "start": "static-server dist --port 5173",
31
+ "test:coverage:ui": "vitest --coverage --ui",
32
+ "test:coverage": "vitest run --coverage",
33
+ "test:watch": "vitest",
34
+ "test": "vitest run"
35
+ },
36
+ "peerDependencies": {
37
+ "react": "^18.3.1 || ^19.0.0",
38
+ "react-dom": "^18.3.1 || ^19.0.0"
39
+ },
40
+ "devDependencies": {
41
+ "@versini/ui-types": "4.1.0"
42
+ },
43
+ "dependencies": {
44
+ "@floating-ui/react": "0.27.2",
45
+ "@tailwindcss/typography": "0.5.15",
46
+ "clsx": "2.1.1",
47
+ "tailwindcss": "3.4.17"
48
+ },
49
+ "sideEffects": [
50
+ "**/*.css"
51
+ ],
52
+ "gitHead": "62e5ad9aef3842ebba9e968c0cde595e6fd81544"
53
+ }