@atlaskit/navigation-system 2.0.0 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/cjs/ui/menu-item/container-avatar.compiled.css +1 -1
  3. package/dist/cjs/ui/menu-item/container-avatar.js +1 -1
  4. package/dist/cjs/ui/page-layout/aside.js +8 -1
  5. package/dist/cjs/ui/page-layout/panel-splitter/context.js +11 -2
  6. package/dist/cjs/ui/page-layout/panel-splitter/get-width.js +5 -0
  7. package/dist/cjs/ui/page-layout/panel-splitter/panel-splitter.js +8 -1
  8. package/dist/cjs/ui/page-layout/panel-splitter/side-nav-panel-splitter.js +47 -0
  9. package/dist/cjs/ui/page-layout/panel.js +9 -1
  10. package/dist/cjs/ui/page-layout/side-nav/side-nav.js +9 -1
  11. package/dist/cjs/ui/page-layout/use-safe-default-width.js +32 -0
  12. package/dist/cjs/ui/top-nav-items/nav-logo/custom-logo.compiled.css +1 -1
  13. package/dist/cjs/ui/top-nav-items/nav-logo/custom-logo.js +2 -2
  14. package/dist/cjs/ui/top-nav-items/search.compiled.css +1 -1
  15. package/dist/cjs/ui/top-nav-items/search.js +1 -1
  16. package/dist/cjs/ui/top-nav-items/themed/button.compiled.css +1 -1
  17. package/dist/cjs/ui/top-nav-items/themed/button.js +1 -1
  18. package/dist/es2019/ui/menu-item/container-avatar.compiled.css +1 -1
  19. package/dist/es2019/ui/menu-item/container-avatar.js +1 -1
  20. package/dist/es2019/ui/page-layout/aside.js +8 -1
  21. package/dist/es2019/ui/page-layout/panel-splitter/context.js +10 -1
  22. package/dist/es2019/ui/page-layout/panel-splitter/get-width.js +5 -0
  23. package/dist/es2019/ui/page-layout/panel-splitter/panel-splitter.js +9 -2
  24. package/dist/es2019/ui/page-layout/panel-splitter/side-nav-panel-splitter.js +38 -0
  25. package/dist/es2019/ui/page-layout/panel.js +9 -1
  26. package/dist/es2019/ui/page-layout/side-nav/side-nav.js +9 -1
  27. package/dist/es2019/ui/page-layout/use-safe-default-width.js +28 -0
  28. package/dist/es2019/ui/top-nav-items/nav-logo/custom-logo.compiled.css +1 -1
  29. package/dist/es2019/ui/top-nav-items/nav-logo/custom-logo.js +2 -2
  30. package/dist/es2019/ui/top-nav-items/search.compiled.css +1 -1
  31. package/dist/es2019/ui/top-nav-items/search.js +1 -1
  32. package/dist/es2019/ui/top-nav-items/themed/button.compiled.css +1 -1
  33. package/dist/es2019/ui/top-nav-items/themed/button.js +1 -1
  34. package/dist/esm/ui/menu-item/container-avatar.compiled.css +1 -1
  35. package/dist/esm/ui/menu-item/container-avatar.js +1 -1
  36. package/dist/esm/ui/page-layout/aside.js +8 -1
  37. package/dist/esm/ui/page-layout/panel-splitter/context.js +10 -1
  38. package/dist/esm/ui/page-layout/panel-splitter/get-width.js +5 -0
  39. package/dist/esm/ui/page-layout/panel-splitter/panel-splitter.js +9 -2
  40. package/dist/esm/ui/page-layout/panel-splitter/side-nav-panel-splitter.js +38 -0
  41. package/dist/esm/ui/page-layout/panel.js +9 -1
  42. package/dist/esm/ui/page-layout/side-nav/side-nav.js +9 -1
  43. package/dist/esm/ui/page-layout/use-safe-default-width.js +27 -0
  44. package/dist/esm/ui/top-nav-items/nav-logo/custom-logo.compiled.css +1 -1
  45. package/dist/esm/ui/top-nav-items/nav-logo/custom-logo.js +2 -2
  46. package/dist/esm/ui/top-nav-items/search.compiled.css +1 -1
  47. package/dist/esm/ui/top-nav-items/search.js +1 -1
  48. package/dist/esm/ui/top-nav-items/themed/button.compiled.css +1 -1
  49. package/dist/esm/ui/top-nav-items/themed/button.js +1 -1
  50. package/dist/types/ui/page-layout/aside.d.ts +2 -2
  51. package/dist/types/ui/page-layout/panel-splitter/context.d.ts +8 -0
  52. package/dist/types/ui/page-layout/panel-splitter/panel-splitter.d.ts +1 -1
  53. package/dist/types/ui/page-layout/panel-splitter/side-nav-panel-splitter.d.ts +20 -0
  54. package/dist/types/ui/page-layout/panel.d.ts +2 -2
  55. package/dist/types/ui/page-layout/side-nav/side-nav.d.ts +2 -1
  56. package/dist/types/ui/page-layout/use-safe-default-width.d.ts +21 -0
  57. package/dist/types-ts4.5/ui/page-layout/aside.d.ts +2 -2
  58. package/dist/types-ts4.5/ui/page-layout/panel-splitter/context.d.ts +8 -0
  59. package/dist/types-ts4.5/ui/page-layout/panel-splitter/panel-splitter.d.ts +1 -1
  60. package/dist/types-ts4.5/ui/page-layout/panel-splitter/side-nav-panel-splitter.d.ts +20 -0
  61. package/dist/types-ts4.5/ui/page-layout/panel.d.ts +2 -2
  62. package/dist/types-ts4.5/ui/page-layout/side-nav/side-nav.d.ts +2 -1
  63. package/dist/types-ts4.5/ui/page-layout/use-safe-default-width.d.ts +21 -0
  64. package/package.json +5 -43
@@ -1,5 +1,5 @@
1
1
 
2
- ._2rkosqtm{border-radius:var(--ds-border-radius-100,3px)}
2
+ ._2rkofajl{border-radius:var(--ds-radius-small,3px)}
3
3
  ._18zr1b66{padding-inline:var(--ds-space-050,4px)}
4
4
  ._18zru2gc{padding-inline:var(--ds-space-100,8px)}._18m915vq{overflow-y:hidden}
5
5
  ._1e0c1txw{display:flex}
@@ -9,8 +9,8 @@ import { Anchor } from '@atlaskit/primitives';
9
9
  import { useHasCustomTheme } from '../themed/has-custom-theme-context';
10
10
  import { LogoRenderer } from './logo-renderer';
11
11
  const anchorStyles = {
12
- root: "_2rkosqtm _1e0c1txw _4cvr1h6o _4t3izwfg",
13
- customLogoBorderRadius: "_2rkosqtm",
12
+ root: "_2rkofajl _1e0c1txw _4cvr1h6o _4t3izwfg",
13
+ customLogoBorderRadius: "_2rkofajl",
14
14
  newMargin: "_ahbq1b66",
15
15
  newInteractionStates: "_irr3166n _1di61wwy",
16
16
  newInteractionStatesCustomTheming: "_irr31rps _1di6yhlj"
@@ -1,5 +1,5 @@
1
1
 
2
- ._2rkoiti9{border-radius:var(--ds-border-radius-100,4px)}._18zr12x7{padding-inline:var(--ds-space-075,6px)}
2
+ ._2rko12b0{border-radius:var(--ds-radius-small,4px)}._18zr12x7{padding-inline:var(--ds-space-075,6px)}
3
3
  ._1ii7kb7n{grid-row:1}
4
4
  ._1rjcze3t{padding-block:var(--ds-space-0,0)}
5
5
  ._yyhy11wp{grid-column:3}
@@ -6,7 +6,7 @@ import SearchIcon from '@atlaskit/icon/core/search';
6
6
  import { Pressable, Show, Text } from '@atlaskit/primitives/compiled';
7
7
  import { IconButton } from './themed/migration';
8
8
  const styles = {
9
- root: "_2rkoiti9 _1rjcze3t _18zr12x7 _yv0e1mfv _4cvr1h6o _bfhk1j9a _vchhusvi _80om1kdv _1e0cglyw _4t3izwfg _p12f1kvu _1bsb1osq _irr31d5g _1di6r01l _114b11p5",
9
+ root: "_2rko12b0 _1rjcze3t _18zr12x7 _yv0e1mfv _4cvr1h6o _bfhk1j9a _vchhusvi _80om1kdv _1e0cglyw _4t3izwfg _p12f1kvu _1bsb1osq _irr31d5g _1di6r01l _114b11p5",
10
10
  buttonText: "_yyhyjvu9 _1ii7kb7n",
11
11
  iconBefore: "_yyhykb7n _1ii7kb7n _1e0c1txw",
12
12
  elemAfter: "_yyhy11wp _1ii7kb7n _1e0c1txw"
@@ -4,7 +4,7 @@
4
4
  ._11q7esko{background:var(--ds-top-bar-button-primary-background)}
5
5
  ._11q7pkxg{background:var(--ds-top-bar-button-background)}
6
6
  ._14mj1kw7:after{border-radius:inherit}
7
- ._2rkosqtm{border-radius:var(--ds-border-radius-100,3px)}
7
+ ._2rkofajl{border-radius:var(--ds-radius-small,3px)}
8
8
  ._9v7aze3t:after{inset:var(--ds-space-0,0)}
9
9
  ._v5649dqc{transition:background .1s ease-out}
10
10
  ._zulp12x7{gap:var(--ds-space-075,6px)}
@@ -70,7 +70,7 @@ export const themedButtonSelectedBorder = '--ds-top-bar-button-selected-border';
70
70
  export const themedButtonDisabledText = '--ds-top-bar-button-disabled-text';
71
71
  export const themedButtonDisabledBackground = '--ds-top-bar-button-disabled-background';
72
72
  const styles = {
73
- root: "_zulp12x7 _11c82smr _2rkosqtm _v5649dqc _4bfu1r31 _1hmsglyw _ajmmnqa1 _1rjcze3t _1e0c1txw _4cvr1h6o _1bah1h6o _4t3i5r7u _kqswh2mm _1nrm1r31 _1a3b1r31 _9oik1r31 _c2waglyw _4fprglyw _1bnxglyw _1iohnqa1 _5goinqa1 _jf4cnqa1",
73
+ root: "_zulp12x7 _11c82smr _2rkofajl _v5649dqc _4bfu1r31 _1hmsglyw _ajmmnqa1 _1rjcze3t _1e0c1txw _4cvr1h6o _1bah1h6o _4t3i5r7u _kqswh2mm _1nrm1r31 _1a3b1r31 _9oik1r31 _c2waglyw _4fprglyw _1bnxglyw _1iohnqa1 _5goinqa1 _jf4cnqa1",
74
74
  border: "_14mj1kw7 _9v7aze3t _1tv3nqa1 _39yqe4h9 _aetrb3bt _18postnw",
75
75
  selected: "_11q71qds _syazw5ct _8l3m15jn _f8pjw5ct _1053w5ct _19lcjrv1 _30l3w5ct _j6xtnh62 _9h8hw5ct",
76
76
  disabled: "_11q71c9b _syaz1i3i _8l3m1j28 _f8pj1i3i _10531i3i _19lc1c9b _30l31i3i _j6xt1c9b _9h8h1i3i"
@@ -1,4 +1,4 @@
1
1
 
2
- ._2rkoiti9{border-radius:var(--ds-border-radius-100,4px)}._1bsbgktf{width:20px}
2
+ ._2rko12b0{border-radius:var(--ds-radius-small,4px)}._1bsbgktf{width:20px}
3
3
  ._4t3igktf{height:20px}
4
4
  ._vchhusvi{box-sizing:border-box}
@@ -3,7 +3,7 @@ import "./container-avatar.compiled.css";
3
3
  import * as React from 'react';
4
4
  import { ax, ix } from "@compiled/react/runtime";
5
5
  var styles = {
6
- root: "_2rkoiti9 _vchhusvi _4t3igktf _1bsbgktf"
6
+ root: "_2rko12b0 _vchhusvi _4t3igktf _1bsbgktf"
7
7
  };
8
8
  /**
9
9
  * __Container avatar__
@@ -14,6 +14,7 @@ import { DangerouslyHoistCssVarToDocumentRoot } from './hoist-utils';
14
14
  import { useLayoutId } from './id-utils';
15
15
  import { PanelSplitterProvider } from './panel-splitter/provider';
16
16
  import { useResizingWidthCssVarOnRootElement } from './use-resizing-width-css-var-on-root-element';
17
+ import { useSafeDefaultWidth } from './use-safe-default-width';
17
18
  var panelSplitterResizingVar = '--n_asdRsz';
18
19
  /**
19
20
  * The bounds for Aside and Panel are purposely set to support the current usage in Jira.
@@ -45,6 +46,7 @@ var styles = {
45
46
  root: "_nd5lns35 _vchhusvi _kqswh2mm _glte1kzp _ndwch9n0",
46
47
  inner: "_1reo1wug _18m91wug _152timx3 _4t3i1osq _165teqxy _13wn1if8"
47
48
  };
49
+ var fallbackDefaultWidth = 330;
48
50
 
49
51
  /**
50
52
  * The Aside is rendered to the right (inline end) of the Main area.
@@ -55,7 +57,7 @@ export function Aside(_ref) {
55
57
  var children = _ref.children,
56
58
  xcss = _ref.xcss,
57
59
  _ref$defaultWidth = _ref.defaultWidth,
58
- defaultWidth = _ref$defaultWidth === void 0 ? 330 : _ref$defaultWidth,
60
+ defaultWidthProp = _ref$defaultWidth === void 0 ? fallbackDefaultWidth : _ref$defaultWidth,
59
61
  _ref$label = _ref.label,
60
62
  label = _ref$label === void 0 ? 'Aside' : _ref$label,
61
63
  _ref$skipLinkLabel = _ref.skipLinkLabel,
@@ -66,6 +68,11 @@ export function Aside(_ref) {
66
68
  var id = useLayoutId({
67
69
  providedId: providedId
68
70
  });
71
+ var defaultWidth = useSafeDefaultWidth({
72
+ defaultWidthProp: defaultWidthProp,
73
+ fallbackDefaultWidth: fallbackDefaultWidth,
74
+ slotName: 'Aside'
75
+ });
69
76
 
70
77
  /**
71
78
  * Don't show the skip link if the slot has 0 width.
@@ -6,4 +6,13 @@ import { createContext } from 'react';
6
6
  /**
7
7
  * Context for the panel splitter. Only internally exported.
8
8
  */
9
- export var PanelSplitterContext = /*#__PURE__*/createContext(null);
9
+ export var PanelSplitterContext = /*#__PURE__*/createContext(null);
10
+
11
+ /**
12
+ * Context for the panel splitter's double click handler. Only internally exported.
13
+ *
14
+ * NOTE: This context is a temporary workaround to enable the `SideNavPanelSplitter` component
15
+ * to collapse the side nav on double click, without exposing the `onDoubleClick` prop on `PanelSplitter`.
16
+ * Once `PanelSplitter` supports an `onDoubleClick` prop directly, this context should be removed.
17
+ */
18
+ export var OnDoubleClickContext = /*#__PURE__*/createContext(undefined);
@@ -1,3 +1,4 @@
1
+ import { fg } from '@atlaskit/platform-feature-flags';
1
2
  export var getWidthFromDragLocation = function getWidthFromDragLocation(_ref) {
2
3
  var initialWidth = _ref.initialWidth,
3
4
  location = _ref.location,
@@ -19,6 +20,10 @@ export var getWidthFromDragLocation = function getWidthFromDragLocation(_ref) {
19
20
  * Returns the computed width of an element in pixels.
20
21
  */
21
22
  export var getPixelWidth = function getPixelWidth(element) {
23
+ if (fg('platform_dst_nav4_panel_splitter_guards')) {
24
+ // Always returns an integer. Returns 0 if element is hidden / removed.
25
+ return element.offsetWidth;
26
+ }
22
27
  var _window$getComputedSt = window.getComputedStyle(element),
23
28
  width = _window$getComputedSt.width;
24
29
  return parseInt(width);
@@ -19,7 +19,7 @@ import { blockDraggingToIFrames } from '@atlaskit/pragmatic-drag-and-drop/elemen
19
19
  import { disableNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/element/disable-native-drag-preview';
20
20
  import { preventUnhandled } from '@atlaskit/pragmatic-drag-and-drop/prevent-unhandled';
21
21
  import VisuallyHidden from '@atlaskit/visually-hidden';
22
- import { PanelSplitterContext } from './context';
22
+ import { OnDoubleClickContext, PanelSplitterContext } from './context';
23
23
  import { convertResizeBoundToPixels } from './convert-resize-bound-to-pixels';
24
24
  import { getPercentageWithinPixelBounds } from './get-percentage-within-pixel-bounds';
25
25
  import { getPixelWidth, getWidthFromDragLocation } from './get-width';
@@ -82,6 +82,13 @@ var PortaledPanelSplitter = function PortaledPanelSplitter(_ref) {
82
82
  rangeInputBounds = _useState4[0],
83
83
  setRangeInputBounds = _useState4[1];
84
84
  var openLayerObserver = useOpenLayerObserver();
85
+
86
+ /**
87
+ * This is a temporary workaround to enable the `SideNavPanelSplitter` component
88
+ * to collapse the side nav on double click, without exposing the `onDoubleClick` prop on `PanelSplitter`.
89
+ * Once `PanelSplitter` supports an `onDoubleClick` prop directly, this context can be removed.
90
+ */
91
+ var onDoubleClick = useContext(OnDoubleClickContext);
85
92
  useEffect(function () {
86
93
  var splitter = splitterRef.current;
87
94
  invariant(splitter, 'Splitter ref must be set');
@@ -154,7 +161,6 @@ var PortaledPanelSplitter = function PortaledPanelSplitter(_ref) {
154
161
  var source = _ref5.source;
155
162
  invariant(isPanelSplitterDragData(source.data));
156
163
  preventUnhandled.stop();
157
- invariant(isPanelSplitterDragData(source.data));
158
164
  var finalWidth = getPixelWidth(panel);
159
165
  onCompleteResize(finalWidth);
160
166
  onResizeEnd === null || onResizeEnd === void 0 || onResizeEnd({
@@ -266,6 +272,7 @@ var PortaledPanelSplitter = function PortaledPanelSplitter(_ref) {
266
272
  }, /*#__PURE__*/React.createElement("div", {
267
273
  ref: splitterRef,
268
274
  "data-testid": testId,
275
+ onDoubleClick: onDoubleClick,
269
276
  className: ax([grabAreaStyles.root])
270
277
  }, /*#__PURE__*/React.createElement(VisuallyHidden, null, /*#__PURE__*/React.createElement("input", {
271
278
  type: "range",
@@ -0,0 +1,38 @@
1
+ import React, { useContext } from 'react';
2
+ import invariant from 'tiny-invariant';
3
+ import { sideNavPanelSplitterId } from '../constants';
4
+ import { useToggleSideNav } from '../side-nav/use-toggle-side-nav';
5
+ import { OnDoubleClickContext, PanelSplitterContext } from './context';
6
+ import { PanelSplitter } from './panel-splitter';
7
+ /**
8
+ * _SideNavPanelSplitter_
9
+ *
10
+ * A component that allows the user to resize or collapse the side nav.
11
+ * It must be used within the `SideNav` layout area.
12
+ *
13
+ * Example usage:
14
+ * ```tsx
15
+ * <SideNav>
16
+ * <SideNavPanelSplitter label="Resize or collapse Side Nav" />
17
+ * </SideNav>
18
+ * ```
19
+ */
20
+ export var SideNavPanelSplitter = function SideNavPanelSplitter(_ref) {
21
+ var label = _ref.label,
22
+ onResizeStart = _ref.onResizeStart,
23
+ onResizeEnd = _ref.onResizeEnd,
24
+ testId = _ref.testId,
25
+ _ref$shouldCollapseOn = _ref.shouldCollapseOnDoubleClick,
26
+ shouldCollapseOnDoubleClick = _ref$shouldCollapseOn === void 0 ? true : _ref$shouldCollapseOn;
27
+ var context = useContext(PanelSplitterContext);
28
+ invariant((context === null || context === void 0 ? void 0 : context.panelId) === sideNavPanelSplitterId, 'SideNavPanelSplitter must be rendered as a child of <SideNav />.');
29
+ var toggleSideNav = useToggleSideNav();
30
+ return /*#__PURE__*/React.createElement(OnDoubleClickContext.Provider, {
31
+ value: shouldCollapseOnDoubleClick ? toggleSideNav : undefined
32
+ }, /*#__PURE__*/React.createElement(PanelSplitter, {
33
+ label: label,
34
+ onResizeStart: onResizeStart,
35
+ onResizeEnd: onResizeEnd,
36
+ testId: testId
37
+ }));
38
+ };
@@ -15,6 +15,7 @@ import { useLayoutId } from './id-utils';
15
15
  import { PanelSplitterProvider } from './panel-splitter/provider';
16
16
  import { useSideNavRef } from './side-nav/element-context';
17
17
  import { useResizingWidthCssVarOnRootElement } from './use-resizing-width-css-var-on-root-element';
18
+ import { useSafeDefaultWidth } from './use-safe-default-width';
18
19
  var panelSplitterResizingVar = '--n_pnlRsz';
19
20
 
20
21
  /**
@@ -32,6 +33,7 @@ var styles = {
32
33
  oldMobileWidth: "_1bsb1adv",
33
34
  newMobileWidth: "_1bsb1dxx"
34
35
  };
36
+ var fallbackDefaultWidth = 365;
35
37
 
36
38
  /**
37
39
  * The Panel layout area is rendered to the right (inline end) of the Main area, or the Aside area if it is present.
@@ -43,7 +45,7 @@ var styles = {
43
45
  export function Panel(_ref) {
44
46
  var children = _ref.children,
45
47
  _ref$defaultWidth = _ref.defaultWidth,
46
- defaultWidth = _ref$defaultWidth === void 0 ? 365 : _ref$defaultWidth,
48
+ defaultWidthProp = _ref$defaultWidth === void 0 ? fallbackDefaultWidth : _ref$defaultWidth,
47
49
  _ref$label = _ref.label,
48
50
  label = _ref$label === void 0 ? 'Panel' : _ref$label,
49
51
  _ref$skipLinkLabel = _ref.skipLinkLabel,
@@ -57,6 +59,12 @@ export function Panel(_ref) {
57
59
  var id = useLayoutId({
58
60
  providedId: providedId
59
61
  });
62
+ var defaultWidth = useSafeDefaultWidth({
63
+ defaultWidthProp: defaultWidthProp,
64
+ fallbackDefaultWidth: fallbackDefaultWidth,
65
+ slotName: 'Panel'
66
+ });
67
+
60
68
  /**
61
69
  * Don't show the skip link if the slot has 0 width.
62
70
  *
@@ -21,6 +21,7 @@ import { DangerouslyHoistCssVarToDocumentRoot } from '../hoist-utils';
21
21
  import { useLayoutId } from '../id-utils';
22
22
  import { PanelSplitterProvider } from '../panel-splitter/provider';
23
23
  import { useResizingWidthCssVarOnRootElement } from '../use-resizing-width-css-var-on-root-element';
24
+ import { useSafeDefaultWidth } from '../use-safe-default-width';
24
25
  import { useSideNavRef } from './element-context';
25
26
  import { sideNavFlyoutCloseDelayMs } from './flyout-close-delay-ms';
26
27
  import { SideNavToggleButtonElement } from './toggle-button-context';
@@ -50,6 +51,8 @@ var styles = {
50
51
  hiddenMobileOnly: "_1e0cglyw _dm2518uv",
51
52
  hiddenDesktopOnly: "_dm25glyw"
52
53
  };
54
+ var fallbackDefaultWidth = 320;
55
+
53
56
  /**
54
57
  * We need an additional component layer so we can wrap the side nav in a `OpenLayerObserver` and have access to the
55
58
  * context value.
@@ -58,7 +61,7 @@ function SideNavInternal(_ref) {
58
61
  var children = _ref.children,
59
62
  defaultCollapsed = _ref.defaultCollapsed,
60
63
  _ref$defaultWidth = _ref.defaultWidth,
61
- defaultWidth = _ref$defaultWidth === void 0 ? 320 : _ref$defaultWidth,
64
+ defaultWidthProp = _ref$defaultWidth === void 0 ? fallbackDefaultWidth : _ref$defaultWidth,
62
65
  testId = _ref.testId,
63
66
  _ref$label = _ref.label,
64
67
  label = _ref$label === void 0 ? 'Sidebar' : _ref$label,
@@ -104,6 +107,11 @@ function SideNavInternal(_ref) {
104
107
  var _useState = useState(defaultCollapsed),
105
108
  _useState2 = _slicedToArray(_useState, 1),
106
109
  initialDefaultCollapsed = _useState2[0];
110
+ var defaultWidth = useSafeDefaultWidth({
111
+ defaultWidthProp: defaultWidthProp,
112
+ fallbackDefaultWidth: fallbackDefaultWidth,
113
+ slotName: 'SideNav'
114
+ });
107
115
  var _useState3 = useState(defaultWidth),
108
116
  _useState4 = _slicedToArray(_useState3, 2),
109
117
  width = _useState4[0],
@@ -0,0 +1,27 @@
1
+ import { fg } from '@atlaskit/platform-feature-flags';
2
+
3
+ /**
4
+ * When `platform_dst_nav4_panel_splitter_guards` is disabled,
5
+ * `useSafeDefaultWidth` returns the provided `defaultWidthProp`.
6
+ *
7
+ * When `platform_dst_nav4_panel_splitter_guards` is enabled,
8
+ * `useSafeDefaultWidth` returns the `fallbackWidth` if the provided `defaultWidthProp` is not an integer value.
9
+ */
10
+ export function useSafeDefaultWidth(_ref) {
11
+ var defaultWidthProp = _ref.defaultWidthProp,
12
+ fallbackDefaultWidth = _ref.fallbackDefaultWidth,
13
+ slotName = _ref.slotName;
14
+ if (fg('platform_dst_nav4_panel_splitter_guards')) {
15
+ // If the provided `defaultWidth` is invalid then we use our fallback.
16
+ // We are using a runtime check because some invalid numbers like `NaN` are not caught by types,
17
+ // and we saw some issues in products where our experience broke due to this.
18
+ if (!Number.isInteger(defaultWidthProp)) {
19
+ if (process.env.NODE_ENV !== 'production') {
20
+ // eslint-disable-next-line no-console
21
+ console.error("The defaultWidth value must be an integer, but '".concat(defaultWidthProp, "' was provided to ").concat(slotName, ". Falling back to ").concat(fallbackDefaultWidth, "px instead."));
22
+ }
23
+ return fallbackDefaultWidth;
24
+ }
25
+ }
26
+ return defaultWidthProp;
27
+ }
@@ -1,5 +1,5 @@
1
1
 
2
- ._2rkosqtm{border-radius:var(--ds-border-radius-100,3px)}
2
+ ._2rkofajl{border-radius:var(--ds-radius-small,3px)}
3
3
  ._18zr1b66{padding-inline:var(--ds-space-050,4px)}
4
4
  ._18zru2gc{padding-inline:var(--ds-space-100,8px)}._18m915vq{overflow-y:hidden}
5
5
  ._1e0c1txw{display:flex}
@@ -9,8 +9,8 @@ import { Anchor } from '@atlaskit/primitives';
9
9
  import { useHasCustomTheme } from '../themed/has-custom-theme-context';
10
10
  import { LogoRenderer } from './logo-renderer';
11
11
  var anchorStyles = {
12
- root: "_2rkosqtm _1e0c1txw _4cvr1h6o _4t3izwfg",
13
- customLogoBorderRadius: "_2rkosqtm",
12
+ root: "_2rkofajl _1e0c1txw _4cvr1h6o _4t3izwfg",
13
+ customLogoBorderRadius: "_2rkofajl",
14
14
  newMargin: "_ahbq1b66",
15
15
  newInteractionStates: "_irr3166n _1di61wwy",
16
16
  newInteractionStatesCustomTheming: "_irr31rps _1di6yhlj"
@@ -1,5 +1,5 @@
1
1
 
2
- ._2rkoiti9{border-radius:var(--ds-border-radius-100,4px)}._18zr12x7{padding-inline:var(--ds-space-075,6px)}
2
+ ._2rko12b0{border-radius:var(--ds-radius-small,4px)}._18zr12x7{padding-inline:var(--ds-space-075,6px)}
3
3
  ._1ii7kb7n{grid-row:1}
4
4
  ._1rjcze3t{padding-block:var(--ds-space-0,0)}
5
5
  ._yyhy11wp{grid-column:3}
@@ -6,7 +6,7 @@ import SearchIcon from '@atlaskit/icon/core/search';
6
6
  import { Pressable, Show, Text } from '@atlaskit/primitives/compiled';
7
7
  import { IconButton } from './themed/migration';
8
8
  var styles = {
9
- root: "_2rkoiti9 _1rjcze3t _18zr12x7 _yv0e1mfv _4cvr1h6o _bfhk1j9a _vchhusvi _80om1kdv _1e0cglyw _4t3izwfg _p12f1kvu _1bsb1osq _irr31d5g _1di6r01l _114b11p5",
9
+ root: "_2rko12b0 _1rjcze3t _18zr12x7 _yv0e1mfv _4cvr1h6o _bfhk1j9a _vchhusvi _80om1kdv _1e0cglyw _4t3izwfg _p12f1kvu _1bsb1osq _irr31d5g _1di6r01l _114b11p5",
10
10
  buttonText: "_yyhyjvu9 _1ii7kb7n",
11
11
  iconBefore: "_yyhykb7n _1ii7kb7n _1e0c1txw",
12
12
  elemAfter: "_yyhy11wp _1ii7kb7n _1e0c1txw"
@@ -4,7 +4,7 @@
4
4
  ._11q7esko{background:var(--ds-top-bar-button-primary-background)}
5
5
  ._11q7pkxg{background:var(--ds-top-bar-button-background)}
6
6
  ._14mj1kw7:after{border-radius:inherit}
7
- ._2rkosqtm{border-radius:var(--ds-border-radius-100,3px)}
7
+ ._2rkofajl{border-radius:var(--ds-radius-small,3px)}
8
8
  ._9v7aze3t:after{inset:var(--ds-space-0,0)}
9
9
  ._v5649dqc{transition:background .1s ease-out}
10
10
  ._zulp12x7{gap:var(--ds-space-075,6px)}
@@ -77,7 +77,7 @@ export var themedButtonSelectedBorder = '--ds-top-bar-button-selected-border';
77
77
  export var themedButtonDisabledText = '--ds-top-bar-button-disabled-text';
78
78
  export var themedButtonDisabledBackground = '--ds-top-bar-button-disabled-background';
79
79
  var styles = {
80
- root: "_zulp12x7 _11c82smr _2rkosqtm _v5649dqc _4bfu1r31 _1hmsglyw _ajmmnqa1 _1rjcze3t _1e0c1txw _4cvr1h6o _1bah1h6o _4t3i5r7u _kqswh2mm _1nrm1r31 _1a3b1r31 _9oik1r31 _c2waglyw _4fprglyw _1bnxglyw _1iohnqa1 _5goinqa1 _jf4cnqa1",
80
+ root: "_zulp12x7 _11c82smr _2rkofajl _v5649dqc _4bfu1r31 _1hmsglyw _ajmmnqa1 _1rjcze3t _1e0c1txw _4cvr1h6o _1bah1h6o _4t3i5r7u _kqswh2mm _1nrm1r31 _1a3b1r31 _9oik1r31 _c2waglyw _4fprglyw _1bnxglyw _1iohnqa1 _5goinqa1 _jf4cnqa1",
81
81
  border: "_14mj1kw7 _9v7aze3t _1tv3nqa1 _39yqe4h9 _aetrb3bt _18postnw",
82
82
  selected: "_11q71qds _syazw5ct _8l3m15jn _f8pjw5ct _1053w5ct _19lcjrv1 _30l3w5ct _j6xtnh62 _9h8hw5ct",
83
83
  disabled: "_11q71c9b _syaz1i3i _8l3m1j28 _f8pj1i3i _10531i3i _19lc1c9b _30l31i3i _j6xt1c9b _9h8h1i3i"
@@ -5,7 +5,7 @@ import type { CommonSlotProps } from './types';
5
5
  *
6
6
  * You can optionally render a `PanelSplitter` as a child to make the aside area resizable.
7
7
  */
8
- export declare function Aside({ children, xcss, defaultWidth, label, skipLinkLabel, testId, id: providedId, }: CommonSlotProps & {
8
+ export declare function Aside({ children, xcss, defaultWidth: defaultWidthProp, label, skipLinkLabel, testId, id: providedId, }: CommonSlotProps & {
9
9
  /**
10
10
  * The content of the layout area.
11
11
  */
@@ -21,7 +21,7 @@ export declare function Aside({ children, xcss, defaultWidth, label, skipLinkLab
21
21
  /**
22
22
  * The default width of the layout area.
23
23
  *
24
- * It should be between the resize bounds - the minimum is 120px and the maximum is 50% of the viewport width.
24
+ * It should be an integer between the resize bounds - the minimum is 120px and the maximum is 50% of the viewport width.
25
25
  */
26
26
  defaultWidth?: number;
27
27
  }): JSX.Element;
@@ -52,3 +52,11 @@ export type PanelSplitterContextType = {
52
52
  * Context for the panel splitter. Only internally exported.
53
53
  */
54
54
  export declare const PanelSplitterContext: import("react").Context<PanelSplitterContextType | null>;
55
+ /**
56
+ * Context for the panel splitter's double click handler. Only internally exported.
57
+ *
58
+ * NOTE: This context is a temporary workaround to enable the `SideNavPanelSplitter` component
59
+ * to collapse the side nav on double click, without exposing the `onDoubleClick` prop on `PanelSplitter`.
60
+ * Once `PanelSplitter` supports an `onDoubleClick` prop directly, this context should be removed.
61
+ */
62
+ export declare const OnDoubleClickContext: import("react").Context<(() => void) | undefined>;
@@ -4,7 +4,7 @@
4
4
  */
5
5
  import { type ReactNode } from 'react';
6
6
  import type { ResizeBounds, ResizeEndCallback, ResizeStartCallback } from './types';
7
- type PanelSplitterProps = {
7
+ export type PanelSplitterProps = {
8
8
  /**
9
9
  * The accessible label for the panel splitter. It is visually hidden, but is required for accessibility.
10
10
  */
@@ -0,0 +1,20 @@
1
+ import { type ReactNode } from 'react';
2
+ import { type PanelSplitterProps } from './panel-splitter';
3
+ type SideNavPanelSplitterProps = Omit<PanelSplitterProps, 'onDoubleClick'> & {
4
+ shouldCollapseOnDoubleClick?: boolean;
5
+ };
6
+ /**
7
+ * _SideNavPanelSplitter_
8
+ *
9
+ * A component that allows the user to resize or collapse the side nav.
10
+ * It must be used within the `SideNav` layout area.
11
+ *
12
+ * Example usage:
13
+ * ```tsx
14
+ * <SideNav>
15
+ * <SideNavPanelSplitter label="Resize or collapse Side Nav" />
16
+ * </SideNav>
17
+ * ```
18
+ */
19
+ export declare const SideNavPanelSplitter: ({ label, onResizeStart, onResizeEnd, testId, shouldCollapseOnDoubleClick, }: SideNavPanelSplitterProps) => ReactNode;
20
+ export {};
@@ -7,7 +7,7 @@ import type { CommonSlotProps } from './types';
7
7
  *
8
8
  * You can optionally render a `PanelSplitter` as a child to make the panel area resizable.
9
9
  */
10
- export declare function Panel({ children, defaultWidth, label, skipLinkLabel, testId, id: providedId, xcss, hasBorder, }: CommonSlotProps & {
10
+ export declare function Panel({ children, defaultWidth: defaultWidthProp, label, skipLinkLabel, testId, id: providedId, xcss, hasBorder, }: CommonSlotProps & {
11
11
  /**
12
12
  * The content of the layout area.
13
13
  */
@@ -19,7 +19,7 @@ export declare function Panel({ children, defaultWidth, label, skipLinkLabel, te
19
19
  /**
20
20
  * The default width of the layout area.
21
21
  *
22
- * It should be between the resize bounds - the minimum is 120px and the maximum is 50% of the viewport width.
22
+ * It should be an integer between the resize bounds - the minimum is 120px and the maximum is 50% of the viewport width.
23
23
  *
24
24
  * This value is also used as the minimum resizing width, except when the `defaultWidth` is greater then `400px`,
25
25
  * in which case `400px` will be used as the minimum resizing width instead.
@@ -26,7 +26,8 @@ type SideNavProps = CommonSlotProps & {
26
26
  defaultCollapsed?: boolean;
27
27
  /**
28
28
  * The default width of the side nav layout area.
29
- * It should be between the resize bounds - the minimum is 240px and the maximum is 50% of the viewport width.
29
+ *
30
+ * It should be an integer between the resize bounds - the minimum is 240px and the maximum is 50% of the viewport width.
30
31
  *
31
32
  * It is only used when the side nav is first mounted, but you should continuously update your
32
33
  * persisted state using the `onResizeEnd` callback of `PanelSplitter`, to ensure it is up to date
@@ -0,0 +1,21 @@
1
+ /**
2
+ * When `platform_dst_nav4_panel_splitter_guards` is disabled,
3
+ * `useSafeDefaultWidth` returns the provided `defaultWidthProp`.
4
+ *
5
+ * When `platform_dst_nav4_panel_splitter_guards` is enabled,
6
+ * `useSafeDefaultWidth` returns the `fallbackWidth` if the provided `defaultWidthProp` is not an integer value.
7
+ */
8
+ export declare function useSafeDefaultWidth({ defaultWidthProp, fallbackDefaultWidth, slotName, }: {
9
+ /**
10
+ * The `defaultWidth` passed in by the app.
11
+ */
12
+ defaultWidthProp: number;
13
+ /**
14
+ * The fallback value for `defaultWidth` if `defaultWidthProp` is invalid.
15
+ */
16
+ fallbackDefaultWidth: number;
17
+ /**
18
+ * The name of the slot, used for the dev-time console error.
19
+ */
20
+ slotName: string;
21
+ }): number;
@@ -5,7 +5,7 @@ import type { CommonSlotProps } from './types';
5
5
  *
6
6
  * You can optionally render a `PanelSplitter` as a child to make the aside area resizable.
7
7
  */
8
- export declare function Aside({ children, xcss, defaultWidth, label, skipLinkLabel, testId, id: providedId, }: CommonSlotProps & {
8
+ export declare function Aside({ children, xcss, defaultWidth: defaultWidthProp, label, skipLinkLabel, testId, id: providedId, }: CommonSlotProps & {
9
9
  /**
10
10
  * The content of the layout area.
11
11
  */
@@ -21,7 +21,7 @@ export declare function Aside({ children, xcss, defaultWidth, label, skipLinkLab
21
21
  /**
22
22
  * The default width of the layout area.
23
23
  *
24
- * It should be between the resize bounds - the minimum is 120px and the maximum is 50% of the viewport width.
24
+ * It should be an integer between the resize bounds - the minimum is 120px and the maximum is 50% of the viewport width.
25
25
  */
26
26
  defaultWidth?: number;
27
27
  }): JSX.Element;
@@ -52,3 +52,11 @@ export type PanelSplitterContextType = {
52
52
  * Context for the panel splitter. Only internally exported.
53
53
  */
54
54
  export declare const PanelSplitterContext: import("react").Context<PanelSplitterContextType | null>;
55
+ /**
56
+ * Context for the panel splitter's double click handler. Only internally exported.
57
+ *
58
+ * NOTE: This context is a temporary workaround to enable the `SideNavPanelSplitter` component
59
+ * to collapse the side nav on double click, without exposing the `onDoubleClick` prop on `PanelSplitter`.
60
+ * Once `PanelSplitter` supports an `onDoubleClick` prop directly, this context should be removed.
61
+ */
62
+ export declare const OnDoubleClickContext: import("react").Context<(() => void) | undefined>;
@@ -4,7 +4,7 @@
4
4
  */
5
5
  import { type ReactNode } from 'react';
6
6
  import type { ResizeBounds, ResizeEndCallback, ResizeStartCallback } from './types';
7
- type PanelSplitterProps = {
7
+ export type PanelSplitterProps = {
8
8
  /**
9
9
  * The accessible label for the panel splitter. It is visually hidden, but is required for accessibility.
10
10
  */
@@ -0,0 +1,20 @@
1
+ import { type ReactNode } from 'react';
2
+ import { type PanelSplitterProps } from './panel-splitter';
3
+ type SideNavPanelSplitterProps = Omit<PanelSplitterProps, 'onDoubleClick'> & {
4
+ shouldCollapseOnDoubleClick?: boolean;
5
+ };
6
+ /**
7
+ * _SideNavPanelSplitter_
8
+ *
9
+ * A component that allows the user to resize or collapse the side nav.
10
+ * It must be used within the `SideNav` layout area.
11
+ *
12
+ * Example usage:
13
+ * ```tsx
14
+ * <SideNav>
15
+ * <SideNavPanelSplitter label="Resize or collapse Side Nav" />
16
+ * </SideNav>
17
+ * ```
18
+ */
19
+ export declare const SideNavPanelSplitter: ({ label, onResizeStart, onResizeEnd, testId, shouldCollapseOnDoubleClick, }: SideNavPanelSplitterProps) => ReactNode;
20
+ export {};
@@ -7,7 +7,7 @@ import type { CommonSlotProps } from './types';
7
7
  *
8
8
  * You can optionally render a `PanelSplitter` as a child to make the panel area resizable.
9
9
  */
10
- export declare function Panel({ children, defaultWidth, label, skipLinkLabel, testId, id: providedId, xcss, hasBorder, }: CommonSlotProps & {
10
+ export declare function Panel({ children, defaultWidth: defaultWidthProp, label, skipLinkLabel, testId, id: providedId, xcss, hasBorder, }: CommonSlotProps & {
11
11
  /**
12
12
  * The content of the layout area.
13
13
  */
@@ -19,7 +19,7 @@ export declare function Panel({ children, defaultWidth, label, skipLinkLabel, te
19
19
  /**
20
20
  * The default width of the layout area.
21
21
  *
22
- * It should be between the resize bounds - the minimum is 120px and the maximum is 50% of the viewport width.
22
+ * It should be an integer between the resize bounds - the minimum is 120px and the maximum is 50% of the viewport width.
23
23
  *
24
24
  * This value is also used as the minimum resizing width, except when the `defaultWidth` is greater then `400px`,
25
25
  * in which case `400px` will be used as the minimum resizing width instead.
@@ -26,7 +26,8 @@ type SideNavProps = CommonSlotProps & {
26
26
  defaultCollapsed?: boolean;
27
27
  /**
28
28
  * The default width of the side nav layout area.
29
- * It should be between the resize bounds - the minimum is 240px and the maximum is 50% of the viewport width.
29
+ *
30
+ * It should be an integer between the resize bounds - the minimum is 240px and the maximum is 50% of the viewport width.
30
31
  *
31
32
  * It is only used when the side nav is first mounted, but you should continuously update your
32
33
  * persisted state using the `onResizeEnd` callback of `PanelSplitter`, to ensure it is up to date
@@ -0,0 +1,21 @@
1
+ /**
2
+ * When `platform_dst_nav4_panel_splitter_guards` is disabled,
3
+ * `useSafeDefaultWidth` returns the provided `defaultWidthProp`.
4
+ *
5
+ * When `platform_dst_nav4_panel_splitter_guards` is enabled,
6
+ * `useSafeDefaultWidth` returns the `fallbackWidth` if the provided `defaultWidthProp` is not an integer value.
7
+ */
8
+ export declare function useSafeDefaultWidth({ defaultWidthProp, fallbackDefaultWidth, slotName, }: {
9
+ /**
10
+ * The `defaultWidth` passed in by the app.
11
+ */
12
+ defaultWidthProp: number;
13
+ /**
14
+ * The fallback value for `defaultWidth` if `defaultWidthProp` is invalid.
15
+ */
16
+ fallbackDefaultWidth: number;
17
+ /**
18
+ * The name of the slot, used for the dev-time console error.
19
+ */
20
+ slotName: string;
21
+ }): number;