@astryxdesign/core 0.7.9-canary.1fec9fa → 0.7.9-canary.2947be8
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/dist/Layout/LayoutPanel.d.ts +10 -10
- package/dist/Layout/LayoutPanel.d.ts.map +1 -1
- package/dist/Layout/LayoutPanel.js +7 -59
- package/dist/Resizable/ResizeHandle.d.ts +5 -5
- package/dist/Resizable/ResizeHandle.d.ts.map +1 -1
- package/dist/Resizable/ResizeHandle.js +5 -44
- package/dist/Resizable/useResizable.d.ts +0 -7
- package/dist/Resizable/useResizable.d.ts.map +1 -1
- package/dist/Resizable/useResizable.js +0 -13
- package/dist/SideNav/SideNav.d.ts +3 -9
- package/dist/SideNav/SideNav.d.ts.map +1 -1
- package/dist/SideNav/SideNav.js +10 -47
- package/package.json +4 -4
- package/src/Layout/LayoutPanel.doc.mjs +8 -8
- package/src/Layout/LayoutPanel.tsx +13 -89
- package/src/Resizable/Resizable.doc.mjs +12 -40
- package/src/Resizable/ResizeHandle.tsx +6 -68
- package/src/Resizable/useResizable.ts +0 -15
- package/src/SideNav/SideNav.doc.mjs +2 -2
- package/src/SideNav/SideNav.tsx +12 -88
- package/dist/Resizable/resizablePane.d.ts +0 -60
- package/dist/Resizable/resizablePane.d.ts.map +0 -1
- package/dist/Resizable/resizablePane.js +0 -142
- package/src/Resizable/resizablePane.ts +0 -188
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file LayoutPanel.tsx
|
|
3
3
|
* @input Uses React StyleX, LayoutAreaContext, LayoutSlotsContext,
|
|
4
|
-
* useScrollRegionProps
|
|
4
|
+
* useScrollRegionProps
|
|
5
5
|
* @output Exports LayoutPanel component and LayoutPanelProps
|
|
6
6
|
* @position Sidebar panel for Layout start/end slots. Use for navigation panels,
|
|
7
7
|
* settings sidebars, detail panels, or any fixed-width side content.
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
import type { AriaRole, ReactNode } from 'react';
|
|
15
15
|
import type { BaseProps } from '../BaseProps.js';
|
|
16
16
|
import type { SizeValue, SpacingStep } from '../utils/types.js';
|
|
17
|
-
import {
|
|
17
|
+
import type { ResizableProps } from '../Resizable/useResizable.js';
|
|
18
18
|
export interface LayoutPanelProps extends BaseProps<HTMLDivElement> {
|
|
19
19
|
ref?: React.Ref<HTMLDivElement>;
|
|
20
20
|
/**
|
|
@@ -64,20 +64,20 @@ export interface LayoutPanelProps extends BaseProps<HTMLDivElement> {
|
|
|
64
64
|
*/
|
|
65
65
|
width?: SizeValue;
|
|
66
66
|
/**
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
67
|
+
* Resize props from `useResizable()`. When provided, the panel width
|
|
68
|
+
* is driven by the hook and a resize handle should be placed adjacent
|
|
69
|
+
* to this panel.
|
|
70
70
|
*
|
|
71
71
|
* @example
|
|
72
72
|
* ```
|
|
73
|
-
* const
|
|
74
|
-
* <LayoutPanel resizable={
|
|
73
|
+
* const sidebar = useResizable({ defaultSize: 250, minSize: 200 });
|
|
74
|
+
* <LayoutPanel resizable={sidebar.props}>
|
|
75
75
|
* <Navigation />
|
|
76
76
|
* </LayoutPanel>
|
|
77
|
-
* <ResizeHandle resizable={
|
|
77
|
+
* <ResizeHandle resizable={sidebar.props} />
|
|
78
78
|
* ```
|
|
79
79
|
*/
|
|
80
|
-
resizable?:
|
|
80
|
+
resizable?: ResizableProps;
|
|
81
81
|
}
|
|
82
82
|
/**
|
|
83
83
|
* Sidebar or side panel for Layout. Use in the `start` slot for left navigation
|
|
@@ -107,7 +107,7 @@ export interface LayoutPanelProps extends BaseProps<HTMLDivElement> {
|
|
|
107
107
|
* </LayoutContainer>
|
|
108
108
|
* ```
|
|
109
109
|
*/
|
|
110
|
-
export declare function LayoutPanel({ children, hasDivider, isScrollable, label, padding, role, width, resizable
|
|
110
|
+
export declare function LayoutPanel({ children, hasDivider, isScrollable, label, padding, role, width, resizable, xstyle, className, style, ref, ...props }: LayoutPanelProps): import("react").JSX.Element;
|
|
111
111
|
export declare namespace LayoutPanel {
|
|
112
112
|
var displayName: string;
|
|
113
113
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LayoutPanel.d.ts","sourceRoot":"","sources":["../../src/Layout/LayoutPanel.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAC,QAAQ,EAAE,SAAS,EAAC,MAAM,OAAO,CAAC;AAC/C,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAS5C,OAAO,KAAK,EAAC,SAAS,EAAE,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAC3D,OAAO,
|
|
1
|
+
{"version":3,"file":"LayoutPanel.d.ts","sourceRoot":"","sources":["../../src/Layout/LayoutPanel.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAC,QAAQ,EAAE,SAAS,EAAC,MAAM,OAAO,CAAC;AAC/C,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAS5C,OAAO,KAAK,EAAC,SAAS,EAAE,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAC3D,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,2BAA2B,CAAC;AAmF9D,MAAM,WAAW,gBAAiB,SAAQ,SAAS,CAAC,cAAc,CAAC;IACjE,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IAChC;;OAEG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;IAErB;;;;;;;;;OASG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;;;OAIG;IACH,OAAO,CAAC,EAAE,WAAW,CAAC;IAEtB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;OAGG;IACH,IAAI,CAAC,EAAE,QAAQ,CAAC;IAEhB;;;;OAIG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC;IAElB;;;;;;;;;;;;;OAaG;IACH,SAAS,CAAC,EAAE,cAAc,CAAC;CAC5B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,WAAW,CAAC,EAC1B,QAAQ,EACR,UAAkB,EAClB,YAAmB,EACnB,KAAK,EACL,OAAO,EACP,IAAI,EACJ,KAAK,EACL,SAAS,EACT,MAAM,EACN,SAAS,EACT,KAAK,EACL,GAAG,EACH,GAAG,KAAK,EACT,EAAE,gBAAgB,+BAoElB;yBAlFe,WAAW"}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @file LayoutPanel.tsx
|
|
7
7
|
* @input Uses React StyleX, LayoutAreaContext, LayoutSlotsContext,
|
|
8
|
-
* useScrollRegionProps
|
|
8
|
+
* useScrollRegionProps
|
|
9
9
|
* @output Exports LayoutPanel component and LayoutPanelProps
|
|
10
10
|
* @position Sidebar panel for Layout start/end slots. Use for navigation panels,
|
|
11
11
|
* settings sidebars, detail panels, or any fixed-width side content.
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* - /apps/storybook/stories/Layout.stories.tsx
|
|
16
16
|
* - /packages/cli/assets/templates/blocks/components/Layout/ (showcase blocks)
|
|
17
17
|
*/
|
|
18
|
-
import { use
|
|
18
|
+
import { use } from 'react';
|
|
19
19
|
import * as stylex from '@stylexjs/stylex';
|
|
20
20
|
import "../theme/tokens.stylex.js";
|
|
21
21
|
import { colorVars, spacingVars } from "../theme/tokens.stylex.js";
|
|
@@ -24,15 +24,9 @@ import { LayoutSlotsContext } from "./LayoutSlotsContext.js";
|
|
|
24
24
|
import { useMergedRefs } from "../hooks/useMergedRefs.js";
|
|
25
25
|
import { useScrollRegionProps } from "../hooks/useScrollRegionProps.js";
|
|
26
26
|
import { mergeProps } from "../utils/index.js";
|
|
27
|
-
import { resizablePropsOf } from "../Resizable/useResizable.js";
|
|
28
|
-
import { createResizablePaneLink, resizeHandleBeside } from "../Resizable/resizablePane.js";
|
|
29
|
-
import { LayoutChangeSnapshot } from "../motion/LayoutChangeSnapshot.js";
|
|
30
|
-
import { useIsomorphicLayoutEffect } from "../hooks/useIsomorphicLayoutEffect.js";
|
|
31
|
-
import { moveFocusLeftBehind, noteFocusWithin } from "../utils/focusReturn.js";
|
|
32
|
-
import { useFocusLeavingChange } from "../utils/useFocusLeavingChange.js";
|
|
33
27
|
import { themeProps } from "../utils/themeProps.js";
|
|
34
28
|
import { paddingStyles, containerPaddingInlineVarStyles, containerPaddingBlockStartVarStyles, containerPaddingBlockEndVarStyles } from "./padding.stylex.js";
|
|
35
|
-
import { jsx as _jsx
|
|
29
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
36
30
|
const styles = {
|
|
37
31
|
panel: {
|
|
38
32
|
kB7OPa: "x9f619",
|
|
@@ -100,7 +94,6 @@ const styles = {
|
|
|
100
94
|
$$css: true
|
|
101
95
|
}
|
|
102
96
|
};
|
|
103
|
-
const returnFalse = () => false;
|
|
104
97
|
|
|
105
98
|
// Dynamic styles for sizing props
|
|
106
99
|
const dynamicStyles = {
|
|
@@ -147,14 +140,13 @@ export function LayoutPanel({
|
|
|
147
140
|
padding,
|
|
148
141
|
role,
|
|
149
142
|
width,
|
|
150
|
-
resizable
|
|
143
|
+
resizable,
|
|
151
144
|
xstyle,
|
|
152
145
|
className,
|
|
153
146
|
style,
|
|
154
147
|
ref,
|
|
155
148
|
...props
|
|
156
149
|
}) {
|
|
157
|
-
const resizable = resizableValue == null ? undefined : resizablePropsOf(resizableValue);
|
|
158
150
|
const area = use(LayoutAreaContext);
|
|
159
151
|
const {
|
|
160
152
|
hasHeader,
|
|
@@ -164,43 +156,6 @@ export function LayoutPanel({
|
|
|
164
156
|
// When resizable props are provided, use the hook-driven size
|
|
165
157
|
const effectiveWidth = resizable ? resizable._size : width;
|
|
166
158
|
|
|
167
|
-
// With no `resizable`, a ResizeHandle beside the panel that has a region's
|
|
168
|
-
// props finds the panel and holds it collapsed with the region. The panel
|
|
169
|
-
// lends its element in its callback ref for that.
|
|
170
|
-
const [paneLink] = useState(createResizablePaneLink);
|
|
171
|
-
const isHeldCollapsed = useSyncExternalStore(paneLink.subscribe, paneLink.isCollapsed, returnFalse);
|
|
172
|
-
const isLentBeside = resizable == null;
|
|
173
|
-
const lendRef = useCallback(element => {
|
|
174
|
-
paneLink.attach(isLentBeside ? element : null);
|
|
175
|
-
}, [paneLink, isLentBeside]);
|
|
176
|
-
|
|
177
|
-
// A collapsing panel moves focus inside it to its ResizeHandle, through the
|
|
178
|
-
// focus-leaving sequence that disclosures share. It goes inert and hidden
|
|
179
|
-
// from assistive technology a commit later, so inert never drops that focus
|
|
180
|
-
// to the page. Opening drops both at once. The ResizeHandle beside it holds
|
|
181
|
-
// the region's collapse state, or else the `resizable` props hold it.
|
|
182
|
-
const elementRef = useRef(null);
|
|
183
|
-
const isRegionCollapsed = resizable == null ? isHeldCollapsed : resizable._isCollapsed;
|
|
184
|
-
const noteFocusBeforeCollapse = useFocusLeavingChange(isRegionCollapsed, wasCollapsed => wasCollapsed ? null : noteFocusWithin(elementRef.current), (noted, isCollapsed) => {
|
|
185
|
-
const panel = elementRef.current;
|
|
186
|
-
if (isCollapsed && panel != null) {
|
|
187
|
-
moveFocusLeftBehind(noted, paneLink.focusTarget() ?? resizeHandleBeside(panel, area), panel);
|
|
188
|
-
}
|
|
189
|
-
});
|
|
190
|
-
const [isSettledCollapsed, setIsSettledCollapsed] = useState(isRegionCollapsed);
|
|
191
|
-
if (!isRegionCollapsed && isSettledCollapsed) {
|
|
192
|
-
setIsSettledCollapsed(false);
|
|
193
|
-
}
|
|
194
|
-
// Syncs `inert` with the browser's focus: the panel goes inert only after
|
|
195
|
-
// this commit's focus move.
|
|
196
|
-
useIsomorphicLayoutEffect(() => {
|
|
197
|
-
if (isRegionCollapsed && !isSettledCollapsed) {
|
|
198
|
-
// eslint-disable-next-line @eslint-react/set-state-in-effect -- the panel goes inert only after the focus-leaving move above ran in this commit; inert in the collapsing commit would drop that focus to the page first
|
|
199
|
-
setIsSettledCollapsed(true);
|
|
200
|
-
}
|
|
201
|
-
}, [isRegionCollapsed, isSettledCollapsed]);
|
|
202
|
-
const isConcealed = isRegionCollapsed && isSettledCollapsed;
|
|
203
|
-
|
|
204
159
|
// Determine panel position
|
|
205
160
|
const isStartPanel = area === 'start';
|
|
206
161
|
const isEndPanel = area === 'end';
|
|
@@ -213,14 +168,14 @@ export function LayoutPanel({
|
|
|
213
168
|
role,
|
|
214
169
|
label
|
|
215
170
|
});
|
|
216
|
-
const mergedRef = useMergedRefs(ref, region.ref
|
|
171
|
+
const mergedRef = useMergedRefs(ref, region.ref);
|
|
217
172
|
|
|
218
173
|
// Select divider style based on position
|
|
219
174
|
const dividerStyle = isStartPanel ? styles.dividerEnd : isEndPanel ? styles.dividerStart : null;
|
|
220
175
|
|
|
221
176
|
// Select collapse style based on position (collapse the side where divider would be)
|
|
222
177
|
const collapseStyle = isStartPanel ? styles.collapseEnd : isEndPanel ? styles.collapseStart : null;
|
|
223
|
-
return /*#__PURE__*/
|
|
178
|
+
return /*#__PURE__*/_jsx("div", {
|
|
224
179
|
ref: mergedRef,
|
|
225
180
|
role: region.role,
|
|
226
181
|
"aria-label": region['aria-label'],
|
|
@@ -228,14 +183,7 @@ export function LayoutPanel({
|
|
|
228
183
|
// Outer padding on container edges (unless component is full bleed)
|
|
229
184
|
isStartPanel && !isZeroPadding && padding == null && styles.startPanel, isEndPanel && !isZeroPadding && padding == null && styles.endPanel, !hasHeader && !isZeroPadding && padding == null && styles.noHeader, !hasFooter && !isZeroPadding && padding == null && styles.noFooter, isScrollable && styles.scrollable, isZeroPadding && styles.fullBleed, padding != null && paddingStyles[padding], padding != null && containerPaddingInlineVarStyles[padding], padding != null && containerPaddingBlockStartVarStyles[padding], padding != null && containerPaddingBlockEndVarStyles[padding], hasDivider && dividerStyle, shouldCollapseSpacing && collapseStyle, xstyle), className, style),
|
|
230
185
|
...props,
|
|
231
|
-
|
|
232
|
-
inert: true,
|
|
233
|
-
'aria-hidden': true
|
|
234
|
-
} : {}),
|
|
235
|
-
children: [/*#__PURE__*/_jsx(LayoutChangeSnapshot, {
|
|
236
|
-
value: isRegionCollapsed,
|
|
237
|
-
onBeforeChange: noteFocusBeforeCollapse
|
|
238
|
-
}), children]
|
|
186
|
+
children: children
|
|
239
187
|
});
|
|
240
188
|
}
|
|
241
189
|
LayoutPanel.displayName = 'LayoutPanel';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
2
|
import type { BaseProps } from '../BaseProps.js';
|
|
3
|
-
import { type ResizableProps
|
|
3
|
+
import { type ResizableProps } from './useResizable.js';
|
|
4
4
|
type PillPlacement = 'start' | 'end' | 'center' | 'auto';
|
|
5
5
|
export interface ResizeHandleProps extends Omit<BaseProps<HTMLDivElement>, 'style'> {
|
|
6
6
|
ref?: React.Ref<HTMLDivElement>;
|
|
@@ -57,8 +57,8 @@ export interface ResizeHandleProps extends Omit<BaseProps<HTMLDivElement>, 'styl
|
|
|
57
57
|
* @default 'Resize handle'
|
|
58
58
|
*/
|
|
59
59
|
label?: string;
|
|
60
|
-
/**
|
|
61
|
-
resizable?:
|
|
60
|
+
/** Resize props from useResizable region. */
|
|
61
|
+
resizable?: ResizableProps;
|
|
62
62
|
/** Custom handle content. Overrides the default pill. */
|
|
63
63
|
children?: ReactNode;
|
|
64
64
|
}
|
|
@@ -72,12 +72,12 @@ export interface ResizeHandleProps extends Omit<BaseProps<HTMLDivElement>, 'styl
|
|
|
72
72
|
* @example
|
|
73
73
|
* ```
|
|
74
74
|
* <ResizeHandle
|
|
75
|
-
* resizable={
|
|
75
|
+
* resizable={sidebar.props}
|
|
76
76
|
* direction="horizontal"
|
|
77
77
|
* hasDivider />
|
|
78
78
|
* ```
|
|
79
79
|
*/
|
|
80
|
-
export declare function ResizeHandle({ direction, position: positionMode, isReversed, isDisabled, hasDivider, isAlwaysVisible, pillPlacement, label: labelFromProps, resizable
|
|
80
|
+
export declare function ResizeHandle({ direction, position: positionMode, isReversed, isDisabled, hasDivider, isAlwaysVisible, pillPlacement, label: labelFromProps, resizable, children, xstyle, className, ref, ...props }: ResizeHandleProps): import("react").JSX.Element;
|
|
81
81
|
export declare namespace ResizeHandle {
|
|
82
82
|
var displayName: string;
|
|
83
83
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResizeHandle.d.ts","sourceRoot":"","sources":["../../src/Resizable/ResizeHandle.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAiB,SAAS,EAAC,MAAM,OAAO,CAAC;AAErD,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAU5C,OAAO,
|
|
1
|
+
{"version":3,"file":"ResizeHandle.d.ts","sourceRoot":"","sources":["../../src/Resizable/ResizeHandle.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAiB,SAAS,EAAC,MAAM,OAAO,CAAC;AAErD,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAU5C,OAAO,EAGL,KAAK,cAAc,EACpB,MAAM,gBAAgB,CAAC;AAmBxB,KAAK,aAAa,GAAG,OAAO,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;AA8PzD,MAAM,WAAW,iBAAkB,SAAQ,IAAI,CAC7C,SAAS,CAAC,cAAc,CAAC,EACzB,OAAO,CACR;IACC,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IAEhC;;;OAGG;IACH,SAAS,CAAC,EAAE,YAAY,GAAG,UAAU,CAAC;IAEtC;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;IAEhC;;;;;OAKG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;;;;OAKG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;;;OAIG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAE1B;;;;;;;;OAQG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC;IAE9B;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,6CAA6C;IAC7C,SAAS,CAAC,EAAE,cAAc,CAAC;IAE3B,yDAAyD;IACzD,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED;;;;;;;;;;;;;;GAcG;AAEH,wBAAgB,YAAY,CAAC,EAC3B,SAAwB,EACxB,QAAQ,EAAE,YAAuB,EACjC,UAAkB,EAClB,UAAkB,EAClB,UAAkB,EAClB,eAAsB,EACtB,aAAsB,EACtB,KAAK,EAAE,cAAc,EACrB,SAAS,EACT,QAAQ,EACR,MAAM,EACN,SAAS,EACT,GAAG,EACH,GAAG,KAAK,EACT,EAAE,iBAAiB,+BAsSnB;yBArTe,YAAY"}
|
|
@@ -11,21 +11,18 @@
|
|
|
11
11
|
* A drag takes pointer capture on the element it starts on, so moves over an
|
|
12
12
|
* embedded frame still arrive.
|
|
13
13
|
*/
|
|
14
|
-
import {
|
|
14
|
+
import { useEffect, useRef, useState } from 'react';
|
|
15
15
|
import * as stylex from '@stylexjs/stylex';
|
|
16
16
|
import "../theme/tokens.stylex.js";
|
|
17
17
|
import { colorVars, durationVars, easeVars, radiusVars, spacingVars } from "../theme/tokens.stylex.js";
|
|
18
18
|
import { focusOutlineProps } from "../utils/focusOutline.stylex.js";
|
|
19
19
|
import { mergeProps, rtlStyles } from "../utils/index.js";
|
|
20
|
-
import { getCollapseControls, getEffectiveMaxPx
|
|
20
|
+
import { getCollapseControls, getEffectiveMaxPx } from "./useResizable.js";
|
|
21
21
|
import { createResizeGesture } from "./resizeGesture.js";
|
|
22
|
-
import { handOverPane, registerResizeHandle, resizablePaneFor, watchResizablePanes } from "./resizablePane.js";
|
|
23
22
|
import { separatorAttributes } from "./separatorAttributes.js";
|
|
24
23
|
import { themeProps } from "../utils/themeProps.js";
|
|
25
24
|
import { useDevWarning } from "../hooks/useDevWarning.js";
|
|
26
|
-
import { useIsomorphicLayoutEffect } from "../hooks/useIsomorphicLayoutEffect.js";
|
|
27
25
|
import { useMergedRefs } from "../hooks/useMergedRefs.js";
|
|
28
|
-
import { useInteractionModalityTracking } from "../utils/interactionModality.js";
|
|
29
26
|
import { registerEnglishFallback, useComponentTranslator } from "../i18n/useComponentTranslator.js";
|
|
30
27
|
import english from "../i18n/generated-english/Resizable/ResizeHandle.generated.js";
|
|
31
28
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -280,7 +277,7 @@ const dynamicStyles = {
|
|
|
280
277
|
* @example
|
|
281
278
|
* ```
|
|
282
279
|
* <ResizeHandle
|
|
283
|
-
* resizable={
|
|
280
|
+
* resizable={sidebar.props}
|
|
284
281
|
* direction="horizontal"
|
|
285
282
|
* hasDivider />
|
|
286
283
|
* ```
|
|
@@ -295,14 +292,13 @@ export function ResizeHandle({
|
|
|
295
292
|
isAlwaysVisible = true,
|
|
296
293
|
pillPlacement = 'auto',
|
|
297
294
|
label: labelFromProps,
|
|
298
|
-
resizable
|
|
295
|
+
resizable,
|
|
299
296
|
children,
|
|
300
297
|
xstyle,
|
|
301
298
|
className,
|
|
302
299
|
ref,
|
|
303
300
|
...props
|
|
304
301
|
}) {
|
|
305
|
-
const resizable = resizableValue == null ? undefined : resizablePropsOf(resizableValue);
|
|
306
302
|
const t = useComponentTranslator();
|
|
307
303
|
const label = labelFromProps ?? t('@astryx.resizable.handle.label');
|
|
308
304
|
const handleRef = useRef(null);
|
|
@@ -414,41 +410,6 @@ export function ResizeHandle({
|
|
|
414
410
|
};
|
|
415
411
|
}, [hasRegion, regionGesture]);
|
|
416
412
|
|
|
417
|
-
// --- The LayoutPanel beside a handle given `resizable` props ---
|
|
418
|
-
|
|
419
|
-
// A collapsing panel moves focus here, and the ring follows the last input.
|
|
420
|
-
const {
|
|
421
|
-
ref: modalityRef
|
|
422
|
-
} = useInteractionModalityTracking();
|
|
423
|
-
// A LayoutPanel at the region's size, with no `resizable` prop, has no
|
|
424
|
-
// controller to find it. This handle holds it collapsed with the region, so
|
|
425
|
-
// focus inside it moves here and it goes inert. A panel lent later is found
|
|
426
|
-
// at once.
|
|
427
|
-
const [, rerender] = useReducer(count => count + 1, 0);
|
|
428
|
-
const heldPaneRef = useRef(null);
|
|
429
|
-
// The element goes in the handle registry, for a collapsing panel beside it
|
|
430
|
-
// to hand focus to. When the element goes, a held panel opens.
|
|
431
|
-
const registryRef = useCallback(element => {
|
|
432
|
-
if (element == null) {
|
|
433
|
-
return;
|
|
434
|
-
}
|
|
435
|
-
const unregister = registerResizeHandle(element);
|
|
436
|
-
return () => {
|
|
437
|
-
unregister();
|
|
438
|
-
heldPaneRef.current = handOverPane(heldPaneRef.current, null, false, null);
|
|
439
|
-
};
|
|
440
|
-
}, []);
|
|
441
|
-
const isRegionCollapsed = resizable?._isCollapsed ?? false;
|
|
442
|
-
// Syncs with the lent-panel registry. A panel lent or taken back re-renders
|
|
443
|
-
// this handle, so it looks for its pane again.
|
|
444
|
-
useEffect(() => hasRegion ? watchResizablePanes(rerender) : undefined, [hasRegion]);
|
|
445
|
-
// Syncs the held panel with the region's collapse state after each commit.
|
|
446
|
-
useIsomorphicLayoutEffect(() => {
|
|
447
|
-
const element = handleRef.current;
|
|
448
|
-
const pane = hasRegion && element != null ? resizablePaneFor(element, isReversed) : null;
|
|
449
|
-
heldPaneRef.current = handOverPane(heldPaneRef.current, pane, isRegionCollapsed, element);
|
|
450
|
-
});
|
|
451
|
-
|
|
452
413
|
// --- ARIA ---
|
|
453
414
|
const sizeNow = resizable?._size;
|
|
454
415
|
const minNow = resizable?._minSizePx;
|
|
@@ -490,7 +451,7 @@ export function ResizeHandle({
|
|
|
490
451
|
}
|
|
491
452
|
};
|
|
492
453
|
return /*#__PURE__*/_jsxs("div", {
|
|
493
|
-
ref: useMergedRefs(ref, handleRef
|
|
454
|
+
ref: useMergedRefs(ref, handleRef),
|
|
494
455
|
role: "separator",
|
|
495
456
|
...aria,
|
|
496
457
|
"aria-label": label,
|
|
@@ -179,13 +179,6 @@ type CollapseControls = {
|
|
|
179
179
|
collapse: () => void;
|
|
180
180
|
expand: () => void;
|
|
181
181
|
};
|
|
182
|
-
/**
|
|
183
|
-
* The props behind a component's `resizable` slot. It takes useResizable's
|
|
184
|
-
* output directly, and still takes that output's `props`.
|
|
185
|
-
*/
|
|
186
|
-
export declare function resizablePropsOf(value: ResizableRegion | ResizableProps): ResizableProps;
|
|
187
|
-
/** Whether a `resizable` value is useResizable's output for one region. */
|
|
188
|
-
export declare function isResizableRegion(value: unknown): value is ResizableRegion;
|
|
189
182
|
/** The reported maximum for `props`, or `undefined` for a hand-built object. */
|
|
190
183
|
export declare function getEffectiveMaxPx(props: ResizableProps): number | undefined;
|
|
191
184
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useResizable.d.ts","sourceRoot":"","sources":["../../src/Resizable/useResizable.ts"],"names":[],"mappings":"AAIA;;;;;;;;GAQG;AAEH,OAAO,EAML,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,SAAS,CAAC;AAS3C,OAAO,EAEL,KAAK,kBAAkB,EACxB,MAAM,kBAAkB,CAAC;AAM1B,kCAAkC;AAClC,MAAM,MAAM,kBAAkB,GAAG;IAAC,OAAO,CAAC,EAAE,aAAa,CAAA;CAAC,CAAC;AAE3D,kCAAkC;AAClC,MAAM,MAAM,kBAAkB,GAAG;IAAC,OAAO,CAAC,EAAE,aAAa,CAAA;CAAC,CAAC;AAE3D,YAAY,EAAC,kBAAkB,EAAC,MAAM,kBAAkB,CAAC;AAEzD,MAAM,WAAW,qBAAqB;IACpC;;;;;;;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B,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,GAAG,SAAS,CAE3E;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,cAAc,GACpB,gBAAgB,GAAG,SAAS,CAE9B;AAED,mFAAmF;AACnF,KAAK,wBAAwB,CAAC,MAAM,IAAI,MAAM,SAAS,OAAO,GAC1D,MAAM,GAAG;IAAC,SAAS,CAAC,EAAE,KAAK,CAAC;IAAC,SAAS,CAAC,EAAE,KAAK,CAAA;CAAC,GAC/C,KAAK,CAAC;AAEV,KAAK,uBAAuB,CAAC,MAAM,IAAI,MAAM,SAAS,OAAO,GACzD,SAAS,SAAS,MAAM,MAAM,GAC5B,KAAK,GACL,wBAAwB,CAAC,MAAM,CAAC,GAClC,KAAK,CAAC;AAEV,KAAK,sBAAsB,CAAC,MAAM,SAAS,uBAAuB,IAChE,MAAM,SAAS,OAAO,GAClB,MAAM,GAAG;IACP,OAAO,EAAE;SACN,GAAG,IAAI,MAAM,MAAM,CAAC,SAAS,CAAC,GAAG,wBAAwB,CACxD,MAAM,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,CACvB;KACF,CAAC;CACH,GACD,KAAK,CAAC;AAoPZ,wBAAgB,YAAY,CAAC,KAAK,CAAC,MAAM,SAAS,wBAAwB,EACxE,MAAM,EAAE,uBAAuB,CAAC,MAAM,CAAC,GACtC,eAAe,CAAC;AACnB,wBAAgB,YAAY,CAAC,KAAK,CAAC,MAAM,SAAS,uBAAuB,EACvE,MAAM,EAAE,sBAAsB,CAAC,MAAM,CAAC,GACrC,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC"}
|
|
@@ -176,19 +176,6 @@ const collapseControls = new WeakMap();
|
|
|
176
176
|
*/
|
|
177
177
|
const effectiveMaxima = new WeakMap();
|
|
178
178
|
|
|
179
|
-
/**
|
|
180
|
-
* The props behind a component's `resizable` slot. It takes useResizable's
|
|
181
|
-
* output directly, and still takes that output's `props`.
|
|
182
|
-
*/
|
|
183
|
-
export function resizablePropsOf(value) {
|
|
184
|
-
return 'props' in value ? value.props : value;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
/** Whether a `resizable` value is useResizable's output for one region. */
|
|
188
|
-
export function isResizableRegion(value) {
|
|
189
|
-
return typeof value === 'object' && value !== null && 'props' in value;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
179
|
/** The reported maximum for `props`, or `undefined` for a hand-built object. */
|
|
193
180
|
export function getEffectiveMaxPx(props) {
|
|
194
181
|
return effectiveMaxima.get(props);
|
|
@@ -21,7 +21,7 @@ import { type ReactNode } from 'react';
|
|
|
21
21
|
import type { BaseProps } from '../BaseProps.js';
|
|
22
22
|
import type { StyleXStyles } from '@stylexjs/stylex';
|
|
23
23
|
import { type SideNavCollapsibleConfig, type SideNavImperativeCollapseHandle } from './SideNavCollapseContext.js';
|
|
24
|
-
import {
|
|
24
|
+
import type { ResizableConfig } from '../Resizable/useResizable.js';
|
|
25
25
|
export interface SideNavProps extends BaseProps<HTMLElement> {
|
|
26
26
|
/** Ref forwarded to the root element */
|
|
27
27
|
ref?: React.Ref<HTMLElement>;
|
|
@@ -94,18 +94,12 @@ export interface SideNavProps extends BaseProps<HTMLElement> {
|
|
|
94
94
|
* - `defaultIsCollapsed` / `isCollapsed` / `onCollapseChange` — collapse
|
|
95
95
|
* state, when `resizable` should own it rather than `collapsible`
|
|
96
96
|
*
|
|
97
|
-
* - `useResizable()`'s output — the caller's region owns the width and the
|
|
98
|
-
* collapse state. The rail follows its `isCollapsed`, the toggle calls
|
|
99
|
-
* its `collapse` and `expand`, and its `autoSaveId` saves the width.
|
|
100
|
-
* The region's own `collapsible` option also decides whether the rail
|
|
101
|
-
* collapses
|
|
102
|
-
*
|
|
103
97
|
* When both props carry collapse state, `resizable` wins and a dev warning
|
|
104
98
|
* names the conflicting keys.
|
|
105
99
|
*
|
|
106
100
|
* @default false
|
|
107
101
|
*/
|
|
108
|
-
resizable?: boolean | ResizableConfig
|
|
102
|
+
resizable?: boolean | ResizableConfig;
|
|
109
103
|
/**
|
|
110
104
|
* Enables collapse behavior. The sidebar can be collapsed to a narrow
|
|
111
105
|
* icon-only toolbar.
|
|
@@ -140,7 +134,7 @@ export interface SideNavProps extends BaseProps<HTMLElement> {
|
|
|
140
134
|
* </SideNav>
|
|
141
135
|
* ```
|
|
142
136
|
*/
|
|
143
|
-
export declare function SideNav({ header, topContent, children, footer, footerIcons, collapsible
|
|
137
|
+
export declare function SideNav({ header, topContent, children, footer, footerIcons, collapsible, resizable, xstyle, className, style, 'data-testid': testId, ref, handleRef, ...props }: SideNavProps): import("react").JSX.Element;
|
|
144
138
|
export declare namespace SideNav {
|
|
145
139
|
var displayName: string;
|
|
146
140
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SideNav.d.ts","sourceRoot":"","sources":["../../src/SideNav/SideNav.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAQL,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,wBAAwB,EAC7B,KAAK,+BAA+B,EACrC,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"SideNav.d.ts","sourceRoot":"","sources":["../../src/SideNav/SideNav.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAQL,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,wBAAwB,EAC7B,KAAK,+BAA+B,EACrC,MAAM,0BAA0B,CAAC;AAKlC,OAAO,KAAK,EAAC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SideNavCollapseContext.js";
|
|
|
30
30
|
import { SideNavCollapseButton } from "./SideNavCollapseButton.js";
|
|
31
31
|
import { useSideNavRenderMode } from "./SideNavRenderContext.js";
|
|
32
32
|
import { MobileNav } from "../MobileNav/MobileNav.js";
|
|
33
|
-
import {
|
|
33
|
+
import { useResizable } from "../Resizable/useResizable.js";
|
|
34
34
|
import { ResizeHandle } from "../Resizable/ResizeHandle.js";
|
|
35
35
|
import { themeProps } from "../utils/themeProps.js";
|
|
36
36
|
import { SizeProvider } from "../SizeContext/SizeContext.js";
|
|
@@ -93,33 +93,6 @@ function describeCollapseConflict(collapsible, resizable) {
|
|
|
93
93
|
return `${collapsibleKeys.map(key => `collapsible.${key}`).join(', ')} and ` + `${resizableKeys.map(key => `resizable.${key}`).join(', ')} address the ` + `same collapse state. resizable wins; the collapsible ` + `${collapsibleKeys.length === 1 ? 'value is' : 'values are'} ignored.`;
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
/**
|
|
97
|
-
* The collapse config when `resizable` is useResizable's output. The region
|
|
98
|
-
* owns the collapse state and decides whether the rail collapses. A
|
|
99
|
-
* `collapsible` prop that sets state or disagrees is ignored and named in a
|
|
100
|
-
* development warning.
|
|
101
|
-
*/
|
|
102
|
-
function resolveRegionCollapseConfig(collapsible, region) {
|
|
103
|
-
const fromCollapsible = typeof collapsible === 'object' ? collapsible : {};
|
|
104
|
-
const ignoredKeys = [fromCollapsible.defaultIsCollapsed !== undefined && 'defaultIsCollapsed', fromCollapsible.isCollapsed !== undefined && 'isCollapsed', fromCollapsible.onCollapsedChange !== undefined && 'onCollapsedChange'].filter(key => key !== false);
|
|
105
|
-
// The region's own `collapsible` option decides whether the rail collapses.
|
|
106
|
-
const isRegionCollapsible = region.props._collapsible ?? false;
|
|
107
|
-
const conflicts = [];
|
|
108
|
-
if (ignoredKeys.length > 0) {
|
|
109
|
-
conflicts.push(`\`collapsible\` sets ${ignoredKeys.map(key => `\`${key}\``).join(', ')}, ` + 'which the rail ignores: it follows the region.');
|
|
110
|
-
}
|
|
111
|
-
if (collapsible !== undefined && Boolean(collapsible) !== isRegionCollapsible) {
|
|
112
|
-
conflicts.push(isRegionCollapsible ? '`collapsible` is false, but the region is collapsible, so the rail still collapses.' : '`collapsible` turns collapse on, but the region is not collapsible, so the rail never collapses.');
|
|
113
|
-
}
|
|
114
|
-
return {
|
|
115
|
-
isCollapsible: isRegionCollapsible,
|
|
116
|
-
defaultIsCollapsed: region.isCollapsed,
|
|
117
|
-
isCollapsed: undefined,
|
|
118
|
-
onCollapsedChange: undefined,
|
|
119
|
-
conflict: conflicts.length === 0 ? null : "`resizable` is useResizable's output, which owns the collapse " + `state and decides whether the rail collapses. ${conflicts.join(' ')}`
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
|
|
123
96
|
// =============================================================================
|
|
124
97
|
// Styles
|
|
125
98
|
// =============================================================================
|
|
@@ -205,7 +178,7 @@ export function SideNav({
|
|
|
205
178
|
children,
|
|
206
179
|
footer,
|
|
207
180
|
footerIcons,
|
|
208
|
-
collapsible
|
|
181
|
+
collapsible = false,
|
|
209
182
|
resizable = false,
|
|
210
183
|
xstyle,
|
|
211
184
|
className,
|
|
@@ -216,19 +189,14 @@ export function SideNav({
|
|
|
216
189
|
...props
|
|
217
190
|
}) {
|
|
218
191
|
const t = useComponentTranslator();
|
|
219
|
-
// Only a left-out `collapsible` becomes false, as before; `??` would also
|
|
220
|
-
// turn null into false.
|
|
221
|
-
const collapsible = collapsibleProp === undefined ? false : collapsibleProp;
|
|
222
192
|
// Parse collapsible prop
|
|
223
193
|
const collapsibleConfig = typeof collapsible === 'object' ? collapsible : {};
|
|
224
194
|
const hasCollapseButton = collapsibleConfig.hasButton ?? true;
|
|
225
195
|
|
|
226
|
-
// useResizable's output: the caller's region owns the width and collapse.
|
|
227
|
-
const ownerRegion = isResizableRegion(resizable) ? resizable : null;
|
|
228
196
|
// Resizable config
|
|
229
|
-
const resizableConfig = typeof resizable === 'object'
|
|
197
|
+
const resizableConfig = typeof resizable === 'object' ? resizable : {};
|
|
230
198
|
const isResizable = !!resizable;
|
|
231
|
-
const collapseConfig =
|
|
199
|
+
const collapseConfig = resolveCollapseConfig(collapsible, resizable);
|
|
232
200
|
const {
|
|
233
201
|
isCollapsible,
|
|
234
202
|
onCollapsedChange
|
|
@@ -268,8 +236,6 @@ export function SideNav({
|
|
|
268
236
|
|
|
269
237
|
// useResizable is the sole collapse owner in every SideNav mode. Keeping that
|
|
270
238
|
// owner mounted when resize is toggled preserves the current collapse state.
|
|
271
|
-
// Given the hook's output, the caller's region is the owner, and this one
|
|
272
|
-
// stays idle.
|
|
273
239
|
const resizableHook = useResizable({
|
|
274
240
|
defaultSize: resizableConfig.defaultWidth ?? 260,
|
|
275
241
|
minSize: resizableConfig.minWidth ?? 180,
|
|
@@ -282,10 +248,7 @@ export function SideNav({
|
|
|
282
248
|
onSizeChange: resizableConfig.onWidthChange,
|
|
283
249
|
onCollapseChange: onCollapsedChange
|
|
284
250
|
});
|
|
285
|
-
|
|
286
|
-
// The region that sizes the rail: the caller's, or SideNav's own.
|
|
287
|
-
const region = ownerRegion ?? resizableHook;
|
|
288
|
-
const collapsed = region.isCollapsed;
|
|
251
|
+
const collapsed = resizableHook.isCollapsed;
|
|
289
252
|
|
|
290
253
|
// A collapse or expand plays the rail's motion, except an app's change
|
|
291
254
|
// before the rail's first paint. It is measured in the commit before the
|
|
@@ -441,11 +404,11 @@ export function SideNav({
|
|
|
441
404
|
isCollapsed: next
|
|
442
405
|
};
|
|
443
406
|
if (next) {
|
|
444
|
-
|
|
407
|
+
resizableHook.collapse();
|
|
445
408
|
} else {
|
|
446
|
-
|
|
409
|
+
resizableHook.expand();
|
|
447
410
|
}
|
|
448
|
-
}, [collapsed,
|
|
411
|
+
}, [collapsed, resizableHook]);
|
|
449
412
|
const showResizeHandle = isResizable && !collapsed;
|
|
450
413
|
collapseStateRef.current = {
|
|
451
414
|
isCollapsed: collapsed,
|
|
@@ -552,7 +515,7 @@ export function SideNav({
|
|
|
552
515
|
// When resizable, override the nav width via inline style
|
|
553
516
|
const resizableNavStyle = isResizable ? {
|
|
554
517
|
...(style ?? {}),
|
|
555
|
-
width: collapsed ? undefined :
|
|
518
|
+
width: collapsed ? undefined : resizableHook.size
|
|
556
519
|
} : style;
|
|
557
520
|
const navElement = /*#__PURE__*/_jsxs("nav", {
|
|
558
521
|
ref: mergedNavRef,
|
|
@@ -650,7 +613,7 @@ export function SideNav({
|
|
|
650
613
|
pillPlacement: "end",
|
|
651
614
|
isAlwaysVisible: false,
|
|
652
615
|
xstyle: styles.resizableHandle,
|
|
653
|
-
resizable:
|
|
616
|
+
resizable: resizableHook.props,
|
|
654
617
|
label: t('@astryx.sideNav.resizeSidebar'),
|
|
655
618
|
"aria-controls": navId
|
|
656
619
|
})]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astryxdesign/core",
|
|
3
|
-
"version": "0.7.9-canary.
|
|
3
|
+
"version": "0.7.9-canary.2947be8",
|
|
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",
|
|
@@ -880,9 +880,9 @@
|
|
|
880
880
|
"react-dom": ">=19.0.0"
|
|
881
881
|
},
|
|
882
882
|
"devDependencies": {
|
|
883
|
-
"@astryxdesign/a11y-spec": "0.7.9-canary.
|
|
884
|
-
"@astryxdesign/cli": "0.7.9-canary.
|
|
885
|
-
"@astryxdesign/interaction-harness": "0.7.9-canary.
|
|
883
|
+
"@astryxdesign/a11y-spec": "0.7.9-canary.2947be8",
|
|
884
|
+
"@astryxdesign/cli": "0.7.9-canary.2947be8",
|
|
885
|
+
"@astryxdesign/interaction-harness": "0.7.9-canary.2947be8",
|
|
886
886
|
"@babel/cli": "^7.29.7",
|
|
887
887
|
"@babel/core": "^7.29.7",
|
|
888
888
|
"@babel/preset-react": "^7.29.7",
|
|
@@ -65,13 +65,13 @@ export const docs = {
|
|
|
65
65
|
name: 'width',
|
|
66
66
|
type: 'number | string',
|
|
67
67
|
description:
|
|
68
|
-
|
|
68
|
+
'Width of the panel. Numbers are treated as pixels, strings are used as-is. Ignored when resizable is provided; the hook controls width.',
|
|
69
69
|
},
|
|
70
70
|
{
|
|
71
71
|
name: 'resizable',
|
|
72
|
-
type: '
|
|
72
|
+
type: 'ResizableProps',
|
|
73
73
|
description:
|
|
74
|
-
"
|
|
74
|
+
"Resize props from useResizable(). When provided, the hook drives the panel width and a ResizeHandle should be placed adjacent to the panel. Carries the region's axis ('horizontal' | 'vertical'), which must match the adjacent ResizeHandle's direction.",
|
|
75
75
|
},
|
|
76
76
|
],
|
|
77
77
|
};
|
|
@@ -119,13 +119,13 @@ export const docsZh = {
|
|
|
119
119
|
name: 'width',
|
|
120
120
|
type: 'number | string',
|
|
121
121
|
description:
|
|
122
|
-
'面板宽度。数字按像素处理,字符串按原样使用。提供 resizable 时忽略,宽度由 hook
|
|
122
|
+
'面板宽度。数字按像素处理,字符串按原样使用。提供 resizable 时忽略,宽度由 hook 控制。',
|
|
123
123
|
},
|
|
124
124
|
{
|
|
125
125
|
name: 'resizable',
|
|
126
|
-
type: '
|
|
126
|
+
type: 'ResizableProps',
|
|
127
127
|
description:
|
|
128
|
-
"useResizable()
|
|
128
|
+
"来自 useResizable() 的调整大小属性。提供时面板宽度由 hook 驱动,应在面板旁放置 ResizeHandle。其中携带区域的轴向('horizontal' | 'vertical'),必须与相邻 ResizeHandle 的 direction 一致。",
|
|
129
129
|
},
|
|
130
130
|
],
|
|
131
131
|
};
|
|
@@ -145,8 +145,8 @@ export const docsDense = {
|
|
|
145
145
|
'Accessible label for landmark element; also names the region while it scrolls (default "Content").',
|
|
146
146
|
role: 'ARIA landmark role.',
|
|
147
147
|
width:
|
|
148
|
-
'Panel width. Numbers = pixels, strings as-is. Ignored when resizable provided; hook controls width.
|
|
148
|
+
'Panel width. Numbers = pixels, strings as-is. Ignored when resizable provided; hook controls width.',
|
|
149
149
|
resizable:
|
|
150
|
-
'useResizable()
|
|
150
|
+
'Resize props from useResizable(). Hook drives panel width; place ResizeHandle adjacent.',
|
|
151
151
|
},
|
|
152
152
|
};
|