@atlaskit/media-viewer 54.10.6 → 54.11.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 (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
@@ -8,17 +8,25 @@ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstruct
8
8
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
9
9
  import React from 'react';
10
10
  import { Component } from 'react';
11
+ import { createPortal } from 'react-dom';
11
12
  import { injectIntl } from 'react-intl';
12
13
  import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
14
+ import Button from '@atlaskit/button/default/button';
15
+ import AddIcon from '@atlaskit/icon/core/add';
16
+ import MinusIcon from '@atlaskit/icon/core/minus';
13
17
  import ZoomInIcon from '@atlaskit/icon/core/zoom-in';
14
18
  import ZoomOutIcon from '@atlaskit/icon/core/zoom-out';
15
19
  import { hideControlsClassName } from '@atlaskit/media-ui/classNames';
16
20
  import MediaButton from '@atlaskit/media-ui/MediaButton';
17
21
  import { messages } from '@atlaskit/media-ui/messages';
22
+ import Tooltip from '@atlaskit/tooltip/Tooltip';
18
23
  import { createZoomInButtonClickEvent } from './analytics/events/ui/zoomInButtonClicked';
19
24
  import { createZoomOutButtonClickedEvent } from './analytics/events/ui/zoomOutButtonClicked';
20
25
  import { fireAnalytics } from './analytics/fireAnalytics';
26
+ import { ZoomLevel } from './domain/zoomLevel';
27
+ import { withInsetViewerFooter } from './insetViewerContext';
21
28
  import { ZoomWrapper, ZoomCenterControls, ZoomRightControls, ZoomLevelIndicator } from './styleWrappers';
29
+ import { ViewerIconButton } from './viewer-icon-button';
22
30
  export var ZoomControlsBase = /*#__PURE__*/function (_Component) {
23
31
  function ZoomControlsBase() {
24
32
  var _this;
@@ -49,16 +57,60 @@ export var ZoomControlsBase = /*#__PURE__*/function (_Component) {
49
57
  onChange(zoom);
50
58
  }
51
59
  });
60
+ _defineProperty(_this, "zoomToFit", function () {
61
+ var _this$props3 = _this.props,
62
+ onResetZoom = _this$props3.onResetZoom,
63
+ onChange = _this$props3.onChange,
64
+ zoomLevel = _this$props3.zoomLevel;
65
+ if (onResetZoom) {
66
+ onResetZoom();
67
+ return;
68
+ }
69
+ onChange(new ZoomLevel(zoomLevel.initialValue));
70
+ });
52
71
  return _this;
53
72
  }
54
73
  _inherits(ZoomControlsBase, _Component);
55
74
  return _createClass(ZoomControlsBase, [{
56
75
  key: "render",
57
76
  value: function render() {
58
- var _this$props3 = this.props,
59
- zoomLevel = _this$props3.zoomLevel,
60
- formatMessage = _this$props3.intl.formatMessage,
61
- children = _this$props3.children;
77
+ var _this$props4 = this.props,
78
+ zoomLevel = _this$props4.zoomLevel,
79
+ formatMessage = _this$props4.intl.formatMessage,
80
+ children = _this$props4.children,
81
+ isInsetViewer = _this$props4.isInsetViewer,
82
+ mediaFooterControls = _this$props4.mediaFooterControls;
83
+ if (isInsetViewer) {
84
+ if (!mediaFooterControls) {
85
+ return null;
86
+ }
87
+ var zoomPercentage = "".concat(Math.round(zoomLevel.value * 100), "%");
88
+ return /*#__PURE__*/createPortal( /*#__PURE__*/React.createElement(ZoomWrapper, null, /*#__PURE__*/React.createElement(ZoomCenterControls, null, /*#__PURE__*/React.createElement(ViewerIconButton, {
89
+ isDisabled: !zoomLevel.canZoomOut,
90
+ onClick: this.zoomOut,
91
+ icon: MinusIcon,
92
+ label: formatMessage(messages.zoom_out)
93
+ }), /*#__PURE__*/React.createElement(Tooltip, {
94
+ content: formatMessage(messages.zoom_to_fit),
95
+ position: "top",
96
+ tag: "span"
97
+ }, /*#__PURE__*/React.createElement(Button, {
98
+ appearance: "subtle"
99
+ // Names the current zoom as well, since the label replaces the visible percentage.
100
+ ,
101
+ "aria-label": formatMessage(messages.zoom_to_fit_with_level, {
102
+ zoomLevel: zoomPercentage
103
+ }),
104
+ onClick: this.zoomToFit,
105
+ spacing: "default",
106
+ testId: "zoom-level-indicator"
107
+ }, zoomPercentage)), /*#__PURE__*/React.createElement(ViewerIconButton, {
108
+ isDisabled: !zoomLevel.canZoomIn,
109
+ onClick: this.zoomIn,
110
+ icon: AddIcon,
111
+ label: formatMessage(messages.zoom_in)
112
+ })), children ? /*#__PURE__*/React.createElement(ZoomRightControls, null, children) : null), mediaFooterControls);
113
+ }
62
114
  return (
63
115
  /*#__PURE__*/
64
116
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
@@ -87,4 +139,6 @@ export var ZoomControlsBase = /*#__PURE__*/function (_Component) {
87
139
  }(Component);
88
140
 
89
141
  // @ts-ignore: [PIT-1685] Fails in post-office due to backwards incompatibility issue with React 18
90
- export var ZoomControls = withAnalyticsEvents({})(injectIntl(ZoomControlsBase));
142
+ export var ZoomControls = withAnalyticsEvents({})(injectIntl(withInsetViewerFooter(ZoomControlsBase), {
143
+ forwardRef: true
144
+ }));
@@ -1,11 +1,9 @@
1
1
  import React from 'react';
2
- import { Component, type ReactElement } from 'react';
2
+ import { type ReactElement } from 'react';
3
3
  import type { WithShowControlMethodProp } from '@atlaskit/media-ui/types';
4
4
  export interface ContentProps {
5
5
  onClose?: () => void;
6
6
  children: ReactElement<WithShowControlMethodProp>;
7
7
  isSidebarVisible?: boolean;
8
8
  }
9
- export declare class Content extends Component<ContentProps> {
10
- render(): React.JSX.Element;
11
- }
9
+ export declare const Content: React.ForwardRefExoticComponent<ContentProps & React.RefAttributes<any>>;
@@ -1,2 +1,2 @@
1
1
  import React from 'react';
2
- export declare const DisabledToolbarDownloadButton: React.JSX.Element;
2
+ export declare const DisabledToolbarDownloadButton: () => React.JSX.Element;
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import { type Ref } from 'react';
2
3
  import { type WrappedComponentProps } from 'react-intl';
3
4
  import { type Identifier } from '@atlaskit/media-client';
4
5
  import { type MediaFeatureFlags, type MediaTraceContext } from '@atlaskit/media-common';
@@ -14,5 +15,6 @@ export type Props = {
14
15
  readonly isArchiveSideBarVisible?: boolean;
15
16
  traceContext: MediaTraceContext;
16
17
  readonly fallbackMediaNameFetcher?: (id: string) => Promise<string>;
18
+ readonly sidebarToggleRef?: Ref<HTMLButtonElement>;
17
19
  };
18
- export declare const Header: ({ isArchiveSideBarVisible, extensions, isSidebarVisible, onSidebarButtonClick, identifier, onClose, onSetArchiveSideBarVisible, traceContext, fallbackMediaNameFetcher, }: Props & WrappedComponentProps) => React.JSX.Element;
20
+ export declare const Header: ({ isArchiveSideBarVisible, extensions, isSidebarVisible, onSidebarButtonClick, identifier, onClose, onSetArchiveSideBarVisible, traceContext, fallbackMediaNameFetcher, sidebarToggleRef, intl: { formatMessage }, }: Props & WrappedComponentProps) => React.JSX.Element;
@@ -0,0 +1,13 @@
1
+ import React, { type ReactNode, type Ref } from 'react';
2
+ import { type Identifier } from '@atlaskit/media-client/identifier';
3
+ type InsetSidebarHeaderProps = {
4
+ identifier: Identifier;
5
+ title?: ReactNode;
6
+ label?: string;
7
+ onHideSidebar: () => void;
8
+ onClose: () => void;
9
+ hideSidebarButtonRef?: Ref<HTMLButtonElement>;
10
+ fallbackMediaNameFetcher?: (id: string) => Promise<string>;
11
+ };
12
+ export declare const InsetSidebarHeader: ({ identifier, title, label, onHideSidebar, onClose, hideSidebarButtonRef, fallbackMediaNameFetcher, }: InsetSidebarHeaderProps) => React.JSX.Element;
13
+ export {};
@@ -4,7 +4,13 @@ export declare const InsetViewerProvider: ({ isInsetViewer, children, }: {
4
4
  children: ReactNode;
5
5
  }) => React.JSX.Element;
6
6
  export declare const useIsInsetViewer: () => boolean;
7
+ export declare const useMediaFooterControls: () => HTMLElement | null;
8
+ export declare const useSetMediaFooterControls: () => ((element: HTMLElement | null) => void);
7
9
  export type WithInsetViewerProps = {
8
10
  isInsetViewer?: boolean;
9
11
  };
10
12
  export declare const withInsetViewer: <Props, Component>(WrappedComponent: (React.ComponentType<WithInsetViewerProps & Props> | React.ForwardRefExoticComponent<WithInsetViewerProps & Props>) & Component) => React.ForwardRefExoticComponent<React.PropsWithoutRef<JSX.LibraryManagedAttributes<Component, Omit<Props, keyof WithInsetViewerProps>>> & React.RefAttributes<any>>;
13
+ export type WithInsetViewerFooterProps = WithInsetViewerProps & {
14
+ mediaFooterControls?: HTMLElement | null;
15
+ };
16
+ export declare const withInsetViewerFooter: <Props, Component>(WrappedComponent: (React.ComponentType<WithInsetViewerFooterProps & Props> | React.ForwardRefExoticComponent<WithInsetViewerFooterProps & Props>) & Component) => React.ForwardRefExoticComponent<React.PropsWithoutRef<JSX.LibraryManagedAttributes<Component, Omit<Props, keyof WithInsetViewerFooterProps>>> & React.RefAttributes<any>>;
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { type Ref } from 'react';
2
2
  import { type Identifier } from '@atlaskit/media-client';
3
3
  import { type MediaFeatureFlags } from '@atlaskit/media-common';
4
4
  import type { WithShowControlMethodProp } from '@atlaskit/media-ui/types';
@@ -25,10 +25,12 @@ export type Props = Readonly<{
25
25
  featureFlags?: MediaFeatureFlags;
26
26
  viewerOptions?: ViewerOptionsProps;
27
27
  fallbackMediaNameFetcher?: (id: string) => Promise<string>;
28
+ onHeaderClose?: () => void;
29
+ sidebarToggleRef?: Ref<HTMLButtonElement>;
28
30
  } & WithShowControlMethodProp>;
29
31
  export type State = {
30
32
  selectedItem: Identifier;
31
33
  previewCount: number;
32
34
  isArchiveSideBarVisible: boolean;
33
35
  };
34
- export declare const List: ({ defaultSelectedItem, onClose, showControls, extensions, onSidebarButtonClick, contextId, featureFlags, isSidebarVisible, onNavigationChange, onNavigationRequest, items, viewerOptions, fallbackMediaNameFetcher, }: Props) => React.JSX.Element;
36
+ export declare const List: ({ defaultSelectedItem, onClose, showControls, extensions, onSidebarButtonClick, contextId, featureFlags, isSidebarVisible, onNavigationChange, onNavigationRequest, items, viewerOptions, fallbackMediaNameFetcher, onHeaderClose, sidebarToggleRef, }: Props) => React.JSX.Element;
@@ -11,7 +11,7 @@ type Children = {
11
11
  children: ReactNode;
12
12
  };
13
13
  type ClassName = {
14
- className: string;
14
+ className?: string;
15
15
  };
16
16
  type DataTestID = {
17
17
  'data-testid'?: string | undefined;
@@ -23,6 +23,14 @@ export declare const BlanketCloseButton: ({ onClick }: {
23
23
  }) => JSX.Element;
24
24
  export declare const InsetViewerShell: ({ children }: Children) => JSX.Element;
25
25
  export declare const InsetViewerLayout: ({ children }: Children) => JSX.Element;
26
+ type SidebarColumnProps = Children & {
27
+ isOpen: boolean;
28
+ };
29
+ export declare const SidebarColumn: ({ children, isOpen }: SidebarColumnProps) => JSX.Element;
30
+ type InsetSidebarHeaderRowProps = Children & {
31
+ title?: ReactNode;
32
+ };
33
+ export declare const InsetSidebarHeaderRow: ({ children, title, }: InsetSidebarHeaderRowProps) => JSX.Element;
26
34
  type HeaderWrapperProps = {
27
35
  isArchiveSideBarVisible: boolean;
28
36
  };
@@ -32,6 +40,7 @@ export declare const HeaderWrapper: {
32
40
  };
33
41
  export declare const MediaColumn: ({ children }: Children) => JSX.Element;
34
42
  export declare const MediaStage: ({ children }: Children) => JSX.Element;
43
+ export declare const MediaFooterBar: () => JSX.Element;
35
44
  export declare const ListWrapper: {
36
45
  ({ children }: Children): JSX.Element;
37
46
  displayName: string;
@@ -0,0 +1,18 @@
1
+ import React, { type MouseEvent, type ReactChild } from 'react';
2
+ import type UIAnalyticsEvent from '@atlaskit/analytics-next/UIAnalyticsEvent';
3
+ type IconComponent = React.ComponentType<{
4
+ label: string;
5
+ spacing?: 'none' | 'spacious' | 'compact';
6
+ }>;
7
+ type ViewerIconButtonProps = {
8
+ onClick?: (event: MouseEvent<HTMLElement>, analyticsEvent: UIAnalyticsEvent) => void;
9
+ testId?: string;
10
+ isDisabled?: boolean;
11
+ isSelected?: boolean;
12
+ label: string;
13
+ icon?: IconComponent;
14
+ iconBefore?: ReactChild;
15
+ buttonRef?: React.Ref<HTMLButtonElement>;
16
+ };
17
+ export declare const ViewerIconButton: ({ onClick, testId, isDisabled, isSelected, label, icon: Icon, iconBefore, buttonRef, }: ViewerIconButtonProps) => React.JSX.Element;
18
+ export {};
@@ -2,14 +2,17 @@ import React from 'react';
2
2
  import { Component } from 'react';
3
3
  import { type WrappedComponentProps } from 'react-intl';
4
4
  import { type WithAnalyticsEventsProps } from '@atlaskit/analytics-next/withAnalyticsEvents';
5
- import { type ZoomLevel } from './domain/zoomLevel';
5
+ import { ZoomLevel } from './domain/zoomLevel';
6
+ import { type WithInsetViewerFooterProps } from './insetViewerContext';
6
7
  export type ZoomControlsProps = React.PropsWithChildren<Readonly<{
7
8
  onChange: (newZoomLevel: ZoomLevel) => void;
9
+ onResetZoom?: () => void;
8
10
  zoomLevel: ZoomLevel;
9
11
  }> & WithAnalyticsEventsProps>;
10
- export declare class ZoomControlsBase extends Component<ZoomControlsProps & WrappedComponentProps, {}> {
12
+ export declare class ZoomControlsBase extends Component<ZoomControlsProps & WrappedComponentProps & WithInsetViewerFooterProps, {}> {
11
13
  zoomIn: () => void;
12
14
  zoomOut: () => void;
13
- render(): React.JSX.Element;
15
+ zoomToFit: () => void;
16
+ render(): React.JSX.Element | null;
14
17
  }
15
18
  export declare const ZoomControls: React.ComponentType<React.PropsWithChildren<ZoomControlsProps>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/media-viewer",
3
- "version": "54.10.6",
3
+ "version": "54.11.1",
4
4
  "description": "MediaViewer is Atlassian's powerful solution for viewing files on the web. It's both powerful and extendable yet easy-to-integrate",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -37,19 +37,20 @@
37
37
  "@atlaskit/button": "^25.4.0",
38
38
  "@atlaskit/code": "^20.0.0",
39
39
  "@atlaskit/css": "^1.1.0",
40
- "@atlaskit/form": "^18.0.0",
40
+ "@atlaskit/form": "^18.1.0",
41
41
  "@atlaskit/heading": "^8.0.0",
42
42
  "@atlaskit/icon": "^38.0.0",
43
43
  "@atlaskit/icon-file-type": "^8.3.0",
44
44
  "@atlaskit/icon-lab": "^7.11.0",
45
- "@atlaskit/media-client": "^39.0.0",
45
+ "@atlaskit/media-client": "^39.1.0",
46
46
  "@atlaskit/media-client-react": "^7.0.0",
47
47
  "@atlaskit/media-common": "^14.6.0",
48
48
  "@atlaskit/media-document-viewer": "^2.2.0",
49
49
  "@atlaskit/media-state": "^4.0.0",
50
50
  "@atlaskit/media-svg": "^4.0.0",
51
- "@atlaskit/media-ui": "^31.0.0",
51
+ "@atlaskit/media-ui": "^31.2.0",
52
52
  "@atlaskit/menu": "^11.0.0",
53
+ "@atlaskit/motion": "^9.3.0",
53
54
  "@atlaskit/platform-feature-experiments": "^0.3.0",
54
55
  "@atlaskit/platform-feature-flags": "^2.2.0",
55
56
  "@atlaskit/portal": "^7.0.0",
@@ -59,8 +60,8 @@
59
60
  "@atlaskit/spinner": "^20.4.0",
60
61
  "@atlaskit/textfield": "^10.2.0",
61
62
  "@atlaskit/theme": "^28.2.0",
62
- "@atlaskit/tmp-editor-statsig": "^221.0.0",
63
- "@atlaskit/tokens": "^20.1.0",
63
+ "@atlaskit/tmp-editor-statsig": "^222.0.0",
64
+ "@atlaskit/tokens": "^20.3.0",
64
65
  "@atlaskit/tooltip": "^24.4.0",
65
66
  "@atlaskit/ufo": "^2.0.0",
66
67
  "@babel/runtime": "^7.0.0",
@@ -85,6 +86,7 @@
85
86
  "peerDependencies": {
86
87
  "@emotion/react": "^11.7.1",
87
88
  "react": "^18.2.0",
89
+ "react-dom": "^18.2.0",
88
90
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
89
91
  },
90
92
  "devDependencies": {