mirador-dl-plugin 0.13.0 → 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.
- package/README.md +3 -8
- package/dist/mirador-dl-plugin.es.js +11903 -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 +50 -40
- package/es/CanvasDownloadLinks.js +0 -253
- package/es/ManifestDownloadLinks.js +0 -64
- package/es/MiradorDownloadDialog.js +0 -190
- package/es/RenderingDownloadLink.js +0 -57
- package/es/index.js +0 -6
- package/es/miradorDownloadPlugin.js +0 -113
- package/lib/CanvasDownloadLinks.js +0 -284
- package/lib/ManifestDownloadLinks.js +0 -85
- package/lib/MiradorDownloadDialog.js +0 -232
- package/lib/RenderingDownloadLink.js +0 -78
- package/lib/index.js +0 -18
- package/lib/miradorDownloadPlugin.js +0 -137
- package/umd/mirador-dl-plugin.js +0 -23085
- package/umd/mirador-dl-plugin.min.js +0 -42
- package/umd/mirador-dl-plugin.min.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,57 +1,67 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mirador-dl-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0-alpha.2",
|
|
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
|
-
"clean": "
|
|
18
|
+
"build": "vite build --config vite.config.js",
|
|
19
|
+
"clean": "rm -rf ./dist",
|
|
16
20
|
"lint": "npx eslint ./",
|
|
17
21
|
"prepublishOnly": "npm run build",
|
|
18
|
-
"start": "
|
|
19
|
-
"test": "npm run lint &&
|
|
20
|
-
"test:coverage": "
|
|
21
|
-
|
|
22
|
+
"start": "vite",
|
|
23
|
+
"test": "npm run lint && npx vitest run",
|
|
24
|
+
"test:coverage": "npm run lint && npx vitest run --coverage"
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@emotion/cache": "^11.11.0",
|
|
28
|
+
"@emotion/react": "^11.10.6",
|
|
29
|
+
"@emotion/styled": "^11.10.6"
|
|
22
30
|
},
|
|
23
31
|
"peerDependencies": {
|
|
24
|
-
"@material
|
|
25
|
-
"@material-ui/icons": "^4.9.1",
|
|
32
|
+
"@mui/material": "^5.x",
|
|
26
33
|
"lodash": "^4.17.11",
|
|
27
|
-
"mirador": "^
|
|
28
|
-
"
|
|
29
|
-
"react": "
|
|
30
|
-
"react-
|
|
34
|
+
"mirador": "^4.0.0-alpha.7",
|
|
35
|
+
"react": "18.x",
|
|
36
|
+
"react-dom": "18.x",
|
|
37
|
+
"react-i18next": "^13.0.0 || ^14.0.0 || ^15.0.0"
|
|
31
38
|
},
|
|
32
39
|
"devDependencies": {
|
|
33
|
-
"@
|
|
34
|
-
"@
|
|
35
|
-
"@
|
|
36
|
-
"@
|
|
37
|
-
"@
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"eslint": "^
|
|
43
|
-
"eslint-
|
|
44
|
-
"eslint-plugin-
|
|
45
|
-
"eslint-plugin-
|
|
46
|
-
"eslint-plugin-
|
|
47
|
-
"eslint-plugin-react": "^
|
|
48
|
-
"
|
|
40
|
+
"@mui/material": "^5.x",
|
|
41
|
+
"@testing-library/dom": "^10.4.0",
|
|
42
|
+
"@testing-library/jest-dom": "^6.1.5",
|
|
43
|
+
"@testing-library/react": "^16.0.0",
|
|
44
|
+
"@testing-library/user-event": "^14.4.3",
|
|
45
|
+
"@vitejs/plugin-react": "^4.3.4",
|
|
46
|
+
"@vitest/coverage-v8": "^2.1.8",
|
|
47
|
+
"@vitest/ui": "^2.1.4",
|
|
48
|
+
"eslint": "^8.11.0",
|
|
49
|
+
"eslint-config-airbnb": "^19.0.4",
|
|
50
|
+
"eslint-plugin-import": "^2.25.4",
|
|
51
|
+
"eslint-plugin-jest-dom": "^5.1.0",
|
|
52
|
+
"eslint-plugin-jsx-a11y": "^6.4.1",
|
|
53
|
+
"eslint-plugin-react": "^7.29.4",
|
|
54
|
+
"eslint-plugin-react-hooks": "^4.3.0",
|
|
55
|
+
"eslint-plugin-testing-library": "^6.2.0",
|
|
56
|
+
"glob": "^10.3.0",
|
|
57
|
+
"happy-dom": "^15.11.7",
|
|
49
58
|
"lodash": "^4.17.15",
|
|
50
|
-
"mirador": "^
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
59
|
+
"mirador": "^4.0.0-alpha.5",
|
|
60
|
+
"react": "^18.0.0",
|
|
61
|
+
"react-dom": "^18.0.0",
|
|
62
|
+
"vite": "^6.0.0",
|
|
63
|
+
"vitest": "^2.1.4",
|
|
64
|
+
"vitest-fetch-mock": "^0.4.2"
|
|
55
65
|
},
|
|
56
66
|
"author": "",
|
|
57
67
|
"homepage": "",
|
|
@@ -1,253 +0,0 @@
|
|
|
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 Typography from '@material-ui/core/Typography';
|
|
10
|
-
import Link from '@material-ui/core/Link';
|
|
11
|
-
import List from '@material-ui/core/List';
|
|
12
|
-
import ListItem from '@material-ui/core/ListItem';
|
|
13
|
-
import uniqBy from 'lodash/uniqBy';
|
|
14
|
-
import { OSDReferences } from 'mirador/dist/es/src/plugins/OSDReferences';
|
|
15
|
-
import RenderingDownloadLink from './RenderingDownloadLink';
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* CanvasDownloadLinks ~
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
var CanvasDownloadLinks = function (_Component) {
|
|
22
|
-
_inherits(CanvasDownloadLinks, _Component);
|
|
23
|
-
|
|
24
|
-
function CanvasDownloadLinks() {
|
|
25
|
-
_classCallCheck(this, CanvasDownloadLinks);
|
|
26
|
-
|
|
27
|
-
return _possibleConstructorReturn(this, _Component.apply(this, arguments));
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
CanvasDownloadLinks.prototype.zoomedImageLabel = function zoomedImageLabel() {
|
|
31
|
-
var bounds = this.currentBounds();
|
|
32
|
-
return 'Zoomed region (' + Math.floor(bounds.width) + ' x ' + Math.floor(bounds.height) + 'px)';
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
CanvasDownloadLinks.prototype.fullImageLabel = function fullImageLabel() {
|
|
36
|
-
var canvas = this.props.canvas;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return 'Whole image (' + canvas.getWidth() + ' x ' + canvas.getHeight() + 'px)';
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
CanvasDownloadLinks.prototype.smallImageLabel = function smallImageLabel() {
|
|
43
|
-
var canvas = this.props.canvas;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
return 'Whole image (1000 x ' + Math.floor(1000 * canvas.getHeight() / canvas.getWidth()) + 'px)';
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
CanvasDownloadLinks.prototype.zoomedImageUrl = function zoomedImageUrl() {
|
|
50
|
-
var canvas = this.props.canvas;
|
|
51
|
-
|
|
52
|
-
var bounds = this.currentBounds();
|
|
53
|
-
var boundsUrl = canvas.getCanonicalImageUri().replace(/\/full\/.*\/0\//, '/' + bounds.x + ',' + bounds.y + ',' + bounds.width + ',' + bounds.height + '/full/0/');
|
|
54
|
-
|
|
55
|
-
return boundsUrl + '?download=true';
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
CanvasDownloadLinks.prototype.imageUrlForSize = function imageUrlForSize(size) {
|
|
59
|
-
var canvas = this.props.canvas;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
return canvas.getCanonicalImageUri(size.width) + '?download=true';
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
CanvasDownloadLinks.prototype.fullImageUrl = function fullImageUrl() {
|
|
66
|
-
var canvas = this.props.canvas;
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
return canvas.getCanonicalImageUri().replace(/\/full\/.*\/0\//, '/full/full/0/') + '?download=true';
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
CanvasDownloadLinks.prototype.thousandPixelWideImage = function thousandPixelWideImage() {
|
|
73
|
-
var canvas = this.props.canvas;
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
return canvas.getCanonicalImageUri('1000') + '?download=true';
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
CanvasDownloadLinks.prototype.osdViewport = function osdViewport() {
|
|
80
|
-
var windowId = this.props.windowId;
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
return OSDReferences.get(windowId).current.viewport;
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
CanvasDownloadLinks.prototype.currentBounds = function currentBounds() {
|
|
87
|
-
var bounds = this.osdViewport().getBounds();
|
|
88
|
-
|
|
89
|
-
return Object.keys(bounds).reduce(function (object, key) {
|
|
90
|
-
object[key] = Math.ceil(bounds[key]); // eslint-disable-line no-param-reassign
|
|
91
|
-
return object;
|
|
92
|
-
}, {});
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
CanvasDownloadLinks.prototype.definedSizesRestrictsDownload = function definedSizesRestrictsDownload() {
|
|
96
|
-
var infoResponse = this.props.infoResponse;
|
|
97
|
-
|
|
98
|
-
if (!infoResponse.json) return false;
|
|
99
|
-
var _infoResponse$json = infoResponse.json,
|
|
100
|
-
height = _infoResponse$json.height,
|
|
101
|
-
width = _infoResponse$json.width;
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
if (this.definedSizes().length !== 1) return false;
|
|
105
|
-
|
|
106
|
-
return this.definedSizes()[0].width <= width && this.definedSizes()[0].height <= height;
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
CanvasDownloadLinks.prototype.displayCurrentZoomLink = function displayCurrentZoomLink() {
|
|
110
|
-
var _props = this.props,
|
|
111
|
-
restrictDownloadOnSizeDefinition = _props.restrictDownloadOnSizeDefinition,
|
|
112
|
-
infoResponse = _props.infoResponse,
|
|
113
|
-
viewType = _props.viewType;
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
if (viewType !== 'single') return false;
|
|
117
|
-
if (restrictDownloadOnSizeDefinition && this.definedSizesRestrictsDownload()) return false;
|
|
118
|
-
if (!(infoResponse && infoResponse.json)) return false;
|
|
119
|
-
|
|
120
|
-
var bounds = this.currentBounds();
|
|
121
|
-
return bounds.height < infoResponse.json.height && bounds.width < infoResponse.json.width && bounds.x >= 0 && bounds.y >= 0;
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* This only returns unique sizes
|
|
126
|
-
*/
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
CanvasDownloadLinks.prototype.definedSizes = function definedSizes() {
|
|
130
|
-
var infoResponse = this.props.infoResponse;
|
|
131
|
-
|
|
132
|
-
if (!(infoResponse && infoResponse.json && infoResponse.json.sizes)) return [];
|
|
133
|
-
|
|
134
|
-
return uniqBy(infoResponse.json.sizes, function (size) {
|
|
135
|
-
return '' + size.width + size.height;
|
|
136
|
-
});
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
CanvasDownloadLinks.prototype.fullImageLink = function fullImageLink() {
|
|
140
|
-
return React.createElement(
|
|
141
|
-
ListItem,
|
|
142
|
-
{ disableGutters: true, divider: true, key: this.fullImageUrl() },
|
|
143
|
-
React.createElement(
|
|
144
|
-
Link,
|
|
145
|
-
{ href: this.fullImageUrl(), rel: 'noopener noreferrer', target: '_blank', variant: 'body1' },
|
|
146
|
-
this.fullImageLabel()
|
|
147
|
-
)
|
|
148
|
-
);
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
CanvasDownloadLinks.prototype.thousandPixelWideLink = function thousandPixelWideLink() {
|
|
152
|
-
var canvas = this.props.canvas;
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
if (canvas.getWidth() < 1000) return '';
|
|
156
|
-
|
|
157
|
-
return React.createElement(
|
|
158
|
-
ListItem,
|
|
159
|
-
{ disableGutters: true, divider: true, key: this.thousandPixelWideImage() },
|
|
160
|
-
React.createElement(
|
|
161
|
-
Link,
|
|
162
|
-
{ href: this.thousandPixelWideImage(), rel: 'noopener noreferrer', target: '_blank', variant: 'body1' },
|
|
163
|
-
this.smallImageLabel()
|
|
164
|
-
)
|
|
165
|
-
);
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
CanvasDownloadLinks.prototype.linksForDefinedSizes = function linksForDefinedSizes() {
|
|
169
|
-
var _this2 = this;
|
|
170
|
-
|
|
171
|
-
return this.definedSizes().map(function (size) {
|
|
172
|
-
return React.createElement(
|
|
173
|
-
ListItem,
|
|
174
|
-
{ disableGutters: true, divider: true, key: '' + size.width + size.height },
|
|
175
|
-
React.createElement(
|
|
176
|
-
Link,
|
|
177
|
-
{ href: _this2.imageUrlForSize(size), rel: 'noopener noreferrer', target: '_blank', variant: 'body1' },
|
|
178
|
-
'Whole image (' + size.width + ' x ' + size.height + 'px)'
|
|
179
|
-
)
|
|
180
|
-
);
|
|
181
|
-
});
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* Returns the rendered component
|
|
186
|
-
*/
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
CanvasDownloadLinks.prototype.render = function render() {
|
|
190
|
-
var _props2 = this.props,
|
|
191
|
-
canvas = _props2.canvas,
|
|
192
|
-
canvasLabel = _props2.canvasLabel,
|
|
193
|
-
classes = _props2.classes;
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
return React.createElement(
|
|
197
|
-
React.Fragment,
|
|
198
|
-
null,
|
|
199
|
-
React.createElement(
|
|
200
|
-
Typography,
|
|
201
|
-
{ noWrap: true, variant: 'h3', className: classes.h3 },
|
|
202
|
-
canvasLabel
|
|
203
|
-
),
|
|
204
|
-
React.createElement(
|
|
205
|
-
List,
|
|
206
|
-
null,
|
|
207
|
-
this.displayCurrentZoomLink() && React.createElement(
|
|
208
|
-
ListItem,
|
|
209
|
-
{ disableGutters: true, divider: true },
|
|
210
|
-
React.createElement(
|
|
211
|
-
Link,
|
|
212
|
-
{ href: this.zoomedImageUrl(), rel: 'noopener noreferrer', target: '_blank', variant: 'body1' },
|
|
213
|
-
this.zoomedImageLabel()
|
|
214
|
-
)
|
|
215
|
-
),
|
|
216
|
-
this.definedSizes().length === 0 && [this.fullImageLink(), this.thousandPixelWideLink()],
|
|
217
|
-
this.definedSizes().length > 0 && this.linksForDefinedSizes(),
|
|
218
|
-
canvas.getRenderings().map(function (rendering) {
|
|
219
|
-
return React.createElement(RenderingDownloadLink, { rendering: rendering, key: rendering.id });
|
|
220
|
-
})
|
|
221
|
-
)
|
|
222
|
-
);
|
|
223
|
-
};
|
|
224
|
-
|
|
225
|
-
return CanvasDownloadLinks;
|
|
226
|
-
}(Component);
|
|
227
|
-
|
|
228
|
-
export { CanvasDownloadLinks as default };
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
CanvasDownloadLinks.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
232
|
-
canvas: PropTypes.shape({
|
|
233
|
-
id: PropTypes.string.isRequired,
|
|
234
|
-
getCanonicalImageUri: PropTypes.func.isRequired,
|
|
235
|
-
getHeight: PropTypes.func.isRequired,
|
|
236
|
-
getRenderings: PropTypes.func.isRequired,
|
|
237
|
-
getWidth: PropTypes.func.isRequired
|
|
238
|
-
}).isRequired,
|
|
239
|
-
canvasLabel: PropTypes.string.isRequired, // canvasLabel is passed because we need access to redux
|
|
240
|
-
classes: PropTypes.shape({
|
|
241
|
-
h3: PropTypes.string
|
|
242
|
-
}).isRequired,
|
|
243
|
-
infoResponse: PropTypes.shape({
|
|
244
|
-
json: PropTypes.shape({
|
|
245
|
-
height: PropTypes.number,
|
|
246
|
-
sizes: PropTypes.arrayOf(PropTypes.shape({ height: PropTypes.number, width: PropTypes.number })),
|
|
247
|
-
width: PropTypes.number
|
|
248
|
-
})
|
|
249
|
-
}).isRequired,
|
|
250
|
-
restrictDownloadOnSizeDefinition: PropTypes.bool.isRequired,
|
|
251
|
-
viewType: PropTypes.string.isRequired,
|
|
252
|
-
windowId: PropTypes.string.isRequired
|
|
253
|
-
} : {};
|
|
@@ -1,64 +0,0 @@
|
|
|
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 List from '@material-ui/core/List';
|
|
10
|
-
import Typography from '@material-ui/core/Typography';
|
|
11
|
-
import RenderingDownloadLink from './RenderingDownloadLink';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* ManifestDownloadLinks ~
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
var ManifestDownloadLinks = function (_Component) {
|
|
18
|
-
_inherits(ManifestDownloadLinks, _Component);
|
|
19
|
-
|
|
20
|
-
function ManifestDownloadLinks() {
|
|
21
|
-
_classCallCheck(this, ManifestDownloadLinks);
|
|
22
|
-
|
|
23
|
-
return _possibleConstructorReturn(this, _Component.apply(this, arguments));
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Returns the rendered component
|
|
28
|
-
*/
|
|
29
|
-
ManifestDownloadLinks.prototype.render = function render() {
|
|
30
|
-
var _props = this.props,
|
|
31
|
-
classes = _props.classes,
|
|
32
|
-
renderings = _props.renderings;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return React.createElement(
|
|
36
|
-
React.Fragment,
|
|
37
|
-
null,
|
|
38
|
-
React.createElement(
|
|
39
|
-
Typography,
|
|
40
|
-
{ variant: 'h3', className: classes.h3 },
|
|
41
|
-
'Other download options'
|
|
42
|
-
),
|
|
43
|
-
React.createElement(
|
|
44
|
-
List,
|
|
45
|
-
null,
|
|
46
|
-
renderings.map(function (rendering) {
|
|
47
|
-
return React.createElement(RenderingDownloadLink, { rendering: rendering, key: rendering.id });
|
|
48
|
-
})
|
|
49
|
-
)
|
|
50
|
-
);
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
return ManifestDownloadLinks;
|
|
54
|
-
}(Component);
|
|
55
|
-
|
|
56
|
-
export { ManifestDownloadLinks as default };
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
ManifestDownloadLinks.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
60
|
-
classes: PropTypes.shape({
|
|
61
|
-
h3: PropTypes.string
|
|
62
|
-
}).isRequired,
|
|
63
|
-
renderings: PropTypes.array.isRequired // eslint-disable-line react/forbid-prop-types
|
|
64
|
-
} : {};
|
|
@@ -1,190 +0,0 @@
|
|
|
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';
|
|
21
|
-
import ManifestDownloadLinks from './ManifestDownloadLinks';
|
|
22
|
-
|
|
23
|
-
var mapDispatchToProps = function mapDispatchToProps(dispatch, _ref) {
|
|
24
|
-
var windowId = _ref.windowId;
|
|
25
|
-
return {
|
|
26
|
-
closeDialog: function closeDialog() {
|
|
27
|
-
return dispatch({ type: 'CLOSE_WINDOW_DIALOG', windowId: windowId });
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
var mapStateToProps = function mapStateToProps(state, _ref2) {
|
|
33
|
-
var windowId = _ref2.windowId;
|
|
34
|
-
return {
|
|
35
|
-
canvases: getVisibleCanvases(state, { windowId: windowId }),
|
|
36
|
-
canvasLabel: function canvasLabel(canvasId) {
|
|
37
|
-
return getCanvasLabel(state, { canvasId: canvasId, windowId: windowId });
|
|
38
|
-
},
|
|
39
|
-
containerId: getContainerId(state),
|
|
40
|
-
infoResponse: function infoResponse(canvasId) {
|
|
41
|
-
return selectInfoResponse(state, { windowId: windowId, canvasId: canvasId }) || {};
|
|
42
|
-
},
|
|
43
|
-
manifest: getManifestoInstance(state, { windowId: windowId }),
|
|
44
|
-
restrictDownloadOnSizeDefinition: state.config.miradorDownloadPlugin && state.config.miradorDownloadPlugin.restrictDownloadOnSizeDefinition,
|
|
45
|
-
open: state.windowDialogs[windowId] && state.windowDialogs[windowId].openDialog === 'download',
|
|
46
|
-
viewType: getWindowViewType(state, { windowId: windowId })
|
|
47
|
-
};
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* 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
|
-
|
|
65
|
-
if (!(manifest && manifest.getSequences() && manifest.getSequences()[0] && manifest.getSequences()[0].getRenderings())) return [];
|
|
66
|
-
|
|
67
|
-
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
|
-
|
|
183
|
-
export default {
|
|
184
|
-
target: 'Window',
|
|
185
|
-
mode: 'add',
|
|
186
|
-
name: 'MiradorDownloadDialog',
|
|
187
|
-
component: withStyles(styles)(MiradorDownloadDialog),
|
|
188
|
-
mapDispatchToProps: mapDispatchToProps,
|
|
189
|
-
mapStateToProps: mapStateToProps
|
|
190
|
-
};
|
|
@@ -1,57 +0,0 @@
|
|
|
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 Link from '@material-ui/core/Link';
|
|
10
|
-
import ListItem from '@material-ui/core/ListItem';
|
|
11
|
-
import ListItemText from '@material-ui/core/ListItemText';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* RenderingDownloadLink ~
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
var RenderingDownloadLink = function (_Component) {
|
|
18
|
-
_inherits(RenderingDownloadLink, _Component);
|
|
19
|
-
|
|
20
|
-
function RenderingDownloadLink() {
|
|
21
|
-
_classCallCheck(this, RenderingDownloadLink);
|
|
22
|
-
|
|
23
|
-
return _possibleConstructorReturn(this, _Component.apply(this, arguments));
|
|
24
|
-
}
|
|
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;
|
|
46
|
-
}(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
|
-
} : {};
|
package/es/index.js
DELETED