neatkit 0.14.1 → 0.15.0

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.
Files changed (48) hide show
  1. package/dist/Boundary.cjs +1 -1
  2. package/dist/Boundary.js +1 -1
  3. package/dist/Markdown.cjs +1 -1
  4. package/dist/Markdown.js +1 -1
  5. package/dist/Popover.cjs +1 -1
  6. package/dist/Popover.js +104 -101
  7. package/dist/Select.cjs +1 -1
  8. package/dist/Select.js +321 -310
  9. package/dist/Sidebar.cjs +1 -1
  10. package/dist/Sidebar.js +3 -3
  11. package/dist/{Table-BiRwd6PX.js → Table-Dvi-4XA7.js} +1 -1
  12. package/dist/{Table-DYO-bPlD.cjs → Table-GlG5aITK.cjs} +1 -1
  13. package/dist/Table.cjs +1 -1
  14. package/dist/Table.js +1 -1
  15. package/dist/Tooltip-CDOwCTig.js +229 -0
  16. package/dist/Tooltip-DrAZSmEv.cjs +1 -0
  17. package/dist/Tooltip.cjs +1 -1
  18. package/dist/Tooltip.js +1 -1
  19. package/dist/components/Popover/Popover.d.ts +17 -0
  20. package/dist/components/Popover/index.d.ts +1 -1
  21. package/dist/components/Portal/hooks/useFloatingPosition.d.ts +3 -1
  22. package/dist/components/Portal/utils/floating-alignment.d.ts +18 -0
  23. package/dist/components/Portal/utils/floating-position.d.ts +3 -1
  24. package/dist/components/Select/Select.d.ts +1 -1
  25. package/dist/components/Select/components/CustomSelect.d.ts +9 -0
  26. package/dist/components/Select/components/SelectListbox.d.ts +3 -0
  27. package/dist/components/Select/hooks/useSelectPosition.d.ts +3 -1
  28. package/dist/components/Select/index.d.ts +1 -1
  29. package/dist/components/Select/utils/listbox-position.d.ts +3 -1
  30. package/dist/components/Tooltip/Tooltip.d.ts +10 -0
  31. package/dist/components/Tooltip/index.d.ts +1 -1
  32. package/dist/index.cjs +1 -1
  33. package/dist/index.js +1 -1
  34. package/dist/style.css +1 -1
  35. package/dist/tokens.d.ts +2 -8
  36. package/dist/{units-CpnLv2H4.cjs → units-BEMW4BNr.cjs} +1 -1
  37. package/dist/{units-Bx_CBIy8.js → units-D4Waz9EO.js} +1 -5
  38. package/dist/useAnchoredPosition-BEzN03Oi.cjs +1 -0
  39. package/dist/useAnchoredPosition-BIXEDNSo.js +119 -0
  40. package/dist/useFloatingPosition-8_GSpDjw.cjs +1 -0
  41. package/dist/useFloatingPosition-Cizey9UN.js +58 -0
  42. package/package.json +1 -1
  43. package/dist/Tooltip-CxcO3Vu-.cjs +0 -1
  44. package/dist/Tooltip-WwAWQ_Kq.js +0 -226
  45. package/dist/useAnchoredPosition-C0VS7hm6.js +0 -105
  46. package/dist/useAnchoredPosition-D7GRFzoX.cjs +0 -1
  47. package/dist/useFloatingPosition-DQgw-w_Z.cjs +0 -1
  48. package/dist/useFloatingPosition-MGoyautY.js +0 -57
@@ -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
- };