@atlaskit/media-viewer 54.10.5 → 54.11.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.
Files changed (51) hide show
  1. package/AGENTS.md +15 -1
  2. package/CHANGELOG.md +32 -0
  3. package/dist/cjs/DownloadButton.js +15 -1
  4. package/dist/cjs/analytics/ufoExperiences.js +1 -1
  5. package/dist/cjs/content.js +15 -9
  6. package/dist/cjs/download.js +21 -4
  7. package/dist/cjs/header.js +91 -40
  8. package/dist/cjs/inset-sidebar-header.js +108 -0
  9. package/dist/cjs/insetViewerContext.js +34 -2
  10. package/dist/cjs/list.js +9 -5
  11. package/dist/cjs/media-viewer.js +43 -9
  12. package/dist/cjs/styleWrappers.compiled.css +32 -3
  13. package/dist/cjs/styleWrappers.js +205 -135
  14. package/dist/cjs/viewer-icon-button.js +38 -0
  15. package/dist/cjs/zoomControls.js +59 -5
  16. package/dist/es2019/DownloadButton.js +16 -1
  17. package/dist/es2019/analytics/ufoExperiences.js +1 -1
  18. package/dist/es2019/content.js +10 -4
  19. package/dist/es2019/download.js +22 -4
  20. package/dist/es2019/header.js +76 -33
  21. package/dist/es2019/inset-sidebar-header.js +100 -0
  22. package/dist/es2019/insetViewerContext.js +30 -4
  23. package/dist/es2019/list.js +9 -5
  24. package/dist/es2019/media-viewer.js +41 -11
  25. package/dist/es2019/styleWrappers.compiled.css +32 -3
  26. package/dist/es2019/styleWrappers.js +117 -32
  27. package/dist/es2019/viewer-icon-button.js +26 -0
  28. package/dist/es2019/zoomControls.js +57 -2
  29. package/dist/esm/DownloadButton.js +15 -1
  30. package/dist/esm/analytics/ufoExperiences.js +1 -1
  31. package/dist/esm/content.js +15 -9
  32. package/dist/esm/download.js +21 -4
  33. package/dist/esm/header.js +91 -40
  34. package/dist/esm/inset-sidebar-header.js +99 -0
  35. package/dist/esm/insetViewerContext.js +34 -2
  36. package/dist/esm/list.js +9 -5
  37. package/dist/esm/media-viewer.js +45 -11
  38. package/dist/esm/styleWrappers.compiled.css +32 -3
  39. package/dist/esm/styleWrappers.js +205 -135
  40. package/dist/esm/viewer-icon-button.js +31 -0
  41. package/dist/esm/zoomControls.js +59 -5
  42. package/dist/types/content.d.ts +2 -4
  43. package/dist/types/download.d.ts +1 -1
  44. package/dist/types/header.d.ts +3 -1
  45. package/dist/types/inset-sidebar-header.d.ts +13 -0
  46. package/dist/types/insetViewerContext.d.ts +6 -0
  47. package/dist/types/list.d.ts +4 -2
  48. package/dist/types/styleWrappers.d.ts +10 -1
  49. package/dist/types/viewer-icon-button.d.ts +18 -0
  50. package/dist/types/zoomControls.d.ts +6 -3
  51. package/package.json +8 -6
@@ -1,5 +1,5 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import React, { useState, useLayoutEffect, useRef, useCallback } from 'react';
2
+ import React, { useState, useEffect, useLayoutEffect, useRef, useCallback } from 'react';
3
3
  import { start } from 'perf-marks';
4
4
  import FocusLock from 'react-focus-lock';
5
5
  import { IntlProvider, injectIntl } from 'react-intl';
@@ -14,9 +14,10 @@ import { createClosedEvent } from './analytics/events/ui/closed';
14
14
  import { fireAnalytics } from './analytics/fireAnalytics';
15
15
  import { mediaViewerPopupClass } from './classnames';
16
16
  import { Content } from './content';
17
+ import { InsetSidebarHeader } from './inset-sidebar-header';
17
18
  import { InsetViewerProvider } from './insetViewerContext';
18
19
  import { List } from './list';
19
- import { Blanket, BlanketCloseButton, InsetViewerLayout, InsetViewerShell, MediaColumn, MediaStage, SidebarWrapper } from './styleWrappers';
20
+ import { Blanket, BlanketCloseButton, InsetViewerLayout, InsetViewerShell, MediaColumn, MediaFooterBar, MediaStage, SidebarColumn, SidebarWrapper } from './styleWrappers';
20
21
  const getIdentifierId = identifier => isFileIdentifier(identifier) ? identifier.id : undefined;
21
22
  const MediaViewerComponent = ({
22
23
  featureFlags,
@@ -88,6 +89,7 @@ const MediaViewerComponent = ({
88
89
  start('MediaViewer.SessionDuration');
89
90
  }, []);
90
91
  const defaultSelectedItem = selectedItem || items[0];
92
+ const currentIdentifier = selectedIdentifier || defaultSelectedItem;
91
93
 
92
94
  // Toggling the sidebar: opening is unconditional; closing goes through the
93
95
  // optional onSidebarClose interceptor.
@@ -99,6 +101,24 @@ const MediaViewerComponent = ({
99
101
  }
100
102
  }, [isSidebarVisible, requestSidebarClose, setIsSidebarVisible]);
101
103
 
104
+ // In inset mode the sidebar toggle is in the media header while the sidebar is closed and in the
105
+ // sidebar's own header while it's open, so a toggle click unmounts the focused button. Move focus
106
+ // to the toggle that's now showing, only after a toggle click.
107
+ const showSidebarButtonRef = useRef(null);
108
+ const hideSidebarButtonRef = useRef(null);
109
+ const shouldFocusSidebarToggle = useRef(false);
110
+ useEffect(() => {
111
+ if (shouldFocusSidebarToggle.current) {
112
+ var _current;
113
+ shouldFocusSidebarToggle.current = false;
114
+ (_current = (isSidebarVisible ? hideSidebarButtonRef : showSidebarButtonRef).current) === null || _current === void 0 ? void 0 : _current.focus();
115
+ }
116
+ }, [isSidebarVisible]);
117
+ const onInsetSidebarButtonClick = useCallback(() => {
118
+ shouldFocusSidebarToggle.current = true;
119
+ toggleSidebar();
120
+ }, [toggleSidebar]);
121
+
102
122
  // The full modal close — used by ESC, the close button, and click-outside.
103
123
  // Always passed through requestPreviewClose so the consumer can intercept.
104
124
  const handlePreviewClose = useCallback(reason => {
@@ -114,8 +134,7 @@ const MediaViewerComponent = ({
114
134
  // in `items` with the current selected identifier's index. Falls back to
115
135
  // 'next' if we can't determine direction (e.g. random jump from a list).
116
136
  const computeNavigationDirection = useCallback(nextIdentifier => {
117
- const current = selectedIdentifier || defaultSelectedItem;
118
- const currentId = current && getIdentifierId(current);
137
+ const currentId = currentIdentifier && getIdentifierId(currentIdentifier);
119
138
  const nextId = getIdentifierId(nextIdentifier);
120
139
  if (!currentId || !nextId) {
121
140
  return 'next';
@@ -126,13 +145,12 @@ const MediaViewerComponent = ({
126
145
  return 'next';
127
146
  }
128
147
  return nextIndex < currentIndex ? 'prev' : 'next';
129
- }, [items, selectedIdentifier, defaultSelectedItem]);
148
+ }, [items, currentIdentifier]);
130
149
  const renderSidebar = () => {
131
- const sidebarSelectedIdentifier = selectedIdentifier || defaultSelectedItem;
132
- if (sidebarSelectedIdentifier && isSidebarVisible && extensions !== null && extensions !== void 0 && extensions.sidebar) {
150
+ if (currentIdentifier && isSidebarVisible && extensions !== null && extensions !== void 0 && extensions.sidebar) {
133
151
  return /*#__PURE__*/React.createElement(SidebarWrapper, {
134
152
  "data-testid": "media-viewer-sidebar-content"
135
- }, extensions.sidebar.renderer(sidebarSelectedIdentifier, {
153
+ }, extensions.sidebar.renderer(currentIdentifier, {
136
154
  // `close` is what the sidebar renderer calls to dismiss itself.
137
155
  // Route it through the same interceptor so confluence's
138
156
  // unsaved-comment guard runs here too.
@@ -168,7 +186,7 @@ const MediaViewerComponent = ({
168
186
  handlePreviewClose(reason);
169
187
  }
170
188
  }, /*#__PURE__*/React.createElement(List, {
171
- defaultSelectedItem: defaultSelectedItem || items[0],
189
+ defaultSelectedItem: defaultSelectedItem,
172
190
  items: items
173
191
  // Note: `onClose` here is what the prev/next list passes down for
174
192
  // "close-the-modal" actions. Route through interceptor too.
@@ -191,13 +209,25 @@ const MediaViewerComponent = ({
191
209
  const direction = computeNavigationDirection(identifier);
192
210
  requestNavigation(direction, commit);
193
211
  },
194
- onSidebarButtonClick: toggleSidebar,
212
+ onSidebarButtonClick: isInsetViewer ? onInsetSidebarButtonClick : toggleSidebar,
195
213
  isSidebarVisible: isSidebarVisible,
214
+ onHeaderClose: isInsetViewer ? () => handlePreviewClose('button') : undefined,
215
+ sidebarToggleRef: isInsetViewer ? showSidebarButtonRef : undefined,
196
216
  contextId: contextId,
197
217
  featureFlags: featureFlags,
198
218
  viewerOptions: viewerOptions,
199
219
  fallbackMediaNameFetcher: fallbackMediaNameFetcher
200
- })))), renderSidebar())))));
220
+ }))), isInsetViewer ? /*#__PURE__*/React.createElement(MediaFooterBar, null) : null), isInsetViewer ? /*#__PURE__*/React.createElement(SidebarColumn, {
221
+ isOpen: isSidebarVisible
222
+ }, currentIdentifier && extensions !== null && extensions !== void 0 && extensions.sidebar ? /*#__PURE__*/React.createElement(InsetSidebarHeader, {
223
+ identifier: currentIdentifier,
224
+ title: extensions.sidebar.title,
225
+ label: extensions.sidebar.label,
226
+ onHideSidebar: onInsetSidebarButtonClick,
227
+ onClose: () => handlePreviewClose('button'),
228
+ hideSidebarButtonRef: hideSidebarButtonRef,
229
+ fallbackMediaNameFetcher: fallbackMediaNameFetcher
230
+ }) : null, renderSidebar()) : renderSidebar())))));
201
231
  return intl ? content : /*#__PURE__*/React.createElement(IntlProvider, {
202
232
  locale: "en"
203
233
  }, content);
@@ -2,13 +2,16 @@
2
2
  ._151kfhey._151kfhey h1{font:var(--ds-font-body,normal 400 14px/20px "Atlassian Sans",ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI",Ubuntu,"Helvetica Neue",sans-serif)}
3
3
  ._2rkofajl{border-radius:var(--ds-radius-small,3px)}
4
4
  ._2rkopb1k{border-radius:var(--ds-radius-xlarge,9pt)}
5
+ ._zulp1b66{gap:var(--ds-space-050,4px)}
5
6
  ._zulpu2gc{gap:var(--ds-space-100,8px)}
6
7
  ._189eidpf{border-width:0}
7
- ._1ii7cs5v{grid-row:2}
8
+ ._1ii7kb7n{grid-row:1}
9
+ ._yyhycs5v{grid-column:2}
8
10
  ._yyhykb7n{grid-column:1}._11pt15ty svg{filter:drop-shadow(0 1px 1px rgb(9 30 66/25%)) drop-shadow(0 0 1px rgb(9 30 66/31%))}
9
11
  ._152tidpf{inset-block-start:0}
10
12
  ._154i1ejb{top:var(--ds-space-300,24px)}
11
13
  ._154i1ssb{top:50%}
14
+ ._154i1wug{top:auto}
12
15
  ._154iidpf{top:0}
13
16
  ._16jlidpf{flex-grow:0}
14
17
  ._16jlkb7n{flex-grow:1}
@@ -16,6 +19,8 @@
16
19
  ._18ew1wq8._18ew1wq8 h1{font-weight:var(--ds-font-weight-medium,500)}
17
20
  ._18m915vq{overflow-y:hidden}
18
21
  ._18m91wug{overflow-y:auto}
22
+ ._18m9ewfl{overflow-y:visible}
23
+ ._18u01wug{margin-left:auto}
19
24
  ._19bv1ejb{padding-left:var(--ds-space-300,24px)}
20
25
  ._19bv1mjv{padding-left:300px}
21
26
  ._19bvidpf{padding-left:0}
@@ -25,6 +30,8 @@
25
30
  ._19pk1ejb{margin-top:var(--ds-space-300,24px)}
26
31
  ._1bah1h6o{justify-content:center}
27
32
  ._1bah1y6m{justify-content:flex-start}
33
+ ._1bah1yb4{justify-content:space-between}
34
+ ._1bahesu3{justify-content:flex-end}
28
35
  ._1bahusic{justify-content:right}
29
36
  ._1bsb1ber{width:26pc}
30
37
  ._1bsb1kdj{width:25pc}
@@ -32,22 +39,30 @@
32
39
  ._1bsb1tcg{width:24px}
33
40
  ._1bsbauwl{width:100vw}
34
41
  ._1bsbyazj{width:calc(100% - 26pc)}
42
+ ._1bsbze3t{width:var(--ds-space-0,0)}
35
43
  ._1bto1l2s{text-overflow:ellipsis}
44
+ ._1doce4h9{border-bottom-width:var(--ds-border-width,1px)}
36
45
  ._1e02idpf{inset-inline-start:0}
37
46
  ._1e0c11p5{display:grid}
38
47
  ._1e0c1o8l{display:inline-block}
39
48
  ._1e0c1txw{display:flex}
40
49
  ._1ghp1kxc video{max-height:100vh}
50
+ ._1il9nqa1{border-bottom-style:solid}
41
51
  ._1itkdlpg{background-image:linear-gradient(0deg,#101214,rgba(14,22,36,0))}
42
52
  ._1jyy1poe._1jyy1poe h1{color:#c7d1db}
53
+ ._1jyyazsu._1jyyazsu h1{color:var(--ds-text-subtle,#505258)}
43
54
  ._1kemd8h4{image-rendering:pixelated}
44
55
  ._1l1f1n9t .mvng-hide-controls{position:fixed}
45
56
  ._1ltv1ejb{left:var(--ds-space-300,24px)}
46
57
  ._1ltv1mjv{left:300px}
47
58
  ._1ltvidpf{left:0}
59
+ ._1o3i1l7x{border-bottom-color:var(--ds-border,#0b120e24)}
48
60
  ._1o9zidpf{flex-shrink:0}
49
61
  ._1o9zkb7n{flex-shrink:1}
62
+ ._1oec1mzy{transition-duration:var(--ds-duration-long,.25s)}
63
+ ._1oeci9qs{transition-duration:var(--ds-duration-medium,.2s)}
50
64
  ._1p351l2s._1p351l2s h1{text-overflow:ellipsis}
65
+ ._1p3lnqa1{border-left-style:solid}
51
66
  ._1p6zkb7n video{flex-grow:1}
52
67
  ._1p8j15vq._1p8j15vq h1{overflow-y:hidden}
53
68
  ._1pby1qpw{z-index:520}
@@ -56,19 +71,24 @@
56
71
  ._1pbyuou7{z-index:522}
57
72
  ._1reo15vq{overflow-x:hidden}
58
73
  ._1reo1wug{overflow-x:auto}
74
+ ._1reoewfl{overflow-x:visible}
59
75
  ._1tkeidpf{min-height:0}
76
+ ._1tkexy5q{min-height:var(--ds-space-400,2pc)}
77
+ ._1ul91kdj{min-width:25pc}
60
78
  ._1ul9idpf{min-width:0}
61
79
  ._1ul9uuw1{min-width:200px}
62
80
  ._1vgl1rj4 >*{pointer-events:all}
63
81
  ._1vnlkb7n video{flex-shrink:1}
64
82
  ._1xi21ejb{right:var(--ds-space-300,24px)}
83
+ ._1xi21wug{right:auto}
65
84
  ._1xi2idpf{right:0}
66
85
  ._1xi2v47k{right:var(--ds-space-250,20px)}
67
86
  ._1y2kauwl video{width:100vw}
68
87
  ._20ka1poe._20ka1poe button:active svg{color:#c7d1db}
69
88
  ._2hwx1jfw{margin-right:var(--ds-space-500,40px)}
89
+ ._2hwxidpf{margin-right:0}
70
90
  ._2lx21bp4{flex-direction:column}
71
- ._2z051h8r{grid-template-rows:var(--ds-space-800,4pc) minmax(0,1fr)}
91
+ ._2z05i47z{grid-template-rows:minmax(0,1fr)}
72
92
  ._4cvr1fhb{align-items:stretch}
73
93
  ._4cvr1h6o{align-items:center}
74
94
  ._4cvresu3{align-items:flex-end}
@@ -76,8 +96,12 @@
76
96
  ._4t3i1kxc{height:100vh}
77
97
  ._4t3i1osq{height:100%}
78
98
  ._4t3i1uc6{height:98px}
99
+ ._4t3ixncg{height:var(--ds-space-800,4pc)}
100
+ ._4t3ixy5q{height:var(--ds-space-400,2pc)}
79
101
  ._4t3izwfg{height:2pc}
80
102
  ._5ralzm06{object-fit:scale-down}
103
+ ._5wra1l7x{border-left-color:var(--ds-border,#0b120e24)}
104
+ ._6fl4v1ec{transition-timing-function:var(--ds-easing-out-bold,cubic-bezier(0,.4,0,1))}
81
105
  ._7dir1j9a button{background-color:var(--ds-background-input,#fff)}
82
106
  ._80om73ad{cursor:default}
83
107
  ._80omtlke{cursor:pointer}
@@ -94,12 +118,14 @@
94
118
  ._ca0q1azu{padding-top:var(--ds-space-100,8px) var(--ds-space-300,24px)}
95
119
  ._ca0q1ejb{padding-top:var(--ds-space-300,24px)}
96
120
  ._ca0qidpf{padding-top:0}
121
+ ._ca0qpxbi{padding-top:var(--ds-space-200,1pc)}
97
122
  ._ca0qv47k{padding-top:var(--ds-space-250,20px)}
98
123
  ._ca0qze3t{padding-top:var(--ds-space-0,0)}
99
124
  ._di7o9txx._di7o9txx button:hover svg{color:#b6c2cf}
100
125
  ._i0dl1wug{flex-basis:auto}
101
126
  ._i0dlf1ug{flex-basis:0%}
102
127
  ._k48p1wq8{font-weight:var(--ds-font-weight-medium,500)}
128
+ ._k8m01ea5{transition-property:width}
103
129
  ._kqsw1n9t{position:fixed}
104
130
  ._kqswh2mm{position:relative}
105
131
  ._kqswstnw{position:absolute}
@@ -107,6 +133,7 @@
107
133
  ._lcxvglyw{pointer-events:none}
108
134
  ._n3td1ejb{padding-bottom:var(--ds-space-300,24px)}
109
135
  ._n3tdidpf{padding-bottom:0}
136
+ ._n3tdpxbi{padding-bottom:var(--ds-space-200,1pc)}
110
137
  ._n3tdu2gc{padding-bottom:var(--ds-space-100,8px)}
111
138
  ._n3tdv47k{padding-bottom:var(--ds-space-250,20px)}
112
139
  ._n3tdze3t{padding-bottom:var(--ds-space-0,0)}
@@ -121,6 +148,7 @@
121
148
  ._s7n4nkob{vertical-align:middle}
122
149
  ._syaz1poe{color:#c7d1db}
123
150
  ._syazi7uo{color:var(--ds-text,#292a2e)}
151
+ ._t6vde4h9{border-left-width:var(--ds-border-width,1px)}
124
152
  ._t9ec1i34{transform:translateY(-50%)}
125
153
  ._tzy41w01{opacity:.85}
126
154
  ._u5f31ejb{padding-right:var(--ds-space-300,24px)}
@@ -140,4 +168,5 @@
140
168
  ._zcqx1osq p{line-height:100%}
141
169
  ._4pkp1fjg button:hover{color:#161a1d!important}
142
170
  ._6pupl4ek button:hover{background-color:var(--ds-background-input-hovered,#f8f8f8)}
143
- ._1sfy1fjg button:active{color:#161a1d!important}
171
+ ._1sfy1fjg button:active{color:#161a1d!important}
172
+ @media (prefers-reduced-motion:reduce){._156y147i{transition-duration:var(--ds-duration-instant,0ms)}}
@@ -9,19 +9,37 @@ import { forwardRef, useMemo } from 'react';
9
9
  import { TouchScrollable } from 'react-scrolllock';
10
10
  import { useMergeRefs } from 'use-callback-ref';
11
11
  import Heading from '@atlaskit/heading/heading';
12
+ import Motion from '@atlaskit/motion/entering/motion';
13
+ import ExitingPersistence from '@atlaskit/motion/exiting-persistence';
12
14
  // eslint-disable-next-line @atlaskit/design-system/no-emotion-primitives -- to be migrated to @atlaskit/primitives/compiled – go/akcss
13
15
  import { Box, xcss } from '@atlaskit/primitives';
14
- import { useIsInsetViewer } from './insetViewerContext';
16
+ import { useIsInsetViewer, useSetMediaFooterControls } from './insetViewerContext';
15
17
  const INSET_HEADER_HEIGHT = "var(--ds-space-800, 64px)";
18
+ const INSET_SIDEBAR_WIDTH = '400px';
19
+
20
+ // Uses the same timing as the content's `motion.panel.enter`/`exit` slide, so they move together.
21
+ const insetSidebarWidthTransitionStyles = null;
22
+ const insetSidebarSlotStyles = null;
23
+ const insetSidebarSlotOpenStyles = null;
24
+ const insetSidebarSlotClosedStyles = null;
25
+
26
+ // Keeps the content at full width while the slot's width animates.
27
+ const insetSidebarSlotContentStyles = null;
16
28
  const blanketStyles = null;
17
29
  const insetViewerBlanketStyles = null;
18
30
  const blanketCloseButtonStyles = null;
19
31
  const insetViewerShellStyles = null;
20
32
  const insetViewerLayoutStyles = null;
33
+ const insetViewerSidebarColumnStyles = null;
21
34
  const headerWrapperStyles = null;
22
35
  const archiveHeaderWrapperStyles = null;
36
+ const insetViewerHeaderWrapperStyles = null;
23
37
  const insetViewerMediaColumnStyles = null;
38
+ const insetViewerSidebarHeaderStyles = null;
39
+ const insetViewerSidebarHeaderContentStyles = null;
40
+ const insetViewerSidebarHeaderTitleStyles = null;
24
41
  const insetViewerMediaStageStyles = null;
42
+ const insetViewerMediaFooterBarStyles = null;
25
43
  const listWrapperStyles = null;
26
44
  const insetViewerListWrapperStyles = null;
27
45
  const itemStageStyles = null;
@@ -31,8 +49,11 @@ const contentWrapperStyles = null;
31
49
  const contentWrapperStyleWithSideBar = null;
32
50
  const insetViewerContentWrapperStyles = null;
33
51
  const zoomWrapperStyles = null;
52
+ const insetViewerZoomWrapperStyles = null;
34
53
  const zoomCenterControlsStyles = null;
35
54
  const zoomRightControlsStyles = null;
55
+ const insetViewerZoomCenterControlsStyles = null;
56
+ const insetViewerZoomRightControlsStyles = null;
36
57
  const zoomLevelIndicatorStyles = null;
37
58
  const hdIconGroupWrapperStyles = null;
38
59
  const errorMessageWrapperStyles = null;
@@ -50,6 +71,7 @@ const leftWrapperStyles = null;
50
71
  const leftWrapperStylesWithSideBar = null;
51
72
  const rightWrapperStyles = null;
52
73
  const headerStyles = null;
74
+ const insetViewerHeaderStyles = null;
53
75
  const headerStyleWithSideBar = null;
54
76
  const leftHeaderStyles = null;
55
77
  const imageWrapperStyles = null;
@@ -59,6 +81,7 @@ const pixelatedImgStyles = null;
59
81
  const medatadataTextWrapperStyles = null;
60
82
  const metadataWrapperStyles = null;
61
83
  const metadataFileNameStyles = null;
84
+ const insetViewerMetadataFileNameStyles = null;
62
85
  const metadataSubTextStyles = null;
63
86
  const metadataIconWrapperStyles = xcss({
64
87
  paddingTop: 'space.050',
@@ -68,6 +91,7 @@ const metadataIconWrapperStyles = xcss({
68
91
  // oxlint-disable-next-line eslint/no-redeclare
69
92
 
70
93
  const rightHeaderStyles = null;
94
+ const insetViewerRightHeaderStyles = null;
71
95
  const customAudioPlayerWrapperStyles = null;
72
96
  const audioPlayerStyles = null;
73
97
  const audioStyles = null;
@@ -76,6 +100,7 @@ const defaultCoverWrapperStyles = null;
76
100
  const downloadButtonWrapperStyles = null;
77
101
  const customVideoPlayerWrapperStyles = null;
78
102
  const sidebarWrapperStyles = null;
103
+ const insetViewerSidebarWrapperStyles = null;
79
104
  const spinnerWrapperStyles = null;
80
105
  const formattedMessageWrapperStyles = null;
81
106
  // We are keeping this data-testid since JIRA is still using it in their codebase to perform checks. Before removing this, we need to ensure this 'media-viewer-popup' test id is not being used anywhere else in other codebases
@@ -114,29 +139,67 @@ export const InsetViewerShell = ({
114
139
  export const InsetViewerLayout = ({
115
140
  children
116
141
  }) => /*#__PURE__*/React.createElement("div", {
117
- className: ax(["_1e0c11p5 _yv0ehpfy _2z051h8r _1bsb1osq _4t3i1osq _1tkeidpf"])
142
+ className: ax(["_1e0c11p5 _yv0ehpfy _2z05i47z _1bsb1osq _4t3i1osq _1tkeidpf"])
118
143
  }, children);
144
+ // The sidebar's header row and body open and close as one element, so they share one width
145
+ // animation and one enter/exit motion.
146
+ export const SidebarColumn = ({
147
+ children,
148
+ isOpen
149
+ }) => /*#__PURE__*/React.createElement("div", {
150
+ "aria-hidden": !isOpen,
151
+ "data-testid": "media-viewer-sidebar-column",
152
+ className: ax(["_1reo15vq _18m915vq _1e0c1txw _1bahesu3 _1bsbze3t _1ul9idpf _vchhusvi", "_yyhycs5v _1ii7kb7n _1tkeidpf _4t3i1osq", "_k8m01ea5 _6fl4v1ec _156y147i", isOpen && "_1bsb1kdj _1oec1mzy", !isOpen && "_lcxvglyw _1oeci9qs"])
153
+ }, /*#__PURE__*/React.createElement(ExitingPersistence, null, isOpen ? /*#__PURE__*/React.createElement(Motion, {
154
+ enteringAnimation: "var(--ds-panel-enter, 250ms cubic-bezier(0, 0.4, 0, 1) SlideIn100PercentRight)",
155
+ exitingAnimation: "var(--ds-panel-exit, 200ms cubic-bezier(0, 0.4, 0, 1) SlideOut100PercentRight)"
156
+ }, /*#__PURE__*/React.createElement("div", {
157
+ className: ax(["_1bsb1kdj _1ul91kdj _4t3i1osq _1tkeidpf _1e0c1txw _2lx21bp4 _vchhusvi"])
158
+ }, children)) : null));
159
+ export const InsetSidebarHeaderRow = ({
160
+ children,
161
+ title
162
+ }) => /*#__PURE__*/React.createElement("div", {
163
+ "data-testid": "media-viewer-sidebar-header",
164
+ className: ax(["_1o9zidpf _4t3ixncg _bfhk1bhr _t6vde4h9 _1p3lnqa1 _5wra1l7x _1doce4h9 _1il9nqa1 _1o3i1l7x"])
165
+ }, /*#__PURE__*/React.createElement("div", {
166
+ className: ax(["_zulpu2gc _4t3i1osq _1e0c1txw _4cvr1h6o _1bah1yb4 _ca0qpxbi _u5f31ejb _n3tdpxbi _19bv1ejb _vchhusvi"])
167
+ }, /*#__PURE__*/React.createElement("div", {
168
+ className: ax(["_16jlkb7n _1o9zkb7n _i0dlf1ug _1reo15vq _18m915vq _1ul9idpf"])
169
+ }, title ? /*#__PURE__*/React.createElement(Heading, {
170
+ as: "h2",
171
+ size: "small"
172
+ }, title) : null), children));
119
173
  export const HeaderWrapper = ({
120
174
  className,
121
175
  children,
122
176
  isArchiveSideBarVisible
123
177
  }) => {
178
+ const isInsetViewer = useIsInsetViewer();
124
179
  return /*#__PURE__*/React.createElement("div", {
125
180
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
126
- className: ax(["_11q75a80 _kqswstnw _154iidpf _1ltvidpf _1bsb1osq _4t3i1uc6 _tzy41w01 _ouxlidpf _syaz1poe _k48p1wq8 _ca0q1ejb _n3td1ejb _19bv1ejb _u5f31ejb _vchhusvi _lcxvglyw _1pby3tda", isArchiveSideBarVisible && "_ouxl1klg", className])
181
+ className: ax([!isInsetViewer && "_11q75a80 _kqswstnw _154iidpf _1ltvidpf _1bsb1osq _4t3i1uc6 _tzy41w01 _ouxlidpf _syaz1poe _k48p1wq8 _ca0q1ejb _n3td1ejb _19bv1ejb _u5f31ejb _vchhusvi _lcxvglyw _1pby3tda", !isInsetViewer && isArchiveSideBarVisible && "_ouxl1klg", isInsetViewer && "_kqswh2mm _1bsb1osq _4t3ixncg _1o9zidpf _syazi7uo _lcxvglyw _1pbykb7n _1e0c1txw _4cvr1h6o _ca0qpxbi _u5f31ejb _n3tdpxbi _19bv1ejb _vchhusvi", className])
127
182
  }, children);
128
183
  };
129
184
  HeaderWrapper.displayName = 'HeaderWrapper';
130
185
  export const MediaColumn = ({
131
186
  children
132
187
  }) => /*#__PURE__*/React.createElement("div", {
133
- className: ax(["_1reo15vq _18m915vq _yyhykb7n _1ii7cs5v _1e0c1txw _2lx21bp4 _4t3i1osq _1ul9idpf _1tkeidpf"])
188
+ className: ax(["_1reo15vq _18m915vq _yyhykb7n _1ii7kb7n _1e0c1txw _2lx21bp4 _4t3i1osq _1ul9idpf _1tkeidpf"])
134
189
  }, children);
135
190
  export const MediaStage = ({
136
191
  children
137
192
  }) => /*#__PURE__*/React.createElement("div", {
138
193
  className: ax(["_16jlkb7n _1o9zkb7n _i0dlf1ug _1reo15vq _18m915vq _1ul9idpf _1tkeidpf _kqswh2mm"])
139
194
  }, children);
195
+ export const MediaFooterBar = () => {
196
+ const setMediaFooterControls = useSetMediaFooterControls();
197
+ return /*#__PURE__*/React.createElement("div", {
198
+ ref: setMediaFooterControls,
199
+ "data-testid": "media-viewer-media-footer",
200
+ className: ax(["_1reoewfl _18m9ewfl _1o9zidpf _4t3ixncg _vchhusvi _1bsb1osq _1e0c1txw _4cvr1h6o _1bah1h6o _ca0qpxbi _u5f31ejb _n3tdpxbi _19bv1ejb _kqswh2mm _lcxv1rj4"])
201
+ });
202
+ };
140
203
  export const ListWrapper = ({
141
204
  children
142
205
  }) => {
@@ -175,19 +238,29 @@ export const ContentWrapper = ({
175
238
  export const ZoomWrapper = ({
176
239
  className,
177
240
  children
178
- }) => /*#__PURE__*/React.createElement("div", {
179
- className: ax(["_1bsb1osq _kqswstnw _94n5idpf _4t3i1uc6 _1itkdlpg _tzy41w01 _lcxvglyw _vchhusvi _1e0c1txw _4cvresu3 _ca0q1azu _n3tdu2gc _u5f31ejb _19bv1ejb", className])
180
- }, children);
241
+ }) => {
242
+ const isInsetViewer = useIsInsetViewer();
243
+ return /*#__PURE__*/React.createElement("div", {
244
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
245
+ className: ax([!isInsetViewer && "_1bsb1osq _kqswstnw _94n5idpf _4t3i1uc6 _1itkdlpg _tzy41w01 _lcxvglyw _vchhusvi _1e0c1txw _4cvresu3 _ca0q1azu _n3tdu2gc _u5f31ejb _19bv1ejb", isInsetViewer && "_1bsb1osq _4t3i1osq _kqswh2mm _vchhusvi _1e0c1txw _4cvr1h6o _syazi7uo _lcxv1rj4", className])
246
+ }, children);
247
+ };
181
248
  export const ZoomCenterControls = ({
182
249
  children
183
- }) => /*#__PURE__*/React.createElement("div", {
184
- className: ax(["_zulpu2gc _1bsb1osq _1e0c1txw _1bah1h6o _1vgl1rj4"])
185
- }, children);
250
+ }) => {
251
+ const isInsetViewer = useIsInsetViewer();
252
+ return /*#__PURE__*/React.createElement("div", {
253
+ className: ax(["_zulpu2gc _1bsb1osq _1e0c1txw _1bah1h6o _1vgl1rj4", isInsetViewer && "_zulp1b66 _4cvr1h6o _4t3ixy5q"])
254
+ }, children);
255
+ };
186
256
  export const ZoomRightControls = ({
187
257
  children
188
- }) => /*#__PURE__*/React.createElement("div", {
189
- className: ax(["_zulpu2gc _kqswstnw _1xi21ejb _syaz1poe _lcxv1rj4 _1e0c1txw _1bahusic"])
190
- }, children);
258
+ }) => {
259
+ const isInsetViewer = useIsInsetViewer();
260
+ return /*#__PURE__*/React.createElement("div", {
261
+ className: ax(["_zulpu2gc _kqswstnw _1xi21ejb _syaz1poe _lcxv1rj4 _1e0c1txw _1bahusic", isInsetViewer && "_syazi7uo _1xi2idpf _154i1ssb _t9ec1i34"])
262
+ }, children);
263
+ };
191
264
  export const ZoomLevelIndicator = ({
192
265
  children
193
266
  }) => /*#__PURE__*/React.createElement("span", {
@@ -276,10 +349,13 @@ export const Header = ({
276
349
  children,
277
350
  isArchiveSideBarVisible,
278
351
  className
279
- }) => /*#__PURE__*/React.createElement("div", {
280
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
281
- className: ax(["_1e0c1txw _19bvidpf", isArchiveSideBarVisible && "_19bv1mjv", className])
282
- }, children);
352
+ }) => {
353
+ const isInsetViewer = useIsInsetViewer();
354
+ return /*#__PURE__*/React.createElement("div", {
355
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
356
+ className: ax(["_1e0c1txw _19bvidpf", isArchiveSideBarVisible && "_19bv1mjv", isInsetViewer && "_zulpu2gc _1bsb1osq _4cvr1h6o _1bah1yb4 _1tkexy5q _4t3ixy5q", className])
357
+ }, children);
358
+ };
283
359
  export const LeftHeader = ({
284
360
  children
285
361
  }) => /*#__PURE__*/React.createElement("div", {
@@ -358,14 +434,17 @@ export const MetadataWrapper = ({
358
434
  export const MetadataFileName = ({
359
435
  'data-testid': datatestId,
360
436
  children
361
- }) => /*#__PURE__*/React.createElement("div", {
362
- className: ax(["_8at415vq _1p8j15vq _151kfhey _qvww1osq _1p351l2s _8g8b1q9c _18ew1wq8 _1jyy1poe"])
363
- }, /*#__PURE__*/React.createElement(Heading, {
364
- as: "h1",
365
- size: "medium",
366
- id: "media.media-viewer.file.name",
367
- testId: datatestId
368
- }, children));
437
+ }) => {
438
+ const isInsetViewer = useIsInsetViewer();
439
+ return /*#__PURE__*/React.createElement("div", {
440
+ className: ax(["_8at415vq _1p8j15vq _151kfhey _qvww1osq _1p351l2s _8g8b1q9c _18ew1wq8 _1jyy1poe", isInsetViewer && "_1jyyazsu"])
441
+ }, /*#__PURE__*/React.createElement(Heading, {
442
+ as: "h1",
443
+ size: "medium",
444
+ id: "media.media-viewer.file.name",
445
+ testId: datatestId
446
+ }, children));
447
+ };
369
448
  export const MetadataSubText = ({
370
449
  'data-testid': datatestId,
371
450
  children
@@ -380,9 +459,12 @@ export const MetadataIconWrapper = ({
380
459
  }, children);
381
460
  export const RightHeader = ({
382
461
  children
383
- }) => /*#__PURE__*/React.createElement("div", {
384
- className: ax(["_y3gnusic _2hwx1jfw _1ul9uuw1 _1vgl1rj4"])
385
- }, children);
462
+ }) => {
463
+ const isInsetViewer = useIsInsetViewer();
464
+ return /*#__PURE__*/React.createElement("div", {
465
+ className: ax(["_y3gnusic _2hwx1jfw _1ul9uuw1 _1vgl1rj4", isInsetViewer && "_zulp1b66 _2hwxidpf _18u01wug _1ul9idpf _1o9zidpf _1e0c1txw _1bahesu3 _4cvr1h6o"])
466
+ }, children);
467
+ };
386
468
  export const CustomAudioPlayerWrapper = ({
387
469
  children
388
470
  }) => /*#__PURE__*/React.createElement("div", {
@@ -437,10 +519,13 @@ export const CustomVideoPlayerWrapper = ({
437
519
  export const SidebarWrapper = ({
438
520
  'data-testid': datatestId,
439
521
  children
440
- }) => /*#__PURE__*/React.createElement("div", {
441
- "data-testid": datatestId,
442
- className: ax(["_1reo15vq _18m91wug _154iidpf _1xi2idpf _1bsb1ber _4t3i1kxc _bfhkvuon _syazi7uo"])
443
- }, children);
522
+ }) => {
523
+ const isInsetViewer = useIsInsetViewer();
524
+ return /*#__PURE__*/React.createElement("div", {
525
+ "data-testid": datatestId,
526
+ className: ax(["_1reo15vq _18m91wug _154iidpf _1xi2idpf _1bsb1ber _4t3i1kxc _bfhkvuon _syazi7uo", isInsetViewer && "_16jlkb7n _1o9zkb7n _i0dlf1ug _1reo15vq _18m91wug _kqswh2mm _154i1wug _1xi21wug _1bsb1kdj _1ul91kdj _1tkeidpf _vchhusvi _bfhk1bhr _t6vde4h9 _1p3lnqa1 _5wra1l7x"])
527
+ }, children);
528
+ };
444
529
  export const SpinnerWrapper = ({
445
530
  children
446
531
  }) => /*#__PURE__*/React.createElement("div", {
@@ -0,0 +1,26 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import React from 'react';
3
+ import IconButton from '@atlaskit/button/icon/button';
4
+ export const ViewerIconButton = ({
5
+ onClick,
6
+ testId,
7
+ isDisabled,
8
+ isSelected,
9
+ label,
10
+ icon: Icon,
11
+ iconBefore,
12
+ buttonRef
13
+ }) => /*#__PURE__*/React.createElement(IconButton, {
14
+ ref: buttonRef,
15
+ appearance: "subtle",
16
+ label: label,
17
+ icon: Icon ? iconProps => /*#__PURE__*/React.createElement(Icon, _extends({}, iconProps, {
18
+ spacing: "spacious"
19
+ })) : () => iconBefore,
20
+ onClick: onClick,
21
+ isDisabled: isDisabled,
22
+ isSelected: isSelected,
23
+ isTooltipDisabled: false,
24
+ spacing: "default",
25
+ testId: testId
26
+ });
@@ -1,17 +1,25 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import React from 'react';
3
3
  import { Component } from 'react';
4
+ import { createPortal } from 'react-dom';
4
5
  import { injectIntl } from 'react-intl';
5
6
  import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
7
+ import Button from '@atlaskit/button/default/button';
8
+ import AddIcon from '@atlaskit/icon/core/add';
9
+ import MinusIcon from '@atlaskit/icon/core/minus';
6
10
  import ZoomInIcon from '@atlaskit/icon/core/zoom-in';
7
11
  import ZoomOutIcon from '@atlaskit/icon/core/zoom-out';
8
12
  import { hideControlsClassName } from '@atlaskit/media-ui/classNames';
9
13
  import MediaButton from '@atlaskit/media-ui/MediaButton';
10
14
  import { messages } from '@atlaskit/media-ui/messages';
15
+ import Tooltip from '@atlaskit/tooltip/Tooltip';
11
16
  import { createZoomInButtonClickEvent } from './analytics/events/ui/zoomInButtonClicked';
12
17
  import { createZoomOutButtonClickedEvent } from './analytics/events/ui/zoomOutButtonClicked';
13
18
  import { fireAnalytics } from './analytics/fireAnalytics';
19
+ import { ZoomLevel } from './domain/zoomLevel';
20
+ import { withInsetViewerFooter } from './insetViewerContext';
14
21
  import { ZoomWrapper, ZoomCenterControls, ZoomRightControls, ZoomLevelIndicator } from './styleWrappers';
22
+ import { ViewerIconButton } from './viewer-icon-button';
15
23
  export class ZoomControlsBase extends Component {
16
24
  constructor(...args) {
17
25
  super(...args);
@@ -39,6 +47,18 @@ export class ZoomControlsBase extends Component {
39
47
  onChange(zoom);
40
48
  }
41
49
  });
50
+ _defineProperty(this, "zoomToFit", () => {
51
+ const {
52
+ onResetZoom,
53
+ onChange,
54
+ zoomLevel
55
+ } = this.props;
56
+ if (onResetZoom) {
57
+ onResetZoom();
58
+ return;
59
+ }
60
+ onChange(new ZoomLevel(zoomLevel.initialValue));
61
+ });
42
62
  }
43
63
  render() {
44
64
  const {
@@ -46,8 +66,41 @@ export class ZoomControlsBase extends Component {
46
66
  intl: {
47
67
  formatMessage
48
68
  },
49
- children
69
+ children,
70
+ isInsetViewer,
71
+ mediaFooterControls
50
72
  } = this.props;
73
+ if (isInsetViewer) {
74
+ if (!mediaFooterControls) {
75
+ return null;
76
+ }
77
+ const zoomPercentage = `${Math.round(zoomLevel.value * 100)}%`;
78
+ return /*#__PURE__*/createPortal( /*#__PURE__*/React.createElement(ZoomWrapper, null, /*#__PURE__*/React.createElement(ZoomCenterControls, null, /*#__PURE__*/React.createElement(ViewerIconButton, {
79
+ isDisabled: !zoomLevel.canZoomOut,
80
+ onClick: this.zoomOut,
81
+ icon: MinusIcon,
82
+ label: formatMessage(messages.zoom_out)
83
+ }), /*#__PURE__*/React.createElement(Tooltip, {
84
+ content: formatMessage(messages.zoom_to_fit),
85
+ position: "top",
86
+ tag: "span"
87
+ }, /*#__PURE__*/React.createElement(Button, {
88
+ appearance: "subtle"
89
+ // Names the current zoom as well, since the label replaces the visible percentage.
90
+ ,
91
+ "aria-label": formatMessage(messages.zoom_to_fit_with_level, {
92
+ zoomLevel: zoomPercentage
93
+ }),
94
+ onClick: this.zoomToFit,
95
+ spacing: "default",
96
+ testId: "zoom-level-indicator"
97
+ }, zoomPercentage)), /*#__PURE__*/React.createElement(ViewerIconButton, {
98
+ isDisabled: !zoomLevel.canZoomIn,
99
+ onClick: this.zoomIn,
100
+ icon: AddIcon,
101
+ label: formatMessage(messages.zoom_in)
102
+ })), children ? /*#__PURE__*/React.createElement(ZoomRightControls, null, children) : null), mediaFooterControls);
103
+ }
51
104
  return (
52
105
  /*#__PURE__*/
53
106
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
@@ -75,4 +128,6 @@ export class ZoomControlsBase extends Component {
75
128
  }
76
129
 
77
130
  // @ts-ignore: [PIT-1685] Fails in post-office due to backwards incompatibility issue with React 18
78
- export const ZoomControls = withAnalyticsEvents({})(injectIntl(ZoomControlsBase));
131
+ export const ZoomControls = withAnalyticsEvents({})(injectIntl(withInsetViewerFooter(ZoomControlsBase), {
132
+ forwardRef: true
133
+ }));