@atlaskit/side-navigation 1.5.0 → 1.5.2
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/styles.js +7 -19
- package/dist/cjs/components/Footer/index.js +11 -19
- package/dist/cjs/components/Header/index.js +15 -33
- package/dist/cjs/components/Item/button-item.js +6 -20
- package/dist/cjs/components/Item/custom-item.js +8 -21
- package/dist/cjs/components/Item/go-back-item.js +13 -28
- package/dist/cjs/components/Item/index.js +0 -6
- package/dist/cjs/components/Item/link-item.js +6 -20
- package/dist/cjs/components/Item/skeleton-item.js +8 -20
- package/dist/cjs/components/LoadingItems/index.js +8 -16
- package/dist/cjs/components/NavigationContent/index.js +3 -15
- package/dist/cjs/components/NavigationContent/styles.js +9 -24
- package/dist/cjs/components/NavigationFooter/index.js +2 -7
- package/dist/cjs/components/NavigationHeader/index.js +2 -7
- package/dist/cjs/components/NestableNavigationContent/context.js +1 -13
- package/dist/cjs/components/NestableNavigationContent/index.js +30 -51
- package/dist/cjs/components/NestableNavigationContent/nesting-motion.js +3 -11
- package/dist/cjs/components/NestingItem/hack-for-ert.js +0 -1
- package/dist/cjs/components/NestingItem/index.js +25 -61
- package/dist/cjs/components/NestingItem/styles.js +0 -8
- package/dist/cjs/components/Section/heading-item.js +3 -12
- package/dist/cjs/components/Section/index.js +0 -4
- package/dist/cjs/components/Section/section.js +3 -15
- package/dist/cjs/components/Section/skeleton-heading-item.js +5 -17
- package/dist/cjs/components/SideNavigation/index.js +6 -8
- package/dist/cjs/components/index.js +0 -12
- package/dist/cjs/components/utils/hooks.js +2 -10
- package/dist/cjs/index.js +0 -3
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/common/styles.js +7 -6
- package/dist/es2019/components/Footer/index.js +7 -8
- package/dist/es2019/components/Header/index.js +5 -6
- package/dist/es2019/components/Item/button-item.js +4 -6
- package/dist/es2019/components/Item/custom-item.js +7 -8
- package/dist/es2019/components/Item/go-back-item.js +2 -3
- package/dist/es2019/components/Item/link-item.js +4 -6
- package/dist/es2019/components/Item/skeleton-item.js +9 -11
- package/dist/es2019/components/LoadingItems/index.js +3 -6
- package/dist/es2019/components/NavigationContent/index.js +0 -4
- package/dist/es2019/components/NavigationContent/styles.js +9 -10
- package/dist/es2019/components/NavigationFooter/index.js +3 -4
- package/dist/es2019/components/NavigationHeader/index.js +2 -4
- package/dist/es2019/components/NestableNavigationContent/context.js +1 -8
- package/dist/es2019/components/NestableNavigationContent/index.js +17 -22
- package/dist/es2019/components/NestableNavigationContent/nesting-motion.js +1 -1
- package/dist/es2019/components/NestingItem/index.js +7 -17
- package/dist/es2019/components/NestingItem/styles.js +2 -1
- package/dist/es2019/components/Section/heading-item.js +2 -5
- package/dist/es2019/components/Section/section.js +2 -4
- package/dist/es2019/components/Section/skeleton-heading-item.js +6 -8
- package/dist/es2019/components/SideNavigation/index.js +3 -2
- package/dist/es2019/components/utils/hooks.js +2 -4
- package/dist/es2019/version.json +1 -1
- package/dist/esm/common/styles.js +7 -10
- package/dist/esm/components/Footer/index.js +11 -12
- package/dist/esm/components/Header/index.js +16 -20
- package/dist/esm/components/Item/button-item.js +6 -9
- package/dist/esm/components/Item/custom-item.js +9 -11
- package/dist/esm/components/Item/go-back-item.js +13 -16
- package/dist/esm/components/Item/link-item.js +6 -9
- package/dist/esm/components/Item/skeleton-item.js +8 -14
- package/dist/esm/components/LoadingItems/index.js +7 -11
- package/dist/esm/components/NavigationContent/index.js +3 -9
- package/dist/esm/components/NavigationContent/styles.js +9 -13
- package/dist/esm/components/NavigationFooter/index.js +3 -4
- package/dist/esm/components/NavigationHeader/index.js +2 -4
- package/dist/esm/components/NestableNavigationContent/context.js +1 -8
- package/dist/esm/components/NestableNavigationContent/index.js +30 -41
- package/dist/esm/components/NestableNavigationContent/nesting-motion.js +4 -7
- package/dist/esm/components/NestingItem/index.js +25 -41
- package/dist/esm/components/NestingItem/styles.js +0 -4
- package/dist/esm/components/Section/heading-item.js +3 -6
- package/dist/esm/components/Section/section.js +3 -5
- package/dist/esm/components/Section/skeleton-heading-item.js +5 -11
- package/dist/esm/components/SideNavigation/index.js +5 -4
- package/dist/esm/components/utils/hooks.js +2 -4
- package/dist/esm/version.json +1 -1
- package/dist/types/components/NavigationContent/styles.d.ts +4 -4
- package/package.json +2 -2
- package/report.api.md +13 -0
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
|
|
3
2
|
/* eslint-disable @repo/internal/react/use-primitives */
|
|
4
3
|
import React, { forwardRef } from 'react';
|
|
5
4
|
import Box from '@atlaskit/ds-explorations/box';
|
|
@@ -7,12 +6,12 @@ import { N500 } from '@atlaskit/theme/colors';
|
|
|
7
6
|
import { headingSizes } from '@atlaskit/theme/typography';
|
|
8
7
|
import { overrideStyleFunction } from '../../common/styles';
|
|
9
8
|
import { CustomItem } from '../Item';
|
|
9
|
+
|
|
10
10
|
/**
|
|
11
11
|
* __Container__
|
|
12
12
|
*
|
|
13
13
|
* A container for Header and Footer that safely handles props to the child component
|
|
14
14
|
*/
|
|
15
|
-
|
|
16
15
|
export const Container = ({
|
|
17
16
|
children,
|
|
18
17
|
...props
|
|
@@ -39,13 +38,11 @@ export const Container = ({
|
|
|
39
38
|
tabIndex,
|
|
40
39
|
disabled
|
|
41
40
|
}))(props);
|
|
42
|
-
|
|
43
41
|
return /*#__PURE__*/React.createElement(Box, _extends({
|
|
44
42
|
as: "div",
|
|
45
43
|
display: "block"
|
|
46
44
|
}, safeProps), children);
|
|
47
45
|
};
|
|
48
|
-
|
|
49
46
|
/**
|
|
50
47
|
* __Header__
|
|
51
48
|
*
|
|
@@ -73,9 +70,11 @@ const Header = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
73
70
|
}), props.cssFn);
|
|
74
71
|
return /*#__PURE__*/React.createElement(CustomItem, _extends({}, props, {
|
|
75
72
|
ref: ref,
|
|
76
|
-
component: props.component || Container
|
|
73
|
+
component: props.component || Container
|
|
74
|
+
// eslint-disable-next-line @repo/internal/react/no-unsafe-overrides
|
|
77
75
|
,
|
|
78
|
-
cssFn: cssFn
|
|
76
|
+
cssFn: cssFn
|
|
77
|
+
// eslint-disable-next-line @repo/internal/react/no-unsafe-overrides
|
|
79
78
|
,
|
|
80
79
|
overrides: {
|
|
81
80
|
Title: {
|
|
@@ -3,7 +3,6 @@ import React, { forwardRef } from 'react';
|
|
|
3
3
|
import { ButtonItem as Button } from '@atlaskit/menu';
|
|
4
4
|
import { baseSideNavItemStyle, overrideStyleFunction } from '../../common/styles';
|
|
5
5
|
import { useShouldNestedElementRender } from '../NestableNavigationContent/context';
|
|
6
|
-
|
|
7
6
|
/**
|
|
8
7
|
* __Button item__
|
|
9
8
|
*
|
|
@@ -13,7 +12,8 @@ import { useShouldNestedElementRender } from '../NestableNavigationContent/conte
|
|
|
13
12
|
* - [Examples](https://atlassian.design/components/side-navigation/examples#button-item)
|
|
14
13
|
* - [Code](https://atlassian.design/components/side-navigation/code)
|
|
15
14
|
*/
|
|
16
|
-
const ButtonItem = /*#__PURE__*/forwardRef(
|
|
15
|
+
const ButtonItem = /*#__PURE__*/forwardRef(
|
|
16
|
+
// Type needed on props to extract types with extract react types.
|
|
17
17
|
({
|
|
18
18
|
cssFn,
|
|
19
19
|
...rest
|
|
@@ -21,13 +21,11 @@ const ButtonItem = /*#__PURE__*/forwardRef( // Type needed on props to extract t
|
|
|
21
21
|
const {
|
|
22
22
|
shouldRender
|
|
23
23
|
} = useShouldNestedElementRender();
|
|
24
|
-
|
|
25
24
|
if (!shouldRender) {
|
|
26
25
|
return null;
|
|
27
26
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
const cssOverride = overrideStyleFunction(baseSideNavItemStyle, cssFn);
|
|
28
|
+
// eslint-disable-next-line @atlaskit/design-system/no-deprecated-apis, @repo/internal/react/no-unsafe-overrides
|
|
31
29
|
return /*#__PURE__*/React.createElement(Button, _extends({
|
|
32
30
|
ref: ref,
|
|
33
31
|
cssFn: cssOverride
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
|
|
3
2
|
/* eslint-disable @repo/internal/react/no-unsafe-overrides */
|
|
4
3
|
import React, { forwardRef } from 'react';
|
|
5
4
|
import { CustomItem as Custom } from '@atlaskit/menu';
|
|
6
5
|
import { baseSideNavItemStyle, overrideStyleFunction } from '../../common/styles';
|
|
7
6
|
import { useShouldNestedElementRender } from '../NestableNavigationContent/context';
|
|
8
|
-
|
|
9
7
|
/**
|
|
10
8
|
* Used to support any custom items needed by products alongside the Header and Footer patterns.
|
|
11
9
|
* Specific implementation of headers and footers are provided in the examples folder.
|
|
12
10
|
*/
|
|
13
|
-
const CustomItem = /*#__PURE__*/forwardRef(
|
|
11
|
+
const CustomItem = /*#__PURE__*/forwardRef(
|
|
12
|
+
// Type needed on props to extract types with extract react types.
|
|
14
13
|
({
|
|
15
14
|
cssFn,
|
|
16
15
|
...rest
|
|
@@ -18,17 +17,17 @@ const CustomItem = /*#__PURE__*/forwardRef( // Type needed on props to extract t
|
|
|
18
17
|
const {
|
|
19
18
|
shouldRender
|
|
20
19
|
} = useShouldNestedElementRender();
|
|
21
|
-
|
|
22
20
|
if (!shouldRender) {
|
|
23
21
|
return null;
|
|
24
22
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
const cssOverride = overrideStyleFunction(baseSideNavItemStyle, cssFn);
|
|
24
|
+
// eslint-disable-next-line @atlaskit/design-system/no-deprecated-apis
|
|
28
25
|
return /*#__PURE__*/React.createElement(Custom, _extends({
|
|
29
26
|
ref: ref,
|
|
30
27
|
cssFn: cssOverride
|
|
31
28
|
}, rest));
|
|
32
|
-
}
|
|
29
|
+
}
|
|
30
|
+
// Dirty hack to get generics working with forward ref [2/2]
|
|
33
31
|
);
|
|
32
|
+
|
|
34
33
|
export default CustomItem;
|
|
@@ -3,7 +3,6 @@ import React, { forwardRef, useCallback, useState } from 'react';
|
|
|
3
3
|
import LeftArrow from '@atlaskit/icon/glyph/arrow-left-circle';
|
|
4
4
|
import { N10 } from '@atlaskit/theme/colors';
|
|
5
5
|
import ButtonItem from './button-item';
|
|
6
|
-
|
|
7
6
|
/**
|
|
8
7
|
* __Go back item__
|
|
9
8
|
*
|
|
@@ -28,12 +27,12 @@ const GoBackItem = /*#__PURE__*/forwardRef(({
|
|
|
28
27
|
if (isInteracted) {
|
|
29
28
|
return;
|
|
30
29
|
}
|
|
31
|
-
|
|
32
30
|
setIsInteracted(true);
|
|
33
31
|
onClick && onClick(e);
|
|
34
32
|
}, [onClick, isInteracted]);
|
|
35
33
|
return /*#__PURE__*/React.createElement(ButtonItem, _extends({
|
|
36
|
-
isSelected: isSelected || isInteracted
|
|
34
|
+
isSelected: isSelected || isInteracted
|
|
35
|
+
// eslint-disable-next-line @repo/internal/react/no-unsafe-overrides
|
|
37
36
|
,
|
|
38
37
|
cssFn: cssFn,
|
|
39
38
|
iconBefore: iconBefore,
|
|
@@ -3,7 +3,6 @@ import React, { forwardRef } from 'react';
|
|
|
3
3
|
import { LinkItem as Link } from '@atlaskit/menu';
|
|
4
4
|
import { baseSideNavItemStyle, overrideStyleFunction } from '../../common/styles';
|
|
5
5
|
import { useShouldNestedElementRender } from '../NestableNavigationContent/context';
|
|
6
|
-
|
|
7
6
|
/**
|
|
8
7
|
* __Link item__
|
|
9
8
|
*
|
|
@@ -15,7 +14,8 @@ import { useShouldNestedElementRender } from '../NestableNavigationContent/conte
|
|
|
15
14
|
* - [Examples](https://atlassian.design/components/side-navigation/examples#link-item)
|
|
16
15
|
* - [Code](https://atlassian.design/components/side-navigation/code)
|
|
17
16
|
*/
|
|
18
|
-
const LinkItem = /*#__PURE__*/forwardRef(
|
|
17
|
+
const LinkItem = /*#__PURE__*/forwardRef(
|
|
18
|
+
// Type needed on props to extract types with extract react types.
|
|
19
19
|
({
|
|
20
20
|
cssFn,
|
|
21
21
|
...rest
|
|
@@ -23,13 +23,11 @@ const LinkItem = /*#__PURE__*/forwardRef( // Type needed on props to extract typ
|
|
|
23
23
|
const {
|
|
24
24
|
shouldRender
|
|
25
25
|
} = useShouldNestedElementRender();
|
|
26
|
-
|
|
27
26
|
if (!shouldRender) {
|
|
28
27
|
return null;
|
|
29
28
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
const cssOverride = overrideStyleFunction(baseSideNavItemStyle, cssFn);
|
|
30
|
+
// eslint-disable-next-line @atlaskit/design-system/no-deprecated-apis, @repo/internal/react/no-unsafe-overrides
|
|
33
31
|
return /*#__PURE__*/React.createElement(Link, _extends({
|
|
34
32
|
ref: ref,
|
|
35
33
|
cssFn: cssOverride
|
|
@@ -3,7 +3,6 @@ import React from 'react';
|
|
|
3
3
|
import { SkeletonItem as SkelItem } from '@atlaskit/menu';
|
|
4
4
|
import { sectionHeaderSpacingStyles } from '../../common/styles';
|
|
5
5
|
import { useShouldNestedElementRender } from '../NestableNavigationContent/context';
|
|
6
|
-
|
|
7
6
|
/**
|
|
8
7
|
* __Skeleton item__
|
|
9
8
|
*
|
|
@@ -16,23 +15,22 @@ const SkeletonItem = props => {
|
|
|
16
15
|
const {
|
|
17
16
|
shouldRender
|
|
18
17
|
} = useShouldNestedElementRender();
|
|
19
|
-
|
|
20
18
|
if (!shouldRender) {
|
|
21
19
|
return null;
|
|
22
20
|
}
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
return /*#__PURE__*/React.createElement(SkelItem
|
|
22
|
+
// eslint-disable-next-line @atlaskit/design-system/no-deprecated-apis, @repo/internal/react/no-unsafe-overrides
|
|
25
23
|
, _extends({
|
|
26
|
-
cssFn: () => ({
|
|
24
|
+
cssFn: () => ({
|
|
25
|
+
...sectionHeaderSpacingStyles(),
|
|
27
26
|
// This doubles up & to get a higher specificity as well as to not overwite the base styles.
|
|
28
27
|
'&&::before': {
|
|
29
|
-
height: "var(--ds-
|
|
30
|
-
marginRight: "var(--ds-
|
|
31
|
-
width: "var(--ds-
|
|
28
|
+
height: "var(--ds-space-300, 20px)",
|
|
29
|
+
marginRight: "var(--ds-space-200, 18px)",
|
|
30
|
+
width: "var(--ds-space-300, 20px)"
|
|
32
31
|
}
|
|
33
|
-
})
|
|
34
|
-
|
|
32
|
+
})
|
|
33
|
+
// eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
|
|
35
34
|
}, props));
|
|
36
35
|
};
|
|
37
|
-
|
|
38
36
|
export default SkeletonItem;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
|
|
3
2
|
/** @jsx jsx */
|
|
4
3
|
import { css, jsx } from '@emotion/react';
|
|
5
4
|
import { ExitingPersistence, FadeIn, mediumDurationMs } from '@atlaskit/motion';
|
|
@@ -15,12 +14,12 @@ const enteringStyles = css({
|
|
|
15
14
|
position: 'static',
|
|
16
15
|
zIndex: 2
|
|
17
16
|
});
|
|
17
|
+
|
|
18
18
|
/**
|
|
19
19
|
* __Loading items__
|
|
20
20
|
*
|
|
21
21
|
* Loading items conditionally render based on the useShouldNestedElementRender() hook.
|
|
22
22
|
*/
|
|
23
|
-
|
|
24
23
|
const LoadingItems = ({
|
|
25
24
|
children,
|
|
26
25
|
isLoading,
|
|
@@ -30,19 +29,17 @@ const LoadingItems = ({
|
|
|
30
29
|
const {
|
|
31
30
|
shouldRender
|
|
32
31
|
} = useShouldNestedElementRender();
|
|
33
|
-
|
|
34
32
|
if (!shouldRender) {
|
|
35
33
|
return children;
|
|
36
34
|
}
|
|
37
|
-
|
|
38
35
|
return jsx(ExitingPersistence, null, jsx(FadeIn, {
|
|
39
36
|
key: `loading-section-${isLoading}`,
|
|
40
37
|
duration: mediumDurationMs
|
|
41
|
-
}, (motion, state) =>
|
|
38
|
+
}, (motion, state) =>
|
|
39
|
+
// eslint-disable-next-line @repo/internal/react/use-primitives
|
|
42
40
|
jsx("span", _extends({}, motion, {
|
|
43
41
|
"data-testid": testId && `${testId}--${state}`,
|
|
44
42
|
css: [baseMotionStyles, state === 'entering' && enteringStyles]
|
|
45
43
|
}), isLoading ? fallback : children)));
|
|
46
44
|
};
|
|
47
|
-
|
|
48
45
|
export default LoadingItems;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
/* eslint-disable @repo/internal/react/use-primitives */
|
|
2
|
-
|
|
3
2
|
/** @jsx jsx */
|
|
4
3
|
import { forwardRef } from 'react';
|
|
5
4
|
import { jsx } from '@emotion/react';
|
|
6
5
|
import useScrollbarWidth from '@atlaskit/ds-lib/use-scrollbar-width';
|
|
7
6
|
import { useShouldNestedElementRender } from '../NestableNavigationContent/context';
|
|
8
7
|
import { containerCSS, innerContainerCSS, outerContainerCSS } from './styles';
|
|
9
|
-
|
|
10
8
|
/**
|
|
11
9
|
* __Navigation content__
|
|
12
10
|
*
|
|
@@ -25,11 +23,9 @@ const NavigationContent = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
25
23
|
shouldRender
|
|
26
24
|
} = useShouldNestedElementRender();
|
|
27
25
|
const scrollbar = useScrollbarWidth();
|
|
28
|
-
|
|
29
26
|
if (!shouldRender) {
|
|
30
27
|
return children;
|
|
31
28
|
}
|
|
32
|
-
|
|
33
29
|
const typedRef = ref;
|
|
34
30
|
return jsx("div", {
|
|
35
31
|
ref: typedRef,
|
|
@@ -9,14 +9,13 @@ const scrollIndicatorBorderRadius = 1;
|
|
|
9
9
|
const containerPadding = gridSize();
|
|
10
10
|
const itemHeadingContentHeight = headingSizes.h100.lineHeight;
|
|
11
11
|
const skeletonHeadingHeight = containerPadding;
|
|
12
|
-
const skeletonHeadingMarginOffset = 3;
|
|
12
|
+
const skeletonHeadingMarginOffset = 3;
|
|
13
|
+
// Skeleton content is slightly shorter than the real content.
|
|
13
14
|
// Because of that we slightly increase the top margin to offset this so the
|
|
14
15
|
// containing size both real and skeleton always equal approx 30px.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
const skeletonHeadingTopMargin = containerPadding * 2.5 + (itemHeadingContentHeight - skeletonHeadingHeight) - skeletonHeadingMarginOffset;
|
|
17
|
+
// We want to move the entire body up by 3px without affecting the height of the skeleton container.
|
|
18
18
|
const skeletonHeadingBottomMargin = containerPadding * 0.75 + skeletonHeadingMarginOffset;
|
|
19
|
-
|
|
20
19
|
/**
|
|
21
20
|
* This outer container css contains the "real" scroll indicators which are
|
|
22
21
|
* always rendered to the screen.
|
|
@@ -54,12 +53,12 @@ export const outerContainerCSS = opts => ({
|
|
|
54
53
|
backgroundColor: `var(${VAR_SEPARATOR_COLOR}, ${`var(--ds-border, ${N30})`})`
|
|
55
54
|
}
|
|
56
55
|
});
|
|
56
|
+
|
|
57
57
|
/**
|
|
58
58
|
* This inner container css contains the "mask" logic for the scroll indicators.
|
|
59
59
|
* Essentially they cover (mask) the "real" scroll indicators when the user is scrolled
|
|
60
60
|
* to the top or bottom of the container.
|
|
61
61
|
*/
|
|
62
|
-
|
|
63
62
|
export const innerContainerCSS = opts => ({
|
|
64
63
|
display: 'flex',
|
|
65
64
|
overflow: 'auto',
|
|
@@ -102,13 +101,13 @@ export const containerCSS = opts => ({
|
|
|
102
101
|
// so the spacing between matches what it would be if the indicator was a "block" element.
|
|
103
102
|
// We use margin here so any child absolutely positioned elements are positioned correctly.
|
|
104
103
|
marginTop: opts.showTopScrollIndicator ? scrollIndicatorHeight : 0,
|
|
105
|
-
marginLeft: "var(--ds-
|
|
106
|
-
marginRight: "var(--ds-
|
|
104
|
+
marginLeft: "var(--ds-space-100, 8px)",
|
|
105
|
+
marginRight: "var(--ds-space-100, 8px)",
|
|
107
106
|
// Enables child absolutely positioned elements to be positioned relative to this element.
|
|
108
107
|
position: 'relative',
|
|
109
108
|
'& [data-ds--menu--heading-item]': {
|
|
110
|
-
marginBottom: "var(--ds-
|
|
111
|
-
marginTop: "var(--ds-
|
|
109
|
+
marginBottom: "var(--ds-space-075, 6px)",
|
|
110
|
+
marginTop: "var(--ds-space-200, 20px)"
|
|
112
111
|
},
|
|
113
112
|
'& [data-ds--menu--skeleton-heading-item]': {
|
|
114
113
|
marginTop: skeletonHeadingTopMargin,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
+
|
|
2
3
|
import { jsx } from '@emotion/react';
|
|
3
4
|
import Box from '@atlaskit/ds-explorations/box';
|
|
4
|
-
|
|
5
5
|
/**
|
|
6
6
|
* __Navigation footer__
|
|
7
7
|
*
|
|
@@ -16,11 +16,10 @@ const NavigationFooter = ({
|
|
|
16
16
|
return jsx(Box, {
|
|
17
17
|
display: "block",
|
|
18
18
|
position: "relative",
|
|
19
|
-
padding: "
|
|
19
|
+
padding: "space.100",
|
|
20
20
|
UNSAFE_style: {
|
|
21
|
-
paddingBottom: "var(--ds-
|
|
21
|
+
paddingBottom: "var(--ds-space-200, 14px)"
|
|
22
22
|
}
|
|
23
23
|
}, children);
|
|
24
24
|
};
|
|
25
|
-
|
|
26
25
|
export default NavigationFooter;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import { jsx } from '@emotion/react';
|
|
3
3
|
import Box from '@atlaskit/ds-explorations/box';
|
|
4
|
-
|
|
5
4
|
/**
|
|
6
5
|
* __Navigation header__
|
|
7
6
|
*
|
|
@@ -17,11 +16,10 @@ const NavigationHeader = props => {
|
|
|
17
16
|
return jsx(Box, {
|
|
18
17
|
display: "block",
|
|
19
18
|
"data-navheader": true,
|
|
20
|
-
padding: "
|
|
19
|
+
padding: "space.100",
|
|
21
20
|
UNSAFE_style: {
|
|
22
|
-
paddingTop: "var(--ds-
|
|
21
|
+
paddingTop: "var(--ds-space-300, 24px)"
|
|
23
22
|
}
|
|
24
23
|
}, children);
|
|
25
24
|
};
|
|
26
|
-
|
|
27
25
|
export default NavigationHeader;
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import { createContext, useContext } from 'react';
|
|
2
|
-
|
|
3
2
|
/**
|
|
4
3
|
* @internal
|
|
5
4
|
*/
|
|
6
5
|
export const NestedContext = /*#__PURE__*/createContext(undefined);
|
|
7
6
|
export const useNestedContext = () => {
|
|
8
7
|
const context = useContext(NestedContext);
|
|
9
|
-
|
|
10
8
|
if (!context) {
|
|
11
9
|
let error = '';
|
|
12
|
-
|
|
13
10
|
if (process.env.NODE_ENV === 'development') {
|
|
14
11
|
error = `
|
|
15
12
|
To use a <NestingItem /> it needs to be a descendant of <NestableNavigationContent>.
|
|
@@ -18,27 +15,23 @@ You probably need to replace your <NavigationContent> with <NestableNavigationCo
|
|
|
18
15
|
import { NestableNavigationContent } from '@atlaskit/side-navigation';
|
|
19
16
|
`;
|
|
20
17
|
}
|
|
21
|
-
|
|
22
18
|
throw new Error(error);
|
|
23
19
|
}
|
|
24
|
-
|
|
25
20
|
return context;
|
|
26
21
|
};
|
|
22
|
+
|
|
27
23
|
/**
|
|
28
24
|
* Used by children of the NestableNavigationContent component to see if they should render or not.
|
|
29
25
|
* If `shouldRender` returns `true` - return your nodes.
|
|
30
26
|
* If it returns `false` - either return `null` or `children` if you have children.
|
|
31
27
|
*/
|
|
32
|
-
|
|
33
28
|
export const useShouldNestedElementRender = () => {
|
|
34
29
|
const context = useContext(NestedContext);
|
|
35
|
-
|
|
36
30
|
if (!context) {
|
|
37
31
|
return {
|
|
38
32
|
shouldRender: true
|
|
39
33
|
};
|
|
40
34
|
}
|
|
41
|
-
|
|
42
35
|
return {
|
|
43
36
|
shouldRender: context.currentStackId === context.parentId
|
|
44
37
|
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
|
|
3
2
|
/** @jsx jsx */
|
|
4
3
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
5
4
|
import { css, jsx } from '@emotion/react';
|
|
@@ -8,7 +7,8 @@ import { GoBackItem as GoBackButton } from '../Item';
|
|
|
8
7
|
import { default as NestingItem } from '../NestingItem';
|
|
9
8
|
import { useChildIds } from '../utils/hooks';
|
|
10
9
|
import { NestedContext } from './context';
|
|
11
|
-
import { NestingMotion } from './nesting-motion';
|
|
10
|
+
import { NestingMotion } from './nesting-motion';
|
|
11
|
+
// Named so ERT doesn't pick up the override name as a type.
|
|
12
12
|
|
|
13
13
|
export const ROOT_ID = 'ATLASKIT_NESTED_ROOT';
|
|
14
14
|
const nestableNavigationContentStyles = css({
|
|
@@ -23,6 +23,7 @@ const nestingRootStyles = css({
|
|
|
23
23
|
position: 'absolute',
|
|
24
24
|
flexDirection: 'column'
|
|
25
25
|
});
|
|
26
|
+
|
|
26
27
|
/**
|
|
27
28
|
* __Nestable navigation content__
|
|
28
29
|
*
|
|
@@ -31,7 +32,6 @@ const nestingRootStyles = css({
|
|
|
31
32
|
* - [Examples](https://atlassian.design/components/side-navigation/examples#nested-navigation)
|
|
32
33
|
* - [Code](https://atlassian.design/components/side-navigation/code)
|
|
33
34
|
*/
|
|
34
|
-
|
|
35
35
|
const NestableNavigationContent = props => {
|
|
36
36
|
const containerRef = useRef(null);
|
|
37
37
|
const {
|
|
@@ -54,15 +54,14 @@ const NestableNavigationContent = props => {
|
|
|
54
54
|
} = useChildIds(currentStackId, committedStack, onUnknownNest);
|
|
55
55
|
const onNestHandler = useCallback(layerId => {
|
|
56
56
|
onChange && onChange(committedStack.concat(layerId));
|
|
57
|
-
|
|
58
57
|
if (controlledStack) {
|
|
59
58
|
// We are in controlled mode - ignore the steps.
|
|
60
59
|
return;
|
|
61
|
-
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// We need to split the state update into to parts.
|
|
62
63
|
// First: Updating the direction of the motions.
|
|
63
64
|
// Second: Actually updating the stack (which will cause elements to enter & leave).
|
|
64
|
-
|
|
65
|
-
|
|
66
65
|
setTransition('nesting');
|
|
67
66
|
requestAnimationFrame(() => {
|
|
68
67
|
setCommittedStack(prev => {
|
|
@@ -73,15 +72,14 @@ const NestableNavigationContent = props => {
|
|
|
73
72
|
}, [controlledStack, onChange, committedStack]);
|
|
74
73
|
const onUnNestHandler = useCallback(() => {
|
|
75
74
|
onChange && onChange(committedStack.slice(0, committedStack.length - 1));
|
|
76
|
-
|
|
77
75
|
if (controlledStack) {
|
|
78
76
|
// We are in controlled mode - ignore the steps.
|
|
79
77
|
return;
|
|
80
|
-
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// We need to split the state update into to parts.
|
|
81
81
|
// First: Updating the direction of the motions.
|
|
82
82
|
// Second: Actually updating the stack (which will cause elements to enter & leave).
|
|
83
|
-
|
|
84
|
-
|
|
85
83
|
setTransition('unnesting');
|
|
86
84
|
requestAnimationFrame(() => {
|
|
87
85
|
setCommittedStack(prev => {
|
|
@@ -95,13 +93,12 @@ const NestableNavigationContent = props => {
|
|
|
95
93
|
// We aren't in controlled mode - bail out.
|
|
96
94
|
return;
|
|
97
95
|
}
|
|
98
|
-
|
|
99
96
|
if (JSON.stringify(committedStack) === JSON.stringify(controlledStack)) {
|
|
100
97
|
// stacks are equal - do nothing!
|
|
101
98
|
return;
|
|
102
|
-
}
|
|
103
|
-
|
|
99
|
+
}
|
|
104
100
|
|
|
101
|
+
// Controlled prop updated, let's figure out if we're nesting or unnesting.
|
|
105
102
|
if (controlledStack.length < committedStack.length) {
|
|
106
103
|
// We are unnesting (removing from the stack)
|
|
107
104
|
setTransition('unnesting');
|
|
@@ -109,7 +106,6 @@ const NestableNavigationContent = props => {
|
|
|
109
106
|
// We are nesting (adding to the stack)
|
|
110
107
|
setTransition('nesting');
|
|
111
108
|
}
|
|
112
|
-
|
|
113
109
|
requestAnimationFrame(() => {
|
|
114
110
|
setCommittedStack(controlledStack);
|
|
115
111
|
});
|
|
@@ -127,30 +123,30 @@ const NestableNavigationContent = props => {
|
|
|
127
123
|
parentId: ROOT_ID,
|
|
128
124
|
childIds: childIdsRef
|
|
129
125
|
}), [currentStackId, backButton, committedStack, onNestHandler, onUnNestHandler, childIdsRef]);
|
|
130
|
-
|
|
131
126
|
const manageFocus = event => {
|
|
132
127
|
const triggeredByKeyboard = event.nativeEvent.detail === 0;
|
|
133
|
-
|
|
134
128
|
if (triggeredByKeyboard) {
|
|
135
129
|
containerRef.current && containerRef.current.focus();
|
|
136
130
|
}
|
|
137
131
|
};
|
|
138
|
-
|
|
139
|
-
|
|
132
|
+
return (
|
|
133
|
+
// eslint-disable-next-line @repo/internal/react/use-primitives
|
|
140
134
|
jsx("div", {
|
|
141
135
|
"data-testid": testId,
|
|
142
136
|
css: nestableNavigationContentStyles,
|
|
143
137
|
ref: containerRef,
|
|
144
138
|
tabIndex: -1,
|
|
145
139
|
onClick: manageFocus
|
|
146
|
-
}, jsx(ExitingPersistence, null, jsx(NestingMotion
|
|
140
|
+
}, jsx(ExitingPersistence, null, jsx(NestingMotion
|
|
141
|
+
// Key is needed to have a unique react instance per stack name.
|
|
147
142
|
// This enables us to easily animate it in & out with exiting persistence.
|
|
148
143
|
, {
|
|
149
144
|
key: currentStackId,
|
|
150
145
|
enterFrom: transition === 'nesting' ? 'right' : 'left',
|
|
151
146
|
exitTo: transition === 'nesting' ? 'left' : 'right',
|
|
152
147
|
testId: testId && `${testId}-anim`
|
|
153
|
-
}, motion =>
|
|
148
|
+
}, motion =>
|
|
149
|
+
// eslint-disable-next-line @repo/internal/react/use-primitives
|
|
154
150
|
jsx("div", _extends({
|
|
155
151
|
css: nestingRootStyles
|
|
156
152
|
}, motion), jsx(NestedContext.Provider, {
|
|
@@ -163,5 +159,4 @@ const NestableNavigationContent = props => {
|
|
|
163
159
|
}, children))))))
|
|
164
160
|
);
|
|
165
161
|
};
|
|
166
|
-
|
|
167
162
|
export default NestableNavigationContent;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
|
|
3
2
|
/** @jsx jsx */
|
|
4
3
|
import React, { Fragment, useCallback, useMemo, useState } from 'react';
|
|
5
4
|
import { jsx } from '@emotion/react';
|
|
@@ -12,7 +11,6 @@ import { ROOT_ID } from '../NestableNavigationContent';
|
|
|
12
11
|
import { NestedContext, useNestedContext } from '../NestableNavigationContent/context';
|
|
13
12
|
import { useChildIdsEffect } from '../utils/hooks';
|
|
14
13
|
import { nestingItemStyle } from './styles';
|
|
15
|
-
|
|
16
14
|
/**
|
|
17
15
|
* NestingItem will render itself differently depending in what context it is rendered in.
|
|
18
16
|
* When not open - it will render itself as an item.
|
|
@@ -53,52 +51,47 @@ const NestingItem = props => {
|
|
|
53
51
|
backButton,
|
|
54
52
|
parentId: id,
|
|
55
53
|
childIds
|
|
56
|
-
}),
|
|
54
|
+
}),
|
|
55
|
+
// childIds shouldn't change as it's a ref
|
|
57
56
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
58
57
|
[onNest, onUnNest, backButton, stack, id, currentStackId]);
|
|
59
58
|
useChildIdsEffect(childIds, id);
|
|
60
|
-
|
|
61
59
|
const isNormalClick = e => !(e.button || e.metaKey || e.altKey || e.ctrlKey || e.shiftKey);
|
|
60
|
+
|
|
62
61
|
/**
|
|
63
62
|
* We want both the on nest handler and the onclick handler to be called.
|
|
64
63
|
* We create a wrapper function to call both.
|
|
65
64
|
*/
|
|
66
|
-
|
|
67
|
-
|
|
68
65
|
const onClickHandler = useCallback(e => {
|
|
69
66
|
if (isInteracted) {
|
|
70
67
|
// We return early if this has been interacted with because its assumed
|
|
71
68
|
// this will be already exiting - so we don't want to double up the click.
|
|
72
69
|
return;
|
|
73
|
-
}
|
|
74
|
-
|
|
70
|
+
}
|
|
75
71
|
|
|
72
|
+
// Avoid a nesting transition if a modifier key is detected during click.
|
|
76
73
|
if (isNormalClick(e)) {
|
|
77
74
|
setIsInteracted(true);
|
|
78
75
|
onNest(id);
|
|
79
76
|
}
|
|
80
|
-
|
|
81
77
|
onClick && onClick(e);
|
|
82
78
|
}, [isInteracted, onClick, onNest, id]);
|
|
83
|
-
|
|
84
79
|
if (currentStackId === id) {
|
|
85
80
|
return jsx(NestedContext.Provider, {
|
|
86
81
|
value: context
|
|
87
82
|
}, stack.length >= 1 && jsx(Box, {
|
|
88
83
|
as: "div",
|
|
89
84
|
display: "block",
|
|
90
|
-
paddingBlock: "
|
|
91
|
-
paddingInline: "
|
|
85
|
+
paddingBlock: "space.075",
|
|
86
|
+
paddingInline: "space.100"
|
|
92
87
|
}, backButton), jsx(NavigationContent, {
|
|
93
88
|
testId: testId,
|
|
94
89
|
showTopScrollIndicator: stack.length >= 1
|
|
95
90
|
}, children));
|
|
96
91
|
}
|
|
97
|
-
|
|
98
92
|
if ([ROOT_ID, ...stack].includes(id)) {
|
|
99
93
|
return children;
|
|
100
94
|
}
|
|
101
|
-
|
|
102
95
|
const componentProps = {
|
|
103
96
|
iconAfter: jsx(Fragment, null, iconAfter ? jsx(Box, {
|
|
104
97
|
"data-custom-icon": true,
|
|
@@ -120,15 +113,12 @@ const NestingItem = props => {
|
|
|
120
113
|
children: title,
|
|
121
114
|
cssFn: mergedStyles
|
|
122
115
|
};
|
|
123
|
-
|
|
124
116
|
if (component) {
|
|
125
117
|
return jsx(CustomItem, _extends({}, componentProps, {
|
|
126
118
|
//@ts-expect-error TODO Fix legit TypeScript 3.9.6 improved inference error
|
|
127
119
|
component: component
|
|
128
120
|
}));
|
|
129
121
|
}
|
|
130
|
-
|
|
131
122
|
return jsx(ButtonItem, componentProps);
|
|
132
123
|
};
|
|
133
|
-
|
|
134
124
|
export default NestingItem;
|