neatkit 0.9.0 → 0.10.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 (67) hide show
  1. package/dist/{Button-DU4j_IED.cjs → Button-CVe9T_Zw.cjs} +1 -1
  2. package/dist/{Button-BV5OUXpc.js → Button-D6rXvcqq.js} +1 -1
  3. package/dist/Button.cjs +1 -1
  4. package/dist/Button.js +1 -1
  5. package/dist/Checkbox.cjs +1 -1
  6. package/dist/Checkbox.js +111 -110
  7. package/dist/Input.cjs +1 -1
  8. package/dist/Input.js +52 -51
  9. package/dist/Markdown.cjs +1 -1
  10. package/dist/Markdown.js +1 -1
  11. package/dist/Modal.cjs +1 -1
  12. package/dist/Modal.js +57 -56
  13. package/dist/PinInput.cjs +1 -1
  14. package/dist/PinInput.js +88 -87
  15. package/dist/Popover.cjs +1 -1
  16. package/dist/Popover.js +2 -2
  17. package/dist/Progress.cjs +1 -0
  18. package/dist/Progress.js +40 -0
  19. package/dist/Radio.cjs +1 -1
  20. package/dist/Radio.js +48 -47
  21. package/dist/Select.cjs +1 -1
  22. package/dist/Select.js +363 -359
  23. package/dist/Sidebar.cjs +1 -1
  24. package/dist/Sidebar.js +44 -44
  25. package/dist/Spinner-BE0F4y2S.cjs +1 -0
  26. package/dist/Spinner-CmxlDlOk.js +23 -0
  27. package/dist/Spinner.cjs +1 -1
  28. package/dist/Spinner.js +1 -1
  29. package/dist/{Table-qetwZpTC.cjs → Table-BqWBgMTU.cjs} +1 -1
  30. package/dist/{Table-CADupJEU.js → Table-DutHfiXR.js} +2 -2
  31. package/dist/Table.cjs +1 -1
  32. package/dist/Table.js +1 -1
  33. package/dist/{Tooltip-B2d5ss7S.cjs → Tooltip-CCuE-hfp.cjs} +1 -1
  34. package/dist/{Tooltip-BK64rkxV.js → Tooltip-CeyRKNv4.js} +1 -1
  35. package/dist/Tooltip.cjs +1 -1
  36. package/dist/Tooltip.js +1 -1
  37. package/dist/components/Portal/hooks/useAnchoredPosition.d.ts +59 -0
  38. package/dist/components/Progress/Progress.d.ts +38 -0
  39. package/dist/components/Progress/index.d.ts +2 -0
  40. package/dist/components/Progress/utils/value.d.ts +25 -0
  41. package/dist/components/Select/Select.d.ts +6 -74
  42. package/dist/components/Select/components/CustomSelect.d.ts +59 -0
  43. package/dist/components/Select/components/NativeSelect.d.ts +26 -0
  44. package/dist/components/Select/components/SelectListbox.d.ts +50 -0
  45. package/dist/components/Select/hooks/useSelectFormReset.d.ts +27 -0
  46. package/dist/components/Select/hooks/useSelectPosition.d.ts +12 -0
  47. package/dist/components/Select/hooks/useTypeahead.d.ts +14 -0
  48. package/dist/components/Select/utils/options.d.ts +38 -0
  49. package/dist/components/Sidebar/Sidebar.d.ts +30 -24
  50. package/dist/components/Sidebar/components/SidebarOverlay.d.ts +3 -4
  51. package/dist/components/Sidebar/components/SidebarPanel.d.ts +2 -2
  52. package/dist/style.css +1 -1
  53. package/dist/useAnchoredPosition-C0VS7hm6.js +105 -0
  54. package/dist/useAnchoredPosition-D7GRFzoX.cjs +1 -0
  55. package/dist/useFloatingPosition-Dq8xpr3E.js +27 -0
  56. package/dist/useFloatingPosition-g5kXywoB.cjs +1 -0
  57. package/dist/useFocusTrap-C0IcCdNf.js +136 -0
  58. package/dist/useFocusTrap-gAK_402D.cjs +1 -0
  59. package/package.json +6 -1
  60. package/dist/Spinner-BXgw60UC.cjs +0 -1
  61. package/dist/Spinner-CVYvk6YK.js +0 -25
  62. package/dist/floating-position-DIjh2wnP.cjs +0 -1
  63. package/dist/floating-position-DvR6e334.js +0 -50
  64. package/dist/useFloatingPosition-B3ZC-v3v.js +0 -43
  65. package/dist/useFloatingPosition-GzkP9dCc.cjs +0 -1
  66. package/dist/useFocusTrap-BrFZdMqQ.cjs +0 -1
  67. package/dist/useFocusTrap-DhVnlboe.js +0 -136
package/dist/Select.js CHANGED
@@ -1,219 +1,196 @@
1
1
  "use client";
2
- import { jsx as h, jsxs as S } from "react/jsx-runtime";
3
- import { forwardRef as Oe, useId as xe, useRef as K, useState as j, useCallback as R, useEffect as U, useMemo as Re } from "react";
4
- import { h as ue, r as fe } from "./aria-CeA9QfD1.js";
5
- import { I as X } from "./Icon-CxK1wlGk.js";
6
- import { b as oe, c as Se, P as Ne, d as Pe, e as Te } from "./usePresence-CqegYqy4.js";
7
- import { g as He } from "./floating-position-DvR6e334.js";
8
- const G = 8, ee = 4, Ce = 160, Me = 72;
9
- function Ve(n, t, l) {
10
- const a = l.bottom - n.bottom - ee - G, u = n.top - l.top - ee - G, c = a < Ce && u > a, o = Math.max(
11
- Me,
12
- c ? u : a
13
- ), f = Math.max(
14
- n.width,
15
- (t == null ? void 0 : t.width) ?? n.width
16
- ), r = l.left + G, y = Math.min(
17
- Math.max(r, n.left),
2
+ import { jsx as f, jsxs as R } from "react/jsx-runtime";
3
+ import { useRef as T, useEffect as Y, useCallback as I, useMemo as ke, useId as Ee, useState as U, forwardRef as xe } from "react";
4
+ import { b as B, d as De, e as Oe, c as Re, P as Se } from "./usePresence-CqegYqy4.js";
5
+ import { h as le, r as ie } from "./aria-CeA9QfD1.js";
6
+ import { a as Le } from "./reference-CXMr27nM.js";
7
+ import { I as $ } from "./Icon-CxK1wlGk.js";
8
+ import { u as Ne } from "./useAnchoredPosition-C0VS7hm6.js";
9
+ function Pe(t) {
10
+ const { form: n, onReset: a, resetValue: l, triggerReference: o } = t, i = T(null);
11
+ return Y(() => {
12
+ var c;
13
+ const s = (c = o.current) == null ? void 0 : c.form;
14
+ if (!s) return;
15
+ function m() {
16
+ const v = i.current;
17
+ if (v) {
18
+ const b = Array.from(v.options), w = b.find(
19
+ (y) => y.value === l
20
+ ) ?? b[0];
21
+ b.forEach((y) => {
22
+ y.defaultSelected = y === w;
23
+ });
24
+ }
25
+ a();
26
+ }
27
+ return s.addEventListener("reset", m), () => s.removeEventListener("reset", m);
28
+ }, [n, a, l, o]), i;
29
+ }
30
+ const W = 8, X = 4, Te = 160, Ae = 72;
31
+ function He(t, n, a) {
32
+ const l = a.bottom - t.bottom - X - W, o = t.top - a.top - X - W, i = l < Te && o > l, s = Math.max(
33
+ Ae,
34
+ i ? o : l
35
+ ), m = Math.max(
36
+ t.width,
37
+ (n == null ? void 0 : n.width) ?? t.width
38
+ ), c = a.left + W, v = Math.min(
39
+ Math.max(c, t.left),
18
40
  Math.max(
19
- r,
20
- l.right - G - f
41
+ c,
42
+ a.right - W - m
21
43
  )
22
- ), s = c ? Math.max(
23
- l.top + G,
24
- n.top - ee - Math.min((t == null ? void 0 : t.height) ?? o, o)
25
- ) : n.bottom + ee;
44
+ ), b = i ? Math.max(
45
+ a.top + W,
46
+ t.top - X - Math.min((n == null ? void 0 : n.height) ?? s, s)
47
+ ) : t.bottom + X;
26
48
  return {
27
- left: y,
28
- maxHeight: o,
29
- minWidth: n.width,
30
- top: s
49
+ left: v,
50
+ maxHeight: s,
51
+ minWidth: t.width,
52
+ top: b
31
53
  };
32
54
  }
33
- function ae(n, t, l) {
34
- if (n.length === 0) return -1;
35
- for (let a = 1; a <= n.length; a += 1) {
36
- const u = (t + l * a + n.length) % n.length;
37
- if (!n[u].disabled) return u;
55
+ function Me(t, n, a, l) {
56
+ const o = I(
57
+ (i) => {
58
+ const { panelBounds: s, triggerBounds: m, visibleBounds: c } = i;
59
+ return He(
60
+ m,
61
+ s,
62
+ c
63
+ );
64
+ },
65
+ []
66
+ );
67
+ return Ne({
68
+ active: t,
69
+ boundary: l,
70
+ fit: o,
71
+ panel: a,
72
+ trigger: n
73
+ });
74
+ }
75
+ const Ve = 500;
76
+ function Ce(t) {
77
+ const n = T(""), a = T(null), l = T(null);
78
+ return Y(() => () => {
79
+ const o = l.current;
80
+ o && a.current !== null && o.clearTimeout(a.current);
81
+ }, []), I((o) => {
82
+ var c;
83
+ const i = (c = t.current) == null ? void 0 : c.ownerDocument.defaultView;
84
+ if (!i) return null;
85
+ l.current = i;
86
+ const s = n.current + o, m = Array.from(s).every((v) => v === o);
87
+ return n.current = m ? o : s, a.current !== null && i.clearTimeout(a.current), a.current = i.setTimeout(() => {
88
+ n.current = "", a.current = null;
89
+ }, Ve), n.current;
90
+ }, [t]);
91
+ }
92
+ function Z(t, n, a) {
93
+ if (t.length === 0) return -1;
94
+ for (let l = 1; l <= t.length; l += 1) {
95
+ const o = (n + a * l + t.length) % t.length;
96
+ if (!t[o].disabled) return o;
38
97
  }
39
98
  return -1;
40
99
  }
41
- function Ae(n, t, l) {
42
- for (let a = 1; a <= n.length; a += 1) {
43
- const u = (l + a + n.length) % n.length, c = n[u];
44
- if (!c.disabled && c.label.toLocaleLowerCase().startsWith(t))
45
- return u;
100
+ function We(t, n, a) {
101
+ for (let l = 1; l <= t.length; l += 1) {
102
+ const o = (a + l + t.length) % t.length, i = t[o];
103
+ if (!i.disabled && i.label.toLocaleLowerCase().startsWith(n))
104
+ return o;
46
105
  }
47
106
  return -1;
48
107
  }
49
- function We(n) {
50
- const t = /* @__PURE__ */ new Set();
51
- n.forEach((l) => {
52
- if (t.has(l.value))
108
+ function $e(t) {
109
+ const n = /* @__PURE__ */ new Set();
110
+ t.forEach((a) => {
111
+ if (n.has(a.value))
53
112
  throw new Error("Select option values must be unique");
54
- t.add(l.value);
113
+ n.add(a.value);
55
114
  });
56
115
  }
57
- function $e(n, t, l) {
58
- t.current = n, typeof l == "function" ? l(n) : l && (l.current = n);
59
- }
60
- function Ge(n) {
61
- const {
62
- "aria-invalid": t,
63
- children: l,
64
- className: a,
65
- defaultValue: u,
66
- disabled: c = !1,
67
- forwardedReference: o,
68
- invalid: f = !1,
69
- placeholder: r,
70
- style: y,
71
- value: s,
72
- ...k
73
- } = n, g = fe(f, t), I = f || ue(t);
74
- return /* @__PURE__ */ S(
75
- "span",
76
- {
77
- className: ["nk-select", a].filter(Boolean).join(" "),
78
- "data-disabled": c || void 0,
79
- "data-invalid": I || void 0,
80
- "data-mode": "native",
81
- style: y,
82
- children: [
83
- /* @__PURE__ */ S(
84
- "select",
85
- {
86
- ...k,
87
- ref: o,
88
- "aria-invalid": g,
89
- className: "nk-select__control",
90
- defaultValue: s === void 0 ? u ?? (r !== void 0 ? "" : void 0) : void 0,
91
- disabled: c,
92
- value: s,
93
- children: [
94
- r !== void 0 ? /* @__PURE__ */ h("option", { disabled: !0, value: "", children: r }) : null,
95
- l
96
- ]
97
- }
98
- ),
99
- /* @__PURE__ */ h(X, { className: "nk-select__icon", type: "chevron-down" })
100
- ]
101
- }
102
- );
103
- }
104
- function Ke(n, t, l, a) {
105
- const [u, c] = j(null);
106
- return U(() => {
107
- if (!n || !t || !a) {
108
- c(null);
109
- return;
110
- }
111
- const o = t.ownerDocument.defaultView;
112
- if (!o) return;
113
- const f = o;
114
- function r() {
115
- const k = t == null ? void 0 : t.getBoundingClientRect(), g = a == null ? void 0 : a.getBoundingClientRect();
116
- if (!k || !g || !a) return;
117
- const I = Ve(
118
- k,
119
- l == null ? void 0 : l.getBoundingClientRect(),
120
- He(
121
- g,
122
- f.innerWidth,
123
- f.innerHeight
124
- )
125
- );
126
- c({
127
- ...I,
128
- left: I.left - g.left - a.clientLeft + a.scrollLeft,
129
- top: I.top - g.top - a.clientTop + a.scrollTop
130
- });
131
- }
132
- r(), f.addEventListener("scroll", r, !0), f.addEventListener("resize", r);
133
- const y = f.ResizeObserver, s = y ? new y(r) : null;
134
- return s == null || s.observe(t), s == null || s.observe(a), l && (s == null || s.observe(l)), () => {
135
- f.removeEventListener("scroll", r, !0), f.removeEventListener("resize", r), s == null || s.disconnect();
136
- };
137
- }, [n, a, l, t]), u;
138
- }
139
- function je(n) {
116
+ function Ge(t) {
140
117
  const {
141
- active: t,
142
- closeOnEscape: l,
143
- closeOnOutsideInteraction: a,
144
- highlightedIndex: u,
145
- id: c,
146
- listboxReference: o,
147
- onEscapeDismiss: f,
148
- onEscapeKeyDown: r,
149
- onHighlight: y,
150
- onOutsideDismiss: s,
151
- onPointerDownOutside: k,
152
- onSelect: g,
153
- options: I,
154
- ownerDocument: M,
155
- position: D,
156
- selectedValue: L,
157
- state: N,
158
- triggerReference: q
159
- } = n, m = K(null), F = oe("Select").boundaryElement, O = Pe(!0, F), Q = Re(
160
- () => [q, m],
161
- [q]
162
- ), z = R(
118
+ active: n,
119
+ closeOnEscape: a,
120
+ closeOnOutsideInteraction: l,
121
+ highlightedIndex: o,
122
+ id: i,
123
+ listboxReference: s,
124
+ onEscapeDismiss: m,
125
+ onEscapeKeyDown: c,
126
+ onHighlight: v,
127
+ onOutsideDismiss: b,
128
+ onPointerDownOutside: w,
129
+ onSelect: y,
130
+ options: _,
131
+ ownerDocument: A,
132
+ position: x,
133
+ selectedValue: D,
134
+ state: S,
135
+ triggerReference: G
136
+ } = t, u = T(null), K = B("Select").boundaryElement, O = De(!0, K), q = ke(
137
+ () => [G, u],
138
+ [G]
139
+ ), F = I(
163
140
  (d) => {
164
- m.current = d, o(d);
141
+ u.current = d, s(d);
165
142
  },
166
- [o]
143
+ [s]
167
144
  );
168
- return Te({
169
- active: t,
170
- boundaries: Q,
171
- boundary: F,
172
- dismissOnEscape: l,
173
- dismissOnPointerDownOutside: a,
145
+ return Oe({
146
+ active: n,
147
+ boundaries: q,
148
+ boundary: K,
149
+ dismissOnEscape: a,
150
+ dismissOnPointerDownOutside: l,
174
151
  layerId: O.id,
175
- onEscapeDismiss: f,
176
- onEscapeKeyDown: r,
177
- onPointerDownOutside: k,
178
- onPointerDownOutsideDismiss: s,
179
- ownerDocument: M
180
- }), /* @__PURE__ */ h(
152
+ onEscapeDismiss: m,
153
+ onEscapeKeyDown: c,
154
+ onPointerDownOutside: w,
155
+ onPointerDownOutsideDismiss: b,
156
+ ownerDocument: A
157
+ }), /* @__PURE__ */ f(
181
158
  "div",
182
159
  {
183
- "aria-hidden": t ? void 0 : !0,
184
- "aria-labelledby": c,
160
+ "aria-hidden": n ? void 0 : !0,
161
+ "aria-labelledby": i,
185
162
  className: "nk-select__listbox",
186
- "data-state": N,
187
- id: `${c}-listbox`,
188
- ref: z,
163
+ "data-state": S,
164
+ id: `${i}-listbox`,
165
+ ref: F,
189
166
  role: "listbox",
190
- style: D ? {
191
- left: D.left,
192
- maxHeight: D.maxHeight,
193
- minWidth: D.minWidth,
194
- top: D.top,
167
+ style: x ? {
168
+ left: x.left,
169
+ maxHeight: x.maxHeight,
170
+ minWidth: x.minWidth,
171
+ top: x.top,
195
172
  zIndex: O.zIndex
196
173
  } : { visibility: "hidden", zIndex: O.zIndex },
197
- children: I.map((d, V) => /* @__PURE__ */ S(
174
+ children: _.map((d, H) => /* @__PURE__ */ R(
198
175
  "div",
199
176
  {
200
177
  "aria-disabled": d.disabled || void 0,
201
- "aria-selected": d.value === L,
178
+ "aria-selected": d.value === D,
202
179
  className: "nk-select__option",
203
- "data-highlighted": V === u || void 0,
204
- "data-selected": d.value === L || void 0,
205
- id: `${c}-option-${V}`,
206
- onPointerDown: (te) => {
207
- te.preventDefault(), d.disabled || g(d);
180
+ "data-highlighted": H === o || void 0,
181
+ "data-selected": d.value === D || void 0,
182
+ id: `${i}-option-${H}`,
183
+ onPointerDown: (Q) => {
184
+ Q.preventDefault(), d.disabled || y(d);
208
185
  },
209
186
  onPointerMove: () => {
210
- d.disabled || y(V);
187
+ d.disabled || v(H);
211
188
  },
212
189
  role: "option",
213
190
  children: [
214
- d.icon ? /* @__PURE__ */ h(X, { type: d.icon }) : null,
215
- /* @__PURE__ */ h("span", { className: "nk-select__option-label", children: d.label }),
216
- d.value === L ? /* @__PURE__ */ h(X, { className: "nk-select__check", type: "checkmark" }) : null
191
+ d.icon ? /* @__PURE__ */ f($, { type: d.icon }) : null,
192
+ /* @__PURE__ */ f("span", { className: "nk-select__option-label", children: d.label }),
193
+ d.value === D ? /* @__PURE__ */ f($, { className: "nk-select__check", type: "checkmark" }) : null
217
194
  ]
218
195
  },
219
196
  d.value
@@ -221,210 +198,193 @@ function je(n) {
221
198
  }
222
199
  );
223
200
  }
224
- function Ue(n) {
225
- var de;
201
+ function Ke(t, n, a) {
202
+ n.current = t, Le(a, t);
203
+ }
204
+ function qe(t) {
205
+ var ne;
226
206
  const {
227
- "aria-invalid": t,
228
- className: l,
229
- closeOnEscape: a = !0,
230
- closeOnOutsideInteraction: u = !0,
231
- defaultValue: c = "",
232
- disabled: o = !1,
233
- displayOverride: f,
234
- form: r,
235
- forwardedReference: y,
236
- id: s,
237
- invalid: k = !1,
238
- name: g,
239
- onChange: I,
240
- onClick: M,
241
- onEscapeKeyDown: D,
242
- onKeyDown: L,
243
- onOpenChange: N,
244
- onPointerDownOutside: q,
245
- options: m,
246
- placeholder: F,
207
+ "aria-invalid": n,
208
+ className: a,
209
+ closeOnEscape: l = !0,
210
+ closeOnOutsideInteraction: o = !0,
211
+ defaultValue: i = "",
212
+ disabled: s = !1,
213
+ displayOverride: m,
214
+ form: c,
215
+ forwardedReference: v,
216
+ id: b,
217
+ invalid: w = !1,
218
+ name: y,
219
+ onChange: _,
220
+ onClick: A,
221
+ onEscapeKeyDown: x,
222
+ onKeyDown: D,
223
+ onOpenChange: S,
224
+ onPointerDownOutside: G,
225
+ options: u,
226
+ placeholder: K,
247
227
  required: O = !1,
248
- style: Q,
249
- value: z,
228
+ style: q,
229
+ value: F,
250
230
  width: d,
251
- ...V
252
- } = n;
253
- We(m);
254
- const te = xe(), P = s ?? te, b = K(null), se = K(null), T = K(null), Y = K(""), [A, me] = j(null), [p, he] = j(!1), [_, W] = j(-1), [pe, ce] = j(c), H = z !== void 0, x = H ? z : pe, ve = m.find(
255
- (e) => e.value === x
256
- ), Ie = k || ue(t), we = fe(k, t), ne = Se(p), $ = ((de = b.current) == null ? void 0 : de.ownerDocument) ?? (typeof document > "u" ? null : document), ye = oe("Select").boundaryElement, ge = Ke(
257
- ne.present,
258
- b.current,
259
- A,
260
- ye
261
- ), ke = d === void 0 ? Q : { ...Q, width: d }, J = f ?? ve, be = R(
262
- (e) => {
263
- $e(
264
- e,
265
- b,
266
- y
267
- );
268
- },
269
- [y]
270
- ), v = R((e) => {
271
- p !== e && (he(e), N == null || N(e));
272
- }, [N, p]), Z = R((e = 1) => {
273
- const i = m.findIndex(
274
- (E) => E.value === x && !E.disabled
275
- ), w = e === 1 ? -1 : m.length;
276
- W(
277
- i >= 0 ? i : ae(m, w, e)
278
- ), v(!0);
279
- }, [m, x, v]), re = R((e) => {
280
- var i;
281
- o || e.disabled || (H || ce(e.value), v(!1), (i = b.current) == null || i.focus(), I == null || I(e.value));
282
- }, [o, H, I, v]), _e = R(() => {
231
+ ...H
232
+ } = t;
233
+ $e(u);
234
+ const Q = Ee(), L = b ?? Q, g = T(null), [M, se] = U(null), [h, oe] = U(!1), [k, V] = U(-1), [re, ee] = U(i), N = F !== void 0, P = N ? F : re, ce = u.find(
235
+ (e) => e.value === P
236
+ ), de = w || le(n), ue = ie(w, n), J = Re(h), C = ((ne = g.current) == null ? void 0 : ne.ownerDocument) ?? (typeof document > "u" ? null : document), fe = B("Select").boundaryElement, me = Me(
237
+ J.present,
238
+ g.current,
239
+ M,
240
+ fe
241
+ ), he = Ce(g), pe = d === void 0 ? q : { ...q, width: d }, j = m ?? ce, ve = I(
242
+ (e) => Ke(
243
+ e,
244
+ g,
245
+ v
246
+ ),
247
+ [v]
248
+ ), p = I((e) => {
249
+ h !== e && (oe(e), S == null || S(e));
250
+ }, [S, h]), be = I(() => {
251
+ N || ee(i), p(!1);
252
+ }, [i, N, p]), ye = Pe({
253
+ form: c,
254
+ onReset: be,
255
+ resetValue: N ? P : i,
256
+ triggerReference: g
257
+ }), z = I((e = 1) => {
258
+ const r = u.findIndex(
259
+ (ae) => ae.value === P && !ae.disabled
260
+ ), E = e === 1 ? -1 : u.length;
261
+ V(
262
+ r >= 0 ? r : Z(u, E, e)
263
+ ), p(!0);
264
+ }, [u, P, p]), te = I((e) => {
265
+ var r;
266
+ s || e.disabled || (N || ee(e.value), p(!1), (r = g.current) == null || r.focus(), _ == null || _(e.value));
267
+ }, [s, N, _, p]), Ie = I(() => {
283
268
  var e;
284
- v(!1), (e = b.current) == null || e.focus();
285
- }, [v]), Ee = R(() => {
286
- v(!1);
287
- }, [v]);
288
- function De(e) {
289
- M == null || M(e), !(e.defaultPrevented || o) && (p ? v(!1) : Z());
269
+ p(!1), (e = g.current) == null || e.focus();
270
+ }, [p]), ge = I(() => {
271
+ p(!1);
272
+ }, [p]);
273
+ function we(e) {
274
+ A == null || A(e), !(e.defaultPrevented || s) && (h ? p(!1) : z());
290
275
  }
291
- function Le(e) {
292
- if (L == null || L(e), !(e.defaultPrevented || o)) {
276
+ function _e(e) {
277
+ if (D == null || D(e), !(e.defaultPrevented || s)) {
293
278
  if (e.key === "ArrowDown" || e.key === "ArrowUp") {
294
279
  e.preventDefault();
295
- const i = e.key === "ArrowDown" ? 1 : -1;
296
- p ? W(
297
- (w) => ae(m, w, i)
298
- ) : Z(i);
280
+ const r = e.key === "ArrowDown" ? 1 : -1;
281
+ h ? V(
282
+ (E) => Z(u, E, r)
283
+ ) : z(r);
299
284
  return;
300
285
  }
301
286
  if (e.key === "Home" || e.key === "End") {
302
- if (e.preventDefault(), !p) Z(e.key === "Home" ? 1 : -1);
287
+ if (e.preventDefault(), !h) z(e.key === "Home" ? 1 : -1);
303
288
  else {
304
- const i = e.key === "Home" ? 1 : -1, w = i === 1 ? -1 : m.length;
305
- W(
306
- ae(m, w, i)
289
+ const r = e.key === "Home" ? 1 : -1, E = r === 1 ? -1 : u.length;
290
+ V(
291
+ Z(u, E, r)
307
292
  );
308
293
  }
309
294
  return;
310
295
  }
311
296
  if (e.key === "Enter" || e.key === " ") {
312
297
  e.preventDefault();
313
- const i = m[_];
314
- p && i ? re(i) : p || Z();
298
+ const r = u[k];
299
+ h && r ? te(r) : h || z();
315
300
  return;
316
301
  }
317
302
  if (e.key === "Tab") {
318
- v(!1);
303
+ p(!1);
319
304
  return;
320
305
  }
321
306
  if (e.key.length === 1 && !e.altKey && !e.ctrlKey && !e.metaKey) {
322
- const i = e.currentTarget.ownerDocument.defaultView;
323
- if (!i) return;
324
- const w = e.key.toLocaleLowerCase(), E = Y.current + w, le = Array.from(E).every((ie) => ie === w);
325
- Y.current = le ? w : E, T.current !== null && i.clearTimeout(T.current), T.current = i.setTimeout(() => {
326
- Y.current = "", T.current = null;
327
- }, 500);
328
- const C = Ae(
329
- m,
330
- Y.current,
331
- _
307
+ const r = he(e.key.toLocaleLowerCase());
308
+ if (r === null) return;
309
+ const E = We(
310
+ u,
311
+ r,
312
+ k
332
313
  );
333
- C >= 0 && (e.preventDefault(), p || v(!0), W(C));
314
+ E >= 0 && (e.preventDefault(), h || p(!0), V(E));
334
315
  }
335
316
  }
336
317
  }
337
- return U(() => {
338
- o && v(!1);
339
- }, [o, v]), U(() => {
318
+ return Y(() => {
319
+ s && p(!1);
320
+ }, [s, p]), Y(() => {
340
321
  var e;
341
- if (p && _ >= 0) {
342
- const i = $ == null ? void 0 : $.getElementById(
343
- `${P}-option-${_}`
322
+ if (h && k >= 0) {
323
+ const r = C == null ? void 0 : C.getElementById(
324
+ `${L}-option-${k}`
344
325
  );
345
- i && (A != null && A.contains(i)) && ((e = i.scrollIntoView) == null || e.call(i, { block: "nearest" }));
346
- }
347
- }, [_, P, A, p]), U(() => {
348
- var w;
349
- const e = (w = b.current) == null ? void 0 : w.form;
350
- if (!e) return;
351
- function i() {
352
- const E = se.current, le = H ? x : c;
353
- if (E) {
354
- const C = Array.from(E.options), ie = C.find(
355
- (B) => B.value === le
356
- ) ?? C[0];
357
- C.forEach((B) => {
358
- B.defaultSelected = B === ie;
359
- });
360
- }
361
- H || ce(c), v(!1);
326
+ r && (M != null && M.contains(r)) && ((e = r.scrollIntoView) == null || e.call(r, { block: "nearest" }));
362
327
  }
363
- return e.addEventListener("reset", i), () => e.removeEventListener("reset", i);
364
- }, [c, r, H, x, v]), U(() => () => {
365
- var i;
366
- const e = (i = b.current) == null ? void 0 : i.ownerDocument.defaultView;
367
- e && T.current !== null && e.clearTimeout(T.current);
368
- }, []), /* @__PURE__ */ S(
328
+ }, [k, L, M, h]), /* @__PURE__ */ R(
369
329
  "span",
370
330
  {
371
- className: ["nk-select", l].filter(Boolean).join(" "),
372
- "data-disabled": o || void 0,
373
- "data-invalid": Ie || void 0,
331
+ className: ["nk-select", a].filter(Boolean).join(" "),
332
+ "data-disabled": s || void 0,
333
+ "data-invalid": de || void 0,
374
334
  "data-mode": "custom",
375
- "data-open": p || void 0,
376
- style: ke,
335
+ "data-open": h || void 0,
336
+ style: pe,
377
337
  children: [
378
- /* @__PURE__ */ S(
338
+ /* @__PURE__ */ R(
379
339
  "button",
380
340
  {
381
- ...V,
382
- ref: be,
383
- "aria-activedescendant": p && _ >= 0 ? `${P}-option-${_}` : void 0,
384
- "aria-controls": `${P}-listbox`,
385
- "aria-expanded": p,
341
+ ...H,
342
+ ref: ve,
343
+ "aria-activedescendant": h && k >= 0 ? `${L}-option-${k}` : void 0,
344
+ "aria-controls": `${L}-listbox`,
345
+ "aria-expanded": h,
386
346
  "aria-haspopup": "listbox",
387
- "aria-invalid": we,
347
+ "aria-invalid": ue,
388
348
  "aria-required": O || void 0,
389
349
  "aria-autocomplete": "none",
390
350
  className: "nk-select__trigger",
391
- disabled: o,
392
- form: r,
393
- id: P,
394
- onClick: De,
395
- onKeyDown: Le,
351
+ disabled: s,
352
+ form: c,
353
+ id: L,
354
+ onClick: we,
355
+ onKeyDown: _e,
396
356
  role: "combobox",
397
357
  type: "button",
398
358
  children: [
399
- J ? /* @__PURE__ */ S("span", { className: "nk-select__value", children: [
400
- J.icon ? /* @__PURE__ */ h(X, { type: J.icon }) : null,
401
- /* @__PURE__ */ h("span", { className: "nk-select__value-label", children: J.label })
402
- ] }) : /* @__PURE__ */ h("span", { className: "nk-select__placeholder", children: F }),
403
- /* @__PURE__ */ h(X, { className: "nk-select__icon", type: "chevron-down" })
359
+ j ? /* @__PURE__ */ R("span", { className: "nk-select__value", children: [
360
+ j.icon ? /* @__PURE__ */ f($, { type: j.icon }) : null,
361
+ /* @__PURE__ */ f("span", { className: "nk-select__value-label", children: j.label })
362
+ ] }) : /* @__PURE__ */ f("span", { className: "nk-select__placeholder", children: K }),
363
+ /* @__PURE__ */ f($, { className: "nk-select__icon", type: "chevron-down" })
404
364
  ]
405
365
  }
406
366
  ),
407
- g || O ? /* @__PURE__ */ S(
367
+ y || O ? /* @__PURE__ */ R(
408
368
  "select",
409
369
  {
410
- ref: se,
370
+ ref: ye,
411
371
  "aria-hidden": "true",
412
372
  className: "nk-select__form-control",
413
- disabled: o,
414
- form: r,
415
- name: g,
373
+ disabled: s,
374
+ form: c,
375
+ name: y,
416
376
  onChange: () => {
417
377
  },
418
378
  onInvalid: (e) => {
419
- var i;
420
- e.preventDefault(), (i = b.current) == null || i.focus();
379
+ var r;
380
+ e.preventDefault(), (r = g.current) == null || r.focus();
421
381
  },
422
382
  required: O,
423
383
  tabIndex: -1,
424
- value: x,
384
+ value: P,
425
385
  children: [
426
- /* @__PURE__ */ h("option", { value: "" }),
427
- m.map((e) => /* @__PURE__ */ h(
386
+ /* @__PURE__ */ f("option", { value: "" }),
387
+ u.map((e) => /* @__PURE__ */ f(
428
388
  "option",
429
389
  {
430
390
  disabled: e.disabled,
@@ -436,49 +396,93 @@ function Ue(n) {
436
396
  ]
437
397
  }
438
398
  ) : null,
439
- ne.present && $ ? /* @__PURE__ */ h(Ne, { children: /* @__PURE__ */ h(
440
- je,
399
+ J.present && C ? /* @__PURE__ */ f(Se, { children: /* @__PURE__ */ f(
400
+ Ge,
441
401
  {
442
- active: p,
443
- closeOnEscape: a,
444
- closeOnOutsideInteraction: u,
445
- highlightedIndex: _,
446
- id: P,
447
- listboxReference: me,
448
- onEscapeDismiss: _e,
449
- onEscapeKeyDown: D,
450
- onHighlight: W,
451
- onOutsideDismiss: Ee,
452
- onPointerDownOutside: q,
453
- onSelect: re,
454
- options: m,
455
- ownerDocument: $,
456
- position: ge,
457
- selectedValue: x,
458
- state: ne.state === "closing" ? "closing" : "open",
459
- triggerReference: b
402
+ active: h,
403
+ closeOnEscape: l,
404
+ closeOnOutsideInteraction: o,
405
+ highlightedIndex: k,
406
+ id: L,
407
+ listboxReference: se,
408
+ onEscapeDismiss: Ie,
409
+ onEscapeKeyDown: x,
410
+ onHighlight: V,
411
+ onOutsideDismiss: ge,
412
+ onPointerDownOutside: G,
413
+ onSelect: te,
414
+ options: u,
415
+ ownerDocument: C,
416
+ position: me,
417
+ selectedValue: P,
418
+ state: J.state === "closing" ? "closing" : "open",
419
+ triggerReference: g
460
420
  }
461
421
  ) }) : null
462
422
  ]
463
423
  }
464
424
  );
465
425
  }
466
- const Je = Oe(function(t, l) {
467
- const { options: a } = t;
468
- return oe("Select"), a !== void 0 ? /* @__PURE__ */ h(
469
- Ue,
426
+ function Fe(t) {
427
+ const {
428
+ "aria-invalid": n,
429
+ children: a,
430
+ className: l,
431
+ defaultValue: o,
432
+ disabled: i = !1,
433
+ forwardedReference: s,
434
+ invalid: m = !1,
435
+ placeholder: c,
436
+ style: v,
437
+ value: b,
438
+ ...w
439
+ } = t, y = ie(m, n), _ = m || le(n);
440
+ return /* @__PURE__ */ R(
441
+ "span",
442
+ {
443
+ className: ["nk-select", l].filter(Boolean).join(" "),
444
+ "data-disabled": i || void 0,
445
+ "data-invalid": _ || void 0,
446
+ "data-mode": "native",
447
+ style: v,
448
+ children: [
449
+ /* @__PURE__ */ R(
450
+ "select",
451
+ {
452
+ ...w,
453
+ ref: s,
454
+ "aria-invalid": y,
455
+ className: "nk-select__control",
456
+ defaultValue: b === void 0 ? o ?? (c !== void 0 ? "" : void 0) : void 0,
457
+ disabled: i,
458
+ value: b,
459
+ children: [
460
+ c !== void 0 ? /* @__PURE__ */ f("option", { disabled: !0, value: "", children: c }) : null,
461
+ a
462
+ ]
463
+ }
464
+ ),
465
+ /* @__PURE__ */ f($, { className: "nk-select__icon", type: "chevron-down" })
466
+ ]
467
+ }
468
+ );
469
+ }
470
+ const Ze = xe(function(n, a) {
471
+ const { options: l } = n;
472
+ return B("Select"), l !== void 0 ? /* @__PURE__ */ f(
473
+ qe,
470
474
  {
471
- ...t,
472
- forwardedReference: l
475
+ ...n,
476
+ forwardedReference: a
473
477
  }
474
- ) : /* @__PURE__ */ h(
475
- Ge,
478
+ ) : /* @__PURE__ */ f(
479
+ Fe,
476
480
  {
477
- ...t,
478
- forwardedReference: l
481
+ ...n,
482
+ forwardedReference: a
479
483
  }
480
484
  );
481
485
  });
482
486
  export {
483
- Je as default
487
+ Ze as default
484
488
  };