@astryxdesign/core 0.7.2-canary.01eab6a → 0.7.2-canary.0da784d

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 (41) hide show
  1. package/dist/AppShell/AppShell.d.ts.map +1 -1
  2. package/dist/AppShell/AppShell.js +40 -1
  3. package/dist/DropdownMenu/DropdownMenu.d.ts +1 -1
  4. package/dist/DropdownMenu/DropdownMenu.d.ts.map +1 -1
  5. package/dist/DropdownMenu/DropdownMenu.js +36 -7
  6. package/dist/DropdownMenu/lazyMenuBottomSheet.d.ts +24 -0
  7. package/dist/DropdownMenu/lazyMenuBottomSheet.d.ts.map +1 -0
  8. package/dist/DropdownMenu/lazyMenuBottomSheet.js +46 -0
  9. package/dist/MobileNav/MobileNav.d.ts +9 -0
  10. package/dist/MobileNav/MobileNav.d.ts.map +1 -1
  11. package/dist/MobileNav/MobileNav.js +30 -3
  12. package/package.json +3 -3
  13. package/scripts/agent-doc-state.mjs +38 -0
  14. package/scripts/postinstall.mjs +1 -1
  15. package/src/AppShell/AppShell.tsx +45 -1
  16. package/src/Card/Card.doc.mjs +1 -1
  17. package/src/Code/Code.doc.mjs +1 -0
  18. package/src/CommandPalette/CommandPalette.doc.mjs +2 -0
  19. package/src/Drawer/Drawer.doc.mjs +1 -0
  20. package/src/DropdownMenu/DropdownMenu.ssr.test.tsx +57 -0
  21. package/src/DropdownMenu/DropdownMenu.test.tsx +14 -1
  22. package/src/DropdownMenu/DropdownMenu.tsx +36 -8
  23. package/src/DropdownMenu/DropdownMenuLazySheet.test.tsx +126 -0
  24. package/src/DropdownMenu/__tests__/warmMenuBottomSheet.tsx +43 -0
  25. package/src/DropdownMenu/lazyMenuBottomSheet.ts +71 -0
  26. package/src/Field/FieldLabel.doc.mjs +133 -26
  27. package/src/Field/FieldLabel.spec.md +172 -0
  28. package/src/Field/__tests__/FieldLabelAudit.a11y.chromium.spec.ts +296 -0
  29. package/src/Icon/Icon.doc.mjs +36 -0
  30. package/src/Layout/LayoutHeader.doc.mjs +5 -0
  31. package/src/MetadataList/MetadataList.doc.mjs +1 -1
  32. package/src/MobileNav/MobileNav.tsx +30 -3
  33. package/src/MobileNav/MobileNavCloseEdgeCases.test.tsx +173 -15
  34. package/src/MoreMenu/MoreMenu.test.tsx +5 -1
  35. package/src/ProgressBar/ProgressBar.doc.mjs +1 -0
  36. package/src/Resizable/useResizable.doc.mjs +2 -0
  37. package/src/ScrollableArea/ScrollableArea.doc.mjs +1 -1
  38. package/src/Spinner/Spinner.doc.mjs +1 -1
  39. package/src/Timestamp/Timestamp.doc.mjs +1 -1
  40. package/src/ToggleButton/ToggleButtonGroup.doc.mjs +4 -0
  41. package/src/postinstall.test.mjs +46 -0
@@ -1 +1 @@
1
- {"version":3,"file":"AppShell.d.ts","sourceRoot":"","sources":["../../src/AppShell/AppShell.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAQL,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAmBf,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAQ5C,OAAO,EAEL,KAAK,mBAAmB,EACzB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,SAAS,CAAC;AAwBhD;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG,mBAAmB,GAAG,MAAM,CAAC;AAE9D;;;;;;;GAOG;AAEH;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,kBAAkB,CAAC;AAEvD;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB;;OAEG;IACH,YAAY,CAAC,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;IAE7B;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAEzB;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,SAAS,CAAC,EAAE,KAAK,GAAG,eAAe,GAAG,SAAS,CAAC;IAEhD;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,OAAO,CAAC,EAAE,SAAS,CAAC;IAEpB;;;OAGG;IACH,MAAM,CAAC,EAAE,SAAS,CAAC;CACpB;AAkLD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,QAAQ,CAAC,EACvB,OAAoB,EACpB,MAAM,EACN,QAAQ,EACR,cAAc,EACd,aAAa,EAAE,UAAU,EACzB,MAAe,EACf,SAAS,EACT,OAAO,EACP,MAAM,EACN,MAAM,EACN,SAAS,EACT,KAAK,EACL,GAAG,EACH,GAAG,IAAI,EACR,EAAE,aAAa,qBA0bf;yBAzce,QAAQ"}
@@ -29,6 +29,7 @@ import { LayoutHeader } from "../Layout/LayoutHeader.js";
29
29
  import { LayoutPanel } from "../Layout/LayoutPanel.js";
30
30
  import { LayoutContent } from "../Layout/LayoutContent.js";
31
31
  import { MobileNavToggle } from "../MobileNav/MobileNavToggle.js";
32
+ import { MAX_CLOSE_DELAY_MS as MOBILE_NAV_MAX_CLOSE_DELAY_MS } from "../MobileNav/MobileNav.js";
32
33
  import { SideNavRenderContext } from "../SideNav/SideNavRenderContext.js";
33
34
  import { TopNavRenderContext } from "../TopNav/TopNavRenderContext.js";
34
35
  import { TopNavMobileContentContext } from "../TopNav/TopNavMobileContentContext.js";
@@ -62,6 +63,20 @@ const ActivityWrapper = HasActivity ? ({
62
63
 
63
64
  const MAIN_CONTENT_ID = 'astryx-app-shell-main';
64
65
 
66
+ /**
67
+ * Extra time, on top of MobileNav's own worst-case close delay, that
68
+ * AppShell waits before flipping its `Activity` boundary to `'hidden'`.
69
+ *
70
+ * React's `Activity` hides its subtree with `display: none !important`
71
+ * synchronously in the same commit as the mode flip, and re-runs the
72
+ * cleanup of every effect inside it — which would otherwise clear
73
+ * MobileNav's own scheduled `dialog.close()` before it fires, or cut off
74
+ * its slide-out CSS transition before it plays (#5701). Waiting strictly
75
+ * longer than MobileNav's own cap, rather than the same duration, means
76
+ * this never turns into a race decided by browser timer-firing order.
77
+ */
78
+ const ACTIVITY_HIDE_BUFFER_MS = 50;
79
+
65
80
  // =============================================================================
66
81
  // Types
67
82
  // =============================================================================
@@ -259,6 +274,30 @@ export function AppShell({
259
274
  const isBelowBreakpoint = useMediaQuery(breakpointQuery, sideNavBreakpoint === 'none' ? false : mobileNavConfig?.defaultIsMobile);
260
275
  const [uncontrolledMobileOpen, setUncontrolledMobileOpen] = useState(false);
261
276
  const isMobileNavOpen = mobileNavConfig?.isOpen ?? uncontrolledMobileOpen;
277
+
278
+ // Holds the mobile nav's `Activity` boundary visible for a beat after a
279
+ // close, so MobileNav's own close effect gets a real chance to run its
280
+ // slide-out transition and schedule its delayed `dialog.close()` before
281
+ // Activity hides the subtree (#5701). Only the CLOSE is deferred: opening
282
+ // reads `isMobileNavOpen` directly below, so a controlled open is visible in
283
+ // the commit that carries it instead of one effect later.
284
+ const [isMobileNavCloseHeld, setIsMobileNavCloseHeld] = useState(isMobileNavOpen);
285
+ // Arm the hold during render, from the open state itself, so no Effect has
286
+ // to copy props into state; the Effect below only owns the release timer.
287
+ if (isMobileNavOpen && !isMobileNavCloseHeld) {
288
+ setIsMobileNavCloseHeld(true);
289
+ }
290
+ useEffect(() => {
291
+ if (!HasActivity || isMobileNavOpen) {
292
+ return;
293
+ }
294
+ const delayMs = window.matchMedia('(prefers-reduced-motion: reduce)').matches ? 0 : MOBILE_NAV_MAX_CLOSE_DELAY_MS + ACTIVITY_HIDE_BUFFER_MS;
295
+ const timeout = setTimeout(() => {
296
+ setIsMobileNavCloseHeld(false);
297
+ }, delayMs);
298
+ return () => clearTimeout(timeout);
299
+ }, [isMobileNavOpen]);
300
+ const isMobileNavActivityVisible = isMobileNavOpen || isMobileNavCloseHeld;
262
301
  const mobileNavOnOpenChange = mobileNavConfig?.onOpenChange;
263
302
  const setMobileNavOpen = useCallback(open => {
264
303
  if (!mobileNavIsControlled) {
@@ -520,7 +559,7 @@ export function AppShell({
520
559
  start: sideNavContent,
521
560
  content: mainContent
522
561
  }), shouldRenderMobileNavReactNode && mobileNavReactNode, shouldRenderConfigContent && mobileNavConfigContent, isBelowBreakpoint && !mobileNavDisabled && mobileNavReactNode == null && !mobileNavConfigContent && /*#__PURE__*/_jsxs(ActivityWrapper, {
523
- mode: isMobileNavOpen ? 'visible' : 'hidden',
562
+ mode: isMobileNavActivityVisible ? 'visible' : 'hidden',
524
563
  children: [hasSideNav && !hasTopNav && /*#__PURE__*/_jsx(SideNavRenderContext, {
525
564
  value: "drawer",
526
565
  children: sideNav
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @file DropdownMenu.tsx
3
- * @input Uses React, StyleX, usePopover, MenuBottomSheet, Button, List,
3
+ * @input Uses React, StyleX, usePopover, MenuBottomSheet (lazy), Button, List,
4
4
  * useListFocus, and the shared viewport-safe menu-width resolver
5
5
  * @output Exports DropdownMenu with caller-selected popover or bottom-sheet
6
6
  * presentation
@@ -1 +1 @@
1
- {"version":3,"file":"DropdownMenu.d.ts","sourceRoot":"","sources":["../../src/DropdownMenu/DropdownMenu.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,KAAK,EAAE,EAOZ,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAGf,OAAO,EAAS,KAAK,WAAW,EAAC,MAAM,WAAW,CAAC;AAKnD,OAAO,KAAK,EAAC,qBAAqB,EAAC,MAAM,oBAAoB,CAAC;AA0B9D,OAAO,EAEL,KAAK,oBAAoB,EAC1B,MAAM,kCAAkC,CAAC;AAI1C,OAAO,KAAK,EAAC,cAAc,EAAE,cAAc,EAAC,MAAM,mBAAmB,CAAC;AAStE,OAAO,KAAK,EAAC,SAAS,E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gB,YAAY,CAAC,KAAK,EAAE,iBAAiB,qBA4CpD;yBA5Ce,YAAY"}
@@ -4,7 +4,7 @@
4
4
 
5
5
  /**
6
6
  * @file DropdownMenu.tsx
7
- * @input Uses React, StyleX, usePopover, MenuBottomSheet, Button, List,
7
+ * @input Uses React, StyleX, usePopover, MenuBottomSheet (lazy), Button, List,
8
8
  * useListFocus, and the shared viewport-safe menu-width resolver
9
9
  * @output Exports DropdownMenu with caller-selected popover or bottom-sheet
10
10
  * presentation
@@ -58,8 +58,8 @@ import { resolveMenuWidth } from "./menuWidth.js";
58
58
  import "../Layer/layerViewportInset.stylex.js";
59
59
  import { layerViewportInset } from "../Layer/layerViewportInset.stylex.js";
60
60
  import { useAdaptivePresentation } from "../hooks/useAdaptivePresentation.js";
61
- import { MenuBottomSheet } from "./MenuBottomSheet.js";
62
- import { MenuBottomSheetActionList } from "./MenuBottomSheetActionList.js";
61
+ // Loaded on demand: only the bottom-sheet presentation renders the sheet.
62
+ import { MenuBottomSheet, MenuBottomSheetActionList } from "./lazyMenuBottomSheet.js";
63
63
  import { layerAnimations } from "../Layer/layerAnimations.stylex.js";
64
64
  import "../theme/tokens.stylex.js";
65
65
  import { spacingVars, colorVars, radiusVars, durationVars, easeVars } from "../theme/tokens.stylex.js";
@@ -491,12 +491,41 @@ function DropdownMenuBottomSheet({
491
491
  if (!isOpen || openModalityRef.current !== 'keyboard') {
492
492
  return;
493
493
  }
494
- const frame = requestAnimationFrame(() => {
495
- actionListRef.current?.querySelector('button:not(:disabled), a[href]')?.focus({
496
- preventScroll: true
494
+ const findFirstAction = () => actionListRef.current?.querySelector('button:not(:disabled), a[href]') ?? null;
495
+ let observer = null;
496
+ let frame = requestAnimationFrame(() => {
497
+ const action = findFirstAction();
498
+ if (action != null) {
499
+ action.focus({
500
+ preventScroll: true
501
+ });
502
+ return;
503
+ }
504
+ // The sheet loads on demand, so a keyboard open can arrive before its
505
+ // rows exist. Wait for them, then focus a frame later so the sheet's
506
+ // own open-focus has already run.
507
+ observer = new MutationObserver(() => {
508
+ const loaded = findFirstAction();
509
+ if (loaded == null) {
510
+ return;
511
+ }
512
+ observer?.disconnect();
513
+ observer = null;
514
+ frame = requestAnimationFrame(() => {
515
+ loaded.focus({
516
+ preventScroll: true
517
+ });
518
+ });
519
+ });
520
+ observer.observe(document.body, {
521
+ childList: true,
522
+ subtree: true
497
523
  });
498
524
  });
499
- return () => cancelAnimationFrame(frame);
525
+ return () => {
526
+ cancelAnimationFrame(frame);
527
+ observer?.disconnect();
528
+ };
500
529
  }, [currentItems, isOpen]);
501
530
  useEffect(() => {
502
531
  if (!isOpen) {
@@ -0,0 +1,24 @@
1
+ /**
2
+ * @file lazyMenuBottomSheet.ts
3
+ * @input Uses React lazy and Suspense, useIsHydrating, MenuBottomSheet, and
4
+ * MenuBottomSheetActionList
5
+ * @output Exports MenuBottomSheet and MenuBottomSheetActionList wrappers that
6
+ * load the touch sheet on first render
7
+ * @position Internal to DropdownMenu
8
+ *
9
+ * The touch sheet (BottomSheet, its gestures, and the touch action list) only
10
+ * renders for the bottom-sheet presentation. Loading it on demand keeps it out
11
+ * of pages whose dropdowns only open as anchored popovers. Each wrapper keeps
12
+ * the wrapped component's props and renders nothing until its module loads.
13
+ *
14
+ * Neither wrapper renders on the server or in the render that hydrates server
15
+ * HTML (spec:AST-013 FR9): a lazy component that has not loaded yet would
16
+ * leave server markup incomplete and abort hydration. The closed sheet has no
17
+ * visible markup, so it first renders right after hydration.
18
+ */
19
+ import { type ComponentProps, type ReactElement } from 'react';
20
+ import type { MenuBottomSheet as EagerMenuBottomSheet } from './MenuBottomSheet';
21
+ import type { MenuBottomSheetActionList as EagerMenuBottomSheetActionList } from './MenuBottomSheetActionList';
22
+ export declare function MenuBottomSheet(props: ComponentProps<typeof EagerMenuBottomSheet>): ReactElement | null;
23
+ export declare function MenuBottomSheetActionList(props: ComponentProps<typeof EagerMenuBottomSheetActionList>): ReactElement | null;
24
+ //# sourceMappingURL=lazyMenuBottomSheet.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lazyMenuBottomSheet.d.ts","sourceRoot":"","sources":["../../src/DropdownMenu/lazyMenuBottomSheet.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAIL,KAAK,cAAc,EACnB,KAAK,YAAY,EAClB,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EAAC,eAAe,IAAI,oBAAoB,EAAC,MAAM,mBAAmB,CAAC;AAC/E,OAAO,KAAK,EAAC,yBAAyB,IAAI,8BAA8B,EAAC,MAAM,6BAA6B,CAAC;AAc7G,wBAAgB,eAAe,CAC7B,KAAK,EAAE,cAAc,CAAC,OAAO,oBAAoB,CAAC,GACjD,YAAY,GAAG,IAAI,CASrB;AAED,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,cAAc,CAAC,OAAO,8BAA8B,CAAC,GAC3D,YAAY,GAAG,IAAI,CASrB"}
@@ -0,0 +1,46 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ 'use client';
4
+
5
+ /**
6
+ * @file lazyMenuBottomSheet.ts
7
+ * @input Uses React lazy and Suspense, useIsHydrating, MenuBottomSheet, and
8
+ * MenuBottomSheetActionList
9
+ * @output Exports MenuBottomSheet and MenuBottomSheetActionList wrappers that
10
+ * load the touch sheet on first render
11
+ * @position Internal to DropdownMenu
12
+ *
13
+ * The touch sheet (BottomSheet, its gestures, and the touch action list) only
14
+ * renders for the bottom-sheet presentation. Loading it on demand keeps it out
15
+ * of pages whose dropdowns only open as anchored popovers. Each wrapper keeps
16
+ * the wrapped component's props and renders nothing until its module loads.
17
+ *
18
+ * Neither wrapper renders on the server or in the render that hydrates server
19
+ * HTML (spec:AST-013 FR9): a lazy component that has not loaded yet would
20
+ * leave server markup incomplete and abort hydration. The closed sheet has no
21
+ * visible markup, so it first renders right after hydration.
22
+ */
23
+ import { createElement, lazy, Suspense } from 'react';
24
+ import { useIsHydrating } from "../hooks/useIsHydrating.js";
25
+ const LazyMenuBottomSheet = /*#__PURE__*/lazy(async () => import("./MenuBottomSheet.js").then(module => ({
26
+ default: module.MenuBottomSheet
27
+ })));
28
+ const LazyMenuBottomSheetActionList = /*#__PURE__*/lazy(async () => import("./MenuBottomSheetActionList.js").then(module => ({
29
+ default: module.MenuBottomSheetActionList
30
+ })));
31
+ export function MenuBottomSheet(props) {
32
+ if (useIsHydrating()) {
33
+ return null;
34
+ }
35
+ return /*#__PURE__*/createElement(Suspense, {
36
+ fallback: null
37
+ }, /*#__PURE__*/createElement(LazyMenuBottomSheet, props));
38
+ }
39
+ export function MenuBottomSheetActionList(props) {
40
+ if (useIsHydrating()) {
41
+ return null;
42
+ }
43
+ return /*#__PURE__*/createElement(Suspense, {
44
+ fallback: null
45
+ }, /*#__PURE__*/createElement(LazyMenuBottomSheetActionList, props));
46
+ }
@@ -36,6 +36,15 @@
36
36
  */
37
37
  import { type ReactNode } from 'react';
38
38
  import type { BaseProps } from '../BaseProps';
39
+ /**
40
+ * Longest the drawer will wait before closing, however long the hold is.
41
+ *
42
+ * Exported so `AppShell` can defer hiding this drawer's `Activity` boundary
43
+ * by at least this long too (`ACTIVITY_HIDE_BUFFER_MS` in AppShell.tsx) —
44
+ * otherwise Activity's `display: none !important` lands before this delay's
45
+ * own scheduled `dialog.close()` has a chance to run (#5701).
46
+ */
47
+ export declare const MAX_CLOSE_DELAY_MS = 250;
39
48
  /**
40
49
  * Shortest duration in a `transition-duration` list, in ms; null if unreadable.
41
50
  *
@@ -1 +1 @@
1
- {"version":3,"file":"MobileNav.d.ts","sourceRoot":"","sources":["../../src/MobileNav/MobileNav.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,EAOL,KAAK,SAAS,EAEf,MAAM,OAAO,CAAC;AAwBf,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAiM5C;;;;;;;;;;GAUG;AACH,wBAAgB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S,EAAC,MAAM,cAAc,CAAC;AA4L5C;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,MAAM,CAAC;AAItC;;;;;;;;;;GAUG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAkBpE;AA+DD,MAAM,WAAW,cAAe,SAAQ,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC;IAC9D,wCAAwC;IACxC,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;IACnC;;;;OAIG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;IAEzC;;OAEG;IACH,QAAQ,EAAE,SAAS,CAAC;IAEpB;;;;OAIG;IACH,MAAM,CAAC,EAAE,SAAS,CAAC;IAEnB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;;;;;;OAQG;IACH,IAAI,CAAC,EAAE,OAAO,GAAG,KAAK,GAAG,MAAM,CAAC;IAEhC;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAMD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,SAAS,CAAC,EACxB,MAAM,EAAE,UAAU,EAClB,YAAY,EAAE,gBAAgB,EAC9B,QAAQ,EACR,MAAM,EACN,KAAW,EACX,IAAa,EACb,KAAK,EACL,aAAa,EAAE,MAAM,EACrB,MAAM,EACN,SAAS,EACT,KAAK,EACL,OAAO,EAAE,WAAW,EACpB,GAAG,EACH,GAAG,IAAI,EACR,EAAE,cAAc,+BAuQhB;yBAtRe,SAAS"}
@@ -162,8 +162,15 @@ const dynamicStyles = {
162
162
  // Close timing
163
163
  // =============================================================================
164
164
 
165
- /** Longest the drawer will wait before closing, however long the hold is. */
166
- const MAX_CLOSE_DELAY_MS = 250;
165
+ /**
166
+ * Longest the drawer will wait before closing, however long the hold is.
167
+ *
168
+ * Exported so `AppShell` can defer hiding this drawer's `Activity` boundary
169
+ * by at least this long too (`ACTIVITY_HIDE_BUFFER_MS` in AppShell.tsx) —
170
+ * otherwise Activity's `display: none !important` lands before this delay's
171
+ * own scheduled `dialog.close()` has a chance to run (#5701).
172
+ */
173
+ export const MAX_CLOSE_DELAY_MS = 250;
167
174
  /** Fraction of the hold to close at, so the close never lands on its boundary. */
168
175
  const CLOSE_WITHIN_HOLD = 0.6;
169
176
 
@@ -308,6 +315,21 @@ export function MobileNav({
308
315
  // Element that was focused when the drawer opened; focus goes back to it
309
316
  // once the native dialog has closed (see closeAndRestoreFocus).
310
317
  const triggerElementRef = useRef(null);
318
+
319
+ // Keeps the dialog rendered from the commit that closes it until the delayed
320
+ // `close()` below has run. The `display` transition on the dialog is meant to
321
+ // do this, but a browser that does not hold a discrete `display` transition
322
+ // (WebKit) drops the dialog to `display: none` at once while it is still an
323
+ // open modal: nothing is visible, yet the whole page stays inert until the
324
+ // timer fires. Set during render, so it is already true in the commit that
325
+ // closes. The drawer's transform and the backdrop stay keyed to `isOpen`, so
326
+ // the slide-out is unchanged.
327
+ const [isCloseHeld, setIsCloseHeld] = useState(false);
328
+ const [wasOpen, setWasOpen] = useState(isOpen);
329
+ if (wasOpen !== isOpen) {
330
+ setWasOpen(isOpen);
331
+ setIsCloseHeld(!isOpen);
332
+ }
311
333
  const gutterRef = useRef(null);
312
334
 
313
335
  // Gives back the gutter held open in place of the hidden scrollbar.
@@ -374,7 +396,12 @@ export function MobileNav({
374
396
  releaseGutter();
375
397
  closeTimeoutRef.current = setTimeout(() => {
376
398
  closeAndRestoreFocus(dialog, triggerElementRef);
399
+ setIsCloseHeld(false);
377
400
  }, resolveCloseDelay(dialog));
401
+ } else {
402
+ // Nothing is open, so there is no close to hold the dialog for, and no
403
+ // close timer is left to release the hold.
404
+ setIsCloseHeld(false);
378
405
  }
379
406
  return () => {
380
407
  if (closeTimeoutRef.current) {
@@ -444,7 +471,7 @@ export function MobileNav({
444
471
  id: dialogId,
445
472
  ...mergeProps(themeProps('mobile-nav', {
446
473
  side: resolvedSide
447
- }), stylex.props(layerTextReset.reset, layerStructureReset.reset, styles.dialog, overlayPaddingReset.reset, isOpen && styles.open, styles.backdrop, isOpen && styles.backdropOpen, xstyle), className, style),
474
+ }), stylex.props(layerTextReset.reset, layerStructureReset.reset, styles.dialog, overlayPaddingReset.reset, (isOpen || isCloseHeld) && styles.open, styles.backdrop, isOpen && styles.backdropOpen, xstyle), className, style),
448
475
  ...rest,
449
476
  "data-testid": testId,
450
477
  "aria-label": label ?? (typeof header === 'string' ? header : t('@astryx.mobileNav.navigation')),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astryxdesign/core",
3
- "version": "0.7.2-canary.01eab6a",
3
+ "version": "0.7.2-canary.0da784d",
4
4
  "displayName": "Astryx Core",
5
5
  "description": "The component library. Accessible, themeable React components with built-in spacing, dark mode, and StyleX styling.",
6
6
  "author": "Meta Open Source",
@@ -792,8 +792,8 @@
792
792
  "react-dom": ">=19.0.0"
793
793
  },
794
794
  "devDependencies": {
795
- "@astryxdesign/a11y-spec": "0.7.2-canary.01eab6a",
796
- "@astryxdesign/cli": "0.7.2-canary.01eab6a",
795
+ "@astryxdesign/a11y-spec": "0.7.2-canary.0da784d",
796
+ "@astryxdesign/cli": "0.7.2-canary.0da784d",
797
797
  "@babel/cli": "^7.29.7",
798
798
  "@babel/core": "^7.29.7",
799
799
  "@babel/preset-react": "^7.29.7",
@@ -106,6 +106,44 @@ export function isAstryxInitialized(targetDir = process.cwd()) {
106
106
  return false;
107
107
  }
108
108
 
109
+ /**
110
+ * Does an agent working in `startDir` already have the Astryx prompt in reach?
111
+ *
112
+ * Coding agents read the agent docs between the repository root and the folder
113
+ * they work in. So inside a git repository, init's block in any folder from
114
+ * `startDir` up to the repository root counts: a workspace package of a
115
+ * monorepo initialized at its root is set up. Outside a repository only
116
+ * `startDir` itself is checked, as {@link isAstryxInitialized} does. Both the
117
+ * per-command nudge and the postinstall nudges ask this.
118
+ *
119
+ * @param {string} [startDir=process.cwd()]
120
+ * @returns {boolean}
121
+ */
122
+ export function isAstryxPromptInReach(startDir = process.cwd()) {
123
+ const start = path.resolve(startDir);
124
+ const repositoryRoot = findRepositoryRoot(start);
125
+ if (!repositoryRoot) return isAstryxInitialized(start);
126
+ for (let dir = start; ; dir = path.dirname(dir)) {
127
+ if (isAstryxInitialized(dir)) return true;
128
+ if (dir === repositoryRoot) return false;
129
+ }
130
+ }
131
+
132
+ /**
133
+ * The nearest folder at or above `start` that holds `.git` (a folder, or the
134
+ * file a worktree uses), or null outside a repository.
135
+ * @param {string} start
136
+ * @returns {string | null}
137
+ */
138
+ function findRepositoryRoot(start) {
139
+ for (let dir = start; ; ) {
140
+ if (fs.existsSync(path.join(dir, '.git'))) return dir;
141
+ const parent = path.dirname(dir);
142
+ if (parent === dir) return null;
143
+ dir = parent;
144
+ }
145
+ }
146
+
109
147
  /**
110
148
  * The one-line next-step both postinstall nudges print. Kept here so layer 1
111
149
  * (core) and layer 2 (cli) can never word it differently.
@@ -45,7 +45,7 @@ async function main() {
45
45
  contract.shouldNudge({
46
46
  scriptPath: HERE,
47
47
  npmCommand: process.env.npm_command,
48
- isSetUp: contract.isAstryxInitialized(root),
48
+ isSetUp: contract.isAstryxPromptInReach(root),
49
49
  })
50
50
  ) {
51
51
  process.stdout.write(contract.SETUP_NUDGE);
@@ -43,6 +43,7 @@ import {LayoutHeader} from '../Layout/LayoutHeader';
43
43
  import {LayoutPanel} from '../Layout/LayoutPanel';
44
44
  import {LayoutContent} from '../Layout/LayoutContent';
45
45
  import {MobileNavToggle} from '../MobileNav/MobileNavToggle';
46
+ import {MAX_CLOSE_DELAY_MS as MOBILE_NAV_MAX_CLOSE_DELAY_MS} from '../MobileNav/MobileNav';
46
47
  import {SideNavRenderContext} from '../SideNav/SideNavRenderContext';
47
48
  import {TopNavRenderContext} from '../TopNav/TopNavRenderContext';
48
49
  import {TopNavMobileContentContext} from '../TopNav/TopNavMobileContentContext';
@@ -81,6 +82,20 @@ const ActivityWrapper = HasActivity
81
82
 
82
83
  const MAIN_CONTENT_ID = 'astryx-app-shell-main';
83
84
 
85
+ /**
86
+ * Extra time, on top of MobileNav's own worst-case close delay, that
87
+ * AppShell waits before flipping its `Activity` boundary to `'hidden'`.
88
+ *
89
+ * React's `Activity` hides its subtree with `display: none !important`
90
+ * synchronously in the same commit as the mode flip, and re-runs the
91
+ * cleanup of every effect inside it — which would otherwise clear
92
+ * MobileNav's own scheduled `dialog.close()` before it fires, or cut off
93
+ * its slide-out CSS transition before it plays (#5701). Waiting strictly
94
+ * longer than MobileNav's own cap, rather than the same duration, means
95
+ * this never turns into a race decided by browser timer-firing order.
96
+ */
97
+ const ACTIVITY_HIDE_BUFFER_MS = 50;
98
+
84
99
  // =============================================================================
85
100
  // Types
86
101
  // =============================================================================
@@ -525,6 +540,34 @@ export function AppShell({
525
540
  const [uncontrolledMobileOpen, setUncontrolledMobileOpen] = useState(false);
526
541
  const isMobileNavOpen = mobileNavConfig?.isOpen ?? uncontrolledMobileOpen;
527
542
 
543
+ // Holds the mobile nav's `Activity` boundary visible for a beat after a
544
+ // close, so MobileNav's own close effect gets a real chance to run its
545
+ // slide-out transition and schedule its delayed `dialog.close()` before
546
+ // Activity hides the subtree (#5701). Only the CLOSE is deferred: opening
547
+ // reads `isMobileNavOpen` directly below, so a controlled open is visible in
548
+ // the commit that carries it instead of one effect later.
549
+ const [isMobileNavCloseHeld, setIsMobileNavCloseHeld] =
550
+ useState(isMobileNavOpen);
551
+ // Arm the hold during render, from the open state itself, so no Effect has
552
+ // to copy props into state; the Effect below only owns the release timer.
553
+ if (isMobileNavOpen && !isMobileNavCloseHeld) {
554
+ setIsMobileNavCloseHeld(true);
555
+ }
556
+ useEffect(() => {
557
+ if (!HasActivity || isMobileNavOpen) {
558
+ return;
559
+ }
560
+ const delayMs = window.matchMedia('(prefers-reduced-motion: reduce)')
561
+ .matches
562
+ ? 0
563
+ : MOBILE_NAV_MAX_CLOSE_DELAY_MS + ACTIVITY_HIDE_BUFFER_MS;
564
+ const timeout = setTimeout(() => {
565
+ setIsMobileNavCloseHeld(false);
566
+ }, delayMs);
567
+ return () => clearTimeout(timeout);
568
+ }, [isMobileNavOpen]);
569
+ const isMobileNavActivityVisible = isMobileNavOpen || isMobileNavCloseHeld;
570
+
528
571
  const mobileNavOnOpenChange = mobileNavConfig?.onOpenChange;
529
572
  const setMobileNavOpen = useCallback(
530
573
  (open: boolean) => {
@@ -864,7 +907,8 @@ export function AppShell({
864
907
  !mobileNavDisabled &&
865
908
  mobileNavReactNode == null &&
866
909
  !mobileNavConfigContent && (
867
- <ActivityWrapper mode={isMobileNavOpen ? 'visible' : 'hidden'}>
910
+ <ActivityWrapper
911
+ mode={isMobileNavActivityVisible ? 'visible' : 'hidden'}>
868
912
  {/* SideNav drawer — always mounted so presence detection works.
869
913
  Hidden when TopNav owns the drawer (combined mode passes
870
914
  sideNav via TopNav's mobile content context instead). */}
@@ -83,7 +83,7 @@ export const docs = {
83
83
  code: `
84
84
  import {Card} from '@astryxdesign/core/Card';
85
85
  import {Grid} from '@astryxdesign/core/Grid';
86
- import {VStack} from '@astryxdesign/core/Layout';
86
+ import {VStack} from '@astryxdesign/core/VStack';
87
87
  import {Heading} from '@astryxdesign/core/Heading';
88
88
  import {Text} from '@astryxdesign/core/Text';
89
89
 
@@ -4,6 +4,7 @@
4
4
  export const docs = {
5
5
  name: 'Code',
6
6
  displayName: 'Code',
7
+ keywords: ['inlinecode', 'monospace'],
7
8
  group: 'Code',
8
9
  category: 'Content',
9
10
  description:
@@ -87,6 +87,8 @@ export const docs = {
87
87
  'modal',
88
88
  'dialog',
89
89
  'navigation',
90
+ 'commandmenu',
91
+ 'cmdk',
90
92
  ],
91
93
  description:
92
94
  'Root component. Manages open state, search, keyboard navigation, and composition slots.',
@@ -55,6 +55,7 @@ export const docs = {
55
55
  'sidebar',
56
56
  'dialog',
57
57
  'side drawer',
58
+ 'sidesheet',
58
59
  ],
59
60
  // No isInline docs-preview prop (the drawer has no inline containment), so
60
61
  // this is the overlay preview: closed on load with an open trigger, knobs
@@ -0,0 +1,57 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file DropdownMenu.ssr.test.tsx
5
+ * @input DropdownMenu server markup and React hydration
6
+ * @output Proves a bottom-sheet DropdownMenu hydrates without a recoverable
7
+ * error while its on-demand sheet has not loaded (spec:AST-013 FR9)
8
+ * @position SSR acceptance test for DropdownMenu
9
+ */
10
+
11
+ import {act} from 'react';
12
+ import {afterEach, describe, expect, it, vi} from 'vitest';
13
+ import {hydrateRoot} from 'react-dom/client';
14
+ import {renderToString} from 'react-dom/server';
15
+
16
+ afterEach(() => {
17
+ vi.restoreAllMocks();
18
+ document.body.replaceChildren();
19
+ });
20
+
21
+ async function serverRenderThenHydrate(): Promise<unknown[]> {
22
+ // A fresh module graph is a fresh server process: the sheet has not loaded.
23
+ vi.resetModules();
24
+ const {DropdownMenu} = await import('./DropdownMenu');
25
+ const tree = (
26
+ <DropdownMenu
27
+ button={{label: 'Actions'}}
28
+ presentation="bottom-sheet"
29
+ items={[{label: 'Edit project'}, {label: 'Delete'}]}
30
+ />
31
+ );
32
+ const container = document.createElement('div');
33
+ container.innerHTML = renderToString(tree);
34
+ document.body.appendChild(container);
35
+
36
+ vi.spyOn(console, 'error').mockImplementation(() => {});
37
+ const recoverableErrors: unknown[] = [];
38
+ let root!: ReturnType<typeof hydrateRoot>;
39
+ await act(async () => {
40
+ root = hydrateRoot(container, tree, {
41
+ onRecoverableError: error => recoverableErrors.push(error),
42
+ });
43
+ });
44
+ await act(async () => {
45
+ root.unmount();
46
+ });
47
+ container.remove();
48
+ return recoverableErrors;
49
+ }
50
+
51
+ describe('DropdownMenu — SSR', () => {
52
+ it('hydrates a bottom-sheet menu cleanly on the first renders of a server process', async () => {
53
+ expect(await serverRenderThenHydrate()).toEqual([]);
54
+ expect(await serverRenderThenHydrate()).toEqual([]);
55
+ expect(await serverRenderThenHydrate()).toEqual([]);
56
+ }, 30000);
57
+ });
@@ -9,7 +9,15 @@
9
9
  * SYNC: When DropdownMenu.tsx changes, update tests to match new behavior
10
10
  */
11
11
 
12
- import {describe, it, expect, vi, beforeEach, afterEach} from 'vitest';
12
+ import {
13
+ describe,
14
+ it,
15
+ expect,
16
+ vi,
17
+ beforeAll,
18
+ beforeEach,
19
+ afterEach,
20
+ } from 'vitest';
13
21
  import {readFileSync} from 'node:fs';
14
22
  import {render, screen, fireEvent, waitFor, act} from '@testing-library/react';
15
23
  import userEvent from '@testing-library/user-event';
@@ -19,6 +27,7 @@ import {DropdownMenu, type DropdownMenuTriggerProps} from './DropdownMenu';
19
27
  import {DropdownMenuItem} from './DropdownMenuItem';
20
28
  import {DropdownMenuDivider} from './DropdownMenuDivider';
21
29
  import {DropdownMenuGroup} from './DropdownMenuGroup';
30
+ import {warmMenuBottomSheet} from './__tests__/warmMenuBottomSheet';
22
31
  import {DropdownMenuSubMenu} from './DropdownMenuSubMenu';
23
32
  import {Divider} from '../Divider';
24
33
  import {rtlStyles} from '../utils';
@@ -74,6 +83,10 @@ beforeEach(() => {
74
83
  };
75
84
  });
76
85
 
86
+ // The touch sheet is loaded lazily; resolve it once so sheets below render
87
+ // synchronously.
88
+ beforeAll(warmMenuBottomSheet, 20000);
89
+
77
90
  describe('DropdownMenu', () => {
78
91
  it('renders trigger button with label', () => {
79
92
  render(