neatkit 0.14.1 → 0.15.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/dist/Boundary.cjs +1 -1
- package/dist/Boundary.js +1 -1
- package/dist/Markdown.cjs +1 -1
- package/dist/Markdown.js +1 -1
- package/dist/Popover.cjs +1 -1
- package/dist/Popover.js +104 -101
- package/dist/Select.cjs +1 -1
- package/dist/Select.js +325 -314
- package/dist/Sidebar.cjs +1 -1
- package/dist/Sidebar.js +3 -3
- package/dist/{Table-DYO-bPlD.cjs → Table-DBkiHOd0.cjs} +1 -1
- package/dist/{Table-BiRwd6PX.js → Table-DdTjtnRE.js} +1 -1
- package/dist/Table.cjs +1 -1
- package/dist/Table.js +1 -1
- package/dist/Tooltip-4RWCnb2Q.js +229 -0
- package/dist/Tooltip-B2rZmRCs.cjs +1 -0
- package/dist/Tooltip.cjs +1 -1
- package/dist/Tooltip.js +1 -1
- package/dist/components/Popover/Popover.d.ts +17 -0
- package/dist/components/Popover/index.d.ts +1 -1
- package/dist/components/Portal/hooks/useAnchoredPosition.d.ts +12 -10
- package/dist/components/Portal/hooks/useFloatingPosition.d.ts +3 -1
- package/dist/components/Portal/utils/floating-alignment.d.ts +18 -0
- package/dist/components/Portal/utils/floating-position.d.ts +7 -36
- package/dist/components/Portal/utils/geometry.d.ts +45 -0
- package/dist/components/Select/Select.d.ts +1 -1
- package/dist/components/Select/components/CustomSelect.d.ts +9 -0
- package/dist/components/Select/components/SelectListbox.d.ts +3 -0
- package/dist/components/Select/hooks/useSelectPosition.d.ts +3 -1
- package/dist/components/Select/index.d.ts +1 -1
- package/dist/components/Select/utils/listbox-position.d.ts +8 -5
- package/dist/components/Tooltip/Tooltip.d.ts +10 -0
- package/dist/components/Tooltip/index.d.ts +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/style.css +1 -1
- package/dist/tokens.d.ts +2 -8
- package/dist/{units-CpnLv2H4.cjs → units-BEMW4BNr.cjs} +1 -1
- package/dist/{units-Bx_CBIy8.js → units-D4Waz9EO.js} +1 -5
- package/dist/useAnchoredPosition-CrdY2Eat.cjs +1 -0
- package/dist/useAnchoredPosition-xI79veB2.js +79 -0
- package/dist/useFloatingPosition-DPVO2E8O.cjs +1 -0
- package/dist/useFloatingPosition-DktY7k-t.js +110 -0
- package/package.json +1 -1
- package/dist/Tooltip-CxcO3Vu-.cjs +0 -1
- package/dist/Tooltip-WwAWQ_Kq.js +0 -226
- package/dist/useAnchoredPosition-C0VS7hm6.js +0 -105
- package/dist/useAnchoredPosition-D7GRFzoX.cjs +0 -1
- package/dist/useFloatingPosition-DQgw-w_Z.cjs +0 -1
- package/dist/useFloatingPosition-MGoyautY.js +0 -57
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { useState as T } from "react";
|
|
2
|
+
import { a as V } from "./effects-DGbA6Q2O.js";
|
|
3
|
+
function K(o, n, t, e) {
|
|
4
|
+
return o === "start" ? n : o === "end" ? n + t - e : n + (t - e) / 2;
|
|
5
|
+
}
|
|
6
|
+
function W(o, n) {
|
|
7
|
+
const t = n.getComputedStyle(o);
|
|
8
|
+
let e = Number.parseFloat(t.width), i = Number.parseFloat(t.height);
|
|
9
|
+
t.boxSizing !== "border-box" && (e += (Number.parseFloat(t.paddingLeft) || 0) + (Number.parseFloat(t.paddingRight) || 0) + (Number.parseFloat(t.borderLeftWidth) || 0) + (Number.parseFloat(t.borderRightWidth) || 0), i += (Number.parseFloat(t.paddingTop) || 0) + (Number.parseFloat(t.paddingBottom) || 0) + (Number.parseFloat(t.borderTopWidth) || 0) + (Number.parseFloat(t.borderBottomWidth) || 0));
|
|
10
|
+
const s = o.offsetWidth, a = o.offsetHeight;
|
|
11
|
+
return {
|
|
12
|
+
width: Math.round(e) === s ? e : s,
|
|
13
|
+
height: Math.round(i) === a ? i : a
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function H(o, n, t) {
|
|
17
|
+
const e = Math.max(o.left, 0), i = Math.max(o.top, 0), s = Math.min(o.right, n), a = Math.min(o.bottom, t);
|
|
18
|
+
return s <= e || a <= i ? o : { bottom: a, left: e, right: s, top: i };
|
|
19
|
+
}
|
|
20
|
+
const I = 8;
|
|
21
|
+
function _(o, n) {
|
|
22
|
+
const t = n.getComputedStyle(o), e = Number.parseFloat(
|
|
23
|
+
t.getPropertyValue("--nk-space-8")
|
|
24
|
+
);
|
|
25
|
+
return Number.isFinite(e) ? e : I;
|
|
26
|
+
}
|
|
27
|
+
function X(o) {
|
|
28
|
+
const { active: n, boundary: t, fit: e, panel: i, trigger: s } = o, [a, m] = T(null);
|
|
29
|
+
return V(() => {
|
|
30
|
+
if (!n || !s || !t) {
|
|
31
|
+
m(null);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const f = s, u = t, b = s.ownerDocument.defaultView;
|
|
35
|
+
if (!b) return;
|
|
36
|
+
const c = b;
|
|
37
|
+
let g;
|
|
38
|
+
function C() {
|
|
39
|
+
return g === void 0 && (g = _(
|
|
40
|
+
f,
|
|
41
|
+
c
|
|
42
|
+
)), g;
|
|
43
|
+
}
|
|
44
|
+
function d() {
|
|
45
|
+
const l = u.getBoundingClientRect(), p = W(u, c), A = i ? W(i, c) : void 0, P = f.getBoundingClientRect(), v = p.width > 0 && l.width > 0 ? l.width / p.width : 1, L = p.height > 0 && l.height > 0 ? l.height / p.height : 1;
|
|
46
|
+
function N(h) {
|
|
47
|
+
const F = (h.left - l.left) / v - u.clientLeft + u.scrollLeft, x = (h.top - l.top) / L - u.clientTop + u.scrollTop, B = (h.right - h.left) / v, S = (h.bottom - h.top) / L;
|
|
48
|
+
return {
|
|
49
|
+
bottom: x + S,
|
|
50
|
+
height: S,
|
|
51
|
+
left: F,
|
|
52
|
+
right: F + B,
|
|
53
|
+
top: x,
|
|
54
|
+
width: B
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
const y = H(
|
|
58
|
+
l,
|
|
59
|
+
c.innerWidth,
|
|
60
|
+
c.innerHeight
|
|
61
|
+
), E = N(P), M = N(y), R = e({
|
|
62
|
+
panelSize: A,
|
|
63
|
+
readSpacing: C,
|
|
64
|
+
triggerBounds: E,
|
|
65
|
+
visibleBounds: M
|
|
66
|
+
});
|
|
67
|
+
m(R);
|
|
68
|
+
}
|
|
69
|
+
d(), c.addEventListener("scroll", d, !0), c.addEventListener("resize", d);
|
|
70
|
+
const w = c.ResizeObserver, r = w ? new w(d) : null;
|
|
71
|
+
return r == null || r.observe(f, { box: "border-box" }), r == null || r.observe(u, { box: "border-box" }), i && (r == null || r.observe(i, { box: "border-box" })), () => {
|
|
72
|
+
c.removeEventListener("scroll", d, !0), c.removeEventListener("resize", d), r == null || r.disconnect();
|
|
73
|
+
};
|
|
74
|
+
}, [n, t, e, i, s]), a;
|
|
75
|
+
}
|
|
76
|
+
export {
|
|
77
|
+
K as c,
|
|
78
|
+
X as u
|
|
79
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const b=require("react"),u=require("./useAnchoredPosition-CrdY2Eat.cjs");function P(o){return/^on[A-Z]/.test(o)}function A(o){return typeof o=="function"||o===void 0}function T(o,t){return o?t?function(i){o(i),t(i)}:o:t}function E(o,t){const e={...t};for(const[i,l]of Object.entries(t)){if(!P(i))continue;const f=o[i];!A(l)||!A(f)||(e[i]=T(f,l))}return t.className!==void 0?e.className=[o.className,t.className].filter(Boolean).join(" "):delete e.className,t.style!==void 0?e.style={...o.style,...t.style}:delete e.style,e}const F=12,x={bottom:"top",left:"right",right:"left",top:"bottom"};function N(o,t){const e=Math.min(F,t/2);return Math.min(Math.max(e,o),t-e)}function q(o){return x[o]}function w(o,t){return t==="left"||t==="right"?o.width:o.height}function I(o,t,e,i,l,f="center"){const h={bottom:l.bottom-e.bottom-t*2,left:e.left-l.left-t*2,right:l.right-e.right-t*2,top:e.top-l.top-t*2},m=q(o),a=w(i,o),c=h[o]<a&&h[m]>h[o]?m:o;let n=u.calculateAlignedPosition(f,e.left,e.width,i.width),s=u.calculateAlignedPosition(f,e.top,e.height,i.height);c==="top"?s=e.top-i.height-t:c==="bottom"?s=e.bottom+t:c==="left"?n=e.left-i.width-t:n=e.right+t;const M=l.left+t,O=l.top+t;n=Math.min(Math.max(M,n),Math.max(M,l.right-t-i.width)),s=Math.min(Math.max(O,s),Math.max(O,l.bottom-t-i.height));let r;return c==="top"||c==="bottom"?r=N(e.left+e.width/2-n,i.width):r=N(e.top+e.height/2-s,i.height),{arrowOffset:r,left:n,placement:c,top:s}}function _(o,t,e,i,l,f="center"){const h=b.useCallback(m=>{const{panelSize:a,readSpacing:v,triggerBounds:c,visibleBounds:n}=m;return a?I(t,v(),c,a,n,f):null},[f,t]);return u.useAnchoredPosition({active:o,boundary:l,fit:h,panel:i,trigger:e})}exports.resolveTriggerOverrides=E;exports.useFloatingPosition=_;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { useCallback as x } from "react";
|
|
2
|
+
import { c as O, u as A } from "./useAnchoredPosition-xI79veB2.js";
|
|
3
|
+
function E(o) {
|
|
4
|
+
return /^on[A-Z]/.test(o);
|
|
5
|
+
}
|
|
6
|
+
function N(o) {
|
|
7
|
+
return typeof o == "function" || o === void 0;
|
|
8
|
+
}
|
|
9
|
+
function T(o, t) {
|
|
10
|
+
return o ? t ? function(i) {
|
|
11
|
+
o(i), t(i);
|
|
12
|
+
} : o : t;
|
|
13
|
+
}
|
|
14
|
+
function G(o, t) {
|
|
15
|
+
const e = { ...t };
|
|
16
|
+
for (const [i, l] of Object.entries(t)) {
|
|
17
|
+
if (!E(i)) continue;
|
|
18
|
+
const f = o[i];
|
|
19
|
+
!N(l) || !N(f) || (e[i] = T(
|
|
20
|
+
f,
|
|
21
|
+
l
|
|
22
|
+
));
|
|
23
|
+
}
|
|
24
|
+
return t.className !== void 0 ? e.className = [
|
|
25
|
+
o.className,
|
|
26
|
+
t.className
|
|
27
|
+
].filter(Boolean).join(" ") : delete e.className, t.style !== void 0 ? e.style = {
|
|
28
|
+
...o.style,
|
|
29
|
+
...t.style
|
|
30
|
+
} : delete e.style, e;
|
|
31
|
+
}
|
|
32
|
+
const F = 12, P = {
|
|
33
|
+
bottom: "top",
|
|
34
|
+
left: "right",
|
|
35
|
+
right: "left",
|
|
36
|
+
top: "bottom"
|
|
37
|
+
};
|
|
38
|
+
function b(o, t) {
|
|
39
|
+
const e = Math.min(F, t / 2);
|
|
40
|
+
return Math.min(Math.max(e, o), t - e);
|
|
41
|
+
}
|
|
42
|
+
function p(o) {
|
|
43
|
+
return P[o];
|
|
44
|
+
}
|
|
45
|
+
function w(o, t) {
|
|
46
|
+
return t === "left" || t === "right" ? o.width : o.height;
|
|
47
|
+
}
|
|
48
|
+
function I(o, t, e, i, l, f = "center") {
|
|
49
|
+
const s = {
|
|
50
|
+
bottom: l.bottom - e.bottom - t * 2,
|
|
51
|
+
left: e.left - l.left - t * 2,
|
|
52
|
+
right: l.right - e.right - t * 2,
|
|
53
|
+
top: e.top - l.top - t * 2
|
|
54
|
+
}, n = p(o), a = w(i, o), h = s[o] < a && s[n] > s[o] ? n : o;
|
|
55
|
+
let m = O(
|
|
56
|
+
f,
|
|
57
|
+
e.left,
|
|
58
|
+
e.width,
|
|
59
|
+
i.width
|
|
60
|
+
), c = O(
|
|
61
|
+
f,
|
|
62
|
+
e.top,
|
|
63
|
+
e.height,
|
|
64
|
+
i.height
|
|
65
|
+
);
|
|
66
|
+
h === "top" ? c = e.top - i.height - t : h === "bottom" ? c = e.bottom + t : h === "left" ? m = e.left - i.width - t : m = e.right + t;
|
|
67
|
+
const M = l.left + t, v = l.top + t;
|
|
68
|
+
m = Math.min(
|
|
69
|
+
Math.max(M, m),
|
|
70
|
+
Math.max(M, l.right - t - i.width)
|
|
71
|
+
), c = Math.min(
|
|
72
|
+
Math.max(v, c),
|
|
73
|
+
Math.max(v, l.bottom - t - i.height)
|
|
74
|
+
);
|
|
75
|
+
let u;
|
|
76
|
+
return h === "top" || h === "bottom" ? u = b(
|
|
77
|
+
e.left + e.width / 2 - m,
|
|
78
|
+
i.width
|
|
79
|
+
) : u = b(
|
|
80
|
+
e.top + e.height / 2 - c,
|
|
81
|
+
i.height
|
|
82
|
+
), { arrowOffset: u, left: m, placement: h, top: c };
|
|
83
|
+
}
|
|
84
|
+
function H(o, t, e, i, l, f = "center") {
|
|
85
|
+
const s = x(
|
|
86
|
+
(n) => {
|
|
87
|
+
const { panelSize: a, readSpacing: r, triggerBounds: h, visibleBounds: m } = n;
|
|
88
|
+
return a ? I(
|
|
89
|
+
t,
|
|
90
|
+
r(),
|
|
91
|
+
h,
|
|
92
|
+
a,
|
|
93
|
+
m,
|
|
94
|
+
f
|
|
95
|
+
) : null;
|
|
96
|
+
},
|
|
97
|
+
[f, t]
|
|
98
|
+
);
|
|
99
|
+
return A({
|
|
100
|
+
active: o,
|
|
101
|
+
boundary: l,
|
|
102
|
+
fit: s,
|
|
103
|
+
panel: i,
|
|
104
|
+
trigger: e
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
export {
|
|
108
|
+
G as r,
|
|
109
|
+
H as u
|
|
110
|
+
};
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use client";"use strict";const m=require("react/jsx-runtime"),n=require("react"),we=require("./aria-DM-xYEHQ.cjs"),W=require("./reference-C2guRuR0.cjs"),$=require("./useFloatingPosition-DQgw-w_Z.cjs"),be=require("./effects-D98vUn6N.cjs"),F=require("./usePresence-Dm0mls5p.cjs"),Ee=require("./focus-restoration-70WcQRr5.cjs"),ye=require("./Surface-BttJYSDt.cjs"),De=500,J=n.createContext(null);function Ie(s){const{children:p,delay:i=De}=s,c=n.useMemo(()=>({delay:i}),[i]);return m.jsx(J.Provider,{value:c,children:p})}const K=500,G=100;function he(s,p,i,c){p.current=s,W.assignElementReference(i,s),W.assignElementReference(c,s)}function ve(s){return Number.isFinite(s)?Math.max(0,s):K}const Pe=n.forwardRef(function(p,i){const{children:c,className:Q,content:d,contentClassName:X,contentStyle:B,delay:Z,disabled:T=!1,onOpenChange:D,placement:N="top",style:ee}=p;if(d==null||typeof d=="boolean"||typeof d=="string"&&!d.trim())throw new Error("Tooltip content must not be empty");if(c.type===n.Fragment)throw new Error("Tooltip requires a single non-Fragment trigger");const S=`${n.useId()}-tooltip`,k=n.useContext(J),O=c.props,V=W.getElementReference(c),g=n.useRef(null),C=n.useRef(null),A=n.useRef(T),_=n.useRef(!1),I=n.useRef(null),h=n.useRef(null),v=n.useRef(null),P=n.useRef(!1),R=n.useRef(!1),w=n.useRef(!1),u=n.useRef(!1),[b,ne]=n.useState(null),[re,te]=n.useState(null),[L,oe]=n.useState(!1);A.current=T;const x=ve(Z??(k==null?void 0:k.delay)??K),E=F.usePresence(L),z=(b==null?void 0:b.ownerDocument)??(typeof document>"u"?null:document),M=be.useBoundary("Tooltip").boundaryElement,q=F.useOverlayLayer(E.present,M),l=$.useFloatingPosition(E.present,N,b,re,M),se=n.useMemo(()=>[g,C],[]),ce=we.mergeIdentifiers(O["aria-describedby"],S),ie=L&&E.present?ce:O["aria-describedby"],Y=n.useCallback(e=>{he(e,g,V,i),ne(e)},[i,V]),ue=n.useCallback(e=>{C.current=e,e||(u.current=!1),te(e)},[]),t=n.useCallback(()=>{const e=I.current;e&&e.ownerWindow.clearTimeout(e.timerId),I.current=null},[]),o=n.useCallback(()=>{const e=h.current;e&&e.ownerWindow.clearTimeout(e.timerId),h.current=null},[]),y=n.useCallback(()=>{const e=v.current;e&&e.ownerWindow.clearTimeout(e.timerId),v.current=null},[]),r=n.useCallback(e=>{_.current!==e&&(e||(u.current=!1),_.current=e,oe(e),D==null||D(e))},[D]),j=n.useCallback(e=>{var H,U;if(o(),R.current||w.current||u.current)return;if(e===0){r(!1);return}const a=((H=g.current)==null?void 0:H.ownerDocument.defaultView)??((U=C.current)==null?void 0:U.ownerDocument.defaultView);if(!a){r(!1);return}const f=a.setTimeout(()=>{h.current=null,!R.current&&!w.current&&!u.current&&r(!1)},e);h.current={ownerWindow:a,timerId:f}},[o,r]),le=n.useCallback(()=>{var f;if(t(),o(),x===0){r(!0);return}const e=(f=g.current)==null?void 0:f.ownerDocument.defaultView;if(!e)return;const a=e.setTimeout(()=>{I.current=null,A.current||r(!0)},x);I.current={ownerWindow:e,timerId:a}},[o,t,x,r]);function ae(e){if(R.current=!0,o(),P.current||Ee.isElementFocusRestoration(e.currentTarget)){t();return}t(),r(!0)}function fe(e){e.currentTarget.contains(e.relatedTarget)||(R.current=!1,t(),j(0))}function de(){w.current=!0,le()}function me(){w.current=!1,t(),j(G)}function pe(){u.current=!0,o()}function Te(){u.current=!1,j(G)}function ge(){var f;t(),o(),r(!1);const e=(f=g.current)==null?void 0:f.ownerDocument.defaultView;if(!e)return;P.current=!0,y();const a=e.setTimeout(()=>{P.current=!1,v.current=null},0);v.current={ownerWindow:e,timerId:a}}if(F.useDismissableLayer({boundary:M,active:L,boundaries:se,dismissOnPointerDownOutside:!0,layerId:q.id,onEscapeDismiss:()=>r(!1),onPointerDownOutsideDismiss:()=>r(!1),ownerDocument:z}),n.useEffect(()=>{T&&(t(),o(),y(),P.current=!1,R.current=!1,w.current=!1,u.current=!1,_.current&&r(!1))},[o,t,y,T,r]),n.useEffect(()=>{},[b]),n.useEffect(()=>()=>{t(),o(),y()},[o,t,y]),T)return n.cloneElement(c,{ref:Y});const Re=n.cloneElement(c,$.resolveTriggerOverrides(O,{"aria-describedby":ie,className:["nk-tooltip__trigger",Q].filter(Boolean).join(" "),onBlur:fe,onFocus:ae,onMouseEnter:de,onMouseLeave:me,onPointerDown:ge,ref:Y,style:ee}));return m.jsxs(m.Fragment,{children:[Re,E.present&&z?m.jsx(F.Portal,{children:m.jsxs(ye.Surface,{ref:ue,"aria-hidden":L?void 0:!0,className:["nk-tooltip",X].filter(Boolean).join(" "),"data-placement":(l==null?void 0:l.placement)??N,"data-state":E.state==="closing"?"closing":"open",id:S,onMouseEnter:pe,onMouseLeave:Te,role:"tooltip",style:l?{...B,"--nk-tooltip-arrow-offset":`${l.arrowOffset}px`,left:l.left,top:l.top,zIndex:q.zIndex}:{...B,visibility:"hidden",zIndex:q.zIndex},children:[m.jsx("span",{"aria-hidden":"true",className:"nk-tooltip__arrow"}),d]})}):null]})}),Le=Object.assign(Pe,{Provider:Ie});exports.Tooltip2=Le;
|
package/dist/Tooltip-WwAWQ_Kq.js
DELETED
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx as A, jsxs as G, Fragment as De } from "react/jsx-runtime";
|
|
3
|
-
import { useMemo as X, createContext as Ie, forwardRef as he, Fragment as ve, useId as Pe, useContext as Le, useRef as o, useState as N, useCallback as c, useEffect as V, cloneElement as J } from "react";
|
|
4
|
-
import { m as Fe } from "./aria-Bv-xVREf.js";
|
|
5
|
-
import { g as Oe, a as K } from "./reference-CXMr27nM.js";
|
|
6
|
-
import { u as _e, r as Me } from "./useFloatingPosition-MGoyautY.js";
|
|
7
|
-
import { u as xe } from "./effects-DGbA6Q2O.js";
|
|
8
|
-
import { b as We, c as ke, d as Be, P as Ne } from "./usePresence-BTRY1_l-.js";
|
|
9
|
-
import { i as Ve } from "./focus-restoration-BvNZzrQA.js";
|
|
10
|
-
import { S as Ae } from "./Surface-vEFsZC12.js";
|
|
11
|
-
const Ce = 500, Z = Ie(null);
|
|
12
|
-
function je(s) {
|
|
13
|
-
const { children: p, delay: u = Ce } = s, i = X(() => ({
|
|
14
|
-
delay: u
|
|
15
|
-
}), [u]);
|
|
16
|
-
return /* @__PURE__ */ A(Z.Provider, { value: i, children: p });
|
|
17
|
-
}
|
|
18
|
-
const ee = 500, Q = 100;
|
|
19
|
-
function ze(s, p, u, i) {
|
|
20
|
-
p.current = s, K(u, s), K(i, s);
|
|
21
|
-
}
|
|
22
|
-
function Se(s) {
|
|
23
|
-
return Number.isFinite(s) ? Math.max(0, s) : ee;
|
|
24
|
-
}
|
|
25
|
-
const Ye = he(function(p, u) {
|
|
26
|
-
const {
|
|
27
|
-
children: i,
|
|
28
|
-
className: re,
|
|
29
|
-
content: m,
|
|
30
|
-
contentClassName: ne,
|
|
31
|
-
contentStyle: C,
|
|
32
|
-
delay: te,
|
|
33
|
-
disabled: T = !1,
|
|
34
|
-
onOpenChange: D,
|
|
35
|
-
placement: j = "top",
|
|
36
|
-
style: oe
|
|
37
|
-
} = p;
|
|
38
|
-
if (m == null || typeof m == "boolean" || typeof m == "string" && !m.trim())
|
|
39
|
-
throw new Error("Tooltip content must not be empty");
|
|
40
|
-
if (i.type === ve)
|
|
41
|
-
throw new Error("Tooltip requires a single non-Fragment trigger");
|
|
42
|
-
const z = `${Pe()}-tooltip`, F = Le(Z), O = i.props, S = Oe(i), g = o(null), _ = o(null), Y = o(T), M = o(!1), I = o(null), h = o(null), v = o(null), P = o(!1), w = o(!1), y = o(!1), l = o(!1), [b, se] = N(null), [ie, ce] = N(null), [L, ue] = N(!1);
|
|
43
|
-
Y.current = T;
|
|
44
|
-
const x = Se(
|
|
45
|
-
te ?? (F == null ? void 0 : F.delay) ?? ee
|
|
46
|
-
), E = We(L), $ = (b == null ? void 0 : b.ownerDocument) ?? (typeof document > "u" ? null : document), W = xe("Tooltip").boundaryElement, k = ke(E.present, W), a = _e(
|
|
47
|
-
E.present,
|
|
48
|
-
j,
|
|
49
|
-
b,
|
|
50
|
-
ie,
|
|
51
|
-
W
|
|
52
|
-
), le = X(
|
|
53
|
-
() => [g, _],
|
|
54
|
-
[]
|
|
55
|
-
), ae = Fe(
|
|
56
|
-
O["aria-describedby"],
|
|
57
|
-
z
|
|
58
|
-
), fe = L && E.present ? ae : O["aria-describedby"], H = c(
|
|
59
|
-
(e) => {
|
|
60
|
-
ze(
|
|
61
|
-
e,
|
|
62
|
-
g,
|
|
63
|
-
S,
|
|
64
|
-
u
|
|
65
|
-
), se(e);
|
|
66
|
-
},
|
|
67
|
-
[u, S]
|
|
68
|
-
), de = c(
|
|
69
|
-
(e) => {
|
|
70
|
-
_.current = e, e || (l.current = !1), ce(e);
|
|
71
|
-
},
|
|
72
|
-
[]
|
|
73
|
-
), n = c(() => {
|
|
74
|
-
const e = I.current;
|
|
75
|
-
e && e.ownerWindow.clearTimeout(e.timerId), I.current = null;
|
|
76
|
-
}, []), t = c(() => {
|
|
77
|
-
const e = h.current;
|
|
78
|
-
e && e.ownerWindow.clearTimeout(e.timerId), h.current = null;
|
|
79
|
-
}, []), R = c(() => {
|
|
80
|
-
const e = v.current;
|
|
81
|
-
e && e.ownerWindow.clearTimeout(e.timerId), v.current = null;
|
|
82
|
-
}, []), r = c((e) => {
|
|
83
|
-
M.current !== e && (e || (l.current = !1), M.current = e, ue(e), D == null || D(e));
|
|
84
|
-
}, [D]), B = c((e) => {
|
|
85
|
-
var U, q;
|
|
86
|
-
if (t(), w.current || y.current || l.current)
|
|
87
|
-
return;
|
|
88
|
-
if (e === 0) {
|
|
89
|
-
r(!1);
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
const f = ((U = g.current) == null ? void 0 : U.ownerDocument.defaultView) ?? ((q = _.current) == null ? void 0 : q.ownerDocument.defaultView);
|
|
93
|
-
if (!f) {
|
|
94
|
-
r(!1);
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
const d = f.setTimeout(() => {
|
|
98
|
-
h.current = null, !w.current && !y.current && !l.current && r(!1);
|
|
99
|
-
}, e);
|
|
100
|
-
h.current = {
|
|
101
|
-
ownerWindow: f,
|
|
102
|
-
timerId: d
|
|
103
|
-
};
|
|
104
|
-
}, [t, r]), me = c(() => {
|
|
105
|
-
var d;
|
|
106
|
-
if (n(), t(), x === 0) {
|
|
107
|
-
r(!0);
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
const e = (d = g.current) == null ? void 0 : d.ownerDocument.defaultView;
|
|
111
|
-
if (!e) return;
|
|
112
|
-
const f = e.setTimeout(() => {
|
|
113
|
-
I.current = null, Y.current || r(!0);
|
|
114
|
-
}, x);
|
|
115
|
-
I.current = { ownerWindow: e, timerId: f };
|
|
116
|
-
}, [t, n, x, r]);
|
|
117
|
-
function pe(e) {
|
|
118
|
-
if (w.current = !0, t(), P.current || Ve(e.currentTarget)) {
|
|
119
|
-
n();
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
n(), r(!0);
|
|
123
|
-
}
|
|
124
|
-
function Te(e) {
|
|
125
|
-
e.currentTarget.contains(e.relatedTarget) || (w.current = !1, n(), B(0));
|
|
126
|
-
}
|
|
127
|
-
function ge() {
|
|
128
|
-
y.current = !0, me();
|
|
129
|
-
}
|
|
130
|
-
function we() {
|
|
131
|
-
y.current = !1, n(), B(Q);
|
|
132
|
-
}
|
|
133
|
-
function ye() {
|
|
134
|
-
l.current = !0, t();
|
|
135
|
-
}
|
|
136
|
-
function be() {
|
|
137
|
-
l.current = !1, B(Q);
|
|
138
|
-
}
|
|
139
|
-
function Ee() {
|
|
140
|
-
var d;
|
|
141
|
-
n(), t(), r(!1);
|
|
142
|
-
const e = (d = g.current) == null ? void 0 : d.ownerDocument.defaultView;
|
|
143
|
-
if (!e) return;
|
|
144
|
-
P.current = !0, R();
|
|
145
|
-
const f = e.setTimeout(() => {
|
|
146
|
-
P.current = !1, v.current = null;
|
|
147
|
-
}, 0);
|
|
148
|
-
v.current = { ownerWindow: e, timerId: f };
|
|
149
|
-
}
|
|
150
|
-
if (Be({
|
|
151
|
-
boundary: W,
|
|
152
|
-
active: L,
|
|
153
|
-
boundaries: le,
|
|
154
|
-
dismissOnPointerDownOutside: !0,
|
|
155
|
-
layerId: k.id,
|
|
156
|
-
onEscapeDismiss: () => r(!1),
|
|
157
|
-
onPointerDownOutsideDismiss: () => r(!1),
|
|
158
|
-
ownerDocument: $
|
|
159
|
-
}), V(() => {
|
|
160
|
-
T && (n(), t(), R(), P.current = !1, w.current = !1, y.current = !1, l.current = !1, M.current && r(!1));
|
|
161
|
-
}, [
|
|
162
|
-
t,
|
|
163
|
-
n,
|
|
164
|
-
R,
|
|
165
|
-
T,
|
|
166
|
-
r
|
|
167
|
-
]), V(() => {
|
|
168
|
-
}, [b]), V(() => () => {
|
|
169
|
-
n(), t(), R();
|
|
170
|
-
}, [t, n, R]), T)
|
|
171
|
-
return J(
|
|
172
|
-
i,
|
|
173
|
-
{ ref: H }
|
|
174
|
-
);
|
|
175
|
-
const Re = J(
|
|
176
|
-
i,
|
|
177
|
-
Me(O, {
|
|
178
|
-
"aria-describedby": fe,
|
|
179
|
-
className: ["nk-tooltip__trigger", re].filter(Boolean).join(" "),
|
|
180
|
-
onBlur: Te,
|
|
181
|
-
onFocus: pe,
|
|
182
|
-
onMouseEnter: ge,
|
|
183
|
-
onMouseLeave: we,
|
|
184
|
-
onPointerDown: Ee,
|
|
185
|
-
ref: H,
|
|
186
|
-
style: oe
|
|
187
|
-
})
|
|
188
|
-
);
|
|
189
|
-
return /* @__PURE__ */ G(De, { children: [
|
|
190
|
-
Re,
|
|
191
|
-
E.present && $ ? /* @__PURE__ */ A(Ne, { children: /* @__PURE__ */ G(
|
|
192
|
-
Ae,
|
|
193
|
-
{
|
|
194
|
-
ref: de,
|
|
195
|
-
"aria-hidden": L ? void 0 : !0,
|
|
196
|
-
className: ["nk-tooltip", ne].filter(Boolean).join(" "),
|
|
197
|
-
"data-placement": (a == null ? void 0 : a.placement) ?? j,
|
|
198
|
-
"data-state": E.state === "closing" ? "closing" : "open",
|
|
199
|
-
id: z,
|
|
200
|
-
onMouseEnter: ye,
|
|
201
|
-
onMouseLeave: be,
|
|
202
|
-
role: "tooltip",
|
|
203
|
-
style: a ? {
|
|
204
|
-
...C,
|
|
205
|
-
"--nk-tooltip-arrow-offset": `${a.arrowOffset}px`,
|
|
206
|
-
left: a.left,
|
|
207
|
-
top: a.top,
|
|
208
|
-
zIndex: k.zIndex
|
|
209
|
-
} : {
|
|
210
|
-
...C,
|
|
211
|
-
visibility: "hidden",
|
|
212
|
-
zIndex: k.zIndex
|
|
213
|
-
},
|
|
214
|
-
children: [
|
|
215
|
-
/* @__PURE__ */ A("span", { "aria-hidden": "true", className: "nk-tooltip__arrow" }),
|
|
216
|
-
m
|
|
217
|
-
]
|
|
218
|
-
}
|
|
219
|
-
) }) : null
|
|
220
|
-
] });
|
|
221
|
-
}), er = Object.assign(Ye, {
|
|
222
|
-
Provider: je
|
|
223
|
-
});
|
|
224
|
-
export {
|
|
225
|
-
er as T
|
|
226
|
-
};
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { useState as L, useEffect as A } from "react";
|
|
2
|
-
const x = 12, C = {
|
|
3
|
-
bottom: "top",
|
|
4
|
-
left: "right",
|
|
5
|
-
right: "left",
|
|
6
|
-
top: "bottom"
|
|
7
|
-
};
|
|
8
|
-
function u(o, e) {
|
|
9
|
-
const t = Math.min(x, e / 2);
|
|
10
|
-
return Math.min(Math.max(t, o), e - t);
|
|
11
|
-
}
|
|
12
|
-
function E(o) {
|
|
13
|
-
return C[o];
|
|
14
|
-
}
|
|
15
|
-
function T(o, e) {
|
|
16
|
-
return e === "left" || e === "right" ? o.width : o.height;
|
|
17
|
-
}
|
|
18
|
-
function R(o, e, t) {
|
|
19
|
-
const i = Math.max(o.left, 0), n = Math.max(o.top, 0), h = Math.min(o.right, e), s = Math.min(o.bottom, t);
|
|
20
|
-
return h <= i || s <= n ? o : { bottom: s, left: i, right: h, top: n };
|
|
21
|
-
}
|
|
22
|
-
function b(o, e, t, i, n) {
|
|
23
|
-
const h = {
|
|
24
|
-
bottom: n.bottom - t.bottom - e * 2,
|
|
25
|
-
left: t.left - n.left - e * 2,
|
|
26
|
-
right: n.right - t.right - e * 2,
|
|
27
|
-
top: t.top - n.top - e * 2
|
|
28
|
-
}, s = E(o), p = T(i, o), c = h[o] < p && h[s] > h[o] ? s : o;
|
|
29
|
-
let r = t.left + (t.width - i.width) / 2, l = t.top + (t.height - i.height) / 2;
|
|
30
|
-
c === "top" ? l = t.top - i.height - e : c === "bottom" ? l = t.bottom + e : c === "left" ? r = t.left - i.width - e : r = t.right + e;
|
|
31
|
-
const a = n.left + e, M = n.top + e;
|
|
32
|
-
r = Math.min(
|
|
33
|
-
Math.max(a, r),
|
|
34
|
-
Math.max(a, n.right - e - i.width)
|
|
35
|
-
), l = Math.min(
|
|
36
|
-
Math.max(M, l),
|
|
37
|
-
Math.max(M, n.bottom - e - i.height)
|
|
38
|
-
);
|
|
39
|
-
let m;
|
|
40
|
-
return c === "top" || c === "bottom" ? m = u(
|
|
41
|
-
t.left + t.width / 2 - r,
|
|
42
|
-
i.width
|
|
43
|
-
) : m = u(
|
|
44
|
-
t.top + t.height / 2 - l,
|
|
45
|
-
i.height
|
|
46
|
-
), { arrowOffset: m, left: r, placement: c, top: l };
|
|
47
|
-
}
|
|
48
|
-
const g = 8;
|
|
49
|
-
function F(o, e) {
|
|
50
|
-
const t = e.getComputedStyle(o), i = Number.parseFloat(
|
|
51
|
-
t.getPropertyValue("--nk-space-8")
|
|
52
|
-
);
|
|
53
|
-
return Number.isFinite(i) ? i : g;
|
|
54
|
-
}
|
|
55
|
-
function _(o) {
|
|
56
|
-
const { active: e, boundary: t, fit: i, panel: n, trigger: h } = o, [s, p] = L(null);
|
|
57
|
-
return A(() => {
|
|
58
|
-
if (!e || !h || !t) {
|
|
59
|
-
p(null);
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
const w = h, c = t, r = h.ownerDocument.defaultView;
|
|
63
|
-
if (!r) return;
|
|
64
|
-
const l = r;
|
|
65
|
-
let a;
|
|
66
|
-
function M() {
|
|
67
|
-
return a === void 0 && (a = F(
|
|
68
|
-
w,
|
|
69
|
-
l
|
|
70
|
-
)), a;
|
|
71
|
-
}
|
|
72
|
-
function m() {
|
|
73
|
-
const S = c.getBoundingClientRect(), v = i({
|
|
74
|
-
panelBounds: n == null ? void 0 : n.getBoundingClientRect(),
|
|
75
|
-
readSpacing: M,
|
|
76
|
-
triggerBounds: w.getBoundingClientRect(),
|
|
77
|
-
// Fit against the visible part of the boundary so a boundary taller
|
|
78
|
-
// than the viewport cannot place the content below the fold.
|
|
79
|
-
visibleBounds: R(
|
|
80
|
-
S,
|
|
81
|
-
l.innerWidth,
|
|
82
|
-
l.innerHeight
|
|
83
|
-
)
|
|
84
|
-
});
|
|
85
|
-
if (!v) {
|
|
86
|
-
p(null);
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
p({
|
|
90
|
-
...v,
|
|
91
|
-
left: v.left - S.left - c.clientLeft + c.scrollLeft,
|
|
92
|
-
top: v.top - S.top - c.clientTop + c.scrollTop
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
m(), l.addEventListener("scroll", m, !0), l.addEventListener("resize", m);
|
|
96
|
-
const P = l.ResizeObserver, f = P ? new P(m) : null;
|
|
97
|
-
return f == null || f.observe(w), f == null || f.observe(c), n && (f == null || f.observe(n)), () => {
|
|
98
|
-
l.removeEventListener("scroll", m, !0), l.removeEventListener("resize", m), f == null || f.disconnect();
|
|
99
|
-
};
|
|
100
|
-
}, [e, t, i, n, h]), s;
|
|
101
|
-
}
|
|
102
|
-
export {
|
|
103
|
-
b as c,
|
|
104
|
-
_ as u
|
|
105
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const S=require("react"),L=12,C={bottom:"top",left:"right",right:"left",top:"bottom"};function A(o,e){const t=Math.min(L,e/2);return Math.min(Math.max(t,o),e-t)}function E(o){return C[o]}function T(o,e){return e==="left"||e==="right"?o.width:o.height}function g(o,e,t){const i=Math.max(o.left,0),n=Math.max(o.top,0),h=Math.min(o.right,e),s=Math.min(o.bottom,t);return h<=i||s<=n?o:{bottom:s,left:i,right:h,top:n}}function x(o,e,t,i,n){const h={bottom:n.bottom-t.bottom-e*2,left:t.left-n.left-e*2,right:n.right-t.right-e*2,top:t.top-n.top-e*2},s=E(o),p=T(i,o),c=h[o]<p&&h[s]>h[o]?s:o;let r=t.left+(t.width-i.width)/2,l=t.top+(t.height-i.height)/2;c==="top"?l=t.top-i.height-e:c==="bottom"?l=t.bottom+e:c==="left"?r=t.left-i.width-e:r=t.right+e;const a=n.left+e,M=n.top+e;r=Math.min(Math.max(a,r),Math.max(a,n.right-e-i.width)),l=Math.min(Math.max(M,l),Math.max(M,n.bottom-e-i.height));let m;return c==="top"||c==="bottom"?m=A(t.left+t.width/2-r,i.width):m=A(t.top+t.height/2-l,i.height),{arrowOffset:m,left:r,placement:c,top:l}}const F=8;function R(o,e){const t=e.getComputedStyle(o),i=Number.parseFloat(t.getPropertyValue("--nk-space-8"));return Number.isFinite(i)?i:F}function N(o){const{active:e,boundary:t,fit:i,panel:n,trigger:h}=o,[s,p]=S.useState(null);return S.useEffect(()=>{if(!e||!h||!t){p(null);return}const w=h,c=t,r=h.ownerDocument.defaultView;if(!r)return;const l=r;let a;function M(){return a===void 0&&(a=R(w,l)),a}function m(){const v=c.getBoundingClientRect(),u=i({panelBounds:n==null?void 0:n.getBoundingClientRect(),readSpacing:M,triggerBounds:w.getBoundingClientRect(),visibleBounds:g(v,l.innerWidth,l.innerHeight)});if(!u){p(null);return}p({...u,left:u.left-v.left-c.clientLeft+c.scrollLeft,top:u.top-v.top-c.clientTop+c.scrollTop})}m(),l.addEventListener("scroll",m,!0),l.addEventListener("resize",m);const P=l.ResizeObserver,f=P?new P(m):null;return f==null||f.observe(w),f==null||f.observe(c),n&&(f==null||f.observe(n)),()=>{l.removeEventListener("scroll",m,!0),l.removeEventListener("resize",m),f==null||f.disconnect()}},[e,t,i,n,h]),s}exports.calculateFloatingPosition=x;exports.useAnchoredPosition=N;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const m=require("react"),u=require("./useAnchoredPosition-D7GRFzoX.cjs");function v(e){return/^on[A-Z]/.test(e)}function c(e){return typeof e=="function"||e===void 0}function g(e,n){return e?n?function(t){e(t),n(t)}:e:n}function y(e,n){const s={...n};for(const[t,i]of Object.entries(n)){if(!v(t))continue;const o=e[t];!c(i)||!c(o)||(s[t]=g(o,i))}return n.className!==void 0?s.className=[e.className,n.className].filter(Boolean).join(" "):delete s.className,n.style!==void 0?s.style={...e.style,...n.style}:delete s.style,s}function N(e,n,s,t,i){const o=m.useCallback(a=>{const{panelBounds:l,readSpacing:r,triggerBounds:f,visibleBounds:d}=a;return l?u.calculateFloatingPosition(n,r(),f,l,d):null},[n]);return u.useAnchoredPosition({active:e,boundary:i,fit:o,panel:t,trigger:s})}exports.resolveTriggerOverrides=y;exports.useFloatingPosition=N;
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { useCallback as m } from "react";
|
|
2
|
-
import { c as d, u as v } from "./useAnchoredPosition-C0VS7hm6.js";
|
|
3
|
-
function y(e) {
|
|
4
|
-
return /^on[A-Z]/.test(e);
|
|
5
|
-
}
|
|
6
|
-
function a(e) {
|
|
7
|
-
return typeof e == "function" || e === void 0;
|
|
8
|
-
}
|
|
9
|
-
function N(e, n) {
|
|
10
|
-
return e ? n ? function(s) {
|
|
11
|
-
e(s), n(s);
|
|
12
|
-
} : e : n;
|
|
13
|
-
}
|
|
14
|
-
function g(e, n) {
|
|
15
|
-
const t = { ...n };
|
|
16
|
-
for (const [s, o] of Object.entries(n)) {
|
|
17
|
-
if (!y(s)) continue;
|
|
18
|
-
const i = e[s];
|
|
19
|
-
!a(o) || !a(i) || (t[s] = N(
|
|
20
|
-
i,
|
|
21
|
-
o
|
|
22
|
-
));
|
|
23
|
-
}
|
|
24
|
-
return n.className !== void 0 ? t.className = [
|
|
25
|
-
e.className,
|
|
26
|
-
n.className
|
|
27
|
-
].filter(Boolean).join(" ") : delete t.className, n.style !== void 0 ? t.style = {
|
|
28
|
-
...e.style,
|
|
29
|
-
...n.style
|
|
30
|
-
} : delete t.style, t;
|
|
31
|
-
}
|
|
32
|
-
function E(e, n, t, s, o) {
|
|
33
|
-
const i = m(
|
|
34
|
-
(u) => {
|
|
35
|
-
const { panelBounds: l, readSpacing: c, triggerBounds: f, visibleBounds: r } = u;
|
|
36
|
-
return l ? d(
|
|
37
|
-
n,
|
|
38
|
-
c(),
|
|
39
|
-
f,
|
|
40
|
-
l,
|
|
41
|
-
r
|
|
42
|
-
) : null;
|
|
43
|
-
},
|
|
44
|
-
[n]
|
|
45
|
-
);
|
|
46
|
-
return v({
|
|
47
|
-
active: e,
|
|
48
|
-
boundary: o,
|
|
49
|
-
fit: i,
|
|
50
|
-
panel: s,
|
|
51
|
-
trigger: t
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
export {
|
|
55
|
-
g as r,
|
|
56
|
-
E as u
|
|
57
|
-
};
|