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