mirador-dl-plugin 0.13.0 → 1.0.0-alpha.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.
@@ -1,190 +1,131 @@
1
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2
-
3
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
4
-
5
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
6
-
7
- import React, { Component } from 'react';
8
- import PropTypes from 'prop-types';
9
- import { withStyles } from '@material-ui/core/styles';
10
- import Button from '@material-ui/core/Button';
11
- import Dialog from '@material-ui/core/Dialog';
12
- import DialogActions from '@material-ui/core/DialogActions';
13
- import DialogTitle from '@material-ui/core/DialogTitle';
14
- import Typography from '@material-ui/core/Typography';
15
- import { getCanvasLabel, getVisibleCanvases, selectInfoResponse } from 'mirador/dist/es/src/state/selectors/canvases';
16
- import { getWindowViewType } from 'mirador/dist/es/src/state/selectors/windows';
17
- import { getManifestoInstance } from 'mirador/dist/es/src/state/selectors/manifests';
18
- import { getContainerId } from 'mirador/dist/es/src/state/selectors/config';
19
- import ScrollIndicatedDialogContent from 'mirador/dist/es/src/containers/ScrollIndicatedDialogContent';
20
- import CanvasDownloadLinks from './CanvasDownloadLinks';
1
+ import React, { useMemo } from 'react';
2
+ import { useTranslation } from 'react-i18next';
3
+ import { getCanvasLabel, getContainerId, getManifestoInstance, getVisibleCanvases, getWindowViewType, selectInfoResponse, ScrollIndicatedDialogContent } from 'mirador';
4
+ import Typography from '@mui/material/Typography';
5
+ import Dialog from '@mui/material/Dialog';
6
+ import DialogTitle from '@mui/material/DialogTitle';
7
+ import DialogActions from '@mui/material/DialogActions';
8
+ import Button from '@mui/material/Button';
21
9
  import ManifestDownloadLinks from './ManifestDownloadLinks';
22
-
10
+ import translations from './translations';
11
+ import CanvasDownloadLinks from './CanvasDownloadLinks';
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
23
13
  var mapDispatchToProps = function mapDispatchToProps(dispatch, _ref) {
24
14
  var windowId = _ref.windowId;
25
15
  return {
26
16
  closeDialog: function closeDialog() {
27
- return dispatch({ type: 'CLOSE_WINDOW_DIALOG', windowId: windowId });
17
+ return dispatch({
18
+ type: 'CLOSE_WINDOW_DIALOG',
19
+ windowId: windowId
20
+ });
28
21
  }
29
22
  };
30
23
  };
31
-
32
24
  var mapStateToProps = function mapStateToProps(state, _ref2) {
33
25
  var windowId = _ref2.windowId;
34
26
  return {
35
- canvases: getVisibleCanvases(state, { windowId: windowId }),
27
+ canvases: getVisibleCanvases(state, {
28
+ windowId: windowId
29
+ }),
36
30
  canvasLabel: function canvasLabel(canvasId) {
37
- return getCanvasLabel(state, { canvasId: canvasId, windowId: windowId });
31
+ return getCanvasLabel(state, {
32
+ canvasId: canvasId,
33
+ windowId: windowId
34
+ });
38
35
  },
39
36
  containerId: getContainerId(state),
40
37
  infoResponse: function infoResponse(canvasId) {
41
- return selectInfoResponse(state, { windowId: windowId, canvasId: canvasId }) || {};
38
+ return selectInfoResponse(state, {
39
+ windowId: windowId,
40
+ canvasId: canvasId
41
+ }) || {};
42
42
  },
43
- manifest: getManifestoInstance(state, { windowId: windowId }),
43
+ manifest: getManifestoInstance(state, {
44
+ windowId: windowId
45
+ }),
44
46
  restrictDownloadOnSizeDefinition: state.config.miradorDownloadPlugin && state.config.miradorDownloadPlugin.restrictDownloadOnSizeDefinition,
45
47
  open: state.windowDialogs[windowId] && state.windowDialogs[windowId].openDialog === 'download',
46
- viewType: getWindowViewType(state, { windowId: windowId })
48
+ viewType: getWindowViewType(state, {
49
+ windowId: windowId
50
+ })
47
51
  };
48
52
  };
49
53
 
50
54
  /**
51
55
  * MiradorDownloadDialog ~
52
- */
53
- export var MiradorDownloadDialog = function (_Component) {
54
- _inherits(MiradorDownloadDialog, _Component);
55
-
56
- function MiradorDownloadDialog() {
57
- _classCallCheck(this, MiradorDownloadDialog);
58
-
59
- return _possibleConstructorReturn(this, _Component.apply(this, arguments));
60
- }
61
-
62
- MiradorDownloadDialog.prototype.renderings = function renderings() {
63
- var manifest = this.props.manifest;
64
-
56
+ */
57
+ export function MiradorDownloadDialog(_ref3) {
58
+ var _ref3$canvases = _ref3.canvases,
59
+ canvases = _ref3$canvases === void 0 ? [] : _ref3$canvases,
60
+ canvasLabel = _ref3.canvasLabel,
61
+ closeDialog = _ref3.closeDialog,
62
+ containerId = _ref3.containerId,
63
+ infoResponse = _ref3.infoResponse,
64
+ _ref3$manifest = _ref3.manifest,
65
+ manifest = _ref3$manifest === void 0 ? {} : _ref3$manifest,
66
+ _ref3$open = _ref3.open,
67
+ open = _ref3$open === void 0 ? false : _ref3$open,
68
+ _ref3$restrictDownloa = _ref3.restrictDownloadOnSizeDefinition,
69
+ restrictDownloadOnSizeDefinition = _ref3$restrictDownloa === void 0 ? false : _ref3$restrictDownloa,
70
+ viewType = _ref3.viewType,
71
+ windowId = _ref3.windowId;
72
+ var _useTranslation = useTranslation(),
73
+ t = _useTranslation.t;
74
+ var renderings = useMemo(function () {
65
75
  if (!(manifest && manifest.getSequences() && manifest.getSequences()[0] && manifest.getSequences()[0].getRenderings())) return [];
66
-
67
76
  return manifest.getSequences()[0].getRenderings();
68
- };
69
-
70
- /**
71
- * Returns the rendered component
72
- */
73
-
74
-
75
- MiradorDownloadDialog.prototype.render = function render() {
76
- var _props = this.props,
77
- canvases = _props.canvases,
78
- canvasLabel = _props.canvasLabel,
79
- classes = _props.classes,
80
- closeDialog = _props.closeDialog,
81
- containerId = _props.containerId,
82
- infoResponse = _props.infoResponse,
83
- open = _props.open,
84
- restrictDownloadOnSizeDefinition = _props.restrictDownloadOnSizeDefinition,
85
- viewType = _props.viewType,
86
- windowId = _props.windowId;
87
-
88
-
89
- if (!open) return '';
90
-
91
- return React.createElement(
92
- React.Fragment,
93
- null,
94
- React.createElement(
95
- Dialog,
96
- {
97
- container: document.querySelector('#' + containerId + ' .mirador-viewer'),
98
- disableEnforceFocus: true,
99
- onClose: closeDialog,
100
- open: open,
101
- scroll: 'paper',
102
- fullWidth: true,
103
- maxWidth: 'xs'
104
- },
105
- React.createElement(
106
- DialogTitle,
107
- { disableTypography: true, className: classes.h2 },
108
- React.createElement(
109
- Typography,
110
- { variant: 'h2' },
111
- 'Download'
112
- )
113
- ),
114
- React.createElement(
115
- ScrollIndicatedDialogContent,
116
- null,
117
- canvases.map(function (canvas) {
118
- return React.createElement(CanvasDownloadLinks, {
119
- canvas: canvas,
120
- canvasLabel: canvasLabel(canvas.id),
121
- classes: classes,
122
- infoResponse: infoResponse(canvas.id),
123
- restrictDownloadOnSizeDefinition: restrictDownloadOnSizeDefinition,
124
- key: canvas.id,
125
- viewType: viewType,
126
- windowId: windowId
127
- });
128
- }),
129
- this.renderings().length > 0 && React.createElement(ManifestDownloadLinks, { classes: classes, renderings: this.renderings() })
130
- ),
131
- React.createElement(
132
- DialogActions,
133
- null,
134
- React.createElement(
135
- Button,
136
- { onClick: closeDialog, color: 'primary' },
137
- 'Close'
138
- )
139
- )
140
- )
141
- );
142
- };
143
-
144
- return MiradorDownloadDialog;
145
- }(Component);
146
-
147
- MiradorDownloadDialog.propTypes = process.env.NODE_ENV !== "production" ? {
148
- canvasLabel: PropTypes.func.isRequired,
149
- canvases: PropTypes.arrayOf(PropTypes.shape({ id: PropTypes.string, index: PropTypes.number })),
150
- classes: PropTypes.shape({
151
- h2: PropTypes.string,
152
- h3: PropTypes.string
153
- }).isRequired,
154
- closeDialog: PropTypes.func.isRequired,
155
- containerId: PropTypes.string.isRequired,
156
- infoResponse: PropTypes.func.isRequired,
157
- manifest: PropTypes.shape({
158
- getSequences: PropTypes.func
159
- }),
160
- open: PropTypes.bool,
161
- restrictDownloadOnSizeDefinition: PropTypes.bool,
162
- viewType: PropTypes.string.isRequired,
163
- windowId: PropTypes.string.isRequired
164
- } : {};
165
- MiradorDownloadDialog.defaultProps = {
166
- canvases: [],
167
- manifest: {},
168
- open: false,
169
- restrictDownloadOnSizeDefinition: false
170
- };
171
-
172
- var styles = function styles() {
173
- return {
174
- h2: {
175
- paddingBottom: 0
176
- },
177
- h3: {
178
- marginTop: '20px'
179
- }
180
- };
181
- };
182
-
77
+ }, [manifest]);
78
+ if (!open) return '';
79
+ return /*#__PURE__*/_jsxs(Dialog, {
80
+ "data-testid": "dialog-content",
81
+ container: document.querySelector("#".concat(containerId, " .mirador-viewer")),
82
+ disableEnforceFocus: true,
83
+ onClose: closeDialog,
84
+ open: open,
85
+ scroll: "paper",
86
+ fullWidth: true,
87
+ maxWidth: "xs",
88
+ children: [/*#__PURE__*/_jsx(DialogTitle, {
89
+ sx: {
90
+ paddingBottom: 0
91
+ },
92
+ children: /*#__PURE__*/_jsx(Typography, {
93
+ variant: "h2",
94
+ component: "span",
95
+ children: t('mirador-dl-plugin.download')
96
+ })
97
+ }), /*#__PURE__*/_jsxs(ScrollIndicatedDialogContent, {
98
+ children: [canvases.map(function (canvas) {
99
+ return /*#__PURE__*/_jsx(CanvasDownloadLinks, {
100
+ canvas: canvas,
101
+ canvasLabel: canvasLabel(canvas.id),
102
+ infoResponse: infoResponse(canvas.id),
103
+ restrictDownloadOnSizeDefinition: restrictDownloadOnSizeDefinition,
104
+ t: t,
105
+ viewType: viewType,
106
+ windowId: windowId
107
+ }, canvas.id);
108
+ }), renderings.length > 0 && /*#__PURE__*/_jsx(ManifestDownloadLinks, {
109
+ renderings: renderings,
110
+ t: t
111
+ })]
112
+ }), /*#__PURE__*/_jsx(DialogActions, {
113
+ children: /*#__PURE__*/_jsx(Button, {
114
+ onClick: closeDialog,
115
+ color: "primary",
116
+ children: t('mirador-dl-plugin.close')
117
+ })
118
+ })]
119
+ });
120
+ }
183
121
  export default {
184
122
  target: 'Window',
185
123
  mode: 'add',
186
124
  name: 'MiradorDownloadDialog',
187
- component: withStyles(styles)(MiradorDownloadDialog),
125
+ component: MiradorDownloadDialog,
126
+ config: {
127
+ translations: translations
128
+ },
188
129
  mapDispatchToProps: mapDispatchToProps,
189
130
  mapStateToProps: mapStateToProps
190
131
  };
@@ -1,57 +1,52 @@
1
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2
-
3
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
4
-
5
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
6
-
1
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
2
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
3
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
4
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
5
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
6
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
7
+ function _possibleConstructorReturn(t, e) { if (e && ("object" == typeof e || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
8
+ function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
9
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
10
+ function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
11
+ function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
12
+ function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
7
13
  import React, { Component } from 'react';
8
- import PropTypes from 'prop-types';
9
- import Link from '@material-ui/core/Link';
10
- import ListItem from '@material-ui/core/ListItem';
11
- import ListItemText from '@material-ui/core/ListItemText';
14
+ import Link from '@mui/material/Link';
15
+ import ListItem from '@mui/material/ListItem';
16
+ import ListItemText from '@mui/material/ListItemText';
12
17
 
13
18
  /**
14
19
  * RenderingDownloadLink ~
15
- */
16
-
17
- var RenderingDownloadLink = function (_Component) {
18
- _inherits(RenderingDownloadLink, _Component);
19
-
20
+ */
21
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
22
+ var RenderingDownloadLink = /*#__PURE__*/function (_Component) {
20
23
  function RenderingDownloadLink() {
21
24
  _classCallCheck(this, RenderingDownloadLink);
22
-
23
- return _possibleConstructorReturn(this, _Component.apply(this, arguments));
25
+ return _callSuper(this, RenderingDownloadLink, arguments);
24
26
  }
25
-
26
- RenderingDownloadLink.prototype.render = function render() {
27
- var rendering = this.props.rendering;
28
-
29
- return React.createElement(
30
- ListItem,
31
- { disableGutters: true, divider: true, key: rendering.id },
32
- React.createElement(
33
- ListItemText,
34
- { primaryTypographyProps: { variant: 'body1' } },
35
- React.createElement(
36
- Link,
37
- { href: rendering.id, rel: 'noopener noreferrer', target: '_blank', variant: 'body1' },
38
- rendering.getLabel().getValue()
39
- ),
40
- rendering.getFormat() && rendering.getFormat().value && ' (' + rendering.getFormat().value + ')'
41
- )
42
- );
43
- };
44
-
45
- return RenderingDownloadLink;
27
+ _inherits(RenderingDownloadLink, _Component);
28
+ return _createClass(RenderingDownloadLink, [{
29
+ key: "render",
30
+ value: function render() {
31
+ var rendering = this.props.rendering;
32
+ return /*#__PURE__*/_jsx(ListItem, {
33
+ disableGutters: true,
34
+ divider: true,
35
+ children: /*#__PURE__*/_jsxs(ListItemText, {
36
+ primaryTypographyProps: {
37
+ variant: 'body1'
38
+ },
39
+ children: [/*#__PURE__*/_jsx(Link, {
40
+ href: rendering.id,
41
+ download: true,
42
+ rel: "noopener noreferrer",
43
+ target: "_blank",
44
+ variant: "body1",
45
+ children: rendering.getLabel().getValue()
46
+ }), rendering.getFormat() && rendering.getFormat().value && " (".concat(rendering.getFormat().value, ")")]
47
+ })
48
+ }, rendering.id);
49
+ }
50
+ }]);
46
51
  }(Component);
47
-
48
- export { RenderingDownloadLink as default };
49
-
50
-
51
- RenderingDownloadLink.propTypes = process.env.NODE_ENV !== "production" ? {
52
- rendering: PropTypes.shape({
53
- id: PropTypes.string.isRequired,
54
- getLabel: PropTypes.func.isRequired,
55
- getFormat: PropTypes.func.isRequired
56
- }).isRequired
57
- } : {};
52
+ export { RenderingDownloadLink as default };
package/es/index.js CHANGED
@@ -1,6 +1,5 @@
1
+ import '@mui/material/styles/styled';
1
2
  import miradorDownloadPlugin from './miradorDownloadPlugin';
2
3
  import MiradorDownloadDialogPlugin from './MiradorDownloadDialog';
3
-
4
4
  export { miradorDownloadPlugin, MiradorDownloadDialogPlugin };
5
-
6
5
  export default [miradorDownloadPlugin, MiradorDownloadDialogPlugin];
@@ -1,111 +1,76 @@
1
- var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
2
-
3
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
4
-
5
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
6
-
7
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
8
-
9
- import React, { Component } from 'react';
10
- import PropTypes from 'prop-types';
11
- import ListItemIcon from '@material-ui/core/ListItemIcon';
12
- import ListItemText from '@material-ui/core/ListItemText';
13
- import MenuItem from '@material-ui/core/MenuItem';
14
- import DownloadIcon from '@material-ui/icons/VerticalAlignBottomSharp';
15
-
1
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
2
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
3
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
4
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
5
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
6
+ import React, { useCallback } from 'react';
7
+ import { useTranslation } from 'react-i18next';
8
+ import MenuItem from '@mui/material/MenuItem';
9
+ import ListItemIcon from '@mui/material/ListItemIcon';
10
+ import ListItemText from '@mui/material/ListItemText';
11
+ import VerticalAlignBottomIcon from '@mui/icons-material/VerticalAlignBottom';
12
+ import translations from './translations';
13
+
14
+ // eslint-disable-next-line default-param-last
15
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
16
16
  var downloadDialogReducer = function downloadDialogReducer() {
17
17
  var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
18
- var action = arguments[1];
19
-
18
+ var action = arguments.length > 1 ? arguments[1] : undefined;
20
19
  if (action.type === 'OPEN_WINDOW_DIALOG') {
21
- var _extends2;
22
-
23
- return _extends({}, state, (_extends2 = {}, _extends2[action.windowId] = {
20
+ return _objectSpread(_objectSpread({}, state), {}, _defineProperty({}, action.windowId, {
24
21
  openDialog: action.dialogType
25
- }, _extends2));
22
+ }));
26
23
  }
27
-
28
24
  if (action.type === 'CLOSE_WINDOW_DIALOG') {
29
- var _extends3;
30
-
31
- return _extends({}, state, (_extends3 = {}, _extends3[action.windowId] = {
25
+ return _objectSpread(_objectSpread({}, state), {}, _defineProperty({}, action.windowId, {
32
26
  openDialog: null
33
- }, _extends3));
27
+ }));
34
28
  }
35
29
  return state;
36
30
  };
37
-
38
31
  var mapDispatchToProps = function mapDispatchToProps(dispatch, _ref) {
39
32
  var windowId = _ref.windowId;
40
33
  return {
41
34
  openDownloadDialog: function openDownloadDialog() {
42
- return dispatch({ type: 'OPEN_WINDOW_DIALOG', windowId: windowId, dialogType: 'download' });
35
+ return dispatch({
36
+ type: 'OPEN_WINDOW_DIALOG',
37
+ windowId: windowId,
38
+ dialogType: 'download'
39
+ });
43
40
  }
44
41
  };
45
42
  };
46
-
47
- var MiradorDownload = function (_Component) {
48
- _inherits(MiradorDownload, _Component);
49
-
50
- function MiradorDownload() {
51
- _classCallCheck(this, MiradorDownload);
52
-
53
- return _possibleConstructorReturn(this, _Component.apply(this, arguments));
54
- }
55
-
56
- MiradorDownload.prototype.openDialogAndCloseMenu = function openDialogAndCloseMenu() {
57
- var _props = this.props,
58
- handleClose = _props.handleClose,
59
- openDownloadDialog = _props.openDownloadDialog;
60
-
61
-
43
+ function MiradorDownload(_ref2) {
44
+ var _ref2$handleClose = _ref2.handleClose,
45
+ handleClose = _ref2$handleClose === void 0 ? function () {} : _ref2$handleClose,
46
+ _ref2$openDownloadDia = _ref2.openDownloadDialog,
47
+ openDownloadDialog = _ref2$openDownloadDia === void 0 ? function () {} : _ref2$openDownloadDia;
48
+ var openDialogAndCloseMenu = useCallback(function () {
62
49
  openDownloadDialog();
63
50
  handleClose();
64
- };
65
-
66
- MiradorDownload.prototype.render = function render() {
67
- var _this2 = this;
68
-
69
- return React.createElement(
70
- React.Fragment,
71
- null,
72
- React.createElement(
73
- MenuItem,
74
- { onClick: function onClick() {
75
- return _this2.openDialogAndCloseMenu();
76
- } },
77
- React.createElement(
78
- ListItemIcon,
79
- null,
80
- React.createElement(DownloadIcon, null)
81
- ),
82
- React.createElement(
83
- ListItemText,
84
- { primaryTypographyProps: { variant: 'body1' } },
85
- 'Download'
86
- )
87
- )
88
- );
89
- };
90
-
91
- return MiradorDownload;
92
- }(Component);
93
-
94
- MiradorDownload.propTypes = process.env.NODE_ENV !== "production" ? {
95
- handleClose: PropTypes.func,
96
- openDownloadDialog: PropTypes.func
97
- } : {};
98
-
99
- MiradorDownload.defaultProps = {
100
- handleClose: function handleClose() {},
101
- openDownloadDialog: function openDownloadDialog() {}
102
- };
103
-
51
+ }, [handleClose, openDownloadDialog]);
52
+ var _useTranslation = useTranslation(),
53
+ t = _useTranslation.t;
54
+ return /*#__PURE__*/_jsxs(MenuItem, {
55
+ onClick: openDialogAndCloseMenu,
56
+ children: [/*#__PURE__*/_jsx(ListItemIcon, {
57
+ children: /*#__PURE__*/_jsx(VerticalAlignBottomIcon, {})
58
+ }), /*#__PURE__*/_jsx(ListItemText, {
59
+ primaryTypographyProps: {
60
+ variant: 'body1'
61
+ },
62
+ children: t('mirador-dl-plugin.download')
63
+ })]
64
+ });
65
+ }
104
66
  export default {
105
67
  target: 'WindowTopBarPluginMenu',
106
68
  mode: 'add',
107
69
  name: 'MiradorDownloadPlugin',
108
70
  component: MiradorDownload,
71
+ config: {
72
+ translations: translations
73
+ },
109
74
  mapDispatchToProps: mapDispatchToProps,
110
75
  reducers: {
111
76
  windowDialogs: downloadDialogReducer
@@ -0,0 +1,39 @@
1
+ var translations = {
2
+ de: {
3
+ 'mirador-dl-plugin': {
4
+ close: 'Schließen',
5
+ download: 'Download',
6
+ other_download: 'Andere Download-Optionen',
7
+ whole_image: 'Gesamtes Bild ({{width}} x {{height}}px)',
8
+ zoomed_region: 'Aktueller Bildausschnitt ({{width}} x {{height}}px)'
9
+ }
10
+ },
11
+ en: {
12
+ 'mirador-dl-plugin': {
13
+ close: 'Close',
14
+ download: 'Download',
15
+ other_download: 'Other download options',
16
+ whole_image: 'Whole image ({{width}} x {{height}}px)',
17
+ zoomed_region: 'Zoomed region ({{width}} x {{height}}px)'
18
+ }
19
+ },
20
+ et: {
21
+ 'mirador-dl-plugin': {
22
+ close: 'Sulge',
23
+ download: 'Lae alla',
24
+ other_download: 'Teised allalaadimise valikud',
25
+ whole_image: 'Kogu pilt ({{width}} x {{height}}px)',
26
+ zoomed_region: 'Suurendatud piirkond ({{width}} x {{height}}px)'
27
+ }
28
+ },
29
+ fr: {
30
+ 'mirador-dl-plugin': {
31
+ close: 'Fermer',
32
+ download: 'Télécharger',
33
+ other_download: 'Autres options de téléchargement',
34
+ whole_image: 'Image entière ({{width}} x {{height}}px)',
35
+ zoomed_region: 'Région zoomée ({{width}} x {{height}}px)'
36
+ }
37
+ }
38
+ };
39
+ export default translations;