@atlaskit/navigation-system 10.5.7 → 10.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +32 -0
- package/dist/cjs/ui/page-layout/panel.compiled.css +4 -0
- package/dist/cjs/ui/page-layout/panel.js +47 -5
- package/dist/es2019/ui/page-layout/panel.compiled.css +4 -0
- package/dist/es2019/ui/page-layout/panel.js +47 -6
- package/dist/esm/ui/page-layout/panel.compiled.css +4 -0
- package/dist/esm/ui/page-layout/panel.js +48 -6
- package/package.json +9 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
# @atlassian/navigation-system
|
|
2
2
|
|
|
3
|
+
## 10.6.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`95ff9f0742fb9`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/95ff9f0742fb9) -
|
|
8
|
+
[ux] Added motion to `Panel` entry and exit behind the `platform-dst-motion-uplift-panel` feature
|
|
9
|
+
gate.
|
|
10
|
+
|
|
11
|
+
When the gate is enabled, `Panel` animates on entry automatically. To get the exit animation,
|
|
12
|
+
consumers must render the conditionally-mounted `Panel` inside an `ExitingPersistence` boundary so
|
|
13
|
+
the panel stays mounted until its exit motion finishes:
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import ExitingPersistence from '@atlaskit/motion/exiting-persistence';
|
|
17
|
+
import { Panel } from '@atlaskit/navigation-system/layout/panel';
|
|
18
|
+
|
|
19
|
+
function Example({ isPanelOpen }: { isPanelOpen: boolean }) {
|
|
20
|
+
return (
|
|
21
|
+
<ExitingPersistence>
|
|
22
|
+
{isPanelOpen && <Panel defaultWidth={320}>{/* panel content */}</Panel>}
|
|
23
|
+
</ExitingPersistence>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Without the `ExitingPersistence` wrapper the panel is removed immediately on close and the exit
|
|
29
|
+
animation is skipped. Entry animation works with or without the wrapper.
|
|
30
|
+
|
|
31
|
+
### Patch Changes
|
|
32
|
+
|
|
33
|
+
- Updated dependencies
|
|
34
|
+
|
|
3
35
|
## 10.5.7
|
|
4
36
|
|
|
5
37
|
### Patch Changes
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
|
|
2
2
|
._nd5l1b6c{grid-area:main/aside/aside/aside}
|
|
3
|
+
._y44v1s3l{animation:var(--ds-panel-enter,.25s cubic-bezier(0,.4,0,1) SlideIn100PercentRight)}
|
|
4
|
+
._y44vqhwn{animation:var(--ds-panel-exit,.2s cubic-bezier(.6,0,.8,.6) SlideOut100PercentRight)}
|
|
3
5
|
._191wglyw{border-inline-start:none}._10fph9n0{justify-self:end}
|
|
4
6
|
._152timx3{inset-block-start:calc(var(--n_bnrM, 0px) + var(--n_tNvM, 0px))}
|
|
5
7
|
._16qs130s{box-shadow:var(--ds-shadow-overlay,0 8px 9pt #1e1f2126,0 0 1px #1e1f214f)}
|
|
6
8
|
._18m91wug{overflow-y:auto}
|
|
7
9
|
._1bsb1dxx{width:min(90%,var(--minWidth))}
|
|
8
10
|
._1e0cglyw{display:none}
|
|
11
|
+
._1o51eoah{animation-fill-mode:backwards}
|
|
12
|
+
._1o51q7pw{animation-fill-mode:forwards}
|
|
9
13
|
._1pbykb7n{z-index:1}
|
|
10
14
|
._1reo1wug{overflow-x:auto}
|
|
11
15
|
._4t3i1osq{height:100%}
|
|
@@ -13,6 +13,9 @@ var React = _react;
|
|
|
13
13
|
var _runtime = require("@compiled/react/runtime");
|
|
14
14
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
15
15
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
16
|
+
var _react2 = require("@compiled/react");
|
|
17
|
+
var _mergeRefs = _interopRequireDefault(require("@atlaskit/ds-lib/merge-refs"));
|
|
18
|
+
var _useMotion2 = require("@atlaskit/motion/use-motion");
|
|
16
19
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
17
20
|
var _responsive = require("@atlaskit/primitives/responsive");
|
|
18
21
|
var _useSkipLinkInternal = require("../../context/skip-links/use-skip-link-internal");
|
|
@@ -40,7 +43,9 @@ var styles = {
|
|
|
40
43
|
root: "_nd5l1b6c _10fph9n0 _vchhusvi _1pbykb7n _4t3ieqxy _kqsw1if8 _152timx3 _bfhk1bhr _1bsb1dxx _14b54rrg _4ap3vuon _1dhy1c6w _9sns1wug",
|
|
41
44
|
border: "_191wglyw _16qs130s _1w6eia51 _scbpglyw",
|
|
42
45
|
scrollContainer: "_1reo1wug _18m91wug _4t3i1osq",
|
|
43
|
-
hidden: "_1e0cglyw"
|
|
46
|
+
hidden: "_1e0cglyw",
|
|
47
|
+
entering: "_y44v1s3l _1o51eoah",
|
|
48
|
+
exiting: "_y44vqhwn _1o51q7pw"
|
|
44
49
|
};
|
|
45
50
|
|
|
46
51
|
/**
|
|
@@ -67,6 +72,20 @@ function Panel(_ref) {
|
|
|
67
72
|
var id = (0, _useLayoutId.useLayoutId)({
|
|
68
73
|
providedId: providedId
|
|
69
74
|
});
|
|
75
|
+
|
|
76
|
+
// useMotion is applied only when the `platform-dst-motion-uplift-panel` gate is enabled.
|
|
77
|
+
var _useMotion = (0, _useMotion2.useMotion)({
|
|
78
|
+
onFinish: function onFinish(state) {
|
|
79
|
+
if (state === 'exiting' && defaultWidthRef.current === 0) {
|
|
80
|
+
// Set width to 0 as animation is complete
|
|
81
|
+
setWidth(0);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}),
|
|
85
|
+
state = _useMotion.state,
|
|
86
|
+
motionRef = _useMotion.ref,
|
|
87
|
+
reanimate = _useMotion.reanimate;
|
|
88
|
+
var isMotionUpliftEnabled = (0, _platformFeatureFlags.fg)('platform-dst-motion-uplift-panel');
|
|
70
89
|
var defaultWidth = (0, _useSafeDefaultWidth.useSafeDefaultWidth)({
|
|
71
90
|
defaultWidthProp: defaultWidthProp,
|
|
72
91
|
fallbackDefaultWidth: fallbackDefaultWidth,
|
|
@@ -93,6 +112,15 @@ function Panel(_ref) {
|
|
|
93
112
|
// Used to track the previous value of the `defaultWidth` prop, for logging dev warnings when it changes.
|
|
94
113
|
var defaultWidthRef = (0, _react.useRef)(defaultWidth);
|
|
95
114
|
|
|
115
|
+
// `mergeRefs` returns a new callback ref on every call, and combined with a new array literal
|
|
116
|
+
// this would cause React to detach/re-attach the ref on every render. Memoise it so the merged
|
|
117
|
+
// ref is stable across renders.
|
|
118
|
+
var mergedRef = (0, _react.useMemo)(function () {
|
|
119
|
+
return isMotionUpliftEnabled ? (0, _mergeRefs.default)([ref, motionRef]) : ref;
|
|
120
|
+
},
|
|
121
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
122
|
+
[isMotionUpliftEnabled, motionRef]);
|
|
123
|
+
|
|
96
124
|
/**
|
|
97
125
|
* TODO: Remove this useEffect once the `width: 0` usage is removed from Jira.
|
|
98
126
|
* It updates the width state based on changes to `defaultWidth`, as a temporary stopgap to support Jira's current usage.
|
|
@@ -102,13 +130,23 @@ function Panel(_ref) {
|
|
|
102
130
|
if (defaultWidthRef.current === defaultWidth) {
|
|
103
131
|
return;
|
|
104
132
|
}
|
|
133
|
+
if (isMotionUpliftEnabled) {
|
|
134
|
+
if (defaultWidth === 0) {
|
|
135
|
+
reanimate(_useMotion2.Reanimate.exit);
|
|
136
|
+
defaultWidthRef.current = defaultWidth;
|
|
137
|
+
// Set width to 0 once the exit animation is complete
|
|
138
|
+
return;
|
|
139
|
+
} else if (defaultWidthRef.current === 0) {
|
|
140
|
+
reanimate(_useMotion2.Reanimate.enter);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
105
143
|
defaultWidthRef.current = defaultWidth;
|
|
106
144
|
setWidth(defaultWidth);
|
|
107
145
|
if (process.env.NODE_ENV !== 'production') {
|
|
108
146
|
// eslint-disable-next-line no-console
|
|
109
147
|
console.warn('Page Layout warning\n\n', 'The value of the `defaultWidth` prop on the `Panel` layout slot component has changed. This should not be changed after the component has been mounted.\n\n', 'In the future, changes to the `defaultWidth` prop will not be respected. It is only supported as a stopgap to enable migration from Nav3 to Nav4.\n\n');
|
|
110
148
|
}
|
|
111
|
-
}, [defaultWidth]);
|
|
149
|
+
}, [defaultWidth, isMotionUpliftEnabled, reanimate]);
|
|
112
150
|
var sideNavRef = (0, _useSideNavRef.useSideNavRef)();
|
|
113
151
|
|
|
114
152
|
/**
|
|
@@ -152,11 +190,15 @@ function Panel(_ref) {
|
|
|
152
190
|
return /*#__PURE__*/React.createElement("section", {
|
|
153
191
|
id: id,
|
|
154
192
|
"data-layout-slot": true,
|
|
155
|
-
"aria-label": label
|
|
156
|
-
|
|
193
|
+
"aria-label": label
|
|
194
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
|
|
195
|
+
,
|
|
196
|
+
className: (0, _runtime.ax)([styles.root, !isMotionUpliftEnabled && defaultWidth === 0 && styles.hidden, hasBorder && styles.border, isMotionUpliftEnabled ?
|
|
197
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/local-cx-xcss, @compiled/local-cx-xcss
|
|
198
|
+
(0, _react2.cx)(xcss, state === 'entering' && styles.entering, state === 'exiting' && styles.exiting) : xcss]),
|
|
157
199
|
style: (0, _defineProperty2.default)((0, _defineProperty2.default)({}, _constants.panelVar, panelVariableWidth), '--minWidth', "".concat(minWidth, "px")),
|
|
158
200
|
"data-testid": testId,
|
|
159
|
-
ref:
|
|
201
|
+
ref: mergedRef
|
|
160
202
|
}, dangerouslyHoistSlotSizes &&
|
|
161
203
|
/*#__PURE__*/
|
|
162
204
|
// ------ START UNSAFE STYLES ------
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
|
|
2
2
|
._nd5l1b6c{grid-area:main/aside/aside/aside}
|
|
3
|
+
._y44v1s3l{animation:var(--ds-panel-enter,.25s cubic-bezier(0,.4,0,1) SlideIn100PercentRight)}
|
|
4
|
+
._y44vqhwn{animation:var(--ds-panel-exit,.2s cubic-bezier(.6,0,.8,.6) SlideOut100PercentRight)}
|
|
3
5
|
._191wglyw{border-inline-start:none}._10fph9n0{justify-self:end}
|
|
4
6
|
._152timx3{inset-block-start:calc(var(--n_bnrM, 0px) + var(--n_tNvM, 0px))}
|
|
5
7
|
._16qs130s{box-shadow:var(--ds-shadow-overlay,0 8px 9pt #1e1f2126,0 0 1px #1e1f214f)}
|
|
6
8
|
._18m91wug{overflow-y:auto}
|
|
7
9
|
._1bsb1dxx{width:min(90%,var(--minWidth))}
|
|
8
10
|
._1e0cglyw{display:none}
|
|
11
|
+
._1o51eoah{animation-fill-mode:backwards}
|
|
12
|
+
._1o51q7pw{animation-fill-mode:forwards}
|
|
9
13
|
._1pbykb7n{z-index:1}
|
|
10
14
|
._1reo1wug{overflow-x:auto}
|
|
11
15
|
._4t3i1osq{height:100%}
|
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
import "./panel.compiled.css";
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { ax, ix } from "@compiled/react/runtime";
|
|
5
|
-
import { useCallback, useContext, useEffect, useRef, useState } from 'react';
|
|
5
|
+
import { useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
|
|
6
|
+
import { cx } from '@compiled/react';
|
|
7
|
+
import mergeRefs from '@atlaskit/ds-lib/merge-refs';
|
|
8
|
+
import { useMotion, Reanimate } from '@atlaskit/motion/use-motion';
|
|
6
9
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
10
|
// eslint-disable-next-line @atlaskit/design-system/no-emotion-primitives -- TODO: migrate to @atlaskit/primitives/compiled
|
|
8
11
|
import { media } from '@atlaskit/primitives/responsive';
|
|
@@ -29,7 +32,9 @@ const styles = {
|
|
|
29
32
|
root: "_nd5l1b6c _10fph9n0 _vchhusvi _1pbykb7n _4t3ieqxy _kqsw1if8 _152timx3 _bfhk1bhr _1bsb1dxx _14b54rrg _4ap3vuon _1dhy1c6w _9sns1wug",
|
|
30
33
|
border: "_191wglyw _16qs130s _1w6eia51 _scbpglyw",
|
|
31
34
|
scrollContainer: "_1reo1wug _18m91wug _4t3i1osq",
|
|
32
|
-
hidden: "_1e0cglyw"
|
|
35
|
+
hidden: "_1e0cglyw",
|
|
36
|
+
entering: "_y44v1s3l _1o51eoah",
|
|
37
|
+
exiting: "_y44vqhwn _1o51q7pw"
|
|
33
38
|
};
|
|
34
39
|
|
|
35
40
|
/**
|
|
@@ -53,6 +58,21 @@ export function Panel({
|
|
|
53
58
|
const id = useLayoutId({
|
|
54
59
|
providedId
|
|
55
60
|
});
|
|
61
|
+
|
|
62
|
+
// useMotion is applied only when the `platform-dst-motion-uplift-panel` gate is enabled.
|
|
63
|
+
const {
|
|
64
|
+
state,
|
|
65
|
+
ref: motionRef,
|
|
66
|
+
reanimate
|
|
67
|
+
} = useMotion({
|
|
68
|
+
onFinish: state => {
|
|
69
|
+
if (state === 'exiting' && defaultWidthRef.current === 0) {
|
|
70
|
+
// Set width to 0 as animation is complete
|
|
71
|
+
setWidth(0);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
const isMotionUpliftEnabled = fg('platform-dst-motion-uplift-panel');
|
|
56
76
|
const defaultWidth = useSafeDefaultWidth({
|
|
57
77
|
defaultWidthProp,
|
|
58
78
|
fallbackDefaultWidth,
|
|
@@ -76,6 +96,13 @@ export function Panel({
|
|
|
76
96
|
// Used to track the previous value of the `defaultWidth` prop, for logging dev warnings when it changes.
|
|
77
97
|
const defaultWidthRef = useRef(defaultWidth);
|
|
78
98
|
|
|
99
|
+
// `mergeRefs` returns a new callback ref on every call, and combined with a new array literal
|
|
100
|
+
// this would cause React to detach/re-attach the ref on every render. Memoise it so the merged
|
|
101
|
+
// ref is stable across renders.
|
|
102
|
+
const mergedRef = useMemo(() => isMotionUpliftEnabled ? mergeRefs([ref, motionRef]) : ref,
|
|
103
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
104
|
+
[isMotionUpliftEnabled, motionRef]);
|
|
105
|
+
|
|
79
106
|
/**
|
|
80
107
|
* TODO: Remove this useEffect once the `width: 0` usage is removed from Jira.
|
|
81
108
|
* It updates the width state based on changes to `defaultWidth`, as a temporary stopgap to support Jira's current usage.
|
|
@@ -85,13 +112,23 @@ export function Panel({
|
|
|
85
112
|
if (defaultWidthRef.current === defaultWidth) {
|
|
86
113
|
return;
|
|
87
114
|
}
|
|
115
|
+
if (isMotionUpliftEnabled) {
|
|
116
|
+
if (defaultWidth === 0) {
|
|
117
|
+
reanimate(Reanimate.exit);
|
|
118
|
+
defaultWidthRef.current = defaultWidth;
|
|
119
|
+
// Set width to 0 once the exit animation is complete
|
|
120
|
+
return;
|
|
121
|
+
} else if (defaultWidthRef.current === 0) {
|
|
122
|
+
reanimate(Reanimate.enter);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
88
125
|
defaultWidthRef.current = defaultWidth;
|
|
89
126
|
setWidth(defaultWidth);
|
|
90
127
|
if (process.env.NODE_ENV !== 'production') {
|
|
91
128
|
// eslint-disable-next-line no-console
|
|
92
129
|
console.warn('Page Layout warning\n\n', 'The value of the `defaultWidth` prop on the `Panel` layout slot component has changed. This should not be changed after the component has been mounted.\n\n', 'In the future, changes to the `defaultWidth` prop will not be respected. It is only supported as a stopgap to enable migration from Nav3 to Nav4.\n\n');
|
|
93
130
|
}
|
|
94
|
-
}, [defaultWidth]);
|
|
131
|
+
}, [defaultWidth, isMotionUpliftEnabled, reanimate]);
|
|
95
132
|
const sideNavRef = useSideNavRef();
|
|
96
133
|
|
|
97
134
|
/**
|
|
@@ -135,15 +172,19 @@ export function Panel({
|
|
|
135
172
|
return /*#__PURE__*/React.createElement("section", {
|
|
136
173
|
id: id,
|
|
137
174
|
"data-layout-slot": true,
|
|
138
|
-
"aria-label": label
|
|
139
|
-
|
|
175
|
+
"aria-label": label
|
|
176
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
|
|
177
|
+
,
|
|
178
|
+
className: ax([styles.root, !isMotionUpliftEnabled && defaultWidth === 0 && styles.hidden, hasBorder && styles.border, isMotionUpliftEnabled ?
|
|
179
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/local-cx-xcss, @compiled/local-cx-xcss
|
|
180
|
+
cx(xcss, state === 'entering' && styles.entering, state === 'exiting' && styles.exiting) : xcss]),
|
|
140
181
|
style: {
|
|
141
182
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
142
183
|
[panelVar]: panelVariableWidth,
|
|
143
184
|
'--minWidth': `${minWidth}px`
|
|
144
185
|
},
|
|
145
186
|
"data-testid": testId,
|
|
146
|
-
ref:
|
|
187
|
+
ref: mergedRef
|
|
147
188
|
}, dangerouslyHoistSlotSizes &&
|
|
148
189
|
/*#__PURE__*/
|
|
149
190
|
// ------ START UNSAFE STYLES ------
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
|
|
2
2
|
._nd5l1b6c{grid-area:main/aside/aside/aside}
|
|
3
|
+
._y44v1s3l{animation:var(--ds-panel-enter,.25s cubic-bezier(0,.4,0,1) SlideIn100PercentRight)}
|
|
4
|
+
._y44vqhwn{animation:var(--ds-panel-exit,.2s cubic-bezier(.6,0,.8,.6) SlideOut100PercentRight)}
|
|
3
5
|
._191wglyw{border-inline-start:none}._10fph9n0{justify-self:end}
|
|
4
6
|
._152timx3{inset-block-start:calc(var(--n_bnrM, 0px) + var(--n_tNvM, 0px))}
|
|
5
7
|
._16qs130s{box-shadow:var(--ds-shadow-overlay,0 8px 9pt #1e1f2126,0 0 1px #1e1f214f)}
|
|
6
8
|
._18m91wug{overflow-y:auto}
|
|
7
9
|
._1bsb1dxx{width:min(90%,var(--minWidth))}
|
|
8
10
|
._1e0cglyw{display:none}
|
|
11
|
+
._1o51eoah{animation-fill-mode:backwards}
|
|
12
|
+
._1o51q7pw{animation-fill-mode:forwards}
|
|
9
13
|
._1pbykb7n{z-index:1}
|
|
10
14
|
._1reo1wug{overflow-x:auto}
|
|
11
15
|
._4t3i1osq{height:100%}
|
|
@@ -4,7 +4,10 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
|
4
4
|
import "./panel.compiled.css";
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import { ax, ix } from "@compiled/react/runtime";
|
|
7
|
-
import { useCallback, useContext, useEffect, useRef, useState } from 'react';
|
|
7
|
+
import { useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
|
|
8
|
+
import { cx } from '@compiled/react';
|
|
9
|
+
import mergeRefs from '@atlaskit/ds-lib/merge-refs';
|
|
10
|
+
import { useMotion, Reanimate } from '@atlaskit/motion/use-motion';
|
|
8
11
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
9
12
|
// eslint-disable-next-line @atlaskit/design-system/no-emotion-primitives -- TODO: migrate to @atlaskit/primitives/compiled
|
|
10
13
|
import { media } from '@atlaskit/primitives/responsive';
|
|
@@ -31,7 +34,9 @@ var styles = {
|
|
|
31
34
|
root: "_nd5l1b6c _10fph9n0 _vchhusvi _1pbykb7n _4t3ieqxy _kqsw1if8 _152timx3 _bfhk1bhr _1bsb1dxx _14b54rrg _4ap3vuon _1dhy1c6w _9sns1wug",
|
|
32
35
|
border: "_191wglyw _16qs130s _1w6eia51 _scbpglyw",
|
|
33
36
|
scrollContainer: "_1reo1wug _18m91wug _4t3i1osq",
|
|
34
|
-
hidden: "_1e0cglyw"
|
|
37
|
+
hidden: "_1e0cglyw",
|
|
38
|
+
entering: "_y44v1s3l _1o51eoah",
|
|
39
|
+
exiting: "_y44vqhwn _1o51q7pw"
|
|
35
40
|
};
|
|
36
41
|
|
|
37
42
|
/**
|
|
@@ -58,6 +63,20 @@ export function Panel(_ref) {
|
|
|
58
63
|
var id = useLayoutId({
|
|
59
64
|
providedId: providedId
|
|
60
65
|
});
|
|
66
|
+
|
|
67
|
+
// useMotion is applied only when the `platform-dst-motion-uplift-panel` gate is enabled.
|
|
68
|
+
var _useMotion = useMotion({
|
|
69
|
+
onFinish: function onFinish(state) {
|
|
70
|
+
if (state === 'exiting' && defaultWidthRef.current === 0) {
|
|
71
|
+
// Set width to 0 as animation is complete
|
|
72
|
+
setWidth(0);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}),
|
|
76
|
+
state = _useMotion.state,
|
|
77
|
+
motionRef = _useMotion.ref,
|
|
78
|
+
reanimate = _useMotion.reanimate;
|
|
79
|
+
var isMotionUpliftEnabled = fg('platform-dst-motion-uplift-panel');
|
|
61
80
|
var defaultWidth = useSafeDefaultWidth({
|
|
62
81
|
defaultWidthProp: defaultWidthProp,
|
|
63
82
|
fallbackDefaultWidth: fallbackDefaultWidth,
|
|
@@ -84,6 +103,15 @@ export function Panel(_ref) {
|
|
|
84
103
|
// Used to track the previous value of the `defaultWidth` prop, for logging dev warnings when it changes.
|
|
85
104
|
var defaultWidthRef = useRef(defaultWidth);
|
|
86
105
|
|
|
106
|
+
// `mergeRefs` returns a new callback ref on every call, and combined with a new array literal
|
|
107
|
+
// this would cause React to detach/re-attach the ref on every render. Memoise it so the merged
|
|
108
|
+
// ref is stable across renders.
|
|
109
|
+
var mergedRef = useMemo(function () {
|
|
110
|
+
return isMotionUpliftEnabled ? mergeRefs([ref, motionRef]) : ref;
|
|
111
|
+
},
|
|
112
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
113
|
+
[isMotionUpliftEnabled, motionRef]);
|
|
114
|
+
|
|
87
115
|
/**
|
|
88
116
|
* TODO: Remove this useEffect once the `width: 0` usage is removed from Jira.
|
|
89
117
|
* It updates the width state based on changes to `defaultWidth`, as a temporary stopgap to support Jira's current usage.
|
|
@@ -93,13 +121,23 @@ export function Panel(_ref) {
|
|
|
93
121
|
if (defaultWidthRef.current === defaultWidth) {
|
|
94
122
|
return;
|
|
95
123
|
}
|
|
124
|
+
if (isMotionUpliftEnabled) {
|
|
125
|
+
if (defaultWidth === 0) {
|
|
126
|
+
reanimate(Reanimate.exit);
|
|
127
|
+
defaultWidthRef.current = defaultWidth;
|
|
128
|
+
// Set width to 0 once the exit animation is complete
|
|
129
|
+
return;
|
|
130
|
+
} else if (defaultWidthRef.current === 0) {
|
|
131
|
+
reanimate(Reanimate.enter);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
96
134
|
defaultWidthRef.current = defaultWidth;
|
|
97
135
|
setWidth(defaultWidth);
|
|
98
136
|
if (process.env.NODE_ENV !== 'production') {
|
|
99
137
|
// eslint-disable-next-line no-console
|
|
100
138
|
console.warn('Page Layout warning\n\n', 'The value of the `defaultWidth` prop on the `Panel` layout slot component has changed. This should not be changed after the component has been mounted.\n\n', 'In the future, changes to the `defaultWidth` prop will not be respected. It is only supported as a stopgap to enable migration from Nav3 to Nav4.\n\n');
|
|
101
139
|
}
|
|
102
|
-
}, [defaultWidth]);
|
|
140
|
+
}, [defaultWidth, isMotionUpliftEnabled, reanimate]);
|
|
103
141
|
var sideNavRef = useSideNavRef();
|
|
104
142
|
|
|
105
143
|
/**
|
|
@@ -143,11 +181,15 @@ export function Panel(_ref) {
|
|
|
143
181
|
return /*#__PURE__*/React.createElement("section", {
|
|
144
182
|
id: id,
|
|
145
183
|
"data-layout-slot": true,
|
|
146
|
-
"aria-label": label
|
|
147
|
-
|
|
184
|
+
"aria-label": label
|
|
185
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
|
|
186
|
+
,
|
|
187
|
+
className: ax([styles.root, !isMotionUpliftEnabled && defaultWidth === 0 && styles.hidden, hasBorder && styles.border, isMotionUpliftEnabled ?
|
|
188
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/local-cx-xcss, @compiled/local-cx-xcss
|
|
189
|
+
cx(xcss, state === 'entering' && styles.entering, state === 'exiting' && styles.exiting) : xcss]),
|
|
148
190
|
style: _defineProperty(_defineProperty({}, panelVar, panelVariableWidth), '--minWidth', "".concat(minWidth, "px")),
|
|
149
191
|
"data-testid": testId,
|
|
150
|
-
ref:
|
|
192
|
+
ref: mergedRef
|
|
151
193
|
}, dangerouslyHoistSlotSizes &&
|
|
152
194
|
/*#__PURE__*/
|
|
153
195
|
// ------ START UNSAFE STYLES ------
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/navigation-system",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.6.0",
|
|
4
4
|
"description": "The latest navigation system for Atlassian apps.",
|
|
5
5
|
"repository": "https://bitbucket.org/atlassian/atlassian-frontend-mirror",
|
|
6
6
|
"author": "Atlassian Pty Ltd",
|
|
@@ -62,6 +62,7 @@
|
|
|
62
62
|
"@atlaskit/icon": "^37.0.0",
|
|
63
63
|
"@atlaskit/layering": "^4.1.0",
|
|
64
64
|
"@atlaskit/logo": "^21.4.0",
|
|
65
|
+
"@atlaskit/motion": "^7.4.0",
|
|
65
66
|
"@atlaskit/platform-feature-flags": "^2.0.0",
|
|
66
67
|
"@atlaskit/platform-feature-flags-react": "^1.1.0",
|
|
67
68
|
"@atlaskit/popup": "^5.1.0",
|
|
@@ -109,7 +110,7 @@
|
|
|
109
110
|
"@atlaskit/textfield": "^9.1.0",
|
|
110
111
|
"@atlaskit/top-layer": "^1.8.0",
|
|
111
112
|
"@atlassian/feature-flags-test-utils": "^1.2.0",
|
|
112
|
-
"@atlassian/gemini": "^1.
|
|
113
|
+
"@atlassian/gemini": "^1.50.0",
|
|
113
114
|
"@atlassian/search-dialog": "^10.5.0",
|
|
114
115
|
"@atlassian/ssr-tests": "workspace:^",
|
|
115
116
|
"@atlassian/test-utils": "^1.1.0",
|
|
@@ -129,7 +130,8 @@
|
|
|
129
130
|
"dom-events": "use-bind-event-listener",
|
|
130
131
|
"design-tokens": [
|
|
131
132
|
"color",
|
|
132
|
-
"spacing"
|
|
133
|
+
"spacing",
|
|
134
|
+
"motion"
|
|
133
135
|
],
|
|
134
136
|
"deprecation": "no-deprecated-imports",
|
|
135
137
|
"imports": [
|
|
@@ -171,6 +173,10 @@
|
|
|
171
173
|
"type": "boolean",
|
|
172
174
|
"referenceOnly": true
|
|
173
175
|
},
|
|
176
|
+
"platform-dst-motion-uplift-panel": {
|
|
177
|
+
"type": "boolean",
|
|
178
|
+
"referenceOnly": true
|
|
179
|
+
},
|
|
174
180
|
"platform-ads-nav-fixed-height": {
|
|
175
181
|
"type": "boolean"
|
|
176
182
|
}
|