@mechane-ai/elements 0.17.1 → 0.17.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.
package/README.md CHANGED
@@ -99,6 +99,9 @@ Detail titles wrap; list metadata truncates. Sidebar items share contiguous hit
99
99
  navigation and reserve the divided sidebar footer for persistent account controls. Use
100
100
  `SidebarFooter layout="navigation"` for a group of commands; its intrinsic height keeps the scrolling navigation clear.
101
101
 
102
+ Navigation closes the mobile drawer and preserves focus set by the destination. Use
103
+ `NavigationItem shouldCloseOnActivate={false}` for menu triggers.
104
+
102
105
  `AppShell shouldFocus` temporarily hides navigation while retaining its expansion state. `ViewStack.Panel` keeps
103
106
  inactive content mounted and measurable but removes it from keyboard and assistive-technology navigation. The
104
107
  application owns which view is active and when to unmount it; use this for a draft or reading position that must survive
package/dist/layout.js CHANGED
@@ -120,39 +120,39 @@ function M({ children: e, label: t }) {
120
120
  }), e]
121
121
  });
122
122
  }
123
- function N({ children: e, icon: t, isSelected: n = !1, onClick: r, className: i, style: s, ...c }) {
124
- let l = d(E), u = p(), f = l !== null && !l.isExpanded;
123
+ function N({ children: e, icon: t, isSelected: n = !1, shouldCloseOnActivate: r = !0, onClick: i, className: s, style: c, ...l }) {
124
+ let u = d(E), f = p(), m = u !== null && !u.isExpanded;
125
125
  return /* @__PURE__ */ _("div", {
126
126
  ...{
127
127
  0: { className: "x78zum5 xeuugli x1ok0vyi" },
128
128
  1: { className: "x78zum5 xeuugli x1ok0vyi x1r7kqkb" }
129
129
  }[!!n | 0],
130
130
  children: /* @__PURE__ */ v(o, {
131
- ...c,
131
+ ...l,
132
132
  ...a({
133
- className: i,
134
- style: s,
133
+ className: s,
134
+ style: c,
135
135
  styles: {
136
136
  0: { className: "x9f619 x78zum5 x6s0dn4 x1ok0vyi xbixft xjbqb8w x1hz01jw xtqrqnz x1778rvt xj57cvi xvmahel xdpxx8g xkrqix3 x17lu4q8 x1480za7 x13qnu6 x9v5kkp x19rmrnh x1bqaal xc342km x1ypdohk xwj21n9 x1m8qfh3 x1nhvcw1 x1hnptsi x15rya3k x992rv9 x1avwmir xh8yej3 xeuugli xt970qd xksvo5r" },
137
137
  1: { className: "x9f619 x78zum5 x6s0dn4 x1ok0vyi xbixft xjbqb8w x1hz01jw xtqrqnz x1778rvt xj57cvi xvmahel xdpxx8g xkrqix3 x17lu4q8 x1480za7 x13qnu6 x9v5kkp x19rmrnh x1bqaal xc342km x1ypdohk xwj21n9 x1m8qfh3 x1hnptsi x15rya3k x992rv9 x1avwmir xh8yej3 xeuugli xt970qd xksvo5r xl56j7k x1l31gyv" }
138
- }[!!f | 0]
138
+ }[!!m | 0]
139
139
  }),
140
140
  "aria-current": n ? "page" : void 0,
141
- "aria-labelledby": c["aria-labelledby"] ?? (c["aria-label"] === void 0 ? u : void 0),
142
- title: c.title ?? (typeof e == "string" ? e : void 0),
141
+ "aria-labelledby": l["aria-labelledby"] ?? (l["aria-label"] === void 0 ? f : void 0),
142
+ title: l.title ?? (typeof e == "string" ? e : void 0),
143
143
  onClick: (e) => {
144
- r !== void 0 && r(e), !e.defaultPrevented && l !== null && l.onNavigate();
144
+ i !== void 0 && i(e), !e.defaultPrevented && u !== null && r && u.onNavigate();
145
145
  },
146
146
  children: [t != null && /* @__PURE__ */ _("span", {
147
147
  "aria-hidden": !0,
148
148
  className: "x3nfvp2 x6s0dn4 xl56j7k xtwnzbg x18utl2x x2lah0s",
149
149
  children: t
150
150
  }), /* @__PURE__ */ _("span", {
151
- id: u,
151
+ id: f,
152
152
  ...{
153
153
  0: { className: "xeuugli xb3r6kr xlyipyv xuxw1ft" },
154
154
  1: { className: "xeuugli xb3r6kr xlyipyv xuxw1ft x1s85apg xeod2sa" }
155
- }[!!f | 0],
155
+ }[!!m | 0],
156
156
  children: e
157
157
  })]
158
158
  })
@@ -252,7 +252,7 @@ var R = { drawer: {
252
252
  $$css: !0
253
253
  } };
254
254
  function z({ sidebarHeader: t, sidebar: n, footer: r, children: i, mainId: a = "main", shouldFocus: o = !1 }) {
255
- let [s, c] = h(!0), [l, u] = h(!1), [d] = h(() => e.createHandle()), g = p(), y = m(null), b = m(null);
255
+ let [s, c] = h(!0), [l, u] = h(!1), [d] = h(() => e.createHandle()), g = p(), y = m(null), b = m(null), x = m(!1);
256
256
  return f(() => {
257
257
  let e = globalThis.matchMedia(T.sidebarDesktopQuery);
258
258
  function t() {
@@ -267,7 +267,9 @@ function z({ sidebarHeader: t, sidebar: n, footer: r, children: i, mainId: a = "
267
267
  navigationToggleRef: y,
268
268
  mobileNavigationToggleRef: b,
269
269
  onToggle: () => c((e) => !e),
270
- onNavigate: () => u(!1)
270
+ onNavigate: () => {
271
+ x.current = l, u(!1);
272
+ }
271
273
  },
272
274
  children: [/* @__PURE__ */ v("div", {
273
275
  className: "x9f619 x1ov3xa9 x78zum5 xpvm0e4 xbixft x1hz01jw xtqrqnz x1778rvt xvmahel",
@@ -298,7 +300,14 @@ function z({ sidebarHeader: t, sidebar: n, footer: r, children: i, mainId: a = "
298
300
  onOpenChange: u,
299
301
  children: /* @__PURE__ */ v(e.Portal, { children: [/* @__PURE__ */ _(e.Backdrop, {}), /* @__PURE__ */ _(e.Viewport, { children: /* @__PURE__ */ v(e.Popup, {
300
302
  xstyle: R.drawer,
301
- finalFocus: () => globalThis.matchMedia(T.sidebarDesktopQuery).matches ? y.current : b.current,
303
+ finalFocus: () => {
304
+ if (x.current) {
305
+ x.current = !1;
306
+ let e = document.querySelector(`#${CSS.escape(a)}`), t = document.activeElement;
307
+ return t instanceof HTMLElement && e?.contains(t) === !0 ? t : e;
308
+ }
309
+ return globalThis.matchMedia(T.sidebarDesktopQuery).matches ? y.current : b.current;
310
+ },
302
311
  children: [/* @__PURE__ */ _(e.Title, {
303
312
  isVisuallyHidden: !0,
304
313
  children: "Navigation"
@@ -367,14 +376,14 @@ function U({ label: e, children: t, isFlush: n = !1, scrollRestorationId: r }) {
367
376
  children: t
368
377
  });
369
378
  }
370
- function ee({ children: e }) {
379
+ function W({ children: e }) {
371
380
  return /* @__PURE__ */ _("div", {
372
381
  className: "x2lah0s x1c8xbx5 x178xt8z x13fuv20 xhjagg4 xpvm0e4",
373
382
  children: e
374
383
  });
375
384
  }
376
385
  // packages/layout/src/view-stack.tsx
377
- function W({ children: e }) {
386
+ function ee({ children: e }) {
378
387
  return /* @__PURE__ */ _("div", {
379
388
  className: "x1n2onr6 x78zum5 xdt5ytf x98rzlu xeuugli x2lwn1j",
380
389
  children: e
@@ -392,7 +401,7 @@ function G({ isActive: e, children: t }) {
392
401
  });
393
402
  }
394
403
  var K = {
395
- Root: W,
404
+ Root: ee,
396
405
  Panel: G
397
406
  }, q = { action: {
398
407
  k7Eaqz: "xeuugli",
@@ -578,4 +587,4 @@ var ce = {
578
587
  Pane: oe,
579
588
  Handle: se
580
589
  };
581
- export { z as AppShell, B as DetailPage, V as FocusPage, j as Navigation, N as NavigationItem, P as NavigationLink, M as NavigationSection, X as PageContent, J as PageToolbar, ie as RecordPage, ce as Resizable, I as SidebarFooter, F as SidebarLabel, Y as ToolbarAction, K as ViewStack, H as Workbench, ee as WorkbenchFooter, U as WorkbenchScroll };
590
+ export { z as AppShell, B as DetailPage, V as FocusPage, j as Navigation, N as NavigationItem, P as NavigationLink, M as NavigationSection, X as PageContent, J as PageToolbar, ie as RecordPage, ce as Resizable, I as SidebarFooter, F as SidebarLabel, Y as ToolbarAction, K as ViewStack, H as Workbench, W as WorkbenchFooter, U as WorkbenchScroll };
@@ -24,6 +24,7 @@ type NavigationProps = {
24
24
  type NavigationItemProps = ComponentProps<typeof BaseButton> & {
25
25
  readonly icon?: ReactNode;
26
26
  readonly isSelected?: boolean;
27
+ readonly shouldCloseOnActivate?: boolean;
27
28
  };
28
29
  type NavigationLinkProps = ComponentProps<'a'> & {
29
30
  readonly icon?: ReactNode;
@@ -45,7 +46,7 @@ export declare function NavigationSection({ children, label, }: {
45
46
  readonly children: ReactNode;
46
47
  readonly label: string;
47
48
  }): ReactNode;
48
- export declare function NavigationItem({ children, icon, isSelected, onClick, className, style, ...props }: NavigationItemProps): ReactNode;
49
+ export declare function NavigationItem({ children, icon, isSelected, shouldCloseOnActivate, onClick, className, style, ...props }: NavigationItemProps): ReactNode;
49
50
  export declare function NavigationLink({ children, icon, isSelected, onClick, className, style, ...props }: NavigationLinkProps): ReactNode;
50
51
  export declare function SidebarLabel({ children, shouldGrow }: SidebarLabelProps): ReactNode;
51
52
  export declare function SidebarFooter({ children, layout }: SidebarFooterProps): ReactNode;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mechane-ai/elements",
3
- "version": "0.17.1",
3
+ "version": "0.17.2",
4
4
  "description": "Elements by Mechane — React components for applications, AI interfaces, and analytical graphics",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {