neatkit 0.9.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/dist/Boundary.cjs +1 -1
  2. package/dist/Boundary.js +191 -120
  3. package/dist/{Button-DU4j_IED.cjs → Button-DtrX4X-s.cjs} +1 -1
  4. package/dist/{Button-BV5OUXpc.js → Button-LmEHdRkW.js} +2 -2
  5. package/dist/Button.cjs +1 -1
  6. package/dist/Button.js +1 -1
  7. package/dist/Checkbox.cjs +1 -1
  8. package/dist/Checkbox.js +112 -111
  9. package/dist/Field.cjs +1 -1
  10. package/dist/Field.js +57 -62
  11. package/dist/Icon-CMSHMSDJ.cjs +1 -0
  12. package/dist/{Icon-CxK1wlGk.js → Icon-NT3kRJYz.js} +275 -94
  13. package/dist/Icon.cjs +1 -1
  14. package/dist/Icon.js +1 -1
  15. package/dist/Input.cjs +1 -1
  16. package/dist/Input.js +53 -52
  17. package/dist/Markdown.cjs +1 -1
  18. package/dist/Markdown.js +1 -1
  19. package/dist/Modal.cjs +1 -1
  20. package/dist/Modal.js +58 -57
  21. package/dist/PinInput.cjs +1 -1
  22. package/dist/PinInput.js +89 -88
  23. package/dist/Popover.cjs +1 -1
  24. package/dist/Popover.js +117 -119
  25. package/dist/Progress.cjs +1 -0
  26. package/dist/Progress.js +40 -0
  27. package/dist/Radio.cjs +1 -1
  28. package/dist/Radio.js +48 -47
  29. package/dist/Select.cjs +1 -1
  30. package/dist/Select.js +364 -359
  31. package/dist/Sidebar.cjs +1 -1
  32. package/dist/Sidebar.js +381 -332
  33. package/dist/Spinner-BE0F4y2S.cjs +1 -0
  34. package/dist/Spinner-CmxlDlOk.js +23 -0
  35. package/dist/Spinner.cjs +1 -1
  36. package/dist/Spinner.js +1 -1
  37. package/dist/Switch.cjs +1 -1
  38. package/dist/Switch.js +1 -1
  39. package/dist/{Table-qetwZpTC.cjs → Table-Bjw9lUKS.cjs} +1 -1
  40. package/dist/{Table-CADupJEU.js → Table-GeoE4h-u.js} +2 -2
  41. package/dist/Table.cjs +1 -1
  42. package/dist/Table.js +1 -1
  43. package/dist/TextArea.cjs +1 -1
  44. package/dist/TextArea.js +1 -1
  45. package/dist/Tooltip-CpyROf6x.js +225 -0
  46. package/dist/Tooltip-DDPh_YFO.cjs +1 -0
  47. package/dist/Tooltip.cjs +1 -1
  48. package/dist/Tooltip.js +1 -1
  49. package/dist/aria-Bv-xVREf.js +17 -0
  50. package/dist/aria-DM-xYEHQ.cjs +1 -0
  51. package/dist/components/Boundary/hooks/useDocumentBackground.d.ts +28 -0
  52. package/dist/components/Icon/icons/AppleIcon.d.ts +11 -0
  53. package/dist/components/Icon/icons/BingIcon.d.ts +11 -0
  54. package/dist/components/Icon/icons/FacebookIcon.d.ts +11 -0
  55. package/dist/components/Icon/icons/GoogleIcon.d.ts +11 -0
  56. package/dist/components/Icon/icons/InstagramIcon.d.ts +11 -0
  57. package/dist/components/Icon/icons/MicrosoftIcon.d.ts +11 -0
  58. package/dist/components/Icon/icons/TwitterIcon.d.ts +11 -0
  59. package/dist/components/Icon/utils/registry.d.ts +7 -0
  60. package/dist/components/PinInput/PinInput.d.ts +1 -1
  61. package/dist/components/Portal/hooks/useAnchoredPosition.d.ts +59 -0
  62. package/dist/components/Progress/Progress.d.ts +38 -0
  63. package/dist/components/Progress/index.d.ts +2 -0
  64. package/dist/components/Progress/utils/value.d.ts +25 -0
  65. package/dist/components/Radio/Radio.d.ts +1 -1
  66. package/dist/components/Select/Select.d.ts +6 -74
  67. package/dist/components/Select/components/CustomSelect.d.ts +59 -0
  68. package/dist/components/Select/components/NativeSelect.d.ts +26 -0
  69. package/dist/components/Select/components/SelectListbox.d.ts +50 -0
  70. package/dist/components/Select/hooks/useSelectFormReset.d.ts +27 -0
  71. package/dist/components/Select/hooks/useSelectPosition.d.ts +12 -0
  72. package/dist/components/Select/hooks/useTypeahead.d.ts +14 -0
  73. package/dist/components/Select/utils/options.d.ts +38 -0
  74. package/dist/components/Sidebar/Sidebar.d.ts +30 -24
  75. package/dist/components/Sidebar/components/SidebarFallbackTrigger.d.ts +32 -0
  76. package/dist/components/Sidebar/components/SidebarOverlay.d.ts +3 -4
  77. package/dist/components/Sidebar/components/SidebarPanel.d.ts +3 -3
  78. package/dist/components/Sidebar/components/SidebarTrigger.d.ts +4 -0
  79. package/dist/effects-D98vUn6N.cjs +1 -0
  80. package/dist/effects-DGbA6Q2O.js +18 -0
  81. package/dist/style.css +1 -1
  82. package/dist/useAnchoredPosition-C0VS7hm6.js +105 -0
  83. package/dist/useAnchoredPosition-D7GRFzoX.cjs +1 -0
  84. package/dist/useFloatingPosition-DQgw-w_Z.cjs +1 -0
  85. package/dist/useFloatingPosition-MGoyautY.js +57 -0
  86. package/dist/useFocusTrap-BxPazAL6.js +136 -0
  87. package/dist/useFocusTrap-CrMcAu8s.cjs +1 -0
  88. package/dist/{usePresence-CqegYqy4.js → usePresence-BTRY1_l-.js} +47 -56
  89. package/dist/usePresence-Dm0mls5p.cjs +1 -0
  90. package/dist/utils/aria.d.ts +4 -5
  91. package/dist/utils/trigger.d.ts +46 -0
  92. package/package.json +6 -1
  93. package/dist/Icon-BIBzgznI.cjs +0 -1
  94. package/dist/Spinner-BXgw60UC.cjs +0 -1
  95. package/dist/Spinner-CVYvk6YK.js +0 -25
  96. package/dist/Tooltip-B2d5ss7S.cjs +0 -1
  97. package/dist/Tooltip-BK64rkxV.js +0 -231
  98. package/dist/aria-Bntn6ad_.cjs +0 -1
  99. package/dist/aria-CeA9QfD1.js +0 -15
  100. package/dist/effects-D5CWf-Pl.js +0 -8
  101. package/dist/effects-D85L_7zM.cjs +0 -1
  102. package/dist/floating-position-DIjh2wnP.cjs +0 -1
  103. package/dist/floating-position-DvR6e334.js +0 -50
  104. package/dist/useFloatingPosition-B3ZC-v3v.js +0 -43
  105. package/dist/useFloatingPosition-GzkP9dCc.cjs +0 -1
  106. package/dist/useFocusTrap-BrFZdMqQ.cjs +0 -1
  107. package/dist/useFocusTrap-DhVnlboe.js +0 -136
  108. package/dist/usePresence-B5RYv4e1.cjs +0 -1
package/dist/Sidebar.js CHANGED
@@ -1,272 +1,290 @@
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-BV5OUXpc.js";
9
- import { u as fe } from "./useFocusTrap-DhVnlboe.js";
10
- import { u as me } from "./useScrollLock-Drd7OZRC.js";
11
- import { m as ve } from "./aria-CeA9QfD1.js";
12
- import { A as ge } from "./Avatar-DjDCFqNG.js";
13
- import { S as he } from "./Spinner-CVYvk6YK.js";
14
- import { T as ye } from "./Tooltip-BK64rkxV.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);
19
- if (n) return n;
2
+ import { jsx as l, jsxs as R, Fragment as H } from "react/jsx-runtime";
3
+ import { useCallback as k, useSyncExternalStore as ie, forwardRef as O, useId as oe, createElement as fe, useContext as me, useRef as I, useState as C, Fragment as ge, cloneElement as ve, useMemo as re, useEffect as ne } from "react";
4
+ import { u as W, a as D } from "./effects-DGbA6Q2O.js";
5
+ import { g as he, a as le } from "./reference-CXMr27nM.js";
6
+ import { F as ae, c as ye, d as Se, b as _e, P as te } from "./usePresence-BTRY1_l-.js";
7
+ import { B as K } from "./Button-LmEHdRkW.js";
8
+ import { T as $ } from "./Text-rN6iDo0V.js";
9
+ import { u as ke } from "./useFocusTrap-BxPazAL6.js";
10
+ import { u as Ee } from "./useScrollLock-Drd7OZRC.js";
11
+ import { m as Ne } from "./aria-Bv-xVREf.js";
12
+ import { r as Pe } from "./useFloatingPosition-MGoyautY.js";
13
+ import { A as we } from "./Avatar-DjDCFqNG.js";
14
+ import { S as Ie } from "./Spinner-CmxlDlOk.js";
15
+ import { T as Oe } from "./Tooltip-CpyROf6x.js";
16
+ import { b as Te } from "./units-BmjPCccF.js";
17
+ function Be(a) {
18
+ const { label: r, onToggle: e, panelId: n, reference: u, side: i, sidebarOpen: c } = a;
19
+ return /* @__PURE__ */ l(
20
+ K,
21
+ {
22
+ ref: u,
23
+ "aria-controls": n,
24
+ "aria-expanded": c,
25
+ "aria-haspopup": "dialog",
26
+ "aria-label": r,
27
+ className: "nk-sidebar__fallback-trigger",
28
+ "data-side": i,
29
+ icon: "burger",
30
+ onClick: e
31
+ }
32
+ );
33
+ }
34
+ const A = /* @__PURE__ */ new WeakMap();
35
+ function ce(a) {
36
+ const r = A.get(a);
37
+ if (r) return r;
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 A.set(a, 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 Fe(a, r, e) {
46
+ const n = ce(a);
47
+ return n.owner !== null && n.owner !== r ? !1 : (n.owner = r, n.state = e, n.listeners.forEach((u) => u()), !0);
30
48
  }
31
- function ke(t, n) {
32
- const e = L.get(t);
33
- !e || e.owner !== n || (e.owner = null, e.state = void 0, e.listeners.forEach((r) => r()));
49
+ function xe(a, r) {
50
+ const e = A.get(a);
51
+ !e || e.owner !== r || (e.owner = null, e.state = void 0, e.listeners.forEach((n) => n()));
34
52
  }
35
- function Ee(t) {
36
- var n;
37
- return t ? (n = L.get(t)) == null ? void 0 : n.state : void 0;
53
+ function Le(a) {
54
+ var r;
55
+ return a ? (r = A.get(a)) == null ? void 0 : r.state : void 0;
38
56
  }
39
- function Ne(t, n) {
40
- if (!t) return () => {
57
+ function Re(a, r) {
58
+ if (!a) return () => {
41
59
  };
42
- const e = re(t);
43
- return e.listeners.add(n), () => {
44
- e.listeners.delete(n);
60
+ const e = ce(a);
61
+ return e.listeners.add(r), () => {
62
+ e.listeners.delete(r);
45
63
  };
46
64
  }
47
- const Pe = () => {
65
+ const Ce = () => {
48
66
  };
49
- function T(t) {
50
- const n = z(t).boundaryElement, e = k(
51
- (b) => Ne(n, b),
52
- [n]
53
- ), r = k(() => Ee(n), [n]);
54
- return X(e, r, Pe);
67
+ function F(a) {
68
+ const r = W(a).boundaryElement, e = k(
69
+ (u) => Re(r, u),
70
+ [r]
71
+ ), n = k(() => Le(r), [r]);
72
+ return ie(e, n, Ce);
55
73
  }
56
- function x(t, n) {
57
- return t === "both" || t === (n === "overlay" ? "overlay" : "inline");
74
+ function j(a, r) {
75
+ return a === "both" || a === (r === "overlay" ? "overlay" : "inline");
58
76
  }
59
- const we = I(
60
- 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(
77
+ const De = O(
78
+ function(r, e) {
79
+ const { children: n, className: u, presentation: i = "both", ...c } = r, s = F("Sidebar.Footer");
80
+ return j(i, s == null ? void 0 : s.presentation) ? /* @__PURE__ */ l(
63
81
  "div",
64
82
  {
65
- ...u,
83
+ ...c,
66
84
  ref: e,
67
- className: ["nk-sidebar__footer", b].filter(Boolean).join(" "),
68
- children: r
85
+ className: ["nk-sidebar__footer", u].filter(Boolean).join(" "),
86
+ children: n
69
87
  }
70
88
  ) : null;
71
89
  }
72
- ), Ie = I(
73
- function(n, e) {
90
+ ), Ae = O(
91
+ function(r, e) {
74
92
  const {
75
- "aria-label": r,
76
- "aria-labelledby": b,
77
- children: o,
78
- className: u,
79
- label: a,
93
+ "aria-label": n,
94
+ "aria-labelledby": u,
95
+ children: i,
96
+ className: c,
97
+ label: s,
80
98
  presentation: y = "both",
81
- ...m
82
- } = n, g = T("Sidebar.Group"), v = `${Y()}-label`, p = a != null && typeof a != "boolean" && (typeof a != "string" || a.trim() !== "");
83
- if (!x(y, g == null ? void 0 : g.presentation))
99
+ ...g
100
+ } = r, h = F("Sidebar.Group"), v = `${oe()}-label`, b = s != null && typeof s != "boolean" && (typeof s != "string" || s.trim() !== "");
101
+ if (!j(y, h == null ? void 0 : h.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 o = u ?? (n === void 0 && b ? v : void 0);
104
+ return fe(
105
+ !!(n ?? o) ? "nav" : "div",
88
106
  {
89
- ...m,
107
+ ...g,
90
108
  ref: e,
91
- "aria-label": r,
92
- "aria-labelledby": i,
93
- className: ["nk-sidebar__group", u].filter(Boolean).join(" ")
109
+ "aria-label": n,
110
+ "aria-labelledby": o,
111
+ className: ["nk-sidebar__group", c].filter(Boolean).join(" ")
94
112
  },
95
- p ? /* @__PURE__ */ d(
96
- U,
113
+ b ? /* @__PURE__ */ l(
114
+ $,
97
115
  {
98
116
  as: "h2",
99
117
  className: "nk-sidebar__group-label",
100
118
  id: v,
101
119
  size: "subtitle",
102
120
  weight: "medium",
103
- children: a
121
+ children: s
104
122
  }
105
123
  ) : null,
106
- /* @__PURE__ */ d("ul", { className: "nk-sidebar__list", children: o })
124
+ /* @__PURE__ */ l("ul", { className: "nk-sidebar__list", children: i })
107
125
  );
108
126
  }
109
- ), Oe = I(
110
- 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(
127
+ ), je = O(
128
+ function(r, e) {
129
+ const { children: n, className: u, presentation: i = "both", ...c } = r, s = F("Sidebar.Header");
130
+ return j(i, s == null ? void 0 : s.presentation) ? /* @__PURE__ */ l(
113
131
  "div",
114
132
  {
115
- ...u,
133
+ ...c,
116
134
  ref: e,
117
- className: ["nk-sidebar__header", b].filter(Boolean).join(" "),
118
- children: r
135
+ className: ["nk-sidebar__header", u].filter(Boolean).join(" "),
136
+ children: n
119
137
  }
120
138
  ) : null;
121
139
  }
122
- ), Be = I(
123
- function(n, e) {
140
+ ), Ue = O(
141
+ function(r, e) {
124
142
  const {
125
- active: r = !1,
126
- as: b,
127
- children: o,
128
- className: u,
129
- disabled: a = !1,
143
+ active: n = !1,
144
+ as: u,
145
+ children: i,
146
+ className: c,
147
+ disabled: s = !1,
130
148
  icon: y,
131
- onClick: m,
132
- presentation: g = "both",
149
+ onClick: g,
150
+ presentation: h = "both",
133
151
  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(_) {
137
- if (a) {
138
- _.preventDefault();
152
+ ...b
153
+ } = r, o = F("Sidebar.Item"), t = u ?? "button", d = t === "button", f = b, E = f.href !== void 0 || f.to !== void 0;
154
+ function m(N) {
155
+ if (s) {
156
+ N.preventDefault();
139
157
  return;
140
158
  }
141
- m == null || m(_), i != null && i.open && i.presentation === "overlay" && !_.defaultPrevented && i.requestOpenChange(!1, "item");
159
+ g == null || g(N), o != null && o.open && o.presentation === "overlay" && !N.defaultPrevented && o.requestOpenChange(!1, "item");
142
160
  }
143
- return x(g, i == null ? void 0 : i.presentation) ? /* @__PURE__ */ d("li", { className: "nk-sidebar__item-container", children: /* @__PURE__ */ d(
144
- ne,
161
+ return j(h, o == null ? void 0 : o.presentation) ? /* @__PURE__ */ l("li", { className: "nk-sidebar__item-container", children: /* @__PURE__ */ l(
162
+ K,
145
163
  {
146
- ...p,
164
+ ...b,
147
165
  ref: e,
148
- "aria-current": r ? S ? "page" : "true" : void 0,
149
- as: s,
150
- className: ["nk-sidebar__item", u].filter(Boolean).join(" "),
151
- "data-active": r || void 0,
152
- disabled: a,
166
+ "aria-current": n ? E ? "page" : "true" : void 0,
167
+ as: t,
168
+ className: ["nk-sidebar__item", c].filter(Boolean).join(" "),
169
+ "data-active": n || void 0,
170
+ disabled: s,
153
171
  fullWidth: !0,
154
- href: c.href,
172
+ href: f.href,
155
173
  icon: y,
156
- onClick: f,
174
+ onClick: m,
157
175
  shape: "rectangle",
158
176
  textAlignment: "left",
159
- type: l ? v ?? "button" : v,
177
+ type: d ? v ?? "button" : v,
160
178
  variant: "ghost",
161
- children: /* @__PURE__ */ d("span", { className: "nk-sidebar__item-label", children: o })
179
+ children: /* @__PURE__ */ l("span", { className: "nk-sidebar__item-label", children: i })
162
180
  }
163
181
  ) }) : null;
164
182
  }
165
183
  );
166
- function te(t) {
184
+ function de(a) {
167
185
  const {
168
- "aria-label": n,
186
+ "aria-label": r,
169
187
  "aria-labelledby": e,
170
- children: r,
171
- className: b,
172
- top: o,
173
- open: u,
174
- panelId: a,
188
+ children: n,
189
+ className: u,
190
+ height: i,
191
+ open: c,
192
+ panelId: s,
175
193
  panelReference: y,
176
- presentation: m,
177
- side: g,
194
+ presentation: g,
195
+ side: h,
178
196
  state: v,
179
- style: p,
180
- width: i,
181
- ...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-top-offset"] = o), i !== void 0 && (f["--nk-sidebar-width"] = i)), /* @__PURE__ */ d(
197
+ style: b,
198
+ width: o,
199
+ ...t
200
+ } = a, d = g === "overlay", f = r ?? (e === void 0 ? "Sidebar" : void 0), E = d && c;
201
+ let m = b;
202
+ return (o !== void 0 || i !== void 0) && (m = { ...b }, i !== void 0 && (m["--nk-sidebar-height"] = i), o !== void 0 && (m["--nk-sidebar-width"] = o)), /* @__PURE__ */ l(
185
203
  "aside",
186
204
  {
187
- ...s,
205
+ ...t,
188
206
  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": g,
207
+ "aria-hidden": d && !c ? !0 : void 0,
208
+ "aria-label": d && !c ? void 0 : f,
209
+ "aria-labelledby": d && !c ? void 0 : e,
210
+ "aria-modal": E ? "true" : void 0,
211
+ className: ["nk-sidebar", u].filter(Boolean).join(" "),
212
+ "data-responsive": g === "pending" || void 0,
213
+ "data-side": h,
196
214
  "data-state": v,
197
- "data-variant": l ? "overlay" : "inline",
198
- 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 })
215
+ "data-variant": d ? "overlay" : "inline",
216
+ id: s,
217
+ role: E ? "dialog" : void 0,
218
+ style: m,
219
+ tabIndex: d ? -1 : void 0,
220
+ children: /* @__PURE__ */ l("div", { className: "nk-sidebar__body", children: n })
203
221
  }
204
222
  );
205
223
  }
206
- function Te(t) {
224
+ function ze(a) {
207
225
  const {
208
- boundaries: n,
226
+ boundaries: r,
209
227
  initialFocusReference: e,
210
- lockScroll: r,
211
- ownerDocument: b,
212
- panelReference: o,
213
- presenceState: u,
214
- restoreFocus: a,
228
+ lockScroll: n,
229
+ ownerDocument: u,
230
+ panelReference: i,
231
+ presenceState: c,
232
+ restoreFocus: s,
215
233
  sidebar: y,
216
- side: m,
217
- ...g
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");
234
+ side: g,
235
+ ...h
236
+ } = a, { id: v, open: b, requestOpenChange: o } = y, t = me(ae), d = I(null), [f, E] = C(null), m = W("Sidebar").boundaryElement, N = ye(!0, m), U = k((T) => {
237
+ d.current = T, i(T), E(T);
228
238
  }, [i]);
229
- ue({
230
- boundary: f,
231
- active: p,
232
- boundaries: n,
239
+ D(() => {
240
+ f && (f.inert = !b);
241
+ }, [b, f]);
242
+ const z = k(() => {
243
+ o(!1, "escape");
244
+ }, [o]), G = k(() => {
245
+ o(!1, "outside");
246
+ }, [o]);
247
+ Se({
248
+ boundary: m,
249
+ active: b,
250
+ boundaries: r,
233
251
  dismissOnEscape: !0,
234
252
  dismissOnPointerDownOutside: !0,
235
- layerId: _.id,
236
- onEscapeDismiss: D,
237
- onPointerDownOutsideDismiss: N,
238
- ownerDocument: b
253
+ layerId: N.id,
254
+ onEscapeDismiss: z,
255
+ onPointerDownOutsideDismiss: G,
256
+ ownerDocument: u
239
257
  });
240
- const P = fe({
241
- boundary: f,
242
- active: p,
243
- container: c,
244
- initialFocusReference: e ?? l,
245
- layerId: _.id,
246
- restoreFocus: a
258
+ const x = ke({
259
+ boundary: m,
260
+ active: b,
261
+ container: f,
262
+ initialFocusReference: e ?? d,
263
+ layerId: N.id,
264
+ restoreFocus: s
247
265
  });
248
- return me(r && p, b, f), /* @__PURE__ */ d(
249
- V.Provider,
266
+ return Ee(n && b, u, m), /* @__PURE__ */ l(
267
+ ae.Provider,
250
268
  {
251
- value: p ? P : s,
252
- children: /* @__PURE__ */ d(
269
+ value: b ? x : t,
270
+ children: /* @__PURE__ */ l(
253
271
  "div",
254
272
  {
255
273
  className: "nk-sidebar__overlay",
256
- "data-side": m,
257
- "data-state": u,
274
+ "data-side": g,
275
+ "data-state": c,
258
276
  role: "presentation",
259
- style: { zIndex: _.zIndex },
260
- children: /* @__PURE__ */ d(
261
- te,
277
+ style: { zIndex: N.zIndex },
278
+ children: /* @__PURE__ */ l(
279
+ de,
262
280
  {
263
- ...g,
264
- open: p,
281
+ ...h,
282
+ open: b,
265
283
  panelId: v,
266
- panelReference: C,
284
+ panelReference: U,
267
285
  presentation: "overlay",
268
- side: m,
269
- state: u
286
+ side: g,
287
+ state: c
270
288
  }
271
289
  )
272
290
  }
@@ -274,217 +292,248 @@ function Te(t) {
274
292
  }
275
293
  );
276
294
  }
277
- function Fe(t) {
278
- const { children: n } = t;
279
- if (n.type === ie)
295
+ function Ge(a) {
296
+ const { children: r } = a;
297
+ if (r.type === ge)
280
298
  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]);
299
+ const e = F("Sidebar.Trigger"), n = r.props, u = he(r), i = e == null ? void 0 : e.registerTrigger, c = e == null ? void 0 : e.unregisterTrigger, s = I(null), y = k((d) => {
300
+ const f = s.current;
301
+ f && f !== d && (c == null || c(f)), s.current = d, d && (i == null || i(d)), le(u, d);
302
+ }, [u, i, c]), g = k((d) => {
303
+ d.defaultPrevented || !e || e.requestOpenChange(!e.open, "trigger");
304
+ }, [e]);
288
305
  if (!e) return null;
289
- const { id: g, open: v, presentation: p, variant: i } = e;
290
- return oe(
291
- n,
292
- {
293
- "aria-controls": v && p === "overlay" ? ve(r["aria-controls"], g) : r["aria-controls"],
306
+ const { id: h, open: v, presentation: b, variant: o } = e;
307
+ return ve(
308
+ r,
309
+ Pe(n, {
310
+ "aria-controls": v && b === "overlay" ? Ne(n["aria-controls"], h) : n["aria-controls"],
294
311
  "aria-expanded": v,
295
- "aria-haspopup": r["aria-haspopup"] ?? "dialog",
296
- className: [r.className, "nk-sidebar__trigger"].filter(Boolean).join(" "),
297
- "data-sidebar-variant": i,
298
- onClick: m,
312
+ "aria-haspopup": n["aria-haspopup"] ?? "dialog",
313
+ className: "nk-sidebar__trigger",
314
+ "data-sidebar-variant": o,
315
+ onClick: g,
299
316
  ref: y
300
- }
317
+ })
301
318
  );
302
319
  }
303
- const Re = I(
304
- function(n, e) {
320
+ const Me = O(
321
+ function(r, e) {
305
322
  const {
306
- actions: r,
307
- className: b,
308
- description: o,
309
- image: u,
310
- loading: a = !1,
323
+ actions: n,
324
+ className: u,
325
+ description: i,
326
+ image: c,
327
+ loading: s = !1,
311
328
  name: y,
312
- onClick: m,
313
- ...g
314
- } = n, v = o != null && typeof o != "boolean", p = /* @__PURE__ */ A(K, { children: [
315
- /* @__PURE__ */ d(
316
- ge,
329
+ onClick: g,
330
+ ...h
331
+ } = r, v = i != null && typeof i != "boolean", b = /* @__PURE__ */ R(H, { children: [
332
+ /* @__PURE__ */ l(
333
+ we,
317
334
  {
318
335
  alt: y,
319
336
  "aria-hidden": !0,
320
337
  className: "nk-sidebar__user-avatar",
321
- image: u
338
+ image: c
322
339
  }
323
340
  ),
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,
341
+ /* @__PURE__ */ R("span", { className: "nk-sidebar__user-text", children: [
342
+ /* @__PURE__ */ l($, { as: "span", className: "nk-sidebar__user-name", children: y }),
343
+ v ? /* @__PURE__ */ l(
344
+ $,
328
345
  {
329
346
  as: "span",
330
347
  className: "nk-sidebar__user-description",
331
348
  size: "caption",
332
349
  tone: "muted",
333
- children: o
350
+ children: i
334
351
  }
335
352
  ) : null
336
353
  ] })
337
354
  ] });
338
- return /* @__PURE__ */ d(
355
+ return /* @__PURE__ */ l(
339
356
  "div",
340
357
  {
341
- ...g,
358
+ ...h,
342
359
  ref: e,
343
- className: ["nk-sidebar__user", b].filter(Boolean).join(" "),
344
- children: a ? /* @__PURE__ */ d(he, { className: "nk-sidebar__user-spinner", size: 16 }) : /* @__PURE__ */ A(K, { children: [
345
- m ? /* @__PURE__ */ d(
360
+ className: ["nk-sidebar__user", u].filter(Boolean).join(" "),
361
+ children: s ? /* @__PURE__ */ l(Ie, { className: "nk-sidebar__user-spinner", size: 16 }) : /* @__PURE__ */ R(H, { children: [
362
+ g ? /* @__PURE__ */ l(
346
363
  "button",
347
364
  {
348
365
  className: "nk-sidebar__user-details",
349
- onClick: m,
366
+ onClick: g,
350
367
  type: "button",
351
- children: p
368
+ children: b
352
369
  }
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) => {
370
+ ) : /* @__PURE__ */ l("div", { className: "nk-sidebar__user-details", children: b }),
371
+ n !== void 0 && n.length > 0 ? /* @__PURE__ */ l("div", { className: "nk-sidebar__user-actions", children: n.map((o) => {
355
372
  const {
356
- "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,
373
+ "aria-label": t,
374
+ icon: d,
375
+ label: f,
376
+ ...E
377
+ } = o;
378
+ return /* @__PURE__ */ l(Oe, { content: f, children: /* @__PURE__ */ l(
379
+ K,
363
380
  {
364
- ...S,
365
- "aria-label": s ?? c,
381
+ ...E,
382
+ "aria-label": t ?? f,
366
383
  className: "nk-sidebar__user-action",
367
- icon: l,
384
+ icon: d,
368
385
  shape: "rectangle",
369
386
  type: "button",
370
387
  variant: "ghost"
371
388
  }
372
- ) }, c);
389
+ ) }, f);
373
390
  }) }) : null
374
391
  ] })
375
392
  }
376
393
  );
377
394
  }
378
- ), Le = () => () => {
379
- }, W = () => {
395
+ ), qe = () => () => {
396
+ }, se = () => {
380
397
  };
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
398
+ function He(a, r) {
399
+ const e = a === "responsive" ? r : void 0, n = ie(
400
+ (e == null ? void 0 : e.subscribe) ?? qe,
401
+ (e == null ? void 0 : e.read) ?? se,
402
+ se
386
403
  );
387
- return t !== "responsive" ? t : r === void 0 ? "pending" : r >= Se("md") ? "inline" : "overlay";
404
+ return a !== "responsive" ? a : n === void 0 ? "pending" : n >= Te("md") ? "inline" : "overlay";
388
405
  }
389
- const Ce = I(function(n, e) {
390
- var J;
406
+ const $e = 32, We = O(function(r, e) {
407
+ var ee;
391
408
  const {
392
- defaultOpen: r = !1,
393
- initialFocusReference: b,
394
- top: o,
395
- lockScroll: u = !0,
396
- onOpenChange: a,
409
+ defaultOpen: n = !1,
410
+ height: u,
411
+ initialFocusReference: i,
412
+ lockScroll: c = !0,
413
+ onOpenChange: s,
397
414
  open: y,
398
- restoreFocus: m = !0,
399
- side: g = "start",
415
+ restoreFocus: g = !0,
416
+ side: h = "left",
400
417
  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;
418
+ width: b,
419
+ ...o
420
+ } = r, t = W("Sidebar"), d = `${oe()}-sidebar`, f = I(Symbol("nk-sidebar")).current, E = I(null), m = He(v, t == null ? void 0 : t.width), N = y !== void 0, [U, z] = C(n), [G, x] = C(0), [T, ue] = C(!1), V = I(null), w = N ? y : U, L = I(s);
421
+ D(() => {
422
+ L.current = s;
406
423
  });
407
- const E = k((h, O) => {
408
- var F;
409
- N !== h && (_ || D(h), (F = P.current) == null || F.call(P, h, O));
410
- }, [_, N]), G = k((h) => {
411
- S.current = h, ee(e ?? void 0, h);
412
- }, [e]), w = Q(
413
- () => [S],
424
+ const B = k((p, S) => {
425
+ var _;
426
+ w !== p && (N || z(p), (_ = L.current) == null || _.call(L, p, S));
427
+ }, [N, w]), Y = k((p) => {
428
+ E.current = p, le(e, p);
429
+ }, [e]), P = re(
430
+ () => [E],
414
431
  []
415
- ), q = k((h) => {
416
- w.push({ current: h });
417
- }, [w]), H = k((h) => {
418
- const O = w.findIndex((F) => F.current === h);
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,
432
+ ), J = k((p) => {
433
+ P.push({ current: p }), x((S) => S + 1);
434
+ }, [P]), Q = k((p) => {
435
+ const S = P.findIndex((_) => _.current === p);
436
+ S > 0 && P.splice(S, 1), x((_) => Math.max(_ - 1, 0));
437
+ }, [P]), pe = k((p) => {
438
+ const S = V.current;
439
+ if (S && S !== p) {
440
+ const _ = P.findIndex((be) => be.current === S);
441
+ _ > 0 && P.splice(_, 1);
442
+ }
443
+ V.current = p, p && P.push({ current: p });
444
+ }, [P]), M = re(() => ({
445
+ id: d,
446
+ open: w,
447
+ presentation: m,
448
+ registerTrigger: J,
449
+ requestOpenChange: B,
450
+ unregisterTrigger: Q,
427
451
  variant: v
428
452
  }), [
429
- N,
430
- l,
431
- f,
432
- q,
433
- E,
434
- H,
453
+ w,
454
+ d,
455
+ m,
456
+ J,
457
+ B,
458
+ Q,
435
459
  v
436
460
  ]);
437
- R(() => {
438
- const h = s == null ? void 0 : s.boundaryElement;
439
- if (!h) return;
440
- if (_e(h, c, j) === !1)
461
+ D(() => {
462
+ const p = t == null ? void 0 : t.boundaryElement;
463
+ if (!p) return;
464
+ if (Fe(p, f, M) === !1)
441
465
  throw new Error(
442
466
  "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
467
  );
444
- }, [s == null ? void 0 : s.boundaryElement, c, j]), R(() => {
445
- const h = s == null ? void 0 : s.boundaryElement;
446
- if (h)
447
- return () => ke(h, 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
- top: o,
457
- open: !1,
458
- panelId: l,
459
- panelReference: G,
460
- presentation: f,
461
- side: g,
462
- width: p
463
- }
464
- ) : !M.present || !$ ? null : /* @__PURE__ */ d(be, { children: /* @__PURE__ */ d(
465
- Te,
468
+ }, [t == null ? void 0 : t.boundaryElement, f, M]), D(() => {
469
+ const p = t == null ? void 0 : t.boundaryElement;
470
+ if (p)
471
+ return () => xe(p, f);
472
+ }, [t == null ? void 0 : t.boundaryElement, f]), ne(() => {
473
+ m === "inline" && B(!1, "variant");
474
+ }, [m, B]), ne(() => {
475
+ var _;
476
+ const p = (_ = t == null ? void 0 : t.boundaryElement) == null ? void 0 : _.ownerDocument.defaultView;
477
+ if (!p) return;
478
+ const S = p.setTimeout(
479
+ () => ue(!0),
480
+ $e
481
+ );
482
+ return () => p.clearTimeout(S);
483
+ }, [t == null ? void 0 : t.boundaryElement]);
484
+ const q = _e(w && m === "overlay"), X = ((ee = t == null ? void 0 : t.boundaryElement) == null ? void 0 : ee.ownerDocument) ?? (typeof document > "u" ? null : document);
485
+ if (m !== "overlay")
486
+ return /* @__PURE__ */ l(
487
+ de,
488
+ {
489
+ ...o,
490
+ height: u,
491
+ open: !1,
492
+ panelId: d,
493
+ panelReference: Y,
494
+ presentation: m,
495
+ side: h,
496
+ width: b
497
+ }
498
+ );
499
+ const Z = T && G === 0 ? /* @__PURE__ */ l(te, { children: /* @__PURE__ */ l(
500
+ Be,
466
501
  {
467
- ...i,
468
- initialFocusReference: b,
469
- lockScroll: u,
470
- ownerDocument: $,
471
- presenceState: M.state === "closing" ? "closing" : "open",
472
- boundaries: w,
473
- panelReference: G,
474
- restoreFocus: m,
475
- sidebar: j,
476
- side: g,
477
- width: p
502
+ label: `Open ${o["aria-label"] ?? "Sidebar"}`,
503
+ onToggle: () => B(!w, "trigger"),
504
+ panelId: q.present ? d : void 0,
505
+ reference: pe,
506
+ side: h,
507
+ sidebarOpen: w
478
508
  }
479
- ) });
480
- }), We = Object.assign(Ce, {
481
- Footer: we,
482
- Group: Ie,
483
- Header: Oe,
484
- Item: Be,
485
- Trigger: Fe,
486
- User: Re
509
+ ) }) : null;
510
+ return !q.present || !X ? Z : /* @__PURE__ */ R(H, { children: [
511
+ Z,
512
+ /* @__PURE__ */ l(te, { children: /* @__PURE__ */ l(
513
+ ze,
514
+ {
515
+ ...o,
516
+ boundaries: P,
517
+ initialFocusReference: i,
518
+ lockScroll: c,
519
+ ownerDocument: X,
520
+ panelReference: Y,
521
+ presenceState: q.state === "closing" ? "closing" : "open",
522
+ restoreFocus: g,
523
+ side: h,
524
+ sidebar: M,
525
+ width: b
526
+ }
527
+ ) })
528
+ ] });
529
+ }), lr = Object.assign(We, {
530
+ Footer: De,
531
+ Group: Ae,
532
+ Header: je,
533
+ Item: Ue,
534
+ Trigger: Ge,
535
+ User: Me
487
536
  });
488
537
  export {
489
- We as default
538
+ lr as default
490
539
  };