@atlaskit/page-layout 1.6.5 → 1.7.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 +14 -0
- package/dist/cjs/common/constants.js +5 -1
- package/dist/cjs/components/resize-control/index.js +16 -24
- package/dist/cjs/components/resize-control/resize-button.js +10 -4
- package/dist/cjs/components/skip-links/skip-link-components.js +1 -1
- package/dist/cjs/components/slots/internal/left-sidebar-inner.js +29 -2
- package/dist/cjs/components/slots/internal/left-sidebar-outer.js +40 -7
- package/dist/cjs/components/slots/internal/resizable-children-wrapper.js +1 -1
- package/dist/cjs/components/slots/left-sidebar.js +137 -39
- package/dist/cjs/components/slots/main.js +1 -1
- package/dist/cjs/components/slots/page-layout.js +10 -1
- package/dist/cjs/components/slots/slot-dimensions.js +5 -2
- package/dist/cjs/controllers/sidebar-resize-context.js +2 -1
- package/dist/cjs/controllers/sidebar-resize-controller.js +96 -35
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/common/constants.js +2 -0
- package/dist/es2019/components/resize-control/index.js +15 -23
- package/dist/es2019/components/resize-control/resize-button.js +13 -4
- package/dist/es2019/components/skip-links/skip-link-components.js +1 -1
- package/dist/es2019/components/slots/internal/left-sidebar-inner.js +34 -3
- package/dist/es2019/components/slots/internal/left-sidebar-outer.js +51 -8
- package/dist/es2019/components/slots/internal/resizable-children-wrapper.js +1 -1
- package/dist/es2019/components/slots/left-sidebar.js +142 -42
- package/dist/es2019/components/slots/main.js +1 -1
- package/dist/es2019/components/slots/page-layout.js +17 -1
- package/dist/es2019/components/slots/slot-dimensions.js +5 -2
- package/dist/es2019/controllers/sidebar-resize-context.js +2 -1
- package/dist/es2019/controllers/sidebar-resize-controller.js +96 -38
- package/dist/es2019/version.json +1 -1
- package/dist/esm/common/constants.js +2 -0
- package/dist/esm/components/resize-control/index.js +15 -23
- package/dist/esm/components/resize-control/resize-button.js +10 -4
- package/dist/esm/components/skip-links/skip-link-components.js +1 -1
- package/dist/esm/components/slots/internal/left-sidebar-inner.js +29 -3
- package/dist/esm/components/slots/internal/left-sidebar-outer.js +42 -9
- package/dist/esm/components/slots/internal/resizable-children-wrapper.js +1 -1
- package/dist/esm/components/slots/left-sidebar.js +140 -42
- package/dist/esm/components/slots/main.js +1 -1
- package/dist/esm/components/slots/page-layout.js +10 -1
- package/dist/esm/components/slots/slot-dimensions.js +5 -2
- package/dist/esm/controllers/sidebar-resize-context.js +2 -1
- package/dist/esm/controllers/sidebar-resize-controller.js +96 -35
- package/dist/esm/version.json +1 -1
- package/dist/types/common/constants.d.ts +2 -0
- package/dist/types/components/resize-control/types.d.ts +0 -2
- package/dist/types/components/slots/internal/left-sidebar-outer.d.ts +1 -1
- package/dist/types/components/slots/left-sidebar.d.ts +6 -0
- package/dist/types/components/slots/slot-dimensions.d.ts +2 -1
- package/dist/types/controllers/sidebar-resize-context.d.ts +10 -0
- package/dist/types-ts4.5/common/constants.d.ts +2 -0
- package/dist/types-ts4.5/components/resize-control/types.d.ts +0 -2
- package/dist/types-ts4.5/components/slots/internal/left-sidebar-outer.d.ts +1 -1
- package/dist/types-ts4.5/components/slots/left-sidebar.d.ts +6 -0
- package/dist/types-ts4.5/components/slots/slot-dimensions.d.ts +2 -1
- package/dist/types-ts4.5/controllers/sidebar-resize-context.d.ts +10 -0
- package/package.json +13 -7
- package/report.api.md +7 -6
- package/tmp/api-report-tmp.d.ts +174 -0
|
@@ -3,13 +3,14 @@ import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
|
|
3
3
|
import { bind } from 'bind-event-listener';
|
|
4
4
|
import noop from '@atlaskit/ds-lib/noop';
|
|
5
5
|
import { isReducedMotion } from '@atlaskit/motion';
|
|
6
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
7
|
+
import { UNSAFE_useMediaQuery as useMediaQuery } from '@atlaskit/primitives/responsive';
|
|
6
8
|
import { COLLAPSED_LEFT_SIDEBAR_WIDTH, DEFAULT_LEFT_SIDEBAR_WIDTH, IS_SIDEBAR_COLLAPSING } from '../common/constants';
|
|
7
9
|
import { getPageLayoutSlotCSSSelector } from '../common/utils';
|
|
8
10
|
import { SidebarResizeContext } from './sidebar-resize-context';
|
|
9
11
|
var handleDataAttributesAndCb = function handleDataAttributesAndCb() {
|
|
10
12
|
var callback = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : noop;
|
|
11
|
-
var
|
|
12
|
-
var leftSidebarState = arguments.length > 2 ? arguments[2] : undefined;
|
|
13
|
+
var leftSidebarState = arguments.length > 1 ? arguments[1] : undefined;
|
|
13
14
|
document.documentElement.removeAttribute(IS_SIDEBAR_COLLAPSING);
|
|
14
15
|
callback(leftSidebarState);
|
|
15
16
|
};
|
|
@@ -31,7 +32,13 @@ export var SidebarResizeController = function SidebarResizeController(_ref) {
|
|
|
31
32
|
_useState2 = _slicedToArray(_useState, 2),
|
|
32
33
|
leftSidebarState = _useState2[0],
|
|
33
34
|
setLeftSidebarState = _useState2[1];
|
|
34
|
-
var
|
|
35
|
+
var leftSidebarWidth = leftSidebarState.leftSidebarWidth,
|
|
36
|
+
lastLeftSidebarWidth = leftSidebarState.lastLeftSidebarWidth,
|
|
37
|
+
isResizing = leftSidebarState.isResizing,
|
|
38
|
+
flyoutLockCount = leftSidebarState.flyoutLockCount,
|
|
39
|
+
isFixed = leftSidebarState.isFixed,
|
|
40
|
+
isLeftSidebarCollapsed = leftSidebarState.isLeftSidebarCollapsed,
|
|
41
|
+
isFlyoutOpen = leftSidebarState.isFlyoutOpen;
|
|
35
42
|
|
|
36
43
|
// We put the latest callbacks into a ref so we can always have the latest
|
|
37
44
|
// functions in our transitionend listeners
|
|
@@ -44,23 +51,46 @@ export var SidebarResizeController = function SidebarResizeController(_ref) {
|
|
|
44
51
|
onExpand: onExpand,
|
|
45
52
|
onCollapse: onCollapse
|
|
46
53
|
};
|
|
47
|
-
});
|
|
54
|
+
}, [onExpand, onCollapse]);
|
|
48
55
|
var transition = useRef(null);
|
|
56
|
+
var mobileMediaQuery = getBooleanFF('platform.design-system-team.responsive-page-layout-left-sidebar_p8r7g') ?
|
|
57
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks -- With the feature flag, this does not apply as it should be static.
|
|
58
|
+
useMediaQuery('below.md') : null;
|
|
59
|
+
var isOpen = mobileMediaQuery !== null && mobileMediaQuery !== void 0 && mobileMediaQuery.matches ? isFlyoutOpen : !isLeftSidebarCollapsed;
|
|
49
60
|
var expandLeftSidebar = useCallback(function () {
|
|
50
|
-
var _transition$
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
61
|
+
var _transition$current2, _transition$current3;
|
|
62
|
+
if (isOpen) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// If the user is at a mobile viewport when this runs, we handle it differently
|
|
67
|
+
// We don't expand at mobile widths; instead we use a flyout which is treated the same otherwise
|
|
68
|
+
if (mobileMediaQuery !== null && mobileMediaQuery !== void 0 && mobileMediaQuery.matches) {
|
|
69
|
+
var _transition$current;
|
|
70
|
+
var flyoutOpenSidebarState = {
|
|
71
|
+
isResizing: false,
|
|
72
|
+
isLeftSidebarCollapsed: true,
|
|
73
|
+
leftSidebarWidth: COLLAPSED_LEFT_SIDEBAR_WIDTH,
|
|
74
|
+
lastLeftSidebarWidth: leftSidebarWidth,
|
|
75
|
+
isFlyoutOpen: true,
|
|
76
|
+
flyoutLockCount: 0,
|
|
77
|
+
isFixed: isFixed
|
|
78
|
+
};
|
|
79
|
+
setLeftSidebarState(flyoutOpenSidebarState);
|
|
80
|
+
|
|
81
|
+
// Flush the desktop transitions, cleanup, and call the `onExpand` still
|
|
82
|
+
(_transition$current = transition.current) === null || _transition$current === void 0 ? void 0 : _transition$current.complete();
|
|
83
|
+
handleDataAttributesAndCb(stableRef.current.onExpand, flyoutOpenSidebarState);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
56
86
|
if (isResizing || !isLeftSidebarCollapsed ||
|
|
57
87
|
// already expanding
|
|
58
|
-
((_transition$
|
|
88
|
+
((_transition$current2 = transition.current) === null || _transition$current2 === void 0 ? void 0 : _transition$current2.action) === 'expand') {
|
|
59
89
|
return;
|
|
60
90
|
}
|
|
61
91
|
|
|
62
92
|
// flush existing transition
|
|
63
|
-
(_transition$
|
|
93
|
+
(_transition$current3 = transition.current) === null || _transition$current3 === void 0 ? void 0 : _transition$current3.complete();
|
|
64
94
|
var width = Math.max(lastLeftSidebarWidth, DEFAULT_LEFT_SIDEBAR_WIDTH);
|
|
65
95
|
var updatedLeftSidebarState = {
|
|
66
96
|
isLeftSidebarCollapsed: false,
|
|
@@ -73,9 +103,7 @@ export var SidebarResizeController = function SidebarResizeController(_ref) {
|
|
|
73
103
|
};
|
|
74
104
|
setLeftSidebarState(updatedLeftSidebarState);
|
|
75
105
|
function finish() {
|
|
76
|
-
handleDataAttributesAndCb(stableRef.current.onExpand,
|
|
77
|
-
// isCollapsed
|
|
78
|
-
updatedLeftSidebarState);
|
|
106
|
+
handleDataAttributesAndCb(stableRef.current.onExpand, updatedLeftSidebarState);
|
|
79
107
|
}
|
|
80
108
|
var sidebar = document.querySelector(leftSidebarSelector);
|
|
81
109
|
// onTransitionEnd isn't triggered when a user prefers reduced motion
|
|
@@ -87,8 +115,8 @@ export var SidebarResizeController = function SidebarResizeController(_ref) {
|
|
|
87
115
|
type: 'transitionend',
|
|
88
116
|
listener: function listener(event) {
|
|
89
117
|
if (event.target === sidebar && event.propertyName === 'width') {
|
|
90
|
-
var _transition$
|
|
91
|
-
(_transition$
|
|
118
|
+
var _transition$current4;
|
|
119
|
+
(_transition$current4 = transition.current) === null || _transition$current4 === void 0 ? void 0 : _transition$current4.complete();
|
|
92
120
|
}
|
|
93
121
|
}
|
|
94
122
|
});
|
|
@@ -104,22 +132,41 @@ export var SidebarResizeController = function SidebarResizeController(_ref) {
|
|
|
104
132
|
}
|
|
105
133
|
};
|
|
106
134
|
transition.current = value;
|
|
107
|
-
}, [
|
|
135
|
+
}, [isOpen, mobileMediaQuery, isResizing, isLeftSidebarCollapsed, lastLeftSidebarWidth, flyoutLockCount, isFixed, leftSidebarWidth]);
|
|
108
136
|
var collapseLeftSidebar = useCallback(function (event, collapseWithoutTransition) {
|
|
109
|
-
var _transition$
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
137
|
+
var _transition$current6, _transition$current7;
|
|
138
|
+
if (!isOpen) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// If the user is at a mobile viewport when this runs, we handle it differently
|
|
143
|
+
// We don't collapse at mobile widths; instead we close the flyout.
|
|
144
|
+
if (mobileMediaQuery !== null && mobileMediaQuery !== void 0 && mobileMediaQuery.matches) {
|
|
145
|
+
var _transition$current5;
|
|
146
|
+
var flyoutCloseSidebarState = {
|
|
147
|
+
isResizing: false,
|
|
148
|
+
isLeftSidebarCollapsed: true,
|
|
149
|
+
leftSidebarWidth: COLLAPSED_LEFT_SIDEBAR_WIDTH,
|
|
150
|
+
lastLeftSidebarWidth: lastLeftSidebarWidth,
|
|
151
|
+
isFlyoutOpen: false,
|
|
152
|
+
flyoutLockCount: 0,
|
|
153
|
+
isFixed: isFixed
|
|
154
|
+
};
|
|
155
|
+
setLeftSidebarState(flyoutCloseSidebarState);
|
|
156
|
+
|
|
157
|
+
// Flush the desktop transitions, cleanup, and call the `onCollapse` still
|
|
158
|
+
(_transition$current5 = transition.current) === null || _transition$current5 === void 0 ? void 0 : _transition$current5.complete();
|
|
159
|
+
handleDataAttributesAndCb(stableRef.current.onCollapse, flyoutCloseSidebarState);
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
115
162
|
if (isResizing || isLeftSidebarCollapsed ||
|
|
116
163
|
// already collapsing
|
|
117
|
-
((_transition$
|
|
164
|
+
((_transition$current6 = transition.current) === null || _transition$current6 === void 0 ? void 0 : _transition$current6.action) === 'collapse') {
|
|
118
165
|
return;
|
|
119
166
|
}
|
|
120
167
|
|
|
121
168
|
// flush existing transition
|
|
122
|
-
(_transition$
|
|
169
|
+
(_transition$current7 = transition.current) === null || _transition$current7 === void 0 ? void 0 : _transition$current7.complete();
|
|
123
170
|
|
|
124
171
|
// data-attribute is used as a CSS selector to sync the hiding/showing
|
|
125
172
|
// of the nav contents with expand/collapse animation
|
|
@@ -135,7 +182,7 @@ export var SidebarResizeController = function SidebarResizeController(_ref) {
|
|
|
135
182
|
};
|
|
136
183
|
setLeftSidebarState(updatedLeftSidebarState);
|
|
137
184
|
function finish() {
|
|
138
|
-
handleDataAttributesAndCb(stableRef.current.onCollapse,
|
|
185
|
+
handleDataAttributesAndCb(stableRef.current.onCollapse, updatedLeftSidebarState);
|
|
139
186
|
}
|
|
140
187
|
var sidebar = document.querySelector(leftSidebarSelector);
|
|
141
188
|
|
|
@@ -148,8 +195,8 @@ export var SidebarResizeController = function SidebarResizeController(_ref) {
|
|
|
148
195
|
type: 'transitionend',
|
|
149
196
|
listener: function listener(event) {
|
|
150
197
|
if (sidebar === event.target && event.propertyName === 'width') {
|
|
151
|
-
var _transition$
|
|
152
|
-
(_transition$
|
|
198
|
+
var _transition$current8;
|
|
199
|
+
(_transition$current8 = transition.current) === null || _transition$current8 === void 0 ? void 0 : _transition$current8.complete();
|
|
153
200
|
}
|
|
154
201
|
}
|
|
155
202
|
});
|
|
@@ -165,24 +212,38 @@ export var SidebarResizeController = function SidebarResizeController(_ref) {
|
|
|
165
212
|
}
|
|
166
213
|
};
|
|
167
214
|
transition.current = value;
|
|
168
|
-
}, [
|
|
215
|
+
}, [isOpen, mobileMediaQuery, isResizing, isLeftSidebarCollapsed, leftSidebarWidth, flyoutLockCount, isFixed, lastLeftSidebarWidth]);
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Conditionally toggle the expanding or collapsing the sidebars.
|
|
219
|
+
* This supports our mobile flyout mode as well.
|
|
220
|
+
*/
|
|
221
|
+
var toggleLeftSidebar = useCallback(function (event, collapseWithoutTransition) {
|
|
222
|
+
if (isOpen) {
|
|
223
|
+
collapseLeftSidebar(event, collapseWithoutTransition);
|
|
224
|
+
} else {
|
|
225
|
+
expandLeftSidebar();
|
|
226
|
+
}
|
|
227
|
+
}, [isOpen, expandLeftSidebar, collapseLeftSidebar]);
|
|
169
228
|
|
|
170
229
|
// Make sure we finish any lingering transitions when unmounting
|
|
171
230
|
useEffect(function mount() {
|
|
172
231
|
return function unmount() {
|
|
173
|
-
var _transition$
|
|
174
|
-
(_transition$
|
|
232
|
+
var _transition$current9;
|
|
233
|
+
(_transition$current9 = transition.current) === null || _transition$current9 === void 0 ? void 0 : _transition$current9.abort();
|
|
175
234
|
};
|
|
176
235
|
}, []);
|
|
177
236
|
var context = useMemo(function () {
|
|
178
237
|
return {
|
|
179
|
-
isLeftSidebarCollapsed:
|
|
238
|
+
isLeftSidebarCollapsed: !isOpen,
|
|
239
|
+
// Technically this isn't quite true, but with mobile it's a bit safer if products are using this to roll their own collapse/expand
|
|
180
240
|
expandLeftSidebar: expandLeftSidebar,
|
|
181
241
|
collapseLeftSidebar: collapseLeftSidebar,
|
|
182
242
|
leftSidebarState: leftSidebarState,
|
|
183
|
-
setLeftSidebarState: setLeftSidebarState
|
|
243
|
+
setLeftSidebarState: setLeftSidebarState,
|
|
244
|
+
toggleLeftSidebar: toggleLeftSidebar
|
|
184
245
|
};
|
|
185
|
-
}, [
|
|
246
|
+
}, [isOpen, expandLeftSidebar, collapseLeftSidebar, leftSidebarState, toggleLeftSidebar]);
|
|
186
247
|
return /*#__PURE__*/React.createElement(SidebarResizeContext.Provider, {
|
|
187
248
|
value: context
|
|
188
249
|
}, children);
|
package/dist/esm/version.json
CHANGED
|
@@ -21,9 +21,11 @@ export declare const DEFAULT_RIGHT_SIDEBAR_WIDTH = 280;
|
|
|
21
21
|
export declare const DEFAULT_RIGHT_PANEL_WIDTH = 368;
|
|
22
22
|
export declare const DEFAULT_LEFT_PANEL_WIDTH = 368;
|
|
23
23
|
export declare const COLLAPSED_LEFT_SIDEBAR_WIDTH = 20;
|
|
24
|
+
export declare const MOBILE_COLLAPSED_LEFT_SIDEBAR_WIDTH = 16;
|
|
24
25
|
export declare const MIN_LEFT_SIDEBAR_WIDTH = 80;
|
|
25
26
|
export declare const DEFAULT_LEFT_SIDEBAR_FLYOUT_WIDTH = 240;
|
|
26
27
|
export declare const MIN_LEFT_SIDEBAR_DRAG_THRESHOLD = 200;
|
|
28
|
+
export declare const MAX_MOBILE_SIDEBAR_FLYOUT_WIDTH = 350;
|
|
27
29
|
export declare const TRANSITION_DURATION = 300;
|
|
28
30
|
export declare const FLYOUT_DELAY = 200;
|
|
29
31
|
export declare const LEFT_SIDEBAR_EXPANDED_WIDTH = "expandedLeftSidebarWidth";
|
|
@@ -20,6 +20,4 @@ export type ResizeControlProps = {
|
|
|
20
20
|
onResizeEnd?: (leftSidebarState: LeftSidebarState) => void;
|
|
21
21
|
onFlyoutCollapse?: () => void;
|
|
22
22
|
onFlyoutExpand?: () => void;
|
|
23
|
-
leftSidebarState: LeftSidebarState;
|
|
24
|
-
setLeftSidebarState: (leftSidebarState: LeftSidebarState) => void;
|
|
25
23
|
};
|
|
@@ -3,11 +3,11 @@ import { MouseEventHandler, ReactNode } from 'react';
|
|
|
3
3
|
type LeftSidebarOuterProps = {
|
|
4
4
|
children: ReactNode;
|
|
5
5
|
isFixed?: boolean;
|
|
6
|
-
isFlyoutOpen?: boolean;
|
|
7
6
|
testId?: string;
|
|
8
7
|
id?: string;
|
|
9
8
|
onMouseOver?: MouseEventHandler;
|
|
10
9
|
onMouseLeave?: MouseEventHandler;
|
|
10
|
+
onClick?: MouseEventHandler;
|
|
11
11
|
};
|
|
12
12
|
declare const _default: import("react").ForwardRefExoticComponent<LeftSidebarOuterProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
13
13
|
export default _default;
|
|
@@ -5,6 +5,12 @@ import { LeftSidebarProps } from '../../common/types';
|
|
|
5
5
|
*
|
|
6
6
|
* Provides a slot for a left sidebar within the PageLayout.
|
|
7
7
|
*
|
|
8
|
+
* [Behind a feature-flag 'platform.design-system-team.responsive-page-layout-left-sidebar_p8r7g']:
|
|
9
|
+
* On smaller viewports, the left sidebar can no longer be expanded. Instead, expanding it will
|
|
10
|
+
* put it into our "flyout mode" to lay overtop (which in desktop is explicitly a hover state).
|
|
11
|
+
* This ensures the contents behind do not reflow oddly and allows for a better experience
|
|
12
|
+
* resizing between mobile and desktop.
|
|
13
|
+
*
|
|
8
14
|
* - [Examples](https://atlassian.design/components/page-layout/examples)
|
|
9
15
|
* - [Code](https://atlassian.design/components/page-layout/code)
|
|
10
16
|
*/
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
interface SlotDimensionsProps {
|
|
3
3
|
variableName: string;
|
|
4
4
|
value?: number;
|
|
5
|
+
mobileValue?: number;
|
|
5
6
|
}
|
|
6
|
-
declare const _default: ({ variableName, value }: SlotDimensionsProps) => JSX.Element;
|
|
7
|
+
declare const _default: ({ variableName, value, mobileValue }: SlotDimensionsProps) => JSX.Element;
|
|
7
8
|
export default _default;
|
|
@@ -12,6 +12,11 @@ export type SidebarResizeContextValue = {
|
|
|
12
12
|
isLeftSidebarCollapsed: boolean;
|
|
13
13
|
expandLeftSidebar: () => void;
|
|
14
14
|
collapseLeftSidebar: (event?: MouseEvent | KeyboardEvent, collapseWithoutTransition?: boolean) => void;
|
|
15
|
+
/**
|
|
16
|
+
* Conditionally expands or collapses the left sidebar based on the current state.
|
|
17
|
+
* This is aware of our flyout mode in mobile as well.
|
|
18
|
+
*/
|
|
19
|
+
toggleLeftSidebar: (event?: MouseEvent | KeyboardEvent, collapseWithoutTransition?: boolean) => void;
|
|
15
20
|
leftSidebarState: LeftSidebarState;
|
|
16
21
|
setLeftSidebarState: (value: LeftSidebarState | ((prevState: LeftSidebarState) => LeftSidebarState)) => void;
|
|
17
22
|
};
|
|
@@ -20,6 +25,11 @@ export declare const usePageLayoutResize: () => {
|
|
|
20
25
|
isLeftSidebarCollapsed: boolean;
|
|
21
26
|
expandLeftSidebar: () => void;
|
|
22
27
|
collapseLeftSidebar: (event?: MouseEvent | KeyboardEvent, collapseWithoutTransition?: boolean) => void;
|
|
28
|
+
/**
|
|
29
|
+
* Conditionally expands or collapses the left sidebar based on the current state.
|
|
30
|
+
* This is aware of our flyout mode in mobile as well.
|
|
31
|
+
*/
|
|
32
|
+
toggleLeftSidebar: (event?: MouseEvent | KeyboardEvent, collapseWithoutTransition?: boolean) => void;
|
|
23
33
|
leftSidebarState: LeftSidebarState;
|
|
24
34
|
};
|
|
25
35
|
/**
|
|
@@ -21,9 +21,11 @@ export declare const DEFAULT_RIGHT_SIDEBAR_WIDTH = 280;
|
|
|
21
21
|
export declare const DEFAULT_RIGHT_PANEL_WIDTH = 368;
|
|
22
22
|
export declare const DEFAULT_LEFT_PANEL_WIDTH = 368;
|
|
23
23
|
export declare const COLLAPSED_LEFT_SIDEBAR_WIDTH = 20;
|
|
24
|
+
export declare const MOBILE_COLLAPSED_LEFT_SIDEBAR_WIDTH = 16;
|
|
24
25
|
export declare const MIN_LEFT_SIDEBAR_WIDTH = 80;
|
|
25
26
|
export declare const DEFAULT_LEFT_SIDEBAR_FLYOUT_WIDTH = 240;
|
|
26
27
|
export declare const MIN_LEFT_SIDEBAR_DRAG_THRESHOLD = 200;
|
|
28
|
+
export declare const MAX_MOBILE_SIDEBAR_FLYOUT_WIDTH = 350;
|
|
27
29
|
export declare const TRANSITION_DURATION = 300;
|
|
28
30
|
export declare const FLYOUT_DELAY = 200;
|
|
29
31
|
export declare const LEFT_SIDEBAR_EXPANDED_WIDTH = "expandedLeftSidebarWidth";
|
|
@@ -20,6 +20,4 @@ export type ResizeControlProps = {
|
|
|
20
20
|
onResizeEnd?: (leftSidebarState: LeftSidebarState) => void;
|
|
21
21
|
onFlyoutCollapse?: () => void;
|
|
22
22
|
onFlyoutExpand?: () => void;
|
|
23
|
-
leftSidebarState: LeftSidebarState;
|
|
24
|
-
setLeftSidebarState: (leftSidebarState: LeftSidebarState) => void;
|
|
25
23
|
};
|
|
@@ -3,11 +3,11 @@ import { MouseEventHandler, ReactNode } from 'react';
|
|
|
3
3
|
type LeftSidebarOuterProps = {
|
|
4
4
|
children: ReactNode;
|
|
5
5
|
isFixed?: boolean;
|
|
6
|
-
isFlyoutOpen?: boolean;
|
|
7
6
|
testId?: string;
|
|
8
7
|
id?: string;
|
|
9
8
|
onMouseOver?: MouseEventHandler;
|
|
10
9
|
onMouseLeave?: MouseEventHandler;
|
|
10
|
+
onClick?: MouseEventHandler;
|
|
11
11
|
};
|
|
12
12
|
declare const _default: import("react").ForwardRefExoticComponent<LeftSidebarOuterProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
13
13
|
export default _default;
|
|
@@ -5,6 +5,12 @@ import { LeftSidebarProps } from '../../common/types';
|
|
|
5
5
|
*
|
|
6
6
|
* Provides a slot for a left sidebar within the PageLayout.
|
|
7
7
|
*
|
|
8
|
+
* [Behind a feature-flag 'platform.design-system-team.responsive-page-layout-left-sidebar_p8r7g']:
|
|
9
|
+
* On smaller viewports, the left sidebar can no longer be expanded. Instead, expanding it will
|
|
10
|
+
* put it into our "flyout mode" to lay overtop (which in desktop is explicitly a hover state).
|
|
11
|
+
* This ensures the contents behind do not reflow oddly and allows for a better experience
|
|
12
|
+
* resizing between mobile and desktop.
|
|
13
|
+
*
|
|
8
14
|
* - [Examples](https://atlassian.design/components/page-layout/examples)
|
|
9
15
|
* - [Code](https://atlassian.design/components/page-layout/code)
|
|
10
16
|
*/
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
interface SlotDimensionsProps {
|
|
3
3
|
variableName: string;
|
|
4
4
|
value?: number;
|
|
5
|
+
mobileValue?: number;
|
|
5
6
|
}
|
|
6
|
-
declare const _default: ({ variableName, value }: SlotDimensionsProps) => JSX.Element;
|
|
7
|
+
declare const _default: ({ variableName, value, mobileValue }: SlotDimensionsProps) => JSX.Element;
|
|
7
8
|
export default _default;
|
|
@@ -12,6 +12,11 @@ export type SidebarResizeContextValue = {
|
|
|
12
12
|
isLeftSidebarCollapsed: boolean;
|
|
13
13
|
expandLeftSidebar: () => void;
|
|
14
14
|
collapseLeftSidebar: (event?: MouseEvent | KeyboardEvent, collapseWithoutTransition?: boolean) => void;
|
|
15
|
+
/**
|
|
16
|
+
* Conditionally expands or collapses the left sidebar based on the current state.
|
|
17
|
+
* This is aware of our flyout mode in mobile as well.
|
|
18
|
+
*/
|
|
19
|
+
toggleLeftSidebar: (event?: MouseEvent | KeyboardEvent, collapseWithoutTransition?: boolean) => void;
|
|
15
20
|
leftSidebarState: LeftSidebarState;
|
|
16
21
|
setLeftSidebarState: (value: LeftSidebarState | ((prevState: LeftSidebarState) => LeftSidebarState)) => void;
|
|
17
22
|
};
|
|
@@ -20,6 +25,11 @@ export declare const usePageLayoutResize: () => {
|
|
|
20
25
|
isLeftSidebarCollapsed: boolean;
|
|
21
26
|
expandLeftSidebar: () => void;
|
|
22
27
|
collapseLeftSidebar: (event?: MouseEvent | KeyboardEvent, collapseWithoutTransition?: boolean) => void;
|
|
28
|
+
/**
|
|
29
|
+
* Conditionally expands or collapses the left sidebar based on the current state.
|
|
30
|
+
* This is aware of our flyout mode in mobile as well.
|
|
31
|
+
*/
|
|
32
|
+
toggleLeftSidebar: (event?: MouseEvent | KeyboardEvent, collapseWithoutTransition?: boolean) => void;
|
|
23
33
|
leftSidebarState: LeftSidebarState;
|
|
24
34
|
};
|
|
25
35
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/page-layout",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.1",
|
|
4
4
|
"description": "A collection of components which let you compose an application's page layout.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"atlassian": {
|
|
26
26
|
"team": "Design System Team",
|
|
27
27
|
"deprecatedAutoEntryPoints": true,
|
|
28
|
-
"releaseModel": "
|
|
28
|
+
"releaseModel": "continuous",
|
|
29
29
|
"website": {
|
|
30
30
|
"name": "Page layout",
|
|
31
31
|
"category": "Components"
|
|
@@ -36,8 +36,10 @@
|
|
|
36
36
|
"@atlaskit/ds-lib": "^2.2.0",
|
|
37
37
|
"@atlaskit/icon": "^21.12.0",
|
|
38
38
|
"@atlaskit/motion": "^1.4.0",
|
|
39
|
+
"@atlaskit/platform-feature-flags": "^0.2.0",
|
|
40
|
+
"@atlaskit/primitives": "^0.12.4",
|
|
39
41
|
"@atlaskit/theme": "^12.5.0",
|
|
40
|
-
"@atlaskit/tokens": "^1.
|
|
42
|
+
"@atlaskit/tokens": "^1.9.0",
|
|
41
43
|
"@babel/runtime": "^7.0.0",
|
|
42
44
|
"@emotion/react": "^11.7.1",
|
|
43
45
|
"bind-event-listener": "^2.1.1",
|
|
@@ -50,7 +52,7 @@
|
|
|
50
52
|
"devDependencies": {
|
|
51
53
|
"@atlaskit/atlassian-navigation": "^2.6.0",
|
|
52
54
|
"@atlaskit/atlassian-notifications": "^0.4.0",
|
|
53
|
-
"@atlaskit/button": "^16.
|
|
55
|
+
"@atlaskit/button": "^16.8.0",
|
|
54
56
|
"@atlaskit/docs": "*",
|
|
55
57
|
"@atlaskit/drawer": "^7.5.0",
|
|
56
58
|
"@atlaskit/icon": "*",
|
|
@@ -58,8 +60,7 @@
|
|
|
58
60
|
"@atlaskit/menu": "^1.7.0",
|
|
59
61
|
"@atlaskit/notification-indicator": "^9.1.0",
|
|
60
62
|
"@atlaskit/notification-log-client": "^6.1.0",
|
|
61
|
-
"@atlaskit/
|
|
62
|
-
"@atlaskit/popup": "^1.6.0",
|
|
63
|
+
"@atlaskit/popup": "^1.7.0",
|
|
63
64
|
"@atlaskit/section-message": "^6.4.0",
|
|
64
65
|
"@atlaskit/side-navigation": "^1.8.0",
|
|
65
66
|
"@atlaskit/ssr": "*",
|
|
@@ -108,5 +109,10 @@
|
|
|
108
109
|
]
|
|
109
110
|
}
|
|
110
111
|
},
|
|
111
|
-
"prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.1"
|
|
112
|
+
"prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.1",
|
|
113
|
+
"platform-feature-flags": {
|
|
114
|
+
"platform.design-system-team.responsive-page-layout-left-sidebar_p8r7g": {
|
|
115
|
+
"type": "boolean"
|
|
116
|
+
}
|
|
117
|
+
}
|
|
112
118
|
}
|
package/report.api.md
CHANGED
|
@@ -116,7 +116,6 @@ export const PageLayout: ({
|
|
|
116
116
|
|
|
117
117
|
// @public (undocumented)
|
|
118
118
|
interface PageLayoutProps extends SidebarResizeControllerProps {
|
|
119
|
-
children: ReactNode;
|
|
120
119
|
// (undocumented)
|
|
121
120
|
skipLinksLabel?: string;
|
|
122
121
|
testId?: string;
|
|
@@ -143,6 +142,7 @@ export const RightSidebar: (props: SlotWidthProps) => jsx.JSX.Element;
|
|
|
143
142
|
|
|
144
143
|
// @public (undocumented)
|
|
145
144
|
type SidebarResizeControllerProps = {
|
|
145
|
+
children: ReactNode;
|
|
146
146
|
onLeftSidebarExpand?: (leftSidebarState: LeftSidebarState) => void;
|
|
147
147
|
onLeftSidebarCollapse?: (leftSidebarState: LeftSidebarState) => void;
|
|
148
148
|
};
|
|
@@ -198,11 +198,12 @@ export const usePageLayoutResize: () => {
|
|
|
198
198
|
isLeftSidebarCollapsed: boolean;
|
|
199
199
|
expandLeftSidebar: () => void;
|
|
200
200
|
collapseLeftSidebar: (
|
|
201
|
-
event?:
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
201
|
+
event?: KeyboardEvent_2 | MouseEvent_2,
|
|
202
|
+
collapseWithoutTransition?: boolean,
|
|
203
|
+
) => void;
|
|
204
|
+
toggleLeftSidebar: (
|
|
205
|
+
event?: KeyboardEvent_2 | MouseEvent_2,
|
|
206
|
+
collapseWithoutTransition?: boolean,
|
|
206
207
|
) => void;
|
|
207
208
|
leftSidebarState: LeftSidebarState;
|
|
208
209
|
};
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
## API Report File for "@atlaskit/page-layout"
|
|
2
|
+
|
|
3
|
+
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
|
|
7
|
+
import { ButtonHTMLAttributes } from 'react';
|
|
8
|
+
import { ElementType } from 'react';
|
|
9
|
+
import { jsx } from '@emotion/react';
|
|
10
|
+
import { KeyboardEvent as KeyboardEvent_2 } from 'react';
|
|
11
|
+
import { MouseEvent as MouseEvent_2 } from 'react';
|
|
12
|
+
import { ReactElement } from 'react';
|
|
13
|
+
import { ReactNode } from 'react';
|
|
14
|
+
|
|
15
|
+
// @public
|
|
16
|
+
export const Banner: (props: SlotHeightProps) => jsx.JSX.Element;
|
|
17
|
+
|
|
18
|
+
// @public (undocumented)
|
|
19
|
+
export const BANNER_HEIGHT: string;
|
|
20
|
+
|
|
21
|
+
// @public
|
|
22
|
+
export const Content: (props: ContentProps) => jsx.JSX.Element;
|
|
23
|
+
|
|
24
|
+
// @public (undocumented)
|
|
25
|
+
interface ContentProps {
|
|
26
|
+
children: ReactNode;
|
|
27
|
+
testId?: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// @public (undocumented)
|
|
31
|
+
type DimensionNames = 'bannerHeight' | 'leftPanelWidth' | 'leftSidebarFlyoutWidth' | 'leftSidebarWidth' | 'rightPanelWidth' | 'rightSidebarWidth' | 'topNavigationHeight';
|
|
32
|
+
|
|
33
|
+
// @public (undocumented)
|
|
34
|
+
export type Dimensions = Partial<Record<DimensionNames, number>>;
|
|
35
|
+
|
|
36
|
+
// @public (undocumented)
|
|
37
|
+
export const LEFT_PANEL_WIDTH: string;
|
|
38
|
+
|
|
39
|
+
// @public (undocumented)
|
|
40
|
+
export const LEFT_SIDEBAR_WIDTH: string;
|
|
41
|
+
|
|
42
|
+
// @public
|
|
43
|
+
export const LeftPanel: (props: SlotWidthProps) => jsx.JSX.Element;
|
|
44
|
+
|
|
45
|
+
// @public
|
|
46
|
+
export const LeftSidebar: (props: LeftSidebarProps) => jsx.JSX.Element;
|
|
47
|
+
|
|
48
|
+
// @public (undocumented)
|
|
49
|
+
interface LeftSidebarProps extends SlotWidthProps {
|
|
50
|
+
collapsedState?: 'collapsed' | 'expanded';
|
|
51
|
+
onCollapse?: () => void;
|
|
52
|
+
onExpand?: () => void;
|
|
53
|
+
onFlyoutCollapse?: () => void;
|
|
54
|
+
onFlyoutExpand?: () => void;
|
|
55
|
+
onResizeEnd?: (leftSidebarState: LeftSidebarState) => void;
|
|
56
|
+
onResizeStart?: (leftSidebarState: LeftSidebarState) => void;
|
|
57
|
+
overrides?: {
|
|
58
|
+
ResizeButton?: {
|
|
59
|
+
render?: (Component: ElementType<ResizeButtonProps>, props: ResizeButtonProps) => ReactElement;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
resizeButtonLabel?: string;
|
|
63
|
+
resizeGrabAreaLabel?: string;
|
|
64
|
+
testId?: string;
|
|
65
|
+
width?: number;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// @public (undocumented)
|
|
69
|
+
export type LeftSidebarState = {
|
|
70
|
+
isFlyoutOpen: boolean;
|
|
71
|
+
isResizing: boolean;
|
|
72
|
+
isLeftSidebarCollapsed: boolean;
|
|
73
|
+
leftSidebarWidth: number;
|
|
74
|
+
lastLeftSidebarWidth: number;
|
|
75
|
+
flyoutLockCount: number;
|
|
76
|
+
isFixed: boolean;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// @public
|
|
80
|
+
export const LeftSidebarWithoutResize: (props: SlotWidthProps) => jsx.JSX.Element;
|
|
81
|
+
|
|
82
|
+
// @public
|
|
83
|
+
export const Main: (props: SlotWidthProps) => jsx.JSX.Element;
|
|
84
|
+
|
|
85
|
+
// @public
|
|
86
|
+
export const PageLayout: ({ skipLinksLabel, children, testId, onLeftSidebarExpand, onLeftSidebarCollapse, }: PageLayoutProps) => jsx.JSX.Element;
|
|
87
|
+
|
|
88
|
+
// @public (undocumented)
|
|
89
|
+
interface PageLayoutProps extends SidebarResizeControllerProps {
|
|
90
|
+
// (undocumented)
|
|
91
|
+
skipLinksLabel?: string;
|
|
92
|
+
testId?: string;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// @public (undocumented)
|
|
96
|
+
type ResizeButtonProps = ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
97
|
+
isLeftSidebarCollapsed: boolean;
|
|
98
|
+
label: string;
|
|
99
|
+
testId?: string;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
// @public (undocumented)
|
|
103
|
+
export const RIGHT_PANEL_WIDTH: string;
|
|
104
|
+
|
|
105
|
+
// @public (undocumented)
|
|
106
|
+
export const RIGHT_SIDEBAR_WIDTH: string;
|
|
107
|
+
|
|
108
|
+
// @public
|
|
109
|
+
export const RightPanel: (props: SlotWidthProps) => jsx.JSX.Element;
|
|
110
|
+
|
|
111
|
+
// @public
|
|
112
|
+
export const RightSidebar: (props: SlotWidthProps) => jsx.JSX.Element;
|
|
113
|
+
|
|
114
|
+
// @public (undocumented)
|
|
115
|
+
type SidebarResizeControllerProps = {
|
|
116
|
+
children: ReactNode;
|
|
117
|
+
onLeftSidebarExpand?: (leftSidebarState: LeftSidebarState) => void;
|
|
118
|
+
onLeftSidebarCollapse?: (leftSidebarState: LeftSidebarState) => void;
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
// @public (undocumented)
|
|
122
|
+
type SkipLinkData = {
|
|
123
|
+
id: string;
|
|
124
|
+
skipLinkTitle: string;
|
|
125
|
+
listIndex?: number;
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
// @public (undocumented)
|
|
129
|
+
export interface SlotHeightProps extends SlotProps {
|
|
130
|
+
height?: number;
|
|
131
|
+
shouldPersistHeight?: boolean;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// @public (undocumented)
|
|
135
|
+
interface SlotProps {
|
|
136
|
+
children: ReactNode;
|
|
137
|
+
// (undocumented)
|
|
138
|
+
id?: string;
|
|
139
|
+
isFixed?: boolean;
|
|
140
|
+
// (undocumented)
|
|
141
|
+
skipLinkTitle?: string;
|
|
142
|
+
testId?: string;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// @public (undocumented)
|
|
146
|
+
export interface SlotWidthProps extends SlotProps {
|
|
147
|
+
shouldPersistWidth?: boolean;
|
|
148
|
+
width?: number;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// @public (undocumented)
|
|
152
|
+
export const TOP_NAVIGATION_HEIGHT: string;
|
|
153
|
+
|
|
154
|
+
// @public
|
|
155
|
+
export const TopNavigation: (props: SlotHeightProps) => jsx.JSX.Element;
|
|
156
|
+
|
|
157
|
+
// @public (undocumented)
|
|
158
|
+
export const useCustomSkipLink: (id: SkipLinkData['id'], skipLinkTitle: SkipLinkData['skipLinkTitle'], listIndex?: SkipLinkData['listIndex']) => void;
|
|
159
|
+
|
|
160
|
+
// @public
|
|
161
|
+
export const useLeftSidebarFlyoutLock: () => void;
|
|
162
|
+
|
|
163
|
+
// @public (undocumented)
|
|
164
|
+
export const usePageLayoutResize: () => {
|
|
165
|
+
isLeftSidebarCollapsed: boolean;
|
|
166
|
+
expandLeftSidebar: () => void;
|
|
167
|
+
collapseLeftSidebar: (event?: KeyboardEvent_2 | MouseEvent_2, collapseWithoutTransition?: boolean) => void;
|
|
168
|
+
toggleLeftSidebar: (event?: KeyboardEvent_2 | MouseEvent_2, collapseWithoutTransition?: boolean) => void;
|
|
169
|
+
leftSidebarState: LeftSidebarState;
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
// (No @packageDocumentation comment for this package)
|
|
173
|
+
|
|
174
|
+
```
|