@harvard-lts/mirador-hide-nav-plugin 1.0.0 → 1.0.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 CHANGED
@@ -1,2 +1,42 @@
1
1
  # mirador-hide-nav-plugin
2
2
  A Mirador 3 plugin that hides viewer navigation manifest-defined single images.
3
+
4
+ ## Requirements
5
+
6
+ - [NVM](https://github.com/nvm-sh/nvm)
7
+
8
+ ## Setup
9
+
10
+ 1. Run `nvm use` to ensure your version of matches that in the `.nvmrc` file
11
+ 2. Run `npm i` to install dependencies
12
+ 3. Use one of the [NPM scripts](#npm-scripts) to perform the actions described below.
13
+
14
+ ## NPM scripts
15
+
16
+ The following are some useful scripts can be ran using `npm run <script>`. A full list can be seen in [package.json](./package.json)
17
+
18
+ | Script | Description |
19
+ | ------- | -------------------------------------------------------------------------------------------------------------------------- |
20
+ | `clean` | Removes the `dist` directories |
21
+ | `build` | Builds the source files into the `./dist` directory |
22
+ | `serve` | Runs a local web server where the plugin can be viewed in a vanilla Mirador instance (helpful for testing and development) |
23
+ | `test` | Runs the automated test suites
24
+
25
+ ## Installing in Mirador
26
+
27
+ The `mirador-hide-nav-plugin` requires an instance of Mirador 3. Visit the [Mirador wiki](https://github.com/ProjectMirador/mirador/wiki) to learn how to [install an existing plugin](https://github.com/ProjectMirador/mirador/wiki/Mirador-3-plugins#installing-an-existing-plugin) and for additional information about plugins.
28
+
29
+ Package you will need to install:
30
+
31
+ ```bash
32
+ npm i @harvard-lts/mirador-hide-nav-plugin
33
+ ```
34
+
35
+ ## Contribute
36
+ Mirador's development, design, and maintenance is driven by community needs and ongoing feedback and discussion. Join us at our regularly scheduled community calls, on [IIIF slack #mirador](http://bit.ly/iiif-slack), or the [mirador-tech](https://groups.google.com/forum/#!forum/mirador-tech) and [iiif-discuss](https://groups.google.com/forum/#!forum/iiif-discuss) mailing lists. To suggest features, report bugs, and clarify usage, please submit a GitHub issue.
37
+
38
+ [build-badge]: https://img.shields.io/travis/projectmirador/mirador-share-plugin/master.png?style=flat-square
39
+ [build]: https://travis-ci.org/projectmirador/mirador-share-plugin
40
+
41
+ [npm-badge]: https://img.shields.io/npm/v/mirador-share-plugin.png?style=flat-square
42
+ [npm]: https://www.npmjs.org/package/mirador-share-plugin
@@ -0,0 +1,132 @@
1
+ import { Component } from 'react';
2
+ import { getManifestoInstance } from 'mirador/dist/es/src/state/selectors/manifests';
3
+ import { jsx, Fragment } from 'react/jsx-runtime';
4
+
5
+ function _assertThisInitialized(e) {
6
+ if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
7
+ return e;
8
+ }
9
+ function _callSuper(t, o, e) {
10
+ return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e));
11
+ }
12
+ function _classCallCheck(a, n) {
13
+ if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
14
+ }
15
+ function _defineProperties(e, r) {
16
+ for (var t = 0; t < r.length; t++) {
17
+ var o = r[t];
18
+ o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);
19
+ }
20
+ }
21
+ function _createClass(e, r, t) {
22
+ return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
23
+ writable: !1
24
+ }), e;
25
+ }
26
+ function _getPrototypeOf(t) {
27
+ return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
28
+ return t.__proto__ || Object.getPrototypeOf(t);
29
+ }, _getPrototypeOf(t);
30
+ }
31
+ function _inherits(t, e) {
32
+ if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
33
+ t.prototype = Object.create(e && e.prototype, {
34
+ constructor: {
35
+ value: t,
36
+ writable: !0,
37
+ configurable: !0
38
+ }
39
+ }), Object.defineProperty(t, "prototype", {
40
+ writable: !1
41
+ }), e && _setPrototypeOf(t, e);
42
+ }
43
+ function _isNativeReflectConstruct() {
44
+ try {
45
+ var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
46
+ } catch (t) {}
47
+ return (_isNativeReflectConstruct = function () {
48
+ return !!t;
49
+ })();
50
+ }
51
+ function _possibleConstructorReturn(t, e) {
52
+ if (e && ("object" == typeof e || "function" == typeof e)) return e;
53
+ if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
54
+ return _assertThisInitialized(t);
55
+ }
56
+ function _setPrototypeOf(t, e) {
57
+ return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
58
+ return t.__proto__ = e, t;
59
+ }, _setPrototypeOf(t, e);
60
+ }
61
+ function _toPrimitive(t, r) {
62
+ if ("object" != typeof t || !t) return t;
63
+ var e = t[Symbol.toPrimitive];
64
+ if (void 0 !== e) {
65
+ var i = e.call(t, r || "default");
66
+ if ("object" != typeof i) return i;
67
+ throw new TypeError("@@toPrimitive must return a primitive value.");
68
+ }
69
+ return ("string" === r ? String : Number)(t);
70
+ }
71
+ function _toPropertyKey(t) {
72
+ var i = _toPrimitive(t, "string");
73
+ return "symbol" == typeof i ? i : i + "";
74
+ }
75
+
76
+ var hideViewerNavigation = /*#__PURE__*/function (_Component) {
77
+ function hideViewerNavigation() {
78
+ _classCallCheck(this, hideViewerNavigation);
79
+ return _callSuper(this, hideViewerNavigation, arguments);
80
+ }
81
+ _inherits(hideViewerNavigation, _Component);
82
+ return _createClass(hideViewerNavigation, [{
83
+ key: "viewingHint",
84
+ value: function viewingHint() {
85
+ var manifest = this.props.manifest;
86
+ if (!(manifest && manifest.getSequences() && manifest.getSequences()[0] && manifest.getSequences()[0].getProperty('viewingHint'))) return [''];
87
+ return manifest.getSequences()[0].getProperty('viewingHint');
88
+ }
89
+ }, {
90
+ key: "render",
91
+ value: function render() {
92
+ return /*#__PURE__*/jsx(Fragment, {});
93
+ }
94
+ }, {
95
+ key: "componentDidUpdate",
96
+ value: function componentDidUpdate() {
97
+ var viewingHint = this.viewingHint();
98
+ if (viewingHint == 'individuals') {
99
+ window.document.querySelectorAll('.mirador-osd-info').forEach(function (elem) {
100
+ return elem.remove();
101
+ });
102
+ window.document.querySelectorAll('.mirador-osd-navigation').forEach(function (elem) {
103
+ return elem.remove();
104
+ });
105
+ window.document.querySelectorAll('[class*="Connect(WithPlugins(ZoomControls))-divider-"]').forEach(function (elem) {
106
+ return elem.remove();
107
+ });
108
+ }
109
+ }
110
+ }]);
111
+ }(Component);
112
+ var mapStateToProps = function mapStateToProps(state, _ref) {
113
+ var windowId = _ref.windowId;
114
+ return {
115
+ manifestId: (getManifestoInstance(state, {
116
+ windowId: windowId
117
+ }) || {}).id,
118
+ manifest: getManifestoInstance(state, {
119
+ windowId: windowId
120
+ })
121
+ };
122
+ };
123
+ var hideViewerNavigationPlugin = {
124
+ target: 'Window',
125
+ mode: 'add',
126
+ component: hideViewerNavigation,
127
+ mapStateToProps: mapStateToProps
128
+ };
129
+
130
+ var index = [hideViewerNavigationPlugin];
131
+
132
+ export { index as default, hideViewerNavigationPlugin };
package/package.json CHANGED
@@ -1,40 +1,53 @@
1
1
  {
2
2
  "name": "@harvard-lts/mirador-hide-nav-plugin",
3
- "version": "1.0.0",
4
- "description": "mirador-hide-nav-plugin React component",
5
- "main": "lib/index.js",
6
- "module": "es/index.js",
3
+ "license": "Apache-2.0",
4
+ "repository": "https://github.com/harvard-lts/mirador-hide-nav-plugin.git",
5
+ "keywords": [
6
+ "react-component"
7
+ ],
8
+ "version": "1.0.2",
9
+ "description": "mirador-analytics-plugin React component",
10
+ "module": "dist/es/index.js",
7
11
  "files": [
8
- "css",
9
- "es",
10
- "lib",
11
- "umd"
12
+ "dist"
12
13
  ],
13
14
  "scripts": {
14
- "build": "nwb build-react-component",
15
- "clean": "nwb clean-module && nwb clean-demo",
15
+ "clean": "rm -rf ./dist && rm -rf ./demo/dist",
16
+ "prebuild": "npm run clean",
16
17
  "prepublishOnly": "npm run build",
17
- "start": "nwb serve-react-demo",
18
- "test": "nwb test-react",
19
- "test:coverage": "nwb test-react --coverage",
20
- "test:watch": "nwb test-react --server"
21
- },
22
- "peerDependencies": {
23
- "mirador": "^3.3.0",
24
- "react": "16.x",
25
- "react-dom": "16.x"
18
+ "build": "run-p build:es",
19
+ "build:es": "rollup -c",
20
+ "serve": "webpack serve --mode development --open",
21
+ "test": "jest",
22
+ "test:coverage": "jest --coverage",
23
+ "test:watch": "jest --watch"
26
24
  },
27
- "devDependencies": {
28
- "mirador": "^3.3.0",
29
- "nwb": "0.25.x",
25
+ "dependencies": {
26
+ "jquery": "^3.7.0",
27
+ "prop-types": "^15.8.1",
30
28
  "react": "^16.14.0",
31
29
  "react-dom": "^16.14.0"
32
30
  },
33
- "author": "",
34
- "homepage": "",
35
- "license": "MIT",
36
- "repository": "",
37
- "keywords": [
38
- "react-component"
39
- ]
31
+ "devDependencies": {
32
+ "@babel/cli": "^7.26.4",
33
+ "@babel/core": "^7.26.0",
34
+ "@babel/preset-env": "^7.21.4",
35
+ "@babel/preset-react": "^7.18.6",
36
+ "@rollup/plugin-babel": "^6.0.3",
37
+ "@testing-library/jest-dom": "^5.16.5",
38
+ "@testing-library/react": "^12.0.0",
39
+ "babel-jest": "^29.7.0",
40
+ "babel-loader": "^9.1.2",
41
+ "jest": "^29.7.0",
42
+ "jest-environment-jsdom": "^29.7.0",
43
+ "mirador": "^3.4.3",
44
+ "npm-run-all": "^4.1.5",
45
+ "rollup": "^3.29.5",
46
+ "url": "^0.11.0",
47
+ "webpack": "^5.94.0",
48
+ "webpack-cli": "^5.1.4",
49
+ "webpack-dev-server": "^5.2.0",
50
+ "webpack-node-externals": "^3.0.0",
51
+ "whatwg-fetch": "^3.6.2"
52
+ }
40
53
  }
@@ -1,63 +0,0 @@
1
- function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
2
-
3
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
4
-
5
- import React, { Component } from 'react';
6
- import { getManifestoInstance } from 'mirador/dist/es/src/state/selectors/manifests';
7
-
8
- var hideViewerNavigation = /*#__PURE__*/function (_Component) {
9
- _inheritsLoose(hideViewerNavigation, _Component);
10
-
11
- function hideViewerNavigation() {
12
- return _Component.apply(this, arguments) || this;
13
- }
14
-
15
- var _proto = hideViewerNavigation.prototype;
16
-
17
- _proto.viewingHint = function viewingHint() {
18
- var manifest = this.props.manifest;
19
- if (!(manifest && manifest.getSequences() && manifest.getSequences()[0] && manifest.getSequences()[0].getProperty('viewingHint'))) return [''];
20
- return manifest.getSequences()[0].getProperty('viewingHint');
21
- };
22
-
23
- _proto.render = function render() {
24
- return /*#__PURE__*/React.createElement(React.Fragment, null);
25
- };
26
-
27
- _proto.componentDidUpdate = function componentDidUpdate() {
28
- var viewingHint = this.viewingHint();
29
-
30
- if (viewingHint == 'individuals') {
31
- window.document.querySelectorAll('.mirador-osd-info').forEach(function (elem) {
32
- return elem.remove();
33
- });
34
- window.document.querySelectorAll('.mirador-osd-navigation').forEach(function (elem) {
35
- return elem.remove();
36
- });
37
- window.document.querySelectorAll('[class*="Connect(WithPlugins(ZoomControls))-divider-"]').forEach(function (elem) {
38
- return elem.remove();
39
- });
40
- }
41
- };
42
-
43
- return hideViewerNavigation;
44
- }(Component);
45
-
46
- var mapStateToProps = function mapStateToProps(state, _ref) {
47
- var windowId = _ref.windowId;
48
- return {
49
- manifestId: (getManifestoInstance(state, {
50
- windowId: windowId
51
- }) || {}).id,
52
- manifest: getManifestoInstance(state, {
53
- windowId: windowId
54
- })
55
- };
56
- };
57
-
58
- export default {
59
- target: 'Window',
60
- mode: 'add',
61
- component: hideViewerNavigation,
62
- mapStateToProps: mapStateToProps
63
- };
package/es/index.js DELETED
@@ -1,3 +0,0 @@
1
- import hideViewerNavigationPlugin from './hideViewerNavigationPlugin';
2
- export { hideViewerNavigationPlugin };
3
- export default [hideViewerNavigationPlugin];
@@ -1,75 +0,0 @@
1
- "use strict";
2
-
3
- exports.__esModule = true;
4
- exports["default"] = void 0;
5
-
6
- var _react = _interopRequireWildcard(require("react"));
7
-
8
- var _manifests = require("mirador/dist/es/src/state/selectors/manifests");
9
-
10
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
11
-
12
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13
-
14
- function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
15
-
16
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
17
-
18
- var hideViewerNavigation = /*#__PURE__*/function (_Component) {
19
- _inheritsLoose(hideViewerNavigation, _Component);
20
-
21
- function hideViewerNavigation() {
22
- return _Component.apply(this, arguments) || this;
23
- }
24
-
25
- var _proto = hideViewerNavigation.prototype;
26
-
27
- _proto.viewingHint = function viewingHint() {
28
- var manifest = this.props.manifest;
29
- if (!(manifest && manifest.getSequences() && manifest.getSequences()[0] && manifest.getSequences()[0].getProperty('viewingHint'))) return [''];
30
- return manifest.getSequences()[0].getProperty('viewingHint');
31
- };
32
-
33
- _proto.render = function render() {
34
- return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null);
35
- };
36
-
37
- _proto.componentDidUpdate = function componentDidUpdate() {
38
- var viewingHint = this.viewingHint();
39
-
40
- if (viewingHint == 'individuals') {
41
- window.document.querySelectorAll('.mirador-osd-info').forEach(function (elem) {
42
- return elem.remove();
43
- });
44
- window.document.querySelectorAll('.mirador-osd-navigation').forEach(function (elem) {
45
- return elem.remove();
46
- });
47
- window.document.querySelectorAll('[class*="Connect(WithPlugins(ZoomControls))-divider-"]').forEach(function (elem) {
48
- return elem.remove();
49
- });
50
- }
51
- };
52
-
53
- return hideViewerNavigation;
54
- }(_react.Component);
55
-
56
- var mapStateToProps = function mapStateToProps(state, _ref) {
57
- var windowId = _ref.windowId;
58
- return {
59
- manifestId: ((0, _manifests.getManifestoInstance)(state, {
60
- windowId: windowId
61
- }) || {}).id,
62
- manifest: (0, _manifests.getManifestoInstance)(state, {
63
- windowId: windowId
64
- })
65
- };
66
- };
67
-
68
- var _default = {
69
- target: 'Window',
70
- mode: 'add',
71
- component: hideViewerNavigation,
72
- mapStateToProps: mapStateToProps
73
- };
74
- exports["default"] = _default;
75
- module.exports = exports.default;
package/lib/index.js DELETED
@@ -1,13 +0,0 @@
1
- "use strict";
2
-
3
- exports.__esModule = true;
4
- exports["default"] = void 0;
5
-
6
- var _hideViewerNavigationPlugin = _interopRequireDefault(require("./hideViewerNavigationPlugin"));
7
-
8
- exports.hideViewerNavigationPlugin = _hideViewerNavigationPlugin["default"];
9
-
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
11
-
12
- var _default = [_hideViewerNavigationPlugin["default"]];
13
- exports["default"] = _default;