@gkucmierz/nano-ui 1.0.2 → 1.2.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 +13 -0
- package/dist/nano-ui.css +1 -1
- package/dist/nano-ui.js +106 -4
- package/package.json +7 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright (c) 2026, Grzegorz Kućmierz
|
|
2
|
+
|
|
3
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
4
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
5
|
+
copyright notice and this permission notice appear in all copies.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
8
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
9
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
10
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
11
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
12
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
13
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
package/dist/nano-ui.css
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
span.ripple{background-color:var(--nano-ripple-color,#fff6);pointer-events:none;border-radius:50%;animation:.6s linear nano-ripple-anim;position:absolute;transform:scale(0)}@keyframes nano-ripple-anim{to{opacity:0;transform:scale(4)}}
|
|
1
|
+
.global-tooltip[data-v-37c91a21]{--nu-tooltip-bg:#0f172af2;--nu-tooltip-color:#f8fafc;--nu-tooltip-radius:8px;--nu-tooltip-padding:8px 14px;--nu-tooltip-shadow:0 8px 24px #0000004d;--nu-tooltip-border:1px solid #ffffff1a;--nu-tooltip-arrow-border:#ffffff1a;z-index:99999;background:var(--nu-tooltip-bg);-webkit-backdrop-filter:blur(8px);color:var(--nu-tooltip-color);padding:var(--nu-tooltip-padding);border-radius:var(--nu-tooltip-radius);text-align:center;white-space:normal;word-wrap:break-word;pointer-events:none;width:max-content;max-width:min(350px,100vw - 32px);box-shadow:var(--nu-tooltip-shadow);border:var(--nu-tooltip-border);opacity:0;visibility:hidden;font-size:.85rem;font-weight:500;line-height:1.4;transition:opacity .2s cubic-bezier(.16,1,.3,1),transform .2s cubic-bezier(.16,1,.3,1);position:fixed;top:0;left:0;transform:translateY(4px)scale(.95)}.global-tooltip[data-v-37c91a21]:after{content:"";left:calc(50% + var(--arrow-offset,0px));background:var(--nu-tooltip-bg);-webkit-backdrop-filter:blur(8px);border-right:1px solid var(--nu-tooltip-arrow-border);border-bottom:1px solid var(--nu-tooltip-arrow-border);clip-path:polygon(100% 0,100% 100%,0 100%);border-radius:0 0 2px;width:10px;height:10px;margin-left:-5px;position:absolute;bottom:-5px;transform:rotate(45deg)}.global-tooltip.tooltip-bottom[data-v-37c91a21]:after{border-bottom:none;border-right:none;border-left:1px solid var(--nu-tooltip-arrow-border);border-top:1px solid var(--nu-tooltip-arrow-border);clip-path:polygon(0 0,100% 0,0 100%);border-radius:2px 0 0;top:-5px;bottom:auto}.global-tooltip.visible[data-v-37c91a21]{opacity:1;visibility:visible}span.ripple{background-color:var(--nano-ripple-color,#fff6);pointer-events:none;border-radius:50%;animation:.6s linear nano-ripple-anim;position:absolute;transform:scale(0)}@keyframes nano-ripple-anim{to{opacity:0;transform:scale(4)}}
|
|
2
2
|
/*$vite$:1*/
|
package/dist/nano-ui.js
CHANGED
|
@@ -1,13 +1,115 @@
|
|
|
1
|
+
import { createElementBlock as e, nextTick as t, normalizeClass as n, normalizeStyle as r, openBlock as i, reactive as a, ref as o, toDisplayString as s, unref as c, watch as l } from "vue";
|
|
1
2
|
//#region src/directives/ripple.js
|
|
2
|
-
var
|
|
3
|
+
var u = { mounted(e, t) {
|
|
3
4
|
e.style.position = "relative", e.style.overflow = "hidden", e.addEventListener("click", function(n) {
|
|
4
5
|
let r = e.getBoundingClientRect(), i = n.clientX - r.left, a = n.clientY - r.top, o = document.createElement("span"), s = Math.max(r.width, r.height), c = s / 2;
|
|
5
6
|
o.style.width = o.style.height = `${s}px`, o.style.left = `${i - c}px`, o.style.top = `${a - c}px`, o.classList.add("ripple"), t.value && typeof t.value == "string" && (o.style.backgroundColor = t.value), e.appendChild(o), setTimeout(() => {
|
|
6
7
|
o.remove();
|
|
7
8
|
}, 600);
|
|
8
9
|
});
|
|
9
|
-
} },
|
|
10
|
-
|
|
10
|
+
} }, d = a({
|
|
11
|
+
isVisible: !1,
|
|
12
|
+
text: "",
|
|
13
|
+
customClass: "",
|
|
14
|
+
targetRect: null
|
|
15
|
+
});
|
|
16
|
+
function f(e, t) {
|
|
17
|
+
if (!t) return;
|
|
18
|
+
let n = typeof t == "object" ? t.text : t, r = typeof t == "object" && t.class || "";
|
|
19
|
+
if (!n) return;
|
|
20
|
+
e.hasAttribute("aria-label") || e.setAttribute("aria-label", n);
|
|
21
|
+
let i = e.getBoundingClientRect();
|
|
22
|
+
d.targetRect = {
|
|
23
|
+
top: i.top,
|
|
24
|
+
left: i.left,
|
|
25
|
+
width: i.width,
|
|
26
|
+
bottom: i.bottom,
|
|
27
|
+
right: i.right
|
|
28
|
+
}, d.text = n, d.customClass = r, d.isVisible = !0;
|
|
29
|
+
}
|
|
30
|
+
typeof window < "u" && window.addEventListener("scroll", p, {
|
|
31
|
+
passive: !0,
|
|
32
|
+
capture: !0
|
|
33
|
+
});
|
|
34
|
+
function p() {
|
|
35
|
+
d.isVisible = !1;
|
|
36
|
+
}
|
|
37
|
+
//#endregion
|
|
38
|
+
//#region src/directives/tooltip.js
|
|
39
|
+
var m = {
|
|
40
|
+
mounted(e, t) {
|
|
41
|
+
e._tooltipOptions = t.value;
|
|
42
|
+
let n = null, r = !1;
|
|
43
|
+
e._handleMouseEnter = () => {
|
|
44
|
+
r || f(e, e._tooltipOptions);
|
|
45
|
+
}, e._handleMouseLeave = () => {
|
|
46
|
+
r || p();
|
|
47
|
+
}, e._handleFocus = () => {
|
|
48
|
+
r || f(e, e._tooltipOptions);
|
|
49
|
+
}, e._handleBlur = () => {
|
|
50
|
+
r || p();
|
|
51
|
+
}, e._handleTouchStart = () => {
|
|
52
|
+
r = !0, n && clearTimeout(n), n = setTimeout(() => {
|
|
53
|
+
f(e, e._tooltipOptions);
|
|
54
|
+
}, 400);
|
|
55
|
+
}, e._handleTouchEnd = () => {
|
|
56
|
+
n && clearTimeout(n), p(), setTimeout(() => {
|
|
57
|
+
r = !1;
|
|
58
|
+
}, 500);
|
|
59
|
+
}, e._handleTouchCancel = () => {
|
|
60
|
+
n && clearTimeout(n), p(), setTimeout(() => {
|
|
61
|
+
r = !1;
|
|
62
|
+
}, 500);
|
|
63
|
+
}, e._handleContextMenu = (t) => {
|
|
64
|
+
let n = typeof e._tooltipOptions == "object" ? e._tooltipOptions.text : e._tooltipOptions;
|
|
65
|
+
r && d.isVisible && d.text === n && t.preventDefault();
|
|
66
|
+
}, e.addEventListener("mouseenter", e._handleMouseEnter), e.addEventListener("mouseleave", e._handleMouseLeave), e.addEventListener("focus", e._handleFocus), e.addEventListener("blur", e._handleBlur), e.addEventListener("touchstart", e._handleTouchStart, { passive: !0 }), e.addEventListener("touchend", e._handleTouchEnd), e.addEventListener("touchmove", e._handleTouchCancel, { passive: !0 }), e.addEventListener("touchcancel", e._handleTouchCancel), e.addEventListener("contextmenu", e._handleContextMenu);
|
|
67
|
+
},
|
|
68
|
+
updated(e, t) {
|
|
69
|
+
e._tooltipOptions = t.value;
|
|
70
|
+
let n = typeof t.value == "object" ? t.value.text : t.value;
|
|
71
|
+
d.isVisible && d.text !== n && (e.matches(":hover") || document.activeElement === e) && f(e, t.value);
|
|
72
|
+
},
|
|
73
|
+
unmounted(e) {
|
|
74
|
+
e._handleMouseEnter && (e.removeEventListener("mouseenter", e._handleMouseEnter), e.removeEventListener("mouseleave", e._handleMouseLeave), e.removeEventListener("focus", e._handleFocus), e.removeEventListener("blur", e._handleBlur), e.removeEventListener("touchstart", e._handleTouchStart), e.removeEventListener("touchend", e._handleTouchEnd), e.removeEventListener("touchmove", e._handleTouchCancel), e.removeEventListener("touchcancel", e._handleTouchCancel), e.removeEventListener("contextmenu", e._handleContextMenu)), p();
|
|
75
|
+
}
|
|
76
|
+
}, h = /* @__PURE__ */ ((e, t) => {
|
|
77
|
+
let n = e.__vccOpts || e;
|
|
78
|
+
for (let [e, r] of t) n[e] = r;
|
|
79
|
+
return n;
|
|
80
|
+
})({
|
|
81
|
+
__name: "GlobalTooltip",
|
|
82
|
+
setup(a) {
|
|
83
|
+
let u = o(null), f = o(0), p = o(0), m = o(0), h = o(!1);
|
|
84
|
+
return l(() => d.isVisible, async (e) => {
|
|
85
|
+
if (e) {
|
|
86
|
+
if (await t(), !u.value || !d.targetRect) return;
|
|
87
|
+
let e = d.targetRect, n = u.value.getBoundingClientRect(), r = window.innerWidth, i = window.innerHeight, a = e.top, o = i - e.bottom, s = e.top - n.height - 8;
|
|
88
|
+
h.value = !1, (s < 8 || a < n.height + 8 && o > a) && (s = e.bottom + 8, h.value = !0), s + n.height > i - 8 && (s = i - n.height - 8), s < 8 && (s = 8);
|
|
89
|
+
let c = e.left + e.width / 2, l = c - n.width / 2;
|
|
90
|
+
l < 8 ? l = 8 : l + n.width > r - 8 && (l = r - n.width - 8);
|
|
91
|
+
let g = c - (l + n.width / 2), _ = n.width / 2 - 12;
|
|
92
|
+
g > _ && (g = _), g < -_ && (g = -_), m.value = g, f.value = l, p.value = s;
|
|
93
|
+
}
|
|
94
|
+
}), (t, a) => (i(), e("div", {
|
|
95
|
+
ref_key: "tooltipRef",
|
|
96
|
+
ref: u,
|
|
97
|
+
class: n([
|
|
98
|
+
"global-tooltip",
|
|
99
|
+
{
|
|
100
|
+
visible: c(d).isVisible,
|
|
101
|
+
"tooltip-bottom": h.value
|
|
102
|
+
},
|
|
103
|
+
c(d).customClass
|
|
104
|
+
]),
|
|
105
|
+
style: r({
|
|
106
|
+
transform: `translate(${f.value}px, ${p.value}px)`,
|
|
107
|
+
"--arrow-offset": `${m.value}px`
|
|
108
|
+
})
|
|
109
|
+
}, s(c(d).text), 7));
|
|
110
|
+
}
|
|
111
|
+
}, [["__scopeId", "data-v-37c91a21"]]), g = { install(e) {
|
|
112
|
+
e.directive("ripple", u), e.directive("tooltip", m), e.component("GlobalTooltip", h);
|
|
11
113
|
} };
|
|
12
114
|
//#endregion
|
|
13
|
-
export {
|
|
115
|
+
export { h as GlobalTooltip, u as Ripple, g as default, p as hideTooltip, f as showTooltip, m as tooltipDirective, d as tooltipState };
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gkucmierz/nano-ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.1",
|
|
4
|
+
"license": "ISC",
|
|
4
5
|
"description": "High-performance, minimal footprint Vue 3 UI library and directives.",
|
|
5
6
|
"type": "module",
|
|
6
7
|
"main": "./dist/nano-ui.js",
|
|
@@ -23,7 +24,7 @@
|
|
|
23
24
|
"vue": "^3.0.0"
|
|
24
25
|
},
|
|
25
26
|
"devDependencies": {
|
|
26
|
-
"@vitejs/plugin-vue": "^
|
|
27
|
+
"@vitejs/plugin-vue": "^6.0.5",
|
|
27
28
|
"vite": "^8.0.12",
|
|
28
29
|
"vue": "^3.4.0"
|
|
29
30
|
},
|
|
@@ -40,5 +41,8 @@
|
|
|
40
41
|
"ripple",
|
|
41
42
|
"nano",
|
|
42
43
|
"glassmorphism"
|
|
43
|
-
]
|
|
44
|
+
],
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"vue-router": "^5.0.6"
|
|
47
|
+
}
|
|
44
48
|
}
|