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