tembro 2.0.1 → 2.0.2

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.
@@ -1,45 +1,51 @@
1
1
  import { cn as e } from "../../lib/utils.js";
2
2
  import { Tooltip as t } from "../ui/tooltip/index.js";
3
- import * as n from "react";
4
- import { Fragment as r, jsx as i, jsxs as a } from "react/jsx-runtime";
3
+ import { useIsMobile as n } from "../../hooks/use-is-mobile.js";
4
+ import * as r from "react";
5
+ import { MenuIcon as i, XIcon as a } from "lucide-react";
6
+ import { Fragment as o, jsx as s, jsxs as c } from "react/jsx-runtime";
5
7
  //#region src/components/layout/app-sidebar.tsx
6
- function o(e) {
8
+ var l = 1024;
9
+ function u(e) {
7
10
  return e.items?.some((e) => !e.hidden) ?? !1;
8
11
  }
9
- function s(e) {
10
- return e.active ? !0 : e.items?.some((e) => s(e)) ?? !1;
12
+ function d(e) {
13
+ return e.active ? !0 : e.items?.some((e) => d(e)) ?? !1;
11
14
  }
12
- function c({ item: n, collapsed: o, depth: s, onItemSelect: c, renderLink: l }) {
15
+ function f(e, t) {
16
+ e.onSelect?.(), t?.(e);
17
+ }
18
+ function p({ item: n, collapsed: r, depth: i, onItemSelect: a, renderLink: l }) {
13
19
  let u = {
14
20
  "aria-current": n.current ?? (n.active ? "page" : void 0),
15
21
  "aria-disabled": n.disabled || void 0,
16
22
  "data-slot": "app-sidebar-item",
17
23
  "data-active": n.active || void 0,
18
24
  "data-disabled": n.disabled || void 0,
19
- "data-depth": String(s),
20
- className: e("flex min-h-9 items-center gap-2 rounded-lg border border-transparent px-2.5 text-sm font-medium outline-none transition-[background-color,border-color,color,box-shadow] data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50", o && "justify-center px-2")
21
- }, d = /* @__PURE__ */ a(r, { children: [
22
- n.icon && /* @__PURE__ */ i("span", {
25
+ "data-depth": String(i),
26
+ className: e("flex min-h-9 items-center gap-2 rounded-lg border border-transparent px-2.5 text-sm font-medium outline-none transition-[background-color,border-color,color,box-shadow] data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50", r && "justify-center px-2")
27
+ }, d = /* @__PURE__ */ c(o, { children: [
28
+ n.icon && /* @__PURE__ */ s("span", {
23
29
  className: "shrink-0",
24
30
  children: n.icon
25
31
  }),
26
- !o && /* @__PURE__ */ i("span", {
32
+ !r && /* @__PURE__ */ s("span", {
27
33
  className: "min-w-0 flex-1 truncate",
28
34
  children: n.label
29
35
  }),
30
- !o && n.badge && /* @__PURE__ */ i("span", {
36
+ !r && n.badge && /* @__PURE__ */ s("span", {
31
37
  className: "shrink-0",
32
38
  children: n.badge
33
39
  })
34
- ] }), f = (e) => o ? /* @__PURE__ */ i(t, {
40
+ ] }), p = (e) => r ? /* @__PURE__ */ s(t, {
35
41
  content: n.tooltip ?? n.label,
36
42
  side: "right",
37
- children: /* @__PURE__ */ i("span", {
43
+ children: /* @__PURE__ */ s("span", {
38
44
  className: "block",
39
45
  children: e
40
46
  })
41
47
  }) : e;
42
- return n.href?.startsWith("/") ? f(l ? /* @__PURE__ */ i(r, { children: l({
48
+ return n.href?.startsWith("/") ? p(l ? /* @__PURE__ */ s(o, { children: l({
43
49
  item: n,
44
50
  href: n.href,
45
51
  ...u,
@@ -48,10 +54,10 @@ function c({ item: n, collapsed: o, depth: s, onItemSelect: c, renderLink: l })
48
54
  e.preventDefault();
49
55
  return;
50
56
  }
51
- n.onSelect?.(), c?.(n);
57
+ f(n, a);
52
58
  },
53
59
  children: d
54
- }) }) : /* @__PURE__ */ i("a", {
60
+ }) }) : /* @__PURE__ */ s("a", {
55
61
  href: n.href,
56
62
  ...u,
57
63
  onClick: (e) => {
@@ -59,10 +65,10 @@ function c({ item: n, collapsed: o, depth: s, onItemSelect: c, renderLink: l })
59
65
  e.preventDefault();
60
66
  return;
61
67
  }
62
- n.onSelect?.(), c?.(n);
68
+ f(n, a);
63
69
  },
64
70
  children: d
65
- })) : n.href ? f(/* @__PURE__ */ i("button", {
71
+ })) : n.href ? p(/* @__PURE__ */ s("button", {
66
72
  type: "button",
67
73
  ...u,
68
74
  className: e(u.className, "w-full"),
@@ -70,7 +76,7 @@ function c({ item: n, collapsed: o, depth: s, onItemSelect: c, renderLink: l })
70
76
  if (n.disabled) return;
71
77
  let e = n.href;
72
78
  if (e) {
73
- if (n.onSelect?.(), c?.(n), e.startsWith("http")) {
79
+ if (f(n, a), e.startsWith("http")) {
74
80
  window.open(e, "_blank", "noopener,noreferrer");
75
81
  return;
76
82
  }
@@ -78,89 +84,89 @@ function c({ item: n, collapsed: o, depth: s, onItemSelect: c, renderLink: l })
78
84
  }
79
85
  },
80
86
  children: d
81
- })) : f(/* @__PURE__ */ i("button", {
87
+ })) : p(/* @__PURE__ */ s("button", {
82
88
  type: "button",
83
89
  disabled: n.disabled,
84
90
  ...u,
85
91
  onClick: () => {
86
- n.onSelect?.(), c?.(n);
92
+ n.disabled || f(n, a);
87
93
  },
88
94
  children: d
89
95
  }));
90
96
  }
91
- function l({ items: r, collapsed: u, depth: d, onItemSelect: f, renderLink: p }) {
92
- return r.map((r) => {
93
- if (r.hidden) return null;
94
- let m = o(r), h = s(r), g = !u && d === 0 && r.sectionLabel;
95
- if (!m) return /* @__PURE__ */ a(n.Fragment, { children: [g ? /* @__PURE__ */ i("div", {
97
+ function m({ items: n, collapsed: i, depth: a, onItemSelect: o, renderLink: l }) {
98
+ return n.map((n) => {
99
+ if (n.hidden) return null;
100
+ let f = u(n), h = d(n), g = !i && a === 0 && n.sectionLabel;
101
+ if (!f) return /* @__PURE__ */ c(r.Fragment, { children: [g ? /* @__PURE__ */ s("div", {
96
102
  "data-slot": "app-sidebar-group-label",
97
103
  className: "px-2.5 pb-1 pt-3 text-[11px] font-semibold uppercase tracking-[0.14em] text-muted-foreground first:pt-0",
98
- children: r.sectionLabel
99
- }) : null, /* @__PURE__ */ i(c, {
100
- item: r,
101
- collapsed: u,
102
- depth: d,
103
- onItemSelect: f,
104
- renderLink: p
105
- })] }, r.key);
106
- let _ = r.defaultExpanded ?? h;
107
- return /* @__PURE__ */ a("div", {
104
+ children: n.sectionLabel
105
+ }) : null, /* @__PURE__ */ s(p, {
106
+ item: n,
107
+ collapsed: i,
108
+ depth: a,
109
+ onItemSelect: o,
110
+ renderLink: l
111
+ })] }, n.key);
112
+ let _ = n.defaultExpanded ?? h;
113
+ return /* @__PURE__ */ c("div", {
108
114
  "data-slot": "app-sidebar-group",
109
- "data-depth": d,
110
- children: [g && /* @__PURE__ */ i("div", {
115
+ "data-depth": a,
116
+ children: [g && /* @__PURE__ */ s("div", {
111
117
  "data-slot": "app-sidebar-group-label",
112
118
  className: "px-2.5 pb-1 pt-3 text-[11px] font-semibold uppercase tracking-[0.14em] text-muted-foreground first:pt-0",
113
- children: r.sectionLabel
114
- }), /* @__PURE__ */ a("details", {
119
+ children: n.sectionLabel
120
+ }), /* @__PURE__ */ c("details", {
115
121
  "data-slot": "app-sidebar-group-details",
116
122
  open: _,
117
123
  className: "group/app-sidebar-details",
118
- children: [/* @__PURE__ */ a("summary", {
124
+ children: [/* @__PURE__ */ c("summary", {
119
125
  "data-slot": "app-sidebar-group-trigger",
120
- className: e("flex min-h-9 list-none items-center gap-2 rounded-lg border border-transparent text-sm font-medium outline-none transition-[background-color,border-color,color,box-shadow]", u ? "justify-center px-2" : "px-2.5"),
126
+ className: e("flex min-h-9 list-none items-center gap-2 rounded-lg border border-transparent text-sm font-medium outline-none transition-[background-color,border-color,color,box-shadow]", i ? "justify-center px-2" : "px-2.5"),
121
127
  children: [
122
- r.icon ? u ? /* @__PURE__ */ i(t, {
123
- content: r.tooltip ?? r.label,
128
+ n.icon ? i ? /* @__PURE__ */ s(t, {
129
+ content: n.tooltip ?? n.label,
124
130
  side: "right",
125
- children: /* @__PURE__ */ i("span", {
131
+ children: /* @__PURE__ */ s("span", {
126
132
  className: "shrink-0",
127
- children: r.icon
133
+ children: n.icon
128
134
  })
129
- }) : /* @__PURE__ */ i("span", {
135
+ }) : /* @__PURE__ */ s("span", {
130
136
  className: "shrink-0",
131
- children: r.icon
137
+ children: n.icon
132
138
  }) : null,
133
- !u && /* @__PURE__ */ i("span", {
139
+ !i && /* @__PURE__ */ s("span", {
134
140
  className: "min-w-0 flex-1 truncate",
135
- children: r.label
141
+ children: n.label
136
142
  }),
137
- !u && r.badge && /* @__PURE__ */ i("span", {
143
+ !i && n.badge && /* @__PURE__ */ s("span", {
138
144
  className: "shrink-0",
139
- children: r.badge
145
+ children: n.badge
140
146
  }),
141
- !u && /* @__PURE__ */ i("span", {
147
+ !i && /* @__PURE__ */ s("span", {
142
148
  "data-slot": "app-sidebar-group-chevron",
143
149
  className: "ml-auto text-xs text-muted-foreground transition-transform group-open/app-sidebar-details:rotate-90",
144
150
  children: "›"
145
151
  })
146
152
  ]
147
- }), /* @__PURE__ */ i("div", {
153
+ }), /* @__PURE__ */ s("div", {
148
154
  "data-slot": "app-sidebar-group-content",
149
- className: e("mt-1 space-y-1", !u && "pl-3"),
150
- children: /* @__PURE__ */ i(l, {
151
- items: r.items ?? [],
152
- collapsed: u,
153
- depth: d + 1,
154
- onItemSelect: f,
155
- renderLink: p
155
+ className: e("mt-1 space-y-1", !i && "pl-3"),
156
+ children: /* @__PURE__ */ s(m, {
157
+ items: n.items ?? [],
158
+ collapsed: i,
159
+ depth: a + 1,
160
+ onItemSelect: o,
161
+ renderLink: l
156
162
  })
157
163
  })]
158
164
  })]
159
- }, r.key);
165
+ }, n.key);
160
166
  });
161
167
  }
162
- function u({ item: n, collapsed: r, onItemSelect: o }) {
163
- let s = /* @__PURE__ */ a("button", {
168
+ function h({ item: n, collapsed: r, onItemSelect: i }) {
169
+ let a = /* @__PURE__ */ c("button", {
164
170
  type: "button",
165
171
  "data-slot": "app-sidebar-action",
166
172
  "data-active": n.active || void 0,
@@ -168,39 +174,39 @@ function u({ item: n, collapsed: r, onItemSelect: o }) {
168
174
  className: e("flex min-h-9 items-center gap-2 rounded-lg border border-transparent px-2.5 text-sm font-medium outline-none transition-[background-color,border-color,color,box-shadow] data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50", r && "justify-center px-2"),
169
175
  disabled: n.disabled,
170
176
  onClick: () => {
171
- n.disabled || (n.onSelect?.(), o?.(n));
177
+ n.disabled || f(n, i);
172
178
  },
173
179
  children: [
174
- n.icon ? /* @__PURE__ */ i("span", {
180
+ n.icon ? /* @__PURE__ */ s("span", {
175
181
  className: "shrink-0",
176
182
  children: n.icon
177
183
  }) : null,
178
- r ? null : /* @__PURE__ */ i("span", {
184
+ r ? null : /* @__PURE__ */ s("span", {
179
185
  className: "min-w-0 flex-1 truncate",
180
186
  children: n.label
181
187
  }),
182
- !r && n.badge ? /* @__PURE__ */ i("span", {
188
+ !r && n.badge ? /* @__PURE__ */ s("span", {
183
189
  className: "shrink-0",
184
190
  children: n.badge
185
191
  }) : null
186
192
  ]
187
193
  });
188
- return r ? /* @__PURE__ */ i(t, {
194
+ return r ? /* @__PURE__ */ s(t, {
189
195
  content: n.tooltip ?? n.label,
190
196
  side: "right",
191
- children: /* @__PURE__ */ i("span", {
197
+ children: /* @__PURE__ */ s("span", {
192
198
  className: "block",
193
- children: s
199
+ children: a
194
200
  })
195
- }) : s;
201
+ }) : a;
196
202
  }
197
- function d({ account: n, collapsed: r }) {
198
- let o = /* @__PURE__ */ a("button", {
203
+ function g({ account: n, collapsed: r, onAfterSelect: i }) {
204
+ let a = /* @__PURE__ */ c("button", {
199
205
  type: "button",
200
206
  "data-slot": "app-sidebar-account",
201
207
  className: e("flex w-full items-center gap-3 rounded-[min(var(--radius-xl),16px)] border border-transparent text-left transition-[background-color,border-color,color,box-shadow]", r ? "justify-center px-2 py-2.5" : "px-3 py-2.5"),
202
208
  onClick: () => {
203
- if (n.onSelect?.(), n.href) {
209
+ if (n.onSelect?.(), i?.(), n.href) {
204
210
  if (n.href.startsWith("http")) {
205
211
  window.open(n.href, "_blank", "noopener,noreferrer");
206
212
  return;
@@ -208,118 +214,239 @@ function d({ account: n, collapsed: r }) {
208
214
  window.location.assign(n.href);
209
215
  }
210
216
  },
211
- children: [n.avatar ? /* @__PURE__ */ i("span", {
217
+ children: [n.avatar ? /* @__PURE__ */ s("span", {
212
218
  "data-slot": "app-sidebar-account-avatar",
213
219
  className: "inline-flex size-9 shrink-0 items-center justify-center overflow-hidden rounded-full border border-border/65 bg-muted/45 text-sm font-semibold",
214
220
  children: n.avatar
215
- }) : null, r ? null : /* @__PURE__ */ a("span", {
221
+ }) : null, r ? null : /* @__PURE__ */ c("span", {
216
222
  className: "min-w-0 flex-1",
217
- children: [/* @__PURE__ */ i("span", {
223
+ children: [/* @__PURE__ */ s("span", {
218
224
  "data-slot": "app-sidebar-account-label",
219
225
  className: "block truncate text-sm font-semibold text-foreground",
220
226
  children: n.label
221
- }), n.description ? /* @__PURE__ */ i("span", {
227
+ }), n.description ? /* @__PURE__ */ s("span", {
222
228
  "data-slot": "app-sidebar-account-description",
223
229
  className: "block truncate text-xs text-muted-foreground",
224
230
  children: n.description
225
231
  }) : null]
226
232
  })]
227
233
  });
228
- return r ? /* @__PURE__ */ i(t, {
234
+ return r ? /* @__PURE__ */ s(t, {
229
235
  content: n.tooltip ?? n.label,
230
236
  side: "right",
231
- children: /* @__PURE__ */ i("span", {
237
+ children: /* @__PURE__ */ s("span", {
232
238
  className: "block",
233
- children: o
239
+ children: a
234
240
  })
235
- }) : o;
241
+ }) : a;
236
242
  }
237
- function f({ className: o, header: s, footer: c, items: f = [], collapsed: p = !1, collapsedRail: m, railItems: h = [], footerAccount: g, secondaryActions: _ = [], footerSecondary: v, tooltipOnCollapsed: y = !0, onItemSelect: b, renderItem: x, renderLink: S, children: C, ...w }) {
238
- let T = f.filter((e) => !e.hidden), E = h.filter((e) => !e.hidden), D = _.filter((e) => !e.hidden);
239
- return /* @__PURE__ */ a("aside", {
243
+ function _({ className: n, header: i, footer: l, items: u = [], collapsed: d = !1, collapsedRail: f, railItems: p = [], footerAccount: _, secondaryActions: v = [], footerSecondary: y, tooltipOnCollapsed: b, onItemSelect: x, renderItem: S, renderLink: C, children: w, mobile: T, mobileTitle: E, mobileDescription: D, onRequestClose: O, closeOnSelect: k = !0, ...A }) {
244
+ let j = u.filter((e) => !e.hidden), M = p.filter((e) => !e.hidden), N = v.filter((e) => !e.hidden), P = r.useCallback((e) => {
245
+ x?.(e), T && k && O?.();
246
+ }, [
247
+ k,
248
+ T,
249
+ x,
250
+ O
251
+ ]), F = T && (E || D || O);
252
+ return /* @__PURE__ */ c("aside", {
240
253
  "data-slot": "app-sidebar",
241
- "data-collapsed": p || void 0,
242
- className: e("flex h-full min-h-0 flex-col overflow-hidden", o),
243
- ...w,
254
+ "data-collapsed": d || void 0,
255
+ "data-mobile": T || void 0,
256
+ className: e("flex h-full min-h-0 flex-col overflow-hidden", n),
257
+ ...A,
244
258
  children: [
245
- s && /* @__PURE__ */ i("div", {
259
+ (i || F) && /* @__PURE__ */ s("div", {
246
260
  "data-slot": "app-sidebar-header",
247
261
  className: "shrink-0 border-b p-3",
248
- children: s
262
+ children: /* @__PURE__ */ c("div", {
263
+ className: "flex items-start gap-3",
264
+ children: [/* @__PURE__ */ c("div", {
265
+ className: "min-w-0 flex-1",
266
+ children: [i ?? null, F ? /* @__PURE__ */ c("div", {
267
+ className: e(i && "mt-3"),
268
+ children: [E ? /* @__PURE__ */ s("p", {
269
+ className: "text-sm font-semibold text-foreground",
270
+ children: E
271
+ }) : null, D ? /* @__PURE__ */ s("p", {
272
+ className: "mt-1 text-xs leading-5 text-muted-foreground",
273
+ children: D
274
+ }) : null]
275
+ }) : null]
276
+ }), T && O ? /* @__PURE__ */ s("button", {
277
+ type: "button",
278
+ "aria-label": "Close navigation",
279
+ "data-slot": "app-sidebar-mobile-close",
280
+ className: "inline-flex size-9 shrink-0 items-center justify-center rounded-xl border border-[color:var(--aui-divider)] bg-[color:var(--aui-page-bg-alt)] text-[color:var(--aui-page-foreground)] transition hover:bg-[color:var(--aui-control-bg)]",
281
+ onClick: O,
282
+ children: /* @__PURE__ */ s(a, { className: "size-4" })
283
+ }) : null]
284
+ })
249
285
  }),
250
- /* @__PURE__ */ a("nav", {
286
+ /* @__PURE__ */ c("nav", {
251
287
  "data-slot": "app-sidebar-nav",
252
288
  className: "min-h-0 flex-1 space-y-1 overflow-y-auto overscroll-contain p-2",
253
- children: [C ?? T.map((e) => {
254
- if (!x) return null;
255
- let r = x(e, { collapsed: p });
256
- return !p || !y ? /* @__PURE__ */ i(n.Fragment, { children: r }, e.key) : /* @__PURE__ */ i(t, {
289
+ children: [w ?? j.map((e) => {
290
+ if (!S) return null;
291
+ let n = S(e, { collapsed: d });
292
+ return !d || !b ? /* @__PURE__ */ s(r.Fragment, { children: n }, e.key) : /* @__PURE__ */ s(t, {
257
293
  content: e.tooltip ?? e.label,
258
294
  side: "right",
259
- children: /* @__PURE__ */ i("span", {
295
+ children: /* @__PURE__ */ s("span", {
260
296
  className: "block",
261
- children: r
297
+ children: n
262
298
  })
263
299
  }, e.key);
264
- }), !C && !x && /* @__PURE__ */ i(l, {
265
- items: T,
266
- collapsed: p,
300
+ }), !w && !S && /* @__PURE__ */ s(m, {
301
+ items: j,
302
+ collapsed: d,
267
303
  depth: 0,
268
- onItemSelect: b,
269
- renderLink: S
304
+ onItemSelect: P,
305
+ renderLink: C
270
306
  })]
271
307
  }),
272
- (g || v || c || D.length > 0 || p && (m || E.length > 0)) && /* @__PURE__ */ a("div", {
308
+ (_ || y || l || N.length > 0 || d && (f || M.length > 0)) && /* @__PURE__ */ c("div", {
273
309
  "data-slot": "app-sidebar-footer",
274
310
  className: "shrink-0 border-t p-3",
275
311
  children: [
276
- p ? /* @__PURE__ */ a(r, { children: [E.length > 0 ? /* @__PURE__ */ i("div", {
312
+ d ? /* @__PURE__ */ c(o, { children: [M.length > 0 ? /* @__PURE__ */ s("div", {
277
313
  "data-slot": "app-sidebar-rail-actions",
278
314
  className: "grid gap-2",
279
- children: E.map((e) => /* @__PURE__ */ i(u, {
315
+ children: M.map((e) => /* @__PURE__ */ s(h, {
280
316
  item: e,
281
317
  collapsed: !0,
282
- onItemSelect: b
318
+ onItemSelect: P
283
319
  }, e.key))
284
- }) : null, m ? /* @__PURE__ */ i("div", {
320
+ }) : null, f ? /* @__PURE__ */ s("div", {
285
321
  "data-slot": "app-sidebar-rail",
286
- children: m
322
+ children: f
287
323
  }) : null] }) : null,
288
- !p && g ? /* @__PURE__ */ i("div", {
324
+ !d && _ ? /* @__PURE__ */ s("div", {
289
325
  "data-slot": "app-sidebar-account-wrap",
290
326
  className: "mb-3",
291
- children: /* @__PURE__ */ i(d, {
292
- account: g,
293
- collapsed: !1
327
+ children: /* @__PURE__ */ s(g, {
328
+ account: _,
329
+ collapsed: !1,
330
+ onAfterSelect: () => {
331
+ T && k && O?.();
332
+ }
294
333
  })
295
334
  }) : null,
296
- !p && D.length > 0 ? /* @__PURE__ */ i("div", {
335
+ !d && N.length > 0 ? /* @__PURE__ */ s("div", {
297
336
  "data-slot": "app-sidebar-secondary-actions",
298
337
  className: "mb-3 grid gap-2",
299
- children: D.map((e) => /* @__PURE__ */ i(u, {
338
+ children: N.map((e) => /* @__PURE__ */ s(h, {
300
339
  item: e,
301
340
  collapsed: !1,
302
- onItemSelect: b
341
+ onItemSelect: P
303
342
  }, e.key))
304
343
  }) : null,
305
- !p && v ? /* @__PURE__ */ i("div", {
344
+ !d && y ? /* @__PURE__ */ s("div", {
306
345
  "data-slot": "app-sidebar-footer-secondary",
307
346
  className: "mb-3",
308
- children: v
347
+ children: y
309
348
  }) : null,
310
- p && g ? /* @__PURE__ */ i("div", {
349
+ d && _ ? /* @__PURE__ */ s("div", {
311
350
  "data-slot": "app-sidebar-account-wrap",
312
- children: /* @__PURE__ */ i(d, {
313
- account: g,
314
- collapsed: !0
351
+ children: /* @__PURE__ */ s(g, {
352
+ account: _,
353
+ collapsed: !0,
354
+ onAfterSelect: () => {
355
+ T && k && O?.();
356
+ }
315
357
  })
316
358
  }) : null,
317
- !p && c
359
+ !d && l
318
360
  ]
319
361
  })
320
362
  ]
321
363
  });
322
364
  }
323
- var p = f;
365
+ function v({ className: t, header: a, footer: u, items: d = [], collapsed: f = !1, collapsedRail: p, railItems: m = [], footerAccount: h, secondaryActions: g = [], footerSecondary: v, tooltipOnCollapsed: y = !0, responsive: b = !0, mobileBreakpoint: x = l, mobileOpen: S, defaultMobileOpen: C = !1, onMobileOpenChange: w, mobileTitle: T, mobileDescription: E, mobileToggleLabel: D = "Open navigation", mobileToggleIcon: O, showMobileToggle: k = !0, closeOnSelect: A = !0, mobileToggleClassName: j, mobilePanelClassName: M, mobileOverlayClassName: N, renderMobileToggle: P, onItemSelect: F, renderItem: I, renderLink: L, children: R, ...z }) {
366
+ let B = b ? n(x) : !1, [V, H] = r.useState(C), U = S ?? V, W = r.useCallback((e) => {
367
+ S ?? H(e), w?.(e);
368
+ }, [S, w]);
369
+ r.useEffect(() => {
370
+ !B && U && W(!1);
371
+ }, [
372
+ B,
373
+ U,
374
+ W
375
+ ]), r.useEffect(() => {
376
+ if (!B || !U) return;
377
+ let e = document.body.style.overflow;
378
+ document.body.style.overflow = "hidden";
379
+ let t = (e) => {
380
+ e.key === "Escape" && W(!1);
381
+ };
382
+ return window.addEventListener("keydown", t), () => {
383
+ document.body.style.overflow = e, window.removeEventListener("keydown", t);
384
+ };
385
+ }, [
386
+ B,
387
+ U,
388
+ W
389
+ ]);
390
+ let G = {
391
+ className: t,
392
+ header: a,
393
+ footer: u,
394
+ items: d,
395
+ collapsed: f,
396
+ collapsedRail: p,
397
+ railItems: m,
398
+ footerAccount: h,
399
+ secondaryActions: g,
400
+ footerSecondary: v,
401
+ tooltipOnCollapsed: y,
402
+ closeOnSelect: A,
403
+ onItemSelect: F,
404
+ renderItem: I,
405
+ renderLink: L,
406
+ children: R,
407
+ ...z
408
+ };
409
+ if (!b || !B) return /* @__PURE__ */ s(_, { ...G });
410
+ let K = /* @__PURE__ */ c("button", {
411
+ type: "button",
412
+ "aria-label": U ? "Close navigation" : D,
413
+ "data-slot": "app-sidebar-mobile-trigger",
414
+ "data-state": U ? "open" : "closed",
415
+ className: e("inline-flex min-h-10 items-center gap-2 rounded-xl border border-[color:var(--aui-divider)] bg-[color:var(--aui-page-bg)] px-3 text-sm font-medium text-[color:var(--aui-page-foreground)] shadow-sm transition hover:bg-[color:var(--aui-page-bg-alt)]", j),
416
+ onClick: () => W(!U),
417
+ children: [/* @__PURE__ */ s("span", {
418
+ className: "inline-flex size-8 items-center justify-center rounded-lg bg-[color:var(--aui-page-bg-alt)]",
419
+ children: O ?? /* @__PURE__ */ s(i, { className: "size-4" })
420
+ }), /* @__PURE__ */ s("span", { children: U ? "Close navigation" : D })]
421
+ });
422
+ return /* @__PURE__ */ c(o, { children: [k ? P ? P({
423
+ open: U,
424
+ setOpen: W
425
+ }) : K : null, /* @__PURE__ */ c("div", {
426
+ "data-slot": "app-sidebar-mobile-root",
427
+ className: "relative z-40",
428
+ children: [/* @__PURE__ */ s("button", {
429
+ type: "button",
430
+ "aria-label": "Dismiss navigation",
431
+ "data-slot": "app-sidebar-mobile-overlay",
432
+ "data-state": U ? "open" : "closed",
433
+ className: e("fixed inset-0 z-40 bg-black/45 transition-opacity duration-200", U ? "opacity-100" : "pointer-events-none opacity-0", N),
434
+ onClick: () => W(!1)
435
+ }), /* @__PURE__ */ s(_, {
436
+ ...G,
437
+ mobile: !0,
438
+ collapsed: !1,
439
+ mobileTitle: T,
440
+ mobileDescription: E,
441
+ onRequestClose: () => W(!1),
442
+ "data-state": U ? "open" : "closed",
443
+ role: "dialog",
444
+ "aria-modal": "true",
445
+ "aria-label": typeof T == "string" ? T : "Navigation",
446
+ className: e("fixed inset-y-0 left-0 z-50 w-[min(88vw,22rem)] max-w-[22rem] border-r border-[color:var(--aui-divider)] bg-[color:var(--aui-page-bg)] shadow-2xl transition-transform duration-200 ease-out", U ? "translate-x-0" : "-translate-x-full", M, t)
447
+ })]
448
+ })] });
449
+ }
450
+ var y = v;
324
451
  //#endregion
325
- export { f as AppSidebar, p as Sidebar };
452
+ export { v as AppSidebar, y as Sidebar };
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./use-session-storage-state.cjs"),t=require("./use-before-unload-when-dirty.cjs"),n=require("./use-is-mobile.cjs"),r=require("./use-disclosure.cjs"),i=require("./use-debounce.cjs"),a=require("./use-data-table-view-state.cjs");exports.DEFAULT_MOBILE_BREAKPOINT=n.DEFAULT_MOBILE_BREAKPOINT,exports.useBeforeUnloadWhenDirty=t.useBeforeUnloadWhenDirty,exports.useDataTableViewState=a.useDataTableViewState,exports.useDebouncedCallback=i.useDebouncedCallback,exports.useDebouncedValue=i.useDebouncedValue,exports.useDisclosure=r.useDisclosure,exports.useIsMobile=n.useIsMobile,exports.useSessionStorageState=e.useSessionStorageState;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./use-is-mobile.cjs"),t=require("./use-session-storage-state.cjs"),n=require("./use-before-unload-when-dirty.cjs"),r=require("./use-disclosure.cjs"),i=require("./use-debounce.cjs"),a=require("./use-data-table-view-state.cjs");exports.DEFAULT_MOBILE_BREAKPOINT=e.DEFAULT_MOBILE_BREAKPOINT,exports.useBeforeUnloadWhenDirty=n.useBeforeUnloadWhenDirty,exports.useDataTableViewState=a.useDataTableViewState,exports.useDebouncedCallback=i.useDebouncedCallback,exports.useDebouncedValue=i.useDebouncedValue,exports.useDisclosure=r.useDisclosure,exports.useIsMobile=e.useIsMobile,exports.useSessionStorageState=t.useSessionStorageState;
@@ -1,7 +1,7 @@
1
- import { useSessionStorageState as e } from "./use-session-storage-state.js";
2
- import { useBeforeUnloadWhenDirty as t } from "./use-before-unload-when-dirty.js";
3
- import { DEFAULT_MOBILE_BREAKPOINT as n, useIsMobile as r } from "./use-is-mobile.js";
1
+ import { DEFAULT_MOBILE_BREAKPOINT as e, useIsMobile as t } from "./use-is-mobile.js";
2
+ import { useSessionStorageState as n } from "./use-session-storage-state.js";
3
+ import { useBeforeUnloadWhenDirty as r } from "./use-before-unload-when-dirty.js";
4
4
  import { useDisclosure as i } from "./use-disclosure.js";
5
5
  import { useDebouncedCallback as a, useDebouncedValue as o } from "./use-debounce.js";
6
6
  import { useDataTableViewState as s } from "./use-data-table-view-state.js";
7
- export { n as DEFAULT_MOBILE_BREAKPOINT, t as useBeforeUnloadWhenDirty, s as useDataTableViewState, a as useDebouncedCallback, o as useDebouncedValue, i as useDisclosure, r as useIsMobile, e as useSessionStorageState };
7
+ export { e as DEFAULT_MOBILE_BREAKPOINT, r as useBeforeUnloadWhenDirty, s as useDataTableViewState, a as useDebouncedCallback, o as useDebouncedValue, i as useDisclosure, t as useIsMobile, n as useSessionStorageState };