@atlaskit/navigation-system 5.2.0 → 5.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/dist/cjs/ui/menu-item/button-menu-item.js +9 -6
- package/dist/cjs/ui/menu-item/menu-item.compiled.css +2 -0
- package/dist/cjs/ui/menu-item/menu-item.js +1 -1
- package/dist/cjs/ui/page-layout/side-nav/side-nav.js +76 -8
- package/dist/cjs/ui/page-layout/side-nav/toggle-button.js +28 -2
- package/dist/cjs/ui/page-layout/side-nav/use-side-nav-visibility-callbacks.js +4 -4
- package/dist/cjs/ui/page-layout/side-nav/visibility-provider.js +2 -1
- package/dist/es2019/ui/menu-item/button-menu-item.js +34 -30
- package/dist/es2019/ui/menu-item/menu-item.compiled.css +2 -0
- package/dist/es2019/ui/menu-item/menu-item.js +1 -1
- package/dist/es2019/ui/page-layout/side-nav/side-nav.js +71 -4
- package/dist/es2019/ui/page-layout/side-nav/toggle-button.js +29 -2
- package/dist/es2019/ui/page-layout/side-nav/use-side-nav-visibility-callbacks.js +4 -4
- package/dist/es2019/ui/page-layout/side-nav/visibility-provider.js +2 -1
- package/dist/esm/ui/menu-item/button-menu-item.js +9 -7
- package/dist/esm/ui/menu-item/menu-item.compiled.css +2 -0
- package/dist/esm/ui/menu-item/menu-item.js +1 -1
- package/dist/esm/ui/page-layout/side-nav/side-nav.js +76 -8
- package/dist/esm/ui/page-layout/side-nav/toggle-button.js +28 -2
- package/dist/esm/ui/page-layout/side-nav/use-side-nav-visibility-callbacks.js +4 -4
- package/dist/esm/ui/page-layout/side-nav/visibility-provider.js +2 -1
- package/dist/types/ui/menu-item/button-menu-item.d.ts +14 -5
- package/dist/types/ui/menu-item/expandable-menu-item/expandable-menu-item-trigger.d.ts +0 -4
- package/dist/types/ui/menu-item/flyout-menu-item/flyout-menu-item-trigger.d.ts +0 -4
- package/dist/types/ui/menu-item/menu-item.d.ts +0 -1
- package/dist/types/ui/menu-item/types.d.ts +4 -0
- package/dist/types/ui/page-layout/panel-splitter/context.d.ts +1 -1
- package/dist/types/ui/page-layout/side-nav/side-nav.d.ts +2 -2
- package/dist/types-ts4.5/ui/menu-item/button-menu-item.d.ts +14 -5
- package/dist/types-ts4.5/ui/menu-item/expandable-menu-item/expandable-menu-item-trigger.d.ts +0 -4
- package/dist/types-ts4.5/ui/menu-item/flyout-menu-item/flyout-menu-item-trigger.d.ts +0 -4
- package/dist/types-ts4.5/ui/menu-item/menu-item.d.ts +0 -1
- package/dist/types-ts4.5/ui/menu-item/types.d.ts +4 -0
- package/dist/types-ts4.5/ui/page-layout/panel-splitter/context.d.ts +1 -1
- package/dist/types-ts4.5/ui/page-layout/side-nav/side-nav.d.ts +2 -2
- package/package.json +12 -6
|
@@ -3,6 +3,7 @@ import "./toggle-button.compiled.css";
|
|
|
3
3
|
import { ax, ix } from "@compiled/react/runtime";
|
|
4
4
|
import React, { useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
|
|
5
5
|
import { bind } from 'bind-event-listener';
|
|
6
|
+
import { useAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
6
7
|
import SidebarCollapseIcon from '@atlaskit/icon/core/sidebar-collapse';
|
|
7
8
|
import SidebarExpandIcon from '@atlaskit/icon/core/sidebar-expand';
|
|
8
9
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
@@ -45,7 +46,7 @@ export const SideNavToggleButton = ({
|
|
|
45
46
|
|
|
46
47
|
// When default state is provided to `Root` the state in context will already be
|
|
47
48
|
// initialized in SSR
|
|
48
|
-
const [isSideNavExpanded, setIsSideNavExpanded] = useState(sideNavState === null ? !defaultCollapsed : isSideNavExpandedOnDesktop);
|
|
49
|
+
const [isSideNavExpanded, setIsSideNavExpanded] = useState(sideNavState === null || !fg('platform_dst_nav4_side_nav_default_collapsed_api') ? !defaultCollapsed : isSideNavExpandedOnDesktop);
|
|
49
50
|
const ref = useContext(SideNavToggleButtonAttachRef);
|
|
50
51
|
const elementRef = useRef(null);
|
|
51
52
|
|
|
@@ -88,12 +89,37 @@ export const SideNavToggleButton = ({
|
|
|
88
89
|
const toggleVisibility = useToggleSideNav({
|
|
89
90
|
trigger: 'toggle-button'
|
|
90
91
|
});
|
|
92
|
+
const {
|
|
93
|
+
createAnalyticsEvent
|
|
94
|
+
} = useAnalyticsEvents();
|
|
91
95
|
const handleClick = useCallback((event, analyticsEvent) => {
|
|
92
96
|
onClick === null || onClick === void 0 ? void 0 : onClick(event, analyticsEvent, {
|
|
93
97
|
isSideNavVisible: isSideNavExpanded
|
|
94
98
|
});
|
|
95
99
|
toggleVisibility();
|
|
96
|
-
}, [onClick,
|
|
100
|
+
}, [onClick, isSideNavExpanded, toggleVisibility]);
|
|
101
|
+
const handlePointerEnter = useCallback(() => {
|
|
102
|
+
if (!fg('platform_dst_nav4_fhs_instrumentation_1')) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// Hovers don't do anything on mobile, so not capturing
|
|
107
|
+
const isDesktop = window.matchMedia('(min-width: 64rem)').matches;
|
|
108
|
+
if (!isDesktop) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
const navigationAnalyticsEvent = createAnalyticsEvent({
|
|
112
|
+
source: 'topNav',
|
|
113
|
+
actionSubject: 'sideNav',
|
|
114
|
+
action: 'hovered',
|
|
115
|
+
actionSubjectId: 'sideNavButton',
|
|
116
|
+
attributes: {
|
|
117
|
+
itemState: isSideNavExpanded ? 'expanded' : 'collapsed',
|
|
118
|
+
screen: 'desktop'
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
navigationAnalyticsEvent.fire('navigation');
|
|
122
|
+
}, [createAnalyticsEvent, isSideNavExpanded]);
|
|
97
123
|
|
|
98
124
|
/**
|
|
99
125
|
* ## Behaviour
|
|
@@ -127,6 +153,7 @@ export const SideNavToggleButton = ({
|
|
|
127
153
|
label: isSideNavExpanded ? collapseLabel : expandLabel,
|
|
128
154
|
icon: icon,
|
|
129
155
|
onClick: handleClick,
|
|
156
|
+
onPointerEnter: handlePointerEnter,
|
|
130
157
|
testId: testId,
|
|
131
158
|
isTooltipDisabled: false,
|
|
132
159
|
interactionName: interactionName,
|
|
@@ -32,7 +32,7 @@ export function useSideNavVisibilityCallbacks({
|
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
34
|
if (isExpandedOnDesktop) {
|
|
35
|
-
if (fg('
|
|
35
|
+
if (fg('platform_dst_nav4_fhs_instrumentation_1')) {
|
|
36
36
|
var _onExpandRef$current;
|
|
37
37
|
(_onExpandRef$current = onExpandRef.current) === null || _onExpandRef$current === void 0 ? void 0 : _onExpandRef$current.call(onExpandRef, {
|
|
38
38
|
screen: 'desktop',
|
|
@@ -45,7 +45,7 @@ export function useSideNavVisibilityCallbacks({
|
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
47
|
} else {
|
|
48
|
-
if (fg('
|
|
48
|
+
if (fg('platform_dst_nav4_fhs_instrumentation_1')) {
|
|
49
49
|
var _onCollapseRef$curren;
|
|
50
50
|
(_onCollapseRef$curren = onCollapseRef.current) === null || _onCollapseRef$curren === void 0 ? void 0 : _onCollapseRef$curren.call(onCollapseRef, {
|
|
51
51
|
screen: 'desktop',
|
|
@@ -72,7 +72,7 @@ export function useSideNavVisibilityCallbacks({
|
|
|
72
72
|
return;
|
|
73
73
|
}
|
|
74
74
|
if (isExpandedOnMobile) {
|
|
75
|
-
if (fg('
|
|
75
|
+
if (fg('platform_dst_nav4_fhs_instrumentation_1')) {
|
|
76
76
|
var _onExpandRef$current3;
|
|
77
77
|
(_onExpandRef$current3 = onExpandRef.current) === null || _onExpandRef$current3 === void 0 ? void 0 : _onExpandRef$current3.call(onExpandRef, {
|
|
78
78
|
screen: 'mobile',
|
|
@@ -85,7 +85,7 @@ export function useSideNavVisibilityCallbacks({
|
|
|
85
85
|
});
|
|
86
86
|
}
|
|
87
87
|
} else {
|
|
88
|
-
if (fg('
|
|
88
|
+
if (fg('platform_dst_nav4_fhs_instrumentation_1')) {
|
|
89
89
|
var _onCollapseRef$curren3;
|
|
90
90
|
(_onCollapseRef$curren3 = onCollapseRef.current) === null || _onCollapseRef$curren3 === void 0 ? void 0 : _onCollapseRef$curren3.call(onCollapseRef, {
|
|
91
91
|
screen: 'mobile',
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
3
|
import { SetSideNavVisibilityState, SideNavVisibilityState } from './visibility-context';
|
|
3
4
|
|
|
4
5
|
/**
|
|
@@ -8,7 +9,7 @@ export const SideNavVisibilityProvider = ({
|
|
|
8
9
|
children,
|
|
9
10
|
defaultCollapsed
|
|
10
11
|
}) => {
|
|
11
|
-
const initialState = typeof defaultCollapsed === 'boolean' ? {
|
|
12
|
+
const initialState = typeof defaultCollapsed === 'boolean' && fg('platform_dst_nav4_side_nav_default_collapsed_api') ? {
|
|
12
13
|
desktop: defaultCollapsed ? 'collapsed' : 'expanded',
|
|
13
14
|
mobile: 'collapsed',
|
|
14
15
|
flyout: 'closed',
|
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
import React, { forwardRef } from 'react';
|
|
2
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
3
|
import { MenuItemBase } from './menu-item';
|
|
3
4
|
import { MenuListItem } from './menu-list-item';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* We intentionally do not support the `isSelected` prop (which other menu item components
|
|
7
|
-
* support) because `ButtonMenuItem`s do not correspond to a "page", so can't be navigated
|
|
8
|
-
* to and become in a selected state.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
5
|
/**
|
|
12
6
|
* __ButtonMenuItem__
|
|
13
7
|
*
|
|
@@ -20,9 +14,13 @@ export var ButtonMenuItem = /*#__PURE__*/forwardRef(function (_ref, forwardedRef
|
|
|
20
14
|
description = _ref.description,
|
|
21
15
|
elemAfter = _ref.elemAfter,
|
|
22
16
|
isDisabled = _ref.isDisabled,
|
|
17
|
+
isSelected = _ref.isSelected,
|
|
23
18
|
elemBefore = _ref.elemBefore,
|
|
24
19
|
actionsOnHover = _ref.actionsOnHover,
|
|
25
20
|
onClick = _ref.onClick,
|
|
21
|
+
ariaControls = _ref['aria-controls'],
|
|
22
|
+
ariaExpanded = _ref['aria-expanded'],
|
|
23
|
+
ariaHasPopup = _ref['aria-haspopup'],
|
|
26
24
|
interactionName = _ref.interactionName,
|
|
27
25
|
isContentTooltipDisabled = _ref.isContentTooltipDisabled,
|
|
28
26
|
visualContentRef = _ref.visualContentRef,
|
|
@@ -45,6 +43,10 @@ export var ButtonMenuItem = /*#__PURE__*/forwardRef(function (_ref, forwardedRef
|
|
|
45
43
|
actions: isDisabled ? undefined : actions,
|
|
46
44
|
actionsOnHover: isDisabled ? undefined : actionsOnHover,
|
|
47
45
|
onClick: onClick,
|
|
46
|
+
ariaControls: fg('platform-dst-buttonmenuitem-selected-state-support') ? ariaControls : undefined,
|
|
47
|
+
ariaExpanded: fg('platform-dst-buttonmenuitem-selected-state-support') ? ariaExpanded : undefined,
|
|
48
|
+
ariaHasPopup: fg('platform-dst-buttonmenuitem-selected-state-support') ? ariaHasPopup : undefined,
|
|
49
|
+
isSelected: fg('platform-dst-buttonmenuitem-selected-state-support') ? isSelected : undefined,
|
|
48
50
|
ref: forwardedRef,
|
|
49
51
|
visualContentRef: visualContentRef,
|
|
50
52
|
interactionName: interactionName,
|
|
@@ -57,6 +57,7 @@
|
|
|
57
57
|
._bfhk1o0g{background-color:var(--notch-color)}
|
|
58
58
|
._bfhkcdhy{background-color:var(--ds-background-neutral-bold,#44546f)}
|
|
59
59
|
._bfhkfg4m{background-color:var(--ds-background-selected,#e9f2ff)}
|
|
60
|
+
._bfhkn7od{background-color:unset}
|
|
60
61
|
._bozg12x7{padding-inline-start:var(--ds-space-075,6px)}
|
|
61
62
|
._bozg1b66{padding-inline-start:var(--ds-space-050,4px)}
|
|
62
63
|
._db801b66{--actions-on-hover-padding:var(--ds-space-050,4px)}
|
|
@@ -96,6 +97,7 @@
|
|
|
96
97
|
._11om6b4r:hover{animation-name:k1xyysw3}
|
|
97
98
|
._1sjuglyw:hover{--elem-after-display:none}
|
|
98
99
|
._1uy01amc:hover{animation-delay:.8s}
|
|
100
|
+
._30l31lh4:hover{color:var(--ds-text-disabled,#091e424f)}
|
|
99
101
|
._30l3aqb7:hover{color:var(--ds-text-selected,#0c66e4)}
|
|
100
102
|
._7psyru3m:hover{animation-duration:0s}
|
|
101
103
|
._bir2q7pw:hover{animation-fill-mode:forwards}
|
|
@@ -143,7 +143,7 @@ var containerStyles = {
|
|
|
143
143
|
showHoverActions: "_uomdkb7n _pmxp1wug _db801b66",
|
|
144
144
|
removeElemAfterOnHoverOrOpenNestedPopup: "_1djyglyw _1mfcglyw _1sjuglyw",
|
|
145
145
|
selected: "_bfhkfg4m _syazaqb7 _1yyu1fvw _1swvi1yw _30l3aqb7 _irr3i1yw",
|
|
146
|
-
disabled: "_syaz1lh4 _irr3n7od",
|
|
146
|
+
disabled: "_syaz1lh4 _bfhkn7od _irr3n7od _30l31lh4",
|
|
147
147
|
hasDescription: "_4t3i1wto",
|
|
148
148
|
dragging: "_tzy41ou4"
|
|
149
149
|
};
|
|
@@ -10,6 +10,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
10
10
|
import { useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
|
11
11
|
import { bind } from 'bind-event-listener';
|
|
12
12
|
import { flushSync } from 'react-dom';
|
|
13
|
+
import { useAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
13
14
|
import mergeRefs from '@atlaskit/ds-lib/merge-refs';
|
|
14
15
|
import useStableRef from '@atlaskit/ds-lib/use-stable-ref';
|
|
15
16
|
import { OpenLayerObserverNamespaceProvider, useOpenLayerObserver } from '@atlaskit/layering/experimental/open-layer-observer';
|
|
@@ -134,15 +135,43 @@ function SideNavInternal(_ref) {
|
|
|
134
135
|
var _useState = useState(defaultCollapsed),
|
|
135
136
|
_useState2 = _slicedToArray(_useState, 1),
|
|
136
137
|
initialDefaultCollapsed = _useState2[0];
|
|
138
|
+
var _useAnalyticsEvents = useAnalyticsEvents(),
|
|
139
|
+
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
|
|
140
|
+
var _useState3 = useState(isExpandedOnDesktop),
|
|
141
|
+
_useState4 = _slicedToArray(_useState3, 1),
|
|
142
|
+
initialIsExpandedOnDesktop = _useState4[0];
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Captures the initial collapsed/expanded state of the side nav.
|
|
146
|
+
*
|
|
147
|
+
* Only firing on desktop because the nav is never open by default on mobile.
|
|
148
|
+
*/
|
|
149
|
+
useEffect(function () {
|
|
150
|
+
if (initialIsExpandedOnDesktop && fg('platform_dst_nav4_fhs_instrumentation_1')) {
|
|
151
|
+
var isDesktop = window.matchMedia('(min-width: 64rem)').matches;
|
|
152
|
+
if (isDesktop) {
|
|
153
|
+
var navigationAnalyticsEvent = createAnalyticsEvent({
|
|
154
|
+
source: 'topNav',
|
|
155
|
+
actionSubject: 'sideNav',
|
|
156
|
+
action: 'viewed',
|
|
157
|
+
actionSubjectId: 'sideNavMenu',
|
|
158
|
+
attributes: {
|
|
159
|
+
screen: 'desktop'
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
navigationAnalyticsEvent.fire('navigation');
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}, [createAnalyticsEvent, initialIsExpandedOnDesktop]);
|
|
137
166
|
var defaultWidth = useSafeDefaultWidth({
|
|
138
167
|
defaultWidthProp: defaultWidthProp,
|
|
139
168
|
fallbackDefaultWidth: fallbackDefaultWidth,
|
|
140
169
|
slotName: 'SideNav'
|
|
141
170
|
});
|
|
142
|
-
var
|
|
143
|
-
|
|
144
|
-
width =
|
|
145
|
-
setWidth =
|
|
171
|
+
var _useState5 = useState(defaultWidth),
|
|
172
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
173
|
+
width = _useState6[0],
|
|
174
|
+
setWidth = _useState6[1];
|
|
146
175
|
var clampedWidth = "clamp(".concat(widthResizeBounds.min, ", ").concat(width, "px, ").concat(widthResizeBounds.max, ")");
|
|
147
176
|
var dangerouslyHoistSlotSizes = useContext(DangerouslyHoistSlotSizes);
|
|
148
177
|
var navRef = useRef(null);
|
|
@@ -294,10 +323,29 @@ function SideNavInternal(_ref) {
|
|
|
294
323
|
var toggleVisibilityByClickOutsideOnMobile = useToggleSideNav({
|
|
295
324
|
trigger: 'click-outside-on-mobile'
|
|
296
325
|
});
|
|
326
|
+
useEffect(function () {
|
|
327
|
+
if (fg('platform_dst_nav4_side_nav_default_collapsed_api')) {
|
|
328
|
+
// This is the old version of the hook, so we skip it when the flag is enabled
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
// Sync the visibility in context (provided in `<Root>`) with the local `defaultCollapsed` prop provided to `SideNav`
|
|
333
|
+
// after SSR hydration. This should only run once, after the initial render on the client.
|
|
334
|
+
setSideNavState({
|
|
335
|
+
desktop: initialDefaultCollapsed ? 'collapsed' : 'expanded',
|
|
336
|
+
mobile: 'collapsed',
|
|
337
|
+
flyout: 'closed',
|
|
338
|
+
lastTrigger: null
|
|
339
|
+
});
|
|
340
|
+
}, [initialDefaultCollapsed, setSideNavState]);
|
|
297
341
|
|
|
298
342
|
// Moving to `useLayoutEffect` so that there's no visual shift in non-SSR environments when using legacy API
|
|
299
343
|
// For SSR the new API is still necessary
|
|
300
344
|
useLayoutEffect(function () {
|
|
345
|
+
if (!fg('platform_dst_nav4_side_nav_default_collapsed_api')) {
|
|
346
|
+
// This is the new version of the hook, so we skip it when the flag is disabled
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
301
349
|
if (sideNavState !== null) {
|
|
302
350
|
// Only need to do an initial sync if it hasn't been initialized from Root
|
|
303
351
|
return;
|
|
@@ -315,11 +363,21 @@ function SideNavInternal(_ref) {
|
|
|
315
363
|
var handleExpand = useCallback(function (_ref2) {
|
|
316
364
|
var screen = _ref2.screen,
|
|
317
365
|
trigger = _ref2.trigger;
|
|
318
|
-
if (fg('
|
|
366
|
+
if (fg('platform_dst_nav4_fhs_instrumentation_1')) {
|
|
319
367
|
onExpand === null || onExpand === void 0 || onExpand({
|
|
320
368
|
screen: screen,
|
|
321
369
|
trigger: trigger
|
|
322
370
|
});
|
|
371
|
+
var navigationAnalyticsEvent = createAnalyticsEvent({
|
|
372
|
+
source: 'topNav',
|
|
373
|
+
actionSubject: 'sideNav',
|
|
374
|
+
action: 'expanded',
|
|
375
|
+
actionSubjectId: 'sideNavMenu',
|
|
376
|
+
attributes: {
|
|
377
|
+
trigger: trigger
|
|
378
|
+
}
|
|
379
|
+
});
|
|
380
|
+
navigationAnalyticsEvent.fire('navigation');
|
|
323
381
|
} else {
|
|
324
382
|
onExpand === null || onExpand === void 0 || onExpand({
|
|
325
383
|
screen: screen
|
|
@@ -329,15 +387,25 @@ function SideNavInternal(_ref) {
|
|
|
329
387
|
// When the side nav gets expanded, we close the flyout to reset it.
|
|
330
388
|
// This prevents the flyout from staying open and ensures we are respecting the user's intent to expand.
|
|
331
389
|
updateFlyoutState('force-close');
|
|
332
|
-
}, [onExpand, updateFlyoutState]);
|
|
390
|
+
}, [onExpand, updateFlyoutState, createAnalyticsEvent]);
|
|
333
391
|
var handleCollapse = useCallback(function (_ref3) {
|
|
334
392
|
var screen = _ref3.screen,
|
|
335
393
|
trigger = _ref3.trigger;
|
|
336
|
-
if (fg('
|
|
394
|
+
if (fg('platform_dst_nav4_fhs_instrumentation_1')) {
|
|
337
395
|
onCollapse === null || onCollapse === void 0 || onCollapse({
|
|
338
396
|
screen: screen,
|
|
339
397
|
trigger: trigger
|
|
340
398
|
});
|
|
399
|
+
var navigationAnalyticsEvent = createAnalyticsEvent({
|
|
400
|
+
source: 'topNav',
|
|
401
|
+
actionSubject: 'sideNav',
|
|
402
|
+
action: 'collapsed',
|
|
403
|
+
actionSubjectId: 'sideNavMenu',
|
|
404
|
+
attributes: {
|
|
405
|
+
trigger: trigger
|
|
406
|
+
}
|
|
407
|
+
});
|
|
408
|
+
navigationAnalyticsEvent.fire('navigation');
|
|
341
409
|
} else {
|
|
342
410
|
onCollapse === null || onCollapse === void 0 || onCollapse({
|
|
343
411
|
screen: screen
|
|
@@ -347,7 +415,7 @@ function SideNavInternal(_ref) {
|
|
|
347
415
|
// When the side nav gets collapsed, we close the flyout to reset it.
|
|
348
416
|
// This prevents the flyout from staying open and ensures we are respecting the user's intent to collapse.
|
|
349
417
|
updateFlyoutState('force-close');
|
|
350
|
-
}, [onCollapse, updateFlyoutState]);
|
|
418
|
+
}, [onCollapse, updateFlyoutState, createAnalyticsEvent]);
|
|
351
419
|
useSideNavVisibilityCallbacks({
|
|
352
420
|
onExpand: handleExpand,
|
|
353
421
|
onCollapse: handleCollapse,
|
|
@@ -7,6 +7,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
7
7
|
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; }
|
|
8
8
|
import React, { useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
|
|
9
9
|
import { bind } from 'bind-event-listener';
|
|
10
|
+
import { useAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
10
11
|
import SidebarCollapseIcon from '@atlaskit/icon/core/sidebar-collapse';
|
|
11
12
|
import SidebarExpandIcon from '@atlaskit/icon/core/sidebar-expand';
|
|
12
13
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
@@ -48,7 +49,7 @@ export var SideNavToggleButton = function SideNavToggleButton(_ref) {
|
|
|
48
49
|
|
|
49
50
|
// When default state is provided to `Root` the state in context will already be
|
|
50
51
|
// initialized in SSR
|
|
51
|
-
var _useState = useState(sideNavState === null ? !defaultCollapsed : isSideNavExpandedOnDesktop),
|
|
52
|
+
var _useState = useState(sideNavState === null || !fg('platform_dst_nav4_side_nav_default_collapsed_api') ? !defaultCollapsed : isSideNavExpandedOnDesktop),
|
|
52
53
|
_useState2 = _slicedToArray(_useState, 2),
|
|
53
54
|
isSideNavExpanded = _useState2[0],
|
|
54
55
|
setIsSideNavExpanded = _useState2[1];
|
|
@@ -96,12 +97,36 @@ export var SideNavToggleButton = function SideNavToggleButton(_ref) {
|
|
|
96
97
|
var toggleVisibility = useToggleSideNav({
|
|
97
98
|
trigger: 'toggle-button'
|
|
98
99
|
});
|
|
100
|
+
var _useAnalyticsEvents = useAnalyticsEvents(),
|
|
101
|
+
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
|
|
99
102
|
var handleClick = useCallback(function (event, analyticsEvent) {
|
|
100
103
|
onClick === null || onClick === void 0 || onClick(event, analyticsEvent, {
|
|
101
104
|
isSideNavVisible: isSideNavExpanded
|
|
102
105
|
});
|
|
103
106
|
toggleVisibility();
|
|
104
|
-
}, [onClick,
|
|
107
|
+
}, [onClick, isSideNavExpanded, toggleVisibility]);
|
|
108
|
+
var handlePointerEnter = useCallback(function () {
|
|
109
|
+
if (!fg('platform_dst_nav4_fhs_instrumentation_1')) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Hovers don't do anything on mobile, so not capturing
|
|
114
|
+
var isDesktop = window.matchMedia('(min-width: 64rem)').matches;
|
|
115
|
+
if (!isDesktop) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
var navigationAnalyticsEvent = createAnalyticsEvent({
|
|
119
|
+
source: 'topNav',
|
|
120
|
+
actionSubject: 'sideNav',
|
|
121
|
+
action: 'hovered',
|
|
122
|
+
actionSubjectId: 'sideNavButton',
|
|
123
|
+
attributes: {
|
|
124
|
+
itemState: isSideNavExpanded ? 'expanded' : 'collapsed',
|
|
125
|
+
screen: 'desktop'
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
navigationAnalyticsEvent.fire('navigation');
|
|
129
|
+
}, [createAnalyticsEvent, isSideNavExpanded]);
|
|
105
130
|
|
|
106
131
|
/**
|
|
107
132
|
* ## Behaviour
|
|
@@ -136,6 +161,7 @@ export var SideNavToggleButton = function SideNavToggleButton(_ref) {
|
|
|
136
161
|
label: isSideNavExpanded ? collapseLabel : expandLabel,
|
|
137
162
|
icon: icon,
|
|
138
163
|
onClick: handleClick,
|
|
164
|
+
onPointerEnter: handlePointerEnter,
|
|
139
165
|
testId: testId,
|
|
140
166
|
isTooltipDisabled: false,
|
|
141
167
|
interactionName: interactionName,
|
|
@@ -31,7 +31,7 @@ export function useSideNavVisibilityCallbacks(_ref) {
|
|
|
31
31
|
return;
|
|
32
32
|
}
|
|
33
33
|
if (isExpandedOnDesktop) {
|
|
34
|
-
if (fg('
|
|
34
|
+
if (fg('platform_dst_nav4_fhs_instrumentation_1')) {
|
|
35
35
|
var _onExpandRef$current;
|
|
36
36
|
(_onExpandRef$current = onExpandRef.current) === null || _onExpandRef$current === void 0 || _onExpandRef$current.call(onExpandRef, {
|
|
37
37
|
screen: 'desktop',
|
|
@@ -44,7 +44,7 @@ export function useSideNavVisibilityCallbacks(_ref) {
|
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
46
|
} else {
|
|
47
|
-
if (fg('
|
|
47
|
+
if (fg('platform_dst_nav4_fhs_instrumentation_1')) {
|
|
48
48
|
var _onCollapseRef$curren;
|
|
49
49
|
(_onCollapseRef$curren = onCollapseRef.current) === null || _onCollapseRef$curren === void 0 || _onCollapseRef$curren.call(onCollapseRef, {
|
|
50
50
|
screen: 'desktop',
|
|
@@ -71,7 +71,7 @@ export function useSideNavVisibilityCallbacks(_ref) {
|
|
|
71
71
|
return;
|
|
72
72
|
}
|
|
73
73
|
if (isExpandedOnMobile) {
|
|
74
|
-
if (fg('
|
|
74
|
+
if (fg('platform_dst_nav4_fhs_instrumentation_1')) {
|
|
75
75
|
var _onExpandRef$current3;
|
|
76
76
|
(_onExpandRef$current3 = onExpandRef.current) === null || _onExpandRef$current3 === void 0 || _onExpandRef$current3.call(onExpandRef, {
|
|
77
77
|
screen: 'mobile',
|
|
@@ -84,7 +84,7 @@ export function useSideNavVisibilityCallbacks(_ref) {
|
|
|
84
84
|
});
|
|
85
85
|
}
|
|
86
86
|
} else {
|
|
87
|
-
if (fg('
|
|
87
|
+
if (fg('platform_dst_nav4_fhs_instrumentation_1')) {
|
|
88
88
|
var _onCollapseRef$curren3;
|
|
89
89
|
(_onCollapseRef$curren3 = onCollapseRef.current) === null || _onCollapseRef$curren3 === void 0 || _onCollapseRef$curren3.call(onCollapseRef, {
|
|
90
90
|
screen: 'mobile',
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
2
|
import React, { useState } from 'react';
|
|
3
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
4
|
import { SetSideNavVisibilityState, SideNavVisibilityState } from './visibility-context';
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -8,7 +9,7 @@ import { SetSideNavVisibilityState, SideNavVisibilityState } from './visibility-
|
|
|
8
9
|
export var SideNavVisibilityProvider = function SideNavVisibilityProvider(_ref) {
|
|
9
10
|
var children = _ref.children,
|
|
10
11
|
defaultCollapsed = _ref.defaultCollapsed;
|
|
11
|
-
var initialState = typeof defaultCollapsed === 'boolean' ? {
|
|
12
|
+
var initialState = typeof defaultCollapsed === 'boolean' && fg('platform_dst_nav4_side_nav_default_collapsed_api') ? {
|
|
12
13
|
desktop: defaultCollapsed ? 'collapsed' : 'expanded',
|
|
13
14
|
mobile: 'collapsed',
|
|
14
15
|
flyout: 'closed',
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { MenuItemLinkOrButtonCommonProps, MenuItemOnClick } from './types';
|
|
3
|
-
/**
|
|
4
|
-
* We intentionally do not support the `isSelected` prop (which other menu item components
|
|
5
|
-
* support) because `ButtonMenuItem`s do not correspond to a "page", so can't be navigated
|
|
6
|
-
* to and become in a selected state.
|
|
7
|
-
*/
|
|
8
3
|
export type ButtonMenuItemProps = MenuItemLinkOrButtonCommonProps & {
|
|
9
4
|
/**
|
|
10
5
|
* We are not using a discriminated union to enforce that the `actions` and `actionsOnHover`
|
|
@@ -24,6 +19,20 @@ export type ButtonMenuItemProps = MenuItemLinkOrButtonCommonProps & {
|
|
|
24
19
|
* Called when the user has clicked on the trigger content.
|
|
25
20
|
*/
|
|
26
21
|
onClick?: MenuItemOnClick<HTMLButtonElement>;
|
|
22
|
+
/**
|
|
23
|
+
* Identifies the popup element that this element controls when it is used as a popup trigger.
|
|
24
|
+
* Should match the `id` of the popup content for screen readers to understand the relationship.
|
|
25
|
+
*/
|
|
26
|
+
'aria-controls'?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Announces to assistive technology whether the popup is currently open or closed,
|
|
29
|
+
* when this element is used as a popup trigger.
|
|
30
|
+
*/
|
|
31
|
+
'aria-expanded'?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Informs assistive technology that this element triggers a popup.
|
|
34
|
+
*/
|
|
35
|
+
'aria-haspopup'?: boolean | 'dialog';
|
|
27
36
|
};
|
|
28
37
|
/**
|
|
29
38
|
* __ButtonMenuItem__
|
|
@@ -34,10 +34,6 @@ export type ExpandableMenuItemTriggerProps = MenuItemCommonProps & Omit<MenuItem
|
|
|
34
34
|
* will always be displayed.
|
|
35
35
|
*/
|
|
36
36
|
elemBefore?: ReactNode;
|
|
37
|
-
/**
|
|
38
|
-
* Indicates that the menu item is selected.
|
|
39
|
-
*/
|
|
40
|
-
isSelected?: boolean;
|
|
41
37
|
/**
|
|
42
38
|
* If provided, the chevron icon (expand/collapse symbol) will be rendered within a separate
|
|
43
39
|
* icon button element. Clicking on this icon button will not trigger the `onClick` event. It
|
|
@@ -37,10 +37,6 @@ export type FlyoutMenuItemTriggerProps = MenuItemCommonProps & {
|
|
|
37
37
|
* If you are controlling the open state of the flyout menu, use this to update your state.
|
|
38
38
|
*/
|
|
39
39
|
onClick?: MenuItemOnClick<HTMLButtonElement>;
|
|
40
|
-
/**
|
|
41
|
-
* Indicates that the menu item is selected.
|
|
42
|
-
*/
|
|
43
|
-
isSelected?: boolean;
|
|
44
40
|
};
|
|
45
41
|
/**
|
|
46
42
|
* __FlyoutMenuItemTrigger__
|
|
@@ -34,7 +34,6 @@ type MenuItemBaseProps<T extends HTMLAnchorElement | HTMLButtonElement> = MenuIt
|
|
|
34
34
|
href?: string | Record<string, any>;
|
|
35
35
|
target?: HTMLAnchorElement['target'];
|
|
36
36
|
isDisabled?: boolean;
|
|
37
|
-
isSelected?: boolean;
|
|
38
37
|
ariaControls?: string;
|
|
39
38
|
ariaExpanded?: boolean;
|
|
40
39
|
ariaHasPopup?: boolean | 'dialog';
|
|
@@ -33,6 +33,10 @@ export type MenuItemCommonProps = {
|
|
|
33
33
|
* to display the full menu content and description of a menu item close by (eg with another popup)
|
|
34
34
|
*/
|
|
35
35
|
isContentTooltipDisabled?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Indicates that the menu item is selected.
|
|
38
|
+
*/
|
|
39
|
+
isSelected?: boolean;
|
|
36
40
|
/**
|
|
37
41
|
* Exposes the visually complete menu item, including:
|
|
38
42
|
*
|
|
@@ -50,7 +50,7 @@ export type PanelSplitterContextType = {
|
|
|
50
50
|
isEnabled?: boolean;
|
|
51
51
|
/**
|
|
52
52
|
* The keyboard shortcut to display in the tooltip.
|
|
53
|
-
*
|
|
53
|
+
*
|
|
54
54
|
* Note this does not handle the keyboard shortcut functionality, it only displays the shortcut in the tooltip.
|
|
55
55
|
*/
|
|
56
56
|
shortcut?: TooltipProps['shortcut'];
|
|
@@ -44,13 +44,13 @@ type SideNavProps = CommonSlotProps & {
|
|
|
44
44
|
/**
|
|
45
45
|
* Called when the side nav is expanded.
|
|
46
46
|
*
|
|
47
|
-
* Note: The trigger parameter is only provided when the `
|
|
47
|
+
* Note: The trigger parameter is only provided when the `platform_dst_nav4_fhs_instrumentation_1` feature flag is enabled.
|
|
48
48
|
*/
|
|
49
49
|
onExpand?: VisibilityCallback;
|
|
50
50
|
/**
|
|
51
51
|
* Called when the side nav is collapsed.
|
|
52
52
|
*
|
|
53
|
-
* Note: The trigger parameter is only provided when the `
|
|
53
|
+
* Note: The trigger parameter is only provided when the `platform_dst_nav4_fhs_instrumentation_1` feature flag is enabled.
|
|
54
54
|
*/
|
|
55
55
|
onCollapse?: VisibilityCallback;
|
|
56
56
|
/**
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { MenuItemLinkOrButtonCommonProps, MenuItemOnClick } from './types';
|
|
3
|
-
/**
|
|
4
|
-
* We intentionally do not support the `isSelected` prop (which other menu item components
|
|
5
|
-
* support) because `ButtonMenuItem`s do not correspond to a "page", so can't be navigated
|
|
6
|
-
* to and become in a selected state.
|
|
7
|
-
*/
|
|
8
3
|
export type ButtonMenuItemProps = MenuItemLinkOrButtonCommonProps & {
|
|
9
4
|
/**
|
|
10
5
|
* We are not using a discriminated union to enforce that the `actions` and `actionsOnHover`
|
|
@@ -24,6 +19,20 @@ export type ButtonMenuItemProps = MenuItemLinkOrButtonCommonProps & {
|
|
|
24
19
|
* Called when the user has clicked on the trigger content.
|
|
25
20
|
*/
|
|
26
21
|
onClick?: MenuItemOnClick<HTMLButtonElement>;
|
|
22
|
+
/**
|
|
23
|
+
* Identifies the popup element that this element controls when it is used as a popup trigger.
|
|
24
|
+
* Should match the `id` of the popup content for screen readers to understand the relationship.
|
|
25
|
+
*/
|
|
26
|
+
'aria-controls'?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Announces to assistive technology whether the popup is currently open or closed,
|
|
29
|
+
* when this element is used as a popup trigger.
|
|
30
|
+
*/
|
|
31
|
+
'aria-expanded'?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Informs assistive technology that this element triggers a popup.
|
|
34
|
+
*/
|
|
35
|
+
'aria-haspopup'?: boolean | 'dialog';
|
|
27
36
|
};
|
|
28
37
|
/**
|
|
29
38
|
* __ButtonMenuItem__
|
package/dist/types-ts4.5/ui/menu-item/expandable-menu-item/expandable-menu-item-trigger.d.ts
CHANGED
|
@@ -34,10 +34,6 @@ export type ExpandableMenuItemTriggerProps = MenuItemCommonProps & Omit<MenuItem
|
|
|
34
34
|
* will always be displayed.
|
|
35
35
|
*/
|
|
36
36
|
elemBefore?: ReactNode;
|
|
37
|
-
/**
|
|
38
|
-
* Indicates that the menu item is selected.
|
|
39
|
-
*/
|
|
40
|
-
isSelected?: boolean;
|
|
41
37
|
/**
|
|
42
38
|
* If provided, the chevron icon (expand/collapse symbol) will be rendered within a separate
|
|
43
39
|
* icon button element. Clicking on this icon button will not trigger the `onClick` event. It
|
|
@@ -37,10 +37,6 @@ export type FlyoutMenuItemTriggerProps = MenuItemCommonProps & {
|
|
|
37
37
|
* If you are controlling the open state of the flyout menu, use this to update your state.
|
|
38
38
|
*/
|
|
39
39
|
onClick?: MenuItemOnClick<HTMLButtonElement>;
|
|
40
|
-
/**
|
|
41
|
-
* Indicates that the menu item is selected.
|
|
42
|
-
*/
|
|
43
|
-
isSelected?: boolean;
|
|
44
40
|
};
|
|
45
41
|
/**
|
|
46
42
|
* __FlyoutMenuItemTrigger__
|
|
@@ -34,7 +34,6 @@ type MenuItemBaseProps<T extends HTMLAnchorElement | HTMLButtonElement> = MenuIt
|
|
|
34
34
|
href?: string | Record<string, any>;
|
|
35
35
|
target?: HTMLAnchorElement['target'];
|
|
36
36
|
isDisabled?: boolean;
|
|
37
|
-
isSelected?: boolean;
|
|
38
37
|
ariaControls?: string;
|
|
39
38
|
ariaExpanded?: boolean;
|
|
40
39
|
ariaHasPopup?: boolean | 'dialog';
|
|
@@ -33,6 +33,10 @@ export type MenuItemCommonProps = {
|
|
|
33
33
|
* to display the full menu content and description of a menu item close by (eg with another popup)
|
|
34
34
|
*/
|
|
35
35
|
isContentTooltipDisabled?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Indicates that the menu item is selected.
|
|
38
|
+
*/
|
|
39
|
+
isSelected?: boolean;
|
|
36
40
|
/**
|
|
37
41
|
* Exposes the visually complete menu item, including:
|
|
38
42
|
*
|
|
@@ -50,7 +50,7 @@ export type PanelSplitterContextType = {
|
|
|
50
50
|
isEnabled?: boolean;
|
|
51
51
|
/**
|
|
52
52
|
* The keyboard shortcut to display in the tooltip.
|
|
53
|
-
*
|
|
53
|
+
*
|
|
54
54
|
* Note this does not handle the keyboard shortcut functionality, it only displays the shortcut in the tooltip.
|
|
55
55
|
*/
|
|
56
56
|
shortcut?: TooltipProps['shortcut'];
|
|
@@ -44,13 +44,13 @@ type SideNavProps = CommonSlotProps & {
|
|
|
44
44
|
/**
|
|
45
45
|
* Called when the side nav is expanded.
|
|
46
46
|
*
|
|
47
|
-
* Note: The trigger parameter is only provided when the `
|
|
47
|
+
* Note: The trigger parameter is only provided when the `platform_dst_nav4_fhs_instrumentation_1` feature flag is enabled.
|
|
48
48
|
*/
|
|
49
49
|
onExpand?: VisibilityCallback;
|
|
50
50
|
/**
|
|
51
51
|
* Called when the side nav is collapsed.
|
|
52
52
|
*
|
|
53
|
-
* Note: The trigger parameter is only provided when the `
|
|
53
|
+
* Note: The trigger parameter is only provided when the `platform_dst_nav4_fhs_instrumentation_1` feature flag is enabled.
|
|
54
54
|
*/
|
|
55
55
|
onCollapse?: VisibilityCallback;
|
|
56
56
|
/**
|