neatkit 0.9.0 → 0.11.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.
- package/dist/Boundary.cjs +1 -1
- package/dist/Boundary.js +191 -120
- package/dist/{Button-DU4j_IED.cjs → Button-DtrX4X-s.cjs} +1 -1
- package/dist/{Button-BV5OUXpc.js → Button-LmEHdRkW.js} +2 -2
- package/dist/Button.cjs +1 -1
- package/dist/Button.js +1 -1
- package/dist/Checkbox.cjs +1 -1
- package/dist/Checkbox.js +112 -111
- package/dist/Field.cjs +1 -1
- package/dist/Field.js +57 -62
- package/dist/Icon-CMSHMSDJ.cjs +1 -0
- package/dist/{Icon-CxK1wlGk.js → Icon-NT3kRJYz.js} +275 -94
- package/dist/Icon.cjs +1 -1
- package/dist/Icon.js +1 -1
- package/dist/Input.cjs +1 -1
- package/dist/Input.js +53 -52
- package/dist/Markdown.cjs +1 -1
- package/dist/Markdown.js +1 -1
- package/dist/Modal.cjs +1 -1
- package/dist/Modal.js +58 -57
- package/dist/PinInput.cjs +1 -1
- package/dist/PinInput.js +89 -88
- package/dist/Popover.cjs +1 -1
- package/dist/Popover.js +117 -119
- package/dist/Progress.cjs +1 -0
- package/dist/Progress.js +40 -0
- package/dist/Radio.cjs +1 -1
- package/dist/Radio.js +48 -47
- package/dist/Select.cjs +1 -1
- package/dist/Select.js +364 -359
- package/dist/Sidebar.cjs +1 -1
- package/dist/Sidebar.js +381 -332
- package/dist/Spinner-BE0F4y2S.cjs +1 -0
- package/dist/Spinner-CmxlDlOk.js +23 -0
- package/dist/Spinner.cjs +1 -1
- package/dist/Spinner.js +1 -1
- package/dist/Switch.cjs +1 -1
- package/dist/Switch.js +1 -1
- package/dist/{Table-qetwZpTC.cjs → Table-Bjw9lUKS.cjs} +1 -1
- package/dist/{Table-CADupJEU.js → Table-GeoE4h-u.js} +2 -2
- package/dist/Table.cjs +1 -1
- package/dist/Table.js +1 -1
- package/dist/TextArea.cjs +1 -1
- package/dist/TextArea.js +1 -1
- package/dist/Tooltip-CpyROf6x.js +225 -0
- package/dist/Tooltip-DDPh_YFO.cjs +1 -0
- package/dist/Tooltip.cjs +1 -1
- package/dist/Tooltip.js +1 -1
- package/dist/aria-Bv-xVREf.js +17 -0
- package/dist/aria-DM-xYEHQ.cjs +1 -0
- package/dist/components/Boundary/hooks/useDocumentBackground.d.ts +28 -0
- package/dist/components/Icon/icons/AppleIcon.d.ts +11 -0
- package/dist/components/Icon/icons/BingIcon.d.ts +11 -0
- package/dist/components/Icon/icons/FacebookIcon.d.ts +11 -0
- package/dist/components/Icon/icons/GoogleIcon.d.ts +11 -0
- package/dist/components/Icon/icons/InstagramIcon.d.ts +11 -0
- package/dist/components/Icon/icons/MicrosoftIcon.d.ts +11 -0
- package/dist/components/Icon/icons/TwitterIcon.d.ts +11 -0
- package/dist/components/Icon/utils/registry.d.ts +7 -0
- package/dist/components/PinInput/PinInput.d.ts +1 -1
- package/dist/components/Portal/hooks/useAnchoredPosition.d.ts +59 -0
- package/dist/components/Progress/Progress.d.ts +38 -0
- package/dist/components/Progress/index.d.ts +2 -0
- package/dist/components/Progress/utils/value.d.ts +25 -0
- package/dist/components/Radio/Radio.d.ts +1 -1
- package/dist/components/Select/Select.d.ts +6 -74
- package/dist/components/Select/components/CustomSelect.d.ts +59 -0
- package/dist/components/Select/components/NativeSelect.d.ts +26 -0
- package/dist/components/Select/components/SelectListbox.d.ts +50 -0
- package/dist/components/Select/hooks/useSelectFormReset.d.ts +27 -0
- package/dist/components/Select/hooks/useSelectPosition.d.ts +12 -0
- package/dist/components/Select/hooks/useTypeahead.d.ts +14 -0
- package/dist/components/Select/utils/options.d.ts +38 -0
- package/dist/components/Sidebar/Sidebar.d.ts +30 -24
- package/dist/components/Sidebar/components/SidebarFallbackTrigger.d.ts +32 -0
- package/dist/components/Sidebar/components/SidebarOverlay.d.ts +3 -4
- package/dist/components/Sidebar/components/SidebarPanel.d.ts +3 -3
- package/dist/components/Sidebar/components/SidebarTrigger.d.ts +4 -0
- package/dist/effects-D98vUn6N.cjs +1 -0
- package/dist/effects-DGbA6Q2O.js +18 -0
- package/dist/style.css +1 -1
- package/dist/useAnchoredPosition-C0VS7hm6.js +105 -0
- package/dist/useAnchoredPosition-D7GRFzoX.cjs +1 -0
- package/dist/useFloatingPosition-DQgw-w_Z.cjs +1 -0
- package/dist/useFloatingPosition-MGoyautY.js +57 -0
- package/dist/useFocusTrap-BxPazAL6.js +136 -0
- package/dist/useFocusTrap-CrMcAu8s.cjs +1 -0
- package/dist/{usePresence-CqegYqy4.js → usePresence-BTRY1_l-.js} +47 -56
- package/dist/usePresence-Dm0mls5p.cjs +1 -0
- package/dist/utils/aria.d.ts +4 -5
- package/dist/utils/trigger.d.ts +46 -0
- package/package.json +6 -1
- package/dist/Icon-BIBzgznI.cjs +0 -1
- package/dist/Spinner-BXgw60UC.cjs +0 -1
- package/dist/Spinner-CVYvk6YK.js +0 -25
- package/dist/Tooltip-B2d5ss7S.cjs +0 -1
- package/dist/Tooltip-BK64rkxV.js +0 -231
- package/dist/aria-Bntn6ad_.cjs +0 -1
- package/dist/aria-CeA9QfD1.js +0 -15
- package/dist/effects-D5CWf-Pl.js +0 -8
- package/dist/effects-D85L_7zM.cjs +0 -1
- package/dist/floating-position-DIjh2wnP.cjs +0 -1
- package/dist/floating-position-DvR6e334.js +0 -50
- package/dist/useFloatingPosition-B3ZC-v3v.js +0 -43
- package/dist/useFloatingPosition-GzkP9dCc.cjs +0 -1
- package/dist/useFocusTrap-BrFZdMqQ.cjs +0 -1
- package/dist/useFocusTrap-DhVnlboe.js +0 -136
- package/dist/usePresence-B5RYv4e1.cjs +0 -1
package/dist/PinInput.js
CHANGED
|
@@ -1,36 +1,37 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as G, jsx as
|
|
2
|
+
import { jsxs as G, jsx as V } from "react/jsx-runtime";
|
|
3
3
|
import { useRef as B, useState as H, useCallback as X, useEffect as K, forwardRef as Z } from "react";
|
|
4
|
-
import { r as J, h as Q } from "./aria-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
import { r as J, h as Q } from "./aria-Bv-xVREf.js";
|
|
5
|
+
import { a as W } from "./reference-CXMr27nM.js";
|
|
6
|
+
const Y = 3, ee = 10, q = 4;
|
|
7
|
+
function te(r) {
|
|
8
|
+
return Number.isFinite(r) ? Math.min(
|
|
9
|
+
ee,
|
|
10
|
+
Math.max(Y, Math.trunc(r))
|
|
10
11
|
) : q;
|
|
11
12
|
}
|
|
12
|
-
function S(
|
|
13
|
-
return (s === "numeric" ?
|
|
13
|
+
function S(r, s, l) {
|
|
14
|
+
return (s === "numeric" ? r.replace(/[^0-9]/g, "") : r.replace(/[^0-9a-z]/gi, "").toUpperCase()).slice(0, l);
|
|
14
15
|
}
|
|
15
|
-
function
|
|
16
|
-
s.current =
|
|
16
|
+
function ne(r, s, l) {
|
|
17
|
+
s.current = r, W(l, r);
|
|
17
18
|
}
|
|
18
|
-
function
|
|
19
|
+
function ae(r, s) {
|
|
19
20
|
var c;
|
|
20
|
-
const
|
|
21
|
-
Object.getPrototypeOf(
|
|
21
|
+
const l = (c = Object.getOwnPropertyDescriptor(
|
|
22
|
+
Object.getPrototypeOf(r),
|
|
22
23
|
"value"
|
|
23
24
|
)) == null ? void 0 : c.set;
|
|
24
|
-
|
|
25
|
+
l ? l.call(r, s) : r.value = s;
|
|
25
26
|
}
|
|
26
|
-
function U(
|
|
27
|
-
const c = Math.min(
|
|
28
|
-
|
|
27
|
+
function U(r, s, l) {
|
|
28
|
+
const c = Math.min(l - 1, Math.max(0, s)), x = Math.min(c + 1, r.value.length);
|
|
29
|
+
r.focus(), r.setSelectionRange(c, x);
|
|
29
30
|
}
|
|
30
|
-
function
|
|
31
|
+
function re(r) {
|
|
31
32
|
const {
|
|
32
33
|
defaultValue: s,
|
|
33
|
-
disabled:
|
|
34
|
+
disabled: l,
|
|
34
35
|
forwardedReference: c,
|
|
35
36
|
length: x,
|
|
36
37
|
mode: u,
|
|
@@ -41,78 +42,78 @@ function ae(a) {
|
|
|
41
42
|
onPaste: g,
|
|
42
43
|
onSelect: N,
|
|
43
44
|
readOnly: v,
|
|
44
|
-
value:
|
|
45
|
-
} =
|
|
45
|
+
value: b
|
|
46
|
+
} = r, n = te(x), w = S(
|
|
46
47
|
s,
|
|
47
48
|
u,
|
|
48
49
|
n
|
|
49
|
-
),
|
|
50
|
-
|
|
51
|
-
), [
|
|
52
|
-
f ?
|
|
50
|
+
), y = B(null), [k, R] = H(
|
|
51
|
+
w
|
|
52
|
+
), [D, d] = H(0), f = b !== void 0, i = S(
|
|
53
|
+
f ? b : k,
|
|
53
54
|
u,
|
|
54
55
|
n
|
|
55
|
-
),
|
|
56
|
-
(t) =>
|
|
56
|
+
), C = X(
|
|
57
|
+
(t) => ne(
|
|
57
58
|
t,
|
|
58
|
-
|
|
59
|
+
y,
|
|
59
60
|
c
|
|
60
61
|
),
|
|
61
62
|
[c]
|
|
62
63
|
);
|
|
63
64
|
K(() => {
|
|
64
|
-
!f &&
|
|
65
|
-
}, [f, i,
|
|
66
|
-
var
|
|
65
|
+
!f && k !== i && R(i);
|
|
66
|
+
}, [f, i, k]), K(() => {
|
|
67
|
+
var o;
|
|
67
68
|
if (f) return;
|
|
68
|
-
const t = (
|
|
69
|
+
const t = (o = y.current) == null ? void 0 : o.form;
|
|
69
70
|
if (!t) return;
|
|
70
71
|
const e = t.getRootNode();
|
|
71
|
-
function
|
|
72
|
-
h.target !== t || h.defaultPrevented || (
|
|
72
|
+
function a(h) {
|
|
73
|
+
h.target !== t || h.defaultPrevented || (R(w), d(0));
|
|
73
74
|
}
|
|
74
|
-
return e.addEventListener("reset",
|
|
75
|
-
}, [f,
|
|
76
|
-
function
|
|
75
|
+
return e.addEventListener("reset", a), () => e.removeEventListener("reset", a);
|
|
76
|
+
}, [f, w]);
|
|
77
|
+
function E(t) {
|
|
77
78
|
const e = t.selectionStart ?? i.length;
|
|
78
79
|
return Math.min(n - 1, Math.max(0, e));
|
|
79
80
|
}
|
|
80
81
|
function T(t) {
|
|
81
|
-
const e = t.currentTarget,
|
|
82
|
-
e.value.slice(0,
|
|
82
|
+
const e = t.currentTarget, a = e.selectionStart ?? e.value.length, o = S(e.value, u, n), h = S(
|
|
83
|
+
e.value.slice(0, a),
|
|
83
84
|
u,
|
|
84
85
|
n
|
|
85
86
|
).length;
|
|
86
|
-
e.value =
|
|
87
|
+
e.value = o, f || R(o), M == null || M(t), o.length === n && o !== i && (P == null || P(o));
|
|
87
88
|
const m = Math.min(n - 1, h);
|
|
88
89
|
d(m), e.setSelectionRange(
|
|
89
90
|
m,
|
|
90
|
-
Math.min(m + 1,
|
|
91
|
+
Math.min(m + 1, o.length)
|
|
91
92
|
);
|
|
92
93
|
}
|
|
93
94
|
function A(t) {
|
|
94
|
-
if (g == null || g(t), t.defaultPrevented ||
|
|
95
|
+
if (g == null || g(t), t.defaultPrevented || l || v) return;
|
|
95
96
|
const e = S(
|
|
96
97
|
t.clipboardData.getData("text"),
|
|
97
98
|
u,
|
|
98
99
|
n
|
|
99
100
|
);
|
|
100
101
|
if (t.preventDefault(), e.length === 0) return;
|
|
101
|
-
const
|
|
102
|
-
i.slice(0,
|
|
102
|
+
const a = t.currentTarget, o = a.selectionStart ?? i.length, h = a.selectionEnd ?? o, m = e.length === n ? e : S(
|
|
103
|
+
i.slice(0, o) + e + i.slice(h),
|
|
103
104
|
u,
|
|
104
105
|
n
|
|
105
|
-
),
|
|
106
|
-
|
|
106
|
+
), L = e.length === n ? n : Math.min(n, o + e.length);
|
|
107
|
+
ae(a, m), a.setSelectionRange(L, L), a.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
107
108
|
}
|
|
108
109
|
function z(t) {
|
|
109
110
|
if (p == null || p(t), t.defaultPrevented || t.key !== "ArrowLeft" && t.key !== "ArrowRight") return;
|
|
110
111
|
t.preventDefault();
|
|
111
|
-
const e = t.key === "ArrowLeft" ? -1 : 1,
|
|
112
|
+
const e = t.key === "ArrowLeft" ? -1 : 1, a = Math.min(
|
|
112
113
|
n - 1,
|
|
113
|
-
Math.max(0,
|
|
114
|
+
Math.max(0, E(t.currentTarget) + e)
|
|
114
115
|
);
|
|
115
|
-
d(
|
|
116
|
+
d(a), U(t.currentTarget, a, n);
|
|
116
117
|
}
|
|
117
118
|
function F(t) {
|
|
118
119
|
_ == null || _(t);
|
|
@@ -120,27 +121,27 @@ function ae(a) {
|
|
|
120
121
|
d(e), U(t.currentTarget, e, n);
|
|
121
122
|
}
|
|
122
123
|
function O(t) {
|
|
123
|
-
N == null || N(t), d(
|
|
124
|
+
N == null || N(t), d(E(t.currentTarget));
|
|
124
125
|
}
|
|
125
126
|
function j(t, e) {
|
|
126
|
-
if (t.preventDefault(),
|
|
127
|
-
const
|
|
128
|
-
|
|
127
|
+
if (t.preventDefault(), l) return;
|
|
128
|
+
const a = y.current;
|
|
129
|
+
a && (d(e), U(a, e, n));
|
|
129
130
|
}
|
|
130
131
|
return {
|
|
131
|
-
activeIndex:
|
|
132
|
+
activeIndex: D,
|
|
132
133
|
handleChange: T,
|
|
133
134
|
handleFocus: F,
|
|
134
135
|
handleKeyDown: z,
|
|
135
136
|
handlePaste: A,
|
|
136
137
|
handleSelect: O,
|
|
137
138
|
handleSlotPointerDown: j,
|
|
138
|
-
inputCallbackReference:
|
|
139
|
+
inputCallbackReference: C,
|
|
139
140
|
length: n,
|
|
140
141
|
renderedValue: i
|
|
141
142
|
};
|
|
142
143
|
}
|
|
143
|
-
const
|
|
144
|
+
const ue = Z(function(s, l) {
|
|
144
145
|
const {
|
|
145
146
|
"aria-invalid": c,
|
|
146
147
|
autoCapitalize: x,
|
|
@@ -152,19 +153,19 @@ const se = Z(function(s, r) {
|
|
|
152
153
|
invalid: g = !1,
|
|
153
154
|
length: N = q,
|
|
154
155
|
mode: v = "numeric",
|
|
155
|
-
onChange:
|
|
156
|
+
onChange: b,
|
|
156
157
|
onComplete: n,
|
|
157
|
-
onFocus:
|
|
158
|
-
onKeyDown:
|
|
159
|
-
onPaste:
|
|
160
|
-
onSelect:
|
|
161
|
-
readOnly:
|
|
158
|
+
onFocus: w,
|
|
159
|
+
onKeyDown: y,
|
|
160
|
+
onPaste: k,
|
|
161
|
+
onSelect: R,
|
|
162
|
+
readOnly: D = !1,
|
|
162
163
|
style: d,
|
|
163
164
|
value: f,
|
|
164
165
|
wrap: i = !1,
|
|
165
|
-
...
|
|
166
|
+
...C
|
|
166
167
|
} = s, {
|
|
167
|
-
activeIndex:
|
|
168
|
+
activeIndex: E,
|
|
168
169
|
handleChange: T,
|
|
169
170
|
handleFocus: A,
|
|
170
171
|
handleKeyDown: z,
|
|
@@ -173,22 +174,22 @@ const se = Z(function(s, r) {
|
|
|
173
174
|
handleSlotPointerDown: j,
|
|
174
175
|
inputCallbackReference: t,
|
|
175
176
|
length: e,
|
|
176
|
-
renderedValue:
|
|
177
|
-
} =
|
|
177
|
+
renderedValue: a
|
|
178
|
+
} = re({
|
|
178
179
|
defaultValue: _,
|
|
179
180
|
disabled: p,
|
|
180
|
-
forwardedReference:
|
|
181
|
+
forwardedReference: l,
|
|
181
182
|
length: N,
|
|
182
183
|
mode: v,
|
|
183
|
-
onChange:
|
|
184
|
+
onChange: b,
|
|
184
185
|
onComplete: n,
|
|
185
|
-
onFocus:
|
|
186
|
-
onKeyDown:
|
|
187
|
-
onPaste:
|
|
188
|
-
onSelect:
|
|
189
|
-
readOnly:
|
|
186
|
+
onFocus: w,
|
|
187
|
+
onKeyDown: y,
|
|
188
|
+
onPaste: k,
|
|
189
|
+
onSelect: R,
|
|
190
|
+
readOnly: D,
|
|
190
191
|
value: f
|
|
191
|
-
}),
|
|
192
|
+
}), o = g || Q(c), h = !i && e >= 6 && e % 2 === 0, m = e / 2, L = {
|
|
192
193
|
...d,
|
|
193
194
|
"--nk-pin-input-columns": Math.ceil(e / 2)
|
|
194
195
|
};
|
|
@@ -197,15 +198,15 @@ const se = Z(function(s, r) {
|
|
|
197
198
|
{
|
|
198
199
|
className: ["nk-pin-input", M].filter(Boolean).join(" "),
|
|
199
200
|
"data-disabled": p || void 0,
|
|
200
|
-
"data-invalid":
|
|
201
|
-
"data-read-only":
|
|
201
|
+
"data-invalid": o || void 0,
|
|
202
|
+
"data-read-only": D || void 0,
|
|
202
203
|
"data-wrap": i || void 0,
|
|
203
|
-
style:
|
|
204
|
+
style: L,
|
|
204
205
|
children: [
|
|
205
|
-
/* @__PURE__ */
|
|
206
|
+
/* @__PURE__ */ V(
|
|
206
207
|
"input",
|
|
207
208
|
{
|
|
208
|
-
...
|
|
209
|
+
...C,
|
|
209
210
|
ref: t,
|
|
210
211
|
"aria-invalid": J(g, c),
|
|
211
212
|
autoCapitalize: x ?? (v === "alphanumeric" ? "characters" : "off"),
|
|
@@ -221,21 +222,21 @@ const se = Z(function(s, r) {
|
|
|
221
222
|
onPaste: F,
|
|
222
223
|
onSelect: O,
|
|
223
224
|
pattern: v === "numeric" ? `[0-9]{${e}}` : `[0-9A-Za-z]{${e}}`,
|
|
224
|
-
readOnly:
|
|
225
|
+
readOnly: D,
|
|
225
226
|
spellCheck: !1,
|
|
226
227
|
type: "text",
|
|
227
|
-
value:
|
|
228
|
+
value: a
|
|
228
229
|
}
|
|
229
230
|
),
|
|
230
|
-
/* @__PURE__ */
|
|
231
|
-
h && I === m ? /* @__PURE__ */
|
|
232
|
-
/* @__PURE__ */
|
|
231
|
+
/* @__PURE__ */ V("span", { "aria-hidden": "true", className: "nk-pin-input__slots", children: Array.from({ length: e }, (oe, I) => /* @__PURE__ */ G("span", { className: "nk-pin-input__slot-group", children: [
|
|
232
|
+
h && I === m ? /* @__PURE__ */ V("span", { className: "nk-pin-input__separator", children: "-" }) : null,
|
|
233
|
+
/* @__PURE__ */ V(
|
|
233
234
|
"span",
|
|
234
235
|
{
|
|
235
236
|
className: "nk-pin-input__slot",
|
|
236
|
-
"data-active":
|
|
237
|
+
"data-active": E === I || void 0,
|
|
237
238
|
onPointerDown: ($) => j($, I),
|
|
238
|
-
children: P &&
|
|
239
|
+
children: P && a[I] ? /* @__PURE__ */ V("span", { className: "nk-pin-input__censor" }) : a[I] ?? ""
|
|
239
240
|
}
|
|
240
241
|
)
|
|
241
242
|
] }, I)) })
|
|
@@ -244,5 +245,5 @@ const se = Z(function(s, r) {
|
|
|
244
245
|
);
|
|
245
246
|
});
|
|
246
247
|
export {
|
|
247
|
-
|
|
248
|
+
ue as default
|
|
248
249
|
};
|
package/dist/Popover.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("react/jsx-runtime"),
|
|
1
|
+
"use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("react/jsx-runtime"),r=require("react"),we=require("./aria-DM-xYEHQ.cjs"),ne=require("./effects-D98vUn6N.cjs"),B=require("./reference-C2guRuR0.cjs"),te=require("./useFloatingPosition-DQgw-w_Z.cjs"),h=require("./usePresence-Dm0mls5p.cjs"),je=require("./useFocusTrap-CrMcAu8s.cjs"),De=require("./Surface-BttJYSDt.cjs");function Le(n){const{inert:i,panelElement:c}=n;return ne.useIsomorphicLayoutEffect(()=>{c&&(c.inert=i)},[i,c]),null}function Ne(n,i,c){i.current=n,B.assignElementReference(c,n)}function _e(n,i,c){i.current=n,B.assignElementReference(c,n)}function Me(n){const i=n.tagName.toLowerCase();return n.getAttribute("role")==="button"&&i!=="button"?!1:["button","input","select","summary","textarea"].includes(i)?!0:i==="a"&&n.hasAttribute("href")}function Be(n){return n==="grid"||n==="listbox"||n==="menu"||n==="tree"?n:"dialog"}const ze=r.forwardRef(function(i,c){const{"aria-label":z,"aria-labelledby":se,autoFocus:w=!0,children:oe,className:ae,closeOnEscape:ie=!0,closeOnOutsideInteraction:ce=!0,defaultOpen:ue=!1,disabled:x=!1,initialFocusReference:E,onEscapeKeyDown:le,onOpenChange:k,onPointerDownOutside:I,open:A,placement:H="bottom",restoreFocus:j=!0,role:K="dialog",style:V,tabIndex:de,trapFocus:b=!1,trigger:d,...fe}=i;if(d.type===r.Fragment)throw new Error("Popover requires a single non-Fragment trigger");const $=r.useId(),pe=r.useContext(h.FocusScopeContext),U=`${$}-popover`,o=d.props,G=B.getElementReference(d),J=o.id??`${$}-trigger`,v=x||o.disabled===!0||o["aria-disabled"]===!0||o["aria-disabled"]==="true",R=A!==void 0,[ge,me]=r.useState(ue),t=R?A:ge,C=h.usePresence(t),Q=r.useRef(null),W=r.useRef(null),D=r.useRef("programmatic"),L=r.useRef(null),X=r.useRef(t),T=r.useRef(null),[be,ve]=r.useReducer(e=>e+1,0),[u,ye]=r.useState(null),[f,Pe]=r.useState(null),a=(u==null?void 0:u.ownerDocument)??(typeof document>"u"?null:document),O=ne.useBoundary("Popover").boundaryElement,S=h.useOverlayLayer(C.present,O),he=r.useMemo(()=>[Q,W],[]),p=te.useFloatingPosition(C.present,H,u,f,O),Ee=r.useCallback(e=>{_e(e,Q,G),ye(e)},[G]),Re=r.useCallback(e=>{Ne(e,W,c),Pe(e)},[c]),g=r.useCallback((e,s)=>{t!==e&&(R?(L.current={open:e,reason:s},ve()):(D.current=s,me(e)),k==null||k(e,s))},[R,k,t]),Te=r.useCallback(()=>{g(!1,"escape")},[g]),xe=r.useCallback(()=>{g(!1,"outside")},[g]),ke=r.useCallback(e=>{var m;if(I==null||I(e),e.defaultPrevented)return;const s=(m=a==null?void 0:a.defaultView)==null?void 0:m.HTMLElement;s?T.current=e.composedPath().find(P=>P instanceof s&&P.tabIndex>=0)??e.target:T.current=e.target},[I,a]);h.useDismissableLayer({boundary:O,active:t,boundaries:he,dismissOnEscape:ie,dismissOnPointerDownOutside:ce,layerId:S.id,onEscapeDismiss:Te,onEscapeKeyDown:le,onPointerDownOutside:ke,onPointerDownOutsideDismiss:xe,ownerDocument:a});const Ie=je.useFocusTrap({boundary:O,active:t&&b,autoFocus:w,container:f,initialFocusReference:E,layerId:S.id,restoreFocus:j});r.useEffect(()=>{if(!t||b||!w||!f)return;let e=!0;return Promise.resolve().then(()=>{if(!e)return;const s=E==null?void 0:E.current;(s&&f.contains(s)?s:f).focus({preventScroll:!0})}),()=>{e=!1}},[w,E,t,f,b]),r.useEffect(()=>{var re;const e=X.current;X.current=t;const s=L.current;let m=D.current;if(R&&(m="programmatic",e!==t&&(s==null?void 0:s.open)===t&&(m=s.reason)),L.current=null,t){D.current="programmatic",T.current=null;return}const P=a==null?void 0:a.activeElement,_=T.current,M=(re=a==null?void 0:a.defaultView)==null?void 0:re.HTMLElement,Fe=m==="outside"&&M&&_ instanceof M&&P instanceof M&&(_===P||_.contains(P));e&&!b&&j&&!Fe&&(u==null||u.focus({preventScroll:!0})),T.current=null},[be,R,t,a,j,b,u]),r.useEffect(()=>{x&&t&&g(!1,"programmatic")},[x,t,g]);function Ce(e){if(v){e.preventDefault(),e.stopPropagation();return}e.defaultPrevented||g(!t,"trigger")}function Oe(e){e.defaultPrevented||v||Me(e.currentTarget)||e.key!=="Enter"&&e.key!==" "||(e.preventDefault(),e.currentTarget.click())}if(x)return d;const N=typeof d.type=="string",y=N?d.type:null,Y=y==="a"&&typeof o.href=="string",Z=N&&!(y==="button"||y==="input"||y==="select"||y==="summary"||y==="textarea"||Y),ee=Y&&v;let q=o.role;q===void 0&&(ee?q="link":Z&&(q="button"));let F=o.tabIndex;F===void 0&&Z&&(F=0),v&&(F=-1);const Se=v?{...o,onClick:void 0}:o,qe=r.cloneElement(d,te.resolveTriggerOverrides(Se,{"aria-controls":t?we.mergeIdentifiers(o["aria-controls"],U):o["aria-controls"],"aria-expanded":t,"aria-haspopup":o["aria-haspopup"]??Be(K),"aria-disabled":v?!0:o["aria-disabled"],className:"nk-popover__trigger",href:ee?void 0:o.href,id:J,onClick:Ce,onKeyDown:N?Oe:void 0,ref:Ee,role:q,tabIndex:F}));return l.jsxs(l.Fragment,{children:[qe,l.jsx(h.FocusScopeContext.Provider,{value:t&&b?Ie:pe,children:C.present&&a?l.jsx(h.Portal,{children:l.jsxs(De.Surface,{...fe,ref:Re,"aria-hidden":t?void 0:!0,"aria-label":t?z:void 0,"aria-labelledby":t?se??(z===void 0?J:void 0):void 0,className:["nk-popover",ae].filter(Boolean).join(" "),"data-placement":(p==null?void 0:p.placement)??H,"data-state":C.state==="closing"?"closing":"open",id:U,role:t?K:void 0,style:p?{...V,"--nk-popover-arrow-offset":`${p.arrowOffset}px`,left:p.left,top:p.top,zIndex:S.zIndex}:{...V,visibility:"hidden",zIndex:S.zIndex},tabIndex:de??-1,children:[l.jsx(Le,{inert:!t,panelElement:f}),l.jsx("span",{"aria-hidden":"true",className:"nk-popover__arrow"}),l.jsx("div",{className:"nk-popover__content",children:oe})]})}):null})]})});exports.default=ze;
|