mirador-dl-plugin 1.0.0-alpha.1 → 1.0.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -5
- package/dist/mirador-dl-plugin.es.js +11850 -0
- package/dist/mirador-dl-plugin.es.js.map +1 -0
- package/dist/mirador-dl-plugin.js +188 -0
- package/dist/mirador-dl-plugin.js.map +1 -0
- package/package.json +33 -53
- package/es/CanvasDownloadLinks.js +0 -237
- package/es/ManifestDownloadLinks.js +0 -30
- package/es/MiradorDownloadDialog.js +0 -131
- package/es/RenderingDownloadLink.js +0 -52
- package/es/index.js +0 -5
- package/es/miradorDownloadPlugin.js +0 -78
- package/es/translations.js +0 -39
- package/lib/CanvasDownloadLinks.js +0 -243
- package/lib/ManifestDownloadLinks.js +0 -35
- package/lib/MiradorDownloadDialog.js +0 -141
- package/lib/RenderingDownloadLink.js +0 -58
- package/lib/index.js +0 -23
- package/lib/miradorDownloadPlugin.js +0 -85
- package/lib/translations.js +0 -45
- package/umd/mirador-dl-plugin.js +0 -3
- package/umd/mirador-dl-plugin.js.LICENSE.txt +0 -58
- package/umd/mirador-dl-plugin.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,31 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mirador-dl-plugin",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.3",
|
|
4
4
|
"description": "mirador-dl-plugin React component",
|
|
5
|
-
"main": "
|
|
6
|
-
"module": "
|
|
5
|
+
"main": "./dist/mirador-dl-plugin.js",
|
|
6
|
+
"module": "./dist/mirador-dl-plugin.es.js",
|
|
7
7
|
"files": [
|
|
8
|
-
"
|
|
9
|
-
"es",
|
|
10
|
-
"lib",
|
|
11
|
-
"umd"
|
|
8
|
+
"dist"
|
|
12
9
|
],
|
|
10
|
+
"exports": {
|
|
11
|
+
"./src": "./src/index.js",
|
|
12
|
+
".": {
|
|
13
|
+
"import": "./dist/mirador-dl-plugin.es.js",
|
|
14
|
+
"require": "./dist/mirador-dl-plugin.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
13
17
|
"scripts": {
|
|
14
|
-
"build": "
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"prepublishOnly": "npm run clean && npm run build:es && npm run build:cjs && npm run build",
|
|
22
|
-
"start": "NODE_ENV=development webpack serve --open",
|
|
23
|
-
"test": "npm run lint && jest",
|
|
24
|
-
"test:coverage": "jest --coverage",
|
|
25
|
-
"test:watch": "jest --watch"
|
|
18
|
+
"build": "vite build --config vite.config.js",
|
|
19
|
+
"clean": "rm -rf ./dist",
|
|
20
|
+
"lint": "npx eslint ./",
|
|
21
|
+
"prepublishOnly": "npm run build",
|
|
22
|
+
"start": "vite",
|
|
23
|
+
"test": "npm run lint && npx vitest run",
|
|
24
|
+
"test:coverage": "npm run lint && npx vitest run --coverage"
|
|
26
25
|
},
|
|
27
26
|
"dependencies": {
|
|
28
|
-
"@emotion/babel-plugin": "^11.11.0",
|
|
29
27
|
"@emotion/cache": "^11.11.0",
|
|
30
28
|
"@emotion/react": "^11.10.6",
|
|
31
29
|
"@emotion/styled": "^11.10.6"
|
|
@@ -33,54 +31,36 @@
|
|
|
33
31
|
"peerDependencies": {
|
|
34
32
|
"@mui/material": "^5.x",
|
|
35
33
|
"lodash": "^4.17.11",
|
|
36
|
-
"mirador": "^4.0.0-alpha.
|
|
34
|
+
"mirador": "^4.0.0-alpha.10",
|
|
37
35
|
"react": "18.x",
|
|
38
|
-
"react-dom": "18.x"
|
|
39
|
-
"react-i18next": "^13.0.0 || ^14.0.0 || ^15.0.0"
|
|
36
|
+
"react-dom": "18.x"
|
|
40
37
|
},
|
|
41
38
|
"devDependencies": {
|
|
42
|
-
"@babel/cli": "^7.17.6",
|
|
43
|
-
"@babel/core": "^7.17.7",
|
|
44
|
-
"@babel/eslint-parser": "^7.5.4",
|
|
45
|
-
"@babel/plugin-proposal-class-properties": "^7.16.7",
|
|
46
|
-
"@babel/plugin-proposal-object-rest-spread": "^7.20.7",
|
|
47
|
-
"@babel/plugin-proposal-private-methods": "^7.18.6",
|
|
48
|
-
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
|
|
49
|
-
"@babel/plugin-transform-regenerator": "^7.16.7",
|
|
50
|
-
"@babel/plugin-transform-runtime": "^7.24.7",
|
|
51
|
-
"@babel/preset-env": "^7.16.11",
|
|
52
|
-
"@babel/preset-react": "^7.16.7",
|
|
53
39
|
"@mui/material": "^5.x",
|
|
54
|
-
"@
|
|
55
|
-
"@testing-library/dom": "^9.2.0",
|
|
40
|
+
"@testing-library/dom": "^10.4.0",
|
|
56
41
|
"@testing-library/jest-dom": "^6.1.5",
|
|
57
|
-
"@testing-library/react": "^
|
|
42
|
+
"@testing-library/react": "^16.0.0",
|
|
58
43
|
"@testing-library/user-event": "^14.4.3",
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
|
|
44
|
+
"@vitejs/plugin-react": "^4.3.4",
|
|
45
|
+
"@vitest/coverage-v8": "^2.1.8",
|
|
46
|
+
"@vitest/ui": "^2.1.4",
|
|
63
47
|
"eslint": "^8.11.0",
|
|
64
48
|
"eslint-config-airbnb": "^19.0.4",
|
|
65
|
-
"eslint-plugin-babel": "^5.3.0",
|
|
66
49
|
"eslint-plugin-import": "^2.25.4",
|
|
67
|
-
"eslint-plugin-jest": "^
|
|
50
|
+
"eslint-plugin-jest-dom": "^5.1.0",
|
|
68
51
|
"eslint-plugin-jsx-a11y": "^6.4.1",
|
|
69
52
|
"eslint-plugin-react": "^7.29.4",
|
|
70
53
|
"eslint-plugin-react-hooks": "^4.3.0",
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"jest-environment-jsdom": "^29.4.3",
|
|
75
|
-
"jest-puppeteer": "^9.0.2",
|
|
54
|
+
"eslint-plugin-testing-library": "^6.2.0",
|
|
55
|
+
"glob": "^10.3.0",
|
|
56
|
+
"happy-dom": "^15.11.7",
|
|
76
57
|
"lodash": "^4.17.15",
|
|
77
|
-
"mirador": "^4.0.0-alpha.
|
|
58
|
+
"mirador": "^4.0.0-alpha.10",
|
|
78
59
|
"react": "^18.0.0",
|
|
79
60
|
"react-dom": "^18.0.0",
|
|
80
|
-
"
|
|
81
|
-
"
|
|
82
|
-
"
|
|
83
|
-
"webpack-dev-server": "^4.7.4"
|
|
61
|
+
"vite": "^6.0.0",
|
|
62
|
+
"vitest": "^2.1.4",
|
|
63
|
+
"vitest-fetch-mock": "^0.4.2"
|
|
84
64
|
},
|
|
85
65
|
"author": "",
|
|
86
66
|
"homepage": "",
|
|
@@ -1,237 +0,0 @@
|
|
|
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); }
|
|
13
|
-
import React, { Component } from 'react';
|
|
14
|
-
import uniqBy from 'lodash/uniqBy';
|
|
15
|
-
import { OSDReferences } from 'mirador';
|
|
16
|
-
import Typography from '@mui/material/Typography';
|
|
17
|
-
import Link from '@mui/material/Link';
|
|
18
|
-
import List from '@mui/material/List';
|
|
19
|
-
import ListItem from '@mui/material/ListItem';
|
|
20
|
-
import RenderingDownloadLink from './RenderingDownloadLink';
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* CanvasDownloadLinks ~
|
|
24
|
-
*/
|
|
25
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
26
|
-
var CanvasDownloadLinks = /*#__PURE__*/function (_Component) {
|
|
27
|
-
function CanvasDownloadLinks() {
|
|
28
|
-
_classCallCheck(this, CanvasDownloadLinks);
|
|
29
|
-
return _callSuper(this, CanvasDownloadLinks, arguments);
|
|
30
|
-
}
|
|
31
|
-
_inherits(CanvasDownloadLinks, _Component);
|
|
32
|
-
return _createClass(CanvasDownloadLinks, [{
|
|
33
|
-
key: "zoomedImageLabel",
|
|
34
|
-
value: function zoomedImageLabel() {
|
|
35
|
-
var t = this.props.t;
|
|
36
|
-
var bounds = this.currentBounds();
|
|
37
|
-
return t('mirador-dl-plugin.zoomed_region', {
|
|
38
|
-
width: Math.floor(bounds.width),
|
|
39
|
-
height: Math.floor(bounds.height)
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
}, {
|
|
43
|
-
key: "fullImageLabel",
|
|
44
|
-
value: function fullImageLabel() {
|
|
45
|
-
var _this$props = this.props,
|
|
46
|
-
canvas = _this$props.canvas,
|
|
47
|
-
t = _this$props.t;
|
|
48
|
-
return t('mirador-dl-plugin.whole_image', {
|
|
49
|
-
width: canvas.getWidth(),
|
|
50
|
-
height: canvas.getHeight()
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
}, {
|
|
54
|
-
key: "smallImageLabel",
|
|
55
|
-
value: function smallImageLabel() {
|
|
56
|
-
var _this$props2 = this.props,
|
|
57
|
-
canvas = _this$props2.canvas,
|
|
58
|
-
t = _this$props2.t;
|
|
59
|
-
var height = Math.floor(1000 * canvas.getHeight() / canvas.getWidth());
|
|
60
|
-
return t('mirador-dl-plugin.whole_image', {
|
|
61
|
-
width: 1000,
|
|
62
|
-
height: height
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
}, {
|
|
66
|
-
key: "zoomedImageUrl",
|
|
67
|
-
value: function zoomedImageUrl() {
|
|
68
|
-
var canvas = this.props.canvas;
|
|
69
|
-
var bounds = this.currentBounds();
|
|
70
|
-
var boundsUrl = canvas.getCanonicalImageUri().replace(/\/full\/.*\/0\//, "/".concat(bounds.x, ",").concat(bounds.y, ",").concat(bounds.width, ",").concat(bounds.height, "/full/0/"));
|
|
71
|
-
return "".concat(boundsUrl, "?download=true");
|
|
72
|
-
}
|
|
73
|
-
}, {
|
|
74
|
-
key: "imageUrlForSize",
|
|
75
|
-
value: function imageUrlForSize(size) {
|
|
76
|
-
var canvas = this.props.canvas;
|
|
77
|
-
return "".concat(canvas.getCanonicalImageUri(size.width), "?download=true");
|
|
78
|
-
}
|
|
79
|
-
}, {
|
|
80
|
-
key: "fullImageUrl",
|
|
81
|
-
value: function fullImageUrl() {
|
|
82
|
-
var canvas = this.props.canvas;
|
|
83
|
-
return "".concat(canvas.getCanonicalImageUri().replace(/\/full\/.*\/0\//, '/full/full/0/'), "?download=true");
|
|
84
|
-
}
|
|
85
|
-
}, {
|
|
86
|
-
key: "thousandPixelWideImage",
|
|
87
|
-
value: function thousandPixelWideImage() {
|
|
88
|
-
var canvas = this.props.canvas;
|
|
89
|
-
return "".concat(canvas.getCanonicalImageUri('1000'), "?download=true");
|
|
90
|
-
}
|
|
91
|
-
}, {
|
|
92
|
-
key: "osdViewport",
|
|
93
|
-
value: function osdViewport() {
|
|
94
|
-
var windowId = this.props.windowId;
|
|
95
|
-
return OSDReferences.get(windowId).current.viewport;
|
|
96
|
-
}
|
|
97
|
-
}, {
|
|
98
|
-
key: "currentBounds",
|
|
99
|
-
value: function currentBounds() {
|
|
100
|
-
var bounds = this.osdViewport().getBounds();
|
|
101
|
-
return Object.keys(bounds).reduce(function (object, key) {
|
|
102
|
-
object[key] = Math.ceil(bounds[key]); // eslint-disable-line no-param-reassign
|
|
103
|
-
return object;
|
|
104
|
-
}, {});
|
|
105
|
-
}
|
|
106
|
-
}, {
|
|
107
|
-
key: "definedSizesRestrictsDownload",
|
|
108
|
-
value: function definedSizesRestrictsDownload() {
|
|
109
|
-
var infoResponse = this.props.infoResponse;
|
|
110
|
-
if (!infoResponse.json) return false;
|
|
111
|
-
var _infoResponse$json = infoResponse.json,
|
|
112
|
-
height = _infoResponse$json.height,
|
|
113
|
-
width = _infoResponse$json.width;
|
|
114
|
-
if (this.definedSizes().length !== 1) return false;
|
|
115
|
-
return this.definedSizes()[0].width <= width && this.definedSizes()[0].height <= height;
|
|
116
|
-
}
|
|
117
|
-
}, {
|
|
118
|
-
key: "displayCurrentZoomLink",
|
|
119
|
-
value: function displayCurrentZoomLink() {
|
|
120
|
-
var _this$props3 = this.props,
|
|
121
|
-
restrictDownloadOnSizeDefinition = _this$props3.restrictDownloadOnSizeDefinition,
|
|
122
|
-
infoResponse = _this$props3.infoResponse,
|
|
123
|
-
viewType = _this$props3.viewType;
|
|
124
|
-
if (viewType !== 'single') return false;
|
|
125
|
-
if (restrictDownloadOnSizeDefinition && this.definedSizesRestrictsDownload()) return false;
|
|
126
|
-
if (!(infoResponse && infoResponse.json)) return false;
|
|
127
|
-
var bounds = this.currentBounds();
|
|
128
|
-
return bounds.height < infoResponse.json.height && bounds.width < infoResponse.json.width && bounds.x >= 0 && bounds.y >= 0;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* This only returns unique sizes
|
|
133
|
-
*/
|
|
134
|
-
}, {
|
|
135
|
-
key: "definedSizes",
|
|
136
|
-
value: function definedSizes() {
|
|
137
|
-
var infoResponse = this.props.infoResponse;
|
|
138
|
-
if (!(infoResponse && infoResponse.json && infoResponse.json.sizes)) return [];
|
|
139
|
-
return uniqBy(infoResponse.json.sizes, function (size) {
|
|
140
|
-
return "".concat(size.width).concat(size.height);
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
}, {
|
|
144
|
-
key: "fullImageLink",
|
|
145
|
-
value: function fullImageLink() {
|
|
146
|
-
return /*#__PURE__*/_jsx(ListItem, {
|
|
147
|
-
disableGutters: true,
|
|
148
|
-
divider: true,
|
|
149
|
-
children: /*#__PURE__*/_jsx(Link, {
|
|
150
|
-
href: this.fullImageUrl(),
|
|
151
|
-
rel: "noopener noreferrer",
|
|
152
|
-
target: "_blank",
|
|
153
|
-
variant: "body1",
|
|
154
|
-
children: this.fullImageLabel()
|
|
155
|
-
})
|
|
156
|
-
}, this.fullImageUrl());
|
|
157
|
-
}
|
|
158
|
-
}, {
|
|
159
|
-
key: "thousandPixelWideLink",
|
|
160
|
-
value: function thousandPixelWideLink() {
|
|
161
|
-
var canvas = this.props.canvas;
|
|
162
|
-
if (canvas.getWidth() < 1000) return '';
|
|
163
|
-
return /*#__PURE__*/_jsx(ListItem, {
|
|
164
|
-
disableGutters: true,
|
|
165
|
-
divider: true,
|
|
166
|
-
children: /*#__PURE__*/_jsx(Link, {
|
|
167
|
-
href: this.thousandPixelWideImage(),
|
|
168
|
-
rel: "noopener noreferrer",
|
|
169
|
-
target: "_blank",
|
|
170
|
-
variant: "body1",
|
|
171
|
-
children: this.smallImageLabel()
|
|
172
|
-
})
|
|
173
|
-
}, this.thousandPixelWideImage());
|
|
174
|
-
}
|
|
175
|
-
}, {
|
|
176
|
-
key: "linksForDefinedSizes",
|
|
177
|
-
value: function linksForDefinedSizes() {
|
|
178
|
-
var _this = this;
|
|
179
|
-
var t = this.props.t;
|
|
180
|
-
return this.definedSizes().map(function (size) {
|
|
181
|
-
return /*#__PURE__*/_jsx(ListItem, {
|
|
182
|
-
disableGutters: true,
|
|
183
|
-
divider: true,
|
|
184
|
-
children: /*#__PURE__*/_jsx(Link, {
|
|
185
|
-
href: _this.imageUrlForSize(size),
|
|
186
|
-
rel: "noopener noreferrer",
|
|
187
|
-
target: "_blank",
|
|
188
|
-
variant: "body1",
|
|
189
|
-
children: t('mirador-dl-plugin.whole_image', {
|
|
190
|
-
width: size.width,
|
|
191
|
-
height: size.height
|
|
192
|
-
})
|
|
193
|
-
})
|
|
194
|
-
}, "".concat(size.width).concat(size.height));
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
* Returns the rendered component
|
|
200
|
-
*/
|
|
201
|
-
}, {
|
|
202
|
-
key: "render",
|
|
203
|
-
value: function render() {
|
|
204
|
-
var _this$props4 = this.props,
|
|
205
|
-
canvas = _this$props4.canvas,
|
|
206
|
-
canvasLabel = _this$props4.canvasLabel;
|
|
207
|
-
return /*#__PURE__*/_jsxs(React.Fragment, {
|
|
208
|
-
children: [/*#__PURE__*/_jsx(Typography, {
|
|
209
|
-
noWrap: true,
|
|
210
|
-
variant: "h3",
|
|
211
|
-
sx: {
|
|
212
|
-
marginTop: '20px'
|
|
213
|
-
},
|
|
214
|
-
children: canvasLabel
|
|
215
|
-
}), /*#__PURE__*/_jsxs(List, {
|
|
216
|
-
children: [this.displayCurrentZoomLink() && /*#__PURE__*/_jsx(ListItem, {
|
|
217
|
-
disableGutters: true,
|
|
218
|
-
divider: true,
|
|
219
|
-
children: /*#__PURE__*/_jsx(Link, {
|
|
220
|
-
href: this.zoomedImageUrl(),
|
|
221
|
-
download: true,
|
|
222
|
-
rel: "noopener noreferrer",
|
|
223
|
-
target: "_blank",
|
|
224
|
-
variant: "body1",
|
|
225
|
-
children: this.zoomedImageLabel()
|
|
226
|
-
})
|
|
227
|
-
}), this.definedSizes().length === 0 && [this.fullImageLink(), this.thousandPixelWideLink()], this.definedSizes().length > 0 && this.linksForDefinedSizes(), canvas.getRenderings().map(function (rendering) {
|
|
228
|
-
return /*#__PURE__*/_jsx(RenderingDownloadLink, {
|
|
229
|
-
rendering: rendering
|
|
230
|
-
}, rendering.id);
|
|
231
|
-
})]
|
|
232
|
-
})]
|
|
233
|
-
});
|
|
234
|
-
}
|
|
235
|
-
}]);
|
|
236
|
-
}(Component);
|
|
237
|
-
export { CanvasDownloadLinks as default };
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { useTranslation } from 'react-i18next';
|
|
3
|
-
import Typography from '@mui/material/Typography';
|
|
4
|
-
import List from '@mui/material/List';
|
|
5
|
-
import RenderingDownloadLink from './RenderingDownloadLink';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* ManifestDownloadLinks ~
|
|
9
|
-
*/
|
|
10
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
-
export default function ManifestDownloadLinks(_ref) {
|
|
12
|
-
var renderings = _ref.renderings;
|
|
13
|
-
var _useTranslation = useTranslation(),
|
|
14
|
-
t = _useTranslation.t;
|
|
15
|
-
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
16
|
-
children: [/*#__PURE__*/_jsx(Typography, {
|
|
17
|
-
variant: "h3",
|
|
18
|
-
sx: {
|
|
19
|
-
marginTop: '20px'
|
|
20
|
-
},
|
|
21
|
-
children: t('mirador-dl-plugin.other_download')
|
|
22
|
-
}), /*#__PURE__*/_jsx(List, {
|
|
23
|
-
children: renderings.map(function (rendering) {
|
|
24
|
-
return /*#__PURE__*/_jsx(RenderingDownloadLink, {
|
|
25
|
-
rendering: rendering
|
|
26
|
-
}, rendering.id);
|
|
27
|
-
})
|
|
28
|
-
})]
|
|
29
|
-
});
|
|
30
|
-
}
|
|
@@ -1,131 +0,0 @@
|
|
|
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';
|
|
9
|
-
import ManifestDownloadLinks from './ManifestDownloadLinks';
|
|
10
|
-
import translations from './translations';
|
|
11
|
-
import CanvasDownloadLinks from './CanvasDownloadLinks';
|
|
12
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
-
var mapDispatchToProps = function mapDispatchToProps(dispatch, _ref) {
|
|
14
|
-
var windowId = _ref.windowId;
|
|
15
|
-
return {
|
|
16
|
-
closeDialog: function closeDialog() {
|
|
17
|
-
return dispatch({
|
|
18
|
-
type: 'CLOSE_WINDOW_DIALOG',
|
|
19
|
-
windowId: windowId
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
var mapStateToProps = function mapStateToProps(state, _ref2) {
|
|
25
|
-
var windowId = _ref2.windowId;
|
|
26
|
-
return {
|
|
27
|
-
canvases: getVisibleCanvases(state, {
|
|
28
|
-
windowId: windowId
|
|
29
|
-
}),
|
|
30
|
-
canvasLabel: function canvasLabel(canvasId) {
|
|
31
|
-
return getCanvasLabel(state, {
|
|
32
|
-
canvasId: canvasId,
|
|
33
|
-
windowId: windowId
|
|
34
|
-
});
|
|
35
|
-
},
|
|
36
|
-
containerId: getContainerId(state),
|
|
37
|
-
infoResponse: function infoResponse(canvasId) {
|
|
38
|
-
return selectInfoResponse(state, {
|
|
39
|
-
windowId: windowId,
|
|
40
|
-
canvasId: canvasId
|
|
41
|
-
}) || {};
|
|
42
|
-
},
|
|
43
|
-
manifest: getManifestoInstance(state, {
|
|
44
|
-
windowId: windowId
|
|
45
|
-
}),
|
|
46
|
-
restrictDownloadOnSizeDefinition: state.config.miradorDownloadPlugin && state.config.miradorDownloadPlugin.restrictDownloadOnSizeDefinition,
|
|
47
|
-
open: state.windowDialogs[windowId] && state.windowDialogs[windowId].openDialog === 'download',
|
|
48
|
-
viewType: getWindowViewType(state, {
|
|
49
|
-
windowId: windowId
|
|
50
|
-
})
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* MiradorDownloadDialog ~
|
|
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 () {
|
|
75
|
-
if (!(manifest && manifest.getSequences() && manifest.getSequences()[0] && manifest.getSequences()[0].getRenderings())) return [];
|
|
76
|
-
return manifest.getSequences()[0].getRenderings();
|
|
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
|
-
}
|
|
121
|
-
export default {
|
|
122
|
-
target: 'Window',
|
|
123
|
-
mode: 'add',
|
|
124
|
-
name: 'MiradorDownloadDialog',
|
|
125
|
-
component: MiradorDownloadDialog,
|
|
126
|
-
config: {
|
|
127
|
-
translations: translations
|
|
128
|
-
},
|
|
129
|
-
mapDispatchToProps: mapDispatchToProps,
|
|
130
|
-
mapStateToProps: mapStateToProps
|
|
131
|
-
};
|
|
@@ -1,52 +0,0 @@
|
|
|
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); }
|
|
13
|
-
import React, { Component } from 'react';
|
|
14
|
-
import Link from '@mui/material/Link';
|
|
15
|
-
import ListItem from '@mui/material/ListItem';
|
|
16
|
-
import ListItemText from '@mui/material/ListItemText';
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* RenderingDownloadLink ~
|
|
20
|
-
*/
|
|
21
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
22
|
-
var RenderingDownloadLink = /*#__PURE__*/function (_Component) {
|
|
23
|
-
function RenderingDownloadLink() {
|
|
24
|
-
_classCallCheck(this, RenderingDownloadLink);
|
|
25
|
-
return _callSuper(this, RenderingDownloadLink, arguments);
|
|
26
|
-
}
|
|
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
|
-
}]);
|
|
51
|
-
}(Component);
|
|
52
|
-
export { RenderingDownloadLink as default };
|
package/es/index.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import '@mui/material/styles/styled';
|
|
2
|
-
import miradorDownloadPlugin from './miradorDownloadPlugin';
|
|
3
|
-
import MiradorDownloadDialogPlugin from './MiradorDownloadDialog';
|
|
4
|
-
export { miradorDownloadPlugin, MiradorDownloadDialogPlugin };
|
|
5
|
-
export default [miradorDownloadPlugin, MiradorDownloadDialogPlugin];
|
|
@@ -1,78 +0,0 @@
|
|
|
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
|
-
var downloadDialogReducer = function downloadDialogReducer() {
|
|
17
|
-
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
18
|
-
var action = arguments.length > 1 ? arguments[1] : undefined;
|
|
19
|
-
if (action.type === 'OPEN_WINDOW_DIALOG') {
|
|
20
|
-
return _objectSpread(_objectSpread({}, state), {}, _defineProperty({}, action.windowId, {
|
|
21
|
-
openDialog: action.dialogType
|
|
22
|
-
}));
|
|
23
|
-
}
|
|
24
|
-
if (action.type === 'CLOSE_WINDOW_DIALOG') {
|
|
25
|
-
return _objectSpread(_objectSpread({}, state), {}, _defineProperty({}, action.windowId, {
|
|
26
|
-
openDialog: null
|
|
27
|
-
}));
|
|
28
|
-
}
|
|
29
|
-
return state;
|
|
30
|
-
};
|
|
31
|
-
var mapDispatchToProps = function mapDispatchToProps(dispatch, _ref) {
|
|
32
|
-
var windowId = _ref.windowId;
|
|
33
|
-
return {
|
|
34
|
-
openDownloadDialog: function openDownloadDialog() {
|
|
35
|
-
return dispatch({
|
|
36
|
-
type: 'OPEN_WINDOW_DIALOG',
|
|
37
|
-
windowId: windowId,
|
|
38
|
-
dialogType: 'download'
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
};
|
|
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 () {
|
|
49
|
-
openDownloadDialog();
|
|
50
|
-
handleClose();
|
|
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
|
-
}
|
|
66
|
-
export default {
|
|
67
|
-
target: 'WindowTopBarPluginMenu',
|
|
68
|
-
mode: 'add',
|
|
69
|
-
name: 'MiradorDownloadPlugin',
|
|
70
|
-
component: MiradorDownload,
|
|
71
|
-
config: {
|
|
72
|
-
translations: translations
|
|
73
|
-
},
|
|
74
|
-
mapDispatchToProps: mapDispatchToProps,
|
|
75
|
-
reducers: {
|
|
76
|
-
windowDialogs: downloadDialogReducer
|
|
77
|
-
}
|
|
78
|
-
};
|