@ndla/image-search 6.0.123 → 6.0.125

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.
@@ -13,35 +13,30 @@ var _imageUtil = require("./util/imageUtil");
13
13
  var _ImageMeta = _interopRequireDefault(require("./ImageMeta"));
14
14
  var _jsxRuntime = require("@emotion/react/jsx-runtime");
15
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
17
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
18
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
19
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
20
- function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
21
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } /**
22
- * Copyright (c) 2017-present, NDLA.
23
- *
24
- * This source code is licensed under the GPLv3 license found in the
25
- * LICENSE file in the root directory of this source tree.
26
- *
27
- */
28
- var PreviewImage = function PreviewImage(_ref) {
29
- var _image$tags$tags, _image$title$title, _image$alttext$alttex, _image$caption$captio;
30
- var image = _ref.image,
31
- onSelectImage = _ref.onSelectImage,
32
- useImageTitle = _ref.useImageTitle,
33
- showCheckbox = _ref.showCheckbox,
34
- checkboxLabel = _ref.checkboxLabel;
35
- var _useTranslation = (0, _reactI18next.useTranslation)(),
36
- t = _useTranslation.t;
37
- var _useState = (0, _react.useState)(false),
38
- _useState2 = _slicedToArray(_useState, 2),
39
- saveAsMetaImage = _useState2[0],
40
- setSaveAsMetaImage = _useState2[1];
41
- var tags = (_image$tags$tags = image.tags.tags) !== null && _image$tags$tags !== void 0 ? _image$tags$tags : [];
42
- var title = (_image$title$title = image.title.title) !== null && _image$title$title !== void 0 ? _image$title$title : '';
43
- var altText = (_image$alttext$alttex = image.alttext.alttext) !== null && _image$alttext$alttex !== void 0 ? _image$alttext$alttex : '';
44
- var caption = (_image$caption$captio = image.caption.caption) !== null && _image$caption$captio !== void 0 ? _image$caption$captio : '';
16
+ /**
17
+ * Copyright (c) 2017-present, NDLA.
18
+ *
19
+ * This source code is licensed under the GPLv3 license found in the
20
+ * LICENSE file in the root directory of this source tree.
21
+ *
22
+ */
23
+
24
+ const PreviewImage = _ref => {
25
+ let {
26
+ image,
27
+ onSelectImage,
28
+ useImageTitle,
29
+ showCheckbox,
30
+ checkboxLabel
31
+ } = _ref;
32
+ const {
33
+ t
34
+ } = (0, _reactI18next.useTranslation)();
35
+ const [saveAsMetaImage, setSaveAsMetaImage] = (0, _react.useState)(false);
36
+ const tags = image.tags.tags ?? [];
37
+ const title = image.title.title ?? '';
38
+ const altText = image.alttext.alttext ?? '';
39
+ const caption = image.caption.caption ?? '';
45
40
  return (0, _jsxRuntime.jsxs)("div", {
46
41
  className: "image-preview",
47
42
  children: [(0, _jsxRuntime.jsx)("div", {
@@ -63,9 +58,7 @@ var PreviewImage = function PreviewImage(_ref) {
63
58
  className: "copyright-author",
64
59
  children: (0, _jsxRuntime.jsx)("span", {
65
60
  className: "text",
66
- children: image.copyright.creators.map(function (creator) {
67
- return creator.name;
68
- }).join(', ')
61
+ children: image.copyright.creators.map(creator => creator.name).join(', ')
69
62
  })
70
63
  }) : null, (0, _jsxRuntime.jsx)("div", {
71
64
  className: "info",
@@ -77,19 +70,19 @@ var PreviewImage = function PreviewImage(_ref) {
77
70
  className: "info",
78
71
  children: (0, _jsxRuntime.jsx)("span", {
79
72
  className: "text",
80
- children: "".concat(t('image.caption'), ": ").concat(caption)
73
+ children: `${t('image.caption')}: ${caption}`
81
74
  })
82
75
  }), (0, _jsxRuntime.jsx)("div", {
83
76
  className: "info",
84
77
  children: (0, _jsxRuntime.jsx)("span", {
85
78
  className: "text",
86
- children: "".concat(t('image.altText'), ": ").concat(altText)
79
+ children: `${t('image.altText')}: ${altText}`
87
80
  })
88
81
  }), (0, _jsxRuntime.jsx)("div", {
89
82
  className: "info",
90
83
  children: (0, _jsxRuntime.jsx)("span", {
91
84
  className: "text",
92
- children: "".concat(t('image.modelReleased.label'), ": ").concat(t('image.modelReleased.' + image.modelRelease))
85
+ children: `${t('image.modelReleased.label')}: ${t('image.modelReleased.' + image.modelRelease)}`
93
86
  })
94
87
  }), (0, _jsxRuntime.jsx)(_ImageMeta.default, {
95
88
  contentType: image.image.contentType,
@@ -97,27 +90,19 @@ var PreviewImage = function PreviewImage(_ref) {
97
90
  imageDimensions: image.image.dimensions
98
91
  }), (0, _jsxRuntime.jsx)("div", {
99
92
  className: "tags",
100
- children: tags.map(function (tag) {
101
- return (0, _jsxRuntime.jsx)("span", {
102
- className: "tag_item",
103
- children: "#".concat(tag)
104
- }, (0, _util.uuid)());
105
- })
93
+ children: tags.map(tag => (0, _jsxRuntime.jsx)("span", {
94
+ className: "tag_item",
95
+ children: `#${tag}`
96
+ }, (0, _util.uuid)()))
106
97
  }), (0, _jsxRuntime.jsx)(_button.ButtonV2, {
107
98
  "data-testid": "use-image",
108
- onClick: function onClick() {
109
- return onSelectImage(image, saveAsMetaImage);
110
- },
99
+ onClick: () => onSelectImage(image, saveAsMetaImage),
111
100
  children: useImageTitle
112
101
  }), showCheckbox && (0, _jsxRuntime.jsx)("div", {
113
102
  children: (0, _jsxRuntime.jsx)(_forms.CheckboxItem, {
114
103
  label: checkboxLabel,
115
104
  checked: saveAsMetaImage,
116
- onChange: function onChange() {
117
- return setSaveAsMetaImage(function (prev) {
118
- return !prev;
119
- });
120
- }
105
+ onChange: () => setSaveAsMetaImage(prev => !prev)
121
106
  })
122
107
  })]
123
108
  }), (0, _jsxRuntime.jsx)("div", {
@@ -125,5 +110,4 @@ var PreviewImage = function PreviewImage(_ref) {
125
110
  })]
126
111
  });
127
112
  };
128
- var _default = PreviewImage;
129
- exports.default = _default;
113
+ var _default = exports.default = PreviewImage;
package/lib/index.js CHANGED
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  Object.defineProperty(exports, "ImageMeta", {
7
7
  enumerable: true,
8
- get: function get() {
8
+ get: function () {
9
9
  return _ImageMeta.default;
10
10
  }
11
11
  });
@@ -13,5 +13,4 @@ exports.default = void 0;
13
13
  var _ImageSearch = _interopRequireDefault(require("./ImageSearch"));
14
14
  var _ImageMeta = _interopRequireDefault(require("./ImageMeta"));
15
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
- var _default = _ImageSearch.default;
17
- exports.default = _default;
16
+ var _default = exports.default = _ImageSearch.default;
@@ -15,11 +15,7 @@ exports.getSrcSets = exports.getPreviewSrcSets = void 0;
15
15
  /* - Source sets for gallery search is retina-display optimized
16
16
  - Based on: https://www.smashingmagazine.com/2014/05/responsive-images-done-right-guide-picture-srcset/ */
17
17
 
18
- var getSrcSets = function getSrcSets(imageUrl) {
19
- return ["".concat(imageUrl, "?width=1440 1440w"), "".concat(imageUrl, "?width=1120 1120w"), "".concat(imageUrl, "?width=1000 1000w"), "".concat(imageUrl, "?width=960 960w"), "".concat(imageUrl, "?width=800 800w"), "".concat(imageUrl, "?width=640 640w"), "".concat(imageUrl, "?width=480 480w"), "".concat(imageUrl, "?width=320 320w")].join(', ');
20
- };
18
+ const getSrcSets = imageUrl => [`${imageUrl}?width=1440 1440w`, `${imageUrl}?width=1120 1120w`, `${imageUrl}?width=1000 1000w`, `${imageUrl}?width=960 960w`, `${imageUrl}?width=800 800w`, `${imageUrl}?width=640 640w`, `${imageUrl}?width=480 480w`, `${imageUrl}?width=320 320w`].join(', ');
21
19
  exports.getSrcSets = getSrcSets;
22
- var getPreviewSrcSets = function getPreviewSrcSets(imageUrl) {
23
- return ["".concat(imageUrl, "?width=480 3x"), "".concat(imageUrl, "?width=320 2x"), "".concat(imageUrl, "?width=160 1x")].join(', ');
24
- };
20
+ const getPreviewSrcSets = imageUrl => [`${imageUrl}?width=480 3x`, `${imageUrl}?width=320 2x`, `${imageUrl}?width=160 1x`].join(', ');
25
21
  exports.getPreviewSrcSets = getPreviewSrcSets;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ndla/image-search",
3
- "version": "6.0.123",
3
+ "version": "6.0.125",
4
4
  "description": "A simple library for searching images from NDLA",
5
5
  "license": "GPL-3.0",
6
6
  "main": "lib/index.js",
@@ -26,12 +26,12 @@
26
26
  "es"
27
27
  ],
28
28
  "dependencies": {
29
- "@ndla/button": "^12.0.14",
29
+ "@ndla/button": "^12.0.15",
30
30
  "@ndla/core": "^4.2.7",
31
- "@ndla/forms": "^5.2.1",
31
+ "@ndla/forms": "^5.2.3",
32
32
  "@ndla/icons": "^4.2.2",
33
- "@ndla/pager": "^2.2.39",
34
- "@ndla/ui": "^50.1.0",
33
+ "@ndla/pager": "^2.2.40",
34
+ "@ndla/ui": "^50.1.2",
35
35
  "@ndla/util": "^4.0.1",
36
36
  "pretty-bytes": "^5.6.0"
37
37
  },
@@ -41,10 +41,15 @@
41
41
  "peerDependencies": {
42
42
  "@emotion/react": "^11.10.4",
43
43
  "@emotion/styled": "^11.10.4",
44
- "react": ">= 16.8.0"
44
+ "i18next": ">= 23.0.0",
45
+ "lodash": ">= 4.0.0",
46
+ "react": ">= 16.8.0",
47
+ "react-dom": ">= 16.8.0",
48
+ "react-i18next": ">= 13.0.0",
49
+ "react-router-dom": ">= 6.0.0"
45
50
  },
46
51
  "publishConfig": {
47
52
  "access": "public"
48
53
  },
49
- "gitHead": "252018f46b2084d45d08bf86072787257cdb0348"
54
+ "gitHead": "a3aad57d56edabe22d550adb5fda8af5ab6c8b6f"
50
55
  }