@atlaskit/navigation-system 11.3.4 → 11.4.1
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 +25 -0
- package/README.md +20 -0
- package/constellation/layout/code.mdx +1 -1
- package/constellation/layout/examples.mdx +4 -16
- package/constellation/layout/images/layout-anatomy-dark.png +0 -0
- package/constellation/layout/images/layout-anatomy-light.png +0 -0
- package/constellation/layout/images/layout-do-dark.png +0 -0
- package/constellation/layout/images/layout-do-light.png +0 -0
- package/constellation/layout/images/layout-dont-dark.png +0 -0
- package/constellation/layout/images/layout-dont-light.png +0 -0
- package/constellation/layout/images/layout-example-dark.png +0 -0
- package/constellation/layout/images/layout-example-light.png +0 -0
- package/constellation/layout/images/layout-example-sideNav-dark.png +0 -0
- package/constellation/layout/images/layout-example-sideNav-light.png +0 -0
- package/constellation/layout/images/layout-example-topNav-1-dark.png +0 -0
- package/constellation/layout/images/layout-example-topNav-1-light.png +0 -0
- package/constellation/layout/usage.mdx +1 -2
- package/constellation/top-nav-items/examples.mdx +7 -13
- package/dist/cjs/entry-points/layout/panel-layout.js +19 -0
- package/dist/cjs/ui/page-layout/calculate-layout-area-states.js +4 -4
- package/dist/cjs/ui/page-layout/chat-panel.js +1 -1
- package/dist/cjs/ui/page-layout/constants.js +15 -1
- package/dist/cjs/ui/page-layout/get-panel-layout-defaults.js +22 -0
- package/dist/cjs/ui/page-layout/layout-area-sizing-provider.js +52 -28
- package/dist/cjs/ui/page-layout/layout-area-sizing-runtime.js +5 -4
- package/dist/cjs/ui/page-layout/local-panel-surface.compiled.css +26 -0
- package/dist/cjs/ui/page-layout/local-panel-surface.js +206 -0
- package/dist/cjs/ui/page-layout/main/main.js +5 -2
- package/dist/cjs/ui/page-layout/main-min-width-context.js +10 -0
- package/dist/cjs/ui/page-layout/panel-layout-shell.compiled.css +27 -0
- package/dist/cjs/ui/page-layout/panel-layout-shell.js +67 -0
- package/dist/cjs/ui/page-layout/panel-layout.js +162 -0
- package/dist/cjs/ui/page-layout/panel-splitter/panel-splitter.js +15 -6
- package/dist/cjs/ui/page-layout/side-nav/side-nav.js +1 -1
- package/dist/cjs/ui/top-nav-items/icon-renderer.js +1 -1
- package/dist/es2019/entry-points/layout/panel-layout.js +2 -0
- package/dist/es2019/ui/page-layout/calculate-layout-area-states.js +4 -4
- package/dist/es2019/ui/page-layout/chat-panel.js +2 -2
- package/dist/es2019/ui/page-layout/constants.js +14 -0
- package/dist/es2019/ui/page-layout/get-panel-layout-defaults.js +16 -0
- package/dist/es2019/ui/page-layout/layout-area-sizing-provider.js +19 -4
- package/dist/es2019/ui/page-layout/layout-area-sizing-runtime.js +4 -3
- package/dist/es2019/ui/page-layout/local-panel-surface.compiled.css +26 -0
- package/dist/es2019/ui/page-layout/local-panel-surface.js +193 -0
- package/dist/es2019/ui/page-layout/main/main.js +6 -3
- package/dist/es2019/ui/page-layout/main-min-width-context.js +5 -0
- package/dist/es2019/ui/page-layout/panel-layout-shell.compiled.css +27 -0
- package/dist/es2019/ui/page-layout/panel-layout-shell.js +74 -0
- package/dist/es2019/ui/page-layout/panel-layout.js +147 -0
- package/dist/es2019/ui/page-layout/panel-splitter/panel-splitter.js +15 -6
- package/dist/es2019/ui/page-layout/side-nav/side-nav.js +2 -2
- package/dist/es2019/ui/top-nav-items/icon-renderer.js +1 -1
- package/dist/esm/entry-points/layout/panel-layout.js +2 -0
- package/dist/esm/ui/page-layout/calculate-layout-area-states.js +4 -4
- package/dist/esm/ui/page-layout/chat-panel.js +2 -2
- package/dist/esm/ui/page-layout/constants.js +14 -0
- package/dist/esm/ui/page-layout/get-panel-layout-defaults.js +16 -0
- package/dist/esm/ui/page-layout/layout-area-sizing-provider.js +52 -28
- package/dist/esm/ui/page-layout/layout-area-sizing-runtime.js +4 -3
- package/dist/esm/ui/page-layout/local-panel-surface.compiled.css +26 -0
- package/dist/esm/ui/page-layout/local-panel-surface.js +197 -0
- package/dist/esm/ui/page-layout/main/main.js +6 -3
- package/dist/esm/ui/page-layout/main-min-width-context.js +5 -0
- package/dist/esm/ui/page-layout/panel-layout-shell.compiled.css +27 -0
- package/dist/esm/ui/page-layout/panel-layout-shell.js +59 -0
- package/dist/esm/ui/page-layout/panel-layout.js +154 -0
- package/dist/esm/ui/page-layout/panel-splitter/panel-splitter.js +15 -6
- package/dist/esm/ui/page-layout/side-nav/side-nav.js +2 -2
- package/dist/esm/ui/top-nav-items/icon-renderer.js +1 -1
- package/dist/types/entry-points/layout/panel-layout.d.ts +3 -0
- package/dist/types/ui/page-layout/constants.d.ts +12 -0
- package/dist/types/ui/page-layout/get-panel-layout-defaults.d.ts +10 -0
- package/dist/types/ui/page-layout/layout-area-sizing-context.d.ts +9 -1
- package/dist/types/ui/page-layout/local-panel-surface.d.ts +32 -0
- package/dist/types/ui/page-layout/main-min-width-context.d.ts +2 -0
- package/dist/types/ui/page-layout/panel-layout-shell.d.ts +47 -0
- package/dist/types/ui/page-layout/panel-layout.d.ts +74 -0
- package/layout/panel-layout/package.json +10 -0
- package/package.json +7 -7
- package/constellation/layout/images/layout-example-topNav-2-dark.png +0 -3
- package/constellation/layout/images/layout-example-topNav-2-light.png +0 -3
|
@@ -21,6 +21,7 @@ import TooltipContainer from '@atlaskit/tooltip/TooltipContainer';
|
|
|
21
21
|
import { requestClosePopovers } from '@atlaskit/top-layer/page-surface/request-close-popovers';
|
|
22
22
|
import VisuallyHidden from '@atlaskit/visually-hidden/visually-hidden';
|
|
23
23
|
import { contentInsetBlockStart } from '../constants';
|
|
24
|
+
import { LayoutAreaSizingContext } from '../layout-area-sizing-context';
|
|
24
25
|
import { convertResizeBoundToPixels } from './convert-resize-bound-to-pixels';
|
|
25
26
|
import { getPercentageWithinPixelBounds } from './get-percentage-within-pixel-bounds';
|
|
26
27
|
import { getPixelWidth } from './get-pixel-width';
|
|
@@ -145,7 +146,16 @@ const PortaledPanelSplitter = ({
|
|
|
145
146
|
tooltipContent,
|
|
146
147
|
shortcut
|
|
147
148
|
}) => {
|
|
149
|
+
var _useContext;
|
|
148
150
|
const splitterRef = useRef(null);
|
|
151
|
+
const registerSplitter = (_useContext = useContext(LayoutAreaSizingContext)) === null || _useContext === void 0 ? void 0 : _useContext.registerSplitter;
|
|
152
|
+
const unregisterSplitter = useRef(undefined);
|
|
153
|
+
const setSplitterRef = useCallback(element => {
|
|
154
|
+
var _unregisterSplitter$c;
|
|
155
|
+
(_unregisterSplitter$c = unregisterSplitter.current) === null || _unregisterSplitter$c === void 0 ? void 0 : _unregisterSplitter$c.call(unregisterSplitter);
|
|
156
|
+
splitterRef.current = element;
|
|
157
|
+
unregisterSplitter.current = element && prepareResize ? registerSplitter === null || registerSplitter === void 0 ? void 0 : registerSplitter(element) : undefined;
|
|
158
|
+
}, [prepareResize, registerSplitter]);
|
|
149
159
|
const labelId = useId();
|
|
150
160
|
// Separate state used for the input range width to remove the UI's dependency on the "persisted" layout state value being updated
|
|
151
161
|
const [rangeInputValue, setRangeInputValue] = useState(panelWidth);
|
|
@@ -176,7 +186,7 @@ const PortaledPanelSplitter = ({
|
|
|
176
186
|
const initialClientXRef = useRef(null);
|
|
177
187
|
// Live allocation changes panelWidth on every frame. Only the legacy path should
|
|
178
188
|
// rebind the drag listeners when this value changes.
|
|
179
|
-
const legacyPanelWidth = fg('platform-dst-chat-panel-layout') ? undefined : panelWidth;
|
|
189
|
+
const legacyPanelWidth = fg('platform-dst-chat-panel-layout') || onResizeInternal ? undefined : panelWidth;
|
|
180
190
|
useEffect(() => {
|
|
181
191
|
const splitter = splitterRef.current;
|
|
182
192
|
invariant(splitter, 'Splitter ref must be set');
|
|
@@ -287,7 +297,7 @@ const PortaledPanelSplitter = ({
|
|
|
287
297
|
position
|
|
288
298
|
});
|
|
289
299
|
const resizingWidth = `clamp(${resizeBounds.min}, ${targetWidth}px, ${resizeBounds.max})`;
|
|
290
|
-
if (
|
|
300
|
+
if (onResizeInternal) {
|
|
291
301
|
// The allocator needs below-minimum requests for the local-to-chat cascade.
|
|
292
302
|
const currentBounds = getResizeBounds();
|
|
293
303
|
const width = Math.max(0, Math.min(targetWidth, prepareResize ? window.innerWidth : convertResizeBoundToPixels(currentBounds.max)));
|
|
@@ -324,7 +334,7 @@ const PortaledPanelSplitter = ({
|
|
|
324
334
|
const finalWidth = getPixelWidth(panel);
|
|
325
335
|
// Persist the final preferred width before removing the imperative drag
|
|
326
336
|
// variable, so the rendered width is continuous across pointer release.
|
|
327
|
-
if (fg('platform-dst-chat-panel-layout')) {
|
|
337
|
+
if (fg('platform-dst-chat-panel-layout') || onResizeInternal) {
|
|
328
338
|
flushSync(() => onCompleteResize(finalWidth));
|
|
329
339
|
} else {
|
|
330
340
|
onCompleteResize(finalWidth);
|
|
@@ -358,7 +368,7 @@ const PortaledPanelSplitter = ({
|
|
|
358
368
|
const keyboardBoundsReady = useRef(false);
|
|
359
369
|
const pendingKeyboardWidth = useRef(null);
|
|
360
370
|
const handleSliderInputChange = useCallback(async (event, pendingKey) => {
|
|
361
|
-
const isManagedResize =
|
|
371
|
+
const isManagedResize = onResizeInternal;
|
|
362
372
|
const sequence = focusSequence.current;
|
|
363
373
|
let value = isManagedResize ? parseFloat(event.currentTarget.value) : parseInt(event.currentTarget.value);
|
|
364
374
|
if (prepareResize) {
|
|
@@ -483,9 +493,8 @@ const PortaledPanelSplitter = ({
|
|
|
483
493
|
shortcut: shortcut,
|
|
484
494
|
testId: testId ? `${testId}-tooltip` : undefined
|
|
485
495
|
}, /*#__PURE__*/React.createElement("div", {
|
|
486
|
-
ref:
|
|
496
|
+
ref: setSplitterRef,
|
|
487
497
|
"data-testid": testId,
|
|
488
|
-
"data-panel-splitter": prepareResize ? '' : undefined,
|
|
489
498
|
onDoubleClick: onDoubleClick,
|
|
490
499
|
className: ax([grabAreaStyles.root, fg('platform-dst-tokens-finesse') && grabAreaStyles.rootFinesse])
|
|
491
500
|
}, /*#__PURE__*/React.createElement(VisuallyHidden, null, /*#__PURE__*/React.createElement("input", {
|
|
@@ -17,7 +17,7 @@ import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/adapter/el
|
|
|
17
17
|
import { hasOpenDialogOrPopover } from '@atlaskit/top-layer/page-surface/has-open-dialog-or-popover';
|
|
18
18
|
import { useSkipLinkInternal } from '../../../context/skip-links/use-skip-link-internal';
|
|
19
19
|
import { TopNavStartElement } from '../../../context/top-nav-start/top-nav-start-element';
|
|
20
|
-
import { UNSAFE_sideNavLayoutVar, mainMinimumWidthVar, openLayerObserverSideNavNamespace, sideNavLiveWidthVar, sideNavPanelSplitterId, sideNavVar } from '../constants';
|
|
20
|
+
import { UNSAFE_sideNavLayoutVar, defaultMainMinWidth, mainMinimumWidthVar, openLayerObserverSideNavNamespace, sideNavLiveWidthVar, sideNavPanelSplitterId, sideNavVar } from '../constants';
|
|
21
21
|
import { DangerouslyHoistCssVarToDocumentRoot } from '../dangerously-hoist-css-var-to-document-root';
|
|
22
22
|
import { DangerouslyHoistSlotSizes } from '../hoist-slot-sizes-context';
|
|
23
23
|
import { convertResizeBoundToPixels } from '../panel-splitter/convert-resize-bound-to-pixels';
|
|
@@ -338,7 +338,7 @@ function SideNavInternal({
|
|
|
338
338
|
const isLocalPanelInline = localPanel && getComputedStyle(localPanel).gridArea === 'panel';
|
|
339
339
|
const localPanelWidth = isLocalPanelInline ? localPanel.getBoundingClientRect().width : 0;
|
|
340
340
|
const mainContentWidth = mainWidth - localPanelWidth;
|
|
341
|
-
const mainMinimumWidth = getPixelCustomProperty(main, mainMinimumWidthVar,
|
|
341
|
+
const mainMinimumWidth = getPixelCustomProperty(main, mainMinimumWidthVar, defaultMainMinWidth);
|
|
342
342
|
const availableWidth = Math.max(0, mainContentWidth - mainMinimumWidth);
|
|
343
343
|
const availableInlineWidth = Math.floor(sideNavWidth + availableWidth);
|
|
344
344
|
const constrainedMaxWidth = maxWidth ? Math.min(convertResizeBoundToPixels(maxWidth), availableInlineWidth) : availableInlineWidth;
|
|
@@ -33,7 +33,7 @@ const IconRenderer = ({
|
|
|
33
33
|
size: fg('platform_dst_button_chevron_sizing') ? iconName => iconName.startsWith('Chevron') ? 'small' : 'medium' : undefined
|
|
34
34
|
};
|
|
35
35
|
|
|
36
|
-
// @ts-
|
|
36
|
+
// @ts-expect-error -- The render-prop guard returns IconProp (a component type), which is not a ReactNode.
|
|
37
37
|
return /*#__PURE__*/React.createElement(React.Fragment, null, isRenderProp ? Icon(iconProps) : /*#__PURE__*/React.createElement(Icon, iconProps));
|
|
38
38
|
};
|
|
39
39
|
export default IconRenderer;
|
|
@@ -12,12 +12,12 @@ function clampTargetWidth(_ref) {
|
|
|
12
12
|
function getTargetWidth(area, isSideNavOverlay) {
|
|
13
13
|
var _area$compactDefaultW, _area$liveResize, _ref2, _area$requestedWidth;
|
|
14
14
|
var defaultWidth = isSideNavOverlay ? (_area$compactDefaultW = area.compactDefaultWidth) !== null && _area$compactDefaultW !== void 0 ? _area$compactDefaultW : area.defaultWidth : area.defaultWidth;
|
|
15
|
-
return ((_area$liveResize = area.liveResize) === null || _area$liveResize === void 0 ? void 0 : _area$liveResize.mode) === 'inline' ? area.liveResize.width : (_ref2 = (_area$requestedWidth = area.requestedWidth) !== null && _area$requestedWidth !== void 0 ? _area$requestedWidth : area.
|
|
15
|
+
return ((_area$liveResize = area.liveResize) === null || _area$liveResize === void 0 ? void 0 : _area$liveResize.mode) === 'inline' ? area.liveResize.width : (_ref2 = (_area$requestedWidth = area.requestedWidth) !== null && _area$requestedWidth !== void 0 ? _area$requestedWidth : area.preferredWidth) !== null && _ref2 !== void 0 ? _ref2 : defaultWidth;
|
|
16
16
|
}
|
|
17
|
-
function getOverlayTargetWidth(area, isSideNavOverlay) {
|
|
17
|
+
function getOverlayTargetWidth(area, isSideNavOverlay, areaName) {
|
|
18
18
|
var _area$compactDefaultW2, _area$liveResize2, _ref3, _area$requestedWidth2;
|
|
19
19
|
var defaultWidth = isSideNavOverlay ? (_area$compactDefaultW2 = area.compactDefaultWidth) !== null && _area$compactDefaultW2 !== void 0 ? _area$compactDefaultW2 : area.defaultWidth : area.defaultWidth;
|
|
20
|
-
return ((_area$liveResize2 = area.liveResize) === null || _area$liveResize2 === void 0 ? void 0 : _area$liveResize2.mode) === 'overlay' ? area.liveResize.width : (_ref3 = (_area$requestedWidth2 = area.requestedWidth) !== null && _area$requestedWidth2 !== void 0 ? _area$requestedWidth2 : area.preferredOverlayWidth) !== null && _ref3 !== void 0 ? _ref3 : defaultWidth;
|
|
20
|
+
return ((_area$liveResize2 = area.liveResize) === null || _area$liveResize2 === void 0 ? void 0 : _area$liveResize2.mode) === 'overlay' ? area.liveResize.width : (_ref3 = (_area$requestedWidth2 = area.requestedWidth) !== null && _area$requestedWidth2 !== void 0 ? _area$requestedWidth2 : areaName === 'panel' ? area.preferredWidth : area.preferredOverlayWidth) !== null && _ref3 !== void 0 ? _ref3 : defaultWidth;
|
|
21
21
|
}
|
|
22
22
|
export function calculateLayoutAreaStates(_ref4) {
|
|
23
23
|
var _ref5, _resizeSession$overla, _baselineWidths$chat, _panel$liveResize, _states$sideNav$widt, _states$sideNav, _states$chatPanel$wi, _states$chatPanel;
|
|
@@ -186,7 +186,7 @@ export function calculateLayoutAreaStates(_ref4) {
|
|
|
186
186
|
var layoutMax = (_areaName2 === 'chat-panel' ? layoutWidth : mainAreaWidth) * 0.9;
|
|
187
187
|
var _max = Math.max(0, Math.min(configuredMax, layoutMax));
|
|
188
188
|
var effectiveMin = Math.min(_min2, _max);
|
|
189
|
-
var _target = getOverlayTargetWidth(_area, isSideNavOverlay);
|
|
189
|
+
var _target = getOverlayTargetWidth(_area, isSideNavOverlay, _areaName2);
|
|
190
190
|
var _width = clampTargetWidth({
|
|
191
191
|
target: _target,
|
|
192
192
|
min: effectiveMin,
|
|
@@ -8,7 +8,7 @@ import { useCallback, useEffect, useRef, useState } from 'react';
|
|
|
8
8
|
import { bind } from 'bind-event-listener';
|
|
9
9
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
10
10
|
import { useSkipLinkInternal } from '../../context/skip-links/use-skip-link-internal';
|
|
11
|
-
import { chatPanelLiveWidthVar, chatPanelVar, localSlotLayers, mainMinimumWidthVar } from './constants';
|
|
11
|
+
import { chatPanelLiveWidthVar, chatPanelVar, defaultMainMinWidth, localSlotLayers, mainMinimumWidthVar } from './constants';
|
|
12
12
|
import { convertResizeBoundToPixels } from './panel-splitter/convert-resize-bound-to-pixels';
|
|
13
13
|
import { PanelSplitterProvider } from './panel-splitter/provider';
|
|
14
14
|
import { resolveLayoutWidth } from './resolve-layout-width';
|
|
@@ -152,7 +152,7 @@ export function ChatPanel(_ref) {
|
|
|
152
152
|
var localPanel = main.querySelector('[data-layout-with-panel-slot]');
|
|
153
153
|
var isLocalPanelInline = localPanel && getComputedStyle(localPanel).gridArea === 'panel';
|
|
154
154
|
var localPanelWidth = isLocalPanelInline ? localPanel.getBoundingClientRect().width : 0;
|
|
155
|
-
var mainMinimumWidth = getPixelCustomProperty(main, mainMinimumWidthVar,
|
|
155
|
+
var mainMinimumWidth = getPixelCustomProperty(main, mainMinimumWidthVar, defaultMainMinWidth);
|
|
156
156
|
var mainContentWidth = mainWidth - localPanelWidth;
|
|
157
157
|
var availableWidth = Math.max(0, mainContentWidth - mainMinimumWidth);
|
|
158
158
|
var availableInlineWidth = Math.floor(chatPanelWidth + availableWidth);
|
|
@@ -4,6 +4,11 @@
|
|
|
4
4
|
* We have chosen to ignore this rule to prevent duplicating them across the different slots, and to provide a high level view of them and how they relate.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Default minimum width of Main, in pixels, before a custom minimum is registered.
|
|
9
|
+
*/
|
|
10
|
+
export var defaultMainMinWidth = 320;
|
|
11
|
+
|
|
7
12
|
// These are "compressed" to discourage usage.
|
|
8
13
|
export var sideNavVar = '--n_sNvw';
|
|
9
14
|
export var asideVar = '--n_asDw';
|
|
@@ -15,6 +20,15 @@ export var bannerMountedVar = '--n_bnrM';
|
|
|
15
20
|
export var topNavMountedVar = '--n_tNvM';
|
|
16
21
|
export var ribbonVar = '--n_rbnW';
|
|
17
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Rendered border-box width of the local PanelLayout surface, in both inline and overlay modes.
|
|
25
|
+
* Published on document.documentElement after mounting when Root opts into
|
|
26
|
+
* UNSAFE_dangerouslyHoistSlotSizes. Only the primary Root should opt in.
|
|
27
|
+
* Use `var(${localPanelWidthVar}, 0px)` for external controls, not for width persistence
|
|
28
|
+
* or sizing the panel itself. The property is removed when the surface unmounts.
|
|
29
|
+
*/
|
|
30
|
+
export var localPanelWidthVar = '--n_localPanelWidth';
|
|
31
|
+
|
|
18
32
|
/**
|
|
19
33
|
* Captures the current width of the side navigation, at all times, including during resizing.
|
|
20
34
|
*
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
2
|
+
var DEFAULT_PANEL_WIDTH = 365;
|
|
3
|
+
var DEFAULT_PANEL_WIDTH_WITH_CHAT_PANEL_LAYOUT = 400;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Local-panel defaults in pixels, used only when no explicit preference exists.
|
|
7
|
+
* Keep the existing desktop width until chat layout rolls out. Compact sizing is independent.
|
|
8
|
+
* These are requested defaults, not measurements of an open panel.
|
|
9
|
+
*/
|
|
10
|
+
export function getPanelLayoutDefaults() {
|
|
11
|
+
return {
|
|
12
|
+
panelWidth: fg('platform-dst-chat-panel-layout') ? DEFAULT_PANEL_WIDTH_WITH_CHAT_PANEL_LAYOUT : DEFAULT_PANEL_WIDTH,
|
|
13
|
+
compactPanelWidth: 320,
|
|
14
|
+
panelMinWidth: 320
|
|
15
|
+
};
|
|
16
|
+
}
|
|
@@ -4,6 +4,7 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
|
|
|
4
4
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
5
5
|
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
6
6
|
import { bind, bindAll } from 'bind-event-listener';
|
|
7
|
+
import { defaultMainMinWidth } from './constants';
|
|
7
8
|
import { LayoutAreaSizingContext } from './layout-area-sizing-context';
|
|
8
9
|
import { layoutAreaStateContexts } from './layout-area-state-contexts';
|
|
9
10
|
import { useCssLayoutAreaStates } from './use-css-layout-area-states';
|
|
@@ -65,7 +66,14 @@ export function LayoutAreaSizingProvider(_ref) {
|
|
|
65
66
|
listener: dismissOlderOverlay
|
|
66
67
|
});
|
|
67
68
|
}, [chatPanelMode, lastOpenedOverlay, sideNavMode]);
|
|
68
|
-
var
|
|
69
|
+
var splitters = useRef(new Set());
|
|
70
|
+
var registerSplitter = useCallback(function (element) {
|
|
71
|
+
splitters.current.add(element);
|
|
72
|
+
return function () {
|
|
73
|
+
splitters.current.delete(element);
|
|
74
|
+
};
|
|
75
|
+
}, []);
|
|
76
|
+
var mainMinWidth = useRef(defaultMainMinWidth);
|
|
69
77
|
var loadRef = useRef(function () {});
|
|
70
78
|
var ready = useRef(false);
|
|
71
79
|
var waiting = useRef([]);
|
|
@@ -118,8 +126,23 @@ export function LayoutAreaSizingProvider(_ref) {
|
|
|
118
126
|
};
|
|
119
127
|
loadRef.current = load;
|
|
120
128
|
var loadForSplitter = function loadForSplitter(event) {
|
|
121
|
-
if (event.target instanceof
|
|
122
|
-
|
|
129
|
+
if (!(event.target instanceof Node)) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
var _iterator2 = _createForOfIteratorHelper(splitters.current),
|
|
133
|
+
_step2;
|
|
134
|
+
try {
|
|
135
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
136
|
+
var splitter = _step2.value;
|
|
137
|
+
if (splitter.contains(event.target)) {
|
|
138
|
+
load();
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
} catch (err) {
|
|
143
|
+
_iterator2.e(err);
|
|
144
|
+
} finally {
|
|
145
|
+
_iterator2.f();
|
|
123
146
|
}
|
|
124
147
|
};
|
|
125
148
|
var unbindRoot = bindAll(root, [{
|
|
@@ -142,17 +165,17 @@ export function LayoutAreaSizingProvider(_ref) {
|
|
|
142
165
|
cancelled = true;
|
|
143
166
|
ready.current = false;
|
|
144
167
|
pending.current = [];
|
|
145
|
-
var
|
|
146
|
-
|
|
168
|
+
var _iterator3 = _createForOfIteratorHelper(waitingForRuntime.splice(0)),
|
|
169
|
+
_step3;
|
|
147
170
|
try {
|
|
148
|
-
for (
|
|
149
|
-
var resolve =
|
|
171
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
172
|
+
var resolve = _step3.value;
|
|
150
173
|
resolve(false);
|
|
151
174
|
}
|
|
152
175
|
} catch (err) {
|
|
153
|
-
|
|
176
|
+
_iterator3.e(err);
|
|
154
177
|
} finally {
|
|
155
|
-
|
|
178
|
+
_iterator3.f();
|
|
156
179
|
}
|
|
157
180
|
loadRef.current = function () {};
|
|
158
181
|
unbindRoot();
|
|
@@ -162,20 +185,20 @@ export function LayoutAreaSizingProvider(_ref) {
|
|
|
162
185
|
actions.current = runtime;
|
|
163
186
|
if (runtime) {
|
|
164
187
|
runtime.setMainMinWidth(mainMinWidth.current);
|
|
165
|
-
var
|
|
166
|
-
|
|
188
|
+
var _iterator4 = _createForOfIteratorHelper(['side-nav', 'panel', 'chat-panel']),
|
|
189
|
+
_step4;
|
|
167
190
|
try {
|
|
168
|
-
for (
|
|
169
|
-
var area =
|
|
191
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
192
|
+
var area = _step4.value;
|
|
170
193
|
var config = configs.current[area];
|
|
171
194
|
if (config) {
|
|
172
195
|
runtime.registerArea(area, config);
|
|
173
196
|
}
|
|
174
197
|
}
|
|
175
198
|
} catch (err) {
|
|
176
|
-
|
|
199
|
+
_iterator4.e(err);
|
|
177
200
|
} finally {
|
|
178
|
-
|
|
201
|
+
_iterator4.f();
|
|
179
202
|
}
|
|
180
203
|
}
|
|
181
204
|
}, []);
|
|
@@ -184,29 +207,29 @@ export function LayoutAreaSizingProvider(_ref) {
|
|
|
184
207
|
var runtime = actions.current;
|
|
185
208
|
if (runtime && Object.values(next).some(Boolean)) {
|
|
186
209
|
ready.current = true;
|
|
187
|
-
var
|
|
188
|
-
|
|
210
|
+
var _iterator5 = _createForOfIteratorHelper(pending.current.splice(0)),
|
|
211
|
+
_step5;
|
|
189
212
|
try {
|
|
190
|
-
for (
|
|
191
|
-
var action =
|
|
213
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
214
|
+
var action = _step5.value;
|
|
192
215
|
action(runtime);
|
|
193
216
|
}
|
|
194
217
|
} catch (err) {
|
|
195
|
-
|
|
218
|
+
_iterator5.e(err);
|
|
196
219
|
} finally {
|
|
197
|
-
|
|
220
|
+
_iterator5.f();
|
|
198
221
|
}
|
|
199
|
-
var
|
|
200
|
-
|
|
222
|
+
var _iterator6 = _createForOfIteratorHelper(waiting.current.splice(0)),
|
|
223
|
+
_step6;
|
|
201
224
|
try {
|
|
202
|
-
for (
|
|
203
|
-
var resolve =
|
|
225
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
226
|
+
var resolve = _step6.value;
|
|
204
227
|
resolve(true);
|
|
205
228
|
}
|
|
206
229
|
} catch (err) {
|
|
207
|
-
|
|
230
|
+
_iterator6.e(err);
|
|
208
231
|
} finally {
|
|
209
|
-
|
|
232
|
+
_iterator6.f();
|
|
210
233
|
}
|
|
211
234
|
}
|
|
212
235
|
}, []);
|
|
@@ -221,6 +244,7 @@ export function LayoutAreaSizingProvider(_ref) {
|
|
|
221
244
|
var value = useMemo(function () {
|
|
222
245
|
return {
|
|
223
246
|
prepareResize: prepareResize,
|
|
247
|
+
registerSplitter: registerSplitter,
|
|
224
248
|
registerArea: function registerArea(area, config) {
|
|
225
249
|
var _configs$current$area, _actions$current;
|
|
226
250
|
if (area !== 'panel' && config.isOpen && !((_configs$current$area = configs.current[area]) !== null && _configs$current$area !== void 0 && _configs$current$area.isOpen)) {
|
|
@@ -270,7 +294,7 @@ export function LayoutAreaSizingProvider(_ref) {
|
|
|
270
294
|
});
|
|
271
295
|
}
|
|
272
296
|
};
|
|
273
|
-
}, [dispatch, prepareResize]);
|
|
297
|
+
}, [dispatch, prepareResize, registerSplitter]);
|
|
274
298
|
var SideNavStateProvider = layoutAreaStateContexts['side-nav'].Provider;
|
|
275
299
|
var PanelStateProvider = layoutAreaStateContexts.panel.Provider;
|
|
276
300
|
var ChatPanelStateProvider = layoutAreaStateContexts['chat-panel'].Provider;
|
|
@@ -8,11 +8,11 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
8
8
|
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
9
9
|
import { bind } from 'bind-event-listener';
|
|
10
10
|
import { calculateLayoutAreaStates } from './calculate-layout-area-states';
|
|
11
|
+
import { defaultMainMinWidth } from './constants';
|
|
11
12
|
import { LayoutAreaSizingContext } from './layout-area-sizing-context';
|
|
12
13
|
import { layoutAreaStateContexts } from './layout-area-state-contexts';
|
|
13
14
|
import { resolveLayoutWidth } from './resolve-layout-width';
|
|
14
15
|
import { useOccupiedLayoutWidth } from './use-occupied-layout-width';
|
|
15
|
-
var defaultMainMinWidth = 320;
|
|
16
16
|
function useStableAreaState(state) {
|
|
17
17
|
var _ref = state !== null && state !== void 0 ? state : {},
|
|
18
18
|
mode = _ref.mode,
|
|
@@ -304,7 +304,7 @@ export function LayoutAreaSizingRuntime(_ref2) {
|
|
|
304
304
|
if (!existing) {
|
|
305
305
|
return current;
|
|
306
306
|
}
|
|
307
|
-
if (mode === 'overlay') {
|
|
307
|
+
if (mode === 'overlay' && area !== 'panel') {
|
|
308
308
|
return _objectSpread(_objectSpread({}, current), {}, _defineProperty({}, area, _objectSpread(_objectSpread({}, existing), {}, {
|
|
309
309
|
liveResize: undefined,
|
|
310
310
|
preferredOverlayWidth: width
|
|
@@ -312,7 +312,8 @@ export function LayoutAreaSizingRuntime(_ref2) {
|
|
|
312
312
|
}
|
|
313
313
|
return _objectSpread(_objectSpread({}, current), {}, _defineProperty({}, area, _objectSpread(_objectSpread({}, existing), {}, {
|
|
314
314
|
liveResize: undefined,
|
|
315
|
-
|
|
315
|
+
// Local panels have one preference, regardless of the resized mode.
|
|
316
|
+
preferredWidth: width
|
|
316
317
|
})));
|
|
317
318
|
});
|
|
318
319
|
}, [captureSiblingWidths]);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
._nd5l1c6w{grid-area:panel}
|
|
2
|
+
._nd5l1gzg{grid-area:main}
|
|
3
|
+
._nd5l32aw{grid-area:var(--p_lclPnlSsrArea,main)}
|
|
4
|
+
._y44v1mph{animation:var(--ds-panel-content-enter,.15s cubic-bezier(.4,1,.6,1) FadeIn0to100)}
|
|
5
|
+
._y44vf1qi{animation:var(--ds-panel-content-exit,50ms cubic-bezier(.6,0,.8,.6) FadeOut100to0)}
|
|
6
|
+
._191wbqna{border-inline-start:var(--p_lclPnlSsrBorder,none)}
|
|
7
|
+
._191wglyw{border-inline-start:none}
|
|
8
|
+
._191wia51{border-inline-start:var(--ds-border-width,1px) solid var(--ds-border,#0b120e24)}._10fph9n0{justify-self:end}
|
|
9
|
+
._152tidpf{inset-block-start:0}
|
|
10
|
+
._16qs130s{box-shadow:var(--ds-shadow-overlay,0 8px 9pt #1e1f2126,0 0 1px #1e1f214f)}
|
|
11
|
+
._16qs1dhr{box-shadow:var(--p_lclPnlSsrShadow,var(--ds-shadow-overlay,0 8px 9pt #1e1f2126,0 0 1px #1e1f214f))}
|
|
12
|
+
._16qsglyw{box-shadow:none}
|
|
13
|
+
._18m91wug{overflow-y:auto}
|
|
14
|
+
._1bsb13q4{width:min(90%,var(--p_lclPnlRsz,var(--p_lclPnlW)))}
|
|
15
|
+
._1bsb1c5w{width:var(--p_lclPnlRsz,var(--p_lclPnlW))}
|
|
16
|
+
._1bsb1cku{width:var(--p_lclPnlSsrWidth,min(90%,var(--p_lclPnlSsrPreferredW)))}
|
|
17
|
+
._1reo1wug{overflow-x:auto}
|
|
18
|
+
._4t3i1osq{height:100%}
|
|
19
|
+
._4t3ieqxy{height:calc(100vh - var(--n_bnrM, 0px) - var(--n_tNvM, 0px))}
|
|
20
|
+
._bfhk1bhr{background-color:var(--ds-surface-overlay,#fff)}
|
|
21
|
+
._bfhk1g1j{background-color:var(--p_lclPnlSsrBackground,var(--ds-surface-overlay,#fff))}
|
|
22
|
+
._bfhkvuon{background-color:var(--ds-surface,#fff)}
|
|
23
|
+
._ju25dn4k{animation-delay:var(--ds-duration-xshort,.1s)}
|
|
24
|
+
._kqsw1if8{position:sticky}
|
|
25
|
+
._vchhusvi{box-sizing:border-box}
|
|
26
|
+
@media (prefers-reduced-motion:no-preference){._k1af14vv{animation:var(--ds-panel-exit-right,.2s cubic-bezier(0,.4,0,1) SlideOut100PercentRight)}[dir=rtl] ._105aeydr{animation:var(--ds-panel-exit-left,.2s cubic-bezier(0,.4,0,1) SlideOut100PercentLeft)}._bq641n9t{position:fixed}@starting-style{._1kmh1n9t{position:fixed}}._k1af1nn1{animation:var(--ds-panel-enter-right,.25s cubic-bezier(0,.4,0,1) SlideIn100PercentRight)}._10t81ia4{transition-property:position}._xrrp147i{transition-duration:var(--ds-duration-instant,0ms)}._1wsa1ign{transition-delay:var(--ds-duration-short,.15s)}._1vrh1a5r{transition-behavior:allow-discrete}[dir=rtl] ._105abamb{animation:var(--ds-panel-enter-left,.25s cubic-bezier(0,.4,0,1) SlideIn100PercentLeft)}}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
/* local-panel-surface.tsx generated by @compiled/babel-plugin v3.0.2 */
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
4
|
+
import "./local-panel-surface.compiled.css";
|
|
5
|
+
import * as React from 'react';
|
|
6
|
+
import { ax, ix } from "@compiled/react/runtime";
|
|
7
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
8
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
9
|
+
import { useCallback, useContext, useMemo, useRef } from 'react';
|
|
10
|
+
import mergeRefs from '@atlaskit/ds-lib/merge-refs';
|
|
11
|
+
import { useLayoutEffect } from '@atlaskit/ds-lib/use-layout-effect';
|
|
12
|
+
import useStableRef from '@atlaskit/ds-lib/use-stable-ref';
|
|
13
|
+
import { useMotion } from '@atlaskit/motion/entering/use-motion';
|
|
14
|
+
import ExitingPersistence from '@atlaskit/motion/exiting-persistence';
|
|
15
|
+
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
16
|
+
import { localPanelWidthVar } from './constants';
|
|
17
|
+
import { DangerouslyHoistSlotSizes } from './hoist-slot-sizes-context';
|
|
18
|
+
import { PanelSplitter } from './panel-splitter/panel-splitter';
|
|
19
|
+
import { PanelSplitterProvider } from './panel-splitter/provider';
|
|
20
|
+
var localPanelVar = '--p_lclPnlW';
|
|
21
|
+
var panelSplitterResizingVar = '--p_lclPnlRsz';
|
|
22
|
+
var localPanelSplitterId = Symbol('LocalPanel PanelSplitter');
|
|
23
|
+
|
|
24
|
+
// Compiled preserves the existing container-relative widths and discrete motion styles.
|
|
25
|
+
/* eslint-disable @compiled/shorthand-property-sorting -- Content motion overrides only the animation delay. */
|
|
26
|
+
var styles = {
|
|
27
|
+
panelWrapper: "_nd5l1gzg _kqsw1if8 _bfhk1bhr _vchhusvi _4t3ieqxy _152tidpf _10fph9n0 _1bsb13q4",
|
|
28
|
+
managedInline: "_nd5l1c6w _bfhkvuon _152tidpf _1bsb1c5w",
|
|
29
|
+
unmeasured: "_nd5l32aw _191wbqna _1bsb1cku _bfhk1g1j _16qs1dhr",
|
|
30
|
+
managedOverlay: "_nd5l1gzg _bfhk1bhr _1bsb1c5w",
|
|
31
|
+
panelScrollContainer: "_1reo1wug _18m91wug _4t3i1osq",
|
|
32
|
+
border: "_191wglyw _16qs130s",
|
|
33
|
+
managedInlineBorder: "_191wia51 _16qsglyw",
|
|
34
|
+
entering: "_k1af1nn1 _10t81ia4 _xrrp147i _1wsa1ign _1vrh1a5r _1kmh1n9t _105abamb",
|
|
35
|
+
exiting: "_k1af14vv _bq641n9t _105aeydr",
|
|
36
|
+
contentEntering: "_y44v1mph",
|
|
37
|
+
contentExiting: "_y44vf1qi",
|
|
38
|
+
contentChangeContainer: "_4t3i1osq"
|
|
39
|
+
};
|
|
40
|
+
var contentEnteringDelayStyles = {
|
|
41
|
+
root: "_ju25dn4k"
|
|
42
|
+
};
|
|
43
|
+
/* eslint-enable @compiled/shorthand-property-sorting */
|
|
44
|
+
|
|
45
|
+
var PanelContentMotion = function PanelContentMotion(_ref) {
|
|
46
|
+
var children = _ref.children;
|
|
47
|
+
var _useMotion = useMotion(),
|
|
48
|
+
state = _useMotion.state,
|
|
49
|
+
ref = _useMotion.ref;
|
|
50
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
51
|
+
ref: ref,
|
|
52
|
+
className: ax([styles.contentChangeContainer, state === 'entering' && styles.contentEntering, state === 'exiting' && styles.contentExiting])
|
|
53
|
+
}, children);
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Internal surface for PanelLayout. The host supplies content; navigation owns its geometry.
|
|
57
|
+
*/
|
|
58
|
+
export function LocalPanelSurface(_ref2) {
|
|
59
|
+
var _managedSizing$mode, _managedSizing$width;
|
|
60
|
+
var children = _ref2.children,
|
|
61
|
+
contentKey = _ref2.contentKey,
|
|
62
|
+
label = _ref2.label,
|
|
63
|
+
resizeLabel = _ref2.resizeLabel,
|
|
64
|
+
defaultWidth = _ref2.defaultWidth,
|
|
65
|
+
minWidth = _ref2.minWidth,
|
|
66
|
+
maxWidth = _ref2.maxWidth,
|
|
67
|
+
testId = _ref2.testId,
|
|
68
|
+
layoutRef = _ref2.layoutRef,
|
|
69
|
+
managedSizing = _ref2.managedSizing,
|
|
70
|
+
getManagedResizeBounds = _ref2.getManagedResizeBounds,
|
|
71
|
+
prepareResize = _ref2.prepareResize,
|
|
72
|
+
onManagedResizeStart = _ref2.onManagedResizeStart,
|
|
73
|
+
onManagedResize = _ref2.onManagedResize,
|
|
74
|
+
onManagedResizeEnd = _ref2.onManagedResizeEnd,
|
|
75
|
+
onWidthChange = _ref2.onWidthChange,
|
|
76
|
+
onResizeEnd = _ref2.onResizeEnd;
|
|
77
|
+
var ref = useRef(null);
|
|
78
|
+
var dangerouslyHoistSlotSizes = useContext(DangerouslyHoistSlotSizes);
|
|
79
|
+
useLayoutEffect(function () {
|
|
80
|
+
var panel = ref.current;
|
|
81
|
+
if (!dangerouslyHoistSlotSizes || !panel) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
// Container-relative CSS owns the initial width, before the sizing runtime loads.
|
|
85
|
+
// Publish geometry directly for external controls; never feed it into saved preferences.
|
|
86
|
+
var previousWidth;
|
|
87
|
+
var publishWidth = function publishWidth(width) {
|
|
88
|
+
if (width !== previousWidth) {
|
|
89
|
+
previousWidth = width;
|
|
90
|
+
panel.ownerDocument.documentElement.style.setProperty(localPanelWidthVar, "".concat(width, "px"));
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
publishWidth(panel.getBoundingClientRect().width);
|
|
94
|
+
var observer = new ResizeObserver(function (_ref3) {
|
|
95
|
+
var _entry$borderBoxSize$, _entry$borderBoxSize;
|
|
96
|
+
var _ref4 = _slicedToArray(_ref3, 1),
|
|
97
|
+
entry = _ref4[0];
|
|
98
|
+
publishWidth((_entry$borderBoxSize$ = (_entry$borderBoxSize = entry.borderBoxSize) === null || _entry$borderBoxSize === void 0 || (_entry$borderBoxSize = _entry$borderBoxSize[0]) === null || _entry$borderBoxSize === void 0 ? void 0 : _entry$borderBoxSize.inlineSize) !== null && _entry$borderBoxSize$ !== void 0 ? _entry$borderBoxSize$ : panel.getBoundingClientRect().width);
|
|
99
|
+
});
|
|
100
|
+
observer.observe(panel, {
|
|
101
|
+
box: 'border-box'
|
|
102
|
+
});
|
|
103
|
+
return function () {
|
|
104
|
+
observer.disconnect();
|
|
105
|
+
panel.ownerDocument.documentElement.style.removeProperty(localPanelWidthVar);
|
|
106
|
+
};
|
|
107
|
+
}, [dangerouslyHoistSlotSizes]);
|
|
108
|
+
var scrollRef = useRef(null);
|
|
109
|
+
useLayoutEffect(function () {
|
|
110
|
+
if (scrollRef.current) {
|
|
111
|
+
scrollRef.current.scrollTop = 0;
|
|
112
|
+
}
|
|
113
|
+
}, [contentKey]);
|
|
114
|
+
var _useMotion2 = useMotion(),
|
|
115
|
+
state = _useMotion2.state,
|
|
116
|
+
motionRef = _useMotion2.ref;
|
|
117
|
+
var isMotionUpliftEnabled = fg('platform-dst-motion-uplift-panel');
|
|
118
|
+
var isContentMotionEnabled = fg('platform-dst-motion-uplift-panel-content');
|
|
119
|
+
var mergedRef = useMemo(function () {
|
|
120
|
+
return isMotionUpliftEnabled ? mergeRefs([ref, motionRef]) : ref;
|
|
121
|
+
}, [isMotionUpliftEnabled, motionRef]);
|
|
122
|
+
var mode = (_managedSizing$mode = managedSizing === null || managedSizing === void 0 ? void 0 : managedSizing.mode) !== null && _managedSizing$mode !== void 0 ? _managedSizing$mode : 'overlay';
|
|
123
|
+
var managedMode = useStableRef(managedSizing === null || managedSizing === void 0 ? void 0 : managedSizing.mode);
|
|
124
|
+
// Resize preparation can load the coordinator after the interaction starts.
|
|
125
|
+
// Read its latest mode instead of the pre-load callback's captured fallback.
|
|
126
|
+
var getMode = useCallback(function () {
|
|
127
|
+
if (managedMode.current) {
|
|
128
|
+
return managedMode.current;
|
|
129
|
+
}
|
|
130
|
+
return ref.current && getComputedStyle(ref.current).gridArea.split('/')[0].trim() === 'panel' ? 'inline' : 'overlay';
|
|
131
|
+
}, [managedMode]);
|
|
132
|
+
var dragMode = useRef('overlay');
|
|
133
|
+
var completedResizeModeRef = useRef(mode);
|
|
134
|
+
var renderedWidth = (_managedSizing$width = managedSizing === null || managedSizing === void 0 ? void 0 : managedSizing.width) !== null && _managedSizing$width !== void 0 ? _managedSizing$width : Math.max(minWidth, Math.min(defaultWidth, maxWidth !== null && maxWidth !== void 0 ? maxWidth : Infinity));
|
|
135
|
+
// Before the first measurement, CSS caps the surface to its containing region.
|
|
136
|
+
// Resize preparation waits for the coordinator to resolve the same bounds for both inputs.
|
|
137
|
+
var getResizeBounds = useCallback(function () {
|
|
138
|
+
var _getManagedResizeBoun;
|
|
139
|
+
return (_getManagedResizeBoun = getManagedResizeBounds()) !== null && _getManagedResizeBoun !== void 0 ? _getManagedResizeBoun : {
|
|
140
|
+
min: '0px',
|
|
141
|
+
max: '0px'
|
|
142
|
+
};
|
|
143
|
+
}, [getManagedResizeBounds]);
|
|
144
|
+
var onCompleteResize = useCallback(function (width) {
|
|
145
|
+
// Keyboard analytics are debounced; retain the mode that produced this width,
|
|
146
|
+
// rather than the layout mode when the delayed callback eventually runs.
|
|
147
|
+
var mode = getMode();
|
|
148
|
+
completedResizeModeRef.current = mode;
|
|
149
|
+
onManagedResizeEnd(mode, width);
|
|
150
|
+
onWidthChange(width);
|
|
151
|
+
}, [getMode, onManagedResizeEnd, onWidthChange]);
|
|
152
|
+
var onResizeStartInternal = useCallback(function () {
|
|
153
|
+
dragMode.current = getMode();
|
|
154
|
+
onManagedResizeStart(dragMode.current);
|
|
155
|
+
}, [getMode, onManagedResizeStart]);
|
|
156
|
+
var onResizeInternal = useCallback(function (width) {
|
|
157
|
+
return onManagedResize(dragMode.current, width);
|
|
158
|
+
}, [onManagedResize]);
|
|
159
|
+
var handleResizeEnd = useCallback(function (event) {
|
|
160
|
+
return onResizeEnd(_objectSpread(_objectSpread({}, event), {}, {
|
|
161
|
+
mode: completedResizeModeRef.current
|
|
162
|
+
}));
|
|
163
|
+
}, [onResizeEnd]);
|
|
164
|
+
return /*#__PURE__*/React.createElement("section", {
|
|
165
|
+
"aria-label": label,
|
|
166
|
+
"data-testid": testId,
|
|
167
|
+
"data-layout-with-panel-slot": "",
|
|
168
|
+
style: _defineProperty({}, localPanelVar, "".concat(renderedWidth, "px")),
|
|
169
|
+
ref: mergedRef,
|
|
170
|
+
className: ax([isMotionUpliftEnabled && state === 'entering' && styles.entering, isMotionUpliftEnabled && state === 'exiting' && styles.exiting, styles.panelWrapper, styles.border, !managedSizing && styles.unmeasured, (managedSizing === null || managedSizing === void 0 ? void 0 : managedSizing.mode) === 'inline' && styles.managedInline, (managedSizing === null || managedSizing === void 0 ? void 0 : managedSizing.mode) === 'overlay' && styles.managedOverlay, (managedSizing === null || managedSizing === void 0 ? void 0 : managedSizing.mode) === 'inline' && styles.managedInlineBorder])
|
|
171
|
+
}, /*#__PURE__*/React.createElement(PanelSplitterProvider, {
|
|
172
|
+
panelId: localPanelSplitterId,
|
|
173
|
+
panelRef: ref,
|
|
174
|
+
resizingElementRef: layoutRef,
|
|
175
|
+
panelWidth: renderedWidth,
|
|
176
|
+
onCompleteResize: onCompleteResize,
|
|
177
|
+
prepareResize: prepareResize,
|
|
178
|
+
onResizeStartInternal: onResizeStartInternal,
|
|
179
|
+
onResizeInternal: onResizeInternal,
|
|
180
|
+
getResizeBounds: getResizeBounds,
|
|
181
|
+
isEnabled: managedSizing !== undefined || prepareResize !== undefined,
|
|
182
|
+
resizingCssVar: panelSplitterResizingVar,
|
|
183
|
+
position: "start"
|
|
184
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
185
|
+
ref: scrollRef,
|
|
186
|
+
"data-testid": testId && "".concat(testId, "--scroll-container"),
|
|
187
|
+
className: ax([styles.panelScrollContainer, state === 'entering' && styles.contentEntering, isMotionUpliftEnabled && state === 'entering' && contentEnteringDelayStyles.root, state === 'exiting' && styles.contentExiting])
|
|
188
|
+
}, isContentMotionEnabled && contentKey !== undefined ? /*#__PURE__*/React.createElement(ExitingPersistence, {
|
|
189
|
+
exitThenEnter: true
|
|
190
|
+
}, /*#__PURE__*/React.createElement(PanelContentMotion, {
|
|
191
|
+
key: contentKey
|
|
192
|
+
}, children)) : children, /*#__PURE__*/React.createElement(PanelSplitter, {
|
|
193
|
+
label: resizeLabel,
|
|
194
|
+
testId: testId && "".concat(testId, "--splitter"),
|
|
195
|
+
onResizeEnd: handleResizeEnd
|
|
196
|
+
}))));
|
|
197
|
+
}
|
|
@@ -5,7 +5,8 @@ import { ax, ix } from "@compiled/react/runtime";
|
|
|
5
5
|
import { Fragment } from 'react';
|
|
6
6
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
7
7
|
import { useSkipLink } from '../../../context/skip-links/use-skip-link';
|
|
8
|
-
import { mainMinimumWidthVar } from '../constants';
|
|
8
|
+
import { defaultMainMinWidth, mainMinimumWidthVar } from '../constants';
|
|
9
|
+
import { MainMinWidthContext } from '../main-min-width-context';
|
|
9
10
|
import { gridRootFitId, gridRootId } from '../root';
|
|
10
11
|
import { useLayoutId } from '../use-layout-id';
|
|
11
12
|
import { useLayoutMainSizing } from '../use-layout-main-sizing';
|
|
@@ -26,7 +27,7 @@ export function Main(_ref) {
|
|
|
26
27
|
testId = _ref.testId,
|
|
27
28
|
providedId = _ref.id,
|
|
28
29
|
_ref$minWidth = _ref.minWidth,
|
|
29
|
-
minWidth = _ref$minWidth === void 0 ?
|
|
30
|
+
minWidth = _ref$minWidth === void 0 ? defaultMainMinWidth : _ref$minWidth;
|
|
30
31
|
var id = useLayoutId({
|
|
31
32
|
providedId: providedId
|
|
32
33
|
});
|
|
@@ -41,5 +42,7 @@ export function Main(_ref) {
|
|
|
41
42
|
className: ax([mainElementStyles.root, xcss]),
|
|
42
43
|
role: "main",
|
|
43
44
|
"data-testid": testId
|
|
44
|
-
},
|
|
45
|
+
}, /*#__PURE__*/React.createElement(MainMinWidthContext.Provider, {
|
|
46
|
+
value: fg('platform-dst-chat-panel-layout') ? minWidth : defaultMainMinWidth
|
|
47
|
+
}, children)));
|
|
45
48
|
}
|