@atlaskit/navigation-system 5.19.0 → 5.21.0
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 +23 -0
- package/dist/cjs/ui/page-layout/panel-splitter/get-width.js +8 -2
- package/dist/cjs/ui/page-layout/panel-splitter/panel-splitter.compiled.css +1 -0
- package/dist/cjs/ui/page-layout/panel-splitter/panel-splitter.js +98 -37
- package/dist/es2019/ui/page-layout/panel-splitter/get-width.js +8 -2
- package/dist/es2019/ui/page-layout/panel-splitter/panel-splitter.compiled.css +1 -0
- package/dist/es2019/ui/page-layout/panel-splitter/panel-splitter.js +64 -4
- package/dist/esm/ui/page-layout/panel-splitter/get-width.js +8 -2
- package/dist/esm/ui/page-layout/panel-splitter/panel-splitter.compiled.css +1 -0
- package/dist/esm/ui/page-layout/panel-splitter/panel-splitter.js +99 -38
- package/dist/types/ui/page-layout/panel-splitter/get-width.d.ts +6 -1
- package/dist/types-ts4.5/ui/page-layout/panel-splitter/get-width.d.ts +6 -1
- package/package.json +6 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# @atlassian/navigation-system
|
|
2
2
|
|
|
3
|
+
## 5.21.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`67075d80cdd6b`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/67075d80cdd6b) -
|
|
8
|
+
Fixes a bug where the panel splitter would not be resizable when some browser extensions were
|
|
9
|
+
installed. This was caused by the `dragstart` event incorrectly returning `0` for the client's
|
|
10
|
+
cursor position (`clientX`).
|
|
11
|
+
|
|
12
|
+
This fix is behind the feature gate `platform-dst-panel-splitter-drag-start-client-x`.
|
|
13
|
+
|
|
14
|
+
## 5.20.0
|
|
15
|
+
|
|
16
|
+
### Minor Changes
|
|
17
|
+
|
|
18
|
+
- [`2e7328e8eff65`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/2e7328e8eff65) -
|
|
19
|
+
Modifies the side nav resize tooltip to remain locked on the x-axis relative to the resizer,
|
|
20
|
+
behind the `platform_dst_nav4_side_nav_resize_tooltip_feedback` feature gate.
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- Updated dependencies
|
|
25
|
+
|
|
3
26
|
## 5.19.0
|
|
4
27
|
|
|
5
28
|
### Minor Changes
|
|
@@ -4,12 +4,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getWidthFromDragLocation = exports.getPixelWidth = void 0;
|
|
7
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
8
|
+
/**
|
|
9
|
+
* ⚠️ Note: We are not using the location.initial.input client locations because some browser extensions
|
|
10
|
+
* can cause the client locations (e.g. clientX) in the `dragstart` event to incorrectly return 0.
|
|
11
|
+
*/
|
|
7
12
|
var getWidthFromDragLocation = exports.getWidthFromDragLocation = function getWidthFromDragLocation(_ref) {
|
|
8
13
|
var initialWidth = _ref.initialWidth,
|
|
9
14
|
location = _ref.location,
|
|
15
|
+
initialClientX = _ref.initialClientX,
|
|
10
16
|
direction = _ref.direction,
|
|
11
17
|
position = _ref.position;
|
|
12
|
-
var diffX = location.current.input.clientX - location.initial.input.clientX;
|
|
18
|
+
var diffX = location.current.input.clientX - ((0, _platformFeatureFlags.fg)('platform-dst-panel-splitter-drag-start-client-x') ? initialClientX : location.initial.input.clientX);
|
|
19
|
+
|
|
13
20
|
// Resize line is positioned at the inline-end (right) of the element.
|
|
14
21
|
// If the direction is left-to-right, the width will increase when the mouse is moved to the right, and vice versa.
|
|
15
22
|
if (position === 'end') {
|
|
@@ -20,7 +27,6 @@ var getWidthFromDragLocation = exports.getWidthFromDragLocation = function getWi
|
|
|
20
27
|
// If the direction is left-to-right, the width will decrease when the mouse is moved to the right, and vice versa.
|
|
21
28
|
return direction === 'ltr' ? initialWidth - diffX : initialWidth + diffX;
|
|
22
29
|
};
|
|
23
|
-
|
|
24
30
|
/**
|
|
25
31
|
* Returns the computed width of an element in pixels.
|
|
26
32
|
*/
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
._1qu2glyw{outline-style:none}
|
|
15
15
|
._4t3i1osq{height:100%}
|
|
16
16
|
._85i5ze3t{padding-block-end:var(--ds-space-0,0)}
|
|
17
|
+
._ahbq196n{margin-inline-start:var(--ds-space-negative-075,-6px)}
|
|
17
18
|
._bfhk1j28{background-color:transparent}
|
|
18
19
|
._bfhk1r31{background-color:currentColor}
|
|
19
20
|
._bozgze3t{padding-inline-start:var(--ds-space-0,0)}
|
|
@@ -13,19 +13,24 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
13
13
|
var React = _react;
|
|
14
14
|
var _runtime = require("@compiled/react/runtime");
|
|
15
15
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
16
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
17
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
16
18
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
17
19
|
var _bindEventListener = require("bind-event-listener");
|
|
18
20
|
var _reactDom = require("react-dom");
|
|
19
21
|
var _tinyInvariant = _interopRequireDefault(require("tiny-invariant"));
|
|
22
|
+
var _noop = _interopRequireDefault(require("@atlaskit/ds-lib/noop"));
|
|
20
23
|
var _useId = require("@atlaskit/ds-lib/use-id");
|
|
21
24
|
var _useStableRef = _interopRequireDefault(require("@atlaskit/ds-lib/use-stable-ref"));
|
|
22
25
|
var _openLayerObserver = require("@atlaskit/layering/experimental/open-layer-observer");
|
|
26
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
23
27
|
var _combine = require("@atlaskit/pragmatic-drag-and-drop/combine");
|
|
24
28
|
var _adapter = require("@atlaskit/pragmatic-drag-and-drop/element/adapter");
|
|
25
29
|
var _blockDraggingToIframes = require("@atlaskit/pragmatic-drag-and-drop/element/block-dragging-to-iframes");
|
|
26
30
|
var _disableNativeDragPreview = require("@atlaskit/pragmatic-drag-and-drop/element/disable-native-drag-preview");
|
|
27
31
|
var _preventUnhandled = require("@atlaskit/pragmatic-drag-and-drop/prevent-unhandled");
|
|
28
32
|
var _tooltip = _interopRequireDefault(require("@atlaskit/tooltip"));
|
|
33
|
+
var _TooltipContainer = _interopRequireDefault(require("@atlaskit/tooltip/TooltipContainer"));
|
|
29
34
|
var _visuallyHidden = _interopRequireDefault(require("@atlaskit/visually-hidden"));
|
|
30
35
|
var _useIsFhsEnabled = require("../../fhs-rollout/use-is-fhs-enabled");
|
|
31
36
|
var _context = require("./context");
|
|
@@ -33,6 +38,7 @@ var _convertResizeBoundToPixels = require("./convert-resize-bound-to-pixels");
|
|
|
33
38
|
var _getPercentageWithinPixelBounds = require("./get-percentage-within-pixel-bounds");
|
|
34
39
|
var _getWidth = require("./get-width");
|
|
35
40
|
var _keyboardResizeManager = require("./keyboard-resize-manager");
|
|
41
|
+
var _excluded = ["children", "className"];
|
|
36
42
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
37
43
|
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; }
|
|
38
44
|
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) { (0, _defineProperty2.default)(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; }
|
|
@@ -48,25 +54,43 @@ var grabAreaStyles = {
|
|
|
48
54
|
var lineStyles = {
|
|
49
55
|
root: "_kqswstnw _1e0c1ule _1bsb1l7b _4t3i1osq _syaz1kw7 _bfhk1r31 _1e021v6z"
|
|
50
56
|
};
|
|
57
|
+
var tooltipStyles = {
|
|
58
|
+
root: "_ahbq196n"
|
|
59
|
+
};
|
|
51
60
|
var panelSplitterDragDataSymbol = Symbol('panel-splitter-drag-data');
|
|
52
61
|
function signPanelSplitterDragData(data) {
|
|
53
62
|
return _objectSpread(_objectSpread({}, data), {}, (0, _defineProperty2.default)({}, panelSplitterDragDataSymbol, true));
|
|
54
63
|
}
|
|
64
|
+
var PanelSplitterTooltip = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
65
|
+
var children = _ref.children,
|
|
66
|
+
className = _ref.className,
|
|
67
|
+
props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
68
|
+
return /*#__PURE__*/React.createElement(_TooltipContainer.default, (0, _extends2.default)({}, props, {
|
|
69
|
+
ref: ref
|
|
70
|
+
// Must be statically passed
|
|
71
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop, @atlaskit/design-system/no-unsafe-style-overrides
|
|
72
|
+
,
|
|
73
|
+
className: (0, _runtime.ax)([tooltipStyles.root, className])
|
|
74
|
+
// eslint-disable-next-line @atlaskit/design-system/no-unsafe-style-overrides
|
|
75
|
+
}), children);
|
|
76
|
+
});
|
|
77
|
+
|
|
55
78
|
/**
|
|
56
79
|
* A wrapper component that renders a tooltip if the tooltipContent or shortcut is provided.
|
|
57
80
|
*/
|
|
58
|
-
var MaybeTooltip = function MaybeTooltip(
|
|
59
|
-
var tooltipContent =
|
|
60
|
-
shortcut =
|
|
61
|
-
children =
|
|
81
|
+
var MaybeTooltip = function MaybeTooltip(_ref2) {
|
|
82
|
+
var tooltipContent = _ref2.tooltipContent,
|
|
83
|
+
shortcut = _ref2.shortcut,
|
|
84
|
+
children = _ref2.children;
|
|
62
85
|
var isFhsEnabled = (0, _useIsFhsEnabled.useIsFhsEnabled)();
|
|
63
86
|
if (tooltipContent && isFhsEnabled) {
|
|
64
87
|
return /*#__PURE__*/React.createElement(_tooltip.default, {
|
|
65
88
|
content: tooltipContent,
|
|
66
89
|
shortcut: shortcut,
|
|
67
|
-
position:
|
|
90
|
+
position: (0, _platformFeatureFlags.fg)('platform_dst_nav4_side_nav_resize_tooltip_feedback') ? 'mouse-y' : 'mouse',
|
|
68
91
|
mousePosition: "right",
|
|
69
|
-
isScreenReaderAnnouncementDisabled: true
|
|
92
|
+
isScreenReaderAnnouncementDisabled: true,
|
|
93
|
+
component: (0, _platformFeatureFlags.fg)('platform_dst_nav4_side_nav_resize_tooltip_feedback') ? PanelSplitterTooltip : undefined
|
|
70
94
|
}, children);
|
|
71
95
|
}
|
|
72
96
|
return children;
|
|
@@ -79,21 +103,21 @@ function getTextDirection(element) {
|
|
|
79
103
|
direction = _window$getComputedSt.direction;
|
|
80
104
|
return direction === 'rtl' ? 'rtl' : 'ltr';
|
|
81
105
|
}
|
|
82
|
-
var PortaledPanelSplitter = function PortaledPanelSplitter(
|
|
83
|
-
var label =
|
|
84
|
-
onResizeStart =
|
|
85
|
-
onResizeEnd =
|
|
86
|
-
testId =
|
|
87
|
-
panelId =
|
|
88
|
-
panelWidth =
|
|
89
|
-
onCompleteResize =
|
|
90
|
-
getResizeBounds =
|
|
91
|
-
panel =
|
|
92
|
-
portal =
|
|
93
|
-
resizingCssVar =
|
|
94
|
-
position =
|
|
95
|
-
tooltipContent =
|
|
96
|
-
shortcut =
|
|
106
|
+
var PortaledPanelSplitter = function PortaledPanelSplitter(_ref3) {
|
|
107
|
+
var label = _ref3.label,
|
|
108
|
+
onResizeStart = _ref3.onResizeStart,
|
|
109
|
+
onResizeEnd = _ref3.onResizeEnd,
|
|
110
|
+
testId = _ref3.testId,
|
|
111
|
+
panelId = _ref3.panelId,
|
|
112
|
+
panelWidth = _ref3.panelWidth,
|
|
113
|
+
onCompleteResize = _ref3.onCompleteResize,
|
|
114
|
+
getResizeBounds = _ref3.getResizeBounds,
|
|
115
|
+
panel = _ref3.panel,
|
|
116
|
+
portal = _ref3.portal,
|
|
117
|
+
resizingCssVar = _ref3.resizingCssVar,
|
|
118
|
+
position = _ref3.position,
|
|
119
|
+
tooltipContent = _ref3.tooltipContent,
|
|
120
|
+
shortcut = _ref3.shortcut;
|
|
97
121
|
var isFhsEnabled = (0, _useIsFhsEnabled.useIsFhsEnabled)();
|
|
98
122
|
var splitterRef = (0, _react.useRef)(null);
|
|
99
123
|
var labelId = (0, _useId.useId)();
|
|
@@ -124,15 +148,38 @@ var PortaledPanelSplitter = function PortaledPanelSplitter(_ref2) {
|
|
|
124
148
|
* Once `PanelSplitter` supports an `onDoubleClick` prop directly, this context can be removed.
|
|
125
149
|
*/
|
|
126
150
|
var onDoubleClick = (0, _react.useContext)(_context.OnDoubleClickContext);
|
|
151
|
+
|
|
152
|
+
// Storing the initial `clientX` on `mousedown` events, to workaround a bug caused by some browser extensions
|
|
153
|
+
// where the `dragstart` event incorrectly returns `0` for the `clientX` location.
|
|
154
|
+
var initialClientXRef = (0, _react.useRef)(null);
|
|
127
155
|
(0, _react.useEffect)(function () {
|
|
128
156
|
var splitter = splitterRef.current;
|
|
129
157
|
(0, _tinyInvariant.default)(splitter, 'Splitter ref must be set');
|
|
130
158
|
return (0, _combine.combine)((0, _blockDraggingToIframes.blockDraggingToIFrames)({
|
|
131
159
|
element: splitter
|
|
132
|
-
}),
|
|
160
|
+
}),
|
|
161
|
+
/**
|
|
162
|
+
* Capturing the initial `clientX` from the mousedown, before the drag starts.
|
|
163
|
+
*
|
|
164
|
+
* ⚠️ Note: We are not using pragmatic-drag-and-drop's `onDragStart` for this as some browser
|
|
165
|
+
* extensions can cause the client location (e.g. clientX) to incorrectly return 0 during the `dragstart` event.
|
|
166
|
+
*
|
|
167
|
+
* We are also not using pragmatic-drag-and-drop's `onDrag` here as it is throttled, which means
|
|
168
|
+
* fast mouse movements can cause the real first drag event to be missed, causing a different clientX
|
|
169
|
+
* to be captured.
|
|
170
|
+
*
|
|
171
|
+
* I also tried only binding an event listener inside pragmatic-drag-and-drop's `onDragStart`, which seemd to work
|
|
172
|
+
* but did not feel as robust, and might have timing issues as it happens slightly later.
|
|
173
|
+
*/
|
|
174
|
+
(0, _platformFeatureFlags.fg)('platform-dst-panel-splitter-drag-start-client-x') ? (0, _bindEventListener.bind)(splitter, {
|
|
175
|
+
type: 'mousedown',
|
|
176
|
+
listener: function listener(event) {
|
|
177
|
+
initialClientXRef.current = event.clientX;
|
|
178
|
+
}
|
|
179
|
+
}) : _noop.default, (0, _adapter.draggable)({
|
|
133
180
|
element: splitter,
|
|
134
|
-
onGenerateDragPreview: function onGenerateDragPreview(
|
|
135
|
-
var nativeSetDragImage =
|
|
181
|
+
onGenerateDragPreview: function onGenerateDragPreview(_ref4) {
|
|
182
|
+
var nativeSetDragImage = _ref4.nativeSetDragImage;
|
|
136
183
|
// We will be moving the line to indicate a drag. We can disable the native drag preview
|
|
137
184
|
(0, _disableNativeDragPreview.disableNativeDragPreview)({
|
|
138
185
|
nativeSetDragImage: nativeSetDragImage
|
|
@@ -159,8 +206,12 @@ var PortaledPanelSplitter = function PortaledPanelSplitter(_ref2) {
|
|
|
159
206
|
direction: getTextDirection(panel)
|
|
160
207
|
});
|
|
161
208
|
},
|
|
162
|
-
onDragStart: function onDragStart(
|
|
163
|
-
var source =
|
|
209
|
+
onDragStart: function onDragStart(_ref5) {
|
|
210
|
+
var source = _ref5.source;
|
|
211
|
+
/**
|
|
212
|
+
* ⚠️ Note: We are not using the client locations (e.g. clientX) during `onDragStart`
|
|
213
|
+
* because some browser extensions can cause the event properties to incorrectly return 0.
|
|
214
|
+
*/
|
|
164
215
|
(0, _tinyInvariant.default)(isPanelSplitterDragData(source.data));
|
|
165
216
|
onResizeStart === null || onResizeStart === void 0 || onResizeStart({
|
|
166
217
|
initialWidth: source.data.initialWidth
|
|
@@ -169,14 +220,22 @@ var PortaledPanelSplitter = function PortaledPanelSplitter(_ref2) {
|
|
|
169
220
|
// Close any open layers when the user starts resizing
|
|
170
221
|
openLayerObserver === null || openLayerObserver === void 0 || openLayerObserver.closeLayers();
|
|
171
222
|
},
|
|
172
|
-
onDrag: function onDrag(
|
|
173
|
-
var
|
|
174
|
-
|
|
223
|
+
onDrag: function onDrag(_ref6) {
|
|
224
|
+
var _initialClientXRef$cu;
|
|
225
|
+
var location = _ref6.location,
|
|
226
|
+
source = _ref6.source;
|
|
227
|
+
/**
|
|
228
|
+
* ⚠️ Note: We are not using the location.initial.input client locations because some browser extensions
|
|
229
|
+
* can cause the client locations (e.g. clientX) in the `dragstart` event to incorrectly return 0.
|
|
230
|
+
*/
|
|
175
231
|
(0, _tinyInvariant.default)(isPanelSplitterDragData(source.data));
|
|
176
232
|
var _source$data = source.data,
|
|
177
233
|
initialWidth = _source$data.initialWidth,
|
|
178
234
|
resizeBounds = _source$data.resizeBounds,
|
|
179
235
|
direction = _source$data.direction;
|
|
236
|
+
if ((0, _platformFeatureFlags.fg)('platform-dst-panel-splitter-drag-start-client-x')) {
|
|
237
|
+
(0, _tinyInvariant.default)(initialClientXRef.current !== null, 'initialClientX must be set');
|
|
238
|
+
}
|
|
180
239
|
|
|
181
240
|
/**
|
|
182
241
|
* How wide the element would be if there were no width constraints,
|
|
@@ -185,6 +244,8 @@ var PortaledPanelSplitter = function PortaledPanelSplitter(_ref2) {
|
|
|
185
244
|
var targetWidth = (0, _getWidth.getWidthFromDragLocation)({
|
|
186
245
|
initialWidth: initialWidth,
|
|
187
246
|
location: location,
|
|
247
|
+
// The fallback of 0 won't be used due to the invariant, however we require one to satisfy the type.
|
|
248
|
+
initialClientX: (_initialClientXRef$cu = initialClientXRef.current) !== null && _initialClientXRef$cu !== void 0 ? _initialClientXRef$cu : 0,
|
|
188
249
|
direction: direction,
|
|
189
250
|
position: position
|
|
190
251
|
});
|
|
@@ -192,8 +253,8 @@ var PortaledPanelSplitter = function PortaledPanelSplitter(_ref2) {
|
|
|
192
253
|
panel.style.setProperty(resizingCssVar, resizingWidth);
|
|
193
254
|
source.data.resizingWidth = resizingWidth;
|
|
194
255
|
},
|
|
195
|
-
onDrop: function onDrop(
|
|
196
|
-
var source =
|
|
256
|
+
onDrop: function onDrop(_ref7) {
|
|
257
|
+
var source = _ref7.source;
|
|
197
258
|
(0, _tinyInvariant.default)(isPanelSplitterDragData(source.data));
|
|
198
259
|
_preventUnhandled.preventUnhandled.stop();
|
|
199
260
|
var finalWidth = (0, _getWidth.getPixelWidth)(panel);
|
|
@@ -346,12 +407,12 @@ var PortaledPanelSplitter = function PortaledPanelSplitter(_ref2) {
|
|
|
346
407
|
* </Aside>
|
|
347
408
|
* ```
|
|
348
409
|
*/
|
|
349
|
-
var PanelSplitter = exports.PanelSplitter = function PanelSplitter(
|
|
350
|
-
var label =
|
|
351
|
-
onResizeStart =
|
|
352
|
-
onResizeEnd =
|
|
353
|
-
testId =
|
|
354
|
-
tooltipContent =
|
|
410
|
+
var PanelSplitter = exports.PanelSplitter = function PanelSplitter(_ref8) {
|
|
411
|
+
var label = _ref8.label,
|
|
412
|
+
onResizeStart = _ref8.onResizeStart,
|
|
413
|
+
onResizeEnd = _ref8.onResizeEnd,
|
|
414
|
+
testId = _ref8.testId,
|
|
415
|
+
tooltipContent = _ref8.tooltipContent;
|
|
355
416
|
var _useState7 = (0, _react.useState)(null),
|
|
356
417
|
_useState8 = (0, _slicedToArray2.default)(_useState7, 2),
|
|
357
418
|
panel = _useState8[0],
|
|
@@ -1,10 +1,17 @@
|
|
|
1
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
|
+
/**
|
|
3
|
+
* ⚠️ Note: We are not using the location.initial.input client locations because some browser extensions
|
|
4
|
+
* can cause the client locations (e.g. clientX) in the `dragstart` event to incorrectly return 0.
|
|
5
|
+
*/
|
|
1
6
|
export const getWidthFromDragLocation = ({
|
|
2
7
|
initialWidth,
|
|
3
8
|
location,
|
|
9
|
+
initialClientX,
|
|
4
10
|
direction,
|
|
5
11
|
position
|
|
6
12
|
}) => {
|
|
7
|
-
const diffX = location.current.input.clientX - location.initial.input.clientX;
|
|
13
|
+
const diffX = location.current.input.clientX - (fg('platform-dst-panel-splitter-drag-start-client-x') ? initialClientX : location.initial.input.clientX);
|
|
14
|
+
|
|
8
15
|
// Resize line is positioned at the inline-end (right) of the element.
|
|
9
16
|
// If the direction is left-to-right, the width will increase when the mouse is moved to the right, and vice versa.
|
|
10
17
|
if (position === 'end') {
|
|
@@ -15,7 +22,6 @@ export const getWidthFromDragLocation = ({
|
|
|
15
22
|
// If the direction is left-to-right, the width will decrease when the mouse is moved to the right, and vice versa.
|
|
16
23
|
return direction === 'ltr' ? initialWidth - diffX : initialWidth + diffX;
|
|
17
24
|
};
|
|
18
|
-
|
|
19
25
|
/**
|
|
20
26
|
* Returns the computed width of an element in pixels.
|
|
21
27
|
*/
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
._1qu2glyw{outline-style:none}
|
|
15
15
|
._4t3i1osq{height:100%}
|
|
16
16
|
._85i5ze3t{padding-block-end:var(--ds-space-0,0)}
|
|
17
|
+
._ahbq196n{margin-inline-start:var(--ds-space-negative-075,-6px)}
|
|
17
18
|
._bfhk1j28{background-color:transparent}
|
|
18
19
|
._bfhk1r31{background-color:currentColor}
|
|
19
20
|
._bozgze3t{padding-inline-start:var(--ds-space-0,0)}
|
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
/* panel-splitter.tsx generated by @compiled/babel-plugin v0.38.1 */
|
|
2
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
3
|
import "./panel-splitter.compiled.css";
|
|
3
4
|
import * as React from 'react';
|
|
4
5
|
import { ax, ix } from "@compiled/react/runtime";
|
|
5
|
-
import { useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
|
|
6
|
+
import { forwardRef, useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
|
|
6
7
|
import { bind } from 'bind-event-listener';
|
|
7
8
|
import { createPortal } from 'react-dom';
|
|
8
9
|
import invariant from 'tiny-invariant';
|
|
10
|
+
import noop from '@atlaskit/ds-lib/noop';
|
|
9
11
|
import { useId } from '@atlaskit/ds-lib/use-id';
|
|
10
12
|
import useStableRef from '@atlaskit/ds-lib/use-stable-ref';
|
|
11
13
|
import { useOpenLayerObserver } from '@atlaskit/layering/experimental/open-layer-observer';
|
|
14
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
12
15
|
import { combine } from '@atlaskit/pragmatic-drag-and-drop/combine';
|
|
13
16
|
import { draggable } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
14
17
|
import { blockDraggingToIFrames } from '@atlaskit/pragmatic-drag-and-drop/element/block-dragging-to-iframes';
|
|
15
18
|
import { disableNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/element/disable-native-drag-preview';
|
|
16
19
|
import { preventUnhandled } from '@atlaskit/pragmatic-drag-and-drop/prevent-unhandled';
|
|
17
20
|
import Tooltip from '@atlaskit/tooltip';
|
|
21
|
+
import TooltipContainer from '@atlaskit/tooltip/TooltipContainer';
|
|
18
22
|
import VisuallyHidden from '@atlaskit/visually-hidden';
|
|
19
23
|
import { useIsFhsEnabled } from '../../fhs-rollout/use-is-fhs-enabled';
|
|
20
24
|
import { OnDoubleClickContext, PanelSplitterContext } from './context';
|
|
@@ -34,6 +38,9 @@ const grabAreaStyles = {
|
|
|
34
38
|
const lineStyles = {
|
|
35
39
|
root: "_kqswstnw _1e0c1ule _1bsb1l7b _4t3i1osq _syaz1kw7 _bfhk1r31 _1e021v6z"
|
|
36
40
|
};
|
|
41
|
+
const tooltipStyles = {
|
|
42
|
+
root: "_ahbq196n"
|
|
43
|
+
};
|
|
37
44
|
const panelSplitterDragDataSymbol = Symbol('panel-splitter-drag-data');
|
|
38
45
|
function signPanelSplitterDragData(data) {
|
|
39
46
|
return {
|
|
@@ -41,6 +48,21 @@ function signPanelSplitterDragData(data) {
|
|
|
41
48
|
[panelSplitterDragDataSymbol]: true
|
|
42
49
|
};
|
|
43
50
|
}
|
|
51
|
+
const PanelSplitterTooltip = /*#__PURE__*/forwardRef(({
|
|
52
|
+
children,
|
|
53
|
+
className,
|
|
54
|
+
...props
|
|
55
|
+
}, ref) => {
|
|
56
|
+
return /*#__PURE__*/React.createElement(TooltipContainer, _extends({}, props, {
|
|
57
|
+
ref: ref
|
|
58
|
+
// Must be statically passed
|
|
59
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop, @atlaskit/design-system/no-unsafe-style-overrides
|
|
60
|
+
,
|
|
61
|
+
className: ax([tooltipStyles.root, className])
|
|
62
|
+
// eslint-disable-next-line @atlaskit/design-system/no-unsafe-style-overrides
|
|
63
|
+
}), children);
|
|
64
|
+
});
|
|
65
|
+
|
|
44
66
|
/**
|
|
45
67
|
* A wrapper component that renders a tooltip if the tooltipContent or shortcut is provided.
|
|
46
68
|
*/
|
|
@@ -54,9 +76,10 @@ const MaybeTooltip = ({
|
|
|
54
76
|
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
55
77
|
content: tooltipContent,
|
|
56
78
|
shortcut: shortcut,
|
|
57
|
-
position:
|
|
79
|
+
position: fg('platform_dst_nav4_side_nav_resize_tooltip_feedback') ? 'mouse-y' : 'mouse',
|
|
58
80
|
mousePosition: "right",
|
|
59
|
-
isScreenReaderAnnouncementDisabled: true
|
|
81
|
+
isScreenReaderAnnouncementDisabled: true,
|
|
82
|
+
component: fg('platform_dst_nav4_side_nav_resize_tooltip_feedback') ? PanelSplitterTooltip : undefined
|
|
60
83
|
}, children);
|
|
61
84
|
}
|
|
62
85
|
return children;
|
|
@@ -110,12 +133,35 @@ const PortaledPanelSplitter = ({
|
|
|
110
133
|
* Once `PanelSplitter` supports an `onDoubleClick` prop directly, this context can be removed.
|
|
111
134
|
*/
|
|
112
135
|
const onDoubleClick = useContext(OnDoubleClickContext);
|
|
136
|
+
|
|
137
|
+
// Storing the initial `clientX` on `mousedown` events, to workaround a bug caused by some browser extensions
|
|
138
|
+
// where the `dragstart` event incorrectly returns `0` for the `clientX` location.
|
|
139
|
+
const initialClientXRef = useRef(null);
|
|
113
140
|
useEffect(() => {
|
|
114
141
|
const splitter = splitterRef.current;
|
|
115
142
|
invariant(splitter, 'Splitter ref must be set');
|
|
116
143
|
return combine(blockDraggingToIFrames({
|
|
117
144
|
element: splitter
|
|
118
|
-
}),
|
|
145
|
+
}),
|
|
146
|
+
/**
|
|
147
|
+
* Capturing the initial `clientX` from the mousedown, before the drag starts.
|
|
148
|
+
*
|
|
149
|
+
* ⚠️ Note: We are not using pragmatic-drag-and-drop's `onDragStart` for this as some browser
|
|
150
|
+
* extensions can cause the client location (e.g. clientX) to incorrectly return 0 during the `dragstart` event.
|
|
151
|
+
*
|
|
152
|
+
* We are also not using pragmatic-drag-and-drop's `onDrag` here as it is throttled, which means
|
|
153
|
+
* fast mouse movements can cause the real first drag event to be missed, causing a different clientX
|
|
154
|
+
* to be captured.
|
|
155
|
+
*
|
|
156
|
+
* I also tried only binding an event listener inside pragmatic-drag-and-drop's `onDragStart`, which seemd to work
|
|
157
|
+
* but did not feel as robust, and might have timing issues as it happens slightly later.
|
|
158
|
+
*/
|
|
159
|
+
fg('platform-dst-panel-splitter-drag-start-client-x') ? bind(splitter, {
|
|
160
|
+
type: 'mousedown',
|
|
161
|
+
listener: event => {
|
|
162
|
+
initialClientXRef.current = event.clientX;
|
|
163
|
+
}
|
|
164
|
+
}) : noop, draggable({
|
|
119
165
|
element: splitter,
|
|
120
166
|
onGenerateDragPreview: ({
|
|
121
167
|
nativeSetDragImage
|
|
@@ -149,6 +195,10 @@ const PortaledPanelSplitter = ({
|
|
|
149
195
|
onDragStart({
|
|
150
196
|
source
|
|
151
197
|
}) {
|
|
198
|
+
/**
|
|
199
|
+
* ⚠️ Note: We are not using the client locations (e.g. clientX) during `onDragStart`
|
|
200
|
+
* because some browser extensions can cause the event properties to incorrectly return 0.
|
|
201
|
+
*/
|
|
152
202
|
invariant(isPanelSplitterDragData(source.data));
|
|
153
203
|
onResizeStart === null || onResizeStart === void 0 ? void 0 : onResizeStart({
|
|
154
204
|
initialWidth: source.data.initialWidth
|
|
@@ -161,12 +211,20 @@ const PortaledPanelSplitter = ({
|
|
|
161
211
|
location,
|
|
162
212
|
source
|
|
163
213
|
}) {
|
|
214
|
+
var _initialClientXRef$cu;
|
|
215
|
+
/**
|
|
216
|
+
* ⚠️ Note: We are not using the location.initial.input client locations because some browser extensions
|
|
217
|
+
* can cause the client locations (e.g. clientX) in the `dragstart` event to incorrectly return 0.
|
|
218
|
+
*/
|
|
164
219
|
invariant(isPanelSplitterDragData(source.data));
|
|
165
220
|
const {
|
|
166
221
|
initialWidth,
|
|
167
222
|
resizeBounds,
|
|
168
223
|
direction
|
|
169
224
|
} = source.data;
|
|
225
|
+
if (fg('platform-dst-panel-splitter-drag-start-client-x')) {
|
|
226
|
+
invariant(initialClientXRef.current !== null, 'initialClientX must be set');
|
|
227
|
+
}
|
|
170
228
|
|
|
171
229
|
/**
|
|
172
230
|
* How wide the element would be if there were no width constraints,
|
|
@@ -175,6 +233,8 @@ const PortaledPanelSplitter = ({
|
|
|
175
233
|
const targetWidth = getWidthFromDragLocation({
|
|
176
234
|
initialWidth,
|
|
177
235
|
location,
|
|
236
|
+
// The fallback of 0 won't be used due to the invariant, however we require one to satisfy the type.
|
|
237
|
+
initialClientX: (_initialClientXRef$cu = initialClientXRef.current) !== null && _initialClientXRef$cu !== void 0 ? _initialClientXRef$cu : 0,
|
|
178
238
|
direction,
|
|
179
239
|
position
|
|
180
240
|
});
|
|
@@ -1,9 +1,16 @@
|
|
|
1
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
|
+
/**
|
|
3
|
+
* ⚠️ Note: We are not using the location.initial.input client locations because some browser extensions
|
|
4
|
+
* can cause the client locations (e.g. clientX) in the `dragstart` event to incorrectly return 0.
|
|
5
|
+
*/
|
|
1
6
|
export var getWidthFromDragLocation = function getWidthFromDragLocation(_ref) {
|
|
2
7
|
var initialWidth = _ref.initialWidth,
|
|
3
8
|
location = _ref.location,
|
|
9
|
+
initialClientX = _ref.initialClientX,
|
|
4
10
|
direction = _ref.direction,
|
|
5
11
|
position = _ref.position;
|
|
6
|
-
var diffX = location.current.input.clientX - location.initial.input.clientX;
|
|
12
|
+
var diffX = location.current.input.clientX - (fg('platform-dst-panel-splitter-drag-start-client-x') ? initialClientX : location.initial.input.clientX);
|
|
13
|
+
|
|
7
14
|
// Resize line is positioned at the inline-end (right) of the element.
|
|
8
15
|
// If the direction is left-to-right, the width will increase when the mouse is moved to the right, and vice versa.
|
|
9
16
|
if (position === 'end') {
|
|
@@ -14,7 +21,6 @@ export var getWidthFromDragLocation = function getWidthFromDragLocation(_ref) {
|
|
|
14
21
|
// If the direction is left-to-right, the width will decrease when the mouse is moved to the right, and vice versa.
|
|
15
22
|
return direction === 'ltr' ? initialWidth - diffX : initialWidth + diffX;
|
|
16
23
|
};
|
|
17
|
-
|
|
18
24
|
/**
|
|
19
25
|
* Returns the computed width of an element in pixels.
|
|
20
26
|
*/
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
._1qu2glyw{outline-style:none}
|
|
15
15
|
._4t3i1osq{height:100%}
|
|
16
16
|
._85i5ze3t{padding-block-end:var(--ds-space-0,0)}
|
|
17
|
+
._ahbq196n{margin-inline-start:var(--ds-space-negative-075,-6px)}
|
|
17
18
|
._bfhk1j28{background-color:transparent}
|
|
18
19
|
._bfhk1r31{background-color:currentColor}
|
|
19
20
|
._bozgze3t{padding-inline-start:var(--ds-space-0,0)}
|
|
@@ -1,24 +1,30 @@
|
|
|
1
1
|
/* panel-splitter.tsx generated by @compiled/babel-plugin v0.38.1 */
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
4
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
5
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
6
|
+
var _excluded = ["children", "className"];
|
|
4
7
|
import "./panel-splitter.compiled.css";
|
|
5
8
|
import * as React from 'react';
|
|
6
9
|
import { ax, ix } from "@compiled/react/runtime";
|
|
7
10
|
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
11
|
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, useEffect, useMemo, useRef, useState } from 'react';
|
|
12
|
+
import { forwardRef, useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
|
|
10
13
|
import { bind } from 'bind-event-listener';
|
|
11
14
|
import { createPortal } from 'react-dom';
|
|
12
15
|
import invariant from 'tiny-invariant';
|
|
16
|
+
import noop from '@atlaskit/ds-lib/noop';
|
|
13
17
|
import { useId } from '@atlaskit/ds-lib/use-id';
|
|
14
18
|
import useStableRef from '@atlaskit/ds-lib/use-stable-ref';
|
|
15
19
|
import { useOpenLayerObserver } from '@atlaskit/layering/experimental/open-layer-observer';
|
|
20
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
16
21
|
import { combine } from '@atlaskit/pragmatic-drag-and-drop/combine';
|
|
17
22
|
import { draggable } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
18
23
|
import { blockDraggingToIFrames } from '@atlaskit/pragmatic-drag-and-drop/element/block-dragging-to-iframes';
|
|
19
24
|
import { disableNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/element/disable-native-drag-preview';
|
|
20
25
|
import { preventUnhandled } from '@atlaskit/pragmatic-drag-and-drop/prevent-unhandled';
|
|
21
26
|
import Tooltip from '@atlaskit/tooltip';
|
|
27
|
+
import TooltipContainer from '@atlaskit/tooltip/TooltipContainer';
|
|
22
28
|
import VisuallyHidden from '@atlaskit/visually-hidden';
|
|
23
29
|
import { useIsFhsEnabled } from '../../fhs-rollout/use-is-fhs-enabled';
|
|
24
30
|
import { OnDoubleClickContext, PanelSplitterContext } from './context';
|
|
@@ -38,25 +44,43 @@ var grabAreaStyles = {
|
|
|
38
44
|
var lineStyles = {
|
|
39
45
|
root: "_kqswstnw _1e0c1ule _1bsb1l7b _4t3i1osq _syaz1kw7 _bfhk1r31 _1e021v6z"
|
|
40
46
|
};
|
|
47
|
+
var tooltipStyles = {
|
|
48
|
+
root: "_ahbq196n"
|
|
49
|
+
};
|
|
41
50
|
var panelSplitterDragDataSymbol = Symbol('panel-splitter-drag-data');
|
|
42
51
|
function signPanelSplitterDragData(data) {
|
|
43
52
|
return _objectSpread(_objectSpread({}, data), {}, _defineProperty({}, panelSplitterDragDataSymbol, true));
|
|
44
53
|
}
|
|
54
|
+
var PanelSplitterTooltip = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
55
|
+
var children = _ref.children,
|
|
56
|
+
className = _ref.className,
|
|
57
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
58
|
+
return /*#__PURE__*/React.createElement(TooltipContainer, _extends({}, props, {
|
|
59
|
+
ref: ref
|
|
60
|
+
// Must be statically passed
|
|
61
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop, @atlaskit/design-system/no-unsafe-style-overrides
|
|
62
|
+
,
|
|
63
|
+
className: ax([tooltipStyles.root, className])
|
|
64
|
+
// eslint-disable-next-line @atlaskit/design-system/no-unsafe-style-overrides
|
|
65
|
+
}), children);
|
|
66
|
+
});
|
|
67
|
+
|
|
45
68
|
/**
|
|
46
69
|
* A wrapper component that renders a tooltip if the tooltipContent or shortcut is provided.
|
|
47
70
|
*/
|
|
48
|
-
var MaybeTooltip = function MaybeTooltip(
|
|
49
|
-
var tooltipContent =
|
|
50
|
-
shortcut =
|
|
51
|
-
children =
|
|
71
|
+
var MaybeTooltip = function MaybeTooltip(_ref2) {
|
|
72
|
+
var tooltipContent = _ref2.tooltipContent,
|
|
73
|
+
shortcut = _ref2.shortcut,
|
|
74
|
+
children = _ref2.children;
|
|
52
75
|
var isFhsEnabled = useIsFhsEnabled();
|
|
53
76
|
if (tooltipContent && isFhsEnabled) {
|
|
54
77
|
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
55
78
|
content: tooltipContent,
|
|
56
79
|
shortcut: shortcut,
|
|
57
|
-
position:
|
|
80
|
+
position: fg('platform_dst_nav4_side_nav_resize_tooltip_feedback') ? 'mouse-y' : 'mouse',
|
|
58
81
|
mousePosition: "right",
|
|
59
|
-
isScreenReaderAnnouncementDisabled: true
|
|
82
|
+
isScreenReaderAnnouncementDisabled: true,
|
|
83
|
+
component: fg('platform_dst_nav4_side_nav_resize_tooltip_feedback') ? PanelSplitterTooltip : undefined
|
|
60
84
|
}, children);
|
|
61
85
|
}
|
|
62
86
|
return children;
|
|
@@ -69,21 +93,21 @@ function getTextDirection(element) {
|
|
|
69
93
|
direction = _window$getComputedSt.direction;
|
|
70
94
|
return direction === 'rtl' ? 'rtl' : 'ltr';
|
|
71
95
|
}
|
|
72
|
-
var PortaledPanelSplitter = function PortaledPanelSplitter(
|
|
73
|
-
var label =
|
|
74
|
-
onResizeStart =
|
|
75
|
-
onResizeEnd =
|
|
76
|
-
testId =
|
|
77
|
-
panelId =
|
|
78
|
-
panelWidth =
|
|
79
|
-
onCompleteResize =
|
|
80
|
-
getResizeBounds =
|
|
81
|
-
panel =
|
|
82
|
-
portal =
|
|
83
|
-
resizingCssVar =
|
|
84
|
-
position =
|
|
85
|
-
tooltipContent =
|
|
86
|
-
shortcut =
|
|
96
|
+
var PortaledPanelSplitter = function PortaledPanelSplitter(_ref3) {
|
|
97
|
+
var label = _ref3.label,
|
|
98
|
+
onResizeStart = _ref3.onResizeStart,
|
|
99
|
+
onResizeEnd = _ref3.onResizeEnd,
|
|
100
|
+
testId = _ref3.testId,
|
|
101
|
+
panelId = _ref3.panelId,
|
|
102
|
+
panelWidth = _ref3.panelWidth,
|
|
103
|
+
onCompleteResize = _ref3.onCompleteResize,
|
|
104
|
+
getResizeBounds = _ref3.getResizeBounds,
|
|
105
|
+
panel = _ref3.panel,
|
|
106
|
+
portal = _ref3.portal,
|
|
107
|
+
resizingCssVar = _ref3.resizingCssVar,
|
|
108
|
+
position = _ref3.position,
|
|
109
|
+
tooltipContent = _ref3.tooltipContent,
|
|
110
|
+
shortcut = _ref3.shortcut;
|
|
87
111
|
var isFhsEnabled = useIsFhsEnabled();
|
|
88
112
|
var splitterRef = useRef(null);
|
|
89
113
|
var labelId = useId();
|
|
@@ -114,15 +138,38 @@ var PortaledPanelSplitter = function PortaledPanelSplitter(_ref2) {
|
|
|
114
138
|
* Once `PanelSplitter` supports an `onDoubleClick` prop directly, this context can be removed.
|
|
115
139
|
*/
|
|
116
140
|
var onDoubleClick = useContext(OnDoubleClickContext);
|
|
141
|
+
|
|
142
|
+
// Storing the initial `clientX` on `mousedown` events, to workaround a bug caused by some browser extensions
|
|
143
|
+
// where the `dragstart` event incorrectly returns `0` for the `clientX` location.
|
|
144
|
+
var initialClientXRef = useRef(null);
|
|
117
145
|
useEffect(function () {
|
|
118
146
|
var splitter = splitterRef.current;
|
|
119
147
|
invariant(splitter, 'Splitter ref must be set');
|
|
120
148
|
return combine(blockDraggingToIFrames({
|
|
121
149
|
element: splitter
|
|
122
|
-
}),
|
|
150
|
+
}),
|
|
151
|
+
/**
|
|
152
|
+
* Capturing the initial `clientX` from the mousedown, before the drag starts.
|
|
153
|
+
*
|
|
154
|
+
* ⚠️ Note: We are not using pragmatic-drag-and-drop's `onDragStart` for this as some browser
|
|
155
|
+
* extensions can cause the client location (e.g. clientX) to incorrectly return 0 during the `dragstart` event.
|
|
156
|
+
*
|
|
157
|
+
* We are also not using pragmatic-drag-and-drop's `onDrag` here as it is throttled, which means
|
|
158
|
+
* fast mouse movements can cause the real first drag event to be missed, causing a different clientX
|
|
159
|
+
* to be captured.
|
|
160
|
+
*
|
|
161
|
+
* I also tried only binding an event listener inside pragmatic-drag-and-drop's `onDragStart`, which seemd to work
|
|
162
|
+
* but did not feel as robust, and might have timing issues as it happens slightly later.
|
|
163
|
+
*/
|
|
164
|
+
fg('platform-dst-panel-splitter-drag-start-client-x') ? bind(splitter, {
|
|
165
|
+
type: 'mousedown',
|
|
166
|
+
listener: function listener(event) {
|
|
167
|
+
initialClientXRef.current = event.clientX;
|
|
168
|
+
}
|
|
169
|
+
}) : noop, draggable({
|
|
123
170
|
element: splitter,
|
|
124
|
-
onGenerateDragPreview: function onGenerateDragPreview(
|
|
125
|
-
var nativeSetDragImage =
|
|
171
|
+
onGenerateDragPreview: function onGenerateDragPreview(_ref4) {
|
|
172
|
+
var nativeSetDragImage = _ref4.nativeSetDragImage;
|
|
126
173
|
// We will be moving the line to indicate a drag. We can disable the native drag preview
|
|
127
174
|
disableNativeDragPreview({
|
|
128
175
|
nativeSetDragImage: nativeSetDragImage
|
|
@@ -149,8 +196,12 @@ var PortaledPanelSplitter = function PortaledPanelSplitter(_ref2) {
|
|
|
149
196
|
direction: getTextDirection(panel)
|
|
150
197
|
});
|
|
151
198
|
},
|
|
152
|
-
onDragStart: function onDragStart(
|
|
153
|
-
var source =
|
|
199
|
+
onDragStart: function onDragStart(_ref5) {
|
|
200
|
+
var source = _ref5.source;
|
|
201
|
+
/**
|
|
202
|
+
* ⚠️ Note: We are not using the client locations (e.g. clientX) during `onDragStart`
|
|
203
|
+
* because some browser extensions can cause the event properties to incorrectly return 0.
|
|
204
|
+
*/
|
|
154
205
|
invariant(isPanelSplitterDragData(source.data));
|
|
155
206
|
onResizeStart === null || onResizeStart === void 0 || onResizeStart({
|
|
156
207
|
initialWidth: source.data.initialWidth
|
|
@@ -159,14 +210,22 @@ var PortaledPanelSplitter = function PortaledPanelSplitter(_ref2) {
|
|
|
159
210
|
// Close any open layers when the user starts resizing
|
|
160
211
|
openLayerObserver === null || openLayerObserver === void 0 || openLayerObserver.closeLayers();
|
|
161
212
|
},
|
|
162
|
-
onDrag: function onDrag(
|
|
163
|
-
var
|
|
164
|
-
|
|
213
|
+
onDrag: function onDrag(_ref6) {
|
|
214
|
+
var _initialClientXRef$cu;
|
|
215
|
+
var location = _ref6.location,
|
|
216
|
+
source = _ref6.source;
|
|
217
|
+
/**
|
|
218
|
+
* ⚠️ Note: We are not using the location.initial.input client locations because some browser extensions
|
|
219
|
+
* can cause the client locations (e.g. clientX) in the `dragstart` event to incorrectly return 0.
|
|
220
|
+
*/
|
|
165
221
|
invariant(isPanelSplitterDragData(source.data));
|
|
166
222
|
var _source$data = source.data,
|
|
167
223
|
initialWidth = _source$data.initialWidth,
|
|
168
224
|
resizeBounds = _source$data.resizeBounds,
|
|
169
225
|
direction = _source$data.direction;
|
|
226
|
+
if (fg('platform-dst-panel-splitter-drag-start-client-x')) {
|
|
227
|
+
invariant(initialClientXRef.current !== null, 'initialClientX must be set');
|
|
228
|
+
}
|
|
170
229
|
|
|
171
230
|
/**
|
|
172
231
|
* How wide the element would be if there were no width constraints,
|
|
@@ -175,6 +234,8 @@ var PortaledPanelSplitter = function PortaledPanelSplitter(_ref2) {
|
|
|
175
234
|
var targetWidth = getWidthFromDragLocation({
|
|
176
235
|
initialWidth: initialWidth,
|
|
177
236
|
location: location,
|
|
237
|
+
// The fallback of 0 won't be used due to the invariant, however we require one to satisfy the type.
|
|
238
|
+
initialClientX: (_initialClientXRef$cu = initialClientXRef.current) !== null && _initialClientXRef$cu !== void 0 ? _initialClientXRef$cu : 0,
|
|
178
239
|
direction: direction,
|
|
179
240
|
position: position
|
|
180
241
|
});
|
|
@@ -182,8 +243,8 @@ var PortaledPanelSplitter = function PortaledPanelSplitter(_ref2) {
|
|
|
182
243
|
panel.style.setProperty(resizingCssVar, resizingWidth);
|
|
183
244
|
source.data.resizingWidth = resizingWidth;
|
|
184
245
|
},
|
|
185
|
-
onDrop: function onDrop(
|
|
186
|
-
var source =
|
|
246
|
+
onDrop: function onDrop(_ref7) {
|
|
247
|
+
var source = _ref7.source;
|
|
187
248
|
invariant(isPanelSplitterDragData(source.data));
|
|
188
249
|
preventUnhandled.stop();
|
|
189
250
|
var finalWidth = getPixelWidth(panel);
|
|
@@ -336,12 +397,12 @@ var PortaledPanelSplitter = function PortaledPanelSplitter(_ref2) {
|
|
|
336
397
|
* </Aside>
|
|
337
398
|
* ```
|
|
338
399
|
*/
|
|
339
|
-
export var PanelSplitter = function PanelSplitter(
|
|
340
|
-
var label =
|
|
341
|
-
onResizeStart =
|
|
342
|
-
onResizeEnd =
|
|
343
|
-
testId =
|
|
344
|
-
tooltipContent =
|
|
400
|
+
export var PanelSplitter = function PanelSplitter(_ref8) {
|
|
401
|
+
var label = _ref8.label,
|
|
402
|
+
onResizeStart = _ref8.onResizeStart,
|
|
403
|
+
onResizeEnd = _ref8.onResizeEnd,
|
|
404
|
+
testId = _ref8.testId,
|
|
405
|
+
tooltipContent = _ref8.tooltipContent;
|
|
345
406
|
var _useState7 = useState(null),
|
|
346
407
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
347
408
|
panel = _useState8[0],
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import type { DragLocationHistory } from '@atlaskit/pragmatic-drag-and-drop/types';
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* ⚠️ Note: We are not using the location.initial.input client locations because some browser extensions
|
|
4
|
+
* can cause the client locations (e.g. clientX) in the `dragstart` event to incorrectly return 0.
|
|
5
|
+
*/
|
|
6
|
+
export declare const getWidthFromDragLocation: ({ initialWidth, location, initialClientX, direction, position, }: {
|
|
3
7
|
initialWidth: number;
|
|
4
8
|
location: DragLocationHistory;
|
|
9
|
+
initialClientX: number;
|
|
5
10
|
direction: "ltr" | "rtl";
|
|
6
11
|
position: "start" | "end";
|
|
7
12
|
}) => number;
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import type { DragLocationHistory } from '@atlaskit/pragmatic-drag-and-drop/types';
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* ⚠️ Note: We are not using the location.initial.input client locations because some browser extensions
|
|
4
|
+
* can cause the client locations (e.g. clientX) in the `dragstart` event to incorrectly return 0.
|
|
5
|
+
*/
|
|
6
|
+
export declare const getWidthFromDragLocation: ({ initialWidth, location, initialClientX, direction, position, }: {
|
|
3
7
|
initialWidth: number;
|
|
4
8
|
location: DragLocationHistory;
|
|
9
|
+
initialClientX: number;
|
|
5
10
|
direction: "ltr" | "rtl";
|
|
6
11
|
position: "start" | "end";
|
|
7
12
|
}) => number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/navigation-system",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.21.0",
|
|
4
4
|
"description": "The latest navigation system for Atlassian apps.",
|
|
5
5
|
"repository": "https://bitbucket.org/atlassian/atlassian-frontend-mirror",
|
|
6
6
|
"author": "Atlassian Pty Ltd",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"@atlaskit/css": "^0.19.0",
|
|
73
73
|
"@atlaskit/ds-lib": "^5.3.0",
|
|
74
74
|
"@atlaskit/heading": "^5.2.0",
|
|
75
|
-
"@atlaskit/icon": "^29.
|
|
75
|
+
"@atlaskit/icon": "^29.4.0",
|
|
76
76
|
"@atlaskit/layering": "^3.6.0",
|
|
77
77
|
"@atlaskit/logo": "^19.9.0",
|
|
78
78
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^3.2.0",
|
|
83
83
|
"@atlaskit/primitives": "^17.0.0",
|
|
84
84
|
"@atlaskit/tokens": "^9.1.0",
|
|
85
|
-
"@atlaskit/tooltip": "^20.
|
|
85
|
+
"@atlaskit/tooltip": "^20.12.0",
|
|
86
86
|
"@atlaskit/visually-hidden": "^3.0.0",
|
|
87
87
|
"@babel/runtime": "^7.0.0",
|
|
88
88
|
"@compiled/react": "^0.18.6",
|
|
@@ -193,6 +193,9 @@
|
|
|
193
193
|
},
|
|
194
194
|
"platform_dst_nav4_flyout_menu_slots_close_button": {
|
|
195
195
|
"type": "boolean"
|
|
196
|
+
},
|
|
197
|
+
"platform-dst-panel-splitter-drag-start-client-x": {
|
|
198
|
+
"type": "boolean"
|
|
196
199
|
}
|
|
197
200
|
},
|
|
198
201
|
"homepage": "https://atlassian.design/components/navigation-system"
|