@atlaskit/page-layout 1.3.8 → 1.3.10
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 +13 -0
- package/dist/cjs/common/constants.js +8 -4
- package/dist/cjs/common/hooks/index.js +0 -3
- package/dist/cjs/common/hooks/use-is-sidebar-collapsing.js +3 -12
- package/dist/cjs/common/hooks/use-is-sidebar-dragging.js +3 -12
- package/dist/cjs/common/safe-local-storage.js +2 -13
- package/dist/cjs/common/utils.js +0 -35
- package/dist/cjs/components/index.js +0 -13
- package/dist/cjs/components/resize-control/grab-area.js +8 -17
- package/dist/cjs/components/resize-control/index.js +33 -84
- package/dist/cjs/components/resize-control/resize-button.js +9 -24
- package/dist/cjs/components/resize-control/shadow.js +3 -7
- package/dist/cjs/components/skip-links/index.js +0 -2
- package/dist/cjs/components/skip-links/skip-link-components.js +18 -48
- package/dist/cjs/components/skip-links/use-custom-skip-link.js +3 -8
- package/dist/cjs/components/slots/banner-slot.js +10 -21
- package/dist/cjs/components/slots/content.js +3 -6
- package/dist/cjs/components/slots/internal/left-sidebar-inner.js +9 -14
- package/dist/cjs/components/slots/internal/left-sidebar-outer.js +10 -22
- package/dist/cjs/components/slots/internal/resizable-children-wrapper.js +10 -15
- package/dist/cjs/components/slots/internal/slot-focus-ring.js +5 -8
- package/dist/cjs/components/slots/left-panel.js +9 -20
- package/dist/cjs/components/slots/left-sidebar-without-resize.js +6 -18
- package/dist/cjs/components/slots/left-sidebar.js +39 -75
- package/dist/cjs/components/slots/main.js +9 -23
- package/dist/cjs/components/slots/page-layout.js +7 -16
- package/dist/cjs/components/slots/right-panel.js +9 -20
- package/dist/cjs/components/slots/right-sidebar.js +9 -21
- package/dist/cjs/components/slots/slot-dimensions.js +1 -5
- package/dist/cjs/components/slots/top-navigation.js +10 -21
- package/dist/cjs/controllers/index.js +0 -6
- package/dist/cjs/controllers/sidebar-resize-context.js +6 -21
- package/dist/cjs/controllers/sidebar-resize-controller.js +34 -50
- package/dist/cjs/controllers/skip-link-context.js +2 -12
- package/dist/cjs/controllers/skip-link-controller.js +6 -22
- package/dist/cjs/controllers/use-page-layout-grid.js +6 -12
- package/dist/cjs/controllers/use-update-css-vars.js +0 -3
- package/dist/cjs/index.js +0 -3
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/common/constants.js +8 -4
- package/dist/es2019/common/hooks/use-is-sidebar-collapsing.js +0 -4
- package/dist/es2019/common/hooks/use-is-sidebar-dragging.js +0 -4
- package/dist/es2019/common/safe-local-storage.js +2 -12
- package/dist/es2019/common/utils.js +4 -20
- package/dist/es2019/components/resize-control/grab-area.js +7 -8
- package/dist/es2019/components/resize-control/index.js +26 -43
- package/dist/es2019/components/resize-control/resize-button.js +7 -11
- package/dist/es2019/components/resize-control/shadow.js +3 -3
- package/dist/es2019/components/skip-links/skip-link-components.js +16 -31
- package/dist/es2019/components/slots/banner-slot.js +1 -3
- package/dist/es2019/components/slots/content.js +2 -2
- package/dist/es2019/components/slots/internal/left-sidebar-inner.js +5 -5
- package/dist/es2019/components/slots/internal/left-sidebar-outer.js +1 -4
- package/dist/es2019/components/slots/internal/resizable-children-wrapper.js +4 -4
- package/dist/es2019/components/slots/internal/slot-focus-ring.js +3 -3
- package/dist/es2019/components/slots/left-panel.js +1 -3
- package/dist/es2019/components/slots/left-sidebar-without-resize.js +1 -2
- package/dist/es2019/components/slots/left-sidebar.js +25 -40
- package/dist/es2019/components/slots/main.js +4 -5
- package/dist/es2019/components/slots/page-layout.js +1 -3
- package/dist/es2019/components/slots/right-panel.js +1 -3
- package/dist/es2019/components/slots/right-sidebar.js +3 -5
- package/dist/es2019/components/slots/top-navigation.js +1 -3
- package/dist/es2019/controllers/sidebar-resize-context.js +7 -5
- package/dist/es2019/controllers/sidebar-resize-controller.js +14 -16
- package/dist/es2019/controllers/skip-link-context.js +0 -1
- package/dist/es2019/controllers/skip-link-controller.js +3 -7
- package/dist/es2019/controllers/use-page-layout-grid.js +4 -5
- package/dist/es2019/controllers/use-update-css-vars.js +0 -2
- package/dist/es2019/version.json +1 -1
- package/dist/esm/common/constants.js +8 -4
- package/dist/esm/common/hooks/use-is-sidebar-collapsing.js +3 -8
- package/dist/esm/common/hooks/use-is-sidebar-dragging.js +3 -8
- package/dist/esm/common/safe-local-storage.js +2 -12
- package/dist/esm/common/utils.js +0 -22
- package/dist/esm/components/resize-control/grab-area.js +9 -14
- package/dist/esm/components/resize-control/index.js +33 -72
- package/dist/esm/components/resize-control/resize-button.js +10 -15
- package/dist/esm/components/resize-control/shadow.js +3 -3
- package/dist/esm/components/skip-links/skip-link-components.js +19 -39
- package/dist/esm/components/skip-links/use-custom-skip-link.js +2 -4
- package/dist/esm/components/slots/banner-slot.js +9 -11
- package/dist/esm/components/slots/content.js +3 -3
- package/dist/esm/components/slots/internal/left-sidebar-inner.js +9 -9
- package/dist/esm/components/slots/internal/left-sidebar-outer.js +9 -12
- package/dist/esm/components/slots/internal/resizable-children-wrapper.js +10 -10
- package/dist/esm/components/slots/internal/slot-focus-ring.js +5 -5
- package/dist/esm/components/slots/left-panel.js +8 -10
- package/dist/esm/components/slots/left-sidebar-without-resize.js +7 -9
- package/dist/esm/components/slots/left-sidebar.js +40 -65
- package/dist/esm/components/slots/main.js +10 -13
- package/dist/esm/components/slots/page-layout.js +6 -10
- package/dist/esm/components/slots/right-panel.js +8 -10
- package/dist/esm/components/slots/right-sidebar.js +10 -12
- package/dist/esm/components/slots/slot-dimensions.js +1 -1
- package/dist/esm/components/slots/top-navigation.js +9 -11
- package/dist/esm/controllers/sidebar-resize-context.js +6 -11
- package/dist/esm/controllers/sidebar-resize-controller.js +34 -38
- package/dist/esm/controllers/skip-link-context.js +2 -4
- package/dist/esm/controllers/skip-link-controller.js +6 -12
- package/dist/esm/controllers/use-page-layout-grid.js +6 -8
- package/dist/esm/controllers/use-update-css-vars.js +0 -2
- package/dist/esm/version.json +1 -1
- package/dist/types/common/types.d.ts +4 -4
- package/dist/types/controllers/skip-link-controller.d.ts +4 -2
- package/package.json +10 -9
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
3
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
|
-
|
|
5
4
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
6
|
-
|
|
7
5
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
8
|
-
|
|
9
6
|
/** @jsx jsx */
|
|
10
7
|
import { useCallback, useContext, useMemo, useRef, useState } from 'react';
|
|
11
8
|
import { css, jsx } from '@emotion/react';
|
|
@@ -19,9 +16,7 @@ import { SidebarResizeContext } from '../../controllers/sidebar-resize-context';
|
|
|
19
16
|
import GrabArea from './grab-area';
|
|
20
17
|
import ResizeButton from './resize-button';
|
|
21
18
|
import Shadow from './shadow';
|
|
22
|
-
|
|
23
19
|
var cssSelector = _defineProperty({}, RESIZE_CONTROL_SELECTOR, true);
|
|
24
|
-
|
|
25
20
|
var resizeControlStyles = css({
|
|
26
21
|
position: 'absolute',
|
|
27
22
|
top: 0,
|
|
@@ -32,62 +27,52 @@ var resizeControlStyles = css({
|
|
|
32
27
|
var showResizeButtonStyles = css({
|
|
33
28
|
'--ds--resize-button--opacity': 1
|
|
34
29
|
});
|
|
35
|
-
|
|
36
30
|
var ResizeControl = function ResizeControl(_ref) {
|
|
37
31
|
var testId = _ref.testId,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
32
|
+
overrides = _ref.overrides,
|
|
33
|
+
_ref$resizeButtonLabe = _ref.resizeButtonLabel,
|
|
34
|
+
resizeButtonLabel = _ref$resizeButtonLabe === void 0 ? '' : _ref$resizeButtonLabe,
|
|
35
|
+
_ref$resizeGrabAreaLa = _ref.resizeGrabAreaLabel,
|
|
36
|
+
resizeGrabAreaLabel = _ref$resizeGrabAreaLa === void 0 ? 'Resize' : _ref$resizeGrabAreaLa,
|
|
37
|
+
onResizeStart = _ref.onResizeStart,
|
|
38
|
+
onResizeEnd = _ref.onResizeEnd;
|
|
46
39
|
var _useContext = useContext(SidebarResizeContext),
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
40
|
+
expandLeftSidebar = _useContext.expandLeftSidebar,
|
|
41
|
+
collapseLeftSidebar = _useContext.collapseLeftSidebar,
|
|
42
|
+
leftSidebarState = _useContext.leftSidebarState,
|
|
43
|
+
setLeftSidebarState = _useContext.setLeftSidebarState;
|
|
52
44
|
var isLeftSidebarCollapsed = leftSidebarState.isLeftSidebarCollapsed,
|
|
53
|
-
|
|
54
|
-
var x = useRef(leftSidebarState[VAR_LEFT_SIDEBAR_WIDTH]);
|
|
55
|
-
|
|
45
|
+
isResizing = leftSidebarState.isResizing;
|
|
46
|
+
var x = useRef(leftSidebarState[VAR_LEFT_SIDEBAR_WIDTH]);
|
|
47
|
+
// Distance of mouse from left sidebar onMouseDown
|
|
56
48
|
var offset = useRef(0);
|
|
57
49
|
var keyboardEventTimeout = useRef();
|
|
58
|
-
|
|
59
50
|
var _useState = useState(false),
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
51
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
52
|
+
isGrabAreaFocused = _useState2[0],
|
|
53
|
+
setIsGrabAreaFocused = _useState2[1];
|
|
64
54
|
var unbindEvents = useRef(null);
|
|
65
|
-
|
|
66
55
|
var toggleSideBar = function toggleSideBar(e) {
|
|
67
56
|
if (isResizing) {
|
|
68
57
|
return;
|
|
69
58
|
}
|
|
70
|
-
|
|
71
59
|
if (isLeftSidebarCollapsed) {
|
|
72
60
|
expandLeftSidebar();
|
|
73
61
|
} else {
|
|
74
62
|
collapseLeftSidebar();
|
|
75
|
-
}
|
|
76
|
-
// "clicked" using enter/space on keyboard.
|
|
77
|
-
|
|
63
|
+
}
|
|
78
64
|
|
|
65
|
+
// Bring focus to the resize button if the grab area is
|
|
66
|
+
// "clicked" using enter/space on keyboard.
|
|
79
67
|
if (e && e.nativeEvent.detail === 0) {
|
|
80
68
|
var _resizeButton = document.querySelector("[".concat(RESIZE_BUTTON_SELECTOR, "]"));
|
|
81
|
-
|
|
82
69
|
_resizeButton && _resizeButton.focus();
|
|
83
70
|
}
|
|
84
71
|
};
|
|
85
|
-
|
|
86
72
|
var onMouseDown = function onMouseDown(event) {
|
|
87
73
|
if (isLeftSidebarCollapsed) {
|
|
88
74
|
return;
|
|
89
75
|
}
|
|
90
|
-
|
|
91
76
|
offset.current = event.clientX - leftSidebarState[VAR_LEFT_SIDEBAR_WIDTH] - getLeftPanelWidth();
|
|
92
77
|
unbindEvents.current = bindAll(document, [{
|
|
93
78
|
type: 'mousemove',
|
|
@@ -97,18 +82,14 @@ var ResizeControl = function ResizeControl(_ref) {
|
|
|
97
82
|
listener: onMouseUp
|
|
98
83
|
}]);
|
|
99
84
|
document.documentElement.setAttribute(IS_SIDEBAR_DRAGGING, 'true');
|
|
100
|
-
|
|
101
85
|
var newLeftbarState = _objectSpread(_objectSpread({}, leftSidebarState), {}, {
|
|
102
86
|
isResizing: true
|
|
103
87
|
});
|
|
104
|
-
|
|
105
88
|
setLeftSidebarState(newLeftbarState);
|
|
106
89
|
onResizeStart && onResizeStart(newLeftbarState);
|
|
107
90
|
};
|
|
108
|
-
|
|
109
91
|
var cancelDrag = function cancelDrag(shouldCollapse) {
|
|
110
92
|
var _unbindEvents$current;
|
|
111
|
-
|
|
112
93
|
onMouseMove.cancel();
|
|
113
94
|
(_unbindEvents$current = unbindEvents.current) === null || _unbindEvents$current === void 0 ? void 0 : _unbindEvents$current.call(unbindEvents);
|
|
114
95
|
unbindEvents.current = null;
|
|
@@ -116,51 +97,44 @@ var ResizeControl = function ResizeControl(_ref) {
|
|
|
116
97
|
offset.current = 0;
|
|
117
98
|
collapseLeftSidebar(undefined, true);
|
|
118
99
|
};
|
|
119
|
-
|
|
120
100
|
var onMouseMove = rafSchd(function (event) {
|
|
121
101
|
// Allow the sidebar to be 50% of the available page width
|
|
122
102
|
var maxWidth = Math.round(window.innerWidth / 2);
|
|
123
103
|
var leftPanelWidth = getLeftPanelWidth();
|
|
124
104
|
var leftSidebarWidth = leftSidebarState.leftSidebarWidth;
|
|
125
105
|
var invalidDrag = event.clientX < 0;
|
|
126
|
-
|
|
127
106
|
if (invalidDrag) {
|
|
128
107
|
cancelDrag();
|
|
129
108
|
}
|
|
130
|
-
|
|
131
109
|
var delta = Math.max(Math.min(event.clientX - leftSidebarWidth - leftPanelWidth, maxWidth - leftSidebarWidth - leftPanelWidth), COLLAPSED_LEFT_SIDEBAR_WIDTH - leftSidebarWidth - leftPanelWidth);
|
|
132
110
|
x.current = Math.max(leftSidebarWidth + delta - offset.current, COLLAPSED_LEFT_SIDEBAR_WIDTH);
|
|
133
111
|
document.documentElement.style.setProperty("--".concat(VAR_LEFT_SIDEBAR_WIDTH), "".concat(x.current, "px"));
|
|
134
112
|
});
|
|
135
|
-
|
|
136
113
|
var cleanupAfterResize = function cleanupAfterResize() {
|
|
137
114
|
var _unbindEvents$current2;
|
|
138
|
-
|
|
139
115
|
x.current = 0;
|
|
140
116
|
offset.current = 0;
|
|
141
117
|
(_unbindEvents$current2 = unbindEvents.current) === null || _unbindEvents$current2 === void 0 ? void 0 : _unbindEvents$current2.call(unbindEvents);
|
|
142
118
|
unbindEvents.current = null;
|
|
143
119
|
};
|
|
144
|
-
|
|
145
120
|
var updatedLeftSidebarState = {};
|
|
146
|
-
|
|
147
121
|
var onMouseUp = function onMouseUp(event) {
|
|
148
122
|
if (isLeftSidebarCollapsed) {
|
|
149
123
|
return;
|
|
150
124
|
}
|
|
125
|
+
document.documentElement.removeAttribute(IS_SIDEBAR_DRAGGING);
|
|
151
126
|
|
|
152
|
-
|
|
127
|
+
// If it is dragged to below the threshold,
|
|
153
128
|
// collapse the navigation
|
|
154
|
-
|
|
155
129
|
if (x.current < MIN_LEFT_SIDEBAR_DRAG_THRESHOLD) {
|
|
156
130
|
document.documentElement.style.setProperty("--".concat(VAR_LEFT_SIDEBAR_WIDTH), "".concat(COLLAPSED_LEFT_SIDEBAR_WIDTH, "px"));
|
|
157
131
|
collapseLeftSidebar(undefined, true);
|
|
158
|
-
}
|
|
132
|
+
}
|
|
133
|
+
// If it is dragged to position in between the
|
|
159
134
|
// min threshold and default width
|
|
160
135
|
// expand the nav to the default width
|
|
161
136
|
else if (x.current > MIN_LEFT_SIDEBAR_DRAG_THRESHOLD && x.current < DEFAULT_LEFT_SIDEBAR_WIDTH) {
|
|
162
137
|
var _objectSpread2;
|
|
163
|
-
|
|
164
138
|
document.documentElement.style.setProperty("--".concat(VAR_LEFT_SIDEBAR_WIDTH), "".concat(DEFAULT_LEFT_SIDEBAR_WIDTH, "px"));
|
|
165
139
|
updatedLeftSidebarState = _objectSpread(_objectSpread({}, leftSidebarState), {}, (_objectSpread2 = {
|
|
166
140
|
isResizing: false
|
|
@@ -168,14 +142,12 @@ var ResizeControl = function ResizeControl(_ref) {
|
|
|
168
142
|
setLeftSidebarState(updatedLeftSidebarState);
|
|
169
143
|
} else {
|
|
170
144
|
var _objectSpread3;
|
|
171
|
-
|
|
172
145
|
// otherwise resize it to the desired width
|
|
173
146
|
updatedLeftSidebarState = _objectSpread(_objectSpread({}, leftSidebarState), {}, (_objectSpread3 = {
|
|
174
147
|
isResizing: false
|
|
175
148
|
}, _defineProperty(_objectSpread3, VAR_LEFT_SIDEBAR_WIDTH, x.current), _defineProperty(_objectSpread3, "lastLeftSidebarWidth", x.current), _objectSpread3));
|
|
176
149
|
setLeftSidebarState(updatedLeftSidebarState);
|
|
177
150
|
}
|
|
178
|
-
|
|
179
151
|
requestAnimationFrame(function () {
|
|
180
152
|
onMouseMove.cancel();
|
|
181
153
|
setIsGrabAreaFocused(false);
|
|
@@ -183,25 +155,20 @@ var ResizeControl = function ResizeControl(_ref) {
|
|
|
183
155
|
cleanupAfterResize();
|
|
184
156
|
});
|
|
185
157
|
};
|
|
186
|
-
|
|
187
158
|
var onKeyDown = function onKeyDown(event) {
|
|
188
159
|
if (isLeftSidebarCollapsed || !isGrabAreaFocused) {
|
|
189
160
|
return false;
|
|
190
161
|
}
|
|
191
|
-
|
|
192
162
|
var key = event.key;
|
|
193
163
|
var isLeftOrTopArrow = key === 'ArrowLeft' || key === 'ArrowUp' || key === 'Left' || key === 'Up';
|
|
194
164
|
var isRightOrBottomArrow = key === 'ArrowRight' || key === 'ArrowDown' || key === 'Right' || key === 'Down';
|
|
195
165
|
var isSpaceOrEnter = key === 'Enter' || key === 'Spacebar' || key === ' ';
|
|
196
|
-
|
|
197
166
|
if (isSpaceOrEnter) {
|
|
198
167
|
toggleSideBar(event);
|
|
199
168
|
event.preventDefault();
|
|
200
169
|
}
|
|
201
|
-
|
|
202
170
|
if (isLeftOrTopArrow || isRightOrBottomArrow) {
|
|
203
171
|
event.preventDefault(); // prevent content scroll
|
|
204
|
-
|
|
205
172
|
onResizeStart && onResizeStart(leftSidebarState);
|
|
206
173
|
var step = 10;
|
|
207
174
|
var stepValue = isLeftOrTopArrow ? -step : step;
|
|
@@ -209,7 +176,6 @@ var ResizeControl = function ResizeControl(_ref) {
|
|
|
209
176
|
var maxWidth = Math.round(window.innerWidth / 2) - getLeftPanelWidth();
|
|
210
177
|
var hasModifierKey = event.metaKey || event.altKey || event.ctrlKey || event.shiftKey;
|
|
211
178
|
var width = leftSidebarWidth + stepValue;
|
|
212
|
-
|
|
213
179
|
if (width <= DEFAULT_LEFT_SIDEBAR_WIDTH) {
|
|
214
180
|
width = DEFAULT_LEFT_SIDEBAR_WIDTH;
|
|
215
181
|
document.documentElement.style.setProperty("--".concat(VAR_LEFT_SIDEBAR_WIDTH), "".concat(DEFAULT_LEFT_SIDEBAR_WIDTH - 20, "px"));
|
|
@@ -218,49 +184,44 @@ var ResizeControl = function ResizeControl(_ref) {
|
|
|
218
184
|
document.documentElement.style.setProperty("--".concat(VAR_LEFT_SIDEBAR_WIDTH), "".concat(maxWidth + 20, "px"));
|
|
219
185
|
} else if (hasModifierKey) {
|
|
220
186
|
width = isRightOrBottomArrow ? maxWidth : DEFAULT_LEFT_SIDEBAR_WIDTH;
|
|
221
|
-
}
|
|
222
|
-
// the browser schedule the setTimeout call in an efficient manner
|
|
223
|
-
|
|
187
|
+
}
|
|
224
188
|
|
|
189
|
+
// Nesting the setTimeout within requestAnimationFrame helps
|
|
190
|
+
// the browser schedule the setTimeout call in an efficient manner
|
|
225
191
|
requestAnimationFrame(function () {
|
|
226
192
|
keyboardEventTimeout.current = window.setTimeout(function () {
|
|
227
193
|
var _objectSpread4;
|
|
228
|
-
|
|
229
194
|
keyboardEventTimeout.current && clearTimeout(keyboardEventTimeout.current);
|
|
230
195
|
document.documentElement.style.setProperty("--".concat(VAR_LEFT_SIDEBAR_WIDTH), "".concat(width, "px"));
|
|
231
|
-
|
|
232
196
|
var updatedLeftSidebarState = _objectSpread(_objectSpread({}, leftSidebarState), {}, (_objectSpread4 = {}, _defineProperty(_objectSpread4, VAR_LEFT_SIDEBAR_WIDTH, width), _defineProperty(_objectSpread4, "lastLeftSidebarWidth", width), _objectSpread4));
|
|
233
|
-
|
|
234
197
|
setLeftSidebarState(updatedLeftSidebarState);
|
|
235
198
|
onResizeEnd && onResizeEnd(updatedLeftSidebarState);
|
|
236
199
|
}, 50);
|
|
237
200
|
});
|
|
238
201
|
}
|
|
239
202
|
};
|
|
240
|
-
|
|
241
203
|
var onFocus = useCallback(function () {
|
|
242
204
|
setIsGrabAreaFocused(true);
|
|
243
205
|
}, []);
|
|
244
206
|
var onBlur = useCallback(function () {
|
|
245
207
|
setIsGrabAreaFocused(false);
|
|
246
208
|
}, []);
|
|
247
|
-
|
|
248
209
|
var resizeButton = _objectSpread({
|
|
249
210
|
render: function render(Component, props) {
|
|
250
211
|
return jsx(Component, props);
|
|
251
212
|
}
|
|
252
|
-
}, overrides && overrides.ResizeButton);
|
|
213
|
+
}, overrides && overrides.ResizeButton);
|
|
214
|
+
|
|
215
|
+
// This width is calculated once only on mount.
|
|
253
216
|
// This means resizing the window will cause this value to be incorrect for screen reader users,
|
|
254
217
|
// however this comes with a substantial performance gain and so is considered acceptable.
|
|
255
|
-
|
|
256
|
-
|
|
257
218
|
var maxAriaWidth = useMemo(function () {
|
|
258
219
|
var innerWidth = typeof window === 'undefined' ? 0 : window.innerWidth;
|
|
259
220
|
return Math.round(innerWidth / 2) - getLeftPanelWidth();
|
|
260
221
|
}, []);
|
|
261
222
|
var leftSidebarPercentageExpanded = getLeftSidebarPercentage(leftSidebarState.leftSidebarWidth, maxAriaWidth);
|
|
262
|
-
/* eslint-disable jsx-a11y/role-supports-aria-props */
|
|
263
223
|
|
|
224
|
+
/* eslint-disable jsx-a11y/role-supports-aria-props */
|
|
264
225
|
return jsx("div", _extends({}, cssSelector, {
|
|
265
226
|
css: [resizeControlStyles, (isGrabAreaFocused || isLeftSidebarCollapsed) && showResizeButtonStyles]
|
|
266
227
|
}), jsx(Shadow, {
|
|
@@ -286,7 +247,7 @@ var ResizeControl = function ResizeControl(_ref) {
|
|
|
286
247
|
testId: testId && "".concat(testId, "-resize-button")
|
|
287
248
|
}));
|
|
288
249
|
/* eslint-enable jsx-a11y/role-supports-aria-props */
|
|
289
|
-
};
|
|
290
|
-
|
|
250
|
+
};
|
|
291
251
|
|
|
252
|
+
// eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
292
253
|
export default ResizeControl;
|
|
@@ -2,8 +2,8 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
3
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
4
|
var _excluded = ["isLeftSidebarCollapsed", "label", "testId"];
|
|
5
|
-
|
|
6
5
|
/** @jsx jsx */
|
|
6
|
+
|
|
7
7
|
import { css, jsx } from '@emotion/react';
|
|
8
8
|
import ChevronRight from '@atlaskit/icon/glyph/chevron-right';
|
|
9
9
|
import { easeOut } from '@atlaskit/motion/curves';
|
|
@@ -27,7 +27,6 @@ var resizeIconButtonStyles = css({
|
|
|
27
27
|
backgroundColor: "var(--ds-surface-overlay, ".concat(N0, ")"),
|
|
28
28
|
border: 0,
|
|
29
29
|
borderRadius: '50%',
|
|
30
|
-
|
|
31
30
|
/**
|
|
32
31
|
* TODO: https://product-fabric.atlassian.net/browse/DSP-3392
|
|
33
32
|
* This shadow needs further investigation,
|
|
@@ -37,7 +36,6 @@ var resizeIconButtonStyles = css({
|
|
|
37
36
|
boxShadow: "0 0 0 1px ".concat(N30A, ", 0 2px 4px 1px ").concat(N30A),
|
|
38
37
|
color: "var(--ds-text-subtle, ".concat(N200, ")"),
|
|
39
38
|
cursor: 'pointer',
|
|
40
|
-
|
|
41
39
|
/**
|
|
42
40
|
* The fallback value of 0 ensures that the button is hidden by default,
|
|
43
41
|
* unless some parent (or the button itself) overrides it.
|
|
@@ -61,36 +59,33 @@ var resizeIconButtonExpandedStyles = css({
|
|
|
61
59
|
transform: 'rotate(180deg)',
|
|
62
60
|
transformOrigin: 7
|
|
63
61
|
});
|
|
64
|
-
|
|
65
62
|
var preventDefault = function preventDefault(event) {
|
|
66
63
|
return event.preventDefault();
|
|
67
64
|
};
|
|
68
|
-
|
|
69
65
|
var cssSelector = _defineProperty({}, RESIZE_BUTTON_SELECTOR, true);
|
|
70
|
-
|
|
71
66
|
var ResizeButton = function ResizeButton(_ref) {
|
|
72
67
|
var isLeftSidebarCollapsed = _ref.isLeftSidebarCollapsed,
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
68
|
+
label = _ref.label,
|
|
69
|
+
testId = _ref.testId,
|
|
70
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
77
71
|
return jsx("button", _extends({}, cssSelector, {
|
|
78
72
|
// DO NOT remove. used as a CSS selector.
|
|
79
73
|
"aria-expanded": !isLeftSidebarCollapsed,
|
|
80
74
|
"aria-label": label,
|
|
81
75
|
type: "button",
|
|
82
76
|
css: [resizeIconButtonStyles, !isLeftSidebarCollapsed && resizeIconButtonExpandedStyles],
|
|
83
|
-
"data-testid": testId
|
|
77
|
+
"data-testid": testId
|
|
78
|
+
// Prevents focus staying attached to the button
|
|
84
79
|
// when pressed
|
|
85
80
|
,
|
|
86
|
-
onMouseDown: preventDefault
|
|
87
|
-
|
|
81
|
+
onMouseDown: preventDefault
|
|
82
|
+
// eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
|
|
88
83
|
}, props), jsx(ChevronRight, {
|
|
89
84
|
label: ""
|
|
90
85
|
}), jsx("div", {
|
|
91
86
|
css: increaseHitAreaStyles
|
|
92
87
|
}));
|
|
93
|
-
};
|
|
94
|
-
|
|
88
|
+
};
|
|
95
89
|
|
|
90
|
+
// eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
96
91
|
export default ResizeButton;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
+
|
|
2
3
|
import { css, jsx } from '@emotion/react';
|
|
3
4
|
import { easeOut } from '@atlaskit/motion';
|
|
4
5
|
import { useIsSidebarDragging } from '../../common/hooks';
|
|
@@ -24,7 +25,6 @@ var draggingStyles = css({
|
|
|
24
25
|
background: "var(--ds-background-neutral-subtle, ".concat("linear-gradient(".concat(direction, ", ").concat(colorStops, ")"), ")"),
|
|
25
26
|
opacity: 0.8
|
|
26
27
|
});
|
|
27
|
-
|
|
28
28
|
var Shadow = function Shadow(_ref) {
|
|
29
29
|
var testId = _ref.testId;
|
|
30
30
|
var isDragging = useIsSidebarDragging();
|
|
@@ -32,7 +32,7 @@ var Shadow = function Shadow(_ref) {
|
|
|
32
32
|
"data-testid": testId,
|
|
33
33
|
css: [shadowStyles, isDragging && draggingStyles]
|
|
34
34
|
});
|
|
35
|
-
};
|
|
36
|
-
|
|
35
|
+
};
|
|
37
36
|
|
|
37
|
+
// eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
38
38
|
export default Shadow;
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
-
|
|
4
3
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
5
|
-
|
|
6
4
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
7
|
-
|
|
8
5
|
/* eslint-disable @repo/internal/dom-events/no-unsafe-event-listeners */
|
|
9
|
-
|
|
10
6
|
/** @jsx jsx */
|
|
7
|
+
|
|
11
8
|
import { css, jsx } from '@emotion/react';
|
|
12
9
|
import { easeOut, prefersReducedMotion } from '@atlaskit/motion';
|
|
13
10
|
import { N30A, N60A } from '@atlaskit/theme/colors';
|
|
@@ -26,7 +23,6 @@ var skipLinkStyles = css({
|
|
|
26
23
|
borderRadius: 3,
|
|
27
24
|
boxShadow: "var(--ds-shadow-overlay, ".concat("0 0 0 1px ".concat(N30A, ", 0 2px 10px ").concat(N30A, ", 0 0 20px -4px ").concat(N60A), ")"),
|
|
28
25
|
opacity: 0,
|
|
29
|
-
|
|
30
26
|
/* Do the transform when focused */
|
|
31
27
|
transform: 'translateY(-50%)',
|
|
32
28
|
transition: "transform 0.3s ".concat(easeOut),
|
|
@@ -53,14 +49,13 @@ var skipLinkListStyles = css({
|
|
|
53
49
|
var skipLinkListItemStyles = css({
|
|
54
50
|
marginTop: 0
|
|
55
51
|
});
|
|
56
|
-
|
|
57
52
|
var assignIndex = function assignIndex(num, arr) {
|
|
58
53
|
if (!arr.includes(num)) {
|
|
59
54
|
return num;
|
|
60
55
|
}
|
|
61
|
-
|
|
62
56
|
return assignIndex(num + 1, arr);
|
|
63
57
|
};
|
|
58
|
+
|
|
64
59
|
/**
|
|
65
60
|
* The default label will be used when the `skipLinksLabel` attribute is not
|
|
66
61
|
* provided or the attribute is an empty string. If a string comprised only of
|
|
@@ -68,27 +63,20 @@ var assignIndex = function assignIndex(num, arr) {
|
|
|
68
63
|
* default label will still be used in `title` attribute of the skip links
|
|
69
64
|
* themselves.
|
|
70
65
|
*/
|
|
71
|
-
|
|
72
|
-
|
|
73
66
|
export var SkipLinkWrapper = function SkipLinkWrapper(_ref) {
|
|
74
67
|
var skipLinksLabel = _ref.skipLinksLabel;
|
|
75
|
-
|
|
76
68
|
var _useSkipLinks = useSkipLinks(),
|
|
77
|
-
|
|
78
|
-
|
|
69
|
+
skipLinksData = _useSkipLinks.skipLinksData;
|
|
79
70
|
if (skipLinksData.length === 0) {
|
|
80
71
|
return null;
|
|
81
72
|
}
|
|
82
|
-
|
|
83
73
|
var sortSkipLinks = function sortSkipLinks(arr) {
|
|
84
74
|
var customLinks = arr.filter(function (link) {
|
|
85
75
|
return Number.isInteger(link.listIndex);
|
|
86
76
|
});
|
|
87
|
-
|
|
88
77
|
if (customLinks.length === 0) {
|
|
89
78
|
return arr;
|
|
90
79
|
}
|
|
91
|
-
|
|
92
80
|
var usedIndexes = customLinks.map(function (a) {
|
|
93
81
|
return a.listIndex;
|
|
94
82
|
});
|
|
@@ -105,25 +93,20 @@ export var SkipLinkWrapper = function SkipLinkWrapper(_ref) {
|
|
|
105
93
|
return a.listIndex - b.listIndex;
|
|
106
94
|
});
|
|
107
95
|
};
|
|
108
|
-
|
|
109
96
|
var escapeHandler = function escapeHandler(event) {
|
|
110
97
|
if (event.keyCode === 27) {
|
|
111
98
|
var container = document.querySelector("[".concat(PAGE_LAYOUT_CONTAINER_SELECTOR, "=\"true\"]"));
|
|
112
|
-
|
|
113
99
|
if (container !== null) {
|
|
114
100
|
container.focus();
|
|
115
101
|
}
|
|
116
102
|
}
|
|
117
103
|
};
|
|
118
|
-
|
|
119
104
|
var attachEscHandler = function attachEscHandler() {
|
|
120
105
|
return window.addEventListener('keydown', escapeHandler, false);
|
|
121
106
|
};
|
|
122
|
-
|
|
123
107
|
var removeEscHandler = function removeEscHandler() {
|
|
124
108
|
return window.removeEventListener('keydown', escapeHandler, false);
|
|
125
109
|
};
|
|
126
|
-
|
|
127
110
|
var emptyLabelOverride = !!(skipLinksLabel !== null && skipLinksLabel !== void 0 && skipLinksLabel.match(/^\s+$/));
|
|
128
111
|
var label = skipLinksLabel || DEFAULT_I18N_PROPS_SKIP_LINKS;
|
|
129
112
|
return jsx("div", {
|
|
@@ -137,7 +120,7 @@ export var SkipLinkWrapper = function SkipLinkWrapper(_ref) {
|
|
|
137
120
|
css: skipLinkListStyles
|
|
138
121
|
}, sortSkipLinks(skipLinksData).map(function (_ref2) {
|
|
139
122
|
var id = _ref2.id,
|
|
140
|
-
|
|
123
|
+
skipLinkTitle = _ref2.skipLinkTitle;
|
|
141
124
|
return jsx(SkipLink, {
|
|
142
125
|
key: id,
|
|
143
126
|
href: "#".concat(id),
|
|
@@ -146,48 +129,45 @@ export var SkipLinkWrapper = function SkipLinkWrapper(_ref) {
|
|
|
146
129
|
}, skipLinkTitle);
|
|
147
130
|
})));
|
|
148
131
|
};
|
|
149
|
-
|
|
150
132
|
var handleBlur = function handleBlur(event) {
|
|
151
133
|
// @ts-ignore
|
|
152
|
-
event.target.removeAttribute('tabindex');
|
|
153
|
-
|
|
134
|
+
event.target.removeAttribute('tabindex');
|
|
135
|
+
// @ts-ignore
|
|
154
136
|
event.target.removeEventListener('blur', handleBlur);
|
|
155
137
|
};
|
|
156
|
-
|
|
157
138
|
var focusTargetRef = function focusTargetRef(href) {
|
|
158
139
|
return function (event) {
|
|
159
140
|
event.preventDefault();
|
|
160
|
-
var targetRef = document.querySelector(href);
|
|
141
|
+
var targetRef = document.querySelector(href);
|
|
161
142
|
|
|
162
|
-
|
|
143
|
+
// @ts-ignore
|
|
144
|
+
var key = event.which || event.keycode;
|
|
145
|
+
// if it is a keypress and the key is not
|
|
163
146
|
// space or enter, just ignore it.
|
|
164
|
-
|
|
165
147
|
if (key && key !== 13 && key !== 32) {
|
|
166
148
|
return;
|
|
167
149
|
}
|
|
168
|
-
|
|
169
150
|
if (targetRef) {
|
|
170
|
-
targetRef.setAttribute('tabindex', '-1');
|
|
171
|
-
|
|
172
|
-
targetRef.addEventListener('blur', handleBlur);
|
|
173
|
-
|
|
151
|
+
targetRef.setAttribute('tabindex', '-1');
|
|
152
|
+
// @ts-ignore
|
|
153
|
+
targetRef.addEventListener('blur', handleBlur);
|
|
154
|
+
// @ts-ignore
|
|
174
155
|
targetRef.focus();
|
|
175
156
|
document.activeElement && document.activeElement.scrollIntoView({
|
|
176
157
|
behavior: 'smooth'
|
|
177
158
|
});
|
|
178
159
|
window.scrollTo(0, 0);
|
|
179
160
|
}
|
|
180
|
-
|
|
181
161
|
return false;
|
|
182
162
|
};
|
|
183
|
-
};
|
|
184
|
-
|
|
163
|
+
};
|
|
185
164
|
|
|
165
|
+
// eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
186
166
|
export var SkipLink = function SkipLink(_ref3) {
|
|
187
167
|
var href = _ref3.href,
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
168
|
+
children = _ref3.children,
|
|
169
|
+
isFocusable = _ref3.isFocusable,
|
|
170
|
+
title = _ref3.title;
|
|
191
171
|
return jsx("li", {
|
|
192
172
|
css: skipLinkListItemStyles
|
|
193
173
|
}, jsx("a", {
|
|
@@ -3,11 +3,9 @@ import { useEffect } from 'react';
|
|
|
3
3
|
import { useSkipLinks } from '../../controllers';
|
|
4
4
|
export var useCustomSkipLink = function useCustomSkipLink(id, skipLinkTitle) {
|
|
5
5
|
var listIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
6
|
-
|
|
7
6
|
var _useSkipLinks = useSkipLinks(),
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
registerSkipLink = _useSkipLinks.registerSkipLink,
|
|
8
|
+
unregisterSkipLink = _useSkipLinks.unregisterSkipLink;
|
|
11
9
|
useEffect(function () {
|
|
12
10
|
registerSkipLink({
|
|
13
11
|
id: id,
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
-
|
|
4
3
|
/** @jsx jsx */
|
|
5
4
|
import { useEffect } from 'react';
|
|
6
5
|
import { css, jsx } from '@emotion/react';
|
|
@@ -20,6 +19,7 @@ var bannerFixedStyles = css({
|
|
|
20
19
|
right: RIGHT_PANEL_WIDTH,
|
|
21
20
|
left: LEFT_PANEL_WIDTH
|
|
22
21
|
});
|
|
22
|
+
|
|
23
23
|
/**
|
|
24
24
|
* __Banner__
|
|
25
25
|
*
|
|
@@ -28,17 +28,16 @@ var bannerFixedStyles = css({
|
|
|
28
28
|
* - [Examples](https://atlassian.design/components/page-layout/examples)
|
|
29
29
|
* - [Code](https://atlassian.design/components/page-layout/code)
|
|
30
30
|
*/
|
|
31
|
-
|
|
32
31
|
var Banner = function Banner(props) {
|
|
33
32
|
var children = props.children,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
33
|
+
_props$height = props.height,
|
|
34
|
+
height = _props$height === void 0 ? DEFAULT_BANNER_HEIGHT : _props$height,
|
|
35
|
+
_props$isFixed = props.isFixed,
|
|
36
|
+
isFixed = _props$isFixed === void 0 ? true : _props$isFixed,
|
|
37
|
+
shouldPersistHeight = props.shouldPersistHeight,
|
|
38
|
+
testId = props.testId,
|
|
39
|
+
skipLinkTitle = props.skipLinkTitle,
|
|
40
|
+
id = props.id;
|
|
42
41
|
var bannerHeight = resolveDimension(VAR_BANNER_HEIGHT, height, shouldPersistHeight);
|
|
43
42
|
useEffect(function () {
|
|
44
43
|
publishGridState(_defineProperty({}, VAR_BANNER_HEIGHT, bannerHeight));
|
|
@@ -60,5 +59,4 @@ var Banner = function Banner(props) {
|
|
|
60
59
|
}), children);
|
|
61
60
|
});
|
|
62
61
|
};
|
|
63
|
-
|
|
64
62
|
export default Banner;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
+
|
|
2
3
|
import { css, jsx } from '@emotion/react';
|
|
3
4
|
import { CONTENT } from '../../common/constants';
|
|
4
5
|
var contentStyles = css({
|
|
@@ -7,6 +8,7 @@ var contentStyles = css({
|
|
|
7
8
|
position: 'relative',
|
|
8
9
|
gridArea: CONTENT
|
|
9
10
|
});
|
|
11
|
+
|
|
10
12
|
/**
|
|
11
13
|
* __Content__
|
|
12
14
|
*
|
|
@@ -15,14 +17,12 @@ var contentStyles = css({
|
|
|
15
17
|
* - [Examples](https://atlassian.design/components/page-layout/examples)
|
|
16
18
|
* - [Code](https://atlassian.design/components/page-layout/code)
|
|
17
19
|
*/
|
|
18
|
-
|
|
19
20
|
var Content = function Content(props) {
|
|
20
21
|
var children = props.children,
|
|
21
|
-
|
|
22
|
+
testId = props.testId;
|
|
22
23
|
return jsx("div", {
|
|
23
24
|
"data-testid": testId,
|
|
24
25
|
css: contentStyles
|
|
25
26
|
}, children);
|
|
26
27
|
};
|
|
27
|
-
|
|
28
28
|
export default Content;
|