@astryxdesign/core 0.4.1 → 0.4.2-canary.356d2f9

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 (201) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/dist/Avatar/Avatar.d.ts +4 -1
  3. package/dist/Avatar/Avatar.d.ts.map +1 -1
  4. package/dist/Avatar/Avatar.js +19 -23
  5. package/dist/AvatarGroup/AvatarGroupOverflow.d.ts.map +1 -1
  6. package/dist/AvatarGroup/AvatarGroupOverflow.js +7 -2
  7. package/dist/Button/Button.d.ts.map +1 -1
  8. package/dist/Button/Button.js +9 -7
  9. package/dist/Chat/ChatMessage.d.ts +7 -0
  10. package/dist/Chat/ChatMessage.d.ts.map +1 -1
  11. package/dist/Chat/ChatMessageBubble.d.ts +13 -1
  12. package/dist/Chat/ChatMessageBubble.d.ts.map +1 -1
  13. package/dist/Chat/ChatMessageBubble.js +19 -1
  14. package/dist/CheckboxInput/CheckboxInput.d.ts.map +1 -1
  15. package/dist/CheckboxInput/CheckboxInput.js +5 -0
  16. package/dist/CommandPalette/CommandPaletteFooter.d.ts.map +1 -1
  17. package/dist/CommandPalette/CommandPaletteFooter.js +5 -3
  18. package/dist/DateTimeInput/DateTimeInput.d.ts.map +1 -1
  19. package/dist/DateTimeInput/DateTimeInput.js +2 -2
  20. package/dist/DropdownMenu/DropdownMenuSubMenu.d.ts.map +1 -1
  21. package/dist/DropdownMenu/DropdownMenuSubMenu.js +19 -15
  22. package/dist/HoverCard/HoverCard.d.ts +1 -1
  23. package/dist/HoverCard/HoverCard.d.ts.map +1 -1
  24. package/dist/HoverCard/HoverCard.js +5 -13
  25. package/dist/HoverCard/useHoverCard.d.ts.map +1 -1
  26. package/dist/HoverCard/useHoverCard.js +6 -5
  27. package/dist/InputGroup/groupStyles.d.ts.map +1 -1
  28. package/dist/InputGroup/groupStyles.js +7 -2
  29. package/dist/Layer/layerHost.d.ts +24 -0
  30. package/dist/Layer/layerHost.d.ts.map +1 -0
  31. package/dist/Layer/layerHost.js +79 -0
  32. package/dist/Layer/useLayer.d.ts +14 -6
  33. package/dist/Layer/useLayer.d.ts.map +1 -1
  34. package/dist/Layer/useLayer.js +158 -30
  35. package/dist/NavItem/navItemStyles.stylex.d.ts +17 -5
  36. package/dist/NavItem/navItemStyles.stylex.d.ts.map +1 -1
  37. package/dist/NavItem/navItemStyles.stylex.js +11 -5
  38. package/dist/RadioList/RadioListItem.d.ts.map +1 -1
  39. package/dist/RadioList/RadioListItem.js +5 -0
  40. package/dist/SideNav/SideNav.d.ts +7 -9
  41. package/dist/SideNav/SideNav.d.ts.map +1 -1
  42. package/dist/SideNav/SideNav.js +32 -5
  43. package/dist/SideNav/SideNavCollapseButton.d.ts +25 -9
  44. package/dist/SideNav/SideNavCollapseButton.d.ts.map +1 -1
  45. package/dist/SideNav/SideNavCollapseButton.js +39 -15
  46. package/dist/SideNav/SideNavCollapseContext.d.ts +21 -0
  47. package/dist/SideNav/SideNavCollapseContext.d.ts.map +1 -1
  48. package/dist/SideNav/SideNavCollapseContext.js +16 -2
  49. package/dist/SideNav/SideNavHeading.d.ts.map +1 -1
  50. package/dist/SideNav/SideNavHeading.js +89 -32
  51. package/dist/SideNav/SideNavItem.d.ts +7 -2
  52. package/dist/SideNav/SideNavItem.d.ts.map +1 -1
  53. package/dist/SideNav/SideNavItem.js +119 -75
  54. package/dist/SideNav/SideNavSection.d.ts.map +1 -1
  55. package/dist/SideNav/SideNavSection.js +7 -16
  56. package/dist/SideNav/index.d.ts +1 -1
  57. package/dist/SideNav/index.d.ts.map +1 -1
  58. package/dist/Slider/Slider.d.ts.map +1 -1
  59. package/dist/Slider/Slider.js +56 -15
  60. package/dist/Switch/Switch.d.ts.map +1 -1
  61. package/dist/Switch/Switch.js +5 -0
  62. package/dist/Thumbnail/Thumbnail.d.ts.map +1 -1
  63. package/dist/Thumbnail/Thumbnail.js +5 -0
  64. package/dist/TopNav/TopNavHeading.d.ts.map +1 -1
  65. package/dist/TopNav/TopNavHeading.js +14 -6
  66. package/dist/TopNav/TopNavMegaMenu.d.ts.map +1 -1
  67. package/dist/TopNav/TopNavMegaMenu.js +25 -93
  68. package/dist/TopNav/TopNavMegaMenuItem.js +1 -1
  69. package/dist/TopNav/TopNavMenu.d.ts.map +1 -1
  70. package/dist/TopNav/TopNavMenu.js +10 -5
  71. package/dist/astryx.css +40 -8
  72. package/dist/astryx.umd.js +50 -50
  73. package/dist/astryx.umd.js.map +4 -4
  74. package/dist/hooks/containerReveal.stylex.d.ts +71 -4
  75. package/dist/hooks/containerReveal.stylex.d.ts.map +1 -1
  76. package/dist/hooks/containerReveal.stylex.js +57 -5
  77. package/dist/hooks/index.d.ts +2 -2
  78. package/dist/hooks/index.d.ts.map +1 -1
  79. package/dist/hooks/index.js +1 -1
  80. package/dist/hooks/useContainerReveal.d.ts +60 -3
  81. package/dist/hooks/useContainerReveal.d.ts.map +1 -1
  82. package/dist/hooks/useContainerReveal.js +27 -5
  83. package/dist/hooks/useFocusTrap.d.ts.map +1 -1
  84. package/dist/hooks/useFocusTrap.js +16 -2
  85. package/dist/hooks/useMenuHover.d.ts +50 -5
  86. package/dist/hooks/useMenuHover.d.ts.map +1 -1
  87. package/dist/hooks/useMenuHover.js +171 -51
  88. package/dist/theme/defineTheme.d.ts +16 -5
  89. package/dist/theme/defineTheme.d.ts.map +1 -1
  90. package/dist/theme/defineTheme.js +44 -48
  91. package/dist/theme/derivedVarRegistry.d.ts.map +1 -1
  92. package/dist/theme/derivedVarRegistry.js +7 -0
  93. package/dist/theme/expandColorScale.d.ts.map +1 -1
  94. package/dist/theme/expandColorScale.js +1 -0
  95. package/dist/theme/expandMotionScale.d.ts +1 -0
  96. package/dist/theme/expandMotionScale.d.ts.map +1 -1
  97. package/dist/theme/expandMotionScale.js +1 -0
  98. package/dist/theme/expandRadiusScale.d.ts +1 -0
  99. package/dist/theme/expandRadiusScale.d.ts.map +1 -1
  100. package/dist/theme/expandRadiusScale.js +1 -0
  101. package/dist/theme/expandTypeScale.d.ts +1 -0
  102. package/dist/theme/expandTypeScale.d.ts.map +1 -1
  103. package/dist/theme/expandTypeScale.js +1 -0
  104. package/dist/theme/mergeComponents.d.ts +20 -0
  105. package/dist/theme/mergeComponents.d.ts.map +1 -0
  106. package/dist/theme/mergeComponents.js +56 -0
  107. package/dist/theme/onMediaTokens.d.ts +6 -1
  108. package/dist/theme/onMediaTokens.d.ts.map +1 -1
  109. package/dist/theme/onMediaTokens.js +11 -3
  110. package/dist/theme/tokens.stylex.d.ts +3 -1
  111. package/dist/theme/tokens.stylex.d.ts.map +1 -1
  112. package/dist/theme/tokens.stylex.js +3 -1
  113. package/locales/en.json +84 -0
  114. package/locales/pseudo.json +63 -0
  115. package/package.json +3 -3
  116. package/src/Avatar/Avatar.doc.mjs +5 -2
  117. package/src/Avatar/Avatar.test.tsx +51 -0
  118. package/src/Avatar/Avatar.tsx +30 -20
  119. package/src/AvatarGroup/AvatarGroup.doc.mjs +1 -1
  120. package/src/AvatarGroup/AvatarGroup.test.tsx +14 -0
  121. package/src/AvatarGroup/AvatarGroupOverflow.tsx +3 -2
  122. package/src/Button/Button.tsx +5 -3
  123. package/src/ButtonGroup/ButtonGroup.test.tsx +7 -4
  124. package/src/Card/Card.doc.mjs +2 -0
  125. package/src/Chat/Chat.doc.mjs +4 -1
  126. package/src/Chat/ChatMessage.doc.mjs +3 -3
  127. package/src/Chat/ChatMessage.tsx +7 -0
  128. package/src/Chat/ChatMessageBubble.doc.mjs +7 -0
  129. package/src/Chat/ChatMessageBubble.test.tsx +95 -6
  130. package/src/Chat/ChatMessageBubble.tsx +25 -0
  131. package/src/CheckboxInput/CheckboxInput.tsx +20 -0
  132. package/src/CodeBlock/CodeBlock.doc.mjs +3 -0
  133. package/src/CommandPalette/CommandPaletteFooter.tsx +6 -3
  134. package/src/DateTimeInput/DateTimeInput.tsx +4 -2
  135. package/src/DropdownMenu/DropdownMenuSubMenu.test.tsx +72 -1
  136. package/src/DropdownMenu/DropdownMenuSubMenu.tsx +24 -20
  137. package/src/HoverCard/HoverCard.doc.mjs +3 -3
  138. package/src/HoverCard/HoverCard.test.tsx +283 -55
  139. package/src/HoverCard/HoverCard.tsx +5 -13
  140. package/src/HoverCard/useHoverCard.tsx +8 -11
  141. package/src/InputGroup/groupStyles.ts +7 -8
  142. package/src/Item/Item.doc.mjs +4 -0
  143. package/src/Layer/layerHost.test.ts +99 -0
  144. package/src/Layer/layerHost.ts +141 -0
  145. package/src/Layer/useLayer.doc.mjs +14 -4
  146. package/src/Layer/useLayer.test.tsx +332 -7
  147. package/src/Layer/useLayer.tsx +235 -36
  148. package/src/MobileNav/MobileNav.doc.mjs +7 -0
  149. package/src/NavItem/navItemStyles.stylex.ts +31 -5
  150. package/src/RadioList/RadioListItem.tsx +20 -0
  151. package/src/SideNav/SideNav.doc.mjs +13 -4
  152. package/src/SideNav/SideNav.test.tsx +858 -2
  153. package/src/SideNav/SideNav.tsx +37 -16
  154. package/src/SideNav/SideNavCollapseButton.doc.mjs +28 -6
  155. package/src/SideNav/SideNavCollapseButton.tsx +67 -15
  156. package/src/SideNav/SideNavCollapseContext.ts +29 -9
  157. package/src/SideNav/SideNavHeading.tsx +53 -25
  158. package/src/SideNav/SideNavItem.doc.mjs +13 -0
  159. package/src/SideNav/SideNavItem.tsx +97 -84
  160. package/src/SideNav/SideNavSection.tsx +6 -20
  161. package/src/SideNav/index.ts +2 -0
  162. package/src/Slider/Slider.test.tsx +69 -33
  163. package/src/Slider/Slider.tsx +65 -13
  164. package/src/Switch/Switch.tsx +20 -0
  165. package/src/TabList/TabList.doc.mjs +3 -0
  166. package/src/Text/Text.doc.mjs +1 -1
  167. package/src/Thumbnail/Thumbnail.doc.mjs +3 -0
  168. package/src/Thumbnail/Thumbnail.tsx +10 -0
  169. package/src/Timestamp/Timestamp.test.tsx +40 -22
  170. package/src/Toolbar/Toolbar.test.tsx +14 -14
  171. package/src/TopNav/TopNav.test.tsx +86 -1
  172. package/src/TopNav/TopNavHeading.tsx +21 -14
  173. package/src/TopNav/TopNavMegaMenu.test.tsx +43 -0
  174. package/src/TopNav/TopNavMegaMenu.tsx +29 -105
  175. package/src/TopNav/TopNavMegaMenuItem.tsx +1 -1
  176. package/src/TopNav/TopNavMenu.test.tsx +41 -0
  177. package/src/TopNav/TopNavMenu.tsx +14 -4
  178. package/src/TreeList/TreeList.doc.mjs +1 -0
  179. package/src/hooks/containerReveal.stylex.ts +140 -9
  180. package/src/hooks/index.ts +6 -1
  181. package/src/hooks/useContainerReveal.doc.mjs +11 -5
  182. package/src/hooks/useContainerReveal.test.tsx +70 -3
  183. package/src/hooks/useContainerReveal.ts +86 -7
  184. package/src/hooks/useFocusTrap.test.tsx +16 -0
  185. package/src/hooks/useFocusTrap.ts +20 -2
  186. package/src/hooks/useMenuHover.test.tsx +364 -0
  187. package/src/hooks/useMenuHover.ts +243 -47
  188. package/src/theme/defineTheme.test.ts +127 -0
  189. package/src/theme/defineTheme.ts +57 -51
  190. package/src/theme/derivedVarRegistry.test.ts +78 -12
  191. package/src/theme/derivedVarRegistry.ts +4 -0
  192. package/src/theme/expandColorScale.ts +1 -0
  193. package/src/theme/expandMotionScale.ts +1 -0
  194. package/src/theme/expandRadiusScale.ts +1 -0
  195. package/src/theme/expandTypeScale.ts +1 -0
  196. package/src/theme/mergeComponents.ts +59 -0
  197. package/src/theme/onMediaTokens.ts +9 -2
  198. package/src/theme/themingTargets.test.ts +152 -26
  199. package/src/theme/tokens.stylex.ts +3 -1
  200. package/src/theme/tokens.test.ts +12 -0
  201. package/src/theme/useTheme.test.tsx +18 -0
@@ -0,0 +1,99 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file layerHost.test.ts
5
+ * @input Tests resolveLayerPortalTarget
6
+ * @output Coverage for when and where a layer is portaled
7
+ * @position Test for /packages/core/src/Layer/layerHost.ts
8
+ */
9
+
10
+ import {describe, it, expect, afterEach} from 'vitest';
11
+ import {resolveLayerPortalTarget} from './layerHost';
12
+
13
+ function mount(html: string): HTMLElement {
14
+ const root = document.createElement('div');
15
+ root.id = 'root';
16
+ root.innerHTML = html;
17
+ document.body.appendChild(root);
18
+ return root;
19
+ }
20
+
21
+ afterEach(() => {
22
+ document.getElementById('root')?.remove();
23
+ });
24
+
25
+ describe('resolveLayerPortalTarget', () => {
26
+ it('returns null without an inline parent', () => {
27
+ expect(resolveLayerPortalTarget(null)).toBeNull();
28
+ });
29
+
30
+ it('returns null when the intended inline position is already safe', () => {
31
+ const root = mount(
32
+ '<div id="host"><template id="marker"></template></div>',
33
+ );
34
+ const target = resolveLayerPortalTarget(root.querySelector('#host'));
35
+
36
+ expect(target).toBeNull();
37
+ });
38
+
39
+ it.each([
40
+ ['paragraph', '<p><template></template></p>'],
41
+ ['heading', '<h2><template></template></h2>'],
42
+ ['link', '<a href="#x"><template></template></a>'],
43
+ ['button', '<button><template></template></button>'],
44
+ ['label', '<label><template></template></label>'],
45
+ ['data', '<data><template></template></data>'],
46
+ ['definition', '<dfn><template></template></dfn>'],
47
+ ['meter', '<meter><template></template></meter>'],
48
+ ['output', '<output><template></template></output>'],
49
+ ['progress', '<progress><template></template></progress>'],
50
+ [
51
+ 'nested inline formatting',
52
+ '<p><em><b><template id="marker"></template></b></em></p>',
53
+ ],
54
+ ])('walks out of a %s', (_name, markup) => {
55
+ const root = mount(`<div id="host">${markup}</div>`);
56
+ const marker = root.querySelector('template');
57
+ const target = resolveLayerPortalTarget(marker?.parentElement ?? null);
58
+
59
+ expect(target).toBe(root.querySelector('#host'));
60
+ });
61
+
62
+ it('walks past a safe wrapper nested inside an unsafe ancestor', () => {
63
+ const root = mount(
64
+ '<div id="host"><a href="#x"><div id="inline"><template></template></div></a></div>',
65
+ );
66
+ const target = resolveLayerPortalTarget(root.querySelector('#inline'));
67
+
68
+ expect(target).toBe(root.querySelector('#host'));
69
+ });
70
+
71
+ it.each([
72
+ [
73
+ 'table row',
74
+ '<table><tbody><tr><template></template></tr></tbody></table>',
75
+ ],
76
+ ['list', '<ul><template></template></ul>'],
77
+ ['select', '<select><template></template></select>'],
78
+ ['heading group', '<hgroup><template></template></hgroup>'],
79
+ ])('walks out of a structural %s', (_name, markup) => {
80
+ const root = mount(`<div id="host">${markup}</div>`);
81
+ const marker = root.querySelector('template');
82
+ const target = resolveLayerPortalTarget(marker?.parentElement ?? null);
83
+
84
+ expect(target).toBe(root.querySelector('#host'));
85
+ });
86
+
87
+ it('stops at the nearest safe ancestor rather than the body', () => {
88
+ const root = mount(
89
+ '<section id="outer"><li id="host"><p><span id="t">t</span></p></li></section>',
90
+ );
91
+ const marker = root.querySelector('#t');
92
+ const target = resolveLayerPortalTarget(marker?.parentElement ?? null);
93
+
94
+ // The nearest safe ancestor keeps the layer inside the trigger's theme
95
+ // scope and next to it in the tab order.
96
+ expect(target).toBe(root.querySelector('#host'));
97
+ expect(target).not.toBe(document.body);
98
+ });
99
+ });
@@ -0,0 +1,141 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file layerHost.ts
5
+ * @input Uses the layer's intended inline parent element
6
+ * @output Exports resolveLayerPortalTarget, the corrective portal target
7
+ * @position Layer utility; used by useLayer to place the popover in the DOM
8
+ *
9
+ * SYNC: When modified, update:
10
+ * - /packages/core/src/Layer/layerHost.test.ts
11
+ */
12
+
13
+ /**
14
+ * Ancestors a layer must not be hosted inside.
15
+ *
16
+ * Two overlapping reasons, both verified in Chrome:
17
+ *
18
+ * 1. The HTML parser owns server markup. `<p>` and the heading-ish elements
19
+ * take phrasing content only, so a block element inside one makes the
20
+ * parser close the paragraph and reparent the rest — the layer's content
21
+ * ends up in the page instead of the popover. A nested `<a>` triggers the
22
+ * same tearing through the adoption agency algorithm.
23
+ * 2. Interactive ancestors capture the layer's own interactions. A card
24
+ * hosted inside an `<a>` or `<button>` puts its links and buttons inside
25
+ * that control: clicking one navigates the wrapping link, and every
26
+ * focusable in the card joins the control's own tab stop.
27
+ *
28
+ * Inline formatting elements are on the list for a third, milder reason: a
29
+ * layer hosted in one inherits its typography (font-size, text-align), so a
30
+ * card in a 13px centered paragraph renders 13px and centered.
31
+ */
32
+ const UNSAFE_HOSTS = new Set([
33
+ // Phrasing-content-only containers
34
+ 'p',
35
+ 'h1',
36
+ 'h2',
37
+ 'h3',
38
+ 'h4',
39
+ 'h5',
40
+ 'h6',
41
+ 'dt',
42
+ 'pre',
43
+ 'legend',
44
+ 'data',
45
+ 'dfn',
46
+ 'meter',
47
+ 'output',
48
+ 'progress',
49
+ 'option',
50
+ 'optgroup',
51
+ // Structural containers whose direct children are restricted. An inert
52
+ // <template> marker is valid script-supporting content in these positions,
53
+ // but the eventual div/span layer is not.
54
+ 'table',
55
+ 'thead',
56
+ 'tbody',
57
+ 'tfoot',
58
+ 'tr',
59
+ 'colgroup',
60
+ 'ul',
61
+ 'ol',
62
+ 'menu',
63
+ 'dl',
64
+ 'select',
65
+ 'datalist',
66
+ 'picture',
67
+ 'hgroup',
68
+ 'ruby',
69
+ 'rt',
70
+ 'rp',
71
+ // Interactive containers
72
+ 'a',
73
+ 'button',
74
+ 'label',
75
+ 'summary',
76
+ // Inline formatting context
77
+ 'span',
78
+ 'em',
79
+ 'strong',
80
+ 'b',
81
+ 'i',
82
+ 'u',
83
+ 's',
84
+ 'small',
85
+ 'mark',
86
+ 'code',
87
+ 'kbd',
88
+ 'samp',
89
+ 'var',
90
+ 'sub',
91
+ 'sup',
92
+ 'abbr',
93
+ 'cite',
94
+ 'q',
95
+ 'time',
96
+ 'bdi',
97
+ 'bdo',
98
+ 'ins',
99
+ 'del',
100
+ ]);
101
+
102
+ /**
103
+ * Return the corrective portal target for a layer's intended inline parent.
104
+ *
105
+ * A null result means the inline parent and all of its ancestors are safe, so
106
+ * the layer should stay at its JSX position. Otherwise the result is the
107
+ * nearest element outside every unsafe ancestor around that position.
108
+ *
109
+ * Walking up from the actual render position (rather than the trigger, or
110
+ * portaling to `document.body`) keeps the two things a layer inherits there:
111
+ *
112
+ * - **Theme.** Theme scopes live on DOM ancestors. Staying as close as
113
+ * possible to the intended render position preserves their component rules
114
+ * and custom properties; `document.body` may sit outside a nested scope.
115
+ * - **Tab order.** Sequential focus follows DOM order, so a host near the
116
+ * trigger keeps the layer's focusables next to it. (`show()` also passes
117
+ * the trigger as the popover's invoker `source`, which pins focus order to
118
+ * the invoker in browsers that support it.)
119
+ *
120
+ * The outermost unsafe ancestor matters. A safe div may itself sit inside an
121
+ * anchor; stopping at that div would still put the layer's buttons inside the
122
+ * link. Walking the whole chain ensures the target is outside both.
123
+ */
124
+ export function resolveLayerPortalTarget(
125
+ inlineParent: HTMLElement | null,
126
+ ): HTMLElement | null {
127
+ if (!inlineParent) {
128
+ return null;
129
+ }
130
+
131
+ let outermostUnsafe: HTMLElement | null = null;
132
+ let node: HTMLElement | null = inlineParent;
133
+ while (node) {
134
+ if (UNSAFE_HOSTS.has(node.tagName.toLowerCase())) {
135
+ outermostUnsafe = node;
136
+ }
137
+ node = node.parentElement;
138
+ }
139
+
140
+ return outermostUnsafe?.parentElement ?? null;
141
+ }
@@ -42,6 +42,13 @@ export const docs = {
42
42
  'Whether clicking outside should dismiss the layer using native popover light-dismiss behavior.',
43
43
  default: 'false',
44
44
  },
45
+ {
46
+ name: 'lazyMount',
47
+ type: 'boolean',
48
+ description:
49
+ 'Context mode only. Wait until show() to resolve the inline/portal position and mount content; hide unmounts the content while the inert marker remains.',
50
+ default: 'false',
51
+ },
45
52
  ],
46
53
  returns: [
47
54
  {
@@ -79,7 +86,7 @@ export const docs = {
79
86
  name: 'render',
80
87
  type: '(children: ReactNode, props: ContextRenderProps | FixedRenderProps) => ReactNode',
81
88
  description:
82
- 'Render function for the popover element. Pass placement/alignment in context mode or x/y in fixed mode. Placement/alignment are logical: they map to the self-* position-area keyword family, which resolves against the popover\'s own inherited direction, so RTL contexts mirror automatically in pure CSS. Pass `positioning: "custom"` in context mode to author position styles yourself via `style` (e.g. explicit anchor() insets or an anchor-size() cover): the hook keeps the popover behavior and position-anchor wiring but derives no position styles, including the automatic RTL mirroring, which becomes your responsibility. Pass `offset` (a CSS length; a number is px) in context mode for clearance from the anchor: it applies to both edges of the placement axis, so the gap survives a flip. Layers are flush by default. In context mode, pass `as: "span"` to render an inline-safe layer (e.g. inside a paragraph). The layer renders inline in the React tree; the Popover API promotes it to the top layer when shown, so it escapes ancestor clipping and stacking without a portal. When the layer would overflow the viewport, position-try fallbacks flip it to the opposite side; centered layers additionally slide along the alignment axis (span fallbacks) so they stay on-screen near viewport edges.',
89
+ 'Render function for the popover element. Pass placement/alignment in context mode or x/y in fixed mode. Placement/alignment are logical: they map to the self-* position-area keyword family, which resolves against the popover\'s own inherited direction, so RTL contexts mirror automatically in pure CSS. Pass `positioning: "custom"` in context mode to author position styles yourself via `style` (e.g. explicit anchor() insets or an anchor-size() cover): the hook keeps the popover behavior and position-anchor wiring but derives no position styles, including the automatic RTL mirroring, which becomes your responsibility. Pass `offset` (a CSS length; a number is px) in context mode for clearance from the anchor: it applies to both edges of the placement axis, so the gap survives a flip. Layers are flush by default. Context mode first renders an inert `<template>` marker in matching server and client markup. The final layer stays at that JSX position if its parent is safe; otherwise it is portaled to the nearest ancestor outside paragraphs, links, buttons, inline formatting, and structurally restricted containers. The nearest safe host keeps CSS custom properties inheriting live, while the layer preserves direction and writing mode from its JSX position. By default this resolution occurs after hydration so closed-layer DOM remains available; `lazyMount` defers it until `show()` and unmounts the content again on hide while the marker remains. The Popover API promotes the layer to the top layer when shown, so it escapes ancestor clipping and stacking wherever it is hosted. When the layer would overflow the viewport, position-try fallbacks flip it to the opposite side; centered layers additionally slide along the alignment axis (span fallbacks) so they stay on-screen near viewport edges.',
83
90
  },
84
91
  ],
85
92
  usage: {
@@ -99,7 +106,7 @@ export const docs = {
99
106
  {
100
107
  guidance: true,
101
108
  description:
102
- 'Rely on the Popover API top layer to escape ancestor clipping and stacking: render the layer inline (no portal) so it inherits the trigger\'s theme cascade and keeps a natural focus order. Use `as: "span"` when the layer must be valid inside inline contexts like a paragraph.',
109
+ "Rely on the Popover API top layer to escape ancestor clipping and stacking, and host the layer near its trigger rather than in the body so it inherits the trigger's theme cascade and keeps a natural focus order.",
103
110
  },
104
111
  {
105
112
  guidance: false,
@@ -123,6 +130,8 @@ export const docsDense = {
123
130
  onShow: 'fires when layer becomes visible.',
124
131
  onHide: 'fires when layer hides.',
125
132
  lightDismiss: 'whether native outside-click light-dismiss is enabled.',
133
+ lazyMount:
134
+ 'context only: defer position resolution/content mounting until show; unmount on hide.',
126
135
  },
127
136
  returnDescriptions: {
128
137
  ref: 'trigger ref for context mode; undefined in fixed mode.',
@@ -131,7 +140,8 @@ export const docsDense = {
131
140
  hide: 'hide layer.',
132
141
  isOpen: 'whether layer is open.',
133
142
  id: 'unique ARIA id.',
134
- render: 'renders popover element; pass placement/alignment or x/y. Placement/alignment logical: mapped to self-* position-area keywords resolved against the popover\'s inherited direction (RTL mirrors in pure CSS). `positioning: "custom"` (context mode) = author position styles yourself via `style`; keeps popover behavior + position-anchor wiring, derives nothing (incl. RTL mirroring, which becomes yours). `offset` (context mode) = clearance from the anchor as a CSS length (number = px), applied to both edges of the placement axis so it survives a flip; layers are flush by default. Context mode accepts `as: "span"` for inline-safe layers. Renders inline; the Popover API top layer escapes clipping/stacking without a portal. Viewport overflow: flips to opposite side; centered layers also slide along the alignment axis (span fallbacks).',
143
+ render:
144
+ 'renders popover element; pass placement/alignment or x/y. Placement/alignment logical: mapped to self-* position-area keywords resolved against the popover\'s inherited direction (RTL mirrors in pure CSS). `positioning: "custom"` (context mode) = author position styles yourself via `style`; keeps popover behavior + position-anchor wiring, derives nothing (incl. RTL mirroring, which becomes yours). `offset` (context mode) = clearance from the anchor as a CSS length (number = px), applied to both edges of the placement axis so it survives a flip; layers are flush by default. Context mode begins with an inert `<template>` marker for stable SSR/hydration, then keeps the final layer inline at a safe JSX position or portals it to the nearest safe ancestor; CSS custom properties keep inheriting from that host while direction and writing mode are preserved from the JSX position. `lazyMount` waits for show and unmounts content on hide while the marker remains. The Popover API top layer escapes clipping/stacking wherever it is hosted. Viewport overflow: flips to opposite side; centered layers also slide along the alignment axis (span fallbacks).',
135
145
  },
136
146
  usage: {
137
147
  description:
@@ -150,7 +160,7 @@ export const docsDense = {
150
160
  {
151
161
  guidance: true,
152
162
  description:
153
- 'Rely on the Popover API top layer to escape clipping/stacking: render inline (no portal) to inherit the trigger theme cascade and natural focus order. Use `as: "span"` when the layer must be valid in inline contexts like a paragraph.',
163
+ 'Rely on the Popover API top layer to escape clipping/stacking; host the layer near its trigger (not in the body) to inherit the trigger theme cascade and natural focus order.',
154
164
  },
155
165
  {
156
166
  guidance: false,