neatkit 0.7.0 → 0.8.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 (154) hide show
  1. package/dist/Avatar-Belo7qAY.cjs +1 -0
  2. package/dist/Avatar-DjDCFqNG.js +55 -0
  3. package/dist/Avatar.cjs +1 -1
  4. package/dist/Avatar.js +2 -52
  5. package/dist/Boundary.cjs +1 -0
  6. package/dist/Boundary.js +176 -0
  7. package/dist/{Button-BAsLfA0D.js → Button-Chv4O66e.js} +35 -35
  8. package/dist/Button-DCKtFvSo.cjs +1 -0
  9. package/dist/Button.cjs +1 -1
  10. package/dist/Button.js +1 -1
  11. package/dist/Checkbox.cjs +1 -1
  12. package/dist/Checkbox.js +213 -2
  13. package/dist/Code-ClkozPlv.js +227 -0
  14. package/dist/Code-JDb4VFl7.cjs +4 -0
  15. package/dist/Code.cjs +1 -1
  16. package/dist/Code.js +1 -1
  17. package/dist/{Icon-uQmpr5P2.js → Icon-BoEUoOk7.js} +144 -177
  18. package/dist/Icon-DJ4BigRz.cjs +1 -0
  19. package/dist/Icon.cjs +1 -1
  20. package/dist/Icon.js +2 -35
  21. package/dist/Input.cjs +1 -1
  22. package/dist/Input.js +70 -79
  23. package/dist/Markdown.cjs +1 -31
  24. package/dist/Markdown.js +461 -18062
  25. package/dist/Modal.cjs +1 -1
  26. package/dist/Modal.js +100 -122
  27. package/dist/PinInput.cjs +1 -1
  28. package/dist/PinInput.js +1 -1
  29. package/dist/Popover.cjs +1 -1
  30. package/dist/Popover.js +106 -106
  31. package/dist/Radio.cjs +1 -1
  32. package/dist/Radio.js +86 -41
  33. package/dist/Select.cjs +1 -1
  34. package/dist/Select.js +326 -315
  35. package/dist/Sidebar.cjs +1 -0
  36. package/dist/Sidebar.js +475 -0
  37. package/dist/Skeleton.cjs +1 -1
  38. package/dist/Skeleton.js +20 -16
  39. package/dist/Switch.cjs +1 -1
  40. package/dist/Switch.js +1 -1
  41. package/dist/Table-B30TBckZ.js +402 -0
  42. package/dist/Table-DceR12X9.cjs +1 -0
  43. package/dist/Table.cjs +1 -1
  44. package/dist/Table.js +1 -1
  45. package/dist/TextArea.cjs +1 -1
  46. package/dist/TextArea.js +1 -1
  47. package/dist/Tooltip-B4bajPtk.cjs +1 -0
  48. package/dist/Tooltip-BVqdnKK_.js +231 -0
  49. package/dist/Tooltip.cjs +1 -1
  50. package/dist/Tooltip.js +2 -3
  51. package/dist/aria-Bntn6ad_.cjs +1 -0
  52. package/dist/aria-CeA9QfD1.js +15 -0
  53. package/dist/components/Boundary/Boundary.d.ts +65 -0
  54. package/dist/components/Boundary/contexts/BoundaryContext.d.ts +28 -0
  55. package/dist/components/Boundary/hooks/useBoundary.d.ts +19 -0
  56. package/dist/components/Boundary/hooks/useBoundaryWidth.d.ts +23 -0
  57. package/dist/components/Boundary/index.d.ts +2 -0
  58. package/dist/components/Boundary/utils/width.d.ts +11 -0
  59. package/dist/components/Checkbox/Checkbox.d.ts +9 -1
  60. package/dist/components/{CheckboxGroup → Checkbox/components}/CheckboxGroup.d.ts +2 -2
  61. package/dist/components/Checkbox/index.d.ts +1 -0
  62. package/dist/components/Checkbox/utils/checkbox-option.d.ts +17 -0
  63. package/dist/components/Icon/Icon.d.ts +1 -0
  64. package/dist/components/Icon/index.d.ts +0 -33
  65. package/dist/components/Input/Input.d.ts +1 -9
  66. package/dist/components/Modal/Modal.d.ts +0 -4
  67. package/dist/components/PinInput/PinInput.d.ts +1 -1
  68. package/dist/components/Popover/Popover.d.ts +2 -6
  69. package/dist/components/Portal/Portal.d.ts +11 -8
  70. package/dist/components/Portal/hooks/useDismissableLayer.d.ts +2 -0
  71. package/dist/components/Portal/hooks/useFloatingPosition.d.ts +4 -3
  72. package/dist/components/Portal/hooks/useFocusTrap.d.ts +2 -0
  73. package/dist/components/Portal/hooks/useScrollLock.d.ts +9 -3
  74. package/dist/components/Portal/utils/boundary-focus.d.ts +23 -0
  75. package/dist/components/Portal/utils/floating-position.d.ts +43 -9
  76. package/dist/components/Portal/utils/overlay-stack.d.ts +22 -10
  77. package/dist/components/Portal/utils/scroll-container.d.ts +13 -0
  78. package/dist/components/Radio/Radio.d.ts +9 -1
  79. package/dist/components/{RadioGroup → Radio/components}/RadioGroup.d.ts +9 -2
  80. package/dist/components/Radio/index.d.ts +1 -0
  81. package/dist/components/Select/Select.d.ts +0 -2
  82. package/dist/components/Select/utils/listbox-position.d.ts +28 -0
  83. package/dist/components/Sidebar/Sidebar.d.ts +108 -0
  84. package/dist/components/Sidebar/components/SidebarFooter.d.ts +19 -0
  85. package/dist/components/Sidebar/components/SidebarGroup.d.ts +42 -0
  86. package/dist/components/Sidebar/components/SidebarItem.d.ts +43 -0
  87. package/dist/components/Sidebar/components/SidebarOverlay.d.ts +38 -0
  88. package/dist/components/Sidebar/components/SidebarPanel.d.ts +47 -0
  89. package/dist/components/Sidebar/components/SidebarTrigger.d.ts +47 -0
  90. package/dist/components/Sidebar/components/SidebarUser.d.ts +59 -0
  91. package/dist/components/Sidebar/hooks/usePresentation.d.ts +14 -0
  92. package/dist/components/Sidebar/hooks/useSidebar.d.ts +9 -0
  93. package/dist/components/Sidebar/index.d.ts +2 -0
  94. package/dist/components/Sidebar/utils/state.d.ts +62 -0
  95. package/dist/components/Skeleton/Skeleton.d.ts +21 -5
  96. package/dist/components/Table/Table.d.ts +9 -49
  97. package/dist/components/Table/contexts/TableContext.d.ts +4 -0
  98. package/dist/components/Table/index.d.ts +1 -1
  99. package/dist/components/Tooltip/Tooltip.d.ts +10 -4
  100. package/dist/components/Tooltip/TooltipProvider.d.ts +1 -1
  101. package/dist/components/Tooltip/index.d.ts +0 -1
  102. package/dist/effects-D5CWf-Pl.js +8 -0
  103. package/dist/effects-D85L_7zM.cjs +1 -0
  104. package/dist/floating-position-5wJ5G5IT.js +48 -0
  105. package/dist/floating-position-Cy9xxdH4.cjs +1 -0
  106. package/dist/style.css +1 -1
  107. package/dist/tokens.d.ts +1 -0
  108. package/dist/useFloatingPosition-BBEUHPqy.cjs +1 -0
  109. package/dist/useFloatingPosition-CMirP2-2.js +43 -0
  110. package/dist/useFocusTrap-BrFZdMqQ.cjs +1 -0
  111. package/dist/useFocusTrap-DhVnlboe.js +136 -0
  112. package/dist/usePresence-B5RYv4e1.cjs +1 -0
  113. package/dist/usePresence-CqegYqy4.js +221 -0
  114. package/dist/useScrollLock-Drd7OZRC.js +62 -0
  115. package/dist/useScrollLock-Dy8MZaSn.cjs +1 -0
  116. package/dist/utils/aria.d.ts +9 -0
  117. package/dist/utils/effects.d.ts +12 -0
  118. package/package.json +11 -16
  119. package/dist/Button-D7JUO6Fs.cjs +0 -1
  120. package/dist/Checkbox-BvXM9VyY.js +0 -68
  121. package/dist/Checkbox-VQifZrZZ.cjs +0 -1
  122. package/dist/CheckboxGroup.cjs +0 -1
  123. package/dist/CheckboxGroup.js +0 -144
  124. package/dist/Code-BP2ZCmUf.js +0 -7446
  125. package/dist/Code-eispVOW3.cjs +0 -6
  126. package/dist/Content.cjs +0 -1
  127. package/dist/Content.js +0 -144
  128. package/dist/Icon-D8IZceys.cjs +0 -1
  129. package/dist/RadioGroup.cjs +0 -1
  130. package/dist/RadioGroup.js +0 -51
  131. package/dist/RadioGroupContext-BX9KnDek.cjs +0 -1
  132. package/dist/RadioGroupContext-DbKM4zPZ.js +0 -5
  133. package/dist/Table-83unQQOi.cjs +0 -1
  134. package/dist/Table-Cw8u-pEW.js +0 -403
  135. package/dist/Tooltip-BB82wNOE.cjs +0 -1
  136. package/dist/Tooltip-CqWK_GRD.js +0 -236
  137. package/dist/aria-DHnOMyYp.js +0 -10
  138. package/dist/aria-DKxpE8cA.cjs +0 -1
  139. package/dist/components/CheckboxGroup/index.d.ts +0 -2
  140. package/dist/components/Content/Content.d.ts +0 -60
  141. package/dist/components/Content/hooks/useContentLayout.d.ts +0 -18
  142. package/dist/components/Content/index.d.ts +0 -2
  143. package/dist/components/Content/utils/layout.d.ts +0 -11
  144. package/dist/components/RadioGroup/index.d.ts +0 -2
  145. package/dist/useFloatingPosition-CxzhAvy8.js +0 -73
  146. package/dist/useFloatingPosition-D1FqYy0l.cjs +0 -1
  147. package/dist/useFocusTrap--cgjy78G.cjs +0 -1
  148. package/dist/useFocusTrap-Da4nEash.js +0 -134
  149. package/dist/usePresence-DSPt6aKi.js +0 -210
  150. package/dist/usePresence-qe92UTvK.cjs +0 -1
  151. /package/dist/components/{CheckboxGroup → Checkbox}/contexts/CheckboxGroupContext.d.ts +0 -0
  152. /package/dist/components/{CheckboxGroup → Checkbox}/hooks/useCheckboxGroup.d.ts +0 -0
  153. /package/dist/components/{RadioGroup → Radio}/contexts/RadioGroupContext.d.ts +0 -0
  154. /package/dist/components/{RadioGroup → Radio}/hooks/useRadioGroup.d.ts +0 -0
package/dist/Popover.js CHANGED
@@ -1,52 +1,49 @@
1
1
  "use client";
2
- import { jsxs as te, Fragment as Se, jsx as T } from "react/jsx-runtime";
3
- import { forwardRef as Ce, Fragment as Le, useId as Ne, useContext as Be, useState as j, useRef as b, useReducer as _e, useMemo as je, useCallback as v, useEffect as K, cloneElement as Ke, useLayoutEffect as qe } from "react";
4
- import { g as ze, a as ne } from "./reference-CXMr27nM.js";
5
- import { F as re, a as Ae, b as Me, c as $e, P as He } from "./usePresence-DSPt6aKi.js";
6
- import { u as Ve } from "./useFloatingPosition-CxzhAvy8.js";
7
- import { u as Ue } from "./useFocusTrap-Da4nEash.js";
8
- import { S as Ge } from "./Surface-vEFsZC12.js";
9
- function Je(r) {
10
- const { inert: s, panelElement: a } = r;
11
- return qe(() => {
12
- a && (a.inert = s);
13
- }, [s, a]), null;
2
+ import { jsxs as re, Fragment as Se, jsx as T } from "react/jsx-runtime";
3
+ import { forwardRef as Fe, Fragment as Le, useId as Ne, useContext as Be, useState as K, useRef as b, useReducer as _e, useMemo as Ke, useCallback as v, useEffect as j, cloneElement as je } from "react";
4
+ import { m as qe } from "./aria-CeA9QfD1.js";
5
+ import { u as ze } from "./effects-D5CWf-Pl.js";
6
+ import { g as Ae, a as ne } from "./reference-CXMr27nM.js";
7
+ import { F as te, c as Me, b as $e, d as He, e as Ve, P as Ue } from "./usePresence-CqegYqy4.js";
8
+ import { u as Ge } from "./useFloatingPosition-CMirP2-2.js";
9
+ import { u as Je } from "./useFocusTrap-DhVnlboe.js";
10
+ import { S as Qe } from "./Surface-vEFsZC12.js";
11
+ function We(o) {
12
+ const { inert: a, panelElement: i } = o;
13
+ return ze(() => {
14
+ i && (i.inert = a);
15
+ }, [a, i]), null;
14
16
  }
15
- function Qe(r, s, a) {
16
- s.current = r, ne(a, r);
17
+ function Xe(o, a, i) {
18
+ a.current = o, ne(i, o);
17
19
  }
18
- function We(r, s, a) {
19
- s.current = r, ne(a, r);
20
+ function Ye(o, a, i) {
21
+ a.current = o, ne(i, o);
20
22
  }
21
- function Xe(r, s) {
22
- const a = (r == null ? void 0 : r.split(/\s+/).filter(Boolean)) ?? [];
23
- return a.includes(s) || a.push(s), a.join(" ");
23
+ function Ze(o) {
24
+ const a = o.tagName.toLowerCase();
25
+ return o.getAttribute("role") === "button" && a !== "button" ? !1 : ["button", "input", "select", "summary", "textarea"].includes(a) ? !0 : a === "a" && o.hasAttribute("href");
24
26
  }
25
- function Ye(r) {
26
- const s = r.tagName.toLowerCase();
27
- return r.getAttribute("role") === "button" && s !== "button" ? !1 : ["button", "input", "select", "summary", "textarea"].includes(s) ? !0 : s === "a" && r.hasAttribute("href");
27
+ function er(o) {
28
+ return o === "grid" || o === "listbox" || o === "menu" || o === "tree" ? o : "dialog";
28
29
  }
29
- function Ze(r) {
30
- return r === "grid" || r === "listbox" || r === "menu" || r === "tree" ? r : "dialog";
31
- }
32
- const ct = Ce(function(s, a) {
30
+ const dr = Fe(function(a, i) {
33
31
  const {
34
32
  "aria-label": q,
35
33
  "aria-labelledby": oe,
36
- autoFocus: F = !0,
34
+ autoFocus: D = !0,
37
35
  children: se,
38
36
  className: ae,
39
37
  closeOnEscape: ie = !0,
40
38
  closeOnOutsideInteraction: ce = !0,
41
39
  defaultOpen: le = !1,
42
40
  disabled: I = !1,
43
- initialFocusReference: h,
41
+ initialFocusReference: y,
44
42
  onEscapeKeyDown: ue,
45
43
  onOpenChange: R,
46
44
  onPointerDownOutside: x,
47
45
  open: z,
48
46
  placement: A = "bottom",
49
- portalContainer: k,
50
47
  restoreFocus: S = !0,
51
48
  role: M = "dialog",
52
49
  style: $,
@@ -54,173 +51,176 @@ const ct = Ce(function(s, a) {
54
51
  trapFocus: p = !1,
55
52
  trigger: l,
56
53
  ...fe
57
- } = s;
54
+ } = a;
58
55
  if (l.type === Le)
59
56
  throw new Error("Popover requires a single non-Fragment trigger");
60
- const H = Ne(), pe = Be(re), V = `${H}-popover`, o = l.props, U = ze(l), G = o.id ?? `${H}-trigger`, y = I || o.disabled === !0 || o["aria-disabled"] === !0 || o["aria-disabled"] === "true", P = z !== void 0, [ge, me] = j(le), t = P ? z : ge, O = Ae(t), J = b(null), Q = b(null), C = b("programmatic"), L = b(null), W = b(t), w = b(null), [be, ve] = _e(
57
+ const H = Ne(), pe = Be(te), V = `${H}-popover`, n = l.props, U = Ae(l), G = n.id ?? `${H}-trigger`, h = I || n.disabled === !0 || n["aria-disabled"] === !0 || n["aria-disabled"] === "true", P = z !== void 0, [me, ge] = K(le), r = P ? z : me, k = Me(r), J = b(null), Q = b(null), F = b("programmatic"), L = b(null), W = b(r), O = b(null), [be, ve] = _e(
61
58
  (e) => e + 1,
62
59
  0
63
- ), [c, he] = j(null), [u, ye] = j(null), i = (k == null ? void 0 : k.ownerDocument) ?? (c == null ? void 0 : c.ownerDocument) ?? (typeof document > "u" ? null : document), D = Me(O.present, i), Pe = je(
60
+ ), [c, ye] = K(null), [u, he] = K(null), s = (c == null ? void 0 : c.ownerDocument) ?? (typeof document > "u" ? null : document), w = $e("Popover").boundaryElement, C = He(k.present, w), Pe = Ke(
64
61
  () => [J, Q],
65
62
  []
66
- ), d = Ve(
67
- O.present,
63
+ ), d = Ge(
64
+ k.present,
68
65
  A,
69
66
  c,
70
- u
67
+ u,
68
+ w
71
69
  ), Ee = v(
72
70
  (e) => {
73
- We(
71
+ Ye(
74
72
  e,
75
73
  J,
76
74
  U
77
- ), he(e);
75
+ ), ye(e);
78
76
  },
79
77
  [U]
80
78
  ), Te = v(
81
79
  (e) => {
82
- Qe(
80
+ Xe(
83
81
  e,
84
82
  Q,
85
- a
86
- ), ye(e);
83
+ i
84
+ ), he(e);
87
85
  },
88
- [a]
89
- ), f = v((e, n) => {
90
- t !== e && (P ? (L.current = {
86
+ [i]
87
+ ), f = v((e, t) => {
88
+ r !== e && (P ? (L.current = {
91
89
  open: e,
92
- reason: n
93
- }, ve()) : (C.current = n, me(e)), R == null || R(e, n));
94
- }, [P, R, t]), Ie = v(() => {
90
+ reason: t
91
+ }, ve()) : (F.current = t, ge(e)), R == null || R(e, t));
92
+ }, [P, R, r]), Ie = v(() => {
95
93
  f(!1, "escape");
96
94
  }, [f]), Re = v(() => {
97
95
  f(!1, "outside");
98
96
  }, [f]), xe = v((e) => {
99
97
  var E;
100
98
  if (x == null || x(e), e.defaultPrevented) return;
101
- const n = (E = i == null ? void 0 : i.defaultView) == null ? void 0 : E.HTMLElement;
102
- w.current = n ? e.composedPath().find(
103
- (m) => m instanceof n && m.tabIndex >= 0
99
+ const t = (E = s == null ? void 0 : s.defaultView) == null ? void 0 : E.HTMLElement;
100
+ O.current = t ? e.composedPath().find(
101
+ (g) => g instanceof t && g.tabIndex >= 0
104
102
  ) ?? e.target : e.target;
105
- }, [x, i]);
106
- $e({
107
- active: t,
103
+ }, [x, s]);
104
+ Ve({
105
+ boundary: w,
106
+ active: r,
108
107
  boundaries: Pe,
109
108
  dismissOnEscape: ie,
110
109
  dismissOnPointerDownOutside: ce,
111
- layerId: D.id,
110
+ layerId: C.id,
112
111
  onEscapeDismiss: Ie,
113
112
  onEscapeKeyDown: ue,
114
113
  onPointerDownOutside: xe,
115
114
  onPointerDownOutsideDismiss: Re,
116
- ownerDocument: i
115
+ ownerDocument: s
117
116
  });
118
- const ke = Ue({
119
- active: t && p,
120
- autoFocus: F,
117
+ const ke = Je({
118
+ boundary: w,
119
+ active: r && p,
120
+ autoFocus: D,
121
121
  container: u,
122
- initialFocusReference: h,
123
- layerId: D.id,
122
+ initialFocusReference: y,
123
+ layerId: C.id,
124
124
  restoreFocus: S
125
125
  });
126
- K(() => {
127
- if (!t || p || !F || !u) return;
126
+ j(() => {
127
+ if (!r || p || !D || !u) return;
128
128
  let e = !0;
129
129
  return Promise.resolve().then(() => {
130
130
  if (!e) return;
131
- const n = h == null ? void 0 : h.current;
132
- (n && u.contains(n) ? n : u).focus({ preventScroll: !0 });
131
+ const t = y == null ? void 0 : y.current;
132
+ (t && u.contains(t) ? t : u).focus({ preventScroll: !0 });
133
133
  }), () => {
134
134
  e = !1;
135
135
  };
136
- }, [F, h, t, u, p]), K(() => {
136
+ }, [D, y, r, u, p]), j(() => {
137
137
  var ee;
138
138
  const e = W.current;
139
- W.current = t;
140
- const n = L.current, E = P ? e !== t && (n == null ? void 0 : n.open) === t ? n.reason : "programmatic" : C.current;
141
- if (L.current = null, t) {
142
- C.current = "programmatic", w.current = null;
139
+ W.current = r;
140
+ const t = L.current, E = P ? e !== r && (t == null ? void 0 : t.open) === r ? t.reason : "programmatic" : F.current;
141
+ if (L.current = null, r) {
142
+ F.current = "programmatic", O.current = null;
143
143
  return;
144
144
  }
145
- const m = i == null ? void 0 : i.activeElement, B = w.current, _ = (ee = i == null ? void 0 : i.defaultView) == null ? void 0 : ee.HTMLElement, Fe = E === "outside" && _ && B instanceof _ && m instanceof _ && (B === m || B.contains(m));
146
- e && !p && S && !Fe && (c == null || c.focus({ preventScroll: !0 })), w.current = null;
145
+ const g = s == null ? void 0 : s.activeElement, B = O.current, _ = (ee = s == null ? void 0 : s.defaultView) == null ? void 0 : ee.HTMLElement, De = E === "outside" && _ && B instanceof _ && g instanceof _ && (B === g || B.contains(g));
146
+ e && !p && S && !De && (c == null || c.focus({ preventScroll: !0 })), O.current = null;
147
147
  }, [
148
148
  be,
149
149
  P,
150
- t,
151
- i,
150
+ r,
151
+ s,
152
152
  S,
153
153
  p,
154
154
  c
155
- ]), K(() => {
156
- I && t && f(!1, "programmatic");
157
- }, [I, t, f]);
155
+ ]), j(() => {
156
+ I && r && f(!1, "programmatic");
157
+ }, [I, r, f]);
158
158
  function Oe(e) {
159
- var n;
160
- if (y) {
159
+ var t;
160
+ if (h) {
161
161
  e.preventDefault(), e.stopPropagation();
162
162
  return;
163
163
  }
164
- (n = o.onClick) == null || n.call(o, e), !e.defaultPrevented && f(!t, "trigger");
164
+ (t = n.onClick) == null || t.call(n, e), !e.defaultPrevented && f(!r, "trigger");
165
165
  }
166
166
  function we(e) {
167
- var n;
168
- (n = o.onKeyDown) == null || n.call(o, e), !(e.defaultPrevented || y || Ye(e.currentTarget) || e.key !== "Enter" && e.key !== " ") && (e.preventDefault(), e.currentTarget.click());
167
+ var t;
168
+ (t = n.onKeyDown) == null || t.call(n, e), !(e.defaultPrevented || h || Ze(e.currentTarget) || e.key !== "Enter" && e.key !== " ") && (e.preventDefault(), e.currentTarget.click());
169
169
  }
170
170
  if (I) return l;
171
- const N = typeof l.type == "string", g = N ? l.type : null, X = g === "a" && typeof o.href == "string", Y = N && !(g === "button" || g === "input" || g === "select" || g === "summary" || g === "textarea" || X), Z = X && y, De = Ke(
171
+ const N = typeof l.type == "string", m = N ? l.type : null, X = m === "a" && typeof n.href == "string", Y = N && !(m === "button" || m === "input" || m === "select" || m === "summary" || m === "textarea" || X), Z = X && h, Ce = je(
172
172
  l,
173
173
  {
174
- "aria-controls": t ? Xe(o["aria-controls"], V) : o["aria-controls"],
175
- "aria-expanded": t,
176
- "aria-haspopup": o["aria-haspopup"] ?? Ze(M),
177
- "aria-disabled": y ? !0 : o["aria-disabled"],
178
- className: [o.className, "nk-popover__trigger"].filter(Boolean).join(" "),
179
- href: Z ? void 0 : o.href,
174
+ "aria-controls": r ? qe(n["aria-controls"], V) : n["aria-controls"],
175
+ "aria-expanded": r,
176
+ "aria-haspopup": n["aria-haspopup"] ?? er(M),
177
+ "aria-disabled": h ? !0 : n["aria-disabled"],
178
+ className: [n.className, "nk-popover__trigger"].filter(Boolean).join(" "),
179
+ href: Z ? void 0 : n.href,
180
180
  id: G,
181
181
  onClick: Oe,
182
- onKeyDown: N ? we : o.onKeyDown,
182
+ onKeyDown: N ? we : n.onKeyDown,
183
183
  ref: Ee,
184
- role: o.role ?? (Z ? "link" : Y ? "button" : void 0),
185
- tabIndex: y ? -1 : o.tabIndex ?? (Y ? 0 : void 0)
184
+ role: n.role ?? (Z ? "link" : Y ? "button" : void 0),
185
+ tabIndex: h ? -1 : n.tabIndex ?? (Y ? 0 : void 0)
186
186
  }
187
187
  );
188
- return /* @__PURE__ */ te(Se, { children: [
189
- De,
188
+ return /* @__PURE__ */ re(Se, { children: [
189
+ Ce,
190
190
  /* @__PURE__ */ T(
191
- re.Provider,
191
+ te.Provider,
192
192
  {
193
- value: t && p ? ke : pe,
194
- children: O.present && i ? /* @__PURE__ */ T(He, { container: k, inheritFrom: c, children: /* @__PURE__ */ te(
195
- Ge,
193
+ value: r && p ? ke : pe,
194
+ children: k.present && s ? /* @__PURE__ */ T(Ue, { children: /* @__PURE__ */ re(
195
+ Qe,
196
196
  {
197
197
  ...fe,
198
198
  ref: Te,
199
- "aria-hidden": t ? void 0 : !0,
200
- "aria-label": t ? q : void 0,
201
- "aria-labelledby": t ? oe ?? (q === void 0 ? G : void 0) : void 0,
199
+ "aria-hidden": r ? void 0 : !0,
200
+ "aria-label": r ? q : void 0,
201
+ "aria-labelledby": r ? oe ?? (q === void 0 ? G : void 0) : void 0,
202
202
  className: ["nk-popover", ae].filter(Boolean).join(" "),
203
203
  "data-placement": (d == null ? void 0 : d.placement) ?? A,
204
- "data-state": O.state === "closing" ? "closing" : "open",
204
+ "data-state": k.state === "closing" ? "closing" : "open",
205
205
  id: V,
206
- role: t ? M : void 0,
206
+ role: r ? M : void 0,
207
207
  style: d ? {
208
208
  ...$,
209
209
  "--nk-popover-arrow-offset": `${d.arrowOffset}px`,
210
210
  left: d.left,
211
211
  top: d.top,
212
- zIndex: D.zIndex
212
+ zIndex: C.zIndex
213
213
  } : {
214
214
  ...$,
215
215
  visibility: "hidden",
216
- zIndex: D.zIndex
216
+ zIndex: C.zIndex
217
217
  },
218
218
  tabIndex: de ?? -1,
219
219
  children: [
220
220
  /* @__PURE__ */ T(
221
- Je,
221
+ We,
222
222
  {
223
- inert: !t,
223
+ inert: !r,
224
224
  panelElement: u
225
225
  }
226
226
  ),
@@ -234,5 +234,5 @@ const ct = Ce(function(s, a) {
234
234
  ] });
235
235
  });
236
236
  export {
237
- ct as default
237
+ dr as default
238
238
  };
package/dist/Radio.cjs CHANGED
@@ -1 +1 @@
1
- "use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const u=require("react/jsx-runtime"),i=require("react"),v=require("./RadioGroupContext-BX9KnDek.cjs"),R=require("./Text-DWYlIcPj.cjs");function C(){const e=i.useContext(v.RadioGroupContext);if(!e)throw new Error("Radio must be rendered within RadioGroup");return e}function m(e,r,t){r.current=e,typeof t=="function"?t(e):t&&(t.current=e)}const _=i.forwardRef(function(r,t){const{children:d,className:f,disabled:p=!1,style:b,value:l,...h}=r,n=C(),c=i.useRef(null),a=n.disabled||p,s=n.value!==void 0,x=n.value===l,k=i.useCallback(o=>m(o,c,t),[t]);return i.useEffect(()=>{var o;!s&&a&&((o=c.current)!=null&&o.checked)&&(c.current.checked=!1)},[s,a]),u.jsxs("label",{className:["nk-radio",f].filter(Boolean).join(" "),"data-disabled":a||void 0,style:b,children:[u.jsx("input",{...h,ref:k,checked:s?!a&&x:void 0,className:"nk-radio__control",defaultChecked:s?void 0:!a&&n.defaultValue===l,disabled:a,name:n.name,onChange:n.onChange,required:n.required,type:"radio",value:l}),u.jsx("span",{"aria-hidden":"true",className:"nk-radio__visual"}),u.jsx(R.Text,{as:"span",className:"nk-radio__label",children:d})]})});exports.default=_;
1
+ "use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("react/jsx-runtime"),r=require("react"),R=require("./aria-Bntn6ad_.cjs"),g=require("./field-control-NfLwcPj6.cjs"),j=require("./Text-DWYlIcPj.cjs"),m=r.createContext(void 0),k=r.forwardRef(function(d,e){const{"aria-invalid":c,children:f,className:p,defaultValue:b,disabled:n=!1,invalid:v=!1,name:a,onChange:u,orientation:o="vertical",required:t=!1,value:h,...x}=d,s=v||R.hasInvalidState(c),C={defaultValue:b,disabled:n,name:a,onChange:u,required:t,value:h};return l.jsx(m.Provider,{value:C,children:l.jsx("div",{...x,ref:e,"aria-disabled":n||void 0,"aria-invalid":R.resolveAriaInvalid(v,c),"aria-required":t||void 0,className:["nk-radio-group",p].filter(Boolean).join(" "),"data-disabled":n||void 0,"data-invalid":s||void 0,"data-orientation":o,role:"radiogroup",children:f})})});g.markFieldGroupControl(k,"group");function q(){const i=r.useContext(m);if(!i)throw new Error("Radio must be rendered within RadioGroup");return i}function _(i,d,e){d.current=i,typeof e=="function"?e(i):e&&(e.current=i)}const G=r.forwardRef(function(d,e){const{children:c,className:f,disabled:p=!1,style:b,value:n,...v}=d,a=q(),u=r.useRef(null),o=a.disabled||p,t=a.value!==void 0,h=a.value===n,x=r.useCallback(s=>_(s,u,e),[e]);return r.useEffect(()=>{var s;!t&&o&&((s=u.current)!=null&&s.checked)&&(u.current.checked=!1)},[t,o]),l.jsxs("label",{className:["nk-radio",f].filter(Boolean).join(" "),"data-disabled":o||void 0,style:b,children:[l.jsx("input",{...v,ref:x,checked:t?!o&&h:void 0,className:"nk-radio__control",defaultChecked:t?void 0:!o&&a.defaultValue===n,disabled:o,name:a.name,onChange:a.onChange,required:a.required,type:"radio",value:n}),l.jsx("span",{"aria-hidden":"true",className:"nk-radio__visual"}),l.jsx(j.Text,{as:"span",className:"nk-radio__label",children:c})]})}),N=Object.assign(G,{Group:k});exports.default=N;
package/dist/Radio.js CHANGED
@@ -1,65 +1,110 @@
1
1
  "use client";
2
- import { jsxs as k, jsx as u } from "react/jsx-runtime";
3
- import { useContext as R, forwardRef as v, useRef as C, useCallback as x, useEffect as _ } from "react";
4
- import { R as N } from "./RadioGroupContext-DbKM4zPZ.js";
5
- import { T as g } from "./Text-rN6iDo0V.js";
6
- function j() {
7
- const e = R(N);
8
- if (!e)
2
+ import { jsx as l, jsxs as g } from "react/jsx-runtime";
3
+ import { createContext as x, forwardRef as b, useContext as G, useRef as N, useCallback as _, useEffect as j } from "react";
4
+ import { r as q, h as I } from "./aria-CeA9QfD1.js";
5
+ import { m as V } from "./field-control-XAn_FKks.js";
6
+ import { T as y } from "./Text-rN6iDo0V.js";
7
+ const k = x(void 0), R = b(
8
+ function(s, a) {
9
+ const {
10
+ "aria-invalid": u,
11
+ children: f,
12
+ className: p,
13
+ defaultValue: v,
14
+ disabled: n = !1,
15
+ invalid: c = !1,
16
+ name: e,
17
+ onChange: d,
18
+ orientation: o = "vertical",
19
+ required: r = !1,
20
+ value: m,
21
+ ...h
22
+ } = s, t = c || I(u), C = {
23
+ defaultValue: v,
24
+ disabled: n,
25
+ name: e,
26
+ onChange: d,
27
+ required: r,
28
+ value: m
29
+ };
30
+ return /* @__PURE__ */ l(k.Provider, { value: C, children: /* @__PURE__ */ l(
31
+ "div",
32
+ {
33
+ ...h,
34
+ ref: a,
35
+ "aria-disabled": n || void 0,
36
+ "aria-invalid": q(c, u),
37
+ "aria-required": r || void 0,
38
+ className: ["nk-radio-group", p].filter(Boolean).join(" "),
39
+ "data-disabled": n || void 0,
40
+ "data-invalid": t || void 0,
41
+ "data-orientation": o,
42
+ role: "radiogroup",
43
+ children: f
44
+ }
45
+ ) });
46
+ }
47
+ );
48
+ V(R, "group");
49
+ function P() {
50
+ const i = G(k);
51
+ if (!i)
9
52
  throw new Error("Radio must be rendered within RadioGroup");
10
- return e;
53
+ return i;
11
54
  }
12
- function y(e, t, a) {
13
- t.current = e, typeof a == "function" ? a(e) : a && (a.current = e);
55
+ function B(i, s, a) {
56
+ s.current = i, typeof a == "function" ? a(i) : a && (a.current = i);
14
57
  }
15
- const V = v(function(t, a) {
58
+ const E = b(function(s, a) {
16
59
  const {
17
- children: c,
18
- className: d,
19
- disabled: f = !1,
20
- style: p,
21
- value: r,
22
- ...m
23
- } = t, o = j(), l = C(null), i = o.disabled || f, n = o.value !== void 0, h = o.value === r, b = x(
24
- (s) => y(
25
- s,
26
- l,
60
+ children: u,
61
+ className: f,
62
+ disabled: p = !1,
63
+ style: v,
64
+ value: n,
65
+ ...c
66
+ } = s, e = P(), d = N(null), o = e.disabled || p, r = e.value !== void 0, m = e.value === n, h = _(
67
+ (t) => B(
68
+ t,
69
+ d,
27
70
  a
28
71
  ),
29
72
  [a]
30
73
  );
31
- return _(() => {
32
- var s;
33
- !n && i && ((s = l.current) != null && s.checked) && (l.current.checked = !1);
34
- }, [n, i]), /* @__PURE__ */ k(
74
+ return j(() => {
75
+ var t;
76
+ !r && o && ((t = d.current) != null && t.checked) && (d.current.checked = !1);
77
+ }, [r, o]), /* @__PURE__ */ g(
35
78
  "label",
36
79
  {
37
- className: ["nk-radio", d].filter(Boolean).join(" "),
38
- "data-disabled": i || void 0,
39
- style: p,
80
+ className: ["nk-radio", f].filter(Boolean).join(" "),
81
+ "data-disabled": o || void 0,
82
+ style: v,
40
83
  children: [
41
- /* @__PURE__ */ u(
84
+ /* @__PURE__ */ l(
42
85
  "input",
43
86
  {
44
- ...m,
45
- ref: b,
46
- checked: n ? !i && h : void 0,
87
+ ...c,
88
+ ref: h,
89
+ checked: r ? !o && m : void 0,
47
90
  className: "nk-radio__control",
48
- defaultChecked: n ? void 0 : !i && o.defaultValue === r,
49
- disabled: i,
50
- name: o.name,
51
- onChange: o.onChange,
52
- required: o.required,
91
+ defaultChecked: r ? void 0 : !o && e.defaultValue === n,
92
+ disabled: o,
93
+ name: e.name,
94
+ onChange: e.onChange,
95
+ required: e.required,
53
96
  type: "radio",
54
- value: r
97
+ value: n
55
98
  }
56
99
  ),
57
- /* @__PURE__ */ u("span", { "aria-hidden": "true", className: "nk-radio__visual" }),
58
- /* @__PURE__ */ u(g, { as: "span", className: "nk-radio__label", children: c })
100
+ /* @__PURE__ */ l("span", { "aria-hidden": "true", className: "nk-radio__visual" }),
101
+ /* @__PURE__ */ l(y, { as: "span", className: "nk-radio__label", children: u })
59
102
  ]
60
103
  }
61
104
  );
105
+ }), O = Object.assign(E, {
106
+ Group: R
62
107
  });
63
108
  export {
64
- V as default
109
+ O as default
65
110
  };
package/dist/Select.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"),i=require("react"),G=require("./aria-DKxpE8cA.cjs"),K=require("./Icon-D8IZceys.cjs"),J=require("./usePresence-qe92UTvK.cjs");function ee(a,n,s){if(a.length===0)return-1;for(let c=1;c<=a.length;c+=1){const v=(n+s*c+a.length)%a.length;if(!a[v].disabled)return v}return-1}function xe(a,n,s){for(let c=1;c<=a.length;c+=1){const v=(s+c+a.length)%a.length,d=a[v];if(!d.disabled&&d.label.toLocaleLowerCase().startsWith(n))return v}return-1}function we(a){const n=new Set;a.forEach(s=>{if(n.has(s.value))throw new Error("Select option values must be unique");n.add(s.value)})}function Ie(a,n,s){n.current=a,typeof s=="function"?s(a):s&&(s.current=a)}function ke(a){const{"aria-invalid":n,children:s,className:c,defaultValue:v,disabled:d=!1,forwardedReference:o,invalid:p=!1,placeholder:x,style:f,value:h,...b}=a,k=G.resolveAriaInvalid(p,n),w=p||G.hasInvalidState(n);return l.jsxs("span",{className:["nk-select",c].filter(Boolean).join(" "),"data-disabled":d||void 0,"data-invalid":w||void 0,"data-mode":"native",style:f,children:[l.jsxs("select",{...b,ref:o,"aria-invalid":k,className:"nk-select__control",defaultValue:h===void 0?v??(x!==void 0?"":void 0):void 0,disabled:d,value:h,children:[x!==void 0?l.jsx("option",{disabled:!0,value:"",children:x}):null,s]}),l.jsx(K.Icon,{className:"nk-select__icon",type:"chevron-down"})]})}function De(a,n,s){const[c,v]=i.useState(null);return i.useEffect(()=>{if(!a||!n){v(null);return}const d=n.ownerDocument.defaultView;if(!d)return;const o=d;function p(){const h=n==null?void 0:n.getBoundingClientRect();if(!h)return;const b=8,k=4,w=o.innerHeight-h.bottom-k-b,E=h.top-k-b,j=w<160&&E>w,D=Math.max(72,j?E:w),y=s==null?void 0:s.getBoundingClientRect(),L=Math.max(h.width,(y==null?void 0:y.width)??h.width),r=Math.min(Math.max(b,h.left),Math.max(b,o.innerWidth-b-L)),R=j?Math.max(b,h.top-k-Math.min((y==null?void 0:y.height)??D,D)):h.bottom+k;v({left:r,maxHeight:D,minWidth:h.width,top:R})}p(),o.addEventListener("resize",p),o.addEventListener("scroll",p,!0);const x=o.ResizeObserver,f=x?new x(p):null;return f==null||f.observe(n),s&&(f==null||f.observe(s)),()=>{o.removeEventListener("resize",p),o.removeEventListener("scroll",p,!0),f==null||f.disconnect()}},[a,s,n]),c}function je(a){const{active:n,closeOnEscape:s,closeOnOutsideInteraction:c,highlightedIndex:v,id:d,listboxReference:o,onEscapeDismiss:p,onEscapeKeyDown:x,onHighlight:f,onOutsideDismiss:h,onPointerDownOutside:b,onSelect:k,options:w,ownerDocument:E,position:j,selectedValue:D,state:y,triggerReference:L}=a,r=i.useRef(null),R=J.useOverlayLayer(!0,E),N=i.useMemo(()=>[L,r],[L]),T=i.useCallback(u=>{r.current=u,o(u)},[o]);return J.useDismissableLayer({active:n,boundaries:N,dismissOnEscape:s,dismissOnPointerDownOutside:c,layerId:R.id,onEscapeDismiss:p,onEscapeKeyDown:x,onPointerDownOutside:b,onPointerDownOutsideDismiss:h,ownerDocument:E}),l.jsx("div",{"aria-hidden":n?void 0:!0,"aria-labelledby":d,className:"nk-select__listbox","data-state":y,id:`${d}-listbox`,ref:T,role:"listbox",style:j?{left:j.left,maxHeight:j.maxHeight,minWidth:j.minWidth,top:j.top,zIndex:R.zIndex}:{visibility:"hidden",zIndex:R.zIndex},children:w.map((u,P)=>l.jsxs("div",{"aria-disabled":u.disabled||void 0,"aria-selected":u.value===D,className:"nk-select__option","data-highlighted":P===v||void 0,"data-selected":u.value===D||void 0,id:`${d}-option-${P}`,onPointerDown:B=>{B.preventDefault(),u.disabled||k(u)},onPointerMove:()=>{u.disabled||f(P)},role:"option",children:[u.icon?l.jsx(K.Icon,{type:u.icon}):null,l.jsx("span",{className:"nk-select__option-label",children:u.label}),u.value===D?l.jsx(K.Icon,{className:"nk-select__check",type:"checkmark"}):null]},u.value))})}function _e(a){var ae;const{"aria-invalid":n,className:s,closeOnEscape:c=!0,closeOnOutsideInteraction:v=!0,defaultValue:d="",disabled:o=!1,displayOverride:p,form:x,forwardedReference:f,id:h,invalid:b=!1,name:k,onChange:w,onClick:E,onEscapeKeyDown:j,onKeyDown:D,onOpenChange:y,onPointerDownOutside:L,options:r,placeholder:R,portalContainer:N,required:T=!1,style:u,value:P,width:B,...ie}=a;we(r);const le=i.useId(),M=h??le,_=i.useRef(null),te=i.useRef(null),V=i.useRef(null),z=i.useRef(""),[W,oe]=i.useState(null),[m,re]=i.useState(!1),[O,q]=i.useState(-1),[ce,ne]=i.useState(d),A=P!==void 0,C=A?P:ce,de=r.find(e=>e.value===C),ue=b||G.hasInvalidState(n),fe=G.resolveAriaInvalid(b,n),X=J.usePresence(m),$=(N==null?void 0:N.ownerDocument)??((ae=_.current)==null?void 0:ae.ownerDocument)??(typeof document>"u"?null:document),he=De(X.present,_.current,W),me=B===void 0?u:{...u,width:B},F=p??de,ve=i.useCallback(e=>{Ie(e,_,f)},[f]),g=i.useCallback(e=>{m!==e&&(re(e),y==null||y(e))},[y,m]),Q=i.useCallback((e=1)=>{const t=r.findIndex(S=>S.value===C&&!S.disabled),I=e===1?-1:r.length;q(t>=0?t:ee(r,I,e)),g(!0)},[r,C,g]),se=i.useCallback(e=>{var t;e.disabled||(A||ne(e.value),g(!1),(t=_.current)==null||t.focus(),w==null||w(e.value))},[A,w,g]),pe=i.useCallback(()=>{var e;g(!1),(e=_.current)==null||e.focus()},[g]),be=i.useCallback(()=>{g(!1)},[g]);function ye(e){E==null||E(e),!(e.defaultPrevented||o)&&(m?g(!1):Q())}function ge(e){if(D==null||D(e),!(e.defaultPrevented||o)){if(e.key==="ArrowDown"||e.key==="ArrowUp"){e.preventDefault();const t=e.key==="ArrowDown"?1:-1;m?q(I=>ee(r,I,t)):Q(t);return}if(e.key==="Home"||e.key==="End"){if(e.preventDefault(),!m)Q(e.key==="Home"?1:-1);else{const t=e.key==="Home"?1:-1,I=t===1?-1:r.length;q(ee(r,I,t))}return}if(e.key==="Enter"||e.key===" "){e.preventDefault();const t=r[O];m&&t?se(t):m||Q();return}if(e.key==="Tab"){g(!1);return}if(e.key.length===1&&!e.altKey&&!e.ctrlKey&&!e.metaKey){const t=e.currentTarget.ownerDocument.defaultView;if(!t)return;const I=e.key.toLocaleLowerCase(),S=z.current+I,Y=Array.from(S).every(Z=>Z===I);z.current=Y?I:S,V.current!==null&&t.clearTimeout(V.current),V.current=t.setTimeout(()=>{z.current="",V.current=null},500);const H=xe(r,z.current,O);H>=0&&(e.preventDefault(),m||g(!0),q(H))}}}return i.useEffect(()=>{var e;if(m&&O>=0){const t=$==null?void 0:$.getElementById(`${M}-option-${O}`);t&&(W!=null&&W.contains(t))&&((e=t.scrollIntoView)==null||e.call(t,{block:"nearest"}))}},[O,M,W,m]),i.useEffect(()=>{var I;const e=(I=_.current)==null?void 0:I.form;if(!e)return;function t(){const S=te.current,Y=A?C:d;if(S){const H=Array.from(S.options),Z=H.find(U=>U.value===Y)??H[0];H.forEach(U=>{U.defaultSelected=U===Z})}A||ne(d),g(!1)}return e.addEventListener("reset",t),()=>e.removeEventListener("reset",t)},[d,x,A,C,g]),i.useEffect(()=>()=>{var t;const e=(t=_.current)==null?void 0:t.ownerDocument.defaultView;e&&V.current!==null&&e.clearTimeout(V.current)},[]),l.jsxs("span",{className:["nk-select",s].filter(Boolean).join(" "),"data-disabled":o||void 0,"data-invalid":ue||void 0,"data-mode":"custom","data-open":m||void 0,style:me,children:[l.jsxs("button",{...ie,ref:ve,"aria-activedescendant":m&&O>=0?`${M}-option-${O}`:void 0,"aria-controls":`${M}-listbox`,"aria-expanded":m,"aria-haspopup":"listbox","aria-invalid":fe,"aria-required":T||void 0,"aria-autocomplete":"none",className:"nk-select__trigger",disabled:o,form:x,id:M,onClick:ye,onKeyDown:ge,role:"combobox",type:"button",children:[F?l.jsxs("span",{className:"nk-select__value",children:[F.icon?l.jsx(K.Icon,{type:F.icon}):null,l.jsx("span",{className:"nk-select__value-label",children:F.label})]}):l.jsx("span",{className:"nk-select__placeholder",children:R}),l.jsx(K.Icon,{className:"nk-select__icon",type:"chevron-down"})]}),k||T?l.jsxs("select",{ref:te,"aria-hidden":"true",className:"nk-select__form-control",disabled:o,form:x,name:k,onChange:()=>{},onInvalid:e=>{var t;e.preventDefault(),(t=_.current)==null||t.focus()},required:T,tabIndex:-1,value:C,children:[l.jsx("option",{value:""}),r.map(e=>l.jsx("option",{disabled:e.disabled,value:e.value,children:e.label},e.value))]}):null,X.present&&$?l.jsx(J.Portal,{container:N,inheritFrom:_.current,children:l.jsx(je,{active:m,closeOnEscape:c,closeOnOutsideInteraction:v,highlightedIndex:O,id:M,listboxReference:oe,onEscapeDismiss:pe,onEscapeKeyDown:j,onHighlight:q,onOutsideDismiss:be,onPointerDownOutside:L,onSelect:se,options:r,ownerDocument:$,position:he,selectedValue:C,state:X.state==="closing"?"closing":"open",triggerReference:_})}):null]})}const Ee=i.forwardRef(function(n,s){const{options:c}=n;return c!==void 0?l.jsx(_e,{...n,forwardedReference:s}):l.jsx(ke,{...n,forwardedReference:s})});exports.default=Ee;
1
+ "use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("react/jsx-runtime"),a=require("react"),J=require("./aria-Bntn6ad_.cjs"),$=require("./Icon-DJ4BigRz.cjs"),O=require("./usePresence-B5RYv4e1.cjs"),ke=require("./floating-position-Cy9xxdH4.cjs"),q=8,B=4,ge=160,Ee=72;function _e(n,t,s){const i=s.bottom-n.bottom-B-q,h=n.top-s.top-B-q,d=i<ge&&h>i,c=Math.max(Ee,d?h:i),m=Math.max(n.width,(t==null?void 0:t.width)??n.width),u=s.left+q,w=Math.min(Math.max(u,n.left),Math.max(u,s.right-q-m)),r=d?Math.max(s.top+q,n.top-B-Math.min((t==null?void 0:t.height)??c,c)):n.bottom+B;return{left:w,maxHeight:c,minWidth:n.width,top:r}}function se(n,t,s){if(n.length===0)return-1;for(let i=1;i<=n.length;i+=1){const h=(t+s*i+n.length)%n.length;if(!n[h].disabled)return h}return-1}function De(n,t,s){for(let i=1;i<=n.length;i+=1){const h=(s+i+n.length)%n.length,d=n[h];if(!d.disabled&&d.label.toLocaleLowerCase().startsWith(t))return h}return-1}function Se(n){const t=new Set;n.forEach(s=>{if(t.has(s.value))throw new Error("Select option values must be unique");t.add(s.value)})}function Re(n,t,s){t.current=n,typeof s=="function"?s(n):s&&(s.current=n)}function je(n){const{"aria-invalid":t,children:s,className:i,defaultValue:h,disabled:d=!1,forwardedReference:c,invalid:m=!1,placeholder:u,style:w,value:r,...k}=n,b=J.resolveAriaInvalid(m,t),x=m||J.hasInvalidState(t);return o.jsxs("span",{className:["nk-select",i].filter(Boolean).join(" "),"data-disabled":d||void 0,"data-invalid":x||void 0,"data-mode":"native",style:w,children:[o.jsxs("select",{...k,ref:c,"aria-invalid":b,className:"nk-select__control",defaultValue:r===void 0?h??(u!==void 0?"":void 0):void 0,disabled:d,value:r,children:[u!==void 0?o.jsx("option",{disabled:!0,value:"",children:u}):null,s]}),o.jsx($.Icon,{className:"nk-select__icon",type:"chevron-down"})]})}function Oe(n,t,s,i){const[h,d]=a.useState(null);return a.useEffect(()=>{if(!n||!t||!i){d(null);return}const c=t.ownerDocument.defaultView;if(!c)return;const m=c;function u(){const k=t==null?void 0:t.getBoundingClientRect(),b=i==null?void 0:i.getBoundingClientRect();if(!k||!b||!i)return;const x=_e(k,s==null?void 0:s.getBoundingClientRect(),ke.getVisibleBounds(b,m.innerWidth,m.innerHeight));d({...x,left:x.left-b.left-i.clientLeft+i.scrollLeft,top:x.top-b.top-i.clientTop+i.scrollTop})}u(),m.addEventListener("scroll",u,!0),m.addEventListener("resize",u);const w=m.ResizeObserver,r=w?new w(u):null;return r==null||r.observe(t),r==null||r.observe(i),s&&(r==null||r.observe(s)),()=>{m.removeEventListener("scroll",u,!0),m.removeEventListener("resize",u),r==null||r.disconnect()}},[n,i,s,t]),h}function Le(n){const{active:t,closeOnEscape:s,closeOnOutsideInteraction:i,highlightedIndex:h,id:d,listboxReference:c,onEscapeDismiss:m,onEscapeKeyDown:u,onHighlight:w,onOutsideDismiss:r,onPointerDownOutside:k,onSelect:b,options:x,ownerDocument:M,position:D,selectedValue:S,state:L,triggerReference:G}=n,v=a.useRef(null),K=O.useBoundary("Select").boundaryElement,R=O.useOverlayLayer(!0,K),U=a.useMemo(()=>[G,v],[G]),X=a.useCallback(f=>{v.current=f,c(f)},[c]);return O.useDismissableLayer({active:t,boundaries:U,boundary:K,dismissOnEscape:s,dismissOnPointerDownOutside:i,layerId:R.id,onEscapeDismiss:m,onEscapeKeyDown:u,onPointerDownOutside:k,onPointerDownOutsideDismiss:r,ownerDocument:M}),o.jsx("div",{"aria-hidden":t?void 0:!0,"aria-labelledby":d,className:"nk-select__listbox","data-state":L,id:`${d}-listbox`,ref:X,role:"listbox",style:D?{left:D.left,maxHeight:D.maxHeight,minWidth:D.minWidth,top:D.top,zIndex:R.zIndex}:{visibility:"hidden",zIndex:R.zIndex},children:x.map((f,H)=>o.jsxs("div",{"aria-disabled":f.disabled||void 0,"aria-selected":f.value===S,className:"nk-select__option","data-highlighted":H===h||void 0,"data-selected":f.value===S||void 0,id:`${d}-option-${H}`,onPointerDown:Z=>{Z.preventDefault(),f.disabled||b(f)},onPointerMove:()=>{f.disabled||w(H)},role:"option",children:[f.icon?o.jsx($.Icon,{type:f.icon}):null,o.jsx("span",{className:"nk-select__option-label",children:f.label}),f.value===S?o.jsx($.Icon,{className:"nk-select__check",type:"checkmark"}):null]},f.value))})}function Pe(n){var oe;const{"aria-invalid":t,className:s,closeOnEscape:i=!0,closeOnOutsideInteraction:h=!0,defaultValue:d="",disabled:c=!1,displayOverride:m,form:u,forwardedReference:w,id:r,invalid:k=!1,name:b,onChange:x,onClick:M,onEscapeKeyDown:D,onKeyDown:S,onOpenChange:L,onPointerDownOutside:G,options:v,placeholder:K,required:R=!1,style:U,value:X,width:f,...H}=n;Se(v);const Z=a.useId(),P=r??Z,g=a.useRef(null),le=a.useRef(null),C=a.useRef(null),F=a.useRef(""),[A,ce]=a.useState(null),[p,re]=a.useState(!1),[E,V]=a.useState(-1),[de,ie]=a.useState(d),N=X!==void 0,j=N?X:de,ue=v.find(e=>e.value===j),fe=k||J.hasInvalidState(t),he=J.resolveAriaInvalid(k,t),ee=O.usePresence(p),W=((oe=g.current)==null?void 0:oe.ownerDocument)??(typeof document>"u"?null:document),me=O.useBoundary("Select").boundaryElement,ve=Oe(ee.present,g.current,A,me),pe=f===void 0?U:{...U,width:f},Q=m??ue,Ie=a.useCallback(e=>{Re(e,g,w)},[w]),I=a.useCallback(e=>{p!==e&&(re(e),L==null||L(e))},[L,p]),z=a.useCallback((e=1)=>{const l=v.findIndex(_=>_.value===j&&!_.disabled),y=e===1?-1:v.length;V(l>=0?l:se(v,y,e)),I(!0)},[v,j,I]),ae=a.useCallback(e=>{var l;c||e.disabled||(N||ie(e.value),I(!1),(l=g.current)==null||l.focus(),x==null||x(e.value))},[c,N,x,I]),xe=a.useCallback(()=>{var e;I(!1),(e=g.current)==null||e.focus()},[I]),ye=a.useCallback(()=>{I(!1)},[I]);function we(e){M==null||M(e),!(e.defaultPrevented||c)&&(p?I(!1):z())}function be(e){if(S==null||S(e),!(e.defaultPrevented||c)){if(e.key==="ArrowDown"||e.key==="ArrowUp"){e.preventDefault();const l=e.key==="ArrowDown"?1:-1;p?V(y=>se(v,y,l)):z(l);return}if(e.key==="Home"||e.key==="End"){if(e.preventDefault(),!p)z(e.key==="Home"?1:-1);else{const l=e.key==="Home"?1:-1,y=l===1?-1:v.length;V(se(v,y,l))}return}if(e.key==="Enter"||e.key===" "){e.preventDefault();const l=v[E];p&&l?ae(l):p||z();return}if(e.key==="Tab"){I(!1);return}if(e.key.length===1&&!e.altKey&&!e.ctrlKey&&!e.metaKey){const l=e.currentTarget.ownerDocument.defaultView;if(!l)return;const y=e.key.toLocaleLowerCase(),_=F.current+y,te=Array.from(_).every(ne=>ne===y);F.current=te?y:_,C.current!==null&&l.clearTimeout(C.current),C.current=l.setTimeout(()=>{F.current="",C.current=null},500);const T=De(v,F.current,E);T>=0&&(e.preventDefault(),p||I(!0),V(T))}}}return a.useEffect(()=>{c&&I(!1)},[c,I]),a.useEffect(()=>{var e;if(p&&E>=0){const l=W==null?void 0:W.getElementById(`${P}-option-${E}`);l&&(A!=null&&A.contains(l))&&((e=l.scrollIntoView)==null||e.call(l,{block:"nearest"}))}},[E,P,A,p]),a.useEffect(()=>{var y;const e=(y=g.current)==null?void 0:y.form;if(!e)return;function l(){const _=le.current,te=N?j:d;if(_){const T=Array.from(_.options),ne=T.find(Y=>Y.value===te)??T[0];T.forEach(Y=>{Y.defaultSelected=Y===ne})}N||ie(d),I(!1)}return e.addEventListener("reset",l),()=>e.removeEventListener("reset",l)},[d,u,N,j,I]),a.useEffect(()=>()=>{var l;const e=(l=g.current)==null?void 0:l.ownerDocument.defaultView;e&&C.current!==null&&e.clearTimeout(C.current)},[]),o.jsxs("span",{className:["nk-select",s].filter(Boolean).join(" "),"data-disabled":c||void 0,"data-invalid":fe||void 0,"data-mode":"custom","data-open":p||void 0,style:pe,children:[o.jsxs("button",{...H,ref:Ie,"aria-activedescendant":p&&E>=0?`${P}-option-${E}`:void 0,"aria-controls":`${P}-listbox`,"aria-expanded":p,"aria-haspopup":"listbox","aria-invalid":he,"aria-required":R||void 0,"aria-autocomplete":"none",className:"nk-select__trigger",disabled:c,form:u,id:P,onClick:we,onKeyDown:be,role:"combobox",type:"button",children:[Q?o.jsxs("span",{className:"nk-select__value",children:[Q.icon?o.jsx($.Icon,{type:Q.icon}):null,o.jsx("span",{className:"nk-select__value-label",children:Q.label})]}):o.jsx("span",{className:"nk-select__placeholder",children:K}),o.jsx($.Icon,{className:"nk-select__icon",type:"chevron-down"})]}),b||R?o.jsxs("select",{ref:le,"aria-hidden":"true",className:"nk-select__form-control",disabled:c,form:u,name:b,onChange:()=>{},onInvalid:e=>{var l;e.preventDefault(),(l=g.current)==null||l.focus()},required:R,tabIndex:-1,value:j,children:[o.jsx("option",{value:""}),v.map(e=>o.jsx("option",{disabled:e.disabled,value:e.value,children:e.label},e.value))]}):null,ee.present&&W?o.jsx(O.Portal,{children:o.jsx(Le,{active:p,closeOnEscape:i,closeOnOutsideInteraction:h,highlightedIndex:E,id:P,listboxReference:ce,onEscapeDismiss:xe,onEscapeKeyDown:D,onHighlight:V,onOutsideDismiss:ye,onPointerDownOutside:G,onSelect:ae,options:v,ownerDocument:W,position:ve,selectedValue:j,state:ee.state==="closing"?"closing":"open",triggerReference:g})}):null]})}const Ce=a.forwardRef(function(t,s){const{options:i}=t;return O.useBoundary("Select"),i!==void 0?o.jsx(Pe,{...t,forwardedReference:s}):o.jsx(je,{...t,forwardedReference:s})});exports.default=Ce;