kitzo 2.5.1 → 2.5.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/dist/index.d.ts +2 -2
- package/dist/react/components/tooltip/Tooltip.js +26 -26
- package/dist/react/components/tooltip/helpers/addTooltipStyles.js +74 -80
- package/dist/react/components/tooltip/helpers/getPositionClass.js +9 -14
- package/dist/react/components/tooltip/partials/TooltipWrapper.js +8 -8
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -90,8 +90,8 @@ declare type TooltipCoreProps = {
|
|
|
90
90
|
smartHover?: boolean;
|
|
91
91
|
hideOnTouch?: boolean;
|
|
92
92
|
animation?: TooltipAnimation;
|
|
93
|
-
|
|
94
|
-
|
|
93
|
+
hidden?: boolean;
|
|
94
|
+
dark?: boolean;
|
|
95
95
|
};
|
|
96
96
|
|
|
97
97
|
export declare type TooltipPosition = 'top' | 'top-start' | 'top-end' | 'right' | 'right-start' | 'right-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'left' | 'left-start' | 'left-end';
|
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
import { jsx as a, Fragment as r, jsxs as T } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
2
|
+
import c from "react";
|
|
3
3
|
import v from "./helpers/addTooltipStyles.js";
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
function
|
|
4
|
+
import k from "./helpers/getPositionClass.js";
|
|
5
|
+
import w from "./partials/TooltipWrapper.js";
|
|
6
|
+
import O from "./helpers/getAnimationProperties.js";
|
|
7
|
+
function z(h) {
|
|
8
8
|
const {
|
|
9
9
|
content: n,
|
|
10
10
|
children: t,
|
|
11
11
|
position: y = "top",
|
|
12
12
|
animation: i = !0,
|
|
13
|
-
|
|
13
|
+
hidden: s = !1,
|
|
14
14
|
offset: m = 8,
|
|
15
15
|
smartHover: f = !0,
|
|
16
16
|
hideOnTouch: l = !0,
|
|
17
|
-
|
|
18
|
-
} = h, [
|
|
19
|
-
if (
|
|
20
|
-
|
|
21
|
-
}, []), !
|
|
17
|
+
dark: u
|
|
18
|
+
} = h, [b, x] = c.useState(!1);
|
|
19
|
+
if (c.useEffect(() => {
|
|
20
|
+
x(!0), v();
|
|
21
|
+
}, []), !b) return /* @__PURE__ */ a(r, { children: t });
|
|
22
22
|
if (typeof s == "boolean" && s) return /* @__PURE__ */ a(r, { children: t });
|
|
23
23
|
if (n == null)
|
|
24
24
|
return /* @__PURE__ */ a(r, { children: t });
|
|
25
|
-
const
|
|
25
|
+
const e = {
|
|
26
26
|
offset: isNaN(Number(m)) ? 8 : Number(m),
|
|
27
27
|
smartHover: typeof f == "boolean" ? f : !0,
|
|
28
28
|
hideOnTouch: typeof l == "boolean" ? l : !0
|
|
29
29
|
};
|
|
30
|
-
let p = !1,
|
|
31
|
-
if (typeof window < "u" && (
|
|
32
|
-
const
|
|
30
|
+
let p = !1, d = !1;
|
|
31
|
+
if (typeof window < "u" && (d = window.matchMedia("(pointer: coarse)").matches || navigator.maxTouchPoints > 0, p = typeof u == "boolean" ? u : window.matchMedia("(prefers-color-scheme: dark)").matches), d && e.hideOnTouch) return t;
|
|
32
|
+
const D = k(y), M = !!i, o = O(
|
|
33
33
|
i === !0 ? {} : i
|
|
34
34
|
);
|
|
35
35
|
return /* @__PURE__ */ T(
|
|
@@ -37,25 +37,25 @@ function C(h) {
|
|
|
37
37
|
{
|
|
38
38
|
style: {
|
|
39
39
|
position: "relative",
|
|
40
|
-
|
|
41
|
-
"--offset": Math.max(0,
|
|
40
|
+
inlineSize: "fit-content",
|
|
41
|
+
"--offset": Math.max(0, e.offset),
|
|
42
42
|
"--startDuration": Math.max(
|
|
43
43
|
0,
|
|
44
|
-
|
|
44
|
+
o.startDuration
|
|
45
45
|
),
|
|
46
|
-
"--endDuration": Math.max(0,
|
|
47
|
-
"--startDelay": Math.max(0,
|
|
48
|
-
"--endDelay": Math.max(0,
|
|
46
|
+
"--endDuration": Math.max(0, o.endDuration),
|
|
47
|
+
"--startDelay": Math.max(0, o.startDelay),
|
|
48
|
+
"--endDelay": Math.max(0, o.endDelay)
|
|
49
49
|
},
|
|
50
|
-
className: `kitzo-tooltip-root ${p ? "tooltip-theme-dark" : ""} ${
|
|
50
|
+
className: `kitzo-tooltip-root ${p ? "dark tooltip-theme-dark" : ""} ${e.smartHover ? "smart-hover" : ""} ${M ? "animate-tooltip" : ""}`,
|
|
51
51
|
children: [
|
|
52
52
|
t,
|
|
53
53
|
/* @__PURE__ */ a(
|
|
54
|
-
|
|
54
|
+
w,
|
|
55
55
|
{
|
|
56
56
|
content: n,
|
|
57
|
-
positionClass:
|
|
58
|
-
finalOptions:
|
|
57
|
+
positionClass: D,
|
|
58
|
+
finalOptions: e
|
|
59
59
|
}
|
|
60
60
|
)
|
|
61
61
|
]
|
|
@@ -63,5 +63,5 @@ function C(h) {
|
|
|
63
63
|
);
|
|
64
64
|
}
|
|
65
65
|
export {
|
|
66
|
-
|
|
66
|
+
z as Tooltip
|
|
67
67
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
const o =
|
|
1
|
+
const o = `/*! Default styling */
|
|
2
|
+
.kitzo-tooltip-root {
|
|
2
3
|
--bg-clr: hsl(0, 0%, 15%);
|
|
3
4
|
--text-clr: hsl(0, 0%, 95%);
|
|
4
5
|
|
|
@@ -6,6 +7,8 @@ const o = `.kitzo-tooltip-root {
|
|
|
6
7
|
--transition-endDuration: calc(var(--endDuration) * 1ms);
|
|
7
8
|
--transition-startDelay: calc(var(--startDelay) * 1ms);
|
|
8
9
|
--transition-endDelay: calc(var(--endDelay) * 1ms);
|
|
10
|
+
|
|
11
|
+
--tooltip-offset: calc(var(--offset) * 1px + 1px);
|
|
9
12
|
}
|
|
10
13
|
|
|
11
14
|
.kitzo-tooltip-root.tooltip-theme-dark {
|
|
@@ -32,12 +35,11 @@ const o = `.kitzo-tooltip-root {
|
|
|
32
35
|
color: var(--text-clr);
|
|
33
36
|
padding-block: 0.25rem;
|
|
34
37
|
padding-inline: 0.5rem;
|
|
35
|
-
border-radius: 0.
|
|
38
|
+
border-radius: 0.425rem;
|
|
36
39
|
}
|
|
37
40
|
|
|
38
|
-
|
|
41
|
+
/*! Tooltip transitions */
|
|
39
42
|
.kitzo-tooltip-wrapper {
|
|
40
|
-
--tooltip-offset: calc(var(--offset) * 1px + 1px);
|
|
41
43
|
opacity: 0;
|
|
42
44
|
transition-property: opacity;
|
|
43
45
|
transition-delay: calc(
|
|
@@ -50,80 +52,6 @@ const o = `.kitzo-tooltip-root {
|
|
|
50
52
|
transition-delay: 0ms;
|
|
51
53
|
}
|
|
52
54
|
|
|
53
|
-
/* Top */
|
|
54
|
-
.kitzo-tooltip-wrapper.top {
|
|
55
|
-
bottom: 100%;
|
|
56
|
-
padding-block-end: var(--tooltip-offset);
|
|
57
|
-
}
|
|
58
|
-
.kitzo-tooltip-wrapper.top {
|
|
59
|
-
left: 50%;
|
|
60
|
-
translate: -50% 0;
|
|
61
|
-
}
|
|
62
|
-
.kitzo-tooltip-wrapper.top.start {
|
|
63
|
-
left: 0;
|
|
64
|
-
translate: 0 0;
|
|
65
|
-
}
|
|
66
|
-
.kitzo-tooltip-wrapper.top.end {
|
|
67
|
-
left: auto;
|
|
68
|
-
right: 0;
|
|
69
|
-
translate: 0 0;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/* Right */
|
|
73
|
-
.kitzo-tooltip-wrapper.right {
|
|
74
|
-
left: 100%;
|
|
75
|
-
padding-inline-start: var(--tooltip-offset);
|
|
76
|
-
}
|
|
77
|
-
.kitzo-tooltip-wrapper.right {
|
|
78
|
-
top: 50%;
|
|
79
|
-
translate: 0 -50%;
|
|
80
|
-
}
|
|
81
|
-
.kitzo-tooltip-wrapper.right.start {
|
|
82
|
-
top: 0;
|
|
83
|
-
translate: 0 0;
|
|
84
|
-
}
|
|
85
|
-
.kitzo-tooltip-wrapper.right.end {
|
|
86
|
-
top: 100%;
|
|
87
|
-
translate: 0 -100%;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/* Bottom */
|
|
91
|
-
.kitzo-tooltip-wrapper.bottom {
|
|
92
|
-
top: 100%;
|
|
93
|
-
padding-block-start: var(--tooltip-offset);
|
|
94
|
-
}
|
|
95
|
-
.kitzo-tooltip-wrapper.bottom {
|
|
96
|
-
left: 50%;
|
|
97
|
-
translate: -50% 0;
|
|
98
|
-
}
|
|
99
|
-
.kitzo-tooltip-wrapper.bottom.start {
|
|
100
|
-
left: 0;
|
|
101
|
-
translate: 0 0;
|
|
102
|
-
}
|
|
103
|
-
.kitzo-tooltip-wrapper.bottom.end {
|
|
104
|
-
left: 100%;
|
|
105
|
-
translate: -100% 0;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/* Left */
|
|
109
|
-
.kitzo-tooltip-wrapper.left {
|
|
110
|
-
right: 100%;
|
|
111
|
-
padding-inline-end: var(--tooltip-offset);
|
|
112
|
-
}
|
|
113
|
-
.kitzo-tooltip-wrapper.left {
|
|
114
|
-
top: 50%;
|
|
115
|
-
translate: 0 -50%;
|
|
116
|
-
}
|
|
117
|
-
.kitzo-tooltip-wrapper.left.start {
|
|
118
|
-
top: 0;
|
|
119
|
-
translate: 0 0;
|
|
120
|
-
}
|
|
121
|
-
.kitzo-tooltip-wrapper.left.end {
|
|
122
|
-
top: 100%;
|
|
123
|
-
translate: 0 -100%;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/* Tooltip transitions */
|
|
127
55
|
.kitzo-tooltip-root.animate-tooltip {
|
|
128
56
|
.kitzo-tooltip-content {
|
|
129
57
|
text-rendering: optimizeLegibility;
|
|
@@ -170,7 +98,7 @@ const o = `.kitzo-tooltip-root {
|
|
|
170
98
|
}
|
|
171
99
|
}
|
|
172
100
|
|
|
173
|
-
|
|
101
|
+
/*! smart hover persistence feature */
|
|
174
102
|
.kitzo-tooltip-root {
|
|
175
103
|
.kitzo-tooltip-wrapper {
|
|
176
104
|
pointer-events: none;
|
|
@@ -180,7 +108,73 @@ const o = `.kitzo-tooltip-root {
|
|
|
180
108
|
.kitzo-tooltip-wrapper {
|
|
181
109
|
pointer-events: all;
|
|
182
110
|
}
|
|
183
|
-
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/*! Tooltip positioning */
|
|
114
|
+
/*? Top */
|
|
115
|
+
.kitzo-tooltip-wrapper[data-position^='top'] {
|
|
116
|
+
bottom: 100%;
|
|
117
|
+
padding-block-end: var(--tooltip-offset);
|
|
118
|
+
}
|
|
119
|
+
.kitzo-tooltip-wrapper[data-position='top'] {
|
|
120
|
+
left: 50%;
|
|
121
|
+
translate: -50% 0;
|
|
122
|
+
}
|
|
123
|
+
.kitzo-tooltip-wrapper[data-position='top-start'] {
|
|
124
|
+
left: 0;
|
|
125
|
+
}
|
|
126
|
+
.kitzo-tooltip-wrapper[data-position='top-end'] {
|
|
127
|
+
right: 0;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/*? Right */
|
|
131
|
+
.kitzo-tooltip-wrapper[data-position^='right'] {
|
|
132
|
+
inset-inline-start: 100%;
|
|
133
|
+
padding-inline-start: var(--tooltip-offset);
|
|
134
|
+
}
|
|
135
|
+
.kitzo-tooltip-wrapper[data-position='right'] {
|
|
136
|
+
top: 50%;
|
|
137
|
+
translate: 0 -50%;
|
|
138
|
+
}
|
|
139
|
+
.kitzo-tooltip-wrapper[data-position='right-start'] {
|
|
140
|
+
top: 0;
|
|
141
|
+
}
|
|
142
|
+
.kitzo-tooltip-wrapper[data-position='right-end'] {
|
|
143
|
+
bottom: 0;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/*? Bottom */
|
|
147
|
+
.kitzo-tooltip-wrapper[data-position^='bottom'] {
|
|
148
|
+
top: 100%;
|
|
149
|
+
padding-block-start: var(--tooltip-offset);
|
|
150
|
+
}
|
|
151
|
+
.kitzo-tooltip-wrapper[data-position='bottom'] {
|
|
152
|
+
left: 50%;
|
|
153
|
+
translate: -50% 0;
|
|
154
|
+
}
|
|
155
|
+
.kitzo-tooltip-wrapper[data-position='bottom-start'] {
|
|
156
|
+
left: 0;
|
|
157
|
+
}
|
|
158
|
+
.kitzo-tooltip-wrapper[data-position='bottom-end'] {
|
|
159
|
+
right: 0;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/*? Left */
|
|
163
|
+
.kitzo-tooltip-wrapper[data-position^='left'] {
|
|
164
|
+
inset-inline-end: 100%;
|
|
165
|
+
padding-inline-end: var(--tooltip-offset);
|
|
166
|
+
}
|
|
167
|
+
.kitzo-tooltip-wrapper[data-position='left'] {
|
|
168
|
+
top: 50%;
|
|
169
|
+
translate: 0 -50%;
|
|
170
|
+
}
|
|
171
|
+
.kitzo-tooltip-wrapper[data-position='left-start'] {
|
|
172
|
+
top: 0;
|
|
173
|
+
}
|
|
174
|
+
.kitzo-tooltip-wrapper[data-position='left-end'] {
|
|
175
|
+
bottom: 0;
|
|
176
|
+
}
|
|
177
|
+
`;
|
|
184
178
|
function i() {
|
|
185
179
|
if (!document.getElementById("kitzo-tooltip-styles")) {
|
|
186
180
|
const t = document.createElement("style");
|
|
@@ -1,27 +1,22 @@
|
|
|
1
|
-
const
|
|
2
|
-
"top-start",
|
|
1
|
+
const r = [
|
|
3
2
|
"top",
|
|
3
|
+
"top-start",
|
|
4
4
|
"top-end",
|
|
5
|
-
"right-start",
|
|
6
5
|
"right",
|
|
6
|
+
"right-start",
|
|
7
7
|
"right-end",
|
|
8
|
-
"bottom-start",
|
|
9
8
|
"bottom",
|
|
9
|
+
"bottom-start",
|
|
10
10
|
"bottom-end",
|
|
11
|
-
"left-start",
|
|
12
11
|
"left",
|
|
12
|
+
"left-start",
|
|
13
13
|
"left-end"
|
|
14
14
|
];
|
|
15
|
-
function
|
|
15
|
+
function s(t = "") {
|
|
16
16
|
t = typeof t == "string" ? t.trim().toLowerCase() : "top";
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
if (e.includes("-")) {
|
|
20
|
-
const [o, r] = e.split("-");
|
|
21
|
-
return `${o} ${r}`;
|
|
22
|
-
} else
|
|
23
|
-
return e;
|
|
17
|
+
const o = r.find((e) => e === t);
|
|
18
|
+
return o || "top";
|
|
24
19
|
}
|
|
25
20
|
export {
|
|
26
|
-
|
|
21
|
+
s as default
|
|
27
22
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { jsx as e, Fragment as
|
|
1
|
+
import { jsx as e, Fragment as r } from "react/jsx-runtime";
|
|
2
2
|
function l({
|
|
3
3
|
content: t,
|
|
4
|
-
positionClass:
|
|
5
|
-
finalOptions:
|
|
4
|
+
positionClass: i,
|
|
5
|
+
finalOptions: o
|
|
6
6
|
}) {
|
|
7
7
|
return /* @__PURE__ */ e(
|
|
8
8
|
"div",
|
|
@@ -10,15 +10,15 @@ function l({
|
|
|
10
10
|
style: {
|
|
11
11
|
position: "absolute",
|
|
12
12
|
whiteSpace: "pre-wrap",
|
|
13
|
-
|
|
13
|
+
inlineSize: "max-content"
|
|
14
14
|
},
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
className: `kitzo-tooltip-wrapper ${i}`,
|
|
16
|
+
"data-position": i,
|
|
17
17
|
children: /* @__PURE__ */ e(
|
|
18
18
|
"div",
|
|
19
19
|
{
|
|
20
|
-
className: `kitzo-tooltip-content ${
|
|
21
|
-
children: typeof t == "string" || typeof t == "number" ? /* @__PURE__ */ e("div", { className: "kitzo-tooltip-content-default-style", children: t }) : /* @__PURE__ */ e(
|
|
20
|
+
className: `kitzo-tooltip-content ${i} ${o.arrow ? "tooltip-arrow" : ""}`,
|
|
21
|
+
children: typeof t == "string" || typeof t == "number" ? /* @__PURE__ */ e("div", { className: "kitzo-tooltip-content-default-style", children: t }) : /* @__PURE__ */ e(r, { children: t })
|
|
22
22
|
}
|
|
23
23
|
)
|
|
24
24
|
}
|