@gridui/tooltip 0.0.0 → 1.0.2
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 +7 -2
- package/dist/index.js +39 -19
- package/dist/index.js.map +3 -3
- package/dist/styles.css +1 -48
- package/dist/tooltip/tooltip.d.ts +2 -2
- package/package.json +6 -5
package/README.md
CHANGED
|
@@ -9,8 +9,8 @@ See [component ownership](../../docs/component-ownership.md) and [release histor
|
|
|
9
9
|
|
|
10
10
|
## Tooltips
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
hints.
|
|
12
|
+
The Tooltip family owns composable primitives for supplemental button and link
|
|
13
|
+
hints. This family owns timing,
|
|
14
14
|
controlled state, native trigger composition, portal styling, positioning,
|
|
15
15
|
accessibility, and content limits. Applications own clipboard state and localized labels.
|
|
16
16
|
|
|
@@ -29,6 +29,9 @@ offset and 16px collision padding, and portals into `document.body`. The portal
|
|
|
29
29
|
avoids clipping and uses the document theme's semantic palette. Use `container`
|
|
30
30
|
when a different portal host is required, and `className`, `style`, `side`, or
|
|
31
31
|
`align` for local presentation. Entry/exit motion respects reduced motion.
|
|
32
|
+
With `forceMount`, Overlay retains the content through React Activity while
|
|
33
|
+
closed content stays hidden, its refs are detached, and its effects are suspended. This lifecycle does
|
|
34
|
+
not rely on exit animation, including under reduced motion.
|
|
32
35
|
Radix owns description association, hoverable content, Escape dismissal, and
|
|
33
36
|
viewport collisions. Content is supplemental, noninteractive text; use a popover
|
|
34
37
|
for interactive content. Disabled native controls do not receive focus; essential
|
|
@@ -46,3 +49,5 @@ localization, and business state.
|
|
|
46
49
|
</TooltipProvider>
|
|
47
50
|
```
|
|
48
51
|
|
|
52
|
+
|
|
53
|
+
Surface motion uses `@gridui/overlay`; load `@gridui/overlay/styles.css` after Theme and before this family.
|
package/dist/index.js
CHANGED
|
@@ -1,20 +1,39 @@
|
|
|
1
1
|
// src/tooltip/tooltip.tsx
|
|
2
|
+
import { OverlayOpen, useOverlayState } from "@gridui/overlay";
|
|
2
3
|
import * as Primitive from "@radix-ui/react-tooltip";
|
|
3
|
-
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
var Tooltip = (props) => {
|
|
6
|
+
const state = useOverlayState(props);
|
|
7
|
+
return /* @__PURE__ */ jsx(
|
|
8
|
+
OverlayOpen.Provider,
|
|
9
|
+
{
|
|
10
|
+
value: state.open,
|
|
11
|
+
children: /* @__PURE__ */ jsx(
|
|
12
|
+
Primitive.Root,
|
|
13
|
+
{
|
|
14
|
+
...props,
|
|
15
|
+
...state
|
|
16
|
+
}
|
|
17
|
+
)
|
|
18
|
+
}
|
|
19
|
+
);
|
|
20
|
+
};
|
|
4
21
|
|
|
5
22
|
// src/tooltip-content/style.ts
|
|
23
|
+
import { overlaySurfaceStyles } from "@gridui/overlay";
|
|
6
24
|
import { cn } from "@gridui/style-utils";
|
|
7
25
|
import { cva } from "class-variance-authority";
|
|
8
26
|
var tooltipContentStyles = cva(cn(
|
|
27
|
+
overlaySurfaceStyles({ kind: "tooltip" }),
|
|
9
28
|
"gridui-tooltip-content z-(--gridui-z-tooltip) box-border w-max max-w-[min(20rem,var(--radix-tooltip-content-available-width))]",
|
|
10
|
-
"p-gridui-8
|
|
11
|
-
"data-[state='closed']:pointer-events-none"
|
|
29
|
+
"p-gridui-8 type-supporting wrap-anywhere"
|
|
12
30
|
));
|
|
13
31
|
|
|
14
32
|
// src/tooltip-content/tooltip-content.tsx
|
|
33
|
+
import { RetainedLayer } from "@gridui/overlay";
|
|
15
34
|
import { cn as cn2 } from "@gridui/style-utils";
|
|
16
35
|
import * as Primitive2 from "@radix-ui/react-tooltip";
|
|
17
|
-
import { jsx } from "react/jsx-runtime";
|
|
36
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
18
37
|
var TooltipContent = (props) => {
|
|
19
38
|
const {
|
|
20
39
|
container,
|
|
@@ -25,31 +44,32 @@ var TooltipContent = (props) => {
|
|
|
25
44
|
...restProps
|
|
26
45
|
} = props;
|
|
27
46
|
const mountProps = forceMount ? { forceMount } : {};
|
|
28
|
-
|
|
47
|
+
const content = /* @__PURE__ */ jsx2(
|
|
48
|
+
Primitive2.Content,
|
|
49
|
+
{
|
|
50
|
+
...mountProps,
|
|
51
|
+
...restProps,
|
|
52
|
+
sideOffset,
|
|
53
|
+
collisionPadding,
|
|
54
|
+
className: cn2(tooltipContentStyles(), className)
|
|
55
|
+
}
|
|
56
|
+
);
|
|
57
|
+
return /* @__PURE__ */ jsx2(
|
|
29
58
|
Primitive2.Portal,
|
|
30
59
|
{
|
|
31
60
|
...mountProps,
|
|
32
61
|
container,
|
|
33
|
-
children: /* @__PURE__ */
|
|
34
|
-
Primitive2.Content,
|
|
35
|
-
{
|
|
36
|
-
...mountProps,
|
|
37
|
-
...restProps,
|
|
38
|
-
sideOffset,
|
|
39
|
-
collisionPadding,
|
|
40
|
-
className: cn2(tooltipContentStyles(), className)
|
|
41
|
-
}
|
|
42
|
-
)
|
|
62
|
+
children: forceMount ? /* @__PURE__ */ jsx2(RetainedLayer, { children: content }) : content
|
|
43
63
|
}
|
|
44
64
|
);
|
|
45
65
|
};
|
|
46
66
|
|
|
47
67
|
// src/tooltip-provider/tooltip-provider.tsx
|
|
48
68
|
import * as Primitive3 from "@radix-ui/react-tooltip";
|
|
49
|
-
import { jsx as
|
|
69
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
50
70
|
var TooltipProvider = (props) => {
|
|
51
71
|
const { delayDuration = 300, ...restProps } = props;
|
|
52
|
-
return /* @__PURE__ */
|
|
72
|
+
return /* @__PURE__ */ jsx3(
|
|
53
73
|
Primitive3.Provider,
|
|
54
74
|
{
|
|
55
75
|
...restProps,
|
|
@@ -60,10 +80,10 @@ var TooltipProvider = (props) => {
|
|
|
60
80
|
|
|
61
81
|
// src/tooltip-trigger/tooltip-trigger.tsx
|
|
62
82
|
import * as Primitive4 from "@radix-ui/react-tooltip";
|
|
63
|
-
import { jsx as
|
|
83
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
64
84
|
var TooltipTrigger = (props) => {
|
|
65
85
|
const { asChild = true, ...restProps } = props;
|
|
66
|
-
return /* @__PURE__ */
|
|
86
|
+
return /* @__PURE__ */ jsx4(
|
|
67
87
|
Primitive4.Trigger,
|
|
68
88
|
{
|
|
69
89
|
...restProps,
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/tooltip/tooltip.tsx", "../src/tooltip-content/style.ts", "../src/tooltip-content/tooltip-content.tsx", "../src/tooltip-provider/tooltip-provider.tsx", "../src/tooltip-trigger/tooltip-trigger.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * @author WMXPY\n * @package Tooltip\n * @namespace Tooltip\n * @description Tooltip\n */\n\nimport * as Primitive from \"@radix-ui/react-tooltip\";\nimport type { ComponentPropsWithRef } from \"react\";\n\nexport type TooltipProps = ComponentPropsWithRef<typeof Primitive.Root>;\n\nexport const Tooltip = Primitive.Root;\n", "/**\n * @author WMXPY\n * @package Tooltip\n * @namespace TooltipContent\n * @description Style\n */\n\nimport { cn } from \"@gridui/style-utils\";\nimport { cva } from \"class-variance-authority\";\n\nexport const tooltipContentStyles = cva(cn(\n \"gridui-tooltip-content z-(--gridui-z-tooltip) box-border w-max max-w-[min(20rem,var(--radix-tooltip-content-available-width))]\",\n \"p-gridui-8
|
|
5
|
-
"mappings": ";AAOA,YAAY,eAAe;
|
|
6
|
-
"names": ["cn", "Primitive", "Primitive", "jsx", "Primitive", "jsx"]
|
|
4
|
+
"sourcesContent": ["/**\n * @author WMXPY\n * @package Tooltip\n * @namespace Tooltip\n * @description Tooltip\n */\n\nimport { OverlayOpen, useOverlayState } from \"@gridui/overlay\";\nimport * as Primitive from \"@radix-ui/react-tooltip\";\nimport type { ComponentPropsWithRef, FC } from \"react\";\n\nexport type TooltipProps = ComponentPropsWithRef<typeof Primitive.Root>;\n\nexport const Tooltip: FC<TooltipProps> = (props: TooltipProps) => {\n const state = useOverlayState(props);\n return (<OverlayOpen.Provider\n value={state.open}\n >\n <Primitive.Root\n {...props}\n {...state}\n />\n </OverlayOpen.Provider>);\n};\n", "/**\n * @author WMXPY\n * @package Tooltip\n * @namespace TooltipContent\n * @description Style\n */\n\nimport { overlaySurfaceStyles } from \"@gridui/overlay\";\nimport { cn } from \"@gridui/style-utils\";\nimport { cva } from \"class-variance-authority\";\n\nexport const tooltipContentStyles = cva(cn(\n overlaySurfaceStyles({ kind: \"tooltip\" }),\n \"gridui-tooltip-content z-(--gridui-z-tooltip) box-border w-max max-w-[min(20rem,var(--radix-tooltip-content-available-width))]\",\n \"p-gridui-8 type-supporting wrap-anywhere\",\n));\n", "/**\n * @author WMXPY\n * @package Tooltip\n * @namespace TooltipContent\n * @description Tooltip Content\n */\n\nimport { tooltipContentStyles } from \"./style\";\nimport { RetainedLayer } from \"@gridui/overlay\";\nimport { cn } from \"@gridui/style-utils\";\nimport * as Primitive from \"@radix-ui/react-tooltip\";\nimport type { ComponentPropsWithRef, FC } from \"react\";\n\nexport type TooltipContentProps = ComponentPropsWithRef<typeof Primitive.Content> & {\n readonly container?: ComponentPropsWithRef<typeof Primitive.Portal>[\"container\"];\n};\n\nexport const TooltipContent: FC<TooltipContentProps> = (props: TooltipContentProps) => {\n const {\n container,\n forceMount,\n className,\n sideOffset = 8,\n collisionPadding = 16,\n ...restProps\n } = props;\n const mountProps = forceMount ? { forceMount } : {};\n const content = (<Primitive.Content\n {...mountProps}\n {...restProps}\n sideOffset={sideOffset}\n collisionPadding={collisionPadding}\n className={cn(tooltipContentStyles(), className)}\n />);\n return (<Primitive.Portal\n {...mountProps}\n container={container}\n >\n {forceMount ? (<RetainedLayer>\n {content}\n </RetainedLayer>) : content}\n </Primitive.Portal>);\n};\n", "/**\n * @author WMXPY\n * @package Tooltip\n * @namespace TooltipProvider\n * @description Tooltip Provider\n */\n\nimport * as Primitive from \"@radix-ui/react-tooltip\";\nimport type { ComponentPropsWithRef, FC } from \"react\";\n\nexport type TooltipProviderProps = ComponentPropsWithRef<typeof Primitive.Provider>;\n\nexport const TooltipProvider: FC<TooltipProviderProps> = (props: TooltipProviderProps) => {\n const { delayDuration = 300, ...restProps } = props;\n return (<Primitive.Provider\n {...restProps}\n delayDuration={delayDuration}\n />);\n};\n", "/**\n * @author WMXPY\n * @package Tooltip\n * @namespace TooltipTrigger\n * @description Tooltip Trigger\n */\n\nimport * as Primitive from \"@radix-ui/react-tooltip\";\nimport type { ComponentPropsWithRef, FC } from \"react\";\n\nexport type TooltipTriggerProps = ComponentPropsWithRef<typeof Primitive.Trigger>;\n\nexport const TooltipTrigger: FC<TooltipTriggerProps> = (props: TooltipTriggerProps) => {\n const { asChild = true, ...restProps } = props;\n return (<Primitive.Trigger\n {...restProps}\n asChild={asChild}\n />);\n};\n"],
|
|
5
|
+
"mappings": ";AAOA,SAAS,aAAa,uBAAuB;AAC7C,YAAY,eAAe;AAUnB;AALD,IAAM,UAA4B,CAAC,UAAwB;AAC9D,QAAM,QAAQ,gBAAgB,KAAK;AACnC,SAAQ;AAAA,IAAC,YAAY;AAAA,IAAZ;AAAA,MACL,OAAO,MAAM;AAAA,MAEb;AAAA,QAAW;AAAA,QAAV;AAAA,UACI,GAAG;AAAA,UACH,GAAG;AAAA;AAAA,MACR;AAAA;AAAA,EACJ;AACJ;;;AChBA,SAAS,4BAA4B;AACrC,SAAS,UAAU;AACnB,SAAS,WAAW;AAEb,IAAM,uBAAuB,IAAI;AAAA,EACpC,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAAA,EACxC;AAAA,EACA;AACJ,CAAC;;;ACPD,SAAS,qBAAqB;AAC9B,SAAS,MAAAA,WAAU;AACnB,YAAYC,gBAAe;AAiBN,gBAAAC,YAAA;AAVd,IAAM,iBAA0C,CAAC,UAA+B;AACnF,QAAM;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA,aAAa;AAAA,IACb,mBAAmB;AAAA,IACnB,GAAG;AAAA,EACP,IAAI;AACJ,QAAM,aAAa,aAAa,EAAE,WAAW,IAAI,CAAC;AAClD,QAAM,UAAW,gBAAAA;AAAA,IAAW;AAAA,IAAV;AAAA,MACb,GAAG;AAAA,MACH,GAAG;AAAA,MACJ;AAAA,MACA;AAAA,MACA,WAAWF,IAAG,qBAAqB,GAAG,SAAS;AAAA;AAAA,EACnD;AACA,SAAQ,gBAAAE;AAAA,IAAW;AAAA,IAAV;AAAA,MACJ,GAAG;AAAA,MACJ;AAAA,MAEC,uBAAc,gBAAAA,KAAC,iBACX,mBACL,IAAoB;AAAA;AAAA,EACxB;AACJ;;;ACnCA,YAAYC,gBAAe;AAOf,gBAAAC,YAAA;AAFL,IAAM,kBAA4C,CAAC,UAAgC;AACtF,QAAM,EAAE,gBAAgB,KAAK,GAAG,UAAU,IAAI;AAC9C,SAAQ,gBAAAA;AAAA,IAAW;AAAA,IAAV;AAAA,MACJ,GAAG;AAAA,MACJ;AAAA;AAAA,EACJ;AACJ;;;ACXA,YAAYC,gBAAe;AAOf,gBAAAC,YAAA;AAFL,IAAM,iBAA0C,CAAC,UAA+B;AACnF,QAAM,EAAE,UAAU,MAAM,GAAG,UAAU,IAAI;AACzC,SAAQ,gBAAAA;AAAA,IAAW;AAAA,IAAV;AAAA,MACJ,GAAG;AAAA,MACJ;AAAA;AAAA,EACJ;AACJ;",
|
|
6
|
+
"names": ["cn", "Primitive", "jsx", "Primitive", "jsx", "Primitive", "jsx"]
|
|
7
7
|
}
|
package/dist/styles.css
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */
|
|
2
|
-
@layer properties;
|
|
3
2
|
@layer theme, base, components, utilities;
|
|
4
3
|
@layer utilities {
|
|
5
4
|
.z-\(--gridui-z-tooltip\) {
|
|
@@ -32,23 +31,6 @@
|
|
|
32
31
|
.max-w-\[min\(20rem\,var\(--radix-tooltip-content-available-width\)\)\] {
|
|
33
32
|
max-width: min(20rem, var(--radix-tooltip-content-available-width));
|
|
34
33
|
}
|
|
35
|
-
.rounded-control {
|
|
36
|
-
border-radius: var(--gridui-control-radius);
|
|
37
|
-
}
|
|
38
|
-
.border {
|
|
39
|
-
border-style: var(--tw-border-style);
|
|
40
|
-
border-width: 1px;
|
|
41
|
-
}
|
|
42
|
-
.border-solid {
|
|
43
|
-
--tw-border-style: solid;
|
|
44
|
-
border-style: solid;
|
|
45
|
-
}
|
|
46
|
-
.border-border {
|
|
47
|
-
border-color: var(--gridui-border);
|
|
48
|
-
}
|
|
49
|
-
.bg-background {
|
|
50
|
-
background-color: var(--gridui-background);
|
|
51
|
-
}
|
|
52
34
|
.p-gridui-8 {
|
|
53
35
|
padding: var(--gridui-space-8);
|
|
54
36
|
}
|
|
@@ -59,38 +41,9 @@
|
|
|
59
41
|
.wrap-anywhere {
|
|
60
42
|
overflow-wrap: anywhere;
|
|
61
43
|
}
|
|
62
|
-
.text-foreground {
|
|
63
|
-
color: var(--gridui-foreground);
|
|
64
|
-
}
|
|
65
|
-
.data-\[state\=\'closed\'\]\:pointer-events-none[data-state='closed'] {
|
|
66
|
-
pointer-events: none;
|
|
67
|
-
}
|
|
68
44
|
}
|
|
69
45
|
@layer components {
|
|
70
46
|
.gridui-tooltip-content {
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
.gridui-tooltip-content[data-state="delayed-open"], .gridui-tooltip-content[data-state="instant-open"] {
|
|
74
|
-
animation: gridui-surface-enter var(--gridui-motion-duration-quick) var(--gridui-motion-ease-out) both;
|
|
75
|
-
}
|
|
76
|
-
.gridui-tooltip-content[data-state="closed"] {
|
|
77
|
-
animation: gridui-surface-exit var(--gridui-motion-duration-quick) var(--gridui-motion-ease-in) both;
|
|
78
|
-
}
|
|
79
|
-
@media (prefers-reduced-motion: reduce) {
|
|
80
|
-
.gridui-tooltip-content[data-state] {
|
|
81
|
-
animation: none;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
@property --tw-border-style {
|
|
86
|
-
syntax: "*";
|
|
87
|
-
inherits: false;
|
|
88
|
-
initial-value: solid;
|
|
89
|
-
}
|
|
90
|
-
@layer properties {
|
|
91
|
-
@supports ((-webkit-hyphens: none) and (not (margin-trim: inline))) or ((-moz-orient: inline) and (not (color:rgb(from red r g b)))) {
|
|
92
|
-
*, ::before, ::after, ::backdrop {
|
|
93
|
-
--tw-border-style: solid;
|
|
94
|
-
}
|
|
47
|
+
--gridui-overlay-origin: var(--radix-tooltip-content-transform-origin);
|
|
95
48
|
}
|
|
96
49
|
}
|
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
* @description Tooltip
|
|
6
6
|
*/
|
|
7
7
|
import * as Primitive from "@radix-ui/react-tooltip";
|
|
8
|
-
import type { ComponentPropsWithRef } from "react";
|
|
8
|
+
import type { ComponentPropsWithRef, FC } from "react";
|
|
9
9
|
export type TooltipProps = ComponentPropsWithRef<typeof Primitive.Root>;
|
|
10
|
-
export declare const Tooltip:
|
|
10
|
+
export declare const Tooltip: FC<TooltipProps>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gridui/tooltip",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "GridUI React tooltip",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|
|
@@ -26,16 +26,17 @@
|
|
|
26
26
|
"react-dom": "^19.2.0"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@gridui/
|
|
30
|
-
"@gridui/
|
|
29
|
+
"@gridui/overlay": "^1.1.1",
|
|
30
|
+
"@gridui/style-utils": "^2.1.3",
|
|
31
|
+
"@gridui/theme": "^2.2.1",
|
|
31
32
|
"@radix-ui/react-tooltip": "1.4.1",
|
|
32
33
|
"class-variance-authority": "0.7.1"
|
|
33
34
|
},
|
|
34
35
|
"devDependencies": {
|
|
35
|
-
"@gridui-internal/configuration": "0.0.0",
|
|
36
|
+
"@gridui-internal/configuration": "0.0.0-internal",
|
|
36
37
|
"@jest/globals": "30.5.2",
|
|
37
38
|
"@types/jest": "30.0.0",
|
|
38
|
-
"@types/node": "26.6.
|
|
39
|
+
"@types/node": "26.6.6",
|
|
39
40
|
"@types/react": "19.3.0",
|
|
40
41
|
"@types/react-dom": "19.3.0",
|
|
41
42
|
"jest": "30.5.2",
|