neatkit 0.10.0 → 0.12.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 (105) hide show
  1. package/dist/Boundary.cjs +1 -1
  2. package/dist/Boundary.js +191 -120
  3. package/dist/{Button-CVe9T_Zw.cjs → Button-6oWs-pyF.cjs} +1 -1
  4. package/dist/{Button-D6rXvcqq.js → Button-B0E-M8mp.js} +1 -1
  5. package/dist/Button.cjs +1 -1
  6. package/dist/Button.js +1 -1
  7. package/dist/Card.cjs +1 -1
  8. package/dist/Card.js +75 -2
  9. package/dist/Checkbox.cjs +1 -1
  10. package/dist/Checkbox.js +2 -2
  11. package/dist/Code-f0GWveGp.cjs +4 -0
  12. package/dist/{Code-Bp2X1k-g.js → Code-pROJjsiG.js} +57 -58
  13. package/dist/Code.cjs +1 -1
  14. package/dist/Code.js +1 -1
  15. package/dist/Field.cjs +1 -1
  16. package/dist/Field.js +57 -62
  17. package/dist/Icon-BFaHVAoQ.cjs +1 -0
  18. package/dist/{Icon-CxK1wlGk.js → Icon-Cj1s40xn.js} +308 -96
  19. package/dist/Icon.cjs +1 -1
  20. package/dist/Icon.js +1 -1
  21. package/dist/Input.cjs +1 -1
  22. package/dist/Input.js +2 -2
  23. package/dist/Markdown.cjs +1 -1
  24. package/dist/Markdown.js +76 -75
  25. package/dist/Modal.cjs +1 -1
  26. package/dist/Modal.js +4 -4
  27. package/dist/PinInput.cjs +1 -1
  28. package/dist/PinInput.js +228 -192
  29. package/dist/Popover.cjs +1 -1
  30. package/dist/Popover.js +117 -119
  31. package/dist/Radio.cjs +1 -1
  32. package/dist/Radio.js +1 -1
  33. package/dist/Select.cjs +1 -1
  34. package/dist/Select.js +12 -11
  35. package/dist/Sidebar.cjs +1 -1
  36. package/dist/Sidebar.js +441 -309
  37. package/dist/Switch.cjs +1 -1
  38. package/dist/Switch.js +1 -1
  39. package/dist/{Table-DutHfiXR.js → Table-B2G8CHJ9.js} +111 -108
  40. package/dist/Table-Z8Q6XRkc.cjs +1 -0
  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/Card/Card.d.ts +22 -23
  53. package/dist/components/Card/components/CardBody.d.ts +24 -0
  54. package/dist/components/Card/components/CardFooter.d.ts +24 -0
  55. package/dist/components/Card/components/CardHeader.d.ts +24 -0
  56. package/dist/components/Card/index.d.ts +1 -1
  57. package/dist/components/Code/Code.d.ts +9 -7
  58. package/dist/components/Code/index.d.ts +1 -1
  59. package/dist/components/Icon/icons/AppleIcon.d.ts +11 -0
  60. package/dist/components/Icon/icons/BingIcon.d.ts +11 -0
  61. package/dist/components/Icon/icons/ChainIcon.d.ts +11 -0
  62. package/dist/components/Icon/icons/FacebookIcon.d.ts +11 -0
  63. package/dist/components/Icon/icons/GoogleIcon.d.ts +11 -0
  64. package/dist/components/Icon/icons/InstagramIcon.d.ts +11 -0
  65. package/dist/components/Icon/icons/MicrosoftIcon.d.ts +11 -0
  66. package/dist/components/Icon/icons/TwitterIcon.d.ts +11 -0
  67. package/dist/components/Icon/utils/registry.d.ts +8 -0
  68. package/dist/components/PinInput/PinInput.d.ts +1 -1
  69. package/dist/components/PinInput/hooks/usePinInput.d.ts +1 -1
  70. package/dist/components/Radio/Radio.d.ts +1 -1
  71. package/dist/components/Sidebar/Sidebar.d.ts +5 -0
  72. package/dist/components/Sidebar/components/SidebarFallbackTrigger.d.ts +32 -0
  73. package/dist/components/Sidebar/components/SidebarFooter.d.ts +5 -0
  74. package/dist/components/Sidebar/components/SidebarPanel.d.ts +1 -1
  75. package/dist/components/Sidebar/components/SidebarTrigger.d.ts +4 -0
  76. package/dist/components/Sidebar/hooks/useContentBelow.d.ts +23 -0
  77. package/dist/components/Sidebar/utils/children.d.ts +16 -0
  78. package/dist/components/Table/Table.d.ts +8 -2
  79. package/dist/components/Table/index.d.ts +1 -1
  80. package/dist/effects-D98vUn6N.cjs +1 -0
  81. package/dist/effects-DGbA6Q2O.js +18 -0
  82. package/dist/style.css +1 -1
  83. package/dist/useFloatingPosition-DQgw-w_Z.cjs +1 -0
  84. package/dist/useFloatingPosition-MGoyautY.js +57 -0
  85. package/dist/{useFocusTrap-C0IcCdNf.js → useFocusTrap-BxPazAL6.js} +1 -1
  86. package/dist/{useFocusTrap-gAK_402D.cjs → useFocusTrap-CrMcAu8s.cjs} +1 -1
  87. package/dist/{usePresence-CqegYqy4.js → usePresence-BTRY1_l-.js} +47 -56
  88. package/dist/usePresence-Dm0mls5p.cjs +1 -0
  89. package/dist/utils/aria.d.ts +4 -5
  90. package/dist/utils/trigger.d.ts +46 -0
  91. package/package.json +1 -1
  92. package/dist/Card-CPq6dsut.js +0 -34
  93. package/dist/Card-CQ-8_1tO.cjs +0 -1
  94. package/dist/Code-B7s_rN0G.cjs +0 -4
  95. package/dist/Icon-BIBzgznI.cjs +0 -1
  96. package/dist/Table-BqWBgMTU.cjs +0 -1
  97. package/dist/Tooltip-CCuE-hfp.cjs +0 -1
  98. package/dist/Tooltip-CeyRKNv4.js +0 -231
  99. package/dist/aria-Bntn6ad_.cjs +0 -1
  100. package/dist/aria-CeA9QfD1.js +0 -15
  101. package/dist/effects-D5CWf-Pl.js +0 -8
  102. package/dist/effects-D85L_7zM.cjs +0 -1
  103. package/dist/useFloatingPosition-Dq8xpr3E.js +0 -27
  104. package/dist/useFloatingPosition-g5kXywoB.cjs +0 -1
  105. package/dist/usePresence-B5RYv4e1.cjs +0 -1
package/dist/Sidebar.js CHANGED
@@ -1,272 +1,373 @@
1
1
  "use client";
2
- import { jsx as d, jsxs as A, Fragment as K } from "react/jsx-runtime";
3
- import { useCallback as k, useSyncExternalStore as X, forwardRef as I, useId as Y, createElement as ae, useContext as se, useRef as B, useState as Z, Fragment as ie, cloneElement as oe, useMemo as Q, useEffect as le } from "react";
4
- import { u as R } from "./effects-D5CWf-Pl.js";
5
- import { g as ce, a as ee } from "./reference-CXMr27nM.js";
6
- import { b as z, F as V, d as de, e as ue, c as pe, P as be } from "./usePresence-CqegYqy4.js";
7
- import { T as U } from "./Text-rN6iDo0V.js";
8
- import { B as ne } from "./Button-D6rXvcqq.js";
9
- import { u as fe } from "./useFocusTrap-C0IcCdNf.js";
10
- import { u as me } from "./useScrollLock-Drd7OZRC.js";
11
- import { m as ve } from "./aria-CeA9QfD1.js";
12
- import { A as he } from "./Avatar-DjDCFqNG.js";
13
- import { S as ge } from "./Spinner-CmxlDlOk.js";
14
- import { T as ye } from "./Tooltip-CeyRKNv4.js";
15
- import { b as Se } from "./units-BmjPCccF.js";
16
- const L = /* @__PURE__ */ new WeakMap();
17
- function re(t) {
18
- const n = L.get(t);
2
+ import { jsx as p, jsxs as D, Fragment as $ } from "react/jsx-runtime";
3
+ import { useCallback as _, useSyncExternalStore as le, forwardRef as R, useId as ce, createElement as ye, useState as w, useRef as I, Children as Se, isValidElement as re, Fragment as de, cloneElement as z, useContext as _e, useMemo as te, useEffect as ae } from "react";
4
+ import { u as K, a as M } from "./effects-DGbA6Q2O.js";
5
+ import { g as Ee, a as ue } from "./reference-CXMr27nM.js";
6
+ import { F as se, c as ke, d as Ce, b as Ne, P as oe } from "./usePresence-BTRY1_l-.js";
7
+ import { B as Y } from "./Button-B0E-M8mp.js";
8
+ import { T as V } from "./Text-rN6iDo0V.js";
9
+ import { u as Pe } from "./useFocusTrap-BxPazAL6.js";
10
+ import { u as Te } from "./useScrollLock-Drd7OZRC.js";
11
+ import { m as Ie } from "./aria-Bv-xVREf.js";
12
+ import { r as Le } from "./useFloatingPosition-MGoyautY.js";
13
+ import { A as Re } from "./Avatar-DjDCFqNG.js";
14
+ import { S as Be } from "./Spinner-CmxlDlOk.js";
15
+ import { T as Oe } from "./Tooltip-CpyROf6x.js";
16
+ import { b as Fe } from "./units-BmjPCccF.js";
17
+ function xe(t) {
18
+ const { label: n, onToggle: e, panelId: r, reference: u, side: l, sidebarOpen: o } = t;
19
+ return /* @__PURE__ */ p(
20
+ Y,
21
+ {
22
+ ref: u,
23
+ "aria-controls": r,
24
+ "aria-expanded": o,
25
+ "aria-haspopup": "dialog",
26
+ "aria-label": n,
27
+ className: "nk-sidebar__fallback-trigger",
28
+ "data-side": l,
29
+ icon: "burger",
30
+ onClick: e
31
+ }
32
+ );
33
+ }
34
+ const H = /* @__PURE__ */ new WeakMap();
35
+ function fe(t) {
36
+ const n = H.get(t);
19
37
  if (n) return n;
20
38
  const e = {
21
39
  listeners: /* @__PURE__ */ new Set(),
22
40
  owner: null,
23
41
  state: void 0
24
42
  };
25
- return L.set(t, e), e;
43
+ return H.set(t, e), e;
26
44
  }
27
- function _e(t, n, e) {
28
- const r = re(t);
29
- return r.owner !== null && r.owner !== n ? !1 : (r.owner = n, r.state = e, r.listeners.forEach((b) => b()), !0);
45
+ function De(t, n, e) {
46
+ const r = fe(t);
47
+ return r.owner !== null && r.owner !== n ? !1 : (r.owner = n, r.state = e, r.listeners.forEach((u) => u()), !0);
30
48
  }
31
- function ke(t, n) {
32
- const e = L.get(t);
49
+ function we(t, n) {
50
+ const e = H.get(t);
33
51
  !e || e.owner !== n || (e.owner = null, e.state = void 0, e.listeners.forEach((r) => r()));
34
52
  }
35
- function Ee(t) {
53
+ function Ae(t) {
36
54
  var n;
37
- return t ? (n = L.get(t)) == null ? void 0 : n.state : void 0;
55
+ return t ? (n = H.get(t)) == null ? void 0 : n.state : void 0;
38
56
  }
39
- function Ne(t, n) {
57
+ function je(t, n) {
40
58
  if (!t) return () => {
41
59
  };
42
- const e = re(t);
60
+ const e = fe(t);
43
61
  return e.listeners.add(n), () => {
44
62
  e.listeners.delete(n);
45
63
  };
46
64
  }
47
- const Pe = () => {
65
+ const Me = () => {
48
66
  };
49
- function T(t) {
50
- const n = z(t).boundaryElement, e = k(
51
- (b) => Ne(n, b),
67
+ function A(t) {
68
+ const n = K(t).boundaryElement, e = _(
69
+ (u) => je(n, u),
52
70
  [n]
53
- ), r = k(() => Ee(n), [n]);
54
- return X(e, r, Pe);
71
+ ), r = _(() => Ae(n), [n]);
72
+ return le(e, r, Me);
55
73
  }
56
- function x(t, n) {
74
+ function U(t, n) {
57
75
  return t === "both" || t === (n === "overlay" ? "overlay" : "inline");
58
76
  }
59
- const we = I(
77
+ const be = R(
60
78
  function(n, e) {
61
- const { children: r, className: b, presentation: o = "both", ...u } = n, a = T("Sidebar.Footer");
62
- return x(o, a == null ? void 0 : a.presentation) ? /* @__PURE__ */ d(
79
+ const { children: r, className: u, presentation: l = "both", ...o } = n, a = A("Sidebar.Footer");
80
+ return U(l, a == null ? void 0 : a.presentation) ? /* @__PURE__ */ p(
63
81
  "div",
64
82
  {
65
- ...u,
83
+ ...o,
66
84
  ref: e,
67
- className: ["nk-sidebar__footer", b].filter(Boolean).join(" "),
85
+ className: ["nk-sidebar__footer", u].filter(Boolean).join(" "),
68
86
  children: r
69
87
  }
70
88
  ) : null;
71
89
  }
72
- ), Ie = I(
90
+ ), He = R(
73
91
  function(n, e) {
74
92
  const {
75
93
  "aria-label": r,
76
- "aria-labelledby": b,
77
- children: o,
78
- className: u,
94
+ "aria-labelledby": u,
95
+ children: l,
96
+ className: o,
79
97
  label: a,
80
- presentation: y = "both",
81
- ...m
82
- } = n, h = T("Sidebar.Group"), v = `${Y()}-label`, p = a != null && typeof a != "boolean" && (typeof a != "string" || a.trim() !== "");
83
- if (!x(y, h == null ? void 0 : h.presentation))
98
+ presentation: v = "both",
99
+ ...f
100
+ } = n, y = A("Sidebar.Group"), i = `${ce()}-label`, b = a != null && typeof a != "boolean" && (typeof a != "string" || a.trim() !== "");
101
+ if (!U(v, y == null ? void 0 : y.presentation))
84
102
  return null;
85
- const i = b ?? (r === void 0 && p ? v : void 0);
86
- return ae(
87
- !!(r ?? i) ? "nav" : "div",
103
+ const c = u ?? (r === void 0 && b ? i : void 0);
104
+ return ye(
105
+ !!(r ?? c) ? "nav" : "div",
88
106
  {
89
- ...m,
107
+ ...f,
90
108
  ref: e,
91
109
  "aria-label": r,
92
- "aria-labelledby": i,
93
- className: ["nk-sidebar__group", u].filter(Boolean).join(" ")
110
+ "aria-labelledby": c,
111
+ className: ["nk-sidebar__group", o].filter(Boolean).join(" ")
94
112
  },
95
- p ? /* @__PURE__ */ d(
96
- U,
113
+ b ? /* @__PURE__ */ p(
114
+ V,
97
115
  {
98
116
  as: "h2",
99
117
  className: "nk-sidebar__group-label",
100
- id: v,
118
+ id: i,
101
119
  size: "subtitle",
102
120
  weight: "medium",
103
121
  children: a
104
122
  }
105
123
  ) : null,
106
- /* @__PURE__ */ d("ul", { className: "nk-sidebar__list", children: o })
124
+ /* @__PURE__ */ p("ul", { className: "nk-sidebar__list", children: l })
107
125
  );
108
126
  }
109
- ), Oe = I(
127
+ ), Ue = R(
110
128
  function(n, e) {
111
- const { children: r, className: b, presentation: o = "both", ...u } = n, a = T("Sidebar.Header");
112
- return x(o, a == null ? void 0 : a.presentation) ? /* @__PURE__ */ d(
129
+ const { children: r, className: u, presentation: l = "both", ...o } = n, a = A("Sidebar.Header");
130
+ return U(l, a == null ? void 0 : a.presentation) ? /* @__PURE__ */ p(
113
131
  "div",
114
132
  {
115
- ...u,
133
+ ...o,
116
134
  ref: e,
117
- className: ["nk-sidebar__header", b].filter(Boolean).join(" "),
135
+ className: ["nk-sidebar__header", u].filter(Boolean).join(" "),
118
136
  children: r
119
137
  }
120
138
  ) : null;
121
139
  }
122
- ), Be = I(
140
+ ), Ge = R(
123
141
  function(n, e) {
124
142
  const {
125
143
  active: r = !1,
126
- as: b,
127
- children: o,
128
- className: u,
144
+ as: u,
145
+ children: l,
146
+ className: o,
129
147
  disabled: a = !1,
130
- icon: y,
131
- onClick: m,
132
- presentation: h = "both",
133
- type: v,
134
- ...p
135
- } = n, i = T("Sidebar.Item"), s = b ?? "button", l = s === "button", c = p, S = c.href !== void 0 || c.to !== void 0;
136
- function f(_) {
148
+ icon: v,
149
+ onClick: f,
150
+ presentation: y = "both",
151
+ type: i,
152
+ ...b
153
+ } = n, c = A("Sidebar.Item"), s = u ?? "button", d = s === "button", m = b, E = m.href !== void 0 || m.to !== void 0;
154
+ function g(S) {
137
155
  if (a) {
138
- _.preventDefault();
156
+ S.preventDefault();
139
157
  return;
140
158
  }
141
- m == null || m(_), i != null && i.open && i.presentation === "overlay" && !_.defaultPrevented && i.requestOpenChange(!1, "item");
159
+ f == null || f(S), c != null && c.open && c.presentation === "overlay" && !S.defaultPrevented && c.requestOpenChange(!1, "item");
142
160
  }
143
- return x(h, i == null ? void 0 : i.presentation) ? /* @__PURE__ */ d("li", { className: "nk-sidebar__item-container", children: /* @__PURE__ */ d(
144
- ne,
161
+ return U(y, c == null ? void 0 : c.presentation) ? /* @__PURE__ */ p("li", { className: "nk-sidebar__item-container", children: /* @__PURE__ */ p(
162
+ Y,
145
163
  {
146
- ...p,
164
+ ...b,
147
165
  ref: e,
148
- "aria-current": r ? S ? "page" : "true" : void 0,
166
+ "aria-current": r ? E ? "page" : "true" : void 0,
149
167
  as: s,
150
- className: ["nk-sidebar__item", u].filter(Boolean).join(" "),
168
+ className: ["nk-sidebar__item", o].filter(Boolean).join(" "),
151
169
  "data-active": r || void 0,
152
170
  disabled: a,
153
171
  fullWidth: !0,
154
- href: c.href,
155
- icon: y,
156
- onClick: f,
172
+ href: m.href,
173
+ icon: v,
174
+ onClick: g,
157
175
  shape: "rectangle",
158
176
  textAlignment: "left",
159
- type: l ? v ?? "button" : v,
177
+ type: d ? i ?? "button" : i,
160
178
  variant: "ghost",
161
- children: /* @__PURE__ */ d("span", { className: "nk-sidebar__item-label", children: o })
179
+ children: /* @__PURE__ */ p("span", { className: "nk-sidebar__item-label", children: l })
162
180
  }
163
181
  ) }) : null;
164
182
  }
165
- );
166
- function te(t) {
183
+ ), qe = 1;
184
+ function $e(t) {
185
+ return t == null ? void 0 : t.ResizeObserver;
186
+ }
187
+ function ze(t) {
188
+ return t == null ? void 0 : t.MutationObserver;
189
+ }
190
+ function Ve() {
191
+ const [t, n] = w(!1), e = I(null), r = _((o) => {
192
+ const a = o.scrollHeight - o.scrollTop - o.clientHeight;
193
+ n(a > qe);
194
+ }, []), u = _((o) => {
195
+ var m;
196
+ if ((m = e.current) == null || m.call(e), e.current = null, !o) return;
197
+ const a = o;
198
+ r(a);
199
+ function v() {
200
+ r(a);
201
+ }
202
+ const f = a.ownerDocument.defaultView;
203
+ f == null || f.addEventListener("resize", v);
204
+ const y = $e(f), i = y ? new y(v) : void 0;
205
+ function b() {
206
+ i == null || i.disconnect(), i == null || i.observe(a);
207
+ for (const E of a.children)
208
+ i == null || i.observe(E);
209
+ }
210
+ b();
211
+ function c(E) {
212
+ E.some(
213
+ (S) => S.type === "childList"
214
+ ) && b(), v();
215
+ }
216
+ const s = ze(f), d = s ? new s(c) : void 0;
217
+ d == null || d.observe(a, {
218
+ attributeFilter: ["class", "hidden", "style"],
219
+ characterData: !0,
220
+ childList: !0,
221
+ subtree: !0
222
+ }), e.current = () => {
223
+ f == null || f.removeEventListener("resize", v), i == null || i.disconnect(), d == null || d.disconnect();
224
+ };
225
+ }, [r]), l = _((o) => {
226
+ r(o.currentTarget);
227
+ }, [r]);
228
+ return { containerReference: u, contentBelow: t, handleScroll: l };
229
+ }
230
+ function Ke(t, n) {
231
+ for (const e of Se.toArray(t)) {
232
+ if (re(e) && e.type === de) {
233
+ const r = pe(e.props.children);
234
+ r.bodyChildren.length > 0 && n.bodyChildren.push(z(
235
+ e,
236
+ void 0,
237
+ ...r.bodyChildren
238
+ )), r.footerChildren.length > 0 && n.footerChildren.push(z(
239
+ e,
240
+ void 0,
241
+ ...r.footerChildren
242
+ ));
243
+ continue;
244
+ }
245
+ re(e) && e.type === be ? n.footerChildren.push(e) : n.bodyChildren.push(e);
246
+ }
247
+ }
248
+ function pe(t) {
249
+ const n = {
250
+ bodyChildren: [],
251
+ footerChildren: []
252
+ };
253
+ return Ke(t, n), n;
254
+ }
255
+ function me(t) {
167
256
  const {
168
257
  "aria-label": n,
169
258
  "aria-labelledby": e,
170
259
  children: r,
171
- className: b,
172
- height: o,
173
- open: u,
260
+ className: u,
261
+ height: l,
262
+ open: o,
174
263
  panelId: a,
175
- panelReference: y,
176
- presentation: m,
177
- side: h,
178
- state: v,
179
- style: p,
180
- width: i,
264
+ panelReference: v,
265
+ presentation: f,
266
+ side: y,
267
+ state: i,
268
+ style: b,
269
+ width: c,
181
270
  ...s
182
- } = t, l = m === "overlay", c = n ?? (e === void 0 ? "Sidebar" : void 0), S = l && u;
183
- let f = p;
184
- return (i !== void 0 || o !== void 0) && (f = { ...p }, o !== void 0 && (f["--nk-sidebar-height"] = o), i !== void 0 && (f["--nk-sidebar-width"] = i)), /* @__PURE__ */ d(
271
+ } = t, { containerReference: d, contentBelow: m, handleScroll: E } = Ve(), g = f === "overlay", { bodyChildren: S, footerChildren: B } = pe(r), O = n ?? (e === void 0 ? "Sidebar" : void 0), L = g && o;
272
+ let P = b;
273
+ return (c !== void 0 || l !== void 0) && (P = { ...b }, l !== void 0 && (P["--nk-sidebar-height"] = l), c !== void 0 && (P["--nk-sidebar-width"] = c)), /* @__PURE__ */ D(
185
274
  "aside",
186
275
  {
187
276
  ...s,
188
- ref: y,
189
- "aria-hidden": l && !u ? !0 : void 0,
190
- "aria-label": l && !u ? void 0 : c,
191
- "aria-labelledby": l && !u ? void 0 : e,
192
- "aria-modal": S ? "true" : void 0,
193
- className: ["nk-sidebar", b].filter(Boolean).join(" "),
194
- "data-responsive": m === "pending" || void 0,
195
- "data-side": h,
196
- "data-state": v,
197
- "data-variant": l ? "overlay" : "inline",
277
+ ref: v,
278
+ "aria-hidden": g && !o ? !0 : void 0,
279
+ "aria-label": g && !o ? void 0 : O,
280
+ "aria-labelledby": g && !o ? void 0 : e,
281
+ "aria-modal": L ? "true" : void 0,
282
+ className: ["nk-sidebar", u].filter(Boolean).join(" "),
283
+ "data-responsive": f === "pending" || void 0,
284
+ "data-side": y,
285
+ "data-state": i,
286
+ "data-variant": g ? "overlay" : "inline",
198
287
  id: a,
199
- role: S ? "dialog" : void 0,
200
- style: f,
201
- tabIndex: l ? -1 : void 0,
202
- children: /* @__PURE__ */ d("div", { className: "nk-sidebar__body", children: r })
288
+ role: L ? "dialog" : void 0,
289
+ style: P,
290
+ tabIndex: g ? -1 : void 0,
291
+ children: [
292
+ /* @__PURE__ */ p(
293
+ "div",
294
+ {
295
+ ref: d,
296
+ className: "nk-sidebar__body",
297
+ "data-content-below": m || void 0,
298
+ onScroll: E,
299
+ children: S
300
+ }
301
+ ),
302
+ B
303
+ ]
203
304
  }
204
305
  );
205
306
  }
206
- function Te(t) {
307
+ function Ye(t) {
207
308
  const {
208
309
  boundaries: n,
209
310
  initialFocusReference: e,
210
311
  lockScroll: r,
211
- ownerDocument: b,
212
- panelReference: o,
213
- presenceState: u,
312
+ ownerDocument: u,
313
+ panelReference: l,
314
+ presenceState: o,
214
315
  restoreFocus: a,
215
- sidebar: y,
216
- side: m,
217
- ...h
218
- } = t, { id: v, open: p, requestOpenChange: i } = y, s = se(V), l = B(null), [c, S] = Z(null), f = z("Sidebar").boundaryElement, _ = de(!0, f), C = k((E) => {
219
- l.current = E, o(E), S(E);
220
- }, [o]);
221
- R(() => {
222
- c && (c.inert = !p);
223
- }, [p, c]);
224
- const D = k(() => {
225
- i(!1, "escape");
226
- }, [i]), N = k(() => {
227
- i(!1, "outside");
228
- }, [i]);
229
- ue({
230
- boundary: f,
231
- active: p,
316
+ sidebar: v,
317
+ side: f,
318
+ ...y
319
+ } = t, { id: i, open: b, requestOpenChange: c } = v, s = _e(se), d = I(null), [m, E] = w(null), g = K("Sidebar").boundaryElement, S = ke(!0, g), B = _((F) => {
320
+ d.current = F, l(F), E(F);
321
+ }, [l]);
322
+ M(() => {
323
+ m && (m.inert = !b);
324
+ }, [b, m]);
325
+ const O = _(() => {
326
+ c(!1, "escape");
327
+ }, [c]), L = _(() => {
328
+ c(!1, "outside");
329
+ }, [c]);
330
+ Ce({
331
+ boundary: g,
332
+ active: b,
232
333
  boundaries: n,
233
334
  dismissOnEscape: !0,
234
335
  dismissOnPointerDownOutside: !0,
235
- layerId: _.id,
236
- onEscapeDismiss: D,
237
- onPointerDownOutsideDismiss: N,
238
- ownerDocument: b
336
+ layerId: S.id,
337
+ onEscapeDismiss: O,
338
+ onPointerDownOutsideDismiss: L,
339
+ ownerDocument: u
239
340
  });
240
- const P = fe({
241
- boundary: f,
242
- active: p,
243
- container: c,
244
- initialFocusReference: e ?? l,
245
- layerId: _.id,
341
+ const P = Pe({
342
+ boundary: g,
343
+ active: b,
344
+ container: m,
345
+ initialFocusReference: e ?? d,
346
+ layerId: S.id,
246
347
  restoreFocus: a
247
348
  });
248
- return me(r && p, b, f), /* @__PURE__ */ d(
249
- V.Provider,
349
+ return Te(r && b, u, g), /* @__PURE__ */ p(
350
+ se.Provider,
250
351
  {
251
- value: p ? P : s,
252
- children: /* @__PURE__ */ d(
352
+ value: b ? P : s,
353
+ children: /* @__PURE__ */ p(
253
354
  "div",
254
355
  {
255
356
  className: "nk-sidebar__overlay",
256
- "data-side": m,
257
- "data-state": u,
357
+ "data-side": f,
358
+ "data-state": o,
258
359
  role: "presentation",
259
- style: { zIndex: _.zIndex },
260
- children: /* @__PURE__ */ d(
261
- te,
360
+ style: { zIndex: S.zIndex },
361
+ children: /* @__PURE__ */ p(
362
+ me,
262
363
  {
263
- ...h,
264
- open: p,
265
- panelId: v,
266
- panelReference: C,
364
+ ...y,
365
+ open: b,
366
+ panelId: i,
367
+ panelReference: B,
267
368
  presentation: "overlay",
268
- side: m,
269
- state: u
369
+ side: f,
370
+ state: o
270
371
  }
271
372
  )
272
373
  }
@@ -274,217 +375,248 @@ function Te(t) {
274
375
  }
275
376
  );
276
377
  }
277
- function Fe(t) {
378
+ function Je(t) {
278
379
  const { children: n } = t;
279
- if (n.type === ie)
380
+ if (n.type === de)
280
381
  throw new Error("Sidebar.Trigger requires a single non-Fragment child");
281
- const e = T("Sidebar.Trigger"), r = n.props, b = ce(n), o = e == null ? void 0 : e.registerTrigger, u = e == null ? void 0 : e.unregisterTrigger, a = B(null), y = k((l) => {
282
- const c = a.current;
283
- c && c !== l && (u == null || u(c)), a.current = l, l && (o == null || o(l)), ee(b, l);
284
- }, [b, o, u]), m = k((l) => {
285
- var c;
286
- (c = r.onClick) == null || c.call(r, l), !(l.defaultPrevented || !e) && e.requestOpenChange(!e.open, "trigger");
287
- }, [r, e]);
382
+ const e = A("Sidebar.Trigger"), r = n.props, u = Ee(n), l = e == null ? void 0 : e.registerTrigger, o = e == null ? void 0 : e.unregisterTrigger, a = I(null), v = _((d) => {
383
+ const m = a.current;
384
+ m && m !== d && (o == null || o(m)), a.current = d, d && (l == null || l(d)), ue(u, d);
385
+ }, [u, l, o]), f = _((d) => {
386
+ d.defaultPrevented || !e || e.requestOpenChange(!e.open, "trigger");
387
+ }, [e]);
288
388
  if (!e) return null;
289
- const { id: h, open: v, presentation: p, variant: i } = e;
290
- return oe(
389
+ const { id: y, open: i, presentation: b, variant: c } = e;
390
+ return z(
291
391
  n,
292
- {
293
- "aria-controls": v && p === "overlay" ? ve(r["aria-controls"], h) : r["aria-controls"],
294
- "aria-expanded": v,
392
+ Le(r, {
393
+ "aria-controls": i && b === "overlay" ? Ie(r["aria-controls"], y) : r["aria-controls"],
394
+ "aria-expanded": i,
295
395
  "aria-haspopup": r["aria-haspopup"] ?? "dialog",
296
- className: [r.className, "nk-sidebar__trigger"].filter(Boolean).join(" "),
297
- "data-sidebar-variant": i,
298
- onClick: m,
299
- ref: y
300
- }
396
+ className: "nk-sidebar__trigger",
397
+ "data-sidebar-variant": c,
398
+ onClick: f,
399
+ ref: v
400
+ })
301
401
  );
302
402
  }
303
- const Re = I(
403
+ const Qe = R(
304
404
  function(n, e) {
305
405
  const {
306
406
  actions: r,
307
- className: b,
308
- description: o,
309
- image: u,
407
+ className: u,
408
+ description: l,
409
+ image: o,
310
410
  loading: a = !1,
311
- name: y,
312
- onClick: m,
313
- ...h
314
- } = n, v = o != null && typeof o != "boolean", p = /* @__PURE__ */ A(K, { children: [
315
- /* @__PURE__ */ d(
316
- he,
411
+ name: v,
412
+ onClick: f,
413
+ ...y
414
+ } = n, i = l != null && typeof l != "boolean", b = /* @__PURE__ */ D($, { children: [
415
+ /* @__PURE__ */ p(
416
+ Re,
317
417
  {
318
- alt: y,
418
+ alt: v,
319
419
  "aria-hidden": !0,
320
420
  className: "nk-sidebar__user-avatar",
321
- image: u
421
+ image: o
322
422
  }
323
423
  ),
324
- /* @__PURE__ */ A("span", { className: "nk-sidebar__user-text", children: [
325
- /* @__PURE__ */ d(U, { as: "span", className: "nk-sidebar__user-name", children: y }),
326
- v ? /* @__PURE__ */ d(
327
- U,
424
+ /* @__PURE__ */ D("span", { className: "nk-sidebar__user-text", children: [
425
+ /* @__PURE__ */ p(V, { as: "span", className: "nk-sidebar__user-name", children: v }),
426
+ i ? /* @__PURE__ */ p(
427
+ V,
328
428
  {
329
429
  as: "span",
330
430
  className: "nk-sidebar__user-description",
331
431
  size: "caption",
332
432
  tone: "muted",
333
- children: o
433
+ children: l
334
434
  }
335
435
  ) : null
336
436
  ] })
337
437
  ] });
338
- return /* @__PURE__ */ d(
438
+ return /* @__PURE__ */ p(
339
439
  "div",
340
440
  {
341
- ...h,
441
+ ...y,
342
442
  ref: e,
343
- className: ["nk-sidebar__user", b].filter(Boolean).join(" "),
344
- children: a ? /* @__PURE__ */ d(ge, { className: "nk-sidebar__user-spinner", size: 16 }) : /* @__PURE__ */ A(K, { children: [
345
- m ? /* @__PURE__ */ d(
443
+ className: ["nk-sidebar__user", u].filter(Boolean).join(" "),
444
+ children: a ? /* @__PURE__ */ p(Be, { className: "nk-sidebar__user-spinner", size: 16 }) : /* @__PURE__ */ D($, { children: [
445
+ f ? /* @__PURE__ */ p(
346
446
  "button",
347
447
  {
348
448
  className: "nk-sidebar__user-details",
349
- onClick: m,
449
+ onClick: f,
350
450
  type: "button",
351
- children: p
451
+ children: b
352
452
  }
353
- ) : /* @__PURE__ */ d("div", { className: "nk-sidebar__user-details", children: p }),
354
- r !== void 0 && r.length > 0 ? /* @__PURE__ */ d("div", { className: "nk-sidebar__user-actions", children: r.map((i) => {
453
+ ) : /* @__PURE__ */ p("div", { className: "nk-sidebar__user-details", children: b }),
454
+ r !== void 0 && r.length > 0 ? /* @__PURE__ */ p("div", { className: "nk-sidebar__user-actions", children: r.map((c) => {
355
455
  const {
356
456
  "aria-label": s,
357
- icon: l,
358
- label: c,
359
- ...S
360
- } = i;
361
- return /* @__PURE__ */ d(ye, { content: c, children: /* @__PURE__ */ d(
362
- ne,
457
+ icon: d,
458
+ label: m,
459
+ ...E
460
+ } = c;
461
+ return /* @__PURE__ */ p(Oe, { content: m, children: /* @__PURE__ */ p(
462
+ Y,
363
463
  {
364
- ...S,
365
- "aria-label": s ?? c,
464
+ ...E,
465
+ "aria-label": s ?? m,
366
466
  className: "nk-sidebar__user-action",
367
- icon: l,
467
+ icon: d,
368
468
  shape: "rectangle",
369
469
  type: "button",
370
470
  variant: "ghost"
371
471
  }
372
- ) }, c);
472
+ ) }, m);
373
473
  }) }) : null
374
474
  ] })
375
475
  }
376
476
  );
377
477
  }
378
- ), Le = () => () => {
379
- }, W = () => {
478
+ ), Xe = () => () => {
479
+ }, ie = () => {
380
480
  };
381
- function xe(t, n) {
382
- const e = t === "responsive" ? n : void 0, r = X(
383
- (e == null ? void 0 : e.subscribe) ?? Le,
384
- (e == null ? void 0 : e.read) ?? W,
385
- W
481
+ function Ze(t, n) {
482
+ const e = t === "responsive" ? n : void 0, r = le(
483
+ (e == null ? void 0 : e.subscribe) ?? Xe,
484
+ (e == null ? void 0 : e.read) ?? ie,
485
+ ie
386
486
  );
387
- return t !== "responsive" ? t : r === void 0 ? "pending" : r >= Se("md") ? "inline" : "overlay";
487
+ return t !== "responsive" ? t : r === void 0 ? "pending" : r >= Fe("md") ? "inline" : "overlay";
388
488
  }
389
- const Ce = I(function(n, e) {
390
- var J;
489
+ const We = 32, en = R(function(n, e) {
490
+ var ne;
391
491
  const {
392
492
  defaultOpen: r = !1,
393
- height: b,
394
- initialFocusReference: o,
395
- lockScroll: u = !0,
493
+ height: u,
494
+ initialFocusReference: l,
495
+ lockScroll: o = !0,
396
496
  onOpenChange: a,
397
- open: y,
398
- restoreFocus: m = !0,
399
- side: h = "start",
400
- variant: v = "responsive",
401
- width: p,
402
- ...i
403
- } = n, s = z("Sidebar"), l = `${Y()}-sidebar`, c = B(Symbol("nk-sidebar")).current, S = B(null), f = xe(v, s == null ? void 0 : s.width), _ = y !== void 0, [C, D] = Z(r), N = _ ? y : C, P = B(a);
404
- R(() => {
405
- P.current = a;
497
+ open: v,
498
+ restoreFocus: f = !0,
499
+ side: y = "left",
500
+ variant: i = "responsive",
501
+ width: b,
502
+ ...c
503
+ } = n, s = K("Sidebar"), d = `${ce()}-sidebar`, m = I(Symbol("nk-sidebar")).current, E = I(null), g = Ze(i, s == null ? void 0 : s.width), S = v !== void 0, [B, O] = w(r), [L, P] = w(0), [F, he] = w(!1), J = I(null), T = S ? v : B, j = I(a);
504
+ M(() => {
505
+ j.current = a;
406
506
  });
407
- const E = k((g, O) => {
408
- var F;
409
- N !== g && (_ || D(g), (F = P.current) == null || F.call(P, g, O));
410
- }, [_, N]), G = k((g) => {
411
- S.current = g, ee(e, g);
412
- }, [e]), w = Q(
413
- () => [S],
507
+ const x = _((h, k) => {
508
+ var C;
509
+ T !== h && (S || O(h), (C = j.current) == null || C.call(j, h, k));
510
+ }, [S, T]), Q = _((h) => {
511
+ E.current = h, ue(e, h);
512
+ }, [e]), N = te(
513
+ () => [E],
414
514
  []
415
- ), q = k((g) => {
416
- w.push({ current: g });
417
- }, [w]), H = k((g) => {
418
- const O = w.findIndex((F) => F.current === g);
419
- O > 0 && w.splice(O, 1);
420
- }, [w]), j = Q(() => ({
421
- id: l,
422
- open: N,
423
- presentation: f,
424
- registerTrigger: q,
425
- requestOpenChange: E,
426
- unregisterTrigger: H,
427
- variant: v
515
+ ), X = _((h) => {
516
+ N.push({ current: h }), P((k) => k + 1);
517
+ }, [N]), Z = _((h) => {
518
+ const k = N.findIndex((C) => C.current === h);
519
+ k > 0 && N.splice(k, 1), P((C) => Math.max(C - 1, 0));
520
+ }, [N]), ge = _((h) => {
521
+ const k = J.current;
522
+ if (k && k !== h) {
523
+ const C = N.findIndex((ve) => ve.current === k);
524
+ C > 0 && N.splice(C, 1);
525
+ }
526
+ J.current = h, h && N.push({ current: h });
527
+ }, [N]), G = te(() => ({
528
+ id: d,
529
+ open: T,
530
+ presentation: g,
531
+ registerTrigger: X,
532
+ requestOpenChange: x,
533
+ unregisterTrigger: Z,
534
+ variant: i
428
535
  }), [
429
- N,
430
- l,
431
- f,
432
- q,
433
- E,
434
- H,
435
- v
536
+ T,
537
+ d,
538
+ g,
539
+ X,
540
+ x,
541
+ Z,
542
+ i
436
543
  ]);
437
- R(() => {
438
- const g = s == null ? void 0 : s.boundaryElement;
439
- if (!g) return;
440
- if (_e(g, c, j) === !1)
544
+ M(() => {
545
+ const h = s == null ? void 0 : s.boundaryElement;
546
+ if (!h) return;
547
+ if (De(h, m, G) === !1)
441
548
  throw new Error(
442
549
  "A Boundary supports one Sidebar. Neatkit resolves Trigger, Group, and Item interactions against the single Sidebar published to the nearest Boundary, so give each Sidebar a Boundary of its own."
443
550
  );
444
- }, [s == null ? void 0 : s.boundaryElement, c, j]), R(() => {
445
- const g = s == null ? void 0 : s.boundaryElement;
446
- if (g)
447
- return () => ke(g, c);
448
- }, [s == null ? void 0 : s.boundaryElement, c]), le(() => {
449
- f === "inline" && E(!1, "variant");
450
- }, [f, E]);
451
- const M = pe(N && f === "overlay"), $ = ((J = s == null ? void 0 : s.boundaryElement) == null ? void 0 : J.ownerDocument) ?? (typeof document > "u" ? null : document);
452
- return f !== "overlay" ? /* @__PURE__ */ d(
453
- te,
454
- {
455
- ...i,
456
- height: b,
457
- open: !1,
458
- panelId: l,
459
- panelReference: G,
460
- presentation: f,
461
- side: h,
462
- width: p
463
- }
464
- ) : !M.present || !$ ? null : /* @__PURE__ */ d(be, { children: /* @__PURE__ */ d(
465
- Te,
551
+ }, [s == null ? void 0 : s.boundaryElement, m, G]), M(() => {
552
+ const h = s == null ? void 0 : s.boundaryElement;
553
+ if (h)
554
+ return () => we(h, m);
555
+ }, [s == null ? void 0 : s.boundaryElement, m]), ae(() => {
556
+ g === "inline" && x(!1, "variant");
557
+ }, [g, x]), ae(() => {
558
+ var C;
559
+ const h = (C = s == null ? void 0 : s.boundaryElement) == null ? void 0 : C.ownerDocument.defaultView;
560
+ if (!h) return;
561
+ const k = h.setTimeout(
562
+ () => he(!0),
563
+ We
564
+ );
565
+ return () => h.clearTimeout(k);
566
+ }, [s == null ? void 0 : s.boundaryElement]);
567
+ const q = Ne(T && g === "overlay"), W = ((ne = s == null ? void 0 : s.boundaryElement) == null ? void 0 : ne.ownerDocument) ?? (typeof document > "u" ? null : document);
568
+ if (g !== "overlay")
569
+ return /* @__PURE__ */ p(
570
+ me,
571
+ {
572
+ ...c,
573
+ height: u,
574
+ open: !1,
575
+ panelId: d,
576
+ panelReference: Q,
577
+ presentation: g,
578
+ side: y,
579
+ width: b
580
+ }
581
+ );
582
+ const ee = F && L === 0 ? /* @__PURE__ */ p(oe, { children: /* @__PURE__ */ p(
583
+ xe,
466
584
  {
467
- ...i,
468
- boundaries: w,
469
- initialFocusReference: o,
470
- lockScroll: u,
471
- ownerDocument: $,
472
- panelReference: G,
473
- presenceState: M.state === "closing" ? "closing" : "open",
474
- restoreFocus: m,
475
- side: h,
476
- sidebar: j,
477
- width: p
585
+ label: `Open ${c["aria-label"] ?? "Sidebar"}`,
586
+ onToggle: () => x(!T, "trigger"),
587
+ panelId: q.present ? d : void 0,
588
+ reference: ge,
589
+ side: y,
590
+ sidebarOpen: T
478
591
  }
479
- ) });
480
- }), We = Object.assign(Ce, {
481
- Footer: we,
482
- Group: Ie,
483
- Header: Oe,
484
- Item: Be,
485
- Trigger: Fe,
486
- User: Re
592
+ ) }) : null;
593
+ return !q.present || !W ? ee : /* @__PURE__ */ D($, { children: [
594
+ ee,
595
+ /* @__PURE__ */ p(oe, { children: /* @__PURE__ */ p(
596
+ Ye,
597
+ {
598
+ ...c,
599
+ boundaries: N,
600
+ initialFocusReference: l,
601
+ lockScroll: o,
602
+ ownerDocument: W,
603
+ panelReference: Q,
604
+ presenceState: q.state === "closing" ? "closing" : "open",
605
+ restoreFocus: f,
606
+ side: y,
607
+ sidebar: G,
608
+ width: b
609
+ }
610
+ ) })
611
+ ] });
612
+ }), gn = Object.assign(en, {
613
+ Footer: be,
614
+ Group: He,
615
+ Header: Ue,
616
+ Item: Ge,
617
+ Trigger: Je,
618
+ User: Qe
487
619
  });
488
620
  export {
489
- We as default
621
+ gn as default
490
622
  };