mirador-dl-plugin 1.0.0-alpha.1 → 1.0.0-alpha.2

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,39 +0,0 @@
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;
@@ -1,243 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
- var _react = _interopRequireWildcard(require("react"));
8
- var _uniqBy = _interopRequireDefault(require("lodash/uniqBy"));
9
- var _mirador = require("mirador");
10
- var _Typography = _interopRequireDefault(require("@mui/material/Typography"));
11
- var _Link = _interopRequireDefault(require("@mui/material/Link"));
12
- var _List = _interopRequireDefault(require("@mui/material/List"));
13
- var _ListItem = _interopRequireDefault(require("@mui/material/ListItem"));
14
- var _RenderingDownloadLink = _interopRequireDefault(require("./RenderingDownloadLink"));
15
- var _jsxRuntime = require("react/jsx-runtime");
16
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
17
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
18
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
19
- function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
20
- 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); } }
21
- function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
22
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
23
- 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); }
24
- function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
25
- 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); }
26
- function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
27
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
28
- function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
29
- 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); }
30
- function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); } /**
31
- * CanvasDownloadLinks ~
32
- */
33
- var CanvasDownloadLinks = exports["default"] = /*#__PURE__*/function (_Component) {
34
- function CanvasDownloadLinks() {
35
- _classCallCheck(this, CanvasDownloadLinks);
36
- return _callSuper(this, CanvasDownloadLinks, arguments);
37
- }
38
- _inherits(CanvasDownloadLinks, _Component);
39
- return _createClass(CanvasDownloadLinks, [{
40
- key: "zoomedImageLabel",
41
- value: function zoomedImageLabel() {
42
- var t = this.props.t;
43
- var bounds = this.currentBounds();
44
- return t('mirador-dl-plugin.zoomed_region', {
45
- width: Math.floor(bounds.width),
46
- height: Math.floor(bounds.height)
47
- });
48
- }
49
- }, {
50
- key: "fullImageLabel",
51
- value: function fullImageLabel() {
52
- var _this$props = this.props,
53
- canvas = _this$props.canvas,
54
- t = _this$props.t;
55
- return t('mirador-dl-plugin.whole_image', {
56
- width: canvas.getWidth(),
57
- height: canvas.getHeight()
58
- });
59
- }
60
- }, {
61
- key: "smallImageLabel",
62
- value: function smallImageLabel() {
63
- var _this$props2 = this.props,
64
- canvas = _this$props2.canvas,
65
- t = _this$props2.t;
66
- var height = Math.floor(1000 * canvas.getHeight() / canvas.getWidth());
67
- return t('mirador-dl-plugin.whole_image', {
68
- width: 1000,
69
- height: height
70
- });
71
- }
72
- }, {
73
- key: "zoomedImageUrl",
74
- value: function zoomedImageUrl() {
75
- var canvas = this.props.canvas;
76
- var bounds = this.currentBounds();
77
- var boundsUrl = canvas.getCanonicalImageUri().replace(/\/full\/.*\/0\//, "/".concat(bounds.x, ",").concat(bounds.y, ",").concat(bounds.width, ",").concat(bounds.height, "/full/0/"));
78
- return "".concat(boundsUrl, "?download=true");
79
- }
80
- }, {
81
- key: "imageUrlForSize",
82
- value: function imageUrlForSize(size) {
83
- var canvas = this.props.canvas;
84
- return "".concat(canvas.getCanonicalImageUri(size.width), "?download=true");
85
- }
86
- }, {
87
- key: "fullImageUrl",
88
- value: function fullImageUrl() {
89
- var canvas = this.props.canvas;
90
- return "".concat(canvas.getCanonicalImageUri().replace(/\/full\/.*\/0\//, '/full/full/0/'), "?download=true");
91
- }
92
- }, {
93
- key: "thousandPixelWideImage",
94
- value: function thousandPixelWideImage() {
95
- var canvas = this.props.canvas;
96
- return "".concat(canvas.getCanonicalImageUri('1000'), "?download=true");
97
- }
98
- }, {
99
- key: "osdViewport",
100
- value: function osdViewport() {
101
- var windowId = this.props.windowId;
102
- return _mirador.OSDReferences.get(windowId).current.viewport;
103
- }
104
- }, {
105
- key: "currentBounds",
106
- value: function currentBounds() {
107
- var bounds = this.osdViewport().getBounds();
108
- return Object.keys(bounds).reduce(function (object, key) {
109
- object[key] = Math.ceil(bounds[key]); // eslint-disable-line no-param-reassign
110
- return object;
111
- }, {});
112
- }
113
- }, {
114
- key: "definedSizesRestrictsDownload",
115
- value: function definedSizesRestrictsDownload() {
116
- var infoResponse = this.props.infoResponse;
117
- if (!infoResponse.json) return false;
118
- var _infoResponse$json = infoResponse.json,
119
- height = _infoResponse$json.height,
120
- width = _infoResponse$json.width;
121
- if (this.definedSizes().length !== 1) return false;
122
- return this.definedSizes()[0].width <= width && this.definedSizes()[0].height <= height;
123
- }
124
- }, {
125
- key: "displayCurrentZoomLink",
126
- value: function displayCurrentZoomLink() {
127
- var _this$props3 = this.props,
128
- restrictDownloadOnSizeDefinition = _this$props3.restrictDownloadOnSizeDefinition,
129
- infoResponse = _this$props3.infoResponse,
130
- viewType = _this$props3.viewType;
131
- if (viewType !== 'single') return false;
132
- if (restrictDownloadOnSizeDefinition && this.definedSizesRestrictsDownload()) return false;
133
- if (!(infoResponse && infoResponse.json)) return false;
134
- var bounds = this.currentBounds();
135
- return bounds.height < infoResponse.json.height && bounds.width < infoResponse.json.width && bounds.x >= 0 && bounds.y >= 0;
136
- }
137
-
138
- /**
139
- * This only returns unique sizes
140
- */
141
- }, {
142
- key: "definedSizes",
143
- value: function definedSizes() {
144
- var infoResponse = this.props.infoResponse;
145
- if (!(infoResponse && infoResponse.json && infoResponse.json.sizes)) return [];
146
- return (0, _uniqBy["default"])(infoResponse.json.sizes, function (size) {
147
- return "".concat(size.width).concat(size.height);
148
- });
149
- }
150
- }, {
151
- key: "fullImageLink",
152
- value: function fullImageLink() {
153
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ListItem["default"], {
154
- disableGutters: true,
155
- divider: true,
156
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Link["default"], {
157
- href: this.fullImageUrl(),
158
- rel: "noopener noreferrer",
159
- target: "_blank",
160
- variant: "body1",
161
- children: this.fullImageLabel()
162
- })
163
- }, this.fullImageUrl());
164
- }
165
- }, {
166
- key: "thousandPixelWideLink",
167
- value: function thousandPixelWideLink() {
168
- var canvas = this.props.canvas;
169
- if (canvas.getWidth() < 1000) return '';
170
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ListItem["default"], {
171
- disableGutters: true,
172
- divider: true,
173
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Link["default"], {
174
- href: this.thousandPixelWideImage(),
175
- rel: "noopener noreferrer",
176
- target: "_blank",
177
- variant: "body1",
178
- children: this.smallImageLabel()
179
- })
180
- }, this.thousandPixelWideImage());
181
- }
182
- }, {
183
- key: "linksForDefinedSizes",
184
- value: function linksForDefinedSizes() {
185
- var _this = this;
186
- var t = this.props.t;
187
- return this.definedSizes().map(function (size) {
188
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ListItem["default"], {
189
- disableGutters: true,
190
- divider: true,
191
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Link["default"], {
192
- href: _this.imageUrlForSize(size),
193
- rel: "noopener noreferrer",
194
- target: "_blank",
195
- variant: "body1",
196
- children: t('mirador-dl-plugin.whole_image', {
197
- width: size.width,
198
- height: size.height
199
- })
200
- })
201
- }, "".concat(size.width).concat(size.height));
202
- });
203
- }
204
-
205
- /**
206
- * Returns the rendered component
207
- */
208
- }, {
209
- key: "render",
210
- value: function render() {
211
- var _this$props4 = this.props,
212
- canvas = _this$props4.canvas,
213
- canvasLabel = _this$props4.canvasLabel;
214
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_react["default"].Fragment, {
215
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography["default"], {
216
- noWrap: true,
217
- variant: "h3",
218
- sx: {
219
- marginTop: '20px'
220
- },
221
- children: canvasLabel
222
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_List["default"], {
223
- children: [this.displayCurrentZoomLink() && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ListItem["default"], {
224
- disableGutters: true,
225
- divider: true,
226
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Link["default"], {
227
- href: this.zoomedImageUrl(),
228
- download: true,
229
- rel: "noopener noreferrer",
230
- target: "_blank",
231
- variant: "body1",
232
- children: this.zoomedImageLabel()
233
- })
234
- }), this.definedSizes().length === 0 && [this.fullImageLink(), this.thousandPixelWideLink()], this.definedSizes().length > 0 && this.linksForDefinedSizes(), canvas.getRenderings().map(function (rendering) {
235
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_RenderingDownloadLink["default"], {
236
- rendering: rendering
237
- }, rendering.id);
238
- })]
239
- })]
240
- });
241
- }
242
- }]);
243
- }(_react.Component);
@@ -1,35 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = ManifestDownloadLinks;
7
- var _react = _interopRequireDefault(require("react"));
8
- var _reactI18next = require("react-i18next");
9
- var _Typography = _interopRequireDefault(require("@mui/material/Typography"));
10
- var _List = _interopRequireDefault(require("@mui/material/List"));
11
- var _RenderingDownloadLink = _interopRequireDefault(require("./RenderingDownloadLink"));
12
- var _jsxRuntime = require("react/jsx-runtime");
13
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
14
- /**
15
- * ManifestDownloadLinks ~
16
- */function ManifestDownloadLinks(_ref) {
17
- var renderings = _ref.renderings;
18
- var _useTranslation = (0, _reactI18next.useTranslation)(),
19
- t = _useTranslation.t;
20
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
21
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography["default"], {
22
- variant: "h3",
23
- sx: {
24
- marginTop: '20px'
25
- },
26
- children: t('mirador-dl-plugin.other_download')
27
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_List["default"], {
28
- children: renderings.map(function (rendering) {
29
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_RenderingDownloadLink["default"], {
30
- rendering: rendering
31
- }, rendering.id);
32
- })
33
- })]
34
- });
35
- }
@@ -1,141 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.MiradorDownloadDialog = MiradorDownloadDialog;
7
- exports["default"] = void 0;
8
- var _react = _interopRequireWildcard(require("react"));
9
- var _reactI18next = require("react-i18next");
10
- var _mirador = require("mirador");
11
- var _Typography = _interopRequireDefault(require("@mui/material/Typography"));
12
- var _Dialog = _interopRequireDefault(require("@mui/material/Dialog"));
13
- var _DialogTitle = _interopRequireDefault(require("@mui/material/DialogTitle"));
14
- var _DialogActions = _interopRequireDefault(require("@mui/material/DialogActions"));
15
- var _Button = _interopRequireDefault(require("@mui/material/Button"));
16
- var _ManifestDownloadLinks = _interopRequireDefault(require("./ManifestDownloadLinks"));
17
- var _translations = _interopRequireDefault(require("./translations"));
18
- var _CanvasDownloadLinks = _interopRequireDefault(require("./CanvasDownloadLinks"));
19
- var _jsxRuntime = require("react/jsx-runtime");
20
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
21
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
22
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
23
- var mapDispatchToProps = function mapDispatchToProps(dispatch, _ref) {
24
- var windowId = _ref.windowId;
25
- return {
26
- closeDialog: function closeDialog() {
27
- return dispatch({
28
- type: 'CLOSE_WINDOW_DIALOG',
29
- windowId: windowId
30
- });
31
- }
32
- };
33
- };
34
- var mapStateToProps = function mapStateToProps(state, _ref2) {
35
- var windowId = _ref2.windowId;
36
- return {
37
- canvases: (0, _mirador.getVisibleCanvases)(state, {
38
- windowId: windowId
39
- }),
40
- canvasLabel: function canvasLabel(canvasId) {
41
- return (0, _mirador.getCanvasLabel)(state, {
42
- canvasId: canvasId,
43
- windowId: windowId
44
- });
45
- },
46
- containerId: (0, _mirador.getContainerId)(state),
47
- infoResponse: function infoResponse(canvasId) {
48
- return (0, _mirador.selectInfoResponse)(state, {
49
- windowId: windowId,
50
- canvasId: canvasId
51
- }) || {};
52
- },
53
- manifest: (0, _mirador.getManifestoInstance)(state, {
54
- windowId: windowId
55
- }),
56
- restrictDownloadOnSizeDefinition: state.config.miradorDownloadPlugin && state.config.miradorDownloadPlugin.restrictDownloadOnSizeDefinition,
57
- open: state.windowDialogs[windowId] && state.windowDialogs[windowId].openDialog === 'download',
58
- viewType: (0, _mirador.getWindowViewType)(state, {
59
- windowId: windowId
60
- })
61
- };
62
- };
63
-
64
- /**
65
- * MiradorDownloadDialog ~
66
- */
67
- function MiradorDownloadDialog(_ref3) {
68
- var _ref3$canvases = _ref3.canvases,
69
- canvases = _ref3$canvases === void 0 ? [] : _ref3$canvases,
70
- canvasLabel = _ref3.canvasLabel,
71
- closeDialog = _ref3.closeDialog,
72
- containerId = _ref3.containerId,
73
- infoResponse = _ref3.infoResponse,
74
- _ref3$manifest = _ref3.manifest,
75
- manifest = _ref3$manifest === void 0 ? {} : _ref3$manifest,
76
- _ref3$open = _ref3.open,
77
- open = _ref3$open === void 0 ? false : _ref3$open,
78
- _ref3$restrictDownloa = _ref3.restrictDownloadOnSizeDefinition,
79
- restrictDownloadOnSizeDefinition = _ref3$restrictDownloa === void 0 ? false : _ref3$restrictDownloa,
80
- viewType = _ref3.viewType,
81
- windowId = _ref3.windowId;
82
- var _useTranslation = (0, _reactI18next.useTranslation)(),
83
- t = _useTranslation.t;
84
- var renderings = (0, _react.useMemo)(function () {
85
- if (!(manifest && manifest.getSequences() && manifest.getSequences()[0] && manifest.getSequences()[0].getRenderings())) return [];
86
- return manifest.getSequences()[0].getRenderings();
87
- }, [manifest]);
88
- if (!open) return '';
89
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Dialog["default"], {
90
- "data-testid": "dialog-content",
91
- container: document.querySelector("#".concat(containerId, " .mirador-viewer")),
92
- disableEnforceFocus: true,
93
- onClose: closeDialog,
94
- open: open,
95
- scroll: "paper",
96
- fullWidth: true,
97
- maxWidth: "xs",
98
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_DialogTitle["default"], {
99
- sx: {
100
- paddingBottom: 0
101
- },
102
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography["default"], {
103
- variant: "h2",
104
- component: "span",
105
- children: t('mirador-dl-plugin.download')
106
- })
107
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_mirador.ScrollIndicatedDialogContent, {
108
- children: [canvases.map(function (canvas) {
109
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_CanvasDownloadLinks["default"], {
110
- canvas: canvas,
111
- canvasLabel: canvasLabel(canvas.id),
112
- infoResponse: infoResponse(canvas.id),
113
- restrictDownloadOnSizeDefinition: restrictDownloadOnSizeDefinition,
114
- t: t,
115
- viewType: viewType,
116
- windowId: windowId
117
- }, canvas.id);
118
- }), renderings.length > 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ManifestDownloadLinks["default"], {
119
- renderings: renderings,
120
- t: t
121
- })]
122
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_DialogActions["default"], {
123
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button["default"], {
124
- onClick: closeDialog,
125
- color: "primary",
126
- children: t('mirador-dl-plugin.close')
127
- })
128
- })]
129
- });
130
- }
131
- var _default = exports["default"] = {
132
- target: 'Window',
133
- mode: 'add',
134
- name: 'MiradorDownloadDialog',
135
- component: MiradorDownloadDialog,
136
- config: {
137
- translations: _translations["default"]
138
- },
139
- mapDispatchToProps: mapDispatchToProps,
140
- mapStateToProps: mapStateToProps
141
- };
@@ -1,58 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
- var _react = _interopRequireWildcard(require("react"));
8
- var _Link = _interopRequireDefault(require("@mui/material/Link"));
9
- var _ListItem = _interopRequireDefault(require("@mui/material/ListItem"));
10
- var _ListItemText = _interopRequireDefault(require("@mui/material/ListItemText"));
11
- var _jsxRuntime = require("react/jsx-runtime");
12
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
13
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
14
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
15
- function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
16
- 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); } }
17
- function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
18
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
19
- 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); }
20
- function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
21
- 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); }
22
- function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
23
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
24
- function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
25
- 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); }
26
- function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); } /**
27
- * RenderingDownloadLink ~
28
- */
29
- var RenderingDownloadLink = exports["default"] = /*#__PURE__*/function (_Component) {
30
- function RenderingDownloadLink() {
31
- _classCallCheck(this, RenderingDownloadLink);
32
- return _callSuper(this, RenderingDownloadLink, arguments);
33
- }
34
- _inherits(RenderingDownloadLink, _Component);
35
- return _createClass(RenderingDownloadLink, [{
36
- key: "render",
37
- value: function render() {
38
- var rendering = this.props.rendering;
39
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ListItem["default"], {
40
- disableGutters: true,
41
- divider: true,
42
- children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ListItemText["default"], {
43
- primaryTypographyProps: {
44
- variant: 'body1'
45
- },
46
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Link["default"], {
47
- href: rendering.id,
48
- download: true,
49
- rel: "noopener noreferrer",
50
- target: "_blank",
51
- variant: "body1",
52
- children: rendering.getLabel().getValue()
53
- }), rendering.getFormat() && rendering.getFormat().value && " (".concat(rendering.getFormat().value, ")")]
54
- })
55
- }, rendering.id);
56
- }
57
- }]);
58
- }(_react.Component);
package/lib/index.js DELETED
@@ -1,23 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "MiradorDownloadDialogPlugin", {
7
- enumerable: true,
8
- get: function get() {
9
- return _MiradorDownloadDialog["default"];
10
- }
11
- });
12
- exports["default"] = void 0;
13
- Object.defineProperty(exports, "miradorDownloadPlugin", {
14
- enumerable: true,
15
- get: function get() {
16
- return _miradorDownloadPlugin["default"];
17
- }
18
- });
19
- require("@mui/material/styles/styled");
20
- var _miradorDownloadPlugin = _interopRequireDefault(require("./miradorDownloadPlugin"));
21
- var _MiradorDownloadDialog = _interopRequireDefault(require("./MiradorDownloadDialog"));
22
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
23
- var _default = exports["default"] = [_miradorDownloadPlugin["default"], _MiradorDownloadDialog["default"]];
@@ -1,85 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
- var _react = _interopRequireWildcard(require("react"));
8
- var _reactI18next = require("react-i18next");
9
- var _MenuItem = _interopRequireDefault(require("@mui/material/MenuItem"));
10
- var _ListItemIcon = _interopRequireDefault(require("@mui/material/ListItemIcon"));
11
- var _ListItemText = _interopRequireDefault(require("@mui/material/ListItemText"));
12
- var _VerticalAlignBottom = _interopRequireDefault(require("@mui/icons-material/VerticalAlignBottom"));
13
- var _translations = _interopRequireDefault(require("./translations"));
14
- var _jsxRuntime = require("react/jsx-runtime");
15
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
16
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
17
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
18
- 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; }
19
- 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; }
20
- 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; }
21
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
22
- 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); } // eslint-disable-next-line default-param-last
23
- var downloadDialogReducer = function downloadDialogReducer() {
24
- var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
25
- var action = arguments.length > 1 ? arguments[1] : undefined;
26
- if (action.type === 'OPEN_WINDOW_DIALOG') {
27
- return _objectSpread(_objectSpread({}, state), {}, _defineProperty({}, action.windowId, {
28
- openDialog: action.dialogType
29
- }));
30
- }
31
- if (action.type === 'CLOSE_WINDOW_DIALOG') {
32
- return _objectSpread(_objectSpread({}, state), {}, _defineProperty({}, action.windowId, {
33
- openDialog: null
34
- }));
35
- }
36
- return state;
37
- };
38
- var mapDispatchToProps = function mapDispatchToProps(dispatch, _ref) {
39
- var windowId = _ref.windowId;
40
- return {
41
- openDownloadDialog: function openDownloadDialog() {
42
- return dispatch({
43
- type: 'OPEN_WINDOW_DIALOG',
44
- windowId: windowId,
45
- dialogType: 'download'
46
- });
47
- }
48
- };
49
- };
50
- function MiradorDownload(_ref2) {
51
- var _ref2$handleClose = _ref2.handleClose,
52
- handleClose = _ref2$handleClose === void 0 ? function () {} : _ref2$handleClose,
53
- _ref2$openDownloadDia = _ref2.openDownloadDialog,
54
- openDownloadDialog = _ref2$openDownloadDia === void 0 ? function () {} : _ref2$openDownloadDia;
55
- var openDialogAndCloseMenu = (0, _react.useCallback)(function () {
56
- openDownloadDialog();
57
- handleClose();
58
- }, [handleClose, openDownloadDialog]);
59
- var _useTranslation = (0, _reactI18next.useTranslation)(),
60
- t = _useTranslation.t;
61
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_MenuItem["default"], {
62
- onClick: openDialogAndCloseMenu,
63
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_ListItemIcon["default"], {
64
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_VerticalAlignBottom["default"], {})
65
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ListItemText["default"], {
66
- primaryTypographyProps: {
67
- variant: 'body1'
68
- },
69
- children: t('mirador-dl-plugin.download')
70
- })]
71
- });
72
- }
73
- var _default = exports["default"] = {
74
- target: 'WindowTopBarPluginMenu',
75
- mode: 'add',
76
- name: 'MiradorDownloadPlugin',
77
- component: MiradorDownload,
78
- config: {
79
- translations: _translations["default"]
80
- },
81
- mapDispatchToProps: mapDispatchToProps,
82
- reducers: {
83
- windowDialogs: downloadDialogReducer
84
- }
85
- };