@atlaskit/page-layout 1.3.7 → 1.3.9

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 (104) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/common/constants.js +8 -4
  3. package/dist/cjs/common/hooks/index.js +0 -3
  4. package/dist/cjs/common/hooks/use-is-sidebar-collapsing.js +3 -12
  5. package/dist/cjs/common/hooks/use-is-sidebar-dragging.js +3 -12
  6. package/dist/cjs/common/safe-local-storage.js +2 -13
  7. package/dist/cjs/common/utils.js +0 -35
  8. package/dist/cjs/components/index.js +0 -13
  9. package/dist/cjs/components/resize-control/grab-area.js +8 -17
  10. package/dist/cjs/components/resize-control/index.js +33 -84
  11. package/dist/cjs/components/resize-control/resize-button.js +9 -24
  12. package/dist/cjs/components/resize-control/shadow.js +3 -7
  13. package/dist/cjs/components/skip-links/index.js +0 -2
  14. package/dist/cjs/components/skip-links/skip-link-components.js +18 -48
  15. package/dist/cjs/components/skip-links/use-custom-skip-link.js +3 -8
  16. package/dist/cjs/components/slots/banner-slot.js +10 -21
  17. package/dist/cjs/components/slots/content.js +3 -6
  18. package/dist/cjs/components/slots/internal/left-sidebar-inner.js +9 -14
  19. package/dist/cjs/components/slots/internal/left-sidebar-outer.js +10 -22
  20. package/dist/cjs/components/slots/internal/resizable-children-wrapper.js +10 -15
  21. package/dist/cjs/components/slots/internal/slot-focus-ring.js +5 -8
  22. package/dist/cjs/components/slots/left-panel.js +9 -20
  23. package/dist/cjs/components/slots/left-sidebar-without-resize.js +6 -18
  24. package/dist/cjs/components/slots/left-sidebar.js +39 -75
  25. package/dist/cjs/components/slots/main.js +9 -23
  26. package/dist/cjs/components/slots/page-layout.js +7 -16
  27. package/dist/cjs/components/slots/right-panel.js +9 -20
  28. package/dist/cjs/components/slots/right-sidebar.js +9 -21
  29. package/dist/cjs/components/slots/slot-dimensions.js +1 -5
  30. package/dist/cjs/components/slots/top-navigation.js +10 -21
  31. package/dist/cjs/controllers/index.js +0 -6
  32. package/dist/cjs/controllers/sidebar-resize-context.js +6 -21
  33. package/dist/cjs/controllers/sidebar-resize-controller.js +34 -50
  34. package/dist/cjs/controllers/skip-link-context.js +2 -12
  35. package/dist/cjs/controllers/skip-link-controller.js +6 -22
  36. package/dist/cjs/controllers/use-page-layout-grid.js +6 -12
  37. package/dist/cjs/controllers/use-update-css-vars.js +0 -3
  38. package/dist/cjs/index.js +0 -3
  39. package/dist/cjs/version.json +1 -1
  40. package/dist/es2019/common/constants.js +8 -4
  41. package/dist/es2019/common/hooks/use-is-sidebar-collapsing.js +0 -4
  42. package/dist/es2019/common/hooks/use-is-sidebar-dragging.js +0 -4
  43. package/dist/es2019/common/safe-local-storage.js +2 -12
  44. package/dist/es2019/common/utils.js +4 -20
  45. package/dist/es2019/components/resize-control/grab-area.js +7 -8
  46. package/dist/es2019/components/resize-control/index.js +26 -43
  47. package/dist/es2019/components/resize-control/resize-button.js +7 -11
  48. package/dist/es2019/components/resize-control/shadow.js +3 -3
  49. package/dist/es2019/components/skip-links/skip-link-components.js +16 -31
  50. package/dist/es2019/components/slots/banner-slot.js +1 -3
  51. package/dist/es2019/components/slots/content.js +2 -2
  52. package/dist/es2019/components/slots/internal/left-sidebar-inner.js +5 -5
  53. package/dist/es2019/components/slots/internal/left-sidebar-outer.js +1 -4
  54. package/dist/es2019/components/slots/internal/resizable-children-wrapper.js +4 -4
  55. package/dist/es2019/components/slots/internal/slot-focus-ring.js +3 -3
  56. package/dist/es2019/components/slots/left-panel.js +1 -3
  57. package/dist/es2019/components/slots/left-sidebar-without-resize.js +1 -2
  58. package/dist/es2019/components/slots/left-sidebar.js +25 -40
  59. package/dist/es2019/components/slots/main.js +4 -5
  60. package/dist/es2019/components/slots/page-layout.js +1 -3
  61. package/dist/es2019/components/slots/right-panel.js +1 -3
  62. package/dist/es2019/components/slots/right-sidebar.js +3 -5
  63. package/dist/es2019/components/slots/top-navigation.js +1 -3
  64. package/dist/es2019/controllers/sidebar-resize-context.js +7 -5
  65. package/dist/es2019/controllers/sidebar-resize-controller.js +14 -16
  66. package/dist/es2019/controllers/skip-link-context.js +0 -1
  67. package/dist/es2019/controllers/skip-link-controller.js +3 -7
  68. package/dist/es2019/controllers/use-page-layout-grid.js +4 -5
  69. package/dist/es2019/controllers/use-update-css-vars.js +0 -2
  70. package/dist/es2019/version.json +1 -1
  71. package/dist/esm/common/constants.js +8 -4
  72. package/dist/esm/common/hooks/use-is-sidebar-collapsing.js +3 -8
  73. package/dist/esm/common/hooks/use-is-sidebar-dragging.js +3 -8
  74. package/dist/esm/common/safe-local-storage.js +2 -12
  75. package/dist/esm/common/utils.js +0 -22
  76. package/dist/esm/components/resize-control/grab-area.js +9 -14
  77. package/dist/esm/components/resize-control/index.js +33 -72
  78. package/dist/esm/components/resize-control/resize-button.js +10 -15
  79. package/dist/esm/components/resize-control/shadow.js +3 -3
  80. package/dist/esm/components/skip-links/skip-link-components.js +19 -39
  81. package/dist/esm/components/skip-links/use-custom-skip-link.js +2 -4
  82. package/dist/esm/components/slots/banner-slot.js +9 -11
  83. package/dist/esm/components/slots/content.js +3 -3
  84. package/dist/esm/components/slots/internal/left-sidebar-inner.js +9 -9
  85. package/dist/esm/components/slots/internal/left-sidebar-outer.js +9 -12
  86. package/dist/esm/components/slots/internal/resizable-children-wrapper.js +10 -10
  87. package/dist/esm/components/slots/internal/slot-focus-ring.js +5 -5
  88. package/dist/esm/components/slots/left-panel.js +8 -10
  89. package/dist/esm/components/slots/left-sidebar-without-resize.js +7 -9
  90. package/dist/esm/components/slots/left-sidebar.js +40 -65
  91. package/dist/esm/components/slots/main.js +10 -13
  92. package/dist/esm/components/slots/page-layout.js +6 -10
  93. package/dist/esm/components/slots/right-panel.js +8 -10
  94. package/dist/esm/components/slots/right-sidebar.js +10 -12
  95. package/dist/esm/components/slots/slot-dimensions.js +1 -1
  96. package/dist/esm/components/slots/top-navigation.js +9 -11
  97. package/dist/esm/controllers/sidebar-resize-context.js +6 -11
  98. package/dist/esm/controllers/sidebar-resize-controller.js +34 -38
  99. package/dist/esm/controllers/skip-link-context.js +2 -4
  100. package/dist/esm/controllers/skip-link-controller.js +6 -12
  101. package/dist/esm/controllers/use-page-layout-grid.js +6 -8
  102. package/dist/esm/controllers/use-update-css-vars.js +0 -2
  103. package/dist/esm/version.json +1 -1
  104. package/package.json +2 -2
@@ -1,17 +1,18 @@
1
1
  /** @jsx jsx */
2
+
2
3
  import { css, jsx } from '@emotion/react';
3
4
  import { easeOut, prefersReducedMotion } from '@atlaskit/motion';
4
5
  import { BANNER_HEIGHT, LEFT_PANEL_WIDTH, LEFT_SIDEBAR_FLYOUT_WIDTH, LEFT_SIDEBAR_WIDTH, TOP_NAVIGATION_HEIGHT, TRANSITION_DURATION } from '../../../common/constants';
5
6
  import { useIsSidebarDragging } from '../../../common/hooks';
6
7
  // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
7
8
  var prefersReducedMotionStyles = css(prefersReducedMotion());
9
+
8
10
  /**
9
11
  * This inner wrapper is required to allow the sidebar to be `position: fixed`.
10
12
  *
11
13
  * If we were to apply `position: fixed` to the outer wrapper, it will be popped
12
14
  * out of its flex container and Main would stretch to occupy all the space.
13
15
  */
14
-
15
16
  var fixedInnerStyles = css({
16
17
  width: "".concat(LEFT_SIDEBAR_WIDTH),
17
18
  position: 'fixed',
@@ -23,12 +24,12 @@ var fixedInnerStyles = css({
23
24
  var fixedInnerFlyoutStyles = css({
24
25
  width: LEFT_SIDEBAR_FLYOUT_WIDTH
25
26
  });
27
+
26
28
  /**
27
29
  * Static in the sense of `position: static`.
28
30
  *
29
31
  * It will expand the page height to fit its content.
30
32
  */
31
-
32
33
  var staticInnerStyles = css({
33
34
  height: '100%'
34
35
  });
@@ -37,18 +38,17 @@ var draggingStyles = css({
37
38
  // Make sure drag to resize does not animate as the user drags
38
39
  transition: 'none'
39
40
  });
40
-
41
41
  var LeftSidebarInner = function LeftSidebarInner(_ref) {
42
42
  var children = _ref.children,
43
- _ref$isFixed = _ref.isFixed,
44
- isFixed = _ref$isFixed === void 0 ? false : _ref$isFixed,
45
- _ref$isFlyoutOpen = _ref.isFlyoutOpen,
46
- isFlyoutOpen = _ref$isFlyoutOpen === void 0 ? false : _ref$isFlyoutOpen;
43
+ _ref$isFixed = _ref.isFixed,
44
+ isFixed = _ref$isFixed === void 0 ? false : _ref$isFixed,
45
+ _ref$isFlyoutOpen = _ref.isFlyoutOpen,
46
+ isFlyoutOpen = _ref$isFlyoutOpen === void 0 ? false : _ref$isFlyoutOpen;
47
47
  var isDragging = useIsSidebarDragging();
48
48
  return jsx("div", {
49
49
  css: [!isFixed && staticInnerStyles, isFixed && fixedInnerStyles, isFixed && isFlyoutOpen && fixedInnerFlyoutStyles, isDragging && draggingStyles, prefersReducedMotionStyles]
50
50
  }, children);
51
- }; // eslint-disable-next-line @repo/internal/react/require-jsdoc
52
-
51
+ };
53
52
 
53
+ // eslint-disable-next-line @repo/internal/react/require-jsdoc
54
54
  export default LeftSidebarInner;
@@ -1,5 +1,4 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
-
3
2
  /** @jsx jsx */
4
3
  import { forwardRef } from 'react';
5
4
  import { css, jsx } from '@emotion/react';
@@ -25,12 +24,12 @@ var draggingStyles = css({
25
24
  // Make sure drag to resize does not animate as the user drags
26
25
  transition: 'none'
27
26
  });
27
+
28
28
  /**
29
29
  * In fixed mode this element's child is taken out of the document flow.
30
30
  * It doesn't take up the width as expected,
31
31
  * so the pseudo element forces it to take up the necessary width.
32
32
  */
33
-
34
33
  var fixedStyles = css({
35
34
  '::after': {
36
35
  display: 'inline-block',
@@ -45,17 +44,16 @@ var flyoutFixedStyles = css({
45
44
  width: COLLAPSED_LEFT_SIDEBAR_WIDTH
46
45
  });
47
46
  var selector = getPageLayoutSlotSelector('left-sidebar');
48
-
49
47
  var LeftSidebarOuter = function LeftSidebarOuter(_ref, ref) {
50
48
  var children = _ref.children,
51
- _ref$isFixed = _ref.isFixed,
52
- isFixed = _ref$isFixed === void 0 ? false : _ref$isFixed,
53
- _ref$isFlyoutOpen = _ref.isFlyoutOpen,
54
- isFlyoutOpen = _ref$isFlyoutOpen === void 0 ? false : _ref$isFlyoutOpen,
55
- testId = _ref.testId,
56
- onMouseLeave = _ref.onMouseLeave,
57
- onMouseOver = _ref.onMouseOver,
58
- id = _ref.id;
49
+ _ref$isFixed = _ref.isFixed,
50
+ isFixed = _ref$isFixed === void 0 ? false : _ref$isFixed,
51
+ _ref$isFlyoutOpen = _ref.isFlyoutOpen,
52
+ isFlyoutOpen = _ref$isFlyoutOpen === void 0 ? false : _ref$isFlyoutOpen,
53
+ testId = _ref.testId,
54
+ onMouseLeave = _ref.onMouseLeave,
55
+ onMouseOver = _ref.onMouseOver,
56
+ id = _ref.id;
59
57
  var isDragging = useIsSidebarDragging();
60
58
  return jsx(SlotFocusRing, {
61
59
  isSidebar: true
@@ -78,5 +76,4 @@ var LeftSidebarOuter = function LeftSidebarOuter(_ref, ref) {
78
76
  );
79
77
  });
80
78
  };
81
-
82
79
  export default /*#__PURE__*/forwardRef(LeftSidebarOuter);
@@ -1,17 +1,18 @@
1
1
  /** @jsx jsx */
2
+
2
3
  import { css, jsx } from '@emotion/react';
3
4
  import { prefersReducedMotion } from '@atlaskit/motion';
4
5
  import { TRANSITION_DURATION } from '../../../common/constants';
5
6
  import { useIsSidebarCollapsing } from '../../../common/hooks';
6
7
  // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
7
8
  var prefersReducedMotionStyles = css(prefersReducedMotion());
9
+
8
10
  /**
9
11
  * The transition duration is intentionally set to 0ms.
10
12
  *
11
13
  * A transition is being used here to delay the setting of
12
14
  * opacity and visibility so that it syncs collapsing sidebar.
13
15
  */
14
-
15
16
  var hideLeftSidebarContentsStyles = css({
16
17
  opacity: 0,
17
18
  transition: "opacity 0ms linear, visibility 0ms linear",
@@ -29,15 +30,14 @@ var fixedChildrenWrapperStyles = css({
29
30
  minWidth: 240,
30
31
  height: '100%'
31
32
  });
32
-
33
33
  var ResizableChildrenWrapper = function ResizableChildrenWrapper(_ref) {
34
34
  var children = _ref.children,
35
- _ref$isLeftSidebarCol = _ref.isLeftSidebarCollapsed,
36
- isLeftSidebarCollapsed = _ref$isLeftSidebarCol === void 0 ? false : _ref$isLeftSidebarCol,
37
- _ref$hasCollapsedStat = _ref.hasCollapsedState,
38
- hasCollapsedState = _ref$hasCollapsedStat === void 0 ? false : _ref$hasCollapsedStat,
39
- _ref$isFlyoutOpen = _ref.isFlyoutOpen,
40
- isFlyoutOpen = _ref$isFlyoutOpen === void 0 ? false : _ref$isFlyoutOpen;
35
+ _ref$isLeftSidebarCol = _ref.isLeftSidebarCollapsed,
36
+ isLeftSidebarCollapsed = _ref$isLeftSidebarCol === void 0 ? false : _ref$isLeftSidebarCol,
37
+ _ref$hasCollapsedStat = _ref.hasCollapsedState,
38
+ hasCollapsedState = _ref$hasCollapsedStat === void 0 ? false : _ref$hasCollapsedStat,
39
+ _ref$isFlyoutOpen = _ref.isFlyoutOpen,
40
+ isFlyoutOpen = _ref$isFlyoutOpen === void 0 ? false : _ref$isFlyoutOpen;
41
41
  var isCollapsing = useIsSidebarCollapsing();
42
42
  var isCollapsed = isLeftSidebarCollapsed || hasCollapsedState;
43
43
  var isHidden = isCollapsing || isCollapsed && !isFlyoutOpen;
@@ -46,7 +46,7 @@ var ResizableChildrenWrapper = function ResizableChildrenWrapper(_ref) {
46
46
  }, jsx("div", {
47
47
  css: fixedChildrenWrapperStyles
48
48
  }, children));
49
- }; // eslint-disable-next-line @repo/internal/react/require-jsdoc
50
-
49
+ };
51
50
 
51
+ // eslint-disable-next-line @repo/internal/react/require-jsdoc
52
52
  export default ResizableChildrenWrapper;
@@ -1,4 +1,5 @@
1
1
  /** @jsx jsx */
2
+
2
3
  import { ClassNames, css, jsx } from '@emotion/react';
3
4
  import { B100 } from '@atlaskit/theme/colors';
4
5
  var focusStyles = css({
@@ -11,11 +12,11 @@ var focusStyles = css({
11
12
  }
12
13
  }
13
14
  });
15
+
14
16
  /**
15
17
  * Sidebars have an outer and inner component,
16
18
  * so the nested selector needs to target an extra level deeper.
17
19
  */
18
-
19
20
  var sidebarFocusStyles = css({
20
21
  ':focus': {
21
22
  outline: 'none',
@@ -26,6 +27,7 @@ var sidebarFocusStyles = css({
26
27
  }
27
28
  }
28
29
  });
30
+
29
31
  /**
30
32
  * We don't use `@atlaskit/focus-ring` here,
31
33
  * because we need inset focus styles and:
@@ -35,11 +37,10 @@ var sidebarFocusStyles = css({
35
37
  * 2. We cannot wrap `children` in `FocusRing`,
36
38
  * because there's no guarantee the passed child takes `className`.
37
39
  */
38
-
39
40
  var SlotFocusRing = function SlotFocusRing(_ref) {
40
41
  var children = _ref.children,
41
- _ref$isSidebar = _ref.isSidebar,
42
- isSidebar = _ref$isSidebar === void 0 ? false : _ref$isSidebar;
42
+ _ref$isSidebar = _ref.isSidebar,
43
+ isSidebar = _ref$isSidebar === void 0 ? false : _ref$isSidebar;
43
44
  return jsx(ClassNames, null, function (_ref2) {
44
45
  var css = _ref2.css;
45
46
  return children({
@@ -47,5 +48,4 @@ var SlotFocusRing = function SlotFocusRing(_ref) {
47
48
  });
48
49
  });
49
50
  };
50
-
51
51
  export default SlotFocusRing;
@@ -1,6 +1,5 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
-
4
3
  /** @jsx jsx */
5
4
  import { useEffect } from 'react';
6
5
  import { css, jsx } from '@emotion/react';
@@ -19,6 +18,7 @@ var leftPanelFixedStyles = css({
19
18
  bottom: 0,
20
19
  left: 0
21
20
  });
21
+
22
22
  /**
23
23
  * __Left panel__
24
24
  *
@@ -27,16 +27,15 @@ var leftPanelFixedStyles = css({
27
27
  * - [Examples](https://atlassian.design/components/page-layout/examples)
28
28
  * - [Code](https://atlassian.design/components/page-layout/code)
29
29
  */
30
-
31
30
  var LeftPanel = function LeftPanel(props) {
32
31
  var children = props.children,
33
- isFixed = props.isFixed,
34
- _props$width = props.width,
35
- width = _props$width === void 0 ? DEFAULT_LEFT_PANEL_WIDTH : _props$width,
36
- shouldPersistWidth = props.shouldPersistWidth,
37
- testId = props.testId,
38
- id = props.id,
39
- skipLinkTitle = props.skipLinkTitle;
32
+ isFixed = props.isFixed,
33
+ _props$width = props.width,
34
+ width = _props$width === void 0 ? DEFAULT_LEFT_PANEL_WIDTH : _props$width,
35
+ shouldPersistWidth = props.shouldPersistWidth,
36
+ testId = props.testId,
37
+ id = props.id,
38
+ skipLinkTitle = props.skipLinkTitle;
40
39
  var leftPanelWidth = resolveDimension(VAR_LEFT_PANEL_WIDTH, width, shouldPersistWidth);
41
40
  useEffect(function () {
42
41
  publishGridState(_defineProperty({}, VAR_LEFT_PANEL_WIDTH, leftPanelWidth));
@@ -58,5 +57,4 @@ var LeftPanel = function LeftPanel(props) {
58
57
  }), children);
59
58
  });
60
59
  };
61
-
62
60
  export default LeftPanel;
@@ -1,5 +1,4 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
-
3
2
  /** @jsx jsx */
4
3
  import { useEffect } from 'react';
5
4
  import { jsx } from '@emotion/react';
@@ -9,6 +8,7 @@ import { publishGridState, useSkipLink } from '../../controllers';
9
8
  import LeftSidebarInner from './internal/left-sidebar-inner';
10
9
  import LeftSidebarOuter from './internal/left-sidebar-outer';
11
10
  import SlotDimensions from './slot-dimensions';
11
+
12
12
  /**
13
13
  * __Left sidebar without resize__
14
14
  *
@@ -17,15 +17,14 @@ import SlotDimensions from './slot-dimensions';
17
17
  * - [Examples](https://atlassian.design/components/page-layout/examples)
18
18
  * - [Code](https://atlassian.design/components/page-layout/code)
19
19
  */
20
-
21
20
  var LeftSidebarWithoutResize = function LeftSidebarWithoutResize(props) {
22
21
  var children = props.children,
23
- id = props.id,
24
- width = props.width,
25
- isFixed = props.isFixed,
26
- shouldPersistWidth = props.shouldPersistWidth,
27
- testId = props.testId,
28
- skipLinkTitle = props.skipLinkTitle;
22
+ id = props.id,
23
+ width = props.width,
24
+ isFixed = props.isFixed,
25
+ shouldPersistWidth = props.shouldPersistWidth,
26
+ testId = props.testId,
27
+ skipLinkTitle = props.skipLinkTitle;
29
28
  var leftSidebarWidth = resolveDimension(VAR_LEFT_SIDEBAR_WIDTH, width, shouldPersistWidth);
30
29
  useEffect(function () {
31
30
  publishGridState(_defineProperty({}, VAR_LEFT_SIDEBAR_WIDTH, leftSidebarWidth));
@@ -45,5 +44,4 @@ var LeftSidebarWithoutResize = function LeftSidebarWithoutResize(props) {
45
44
  isFixed: isFixed
46
45
  }, children));
47
46
  };
48
-
49
47
  export default LeftSidebarWithoutResize;
@@ -1,11 +1,7 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
-
3
2
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4
-
5
3
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
6
-
7
4
  /* eslint-disable @repo/internal/dom-events/no-unsafe-event-listeners */
8
-
9
5
  /** @jsx jsx */
10
6
  import { useContext, useEffect, useRef } from 'react';
11
7
  import { jsx } from '@emotion/react';
@@ -17,6 +13,7 @@ import LeftSidebarInner from './internal/left-sidebar-inner';
17
13
  import LeftSidebarOuter from './internal/left-sidebar-outer';
18
14
  import ResizableChildrenWrapper from './internal/resizable-children-wrapper';
19
15
  import SlotDimensions from './slot-dimensions';
16
+
20
17
  /**
21
18
  * __Left sidebar__
22
19
  *
@@ -25,45 +22,44 @@ import SlotDimensions from './slot-dimensions';
25
22
  * - [Examples](https://atlassian.design/components/page-layout/examples)
26
23
  * - [Code](https://atlassian.design/components/page-layout/code)
27
24
  */
28
-
29
25
  var LeftSidebar = function LeftSidebar(props) {
30
26
  var children = props.children,
31
- width = props.width,
32
- _props$isFixed = props.isFixed,
33
- isFixed = _props$isFixed === void 0 ? true : _props$isFixed,
34
- resizeButtonLabel = props.resizeButtonLabel,
35
- resizeGrabAreaLabel = props.resizeGrabAreaLabel,
36
- overrides = props.overrides,
37
- onExpand = props.onExpand,
38
- onCollapse = props.onCollapse,
39
- onResizeStart = props.onResizeStart,
40
- onResizeEnd = props.onResizeEnd,
41
- onFlyoutExpand = props.onFlyoutExpand,
42
- onFlyoutCollapse = props.onFlyoutCollapse,
43
- testId = props.testId,
44
- id = props.id,
45
- skipLinkTitle = props.skipLinkTitle,
46
- collapsedState = props.collapsedState;
27
+ width = props.width,
28
+ _props$isFixed = props.isFixed,
29
+ isFixed = _props$isFixed === void 0 ? true : _props$isFixed,
30
+ resizeButtonLabel = props.resizeButtonLabel,
31
+ resizeGrabAreaLabel = props.resizeGrabAreaLabel,
32
+ overrides = props.overrides,
33
+ onExpand = props.onExpand,
34
+ onCollapse = props.onCollapse,
35
+ onResizeStart = props.onResizeStart,
36
+ onResizeEnd = props.onResizeEnd,
37
+ onFlyoutExpand = props.onFlyoutExpand,
38
+ onFlyoutCollapse = props.onFlyoutCollapse,
39
+ testId = props.testId,
40
+ id = props.id,
41
+ skipLinkTitle = props.skipLinkTitle,
42
+ collapsedState = props.collapsedState;
47
43
  var flyoutTimerRef = useRef();
48
44
  var mouseOverEventRef = useRef();
49
45
  var leftSideBarRef = useRef(null);
50
-
51
46
  var _useContext = useContext(SidebarResizeContext),
52
- leftSidebarState = _useContext.leftSidebarState,
53
- setLeftSidebarState = _useContext.setLeftSidebarState;
54
-
47
+ leftSidebarState = _useContext.leftSidebarState,
48
+ setLeftSidebarState = _useContext.setLeftSidebarState;
55
49
  var isFlyoutOpen = leftSidebarState.isFlyoutOpen,
56
- isResizing = leftSidebarState.isResizing,
57
- flyoutLockCount = leftSidebarState.flyoutLockCount,
58
- isLeftSidebarCollapsed = leftSidebarState.isLeftSidebarCollapsed,
59
- leftSidebarWidth = leftSidebarState.leftSidebarWidth,
60
- lastLeftSidebarWidth = leftSidebarState.lastLeftSidebarWidth;
50
+ isResizing = leftSidebarState.isResizing,
51
+ flyoutLockCount = leftSidebarState.flyoutLockCount,
52
+ isLeftSidebarCollapsed = leftSidebarState.isLeftSidebarCollapsed,
53
+ leftSidebarWidth = leftSidebarState.leftSidebarWidth,
54
+ lastLeftSidebarWidth = leftSidebarState.lastLeftSidebarWidth;
61
55
  var isLocked = flyoutLockCount > 0;
62
56
  var isLockedRef = useRef(isLocked);
63
57
  var mouseXRef = useRef(0);
64
58
  var handlerRef = useRef(null);
65
59
  useEffect(function () {
66
- isLockedRef.current = isLocked; // I tried a one-time `mousemove` handler that gets attached
60
+ isLockedRef.current = isLocked;
61
+
62
+ // I tried a one-time `mousemove` handler that gets attached
67
63
  // when the lock releases. This is not robust because
68
64
  // the mouse can stay still after release (e.g. using keyboard)
69
65
  // and the sidebar will erroneously stay open.
@@ -74,52 +70,43 @@ var LeftSidebar = function LeftSidebar(props) {
74
70
  handlerRef.current = function (event) {
75
71
  mouseXRef.current = event.clientX;
76
72
  };
77
-
78
73
  document.addEventListener('mousemove', handlerRef.current);
79
74
  }
80
-
81
75
  if (!isLocked && handlerRef.current) {
82
76
  if (mouseXRef.current >= lastLeftSidebarWidth) {
83
77
  setLeftSidebarState(_objectSpread(_objectSpread({}, leftSidebarState), {}, {
84
78
  isFlyoutOpen: false
85
79
  }));
86
80
  }
87
-
88
81
  document.removeEventListener('mousemove', handlerRef.current);
89
82
  handlerRef.current = null;
90
83
  }
91
-
92
84
  return function () {
93
85
  if (handlerRef.current) {
94
86
  document.removeEventListener('mousemove', handlerRef.current);
95
87
  }
96
88
  };
97
89
  }, [isLocked, lastLeftSidebarWidth, leftSidebarState, setLeftSidebarState]);
98
-
99
90
  var _width = Math.max(width || 0, DEFAULT_LEFT_SIDEBAR_WIDTH);
100
-
101
91
  var collapsedStateOverrideOpen = collapsedState === 'expanded';
102
92
  var leftSidebarWidthOnMount;
103
-
104
93
  if (collapsedStateOverrideOpen) {
105
94
  leftSidebarWidthOnMount = resolveDimension(VAR_LEFT_SIDEBAR_FLYOUT, _width, !width);
106
95
  } else if (isLeftSidebarCollapsed || collapsedState === 'collapsed') {
107
96
  leftSidebarWidthOnMount = COLLAPSED_LEFT_SIDEBAR_WIDTH;
108
97
  } else {
109
98
  leftSidebarWidthOnMount = resolveDimension(VAR_LEFT_SIDEBAR_WIDTH, _width, !width || !collapsedStateOverrideOpen && getGridStateFromStorage('isLeftSidebarCollapsed'));
110
- } // Update state from cache on mount
111
-
99
+ }
112
100
 
101
+ // Update state from cache on mount
113
102
  useEffect(function () {
114
103
  var cachedCollapsedState = !collapsedStateOverrideOpen && (collapsedState === 'collapsed' || getGridStateFromStorage('isLeftSidebarCollapsed') || false);
115
104
  var cachedGridState = getGridStateFromStorage('gridState') || {};
116
105
  var leftSidebarWidth = !width && cachedGridState[VAR_LEFT_SIDEBAR_FLYOUT] ? Math.max(cachedGridState[VAR_LEFT_SIDEBAR_FLYOUT], DEFAULT_LEFT_SIDEBAR_WIDTH) : _width;
117
106
  var lastLeftSidebarWidth = !width && cachedGridState[VAR_LEFT_SIDEBAR_FLYOUT] ? Math.max(cachedGridState[VAR_LEFT_SIDEBAR_FLYOUT], DEFAULT_LEFT_SIDEBAR_WIDTH) : _width;
118
-
119
107
  if (cachedCollapsedState) {
120
108
  leftSidebarWidth = COLLAPSED_LEFT_SIDEBAR_WIDTH;
121
109
  }
122
-
123
110
  setLeftSidebarState({
124
111
  isFlyoutOpen: false,
125
112
  isResizing: isResizing,
@@ -128,46 +115,40 @@ var LeftSidebar = function LeftSidebar(props) {
128
115
  lastLeftSidebarWidth: lastLeftSidebarWidth,
129
116
  flyoutLockCount: 0,
130
117
  isFixed: isFixed
131
- }); // eslint-disable-next-line react-hooks/exhaustive-deps
132
- }, []); // Every time other than mount,
133
- // update the local storage and css variables.
118
+ });
119
+ // eslint-disable-next-line react-hooks/exhaustive-deps
120
+ }, []);
134
121
 
122
+ // Every time other than mount,
123
+ // update the local storage and css variables.
135
124
  var notFirstRun = useRef(false);
136
125
  useEffect(function () {
137
126
  if (notFirstRun.current) {
138
127
  var _publishGridState;
139
-
140
128
  publishGridState((_publishGridState = {}, _defineProperty(_publishGridState, VAR_LEFT_SIDEBAR_WIDTH, leftSidebarWidth || leftSidebarWidthOnMount), _defineProperty(_publishGridState, VAR_LEFT_SIDEBAR_FLYOUT, lastLeftSidebarWidth), _publishGridState));
141
129
  mergeGridStateIntoStorage('isLeftSidebarCollapsed', isLeftSidebarCollapsed);
142
130
  }
143
-
144
131
  if (!notFirstRun.current) {
145
132
  notFirstRun.current = true;
146
133
  }
147
-
148
134
  return function () {
149
135
  removeMouseOverListener();
150
- }; // eslint-disable-next-line react-hooks/exhaustive-deps
136
+ };
137
+ // eslint-disable-next-line react-hooks/exhaustive-deps
151
138
  }, [isLeftSidebarCollapsed, leftSidebarWidth, id]);
152
-
153
139
  var onMouseOver = function onMouseOver(event) {
154
140
  var isMouseOnResizeButton = event.target.matches("[".concat(RESIZE_BUTTON_SELECTOR, "]")) || event.target.matches("[".concat(RESIZE_BUTTON_SELECTOR, "] *"));
155
-
156
141
  if (isFlyoutOpen || isMouseOnResizeButton || !isLeftSidebarCollapsed) {
157
142
  return;
158
143
  }
159
-
160
144
  event.persist();
161
145
  flyoutTimerRef.current && clearTimeout(flyoutTimerRef.current);
162
-
163
146
  if (!mouseOverEventRef.current) {
164
147
  mouseOverEventRef.current = function (event) {
165
148
  var leftSidebar = leftSideBarRef.current;
166
-
167
149
  if (leftSidebar === null || isLockedRef.current) {
168
150
  return;
169
151
  }
170
-
171
152
  if (!leftSidebar.contains(event.target)) {
172
153
  flyoutTimerRef.current && clearTimeout(flyoutTimerRef.current);
173
154
  onFlyoutCollapse && onFlyoutCollapse();
@@ -180,7 +161,6 @@ var LeftSidebar = function LeftSidebar(props) {
180
161
  }
181
162
  };
182
163
  }
183
-
184
164
  document.addEventListener('mouseover', mouseOverEventRef.current, {
185
165
  capture: true,
186
166
  passive: true
@@ -194,23 +174,18 @@ var LeftSidebar = function LeftSidebar(props) {
194
174
  onFlyoutExpand && onFlyoutExpand();
195
175
  }, FLYOUT_DELAY);
196
176
  };
197
-
198
177
  var removeMouseOverListener = function removeMouseOverListener() {
199
178
  mouseOverEventRef.current && document.removeEventListener('mouseover', mouseOverEventRef.current, {
200
179
  capture: true,
201
180
  passive: true
202
181
  });
203
182
  };
204
-
205
183
  useSkipLink(id, skipLinkTitle);
206
-
207
184
  var onMouseLeave = function onMouseLeave(event) {
208
185
  var isMouseOnResizeButton = event.target.matches("[".concat(RESIZE_BUTTON_SELECTOR, "]")) || event.target.matches("[".concat(RESIZE_BUTTON_SELECTOR, "] *"));
209
-
210
186
  if (isMouseOnResizeButton || !isLeftSidebarCollapsed || flyoutLockCount > 0) {
211
187
  return;
212
188
  }
213
-
214
189
  onFlyoutCollapse && onFlyoutCollapse();
215
190
  setTimeout(function () {
216
191
  setLeftSidebarState(function (current) {
@@ -220,8 +195,8 @@ var LeftSidebar = function LeftSidebar(props) {
220
195
  });
221
196
  }, FLYOUT_DELAY);
222
197
  };
223
-
224
- return (// eslint-disable-next-line jsx-a11y/mouse-events-have-key-events
198
+ return (
199
+ // eslint-disable-next-line jsx-a11y/mouse-events-have-key-events
225
200
  jsx(LeftSidebarOuter, {
226
201
  ref: leftSideBarRef,
227
202
  testId: testId,
@@ -243,7 +218,8 @@ var LeftSidebar = function LeftSidebar(props) {
243
218
  }, children), jsx(ResizeControl, {
244
219
  testId: testId,
245
220
  resizeGrabAreaLabel: resizeGrabAreaLabel,
246
- resizeButtonLabel: resizeButtonLabel // eslint-disable-next-line @repo/internal/react/no-unsafe-overrides
221
+ resizeButtonLabel: resizeButtonLabel
222
+ // eslint-disable-next-line @repo/internal/react/no-unsafe-overrides
247
223
  ,
248
224
  overrides: overrides,
249
225
  onCollapse: onCollapse,
@@ -255,5 +231,4 @@ var LeftSidebar = function LeftSidebar(props) {
255
231
  })))
256
232
  );
257
233
  };
258
-
259
234
  export default LeftSidebar;
@@ -1,5 +1,4 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
-
3
2
  /** @jsx jsx */
4
3
  import { useContext } from 'react';
5
4
  import { css, jsx } from '@emotion/react';
@@ -9,8 +8,9 @@ import { COLLAPSED_LEFT_SIDEBAR_WIDTH, DEFAULT_LEFT_SIDEBAR_FLYOUT_WIDTH, TRANSI
9
8
  import { useIsSidebarDragging } from '../../common/hooks';
10
9
  import { getPageLayoutSlotSelector } from '../../common/utils';
11
10
  import { SidebarResizeContext, useSkipLink } from '../../controllers';
12
- import SlotFocusRing from './internal/slot-focus-ring'; // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
11
+ import SlotFocusRing from './internal/slot-focus-ring';
13
12
 
13
+ // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
14
14
  var prefersReducedMotionStyles = css(prefersReducedMotion());
15
15
  var mainStyles = css({
16
16
  minWidth: 0,
@@ -25,16 +25,17 @@ var draggingStyles = css({
25
25
  // Make sure drag to resize remains snappy.
26
26
  transition: 'none'
27
27
  });
28
+
28
29
  /**
29
30
  * Adds a negative left margin to main,
30
31
  * which transitions at the same speed as the left sidebar's width increase.
31
32
  * This give an illusion that the flyout is appearing on top of the main content,
32
33
  * while main remains in place.
33
34
  */
34
-
35
35
  var flyoutStyles = css({
36
36
  marginLeft: "calc(-1 * var(--".concat(VAR_LEFT_SIDEBAR_FLYOUT, ", ").concat(DEFAULT_LEFT_SIDEBAR_FLYOUT_WIDTH, "px) + ").concat(COLLAPSED_LEFT_SIDEBAR_WIDTH, "px)")
37
37
  });
38
+
38
39
  /**
39
40
  * __Main__
40
41
  *
@@ -43,20 +44,17 @@ var flyoutStyles = css({
43
44
  * - [Examples](https://atlassian.design/components/page-layout/examples)
44
45
  * - [Code](https://atlassian.design/components/page-layout/code)
45
46
  */
46
-
47
47
  var Main = function Main(props) {
48
48
  var children = props.children,
49
- testId = props.testId,
50
- id = props.id,
51
- skipLinkTitle = props.skipLinkTitle;
49
+ testId = props.testId,
50
+ id = props.id,
51
+ skipLinkTitle = props.skipLinkTitle;
52
52
  useSkipLink(id, skipLinkTitle);
53
53
  var isDragging = useIsSidebarDragging();
54
-
55
54
  var _useContext = useContext(SidebarResizeContext),
56
- _useContext$leftSideb = _useContext.leftSidebarState,
57
- isFlyoutOpen = _useContext$leftSideb.isFlyoutOpen,
58
- isFixed = _useContext$leftSideb.isFixed;
59
-
55
+ _useContext$leftSideb = _useContext.leftSidebarState,
56
+ isFlyoutOpen = _useContext$leftSideb.isFlyoutOpen,
57
+ isFixed = _useContext$leftSideb.isFixed;
60
58
  return jsx(SlotFocusRing, null, function (_ref) {
61
59
  var className = _ref.className;
62
60
  return jsx("div", _extends({
@@ -67,5 +65,4 @@ var Main = function Main(props) {
67
65
  }, getPageLayoutSlotSelector('main')), children);
68
66
  });
69
67
  };
70
-
71
68
  export default Main;
@@ -1,15 +1,12 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
-
4
3
  /** @jsx jsx */
5
4
  import { Fragment } from 'react';
6
5
  import { css, jsx } from '@emotion/react';
7
6
  import { BANNER, BANNER_HEIGHT, CONTENT, DEFAULT_I18N_PROPS_SKIP_LINKS, LEFT_PANEL, LEFT_PANEL_WIDTH, PAGE_LAYOUT_CONTAINER_SELECTOR, RIGHT_PANEL, RIGHT_PANEL_WIDTH, TOP_NAVIGATION, TOP_NAVIGATION_HEIGHT } from '../../common/constants';
8
7
  import { SidebarResizeController, SkipLinksController } from '../../controllers';
9
8
  import { SkipLinkWrapper } from '../skip-links';
10
-
11
9
  var pageLayoutSelector = _defineProperty({}, PAGE_LAYOUT_CONTAINER_SELECTOR, true);
12
-
13
10
  var gridTemplateAreas = "\n \"".concat(LEFT_PANEL, " ").concat(BANNER, " ").concat(RIGHT_PANEL, "\"\n \"").concat(LEFT_PANEL, " ").concat(TOP_NAVIGATION, " ").concat(RIGHT_PANEL, "\"\n \"").concat(LEFT_PANEL, " ").concat(CONTENT, " ").concat(RIGHT_PANEL, "\"\n ");
14
11
  var gridStyles = css({
15
12
  display: 'grid',
@@ -19,6 +16,7 @@ var gridStyles = css({
19
16
  gridTemplateRows: "".concat(BANNER_HEIGHT, " ").concat(TOP_NAVIGATION_HEIGHT, " auto"),
20
17
  outline: 'none'
21
18
  });
19
+
22
20
  /**
23
21
  * __Page layout__
24
22
  *
@@ -27,14 +25,13 @@ var gridStyles = css({
27
25
  * - [Examples](https://atlassian.design/components/page-layout/examples)
28
26
  * - [Code](https://atlassian.design/components/page-layout/code)
29
27
  */
30
-
31
28
  var PageLayout = function PageLayout(_ref) {
32
29
  var _ref$skipLinksLabel = _ref.skipLinksLabel,
33
- skipLinksLabel = _ref$skipLinksLabel === void 0 ? DEFAULT_I18N_PROPS_SKIP_LINKS : _ref$skipLinksLabel,
34
- children = _ref.children,
35
- testId = _ref.testId,
36
- onLeftSidebarExpand = _ref.onLeftSidebarExpand,
37
- onLeftSidebarCollapse = _ref.onLeftSidebarCollapse;
30
+ skipLinksLabel = _ref$skipLinksLabel === void 0 ? DEFAULT_I18N_PROPS_SKIP_LINKS : _ref$skipLinksLabel,
31
+ children = _ref.children,
32
+ testId = _ref.testId,
33
+ onLeftSidebarExpand = _ref.onLeftSidebarExpand,
34
+ onLeftSidebarCollapse = _ref.onLeftSidebarCollapse;
38
35
  return jsx(Fragment, null, jsx(SkipLinksController, null, jsx(SkipLinkWrapper, {
39
36
  skipLinksLabel: skipLinksLabel
40
37
  }), jsx("div", _extends({}, pageLayoutSelector, {
@@ -46,5 +43,4 @@ var PageLayout = function PageLayout(_ref) {
46
43
  onLeftSidebarExpand: onLeftSidebarExpand
47
44
  }, children))));
48
45
  };
49
-
50
46
  export default PageLayout;