@astryxdesign/core 0.4.1 → 0.4.2-canary.01592f7
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/CHANGELOG.md +55 -0
- package/dist/Avatar/Avatar.d.ts +4 -1
- package/dist/Avatar/Avatar.d.ts.map +1 -1
- package/dist/Avatar/Avatar.js +19 -23
- package/dist/AvatarGroup/AvatarGroupOverflow.d.ts.map +1 -1
- package/dist/AvatarGroup/AvatarGroupOverflow.js +7 -2
- package/dist/Button/Button.d.ts.map +1 -1
- package/dist/Button/Button.js +9 -7
- package/dist/Chat/ChatMessage.d.ts +7 -0
- package/dist/Chat/ChatMessage.d.ts.map +1 -1
- package/dist/Chat/ChatMessageBubble.d.ts +13 -1
- package/dist/Chat/ChatMessageBubble.d.ts.map +1 -1
- package/dist/Chat/ChatMessageBubble.js +19 -1
- package/dist/Chat/ChatTokenizedText.js +1 -1
- package/dist/CheckboxInput/CheckboxInput.d.ts.map +1 -1
- package/dist/CheckboxInput/CheckboxInput.js +5 -0
- package/dist/CommandPalette/CommandPaletteFooter.d.ts.map +1 -1
- package/dist/CommandPalette/CommandPaletteFooter.js +5 -3
- package/dist/ComplexSelector/ComplexSelector.d.ts +38 -4
- package/dist/ComplexSelector/ComplexSelector.d.ts.map +1 -1
- package/dist/ComplexSelector/ComplexSelector.js +96 -35
- package/dist/ComplexSelector/index.d.ts +2 -2
- package/dist/ComplexSelector/index.d.ts.map +1 -1
- package/dist/ComplexSelector/index.js +1 -1
- package/dist/DateTimeInput/DateTimeInput.d.ts.map +1 -1
- package/dist/DateTimeInput/DateTimeInput.js +2 -2
- package/dist/DropdownMenu/DropdownMenuSubMenu.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenuSubMenu.js +19 -15
- package/dist/HoverCard/HoverCard.d.ts +1 -1
- package/dist/HoverCard/HoverCard.d.ts.map +1 -1
- package/dist/HoverCard/HoverCard.js +5 -13
- package/dist/HoverCard/useHoverCard.d.ts.map +1 -1
- package/dist/HoverCard/useHoverCard.js +6 -5
- package/dist/InputGroup/groupStyles.d.ts.map +1 -1
- package/dist/InputGroup/groupStyles.js +7 -2
- package/dist/Layer/layerHost.d.ts +24 -0
- package/dist/Layer/layerHost.d.ts.map +1 -0
- package/dist/Layer/layerHost.js +79 -0
- package/dist/Layer/useLayer.d.ts +14 -6
- package/dist/Layer/useLayer.d.ts.map +1 -1
- package/dist/Layer/useLayer.js +158 -30
- package/dist/Markdown/parser.d.ts.map +1 -1
- package/dist/Markdown/parser.js +55 -12
- package/dist/NavItem/navItemStyles.stylex.d.ts +17 -5
- package/dist/NavItem/navItemStyles.stylex.d.ts.map +1 -1
- package/dist/NavItem/navItemStyles.stylex.js +11 -5
- package/dist/RadioList/RadioListItem.d.ts.map +1 -1
- package/dist/RadioList/RadioListItem.js +5 -0
- package/dist/SideNav/SideNav.d.ts +7 -9
- package/dist/SideNav/SideNav.d.ts.map +1 -1
- package/dist/SideNav/SideNav.js +32 -5
- package/dist/SideNav/SideNavCollapseButton.d.ts +25 -9
- package/dist/SideNav/SideNavCollapseButton.d.ts.map +1 -1
- package/dist/SideNav/SideNavCollapseButton.js +39 -15
- package/dist/SideNav/SideNavCollapseContext.d.ts +21 -0
- package/dist/SideNav/SideNavCollapseContext.d.ts.map +1 -1
- package/dist/SideNav/SideNavCollapseContext.js +16 -2
- package/dist/SideNav/SideNavHeading.d.ts.map +1 -1
- package/dist/SideNav/SideNavHeading.js +89 -32
- package/dist/SideNav/SideNavItem.d.ts +7 -2
- package/dist/SideNav/SideNavItem.d.ts.map +1 -1
- package/dist/SideNav/SideNavItem.js +119 -75
- package/dist/SideNav/SideNavSection.d.ts.map +1 -1
- package/dist/SideNav/SideNavSection.js +7 -16
- package/dist/SideNav/index.d.ts +1 -1
- package/dist/SideNav/index.d.ts.map +1 -1
- package/dist/Slider/Slider.d.ts.map +1 -1
- package/dist/Slider/Slider.js +56 -15
- package/dist/Switch/Switch.d.ts.map +1 -1
- package/dist/Switch/Switch.js +5 -0
- package/dist/Thumbnail/Thumbnail.d.ts.map +1 -1
- package/dist/Thumbnail/Thumbnail.js +5 -0
- package/dist/TopNav/TopNavHeading.d.ts.map +1 -1
- package/dist/TopNav/TopNavHeading.js +14 -6
- package/dist/TopNav/TopNavMegaMenu.d.ts.map +1 -1
- package/dist/TopNav/TopNavMegaMenu.js +25 -93
- package/dist/TopNav/TopNavMegaMenuItem.js +1 -1
- package/dist/TopNav/TopNavMenu.d.ts.map +1 -1
- package/dist/TopNav/TopNavMenu.js +10 -5
- package/dist/astryx.css +40 -8
- package/dist/astryx.umd.js +50 -50
- package/dist/astryx.umd.js.map +4 -4
- package/dist/hooks/containerReveal.stylex.d.ts +71 -4
- package/dist/hooks/containerReveal.stylex.d.ts.map +1 -1
- package/dist/hooks/containerReveal.stylex.js +57 -5
- package/dist/hooks/index.d.ts +2 -2
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +1 -1
- package/dist/hooks/useContainerReveal.d.ts +60 -3
- package/dist/hooks/useContainerReveal.d.ts.map +1 -1
- package/dist/hooks/useContainerReveal.js +27 -5
- package/dist/hooks/useFocusTrap.d.ts.map +1 -1
- package/dist/hooks/useFocusTrap.js +16 -2
- package/dist/hooks/useMenuHover.d.ts +50 -5
- package/dist/hooks/useMenuHover.d.ts.map +1 -1
- package/dist/hooks/useMenuHover.js +171 -51
- package/dist/theme/defineTheme.d.ts +16 -5
- package/dist/theme/defineTheme.d.ts.map +1 -1
- package/dist/theme/defineTheme.js +44 -48
- package/dist/theme/derivedVarRegistry.d.ts.map +1 -1
- package/dist/theme/derivedVarRegistry.js +7 -0
- package/dist/theme/expandColorScale.d.ts.map +1 -1
- package/dist/theme/expandColorScale.js +1 -0
- package/dist/theme/expandMotionScale.d.ts +1 -0
- package/dist/theme/expandMotionScale.d.ts.map +1 -1
- package/dist/theme/expandMotionScale.js +1 -0
- package/dist/theme/expandRadiusScale.d.ts +1 -0
- package/dist/theme/expandRadiusScale.d.ts.map +1 -1
- package/dist/theme/expandRadiusScale.js +1 -0
- package/dist/theme/expandTypeScale.d.ts +1 -0
- package/dist/theme/expandTypeScale.d.ts.map +1 -1
- package/dist/theme/expandTypeScale.js +1 -0
- package/dist/theme/mergeComponents.d.ts +20 -0
- package/dist/theme/mergeComponents.d.ts.map +1 -0
- package/dist/theme/mergeComponents.js +56 -0
- package/dist/theme/onMediaTokens.d.ts +6 -1
- package/dist/theme/onMediaTokens.d.ts.map +1 -1
- package/dist/theme/onMediaTokens.js +11 -3
- package/dist/theme/tokens.stylex.d.ts +3 -1
- package/dist/theme/tokens.stylex.d.ts.map +1 -1
- package/dist/theme/tokens.stylex.js +3 -1
- package/locales/en.json +84 -0
- package/locales/pseudo.json +63 -0
- package/package.json +3 -3
- package/src/Avatar/Avatar.doc.mjs +5 -2
- package/src/Avatar/Avatar.test.tsx +51 -0
- package/src/Avatar/Avatar.tsx +30 -20
- package/src/AvatarGroup/AvatarGroup.doc.mjs +1 -1
- package/src/AvatarGroup/AvatarGroup.test.tsx +14 -0
- package/src/AvatarGroup/AvatarGroupOverflow.tsx +3 -2
- package/src/Button/Button.tsx +5 -3
- package/src/ButtonGroup/ButtonGroup.test.tsx +7 -4
- package/src/Card/Card.doc.mjs +2 -0
- package/src/Chat/Chat.doc.mjs +4 -1
- package/src/Chat/ChatMessage.doc.mjs +3 -3
- package/src/Chat/ChatMessage.tsx +7 -0
- package/src/Chat/ChatMessageBubble.doc.mjs +7 -0
- package/src/Chat/ChatMessageBubble.test.tsx +95 -6
- package/src/Chat/ChatMessageBubble.tsx +25 -0
- package/src/Chat/ChatTokenizedText.tsx +1 -1
- package/src/CheckboxInput/CheckboxInput.tsx +20 -0
- package/src/CodeBlock/CodeBlock.doc.mjs +3 -0
- package/src/CommandPalette/CommandPaletteFooter.tsx +6 -3
- package/src/ComplexSelector/ComplexSelector.doc.mjs +55 -6
- package/src/ComplexSelector/ComplexSelector.test.tsx +197 -6
- package/src/ComplexSelector/ComplexSelector.tsx +153 -32
- package/src/ComplexSelector/index.ts +3 -1
- package/src/DateTimeInput/DateTimeInput.tsx +4 -2
- package/src/DropdownMenu/DropdownMenuSubMenu.test.tsx +72 -1
- package/src/DropdownMenu/DropdownMenuSubMenu.tsx +24 -20
- package/src/HoverCard/HoverCard.doc.mjs +3 -3
- package/src/HoverCard/HoverCard.test.tsx +283 -55
- package/src/HoverCard/HoverCard.tsx +5 -13
- package/src/HoverCard/useHoverCard.tsx +8 -11
- package/src/InputGroup/groupStyles.ts +7 -8
- package/src/Item/Item.doc.mjs +4 -0
- package/src/Layer/layerHost.test.ts +99 -0
- package/src/Layer/layerHost.ts +141 -0
- package/src/Layer/useLayer.doc.mjs +14 -4
- package/src/Layer/useLayer.test.tsx +332 -7
- package/src/Layer/useLayer.tsx +235 -36
- package/src/Markdown/parser.test.ts +53 -0
- package/src/Markdown/parser.ts +53 -12
- package/src/MobileNav/MobileNav.doc.mjs +7 -0
- package/src/NavItem/navItemStyles.stylex.ts +31 -5
- package/src/RadioList/RadioListItem.tsx +20 -0
- package/src/SideNav/SideNav.doc.mjs +13 -4
- package/src/SideNav/SideNav.test.tsx +858 -2
- package/src/SideNav/SideNav.tsx +37 -16
- package/src/SideNav/SideNavCollapseButton.doc.mjs +28 -6
- package/src/SideNav/SideNavCollapseButton.tsx +67 -15
- package/src/SideNav/SideNavCollapseContext.ts +29 -9
- package/src/SideNav/SideNavHeading.tsx +53 -25
- package/src/SideNav/SideNavItem.doc.mjs +13 -0
- package/src/SideNav/SideNavItem.tsx +97 -84
- package/src/SideNav/SideNavSection.tsx +6 -20
- package/src/SideNav/index.ts +2 -0
- package/src/Slider/Slider.test.tsx +69 -33
- package/src/Slider/Slider.tsx +65 -13
- package/src/Switch/Switch.tsx +20 -0
- package/src/TabList/TabList.doc.mjs +3 -0
- package/src/Text/Text.doc.mjs +1 -1
- package/src/Thumbnail/Thumbnail.doc.mjs +3 -0
- package/src/Thumbnail/Thumbnail.tsx +10 -0
- package/src/Timestamp/Timestamp.test.tsx +40 -22
- package/src/Toolbar/Toolbar.test.tsx +14 -14
- package/src/TopNav/TopNav.test.tsx +86 -1
- package/src/TopNav/TopNavHeading.tsx +21 -14
- package/src/TopNav/TopNavMegaMenu.test.tsx +43 -0
- package/src/TopNav/TopNavMegaMenu.tsx +29 -105
- package/src/TopNav/TopNavMegaMenuItem.tsx +1 -1
- package/src/TopNav/TopNavMenu.test.tsx +41 -0
- package/src/TopNav/TopNavMenu.tsx +14 -4
- package/src/TreeList/TreeList.doc.mjs +1 -0
- package/src/hooks/containerReveal.stylex.ts +140 -9
- package/src/hooks/index.ts +6 -1
- package/src/hooks/useContainerReveal.doc.mjs +11 -5
- package/src/hooks/useContainerReveal.test.tsx +70 -3
- package/src/hooks/useContainerReveal.ts +86 -7
- package/src/hooks/useFocusTrap.test.tsx +16 -0
- package/src/hooks/useFocusTrap.ts +20 -2
- package/src/hooks/useMenuHover.test.tsx +364 -0
- package/src/hooks/useMenuHover.ts +243 -47
- package/src/theme/defineTheme.test.ts +127 -0
- package/src/theme/defineTheme.ts +57 -51
- package/src/theme/derivedVarRegistry.test.ts +78 -12
- package/src/theme/derivedVarRegistry.ts +4 -0
- package/src/theme/expandColorScale.ts +1 -0
- package/src/theme/expandMotionScale.ts +1 -0
- package/src/theme/expandRadiusScale.ts +1 -0
- package/src/theme/expandTypeScale.ts +1 -0
- package/src/theme/mergeComponents.ts +59 -0
- package/src/theme/onMediaTokens.ts +9 -2
- package/src/theme/themingTargets.test.ts +152 -26
- package/src/theme/tokens.stylex.ts +3 -1
- package/src/theme/tokens.test.ts +12 -0
- package/src/theme/useTheme.test.tsx +18 -0
package/dist/Layer/useLayer.d.ts
CHANGED
|
@@ -94,12 +94,11 @@ export interface ContextRenderProps {
|
|
|
94
94
|
/**
|
|
95
95
|
* HTML tag to render the popover container as.
|
|
96
96
|
*
|
|
97
|
-
* Defaults to `'div'`.
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
* the same on either tag.
|
|
97
|
+
* Defaults to `'div'`. Context layers render an inert `<template>` marker at
|
|
98
|
+
* the JSX position. The marker's parent is checked before the requested
|
|
99
|
+
* container mounts there or portals outside ancestors that cannot safely
|
|
100
|
+
* contain it. The marker remains available to detect a new parent if the
|
|
101
|
+
* render call moves. With `lazyMount`, the first check waits until `show()`.
|
|
103
102
|
*
|
|
104
103
|
* @default 'div'
|
|
105
104
|
*/
|
|
@@ -162,6 +161,15 @@ interface BaseLayerOptions {
|
|
|
162
161
|
*/
|
|
163
162
|
export interface ContextLayerOptions extends BaseLayerOptions {
|
|
164
163
|
mode: 'context';
|
|
164
|
+
/**
|
|
165
|
+
* Defer mounting the final layer and resolving its inline/portal position
|
|
166
|
+
* until `show()` is requested. Hiding unmounts it while the inert marker
|
|
167
|
+
* remains at the JSX position. Use this when rich content must never enter
|
|
168
|
+
* an unsafe ancestor, even briefly, and does not need to exist while closed.
|
|
169
|
+
*
|
|
170
|
+
* @default false
|
|
171
|
+
*/
|
|
172
|
+
lazyMount?: boolean;
|
|
165
173
|
}
|
|
166
174
|
/**
|
|
167
175
|
* Options for fixed mode (manual positioning)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLayer.d.ts","sourceRoot":"","sources":["../../src/Layer/useLayer.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,EAMZ,KAAK,SAAS,EACd,KAAK,WAAW,EACjB,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"useLayer.d.ts","sourceRoot":"","sources":["../../src/Layer/useLayer.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,EAMZ,KAAK,SAAS,EACd,KAAK,WAAW,EACjB,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,kBAAkB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AAS,CAAC;CACrE;AAmFD;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CACrC,SAAS,GAAE,cAAwB,EACnC,SAAS,GAAE,cAAyB,GACnC,MAAM,CAgBR;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,mBAAmB,GAAG,kBAAkB,CAAC;AAC3E,wBAAgB,QAAQ,CAAC,OAAO,EAAE,iBAAiB,GAAG,gBAAgB,CAAC"}
|
package/dist/Layer/useLayer.js
CHANGED
|
@@ -15,10 +15,12 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import React, { useCallback, useEffect, useId, useRef, useState } from 'react';
|
|
17
17
|
import * as stylex from '@stylexjs/stylex';
|
|
18
|
+
import { createPortal } from 'react-dom';
|
|
18
19
|
import { addAnchorName, removeAnchorName } from "./anchorName.js";
|
|
20
|
+
import { resolveLayerPortalTarget } from "./layerHost.js";
|
|
19
21
|
import "../theme/tokens.stylex.js";
|
|
20
|
-
import { typographyVars } from "../theme/tokens.stylex.js";
|
|
21
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
22
|
+
import { typeScaleVars, typographyVars } from "../theme/tokens.stylex.js";
|
|
23
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
22
24
|
const _temp = {
|
|
23
25
|
keoZOQ: "x1vhfslr",
|
|
24
26
|
k1K539: "xlm3tn6",
|
|
@@ -38,6 +40,8 @@ const styles = {
|
|
|
38
40
|
ksu8eU: "xng3xce",
|
|
39
41
|
kVQacm: "x1rea2x4",
|
|
40
42
|
kMv6JI: "x9ynric",
|
|
43
|
+
kGuDYH: "xjm74w1",
|
|
44
|
+
kLWn49: "xw6l6zx",
|
|
41
45
|
kWkggS: "xjbqb8w",
|
|
42
46
|
$$css: true
|
|
43
47
|
},
|
|
@@ -100,17 +104,40 @@ const styles = {
|
|
|
100
104
|
function toCssLength(value) {
|
|
101
105
|
return typeof value === 'number' ? `${value}px` : value;
|
|
102
106
|
}
|
|
107
|
+
function readPortalWritingContext(element, portalTarget) {
|
|
108
|
+
const view = element.ownerDocument.defaultView;
|
|
109
|
+
if (!view) {
|
|
110
|
+
return {};
|
|
111
|
+
}
|
|
112
|
+
const sourceStyle = view.getComputedStyle(element);
|
|
113
|
+
const targetStyle = view.getComputedStyle(portalTarget);
|
|
114
|
+
|
|
115
|
+
// Do not snapshot custom properties here. The portal target is the closest
|
|
116
|
+
// safe ancestor, so theme variables continue to inherit and update there.
|
|
117
|
+
// These two properties can be set on the unsafe chain itself and directly
|
|
118
|
+
// affect the logical anchor-positioning keywords used by the layer. Only
|
|
119
|
+
// override values the portal would actually lose; matching values should
|
|
120
|
+
// keep inheriting from the target so later direction changes remain live.
|
|
121
|
+
return {
|
|
122
|
+
...(sourceStyle.direction !== targetStyle.direction && {
|
|
123
|
+
direction: sourceStyle.direction
|
|
124
|
+
}),
|
|
125
|
+
...(sourceStyle.writingMode !== targetStyle.writingMode && {
|
|
126
|
+
writingMode: sourceStyle.writingMode
|
|
127
|
+
})
|
|
128
|
+
};
|
|
129
|
+
}
|
|
103
130
|
|
|
104
131
|
/**
|
|
105
132
|
* Map logical placement/alignment to a CSS position-area value.
|
|
106
133
|
*
|
|
107
134
|
* Uses the self-* logical keyword family: the inline axis resolves against
|
|
108
|
-
* the popover's own
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
135
|
+
* the popover's own direction (inherited inline or preserved when portaled),
|
|
136
|
+
* so it mirrors in RTL without placement-specific JS. The block axis is
|
|
137
|
+
* direction-neutral but must come from the same keyword family — mixing
|
|
138
|
+
* physical `top` with `self-inline-*` produces an invalid position-area
|
|
139
|
+
* (computes to `none`, which pins the popover to the viewport corner because
|
|
140
|
+
* styles.base zeroes the UA margins).
|
|
114
141
|
*
|
|
115
142
|
* Note the plain logical family (`inline-start`, no `self-`) is NOT a
|
|
116
143
|
* substitute: it resolves against the containing block — the page root for
|
|
@@ -182,36 +209,101 @@ export function useLayer(options) {
|
|
|
182
209
|
onHide,
|
|
183
210
|
lightDismiss = false
|
|
184
211
|
} = options;
|
|
212
|
+
const lazyMount = mode === 'context' ? options.lazyMount ?? false : false;
|
|
185
213
|
const id = useId();
|
|
186
214
|
const anchorId = `--astryx-layer-${id.replace(/:/g, '')}`;
|
|
187
215
|
const [isOpen, setIsOpen] = useState(false);
|
|
188
216
|
const popoverRef = useRef(null);
|
|
217
|
+
// The DOM element on which the current logical open state was applied.
|
|
218
|
+
// A portal target change replaces the popover element; retaining the old
|
|
219
|
+
// reference lets the ref callback recognize and reopen its replacement.
|
|
220
|
+
const openedPopoverRef = useRef(null);
|
|
189
221
|
const triggerRef = useRef(null);
|
|
222
|
+
// Context layers place a persistent inert marker at their real JSX position.
|
|
223
|
+
// Its parent tells us whether the final layer can stay inline or needs a
|
|
224
|
+
// corrective portal, including after the render call moves.
|
|
225
|
+
const sentinelRef = useRef(null);
|
|
226
|
+
const contextMountRef = useRef(null);
|
|
227
|
+
const [contextMount, setContextMount] = useState(null);
|
|
228
|
+
// A show() that arrives before the final layer mounts is replayed when its
|
|
229
|
+
// popover ref attaches.
|
|
230
|
+
const pendingShowRef = useRef(false);
|
|
190
231
|
|
|
191
232
|
// Ref mirrors isOpen for synchronous reads inside show/hide.
|
|
192
233
|
// State drives re-renders; the ref lets the imperative calls avoid
|
|
193
234
|
// stale-closure reads of the previous isOpen value.
|
|
194
235
|
const isOpenRef = useRef(false);
|
|
236
|
+
const showPopoverElement = useCallback(popover => {
|
|
237
|
+
// Finding infra-4: the Popover API is unsupported on Safari <17 and
|
|
238
|
+
// Firefox <125. On those browsers `showPopover` does not exist, so fall
|
|
239
|
+
// back to plain visibility instead of throwing.
|
|
240
|
+
if (typeof popover.showPopover === 'function') {
|
|
241
|
+
// The trigger is passed as the popover's invoker `source`: a layer
|
|
242
|
+
// hosted away from its trigger then still takes its sequential focus
|
|
243
|
+
// order (and its popover nesting) from the trigger rather than from its
|
|
244
|
+
// own DOM position. Browsers without the option ignore it.
|
|
245
|
+
popover.showPopover({
|
|
246
|
+
source: triggerRef.current ?? undefined
|
|
247
|
+
});
|
|
248
|
+
} else {
|
|
249
|
+
popover.style.display = 'block';
|
|
250
|
+
}
|
|
251
|
+
openedPopoverRef.current = popover;
|
|
252
|
+
}, []);
|
|
253
|
+
const isCurrentContextPopover = useCallback(popover => {
|
|
254
|
+
if (mode !== 'context') {
|
|
255
|
+
return true;
|
|
256
|
+
}
|
|
257
|
+
const mount = contextMountRef.current;
|
|
258
|
+
if (mount === null) {
|
|
259
|
+
return false;
|
|
260
|
+
}
|
|
261
|
+
const expectedParent = mount.portalTarget ?? sentinelRef.current?.parentElement ?? null;
|
|
262
|
+
return popover.parentElement === expectedParent;
|
|
263
|
+
}, [mode]);
|
|
264
|
+
const requestContextMount = useCallback(() => {
|
|
265
|
+
if (mode !== 'context') {
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
const sentinel = sentinelRef.current;
|
|
269
|
+
const inlineParent = sentinel?.parentElement ?? null;
|
|
270
|
+
if (!sentinel || !inlineParent) {
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
const portalTarget = resolveLayerPortalTarget(inlineParent);
|
|
274
|
+
const mount = {
|
|
275
|
+
portalTarget,
|
|
276
|
+
portalStyle: portalTarget ? readPortalWritingContext(sentinel, portalTarget) : {}
|
|
277
|
+
};
|
|
278
|
+
contextMountRef.current = mount;
|
|
279
|
+
setContextMount(mount);
|
|
280
|
+
}, [mode]);
|
|
281
|
+
const clearContextMount = useCallback(() => {
|
|
282
|
+
if (mode !== 'context' || !lazyMount) {
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
contextMountRef.current = null;
|
|
286
|
+
setContextMount(null);
|
|
287
|
+
}, [mode, lazyMount]);
|
|
195
288
|
const show = useCallback(() => {
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
popover.style.display = 'block';
|
|
208
|
-
}
|
|
289
|
+
// A context popover left over until React commits a previous hide must not
|
|
290
|
+
// be reopened. The synchronous mount ref is the source of truth.
|
|
291
|
+
const candidate = popoverRef.current;
|
|
292
|
+
const popover = candidate && isCurrentContextPopover(candidate) ? candidate : null;
|
|
293
|
+
if (!popover) {
|
|
294
|
+
pendingShowRef.current = true;
|
|
295
|
+
requestContextMount();
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
if (!isOpenRef.current) {
|
|
299
|
+
showPopoverElement(popover);
|
|
209
300
|
isOpenRef.current = true;
|
|
210
301
|
setIsOpen(true);
|
|
211
302
|
onShow?.();
|
|
212
303
|
}
|
|
213
|
-
}, [onShow]);
|
|
304
|
+
}, [onShow, requestContextMount, showPopoverElement, isCurrentContextPopover]);
|
|
214
305
|
const hide = useCallback(() => {
|
|
306
|
+
pendingShowRef.current = false;
|
|
215
307
|
if (isOpenRef.current) {
|
|
216
308
|
const el = popoverRef.current;
|
|
217
309
|
// See finding infra-4 note in `show`: mirror the same guard on hide so
|
|
@@ -223,11 +315,13 @@ export function useLayer(options) {
|
|
|
223
315
|
el.style.display = 'none';
|
|
224
316
|
}
|
|
225
317
|
}
|
|
318
|
+
openedPopoverRef.current = null;
|
|
226
319
|
isOpenRef.current = false;
|
|
227
320
|
setIsOpen(false);
|
|
228
321
|
onHide?.();
|
|
229
322
|
}
|
|
230
|
-
|
|
323
|
+
clearContextMount();
|
|
324
|
+
}, [onHide, clearContextMount]);
|
|
231
325
|
|
|
232
326
|
// Ref for trigger element (context mode only)
|
|
233
327
|
const ref = mode === 'context' ? el => {
|
|
@@ -255,11 +349,13 @@ export function useLayer(options) {
|
|
|
255
349
|
const handleToggle = useCallback(e => {
|
|
256
350
|
const toggleEvent = e;
|
|
257
351
|
if (toggleEvent.newState === 'closed' && isOpenRef.current) {
|
|
352
|
+
openedPopoverRef.current = null;
|
|
258
353
|
isOpenRef.current = false;
|
|
259
354
|
setIsOpen(false);
|
|
260
355
|
onHide?.();
|
|
356
|
+
clearContextMount();
|
|
261
357
|
}
|
|
262
|
-
}, [onHide]);
|
|
358
|
+
}, [onHide, clearContextMount]);
|
|
263
359
|
|
|
264
360
|
// Ref callback for popover element — sets up the `toggle` listener.
|
|
265
361
|
// Tracks the element + handler currently bound so the listener is removed
|
|
@@ -283,7 +379,24 @@ export function useLayer(options) {
|
|
|
283
379
|
const popoverRefCallback = useCallback(el => {
|
|
284
380
|
popoverRef.current = el;
|
|
285
381
|
bindToggleListener(el, handleToggle);
|
|
286
|
-
|
|
382
|
+
if (el && pendingShowRef.current) {
|
|
383
|
+
pendingShowRef.current = false;
|
|
384
|
+
show();
|
|
385
|
+
} else if (el && isOpenRef.current && openedPopoverRef.current !== el && isCurrentContextPopover(el)) {
|
|
386
|
+
// Changing a portal target remounts the popover. Preserve the logical
|
|
387
|
+
// open state without firing onShow again for the replacement element.
|
|
388
|
+
showPopoverElement(el);
|
|
389
|
+
}
|
|
390
|
+
}, [handleToggle, bindToggleListener, show, showPopoverElement, isCurrentContextPopover]);
|
|
391
|
+
const sentinelRefCallback = useCallback(el => {
|
|
392
|
+
sentinelRef.current = el;
|
|
393
|
+
if (el && (!lazyMount || pendingShowRef.current || isOpenRef.current)) {
|
|
394
|
+
// The render call may have moved while the hook stayed mounted.
|
|
395
|
+
// Resolve again from the newly attached marker rather than reusing a
|
|
396
|
+
// portal target from its previous JSX position.
|
|
397
|
+
requestContextMount();
|
|
398
|
+
}
|
|
399
|
+
}, [lazyMount, requestContextMount]);
|
|
287
400
|
|
|
288
401
|
// Re-bind when the handler identity changes while the element stays mounted,
|
|
289
402
|
// and detach on unmount.
|
|
@@ -302,6 +415,17 @@ export function useLayer(options) {
|
|
|
302
415
|
|
|
303
416
|
// Render function for context mode
|
|
304
417
|
const renderContext = useCallback((children, props) => {
|
|
418
|
+
// Keep the marker mounted after resolving the layer. Apart from giving
|
|
419
|
+
// us the real JSX parent on first show, this lets its ref report when a
|
|
420
|
+
// persistent hook's render call moves to a different host.
|
|
421
|
+
const sentinel = /*#__PURE__*/_jsx("template", {
|
|
422
|
+
ref: sentinelRefCallback
|
|
423
|
+
});
|
|
424
|
+
if (contextMount === null) {
|
|
425
|
+
return /*#__PURE__*/_jsx(_Fragment, {
|
|
426
|
+
children: sentinel
|
|
427
|
+
});
|
|
428
|
+
}
|
|
305
429
|
const {
|
|
306
430
|
placement = 'above',
|
|
307
431
|
alignment = 'center',
|
|
@@ -332,10 +456,10 @@ export function useLayer(options) {
|
|
|
332
456
|
const stylexResult = stylex.props(styles.base, offsetStyle, xstyle);
|
|
333
457
|
const combinedClassName = extraClassName ? `${extraClassName} ${stylexResult.className ?? ''}` : stylexResult.className;
|
|
334
458
|
|
|
335
|
-
//
|
|
336
|
-
//
|
|
337
|
-
//
|
|
338
|
-
|
|
459
|
+
// The marker gives us the actual JSX parent without mounting arbitrary
|
|
460
|
+
// children there. Safe positions preserve the existing DOM order and
|
|
461
|
+
// cascade; unsafe positions use the nearest corrective portal target.
|
|
462
|
+
const layer = /*#__PURE__*/_jsx(Container, {
|
|
339
463
|
ref: popoverRefCallback,
|
|
340
464
|
id: id,
|
|
341
465
|
role: role,
|
|
@@ -345,13 +469,17 @@ export function useLayer(options) {
|
|
|
345
469
|
style: {
|
|
346
470
|
...stylexResult.style,
|
|
347
471
|
...anchorStyle,
|
|
472
|
+
...contextMount.portalStyle,
|
|
348
473
|
...extraStyle
|
|
349
474
|
},
|
|
350
475
|
onMouseEnter: onMouseEnter,
|
|
351
476
|
onMouseLeave: onMouseLeave,
|
|
352
477
|
children: children
|
|
353
478
|
});
|
|
354
|
-
|
|
479
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
480
|
+
children: [sentinel, contextMount.portalTarget ? /*#__PURE__*/createPortal(layer, contextMount.portalTarget) : layer]
|
|
481
|
+
});
|
|
482
|
+
}, [anchorId, contextMount, id, lightDismiss, popoverRefCallback, sentinelRefCallback]);
|
|
355
483
|
|
|
356
484
|
// Render function for fixed mode
|
|
357
485
|
const renderFixed = useCallback((children, props) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/Markdown/parser.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AAMH,MAAM,MAAM,UAAU,GAClB;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAC,GAC/B;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,UAAU,EAAE,CAAA;CAAC,GACtC;IAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,EAAE,UAAU,EAAE,CAAA;CAAC,GACxC;IAAC,IAAI,EAAE,eAAe,CAAC;IAAC,QAAQ,EAAE,UAAU,EAAE,CAAA;CAAC,GAC/C;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAC,GAC/B;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,UAAU,EAAE,CAAA;CAAC,GACpD;IAAC,IAAI,EAAE,OAAO,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAC,GACzC;IAAC,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAC,GACpC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAC,CAAC;AAEpB,MAAM,MAAM,SAAS,GACjB;IAAC,IAAI,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAAC,QAAQ,EAAE,UAAU,EAAE,CAAA;CAAC,GACvE;IAAC,IAAI,EAAE,WAAW,CAAC;IAAC,QAAQ,EAAE,UAAU,EAAE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E,YAAY,GAAG,UAAU,EAAE,CAAC;AAqyB/E,wBAAgB,aAAa,CAC3B,KAAK,EAAE,MAAM,EACb,SAAS,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,GAC9B,SAAS,EAAE,CAAC;AACf,wBAAgB,aAAa,CAC3B,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,YAAY,GACpB,SAAS,EAAE,CAAC;AAyJf,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,SAAS,EAAE,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC;IACjB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,wBAAgB,sBAAsB,IAAI,gBAAgB,CAEzD;AAqCD;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAkJ5D;AA0GD,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,gBAAgB,EACvB,SAAS,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,GAC9B,SAAS,EAAE,CAAC;AACf,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,gBAAgB,EACvB,OAAO,EAAE,YAAY,GACpB,SAAS,EAAE,CAAC"}
|
package/dist/Markdown/parser.js
CHANGED
|
@@ -203,7 +203,7 @@ function matchReferenceLink(text, start, linkDefs, opts) {
|
|
|
203
203
|
// matches nothing.
|
|
204
204
|
const label = rawLabel === '' ? linkText : rawLabel;
|
|
205
205
|
const href = linkDefs.get(normalizeLinkLabel(label));
|
|
206
|
-
if (href != null) {
|
|
206
|
+
if (href != null && isSafeUrl(href)) {
|
|
207
207
|
return {
|
|
208
208
|
node: {
|
|
209
209
|
type: 'link',
|
|
@@ -222,7 +222,7 @@ function matchReferenceLink(text, start, linkDefs, opts) {
|
|
|
222
222
|
return null;
|
|
223
223
|
}
|
|
224
224
|
const href = linkDefs.get(normalizeLinkLabel(linkText));
|
|
225
|
-
if (href == null) {
|
|
225
|
+
if (href == null || !isSafeUrl(href)) {
|
|
226
226
|
return null;
|
|
227
227
|
}
|
|
228
228
|
return {
|
|
@@ -304,6 +304,27 @@ function isWordChar(ch) {
|
|
|
304
304
|
return /\w/.test(ch);
|
|
305
305
|
}
|
|
306
306
|
|
|
307
|
+
// ---------------------------------------------------------------------------
|
|
308
|
+
// URL scheme sanitization
|
|
309
|
+
// ---------------------------------------------------------------------------
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Reject URLs with dangerous schemes (javascript:, vbscript:, data:) that
|
|
313
|
+
* could execute arbitrary code when rendered as link hrefs or image srcs.
|
|
314
|
+
* Returns true if the URL is safe to use, false otherwise.
|
|
315
|
+
*/
|
|
316
|
+
function isSafeUrl(url) {
|
|
317
|
+
// Trim and collapse whitespace/control chars that browsers tolerate but
|
|
318
|
+
// could bypass a naive prefix check (e.g. "java\nscript:alert(1)").
|
|
319
|
+
// eslint-disable-next-line no-control-regex -- control chars are the bypass
|
|
320
|
+
const normalized = url.replace(/[\x00-\x1f\x7f]/g, '').trim();
|
|
321
|
+
const lower = normalized.toLowerCase();
|
|
322
|
+
if (lower.startsWith('javascript:') || lower.startsWith('vbscript:') || lower.startsWith('data:text/html')) {
|
|
323
|
+
return false;
|
|
324
|
+
}
|
|
325
|
+
return true;
|
|
326
|
+
}
|
|
327
|
+
|
|
307
328
|
// ---------------------------------------------------------------------------
|
|
308
329
|
// Inline parser
|
|
309
330
|
// ---------------------------------------------------------------------------
|
|
@@ -419,11 +440,20 @@ function parseInlineImpl(text, opts) {
|
|
|
419
440
|
if (altClose !== -1 && text[altClose + 1] === '(') {
|
|
420
441
|
const srcClose = findClosingParen(text, altClose + 2);
|
|
421
442
|
if (srcClose !== -1) {
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
443
|
+
const src = text.slice(altClose + 2, srcClose);
|
|
444
|
+
if (!isSafeUrl(src)) {
|
|
445
|
+
// Dangerous scheme — emit as plain text.
|
|
446
|
+
nodes.push({
|
|
447
|
+
type: 'text',
|
|
448
|
+
content: text.slice(i, srcClose + 1)
|
|
449
|
+
});
|
|
450
|
+
} else {
|
|
451
|
+
nodes.push({
|
|
452
|
+
type: 'image',
|
|
453
|
+
src,
|
|
454
|
+
alt: text.slice(i + 2, altClose)
|
|
455
|
+
});
|
|
456
|
+
}
|
|
427
457
|
i = srcClose + 1;
|
|
428
458
|
continue;
|
|
429
459
|
}
|
|
@@ -459,11 +489,20 @@ function parseInlineImpl(text, opts) {
|
|
|
459
489
|
if (textClose !== -1 && text[textClose + 1] === '(') {
|
|
460
490
|
const urlClose = findClosingParen(text, textClose + 2);
|
|
461
491
|
if (urlClose !== -1) {
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
492
|
+
const href = text.slice(textClose + 2, urlClose);
|
|
493
|
+
if (!isSafeUrl(href)) {
|
|
494
|
+
// Dangerous scheme — emit as plain text instead of a link.
|
|
495
|
+
nodes.push({
|
|
496
|
+
type: 'text',
|
|
497
|
+
content: text.slice(i, urlClose + 1)
|
|
498
|
+
});
|
|
499
|
+
} else {
|
|
500
|
+
nodes.push({
|
|
501
|
+
type: 'link',
|
|
502
|
+
href,
|
|
503
|
+
children: parseInlineImpl(text.slice(i + 1, textClose), opts)
|
|
504
|
+
});
|
|
505
|
+
}
|
|
467
506
|
i = urlClose + 1;
|
|
468
507
|
continue;
|
|
469
508
|
}
|
|
@@ -690,6 +729,10 @@ function scanAutolinksInText(text) {
|
|
|
690
729
|
let m;
|
|
691
730
|
while ((m = re.exec(text)) !== null) {
|
|
692
731
|
const url = m[1];
|
|
732
|
+
// Skip dangerous URL schemes (javascript:, vbscript:, data:text/html)
|
|
733
|
+
if (!isSafeUrl(url)) {
|
|
734
|
+
continue;
|
|
735
|
+
}
|
|
693
736
|
matches.push({
|
|
694
737
|
start: m.index,
|
|
695
738
|
end: m.index + m[0].length,
|
|
@@ -9,8 +9,13 @@
|
|
|
9
9
|
* disabled state) so all nav-like components stay in sync — especially important
|
|
10
10
|
* when TopNav items render inside MobileNav drawers alongside SideNav items.
|
|
11
11
|
*
|
|
12
|
-
* Individual components layer their own overrides (e.g. collapsed mode,
|
|
13
|
-
*
|
|
12
|
+
* Individual components layer their own overrides (e.g. collapsed mode,
|
|
13
|
+
* indentation) via stylex.props composition.
|
|
14
|
+
*
|
|
15
|
+
* The focus ring is not defined here. Compose
|
|
16
|
+
* `focusOutlineProps.focusVisible` (utils/focusOutline.stylex.ts) at the call
|
|
17
|
+
* site, on whichever element actually takes focus — in a split-action row that
|
|
18
|
+
* is the link and the toggle, not the row that contains them.
|
|
14
19
|
*/
|
|
15
20
|
export type NavItemSize = 'sm' | 'md' | 'lg';
|
|
16
21
|
import * as stylex from '@stylexjs/stylex';
|
|
@@ -63,15 +68,22 @@ export declare const navItemStyles: Readonly<{
|
|
|
63
68
|
}>;
|
|
64
69
|
}>;
|
|
65
70
|
readonly selected: Readonly<{
|
|
66
|
-
readonly backgroundColor: stylex.StyleXClassNameFor<"backgroundColor", "light-dark(rgba(5, 54, 89, 0.1), rgba(223, 226, 229, 0.2))">;
|
|
71
|
+
readonly backgroundColor: stylex.StyleXClassNameFor<"backgroundColor", "light-dark(rgba(5, 54, 89, 0.1), rgba(223, 226, 229, 0.2))" | "Highlight">;
|
|
72
|
+
readonly color: stylex.StyleXClassNameFor<"color", "HighlightText" | null>;
|
|
67
73
|
readonly fontWeight: stylex.StyleXClassNameFor<"fontWeight", "500">;
|
|
68
74
|
readonly ':hover': stylex.StyleXClassNameFor<":hover", {
|
|
69
75
|
readonly '@media (hover: hover)': {
|
|
70
|
-
readonly backgroundColor:
|
|
76
|
+
readonly backgroundColor: {
|
|
77
|
+
readonly default: stylex.StyleXVar<"light-dark(rgba(5, 54, 89, 0.1), rgba(223, 226, 229, 0.2))">;
|
|
78
|
+
readonly '@media (forced-colors: active)': "Highlight";
|
|
79
|
+
};
|
|
71
80
|
};
|
|
72
81
|
}>;
|
|
73
82
|
readonly ':active': stylex.StyleXClassNameFor<":active", {
|
|
74
|
-
readonly backgroundColor:
|
|
83
|
+
readonly backgroundColor: {
|
|
84
|
+
readonly default: stylex.StyleXVar<"light-dark(rgba(5, 54, 89, 0.1), rgba(223, 226, 229, 0.2))">;
|
|
85
|
+
readonly '@media (forced-colors: active)': "Highlight";
|
|
86
|
+
};
|
|
75
87
|
}>;
|
|
76
88
|
}>;
|
|
77
89
|
readonly disabled: Readonly<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navItemStyles.stylex.d.ts","sourceRoot":"","sources":["../../src/NavItem/navItemStyles.stylex.ts"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"navItemStyles.stylex.d.ts","sourceRoot":"","sources":["../../src/NavItem/navItemStyles.stylex.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,MAAM,MAAM,WAAW,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAE7C,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAC;AAU3C;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4FxB,CAAC"}
|
|
@@ -11,8 +11,13 @@
|
|
|
11
11
|
* disabled state) so all nav-like components stay in sync — especially important
|
|
12
12
|
* when TopNav items render inside MobileNav drawers alongside SideNav items.
|
|
13
13
|
*
|
|
14
|
-
* Individual components layer their own overrides (e.g. collapsed mode,
|
|
15
|
-
*
|
|
14
|
+
* Individual components layer their own overrides (e.g. collapsed mode,
|
|
15
|
+
* indentation) via stylex.props composition.
|
|
16
|
+
*
|
|
17
|
+
* The focus ring is not defined here. Compose
|
|
18
|
+
* `focusOutlineProps.focusVisible` (utils/focusOutline.stylex.ts) at the call
|
|
19
|
+
* site, on whichever element actually takes focus — in a split-action row that
|
|
20
|
+
* is the link and the toggle, not the row that contains them.
|
|
16
21
|
*/
|
|
17
22
|
|
|
18
23
|
import * as stylex from '@stylexjs/stylex';
|
|
@@ -63,10 +68,11 @@ export const navItemStyles = {
|
|
|
63
68
|
$$css: true
|
|
64
69
|
},
|
|
65
70
|
selected: {
|
|
66
|
-
kWkggS: "x17x4s8c",
|
|
71
|
+
kWkggS: "x17x4s8c x1jzqe4",
|
|
72
|
+
kMwMTN: "x1k5gbb1",
|
|
67
73
|
k63SB2: "x1e4wzip",
|
|
68
|
-
kHE3J0: "x1sua13m",
|
|
69
|
-
kSReZ0: "xjtnuge",
|
|
74
|
+
kHE3J0: "x1sua13m x1jawyga",
|
|
75
|
+
kSReZ0: "xjtnuge x1vo6n7o",
|
|
70
76
|
$$css: true
|
|
71
77
|
},
|
|
72
78
|
disabled: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RadioListItem.d.ts","sourceRoot":"","sources":["../../src/RadioList/RadioListItem.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,EAAqB,KAAK,SAAS,EAAC,MAAM,OAAO,CAAC;AAEhE,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"RadioListItem.d.ts","sourceRoot":"","sources":["../../src/RadioList/RadioListItem.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,EAAqB,KAAK,SAAS,EAAC,MAAM,OAAO,CAAC;AAEhE,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAsF5C,MAAM,WAAW,kBAAmB,SAAQ,SAAS,CAAC,cAAc,CAAC;IACnE,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IAChC;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;OAEG;IACH,YAAY,CAAC,EAAE,SAAS,CAAC;IACzB;;OAEG;IACH,UAAU,CAAC,EAAE,SAAS,CAAC;CACxB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAAC,EAC5B,GAAG,EACH,KAAK,EACL,KAAK,EACL,WAAW,EACX,UAAU,EAAE,cAAsB,EAClC,YAAY,EACZ,UAAU,EACV,MAAM,EACN,SAAS,EACT,KAAK,EACL,GAAG,IAAI,EACR,EAAE,kBAAkB,qBA8GpB;yBA1He,aAAa"}
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
import { type ReactNode } from 'react';
|
|
20
20
|
import type { BaseProps } from '../BaseProps';
|
|
21
21
|
import type { StyleXStyles } from '@stylexjs/stylex';
|
|
22
|
-
import { type SideNavImperativeCollapseHandle } from './SideNavCollapseContext';
|
|
22
|
+
import { type SideNavCollapsibleConfig, type SideNavImperativeCollapseHandle } from './SideNavCollapseContext';
|
|
23
23
|
import type { ResizableConfig } from '../Resizable/useResizable';
|
|
24
24
|
export interface SideNavProps extends BaseProps<HTMLElement> {
|
|
25
25
|
/** Ref forwarded to the root element */
|
|
@@ -28,6 +28,9 @@ export interface SideNavProps extends BaseProps<HTMLElement> {
|
|
|
28
28
|
* Imperative collapse handle for SideNavCollapseButton instances rendered
|
|
29
29
|
* outside this SideNav. This intentionally stays separate from `ref`, which
|
|
30
30
|
* continues to expose the root HTMLElement.
|
|
31
|
+
*
|
|
32
|
+
* @deprecated Hand the same controlled `collapsible` config to SideNav and
|
|
33
|
+
* to the outside button instead.
|
|
31
34
|
*/
|
|
32
35
|
handleRef?: React.Ref<SideNavImperativeCollapseHandle>;
|
|
33
36
|
/**
|
|
@@ -98,19 +101,14 @@ export interface SideNavProps extends BaseProps<HTMLElement> {
|
|
|
98
101
|
* - `true` — enables collapse with default toggle button and uncontrolled state
|
|
99
102
|
* - Object — enables collapse with advanced configuration:
|
|
100
103
|
* - `defaultIsCollapsed` — start collapsed (uncontrolled)
|
|
101
|
-
* - `isCollapsed` + `onCollapsedChange` — controlled mode
|
|
104
|
+
* - `isCollapsed` + `onCollapsedChange` — controlled mode. Pass the same
|
|
105
|
+
* object to a `SideNavCollapseButton` rendered outside this SideNav
|
|
102
106
|
* - `hasButton` — render built-in collapse button (default: true)
|
|
103
107
|
* - `buttonLabel` — accessibility label for the collapse button
|
|
104
108
|
*
|
|
105
109
|
* @default false
|
|
106
110
|
*/
|
|
107
|
-
collapsible?: boolean |
|
|
108
|
-
defaultIsCollapsed?: boolean;
|
|
109
|
-
isCollapsed?: boolean;
|
|
110
|
-
onCollapsedChange?: (isCollapsed: boolean) => void;
|
|
111
|
-
hasButton?: boolean;
|
|
112
|
-
buttonLabel?: string;
|
|
113
|
-
};
|
|
111
|
+
collapsible?: boolean | SideNavCollapsibleConfig;
|
|
114
112
|
}
|
|
115
113
|
/**
|
|
116
114
|
* Sidebar navigation container for application pages.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SideNav.d.ts","sourceRoot":"","sources":["../../src/SideNav/SideNav.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAKL,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAE5C,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAGnD,OAAO,EAGL,KAAK,+BAA+B,EACrC,MAAM,0BAA0B,CAAC;AAKlC,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version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