@mijn-ui/react-tooltip 0.0.0-stage → 0.1.1

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) 2024 MijnUI
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 CHANGED
@@ -1,3 +1,32 @@
1
- # Temporary Holding Version
1
+ # @mijn-ui/react-tooltip
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A short label shown on hover or keyboard focus.
4
+
5
+ [Documentation](https://mijn-ui.vercel.app/react/docs/components/tooltip)
6
+
7
+ ## Installation
8
+
9
+ ```sh
10
+ npm install @mijn-ui/react-tooltip
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ `<TooltipProvider />` is required. Mount one near the root of the app rather
16
+ than around each tooltip — it owns the shared hover delay, which is what lets a
17
+ second trigger open instantly instead of re-waiting the full delay.
18
+
19
+ ```tsx
20
+ <TooltipProvider>
21
+ <Tooltip>
22
+ <TooltipTrigger asChild>
23
+ <Button>Hover me</Button>
24
+ </TooltipTrigger>
25
+ <TooltipContent>Add to your library</TooltipContent>
26
+ </Tooltip>
27
+ </TooltipProvider>
28
+ ```
29
+
30
+ ## License
31
+
32
+ This project is licensed under the terms of the [MIT license.](https://github.com/mijn-ui/mijn-ui-react/blob/main/LICENSE)
@@ -0,0 +1,148 @@
1
+ import * as _mijn_ui_react_core from '@mijn-ui/react-core';
2
+ import { UnstyledComponentWithSlots } from '@mijn-ui/react-core';
3
+ import * as react_jsx_runtime from 'react/jsx-runtime';
4
+ import * as tailwind_variants from 'tailwind-variants';
5
+ import { VariantProps } from 'tailwind-variants';
6
+ import * as tailwind_merge from 'tailwind-merge';
7
+ import * as React from 'react';
8
+ import * as RadixTooltip from '@radix-ui/react-tooltip';
9
+
10
+ declare const tooltipStyles: tailwind_variants.TVReturnType<{
11
+ [key: string]: {
12
+ [key: string]: tailwind_merge.ClassNameValue | {
13
+ base?: tailwind_merge.ClassNameValue;
14
+ trigger?: tailwind_merge.ClassNameValue;
15
+ arrow?: tailwind_merge.ClassNameValue;
16
+ content?: tailwind_merge.ClassNameValue;
17
+ };
18
+ };
19
+ } | {
20
+ [x: string]: {
21
+ [x: string]: tailwind_merge.ClassNameValue | {
22
+ base?: tailwind_merge.ClassNameValue;
23
+ trigger?: tailwind_merge.ClassNameValue;
24
+ arrow?: tailwind_merge.ClassNameValue;
25
+ content?: tailwind_merge.ClassNameValue;
26
+ };
27
+ };
28
+ } | {}, {
29
+ base: string;
30
+ trigger: string;
31
+ content: string[];
32
+ arrow: string;
33
+ }, undefined, {
34
+ [key: string]: {
35
+ [key: string]: tailwind_merge.ClassNameValue | {
36
+ base?: tailwind_merge.ClassNameValue;
37
+ trigger?: tailwind_merge.ClassNameValue;
38
+ arrow?: tailwind_merge.ClassNameValue;
39
+ content?: tailwind_merge.ClassNameValue;
40
+ };
41
+ };
42
+ } | {}, {
43
+ base: string;
44
+ trigger: string;
45
+ content: string[];
46
+ arrow: string;
47
+ }, tailwind_variants.TVReturnType<unknown, {
48
+ base: string;
49
+ trigger: string;
50
+ content: string[];
51
+ arrow: string;
52
+ }, undefined, unknown, unknown, undefined>>;
53
+ type TooltipVariantProps = VariantProps<typeof tooltipStyles>;
54
+ type TooltipSlots = keyof ReturnType<typeof tooltipStyles>;
55
+
56
+ /**
57
+ * Required ancestor for every <Tooltip />. Mount it once, near the root of the
58
+ * app, so a single shared timer governs the hover delay across all tooltips —
59
+ * which is what makes moving between two triggers feel instant rather than
60
+ * re-waiting the full delay each time.
61
+ */
62
+ type TooltipProviderProps = React.ComponentPropsWithoutRef<typeof RadixTooltip.Provider>;
63
+ declare const TooltipProvider: ({ delayDuration, ...props }: TooltipProviderProps) => react_jsx_runtime.JSX.Element;
64
+ type TooltipBaseProps = UnstyledComponentWithSlots<TooltipSlots>;
65
+ declare const useTooltipStyles: (unstyledOverride?: boolean) => {
66
+ classNames: _mijn_ui_react_core.SlotsToClasses<"base" | "trigger" | "arrow" | "content"> | undefined;
67
+ isUnstyled: boolean | undefined;
68
+ base: (slotProps?: ({
69
+ [x: string]: string | number | undefined;
70
+ [x: number]: string | number | undefined;
71
+ } & tailwind_variants.ClassProp<tailwind_merge.ClassNameValue>) | ({
72
+ [x: string]: string | number | undefined;
73
+ [x: number]: string | number | undefined;
74
+ } & tailwind_variants.ClassProp<tailwind_merge.ClassNameValue>) | ({
75
+ [x: string]: string | number | undefined;
76
+ [x: number]: string | number | undefined;
77
+ } & tailwind_variants.ClassProp<tailwind_merge.ClassNameValue>) | ({
78
+ [x: string]: string | number | undefined;
79
+ [x: number]: string | number | undefined;
80
+ } & tailwind_variants.ClassProp<tailwind_merge.ClassNameValue>) | ({
81
+ [x: string]: string | number | undefined;
82
+ [x: number]: string | number | undefined;
83
+ } & tailwind_variants.ClassProp<tailwind_merge.ClassNameValue>) | ({} & tailwind_variants.ClassProp<tailwind_merge.ClassNameValue>) | undefined) => string | undefined;
84
+ trigger: (slotProps?: ({
85
+ [x: string]: string | number | undefined;
86
+ [x: number]: string | number | undefined;
87
+ } & tailwind_variants.ClassProp<tailwind_merge.ClassNameValue>) | ({
88
+ [x: string]: string | number | undefined;
89
+ [x: number]: string | number | undefined;
90
+ } & tailwind_variants.ClassProp<tailwind_merge.ClassNameValue>) | ({
91
+ [x: string]: string | number | undefined;
92
+ [x: number]: string | number | undefined;
93
+ } & tailwind_variants.ClassProp<tailwind_merge.ClassNameValue>) | ({
94
+ [x: string]: string | number | undefined;
95
+ [x: number]: string | number | undefined;
96
+ } & tailwind_variants.ClassProp<tailwind_merge.ClassNameValue>) | ({
97
+ [x: string]: string | number | undefined;
98
+ [x: number]: string | number | undefined;
99
+ } & tailwind_variants.ClassProp<tailwind_merge.ClassNameValue>) | ({} & tailwind_variants.ClassProp<tailwind_merge.ClassNameValue>) | undefined) => string | undefined;
100
+ content: (slotProps?: ({
101
+ [x: string]: string | number | undefined;
102
+ [x: number]: string | number | undefined;
103
+ } & tailwind_variants.ClassProp<tailwind_merge.ClassNameValue>) | ({
104
+ [x: string]: string | number | undefined;
105
+ [x: number]: string | number | undefined;
106
+ } & tailwind_variants.ClassProp<tailwind_merge.ClassNameValue>) | ({
107
+ [x: string]: string | number | undefined;
108
+ [x: number]: string | number | undefined;
109
+ } & tailwind_variants.ClassProp<tailwind_merge.ClassNameValue>) | ({
110
+ [x: string]: string | number | undefined;
111
+ [x: number]: string | number | undefined;
112
+ } & tailwind_variants.ClassProp<tailwind_merge.ClassNameValue>) | ({
113
+ [x: string]: string | number | undefined;
114
+ [x: number]: string | number | undefined;
115
+ } & tailwind_variants.ClassProp<tailwind_merge.ClassNameValue>) | ({} & tailwind_variants.ClassProp<tailwind_merge.ClassNameValue>) | undefined) => string | undefined;
116
+ arrow: (slotProps?: ({
117
+ [x: string]: string | number | undefined;
118
+ [x: number]: string | number | undefined;
119
+ } & tailwind_variants.ClassProp<tailwind_merge.ClassNameValue>) | ({
120
+ [x: string]: string | number | undefined;
121
+ [x: number]: string | number | undefined;
122
+ } & tailwind_variants.ClassProp<tailwind_merge.ClassNameValue>) | ({
123
+ [x: string]: string | number | undefined;
124
+ [x: number]: string | number | undefined;
125
+ } & tailwind_variants.ClassProp<tailwind_merge.ClassNameValue>) | ({
126
+ [x: string]: string | number | undefined;
127
+ [x: number]: string | number | undefined;
128
+ } & tailwind_variants.ClassProp<tailwind_merge.ClassNameValue>) | ({
129
+ [x: string]: string | number | undefined;
130
+ [x: number]: string | number | undefined;
131
+ } & tailwind_variants.ClassProp<tailwind_merge.ClassNameValue>) | ({} & tailwind_variants.ClassProp<tailwind_merge.ClassNameValue>) | undefined) => string | undefined;
132
+ };
133
+ type TooltipProps = React.ComponentPropsWithoutRef<typeof RadixTooltip.Root> & TooltipBaseProps;
134
+ declare const Tooltip: ({ unstyled, classNames, ...props }: TooltipProps) => react_jsx_runtime.JSX.Element;
135
+ type TooltipTriggerProps = React.ComponentPropsWithRef<typeof RadixTooltip.Trigger> & {
136
+ unstyled?: boolean;
137
+ };
138
+ declare const TooltipTrigger: ({ unstyled, className, ...props }: TooltipTriggerProps) => react_jsx_runtime.JSX.Element;
139
+ type TooltipContentProps = React.ComponentPropsWithRef<typeof RadixTooltip.Content> & {
140
+ unstyled?: boolean;
141
+ };
142
+ declare const TooltipContent: ({ unstyled, className, side, sideOffset, ...props }: TooltipContentProps) => react_jsx_runtime.JSX.Element;
143
+ type TooltipArrowProps = React.ComponentPropsWithRef<typeof RadixTooltip.Arrow> & {
144
+ unstyled?: boolean;
145
+ };
146
+ declare const TooltipArrow: ({ unstyled, className, ...props }: TooltipArrowProps) => react_jsx_runtime.JSX.Element;
147
+
148
+ export { Tooltip, TooltipArrow, type TooltipArrowProps, TooltipContent, type TooltipContentProps, type TooltipProps, TooltipProvider, type TooltipProviderProps, type TooltipSlots, TooltipTrigger, type TooltipTriggerProps, type TooltipVariantProps, tooltipStyles, useTooltipStyles };
package/dist/index.js ADDED
@@ -0,0 +1,97 @@
1
+ "use client";
2
+
3
+ // src/tooltip.tsx
4
+ import {
5
+ cn,
6
+ createContext,
7
+ useTVUnstyled
8
+ } from "@mijn-ui/react-core";
9
+ import * as RadixTooltip from "@radix-ui/react-tooltip";
10
+ import { tv } from "tailwind-variants";
11
+ import { jsx } from "react/jsx-runtime";
12
+ var tooltipStyles = tv({
13
+ slots: {
14
+ base: "",
15
+ trigger: "",
16
+ content: [
17
+ "data-[state=delayed-open]:zoom-in-95 data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0",
18
+ "data-[state=instant-open]:zoom-in-95 data-[state=instant-open]:animate-in data-[state=instant-open]:fade-in-0",
19
+ "data-[state=closed]:zoom-out-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0",
20
+ "data-[side=bottom]:slide-in-from-bottom-1 data-[side=left]:slide-in-from-left-1 data-[side=right]:slide-in-from-right-1 data-[side=top]:slide-in-from-top-1",
21
+ "bg-bg-inverse text-fg-inverse z-50 max-w-xs text-balance rounded-md px-2.5 py-1.5 text-xs font-medium shadow-(--mijn-shadow-md) duration-150"
22
+ ],
23
+ arrow: "fill-bg-inverse"
24
+ }
25
+ });
26
+ var TooltipProvider = ({
27
+ delayDuration = 200,
28
+ ...props
29
+ }) => /* @__PURE__ */ jsx(RadixTooltip.Provider, { delayDuration, ...props });
30
+ var [TooltipProviderCtx, useTooltipContext] = createContext({
31
+ name: "TooltipContext",
32
+ strict: true,
33
+ errorMessage: "useTooltipContext: `context` is undefined. Seems you forgot to wrap component within <Tooltip />"
34
+ });
35
+ var useTooltipStyles = (unstyledOverride) => {
36
+ const context = useTooltipContext();
37
+ const unstyledSlots = useTVUnstyled(context, unstyledOverride);
38
+ return { ...unstyledSlots, classNames: context.classNames };
39
+ };
40
+ var Tooltip = ({ unstyled = false, classNames, ...props }) => {
41
+ const styles = tooltipStyles();
42
+ return /* @__PURE__ */ jsx(TooltipProviderCtx, { value: { unstyled, styles, classNames }, children: /* @__PURE__ */ jsx(RadixTooltip.Root, { "data-slot": "tooltip", ...props }) });
43
+ };
44
+ var TooltipTrigger = ({
45
+ unstyled,
46
+ className,
47
+ ...props
48
+ }) => {
49
+ const { trigger, classNames } = useTooltipStyles(unstyled);
50
+ return /* @__PURE__ */ jsx(
51
+ RadixTooltip.Trigger,
52
+ {
53
+ "data-slot": "tooltip-trigger",
54
+ className: trigger({ className: cn(classNames?.trigger, className) }),
55
+ ...props
56
+ }
57
+ );
58
+ };
59
+ var TooltipContent = ({
60
+ unstyled,
61
+ className,
62
+ side = "top",
63
+ sideOffset = 6,
64
+ ...props
65
+ }) => {
66
+ const { content, classNames } = useTooltipStyles(unstyled);
67
+ return /* @__PURE__ */ jsx(RadixTooltip.Portal, { "data-slot": "tooltip-portal", children: /* @__PURE__ */ jsx(
68
+ RadixTooltip.Content,
69
+ {
70
+ "data-slot": "tooltip-content",
71
+ side,
72
+ sideOffset,
73
+ className: content({ className: cn(classNames?.content, className) }),
74
+ ...props
75
+ }
76
+ ) });
77
+ };
78
+ var TooltipArrow = ({ unstyled, className, ...props }) => {
79
+ const { arrow, classNames } = useTooltipStyles(unstyled);
80
+ return /* @__PURE__ */ jsx(
81
+ RadixTooltip.Arrow,
82
+ {
83
+ "data-slot": "tooltip-arrow",
84
+ className: arrow({ className: cn(classNames?.arrow, className) }),
85
+ ...props
86
+ }
87
+ );
88
+ };
89
+ export {
90
+ Tooltip,
91
+ TooltipArrow,
92
+ TooltipContent,
93
+ TooltipProvider,
94
+ TooltipTrigger,
95
+ tooltipStyles,
96
+ useTooltipStyles
97
+ };
@@ -0,0 +1 @@
1
+ {"inputs":{"src/tooltip.tsx":{"bytes":6134,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"@mijn-ui/react-core","kind":"import-statement","external":true},{"path":"@radix-ui/react-tooltip","kind":"import-statement","external":true},{"path":"tailwind-variants","kind":"import-statement","external":true},{"path":"react/jsx-runtime","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":26,"imports":[{"path":"src/tooltip.tsx","kind":"import-statement","original":"./tooltip"}],"format":"esm"}},"outputs":{"dist/index.js":{"imports":[{"path":"@mijn-ui/react-core","kind":"import-statement","external":true},{"path":"@radix-ui/react-tooltip","kind":"import-statement","external":true},{"path":"tailwind-variants","kind":"import-statement","external":true},{"path":"react/jsx-runtime","kind":"import-statement","external":true}],"exports":["Tooltip","TooltipArrow","TooltipContent","TooltipProvider","TooltipTrigger","tooltipStyles","useTooltipStyles"],"entryPoint":"src/index.ts","inputs":{"src/tooltip.tsx":{"bytesInOutput":3002},"src/index.ts":{"bytesInOutput":0}},"bytes":3166}}}
package/package.json CHANGED
@@ -1,6 +1,62 @@
1
1
  {
2
2
  "name": "@mijn-ui/react-tooltip",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "author": "Htet Aung Lin<htetaunglin.coder@gmail.com>",
4
+ "version": "0.1.1",
5
+ "homepage": "https://mijn-ui.vercel.app",
6
+ "license": "MIT",
7
+ "type": "module",
8
+ "sideEffects": false,
9
+ "files": [
10
+ "dist"
11
+ ],
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/mijn-ui/mijn-ui-react.git",
15
+ "directory": "packages/components/tooltip"
16
+ },
17
+ "bugs": {
18
+ "url": "https://github.com/mijn-ui/mijn-ui-react/issues"
19
+ },
20
+ "exports": "./dist/index.js",
21
+ "types": "./dist/index.d.ts",
22
+ "devDependencies": {
23
+ "@next/eslint-plugin-next": "^15.0.3",
24
+ "@testing-library/react": "^16.1.0",
25
+ "@types/react": "^19.0.0",
26
+ "@types/react-dom": "^19.0.0",
27
+ "jsdom": "^30.1.3",
28
+ "react": "19.0.1",
29
+ "react-dom": "19.0.1",
30
+ "@mijn-ui/react-button": "0.7.0",
31
+ "@mijn-ui/react-core": "0.6.0",
32
+ "eslint-config-custom": "0.0.1",
33
+ "tsconfig": "0.0.0",
34
+ "tsup-config": "0.0.0"
35
+ },
36
+ "dependencies": {
37
+ "@radix-ui/react-tooltip": "^1.4.1"
38
+ },
39
+ "peerDependencies": {
40
+ "@mijn-ui/react-core": "^0.6.0",
41
+ "tailwind-merge": "^3.0.0",
42
+ "tailwind-variants": "^3.0.0",
43
+ "react": "^19.0",
44
+ "react-dom": "^19.0"
45
+ },
46
+ "publishConfig": {
47
+ "access": "public"
48
+ },
49
+ "keywords": [
50
+ "tooltip",
51
+ "react",
52
+ "nextjs"
53
+ ],
54
+ "scripts": {
55
+ "clean": "rimraf dist .turbo",
56
+ "build": "tsup",
57
+ "test": "vitest run",
58
+ "lint": "eslint .",
59
+ "lint:fix": "eslint . --fix",
60
+ "types:check": "tsc --noEmit"
61
+ }
6
62
  }