@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.
Files changed (81) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/common/styles.js +7 -19
  3. package/dist/cjs/components/Footer/index.js +11 -19
  4. package/dist/cjs/components/Header/index.js +15 -33
  5. package/dist/cjs/components/Item/button-item.js +6 -20
  6. package/dist/cjs/components/Item/custom-item.js +8 -21
  7. package/dist/cjs/components/Item/go-back-item.js +13 -28
  8. package/dist/cjs/components/Item/index.js +0 -6
  9. package/dist/cjs/components/Item/link-item.js +6 -20
  10. package/dist/cjs/components/Item/skeleton-item.js +8 -20
  11. package/dist/cjs/components/LoadingItems/index.js +8 -16
  12. package/dist/cjs/components/NavigationContent/index.js +3 -15
  13. package/dist/cjs/components/NavigationContent/styles.js +9 -24
  14. package/dist/cjs/components/NavigationFooter/index.js +2 -7
  15. package/dist/cjs/components/NavigationHeader/index.js +2 -7
  16. package/dist/cjs/components/NestableNavigationContent/context.js +1 -13
  17. package/dist/cjs/components/NestableNavigationContent/index.js +30 -51
  18. package/dist/cjs/components/NestableNavigationContent/nesting-motion.js +3 -11
  19. package/dist/cjs/components/NestingItem/hack-for-ert.js +0 -1
  20. package/dist/cjs/components/NestingItem/index.js +25 -61
  21. package/dist/cjs/components/NestingItem/styles.js +0 -8
  22. package/dist/cjs/components/Section/heading-item.js +3 -12
  23. package/dist/cjs/components/Section/index.js +0 -4
  24. package/dist/cjs/components/Section/section.js +3 -15
  25. package/dist/cjs/components/Section/skeleton-heading-item.js +5 -17
  26. package/dist/cjs/components/SideNavigation/index.js +6 -8
  27. package/dist/cjs/components/index.js +0 -12
  28. package/dist/cjs/components/utils/hooks.js +2 -10
  29. package/dist/cjs/index.js +0 -3
  30. package/dist/cjs/version.json +1 -1
  31. package/dist/es2019/common/styles.js +7 -6
  32. package/dist/es2019/components/Footer/index.js +7 -8
  33. package/dist/es2019/components/Header/index.js +5 -6
  34. package/dist/es2019/components/Item/button-item.js +4 -6
  35. package/dist/es2019/components/Item/custom-item.js +7 -8
  36. package/dist/es2019/components/Item/go-back-item.js +2 -3
  37. package/dist/es2019/components/Item/link-item.js +4 -6
  38. package/dist/es2019/components/Item/skeleton-item.js +9 -11
  39. package/dist/es2019/components/LoadingItems/index.js +3 -6
  40. package/dist/es2019/components/NavigationContent/index.js +0 -4
  41. package/dist/es2019/components/NavigationContent/styles.js +9 -10
  42. package/dist/es2019/components/NavigationFooter/index.js +3 -4
  43. package/dist/es2019/components/NavigationHeader/index.js +2 -4
  44. package/dist/es2019/components/NestableNavigationContent/context.js +1 -8
  45. package/dist/es2019/components/NestableNavigationContent/index.js +17 -22
  46. package/dist/es2019/components/NestableNavigationContent/nesting-motion.js +1 -1
  47. package/dist/es2019/components/NestingItem/index.js +7 -17
  48. package/dist/es2019/components/NestingItem/styles.js +2 -1
  49. package/dist/es2019/components/Section/heading-item.js +2 -5
  50. package/dist/es2019/components/Section/section.js +2 -4
  51. package/dist/es2019/components/Section/skeleton-heading-item.js +6 -8
  52. package/dist/es2019/components/SideNavigation/index.js +3 -2
  53. package/dist/es2019/components/utils/hooks.js +2 -4
  54. package/dist/es2019/version.json +1 -1
  55. package/dist/esm/common/styles.js +7 -10
  56. package/dist/esm/components/Footer/index.js +11 -12
  57. package/dist/esm/components/Header/index.js +16 -20
  58. package/dist/esm/components/Item/button-item.js +6 -9
  59. package/dist/esm/components/Item/custom-item.js +9 -11
  60. package/dist/esm/components/Item/go-back-item.js +13 -16
  61. package/dist/esm/components/Item/link-item.js +6 -9
  62. package/dist/esm/components/Item/skeleton-item.js +8 -14
  63. package/dist/esm/components/LoadingItems/index.js +7 -11
  64. package/dist/esm/components/NavigationContent/index.js +3 -9
  65. package/dist/esm/components/NavigationContent/styles.js +9 -13
  66. package/dist/esm/components/NavigationFooter/index.js +3 -4
  67. package/dist/esm/components/NavigationHeader/index.js +2 -4
  68. package/dist/esm/components/NestableNavigationContent/context.js +1 -8
  69. package/dist/esm/components/NestableNavigationContent/index.js +30 -41
  70. package/dist/esm/components/NestableNavigationContent/nesting-motion.js +4 -7
  71. package/dist/esm/components/NestingItem/index.js +25 -41
  72. package/dist/esm/components/NestingItem/styles.js +0 -4
  73. package/dist/esm/components/Section/heading-item.js +3 -6
  74. package/dist/esm/components/Section/section.js +3 -5
  75. package/dist/esm/components/Section/skeleton-heading-item.js +5 -11
  76. package/dist/esm/components/SideNavigation/index.js +5 -4
  77. package/dist/esm/components/utils/hooks.js +2 -4
  78. package/dist/esm/version.json +1 -1
  79. package/dist/types/components/NavigationContent/styles.d.ts +4 -4
  80. package/package.json +2 -2
  81. 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 // eslint-disable-next-line @repo/internal/react/no-unsafe-overrides
73
+ component: props.component || Container
74
+ // eslint-disable-next-line @repo/internal/react/no-unsafe-overrides
77
75
  ,
78
- cssFn: cssFn // eslint-disable-next-line @repo/internal/react/no-unsafe-overrides
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( // Type needed on props to extract types with extract react types.
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
- const cssOverride = overrideStyleFunction(baseSideNavItemStyle, cssFn); // eslint-disable-next-line @atlaskit/design-system/no-deprecated-apis, @repo/internal/react/no-unsafe-overrides
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( // Type needed on props to extract types with extract react types.
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
- const cssOverride = overrideStyleFunction(baseSideNavItemStyle, cssFn); // eslint-disable-next-line @atlaskit/design-system/no-deprecated-apis
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
- } // Dirty hack to get generics working with forward ref [2/2]
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 // eslint-disable-next-line @repo/internal/react/no-unsafe-overrides
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( // Type needed on props to extract types with extract react types.
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
- const cssOverride = overrideStyleFunction(baseSideNavItemStyle, cssFn); // eslint-disable-next-line @atlaskit/design-system/no-deprecated-apis, @repo/internal/react/no-unsafe-overrides
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
- return /*#__PURE__*/React.createElement(SkelItem // eslint-disable-next-line @atlaskit/design-system/no-deprecated-apis, @repo/internal/react/no-unsafe-overrides
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: () => ({ ...sectionHeaderSpacingStyles(),
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-scale-300, 20px)",
30
- marginRight: "var(--ds-scale-200, 18px)",
31
- width: "var(--ds-scale-300, 20px)"
28
+ height: "var(--ds-space-300, 20px)",
29
+ marginRight: "var(--ds-space-200, 18px)",
30
+ width: "var(--ds-space-300, 20px)"
32
31
  }
33
- }) // eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
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) => // eslint-disable-next-line @repo/internal/react/use-primitives
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; // Skeleton content is slightly shorter than the real content.
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
- const skeletonHeadingTopMargin = containerPadding * 2.5 + (itemHeadingContentHeight - skeletonHeadingHeight) - skeletonHeadingMarginOffset; // We want to move the entire body up by 3px without affecting the height of the skeleton container.
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-scale-100, 8px)",
106
- marginRight: "var(--ds-scale-100, 8px)",
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-scale-075, 6px)",
111
- marginTop: "var(--ds-scale-200, 20px)"
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: "scale.100",
19
+ padding: "space.100",
20
20
  UNSAFE_style: {
21
- paddingBottom: "var(--ds-scale-200, 14px)"
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: "scale.100",
19
+ padding: "space.100",
21
20
  UNSAFE_style: {
22
- paddingTop: "var(--ds-scale-300, 24px)"
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'; // Named so ERT doesn't pick up the override name as a type.
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
- } // We need to split the state update into to parts.
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
- } // We need to split the state update into to parts.
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
- } // Controlled prop updated, let's figure out if we're nesting or unnesting.
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
- return (// eslint-disable-next-line @repo/internal/react/use-primitives
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 // Key is needed to have a unique react instance per stack name.
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 => // eslint-disable-next-line @repo/internal/react/use-primitives
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,7 +1,7 @@
1
1
  /** @jsx jsx */
2
+
2
3
  import { jsx } from '@emotion/react';
3
4
  import { easeOut, SlideIn } from '@atlaskit/motion';
4
-
5
5
  /**
6
6
  * @internal
7
7
  */
@@ -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
- }), // childIds shouldn't change as it's a ref
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
- } // Avoid a nesting transition if a modifier key is detected during click.
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: "scale.075",
91
- paddingInline: "scale.100"
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;
@@ -34,6 +34,7 @@ const disabledCSS = {
34
34
  }
35
35
  };
36
36
  export const nestingItemStyle = state => {
37
- return { ...(state.isDisabled ? disabledCSS : enabledCSS)
37
+ return {
38
+ ...(state.isDisabled ? disabledCSS : enabledCSS)
38
39
  };
39
40
  };