@ndla/ui 45.0.17 → 46.0.0

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.
Files changed (79) hide show
  1. package/es/Article/Article.js +3 -3
  2. package/es/AudioPlayer/index.js +0 -2
  3. package/es/Embed/conceptComponents.js +15 -8
  4. package/es/Figure/Figure.js +11 -89
  5. package/es/Figure/index.js +1 -3
  6. package/es/Notion/index.js +1 -3
  7. package/es/all.css +1 -1
  8. package/es/index.js +3 -4
  9. package/lib/Article/Article.js +3 -3
  10. package/lib/AudioPlayer/index.d.ts +0 -2
  11. package/lib/AudioPlayer/index.js +0 -7
  12. package/lib/Embed/conceptComponents.js +17 -10
  13. package/lib/Figure/Figure.d.ts +0 -38
  14. package/lib/Figure/Figure.js +20 -96
  15. package/lib/Figure/index.d.ts +1 -3
  16. package/lib/Figure/index.js +2 -17
  17. package/lib/Notion/index.d.ts +0 -4
  18. package/lib/Notion/index.js +0 -14
  19. package/lib/all.css +1 -1
  20. package/lib/index.d.ts +3 -5
  21. package/lib/index.js +1 -32
  22. package/package.json +18 -22
  23. package/src/Article/Article.tsx +1 -1
  24. package/src/AudioPlayer/AudiPlayer.stories.tsx +88 -0
  25. package/src/AudioPlayer/index.ts +0 -2
  26. package/src/Embed/IframeEmbed.stories.tsx +15 -0
  27. package/src/Embed/ImageEmbed.stories.tsx +169 -2
  28. package/src/Embed/RelatedContentEmbed.stories.tsx +438 -0
  29. package/src/Embed/conceptComponents.tsx +13 -1
  30. package/src/Figure/Figure.tsx +1 -120
  31. package/src/Figure/index.ts +1 -3
  32. package/src/Notion/index.ts +0 -4
  33. package/src/index.ts +3 -13
  34. package/src/main.scss +0 -1
  35. package/es/Animation/Fade.js +0 -62
  36. package/es/Animation/index.js +0 -1
  37. package/es/AudioPlayer/initAudioPlayers.js +0 -60
  38. package/es/Dialog/Dialog.js +0 -70
  39. package/es/Dialog/index.js +0 -11
  40. package/es/Figure/FigureLicense.js +0 -72
  41. package/es/Figure/FigureLicenseDialog.js +0 -54
  42. package/es/Notion/ConceptNotion.js +0 -135
  43. package/es/Notion/FigureNotion.js +0 -93
  44. package/es/Notion/NotionVisualElement.js +0 -68
  45. package/es/utils/createUniversalPortal.js +0 -25
  46. package/lib/Animation/Fade.d.ts +0 -17
  47. package/lib/Animation/Fade.js +0 -70
  48. package/lib/Animation/index.d.ts +0 -1
  49. package/lib/Animation/index.js +0 -13
  50. package/lib/AudioPlayer/initAudioPlayers.d.ts +0 -11
  51. package/lib/AudioPlayer/initAudioPlayers.js +0 -69
  52. package/lib/Dialog/Dialog.d.ts +0 -23
  53. package/lib/Dialog/Dialog.js +0 -75
  54. package/lib/Dialog/index.d.ts +0 -10
  55. package/lib/Dialog/index.js +0 -22
  56. package/lib/Figure/FigureLicense.d.ts +0 -33
  57. package/lib/Figure/FigureLicense.js +0 -76
  58. package/lib/Figure/FigureLicenseDialog.d.ts +0 -29
  59. package/lib/Figure/FigureLicenseDialog.js +0 -57
  60. package/lib/Notion/ConceptNotion.d.ts +0 -24
  61. package/lib/Notion/ConceptNotion.js +0 -141
  62. package/lib/Notion/FigureNotion.d.ts +0 -27
  63. package/lib/Notion/FigureNotion.js +0 -97
  64. package/lib/Notion/NotionVisualElement.d.ts +0 -22
  65. package/lib/Notion/NotionVisualElement.js +0 -75
  66. package/lib/utils/createUniversalPortal.d.ts +0 -9
  67. package/lib/utils/createUniversalPortal.js +0 -32
  68. package/src/Animation/Fade.tsx +0 -46
  69. package/src/Animation/index.ts +0 -1
  70. package/src/AudioPlayer/initAudioPlayers.tsx +0 -57
  71. package/src/Dialog/Dialog.tsx +0 -80
  72. package/src/Dialog/component.dialog.scss +0 -144
  73. package/src/Dialog/index.ts +0 -13
  74. package/src/Figure/FigureLicense.tsx +0 -75
  75. package/src/Figure/FigureLicenseDialog.tsx +0 -51
  76. package/src/Notion/ConceptNotion.tsx +0 -170
  77. package/src/Notion/FigureNotion.tsx +0 -104
  78. package/src/Notion/NotionVisualElement.tsx +0 -80
  79. package/src/utils/createUniversalPortal.tsx +0 -23
@@ -1,62 +0,0 @@
1
- /**
2
- * Copyright (c) 2022-present, NDLA.
3
- *
4
- * This source code is licensed under the GPLv3 license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- */
8
-
9
- import { useMemo } from 'react';
10
- import { AnimatePresence, LazyMotion, m, domAnimation } from 'framer-motion';
11
- import uniqueId from 'lodash/uniqueId';
12
- import { jsx as _jsx } from "@emotion/react/jsx-runtime";
13
- var animations = function animations(duration, delayIn, delayOut) {
14
- return {
15
- open: {
16
- opacity: 1,
17
- transition: {
18
- delay: delayIn / 1000,
19
- ease: 'easeInOut',
20
- duration: duration / 1000
21
- }
22
- },
23
- closed: {
24
- opacity: 0,
25
- transition: {
26
- delay: delayOut / 1000,
27
- ease: 'easeInOut',
28
- duration: duration / 1000
29
- }
30
- }
31
- };
32
- };
33
- var defaultTimeout = 300;
34
- var Fade = function Fade(_ref) {
35
- var show = _ref.show,
36
- _ref$delay = _ref.delay,
37
- delay = _ref$delay === void 0 ? 0 : _ref$delay,
38
- _ref$timeout = _ref.timeout,
39
- timeout = _ref$timeout === void 0 ? defaultTimeout : _ref$timeout,
40
- _ref$exitDelay = _ref.exitDelay,
41
- exitDelay = _ref$exitDelay === void 0 ? 0 : _ref$exitDelay,
42
- children = _ref.children;
43
- var id = useMemo(function () {
44
- return uniqueId();
45
- }, []);
46
- var variants = useMemo(function () {
47
- return animations(timeout, delay, exitDelay);
48
- }, [timeout, delay, exitDelay]);
49
- return _jsx(LazyMotion, {
50
- features: domAnimation,
51
- children: _jsx(AnimatePresence, {
52
- children: show && _jsx(m.div, {
53
- initial: "closed",
54
- animate: "open",
55
- exit: "closed",
56
- variants: variants,
57
- children: children
58
- }, id)
59
- })
60
- });
61
- };
62
- export default Fade;
@@ -1 +0,0 @@
1
- export { default as Fade } from './Fade';
@@ -1,60 +0,0 @@
1
- /**
2
- * Copyright (c) 2021-present, NDLA.
3
- *
4
- * This source code is licensed under the GPLv3 license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- */
8
-
9
- import ReactDOM from 'react-dom';
10
- import shave from 'shave';
11
- import Controls from './Controls';
12
- import SpeechControl from './SpeechControl';
13
- import { jsx as _jsx } from "@emotion/react/jsx-runtime";
14
- export var truncateDescription = function truncateDescription(el, readMoreLabel) {
15
- shave(el, 90, {
16
- character: "... <a href=\"#\" onclick=\"(function(e){e.preventDefault(); const parentNode = e.target.parentNode; parentNode.nextSibling.style.display = 'inline'; parentNode.remove();return false;})(arguments[0]);return false;\">".concat(readMoreLabel, "</a>")
17
- });
18
- };
19
- var forEachElement = function forEachElement(selector, callback) {
20
- var nodeList = document.querySelectorAll(selector);
21
- for (var i = 0; i < nodeList.length; i += 1) {
22
- callback(nodeList[i], i);
23
- }
24
- };
25
- var initAudioPlayers = function initAudioPlayers(locale) {
26
- forEachElement('[data-audio-player]', function (el) {
27
- var src = el.getAttribute('data-src');
28
- var title = el.getAttribute('data-title');
29
- var speech = el.getAttribute('data-speech');
30
- if (src && title) {
31
- if (speech) {
32
- // eslint-disable-next-line react/no-deprecated
33
- ReactDOM.hydrate(_jsx(SpeechControl, {
34
- src: src,
35
- title: title
36
- }), el);
37
- } else {
38
- // eslint-disable-next-line react/no-deprecated
39
- ReactDOM.hydrate(_jsx(Controls, {
40
- src: src,
41
- title: title
42
- }), el);
43
- }
44
- }
45
- });
46
- forEachElement('[data-audio-player-description]', function (el) {
47
- var readMoreLabel = el.getAttribute('data-read-more-text');
48
- truncateDescription(el, readMoreLabel);
49
- });
50
- forEachElement('[data-audio-text-button-id]', function (el) {
51
- var id = el.getAttribute('data-audio-text-button-id');
52
- if (id) {
53
- el.onclick = function () {
54
- var _document, _document$getElementB;
55
- return (_document = document) === null || _document === void 0 ? void 0 : (_document$getElementB = _document.getElementById(id)) === null || _document$getElementB === void 0 ? void 0 : _document$getElementB.toggleAttribute('hidden');
56
- };
57
- }
58
- });
59
- };
60
- export default initAudioPlayers;
@@ -1,70 +0,0 @@
1
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
- var _excluded = ["children", "messages", "id", "labelledby", "label", "modifier", "disablePortal", "hidden", "onClose"];
3
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
5
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
7
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
8
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
9
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
10
- /**
11
- * Copyright (c) 2017-present, NDLA.
12
- *
13
- * This source code is licensed under the GPLv3 license found in the
14
- * LICENSE file in the root directory of this source tree.
15
- *
16
- */
17
-
18
- // N.B These component is used to render static markup serverside
19
- // Any interactivty is added by scripts located in the ndla-article-scripts package
20
-
21
- import BEMHelper from 'react-bem-helper';
22
- import { createUniversalPortal } from '../utils/createUniversalPortal';
23
- import { jsx as _jsx } from "@emotion/react/jsx-runtime";
24
- import { jsxs as _jsxs } from "@emotion/react/jsx-runtime";
25
- var classes = new BEMHelper({
26
- name: 'dialog',
27
- prefix: 'c-'
28
- });
29
- export var Dialog = function Dialog(_ref) {
30
- var children = _ref.children,
31
- _ref$messages = _ref.messages,
32
- messages = _ref$messages === void 0 ? {
33
- close: 'Lukk'
34
- } : _ref$messages,
35
- id = _ref.id,
36
- labelledby = _ref.labelledby,
37
- label = _ref.label,
38
- modifier = _ref.modifier,
39
- _ref$disablePortal = _ref.disablePortal,
40
- disablePortal = _ref$disablePortal === void 0 ? false : _ref$disablePortal,
41
- _ref$hidden = _ref.hidden,
42
- hidden = _ref$hidden === void 0 ? true : _ref$hidden,
43
- onClose = _ref.onClose,
44
- rest = _objectWithoutProperties(_ref, _excluded);
45
- var content = _jsxs("div", _objectSpread(_objectSpread(_objectSpread({}, classes('', modifier)), {}, {
46
- "data-dialog-id": id,
47
- role: "dialog",
48
- "aria-hidden": hidden,
49
- "aria-labelledby": labelledby,
50
- "aria-label": label
51
- }, rest), {}, {
52
- children: [_jsxs("div", _objectSpread(_objectSpread({}, classes('content')), {}, {
53
- children: [_jsx("button", _objectSpread(_objectSpread({}, classes('close')), {}, {
54
- type: "button",
55
- onClick: function onClick() {
56
- if (onClose) {
57
- onClose();
58
- }
59
- },
60
- children: messages.close
61
- })), children]
62
- })), _jsx("div", {
63
- className: "o-backdrop"
64
- })]
65
- }));
66
- if (disablePortal) {
67
- return content;
68
- }
69
- return createUniversalPortal(content, 'body');
70
- };
@@ -1,11 +0,0 @@
1
- /**
2
- * Copyright (c) 2017-present, NDLA.
3
- *
4
- * This source code is licensed under the GPLv3 license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- */
8
-
9
- import { Dialog } from './Dialog';
10
- export { Dialog };
11
- export default Dialog;
@@ -1,72 +0,0 @@
1
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
7
- /**
8
- * Copyright (c) 2018-present, NDLA.
9
- *
10
- * This source code is licensed under the GPLv3 license found in the
11
- * LICENSE file in the root directory of this source tree.
12
- *
13
- */
14
-
15
- // N.B This component is used to render static markup serverside
16
- // Any interactivty is added by scripts located in the ndla-article-scripts package
17
-
18
- import BEMHelper from 'react-bem-helper';
19
- import { uuid } from '@ndla/util';
20
- import { LicenseDescription } from '@ndla/notion';
21
- import { jsx as _jsx } from "@emotion/react/jsx-runtime";
22
- import { jsxs as _jsxs } from "@emotion/react/jsx-runtime";
23
- import { Fragment as _Fragment } from "@emotion/react/jsx-runtime";
24
- export var classLicenses = new BEMHelper({
25
- name: 'figure-license',
26
- prefix: 'c-'
27
- });
28
- export var FigureLicenseCta = function FigureLicenseCta(_ref) {
29
- var children = _ref.children,
30
- messages = _ref.messages,
31
- authors = _ref.authors,
32
- origin = _ref.origin,
33
- title = _ref.title;
34
- return _jsxs("div", _objectSpread(_objectSpread({}, classLicenses('cta-wrapper')), {}, {
35
- children: [_jsxs("ul", _objectSpread(_objectSpread({}, classLicenses('list')), {}, {
36
- children: [title && _jsx("li", _objectSpread(_objectSpread({}, classLicenses('item')), {}, {
37
- children: "".concat(messages.title, ": ").concat(title)
38
- })), authors === null || authors === void 0 ? void 0 : authors.map(function (author) {
39
- return _jsx("li", _objectSpread(_objectSpread({}, classLicenses('item')), {}, {
40
- children: "".concat(author.type, ": ").concat(author.name)
41
- }), uuid());
42
- }), origin && _jsxs("li", _objectSpread(_objectSpread({}, classLicenses('item')), {}, {
43
- children: [messages.source, ":", ' ', origin.startsWith('http') ? _jsx("a", {
44
- href: origin,
45
- target: "_blank",
46
- rel: "noopener noreferrer",
47
- children: origin
48
- }) : origin]
49
- }))]
50
- })), _jsx("div", _objectSpread(_objectSpread({}, classLicenses('cta-block')), {}, {
51
- children: children
52
- }))]
53
- }));
54
- };
55
- export var FigureLicenseByline = function FigureLicenseByline(_ref2) {
56
- var messages = _ref2.messages,
57
- license = _ref2.license,
58
- locale = _ref2.locale;
59
- return _jsxs(_Fragment, {
60
- children: [_jsx(LicenseDescription, {
61
- highlightCC: true,
62
- locale: locale,
63
- messages: messages,
64
- licenseRights: license.rights
65
- }, "byline"), _jsx("a", _objectSpread(_objectSpread({}, classLicenses('link')), {}, {
66
- target: "_blank",
67
- rel: "noopener noreferrer",
68
- href: license.url,
69
- children: license.linkText
70
- }), "link")]
71
- });
72
- };
@@ -1,54 +0,0 @@
1
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
7
- /**
8
- * Copyright (c) 2017-present, NDLA.
9
- *
10
- * This source code is licensed under the GPLv3 license found in the
11
- * LICENSE file in the root directory of this source tree.
12
- *
13
- */
14
-
15
- // N.B This component is used to render static markup serverside
16
- // Any interactivty is added by scripts located in the ndla-article-scripts package
17
-
18
- import Dialog from '../Dialog';
19
- import { classLicenses, FigureLicenseByline, FigureLicenseCta } from './FigureLicense';
20
- import { jsx as _jsx } from "@emotion/react/jsx-runtime";
21
- import { jsxs as _jsxs } from "@emotion/react/jsx-runtime";
22
- export var FigureLicenseDialog = function FigureLicenseDialog(_ref) {
23
- var children = _ref.children,
24
- messages = _ref.messages,
25
- id = _ref.id,
26
- authors = _ref.authors,
27
- origin = _ref.origin,
28
- title = _ref.title,
29
- locale = _ref.locale,
30
- license = _ref.license;
31
- var headingLabelId = "heading-".concat(id);
32
- return _jsx(Dialog, {
33
- id: id,
34
- labelledby: headingLabelId,
35
- messages: messages,
36
- children: _jsxs("div", _objectSpread(_objectSpread({}, classLicenses()), {}, {
37
- children: [_jsx("h1", _objectSpread(_objectSpread({
38
- id: headingLabelId
39
- }, classLicenses('title')), {}, {
40
- children: messages.rulesForUse
41
- })), _jsx(FigureLicenseByline, {
42
- license: license,
43
- messages: messages,
44
- locale: locale
45
- }), _jsx(FigureLicenseCta, {
46
- authors: authors,
47
- title: title,
48
- origin: origin,
49
- messages: messages,
50
- children: children
51
- })]
52
- }))
53
- });
54
- };
@@ -1,135 +0,0 @@
1
- import _styled from "@emotion/styled/base";
2
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
3
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
- 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); }
5
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
6
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
7
- 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; }
8
- /**
9
- * Copyright (c) 2022-present, NDLA.
10
- *
11
- * This source code is licensed under the GPLv3 license found in the
12
- * LICENSE file in the root directory of this source tree. *
13
- */
14
-
15
- import { useEffect } from 'react';
16
- //@ts-ignore
17
- import { initArticleScripts } from '@ndla/article-scripts';
18
- import { useTranslation } from 'react-i18next';
19
- import { breakpoints, mq, spacing } from '@ndla/core';
20
- import { parseMarkdown } from '@ndla/util';
21
- import { getLicenseCredits } from '@ndla/licenses';
22
- import Notion, { NotionDialogContent, NotionDialogText, NotionDialogLicenses } from '@ndla/notion';
23
- import { Notion as UINotion } from '.';
24
- import { NotionImage } from './NotionImage';
25
- import NotionVisualElement from './NotionVisualElement';
26
- import FigureNotion from './FigureNotion';
27
- import { jsx as _jsx } from "@emotion/react/jsx-runtime";
28
- import { jsxs as _jsxs } from "@emotion/react/jsx-runtime";
29
- import { Fragment as _Fragment } from "@emotion/react/jsx-runtime";
30
- var ImageWrapper = /*#__PURE__*/_styled("div", {
31
- target: "ebdyuo10",
32
- label: "ImageWrapper"
33
- })("float:right;padding-left:", spacing.normal, ";position:relative;", mq.range({
34
- until: breakpoints.tabletWide
35
- }), "{width:100%;padding-left:0;}" + (process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkNvbmNlcHROb3Rpb24udHN4Il0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQXdCK0IiLCJmaWxlIjoiQ29uY2VwdE5vdGlvbi50c3giLCJzb3VyY2VzQ29udGVudCI6WyIvKipcbiAqIENvcHlyaWdodCAoYykgMjAyMi1wcmVzZW50LCBORExBLlxuICpcbiAqIFRoaXMgc291cmNlIGNvZGUgaXMgbGljZW5zZWQgdW5kZXIgdGhlIEdQTHYzIGxpY2Vuc2UgZm91bmQgaW4gdGhlXG4gKiBMSUNFTlNFIGZpbGUgaW4gdGhlIHJvb3QgZGlyZWN0b3J5IG9mIHRoaXMgc291cmNlIHRyZWUuICpcbiAqL1xuaW1wb3J0IHN0eWxlZCBmcm9tICdAZW1vdGlvbi9zdHlsZWQnO1xuXG5pbXBvcnQgeyB1c2VFZmZlY3QgfSBmcm9tICdyZWFjdCc7XG4vL0B0cy1pZ25vcmVcbmltcG9ydCB7IGluaXRBcnRpY2xlU2NyaXB0cyB9IGZyb20gJ0BuZGxhL2FydGljbGUtc2NyaXB0cyc7XG5pbXBvcnQgeyB1c2VUcmFuc2xhdGlvbiB9IGZyb20gJ3JlYWN0LWkxOG5leHQnO1xuaW1wb3J0IHsgYnJlYWtwb2ludHMsIG1xLCBzcGFjaW5nIH0gZnJvbSAnQG5kbGEvY29yZSc7XG5pbXBvcnQgeyBwYXJzZU1hcmtkb3duIH0gZnJvbSAnQG5kbGEvdXRpbCc7XG5pbXBvcnQgeyBnZXRMaWNlbnNlQ3JlZGl0cyB9IGZyb20gJ0BuZGxhL2xpY2Vuc2VzJztcbmltcG9ydCBOb3Rpb24sIHsgTm90aW9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IHN1YlRpdGxlPXt0KCdzZWFyY2hQYWdlLnJlc3VsdFR5cGUubm90aW9uc0hlYWRpbmcnKX1cbiAgICAgICAgICAgICAgICBoaWRlQmFzZWxpbmVJY29uXG4gICAgICAgICAgICAgICAgY29udGVudD17XG4gICAgICAgICAgICAgICAgICA8PlxuICAgICAgICAgICAgICAgICAgICA8Tm90aW9uRGlhbG9nQ29udGVudD5cbiAgICAgICAgICAgICAgICAgICAgICB7Y29uY2VwdC52aXN1YWxFbGVtZW50Py5yZXNvdXJjZSA9PT0gJ2ltYWdlJyAmJiBjb25jZXB0LnZpc3VhbEVsZW1lbnQuaW1hZ2UgPyAoXG4gICAgICAgICAgICAgICAgICAgICAgICA8Tm90aW9uVmlzdWFsRWxlbWVudCB2aXN1YWxFbGVtZW50PXtjb25jZXB0LnZpc3VhbEVsZW1lbnR9IGlkPXtub3Rpb25JZH0gZmlndXJlSWQ9e2ZpZ3VyZUlkfSAvPlxuICAgICAgICAgICAgICAgICAgICAgICkgOiB1bmRlZmluZWR9XG4gICAgICAgICAgICAgICAgICAgICAgPE5vdGlvbkRpYWxvZ1RleHQ+e3BhcnNlTWFya2Rvd24oY29uY2VwdC50ZXh0LCAnYm9keScpfTwvTm90aW9uRGlhbG9nVGV4dD5cbiAgICAgICAgICAgICAgICAgICAgPC9Ob3Rpb25EaWFsb2dDb250ZW50PlxuICAgICAgICAgICAgICAgICAgICA8Tm90aW9uRGlhbG9nTGljZW5zZXNcbiAgICAgICAgICAgICAgICAgICAgICBhdXRob3JzPXthdXRob3JzfVxuICAgICAgICAgICAgICAgICAgICAgIGxpY2Vuc2U9e2NvbmNlcHQuY29weXJpZ2h0Py5saWNlbnNlPy5saWNlbnNlID8/ICcnfVxuICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZT17Y29uY2VwdC5zb3VyY2V9XG4gICAgICAgICAgICAgICAgICAgIC8+XG4gICAgICAgICAgICAgICAgICA8Lz5cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgID5cbiAgICAgICAgICAgICAgICB7Y29uY2VwdC52aXN1YWxFbGVtZW50LmltYWdlICYmIChcbiAgICAgICAgICAgICAgICAgIDxOb3Rpb25JbWFnZVxuICAgICAgICAgICAgICAgICAgICB0eXBlPXt0eXBlfVxuICAgICAgICAgICAgICAgICAgICBpZD17dmlzdWFsRWxlbWVudElkfVxuICAgICAgICAgICAgICAgICAgICBzcmM9e2NvbmNlcHQudmlzdWFsRWxlbWVudC5pbWFnZS5zcmN9XG4gICAgICAgICAgICAgICAgICAgIGFsdD17Y29uY2VwdC52aXN1YWxFbGVtZW50LmltYWdlLmFsdCA/PyAnJ31cbiAgICAgICAgICAgICAgICAgIC8+XG4gICAgICAgICAgICAgICAgKX1cbiAgICAgICAgICAgICAgPC9Ob3Rpb24+XG4gICAgICAgICAgICA8L0ltYWdlV3JhcHBlcj5cbiAgICAgICAgICApIDogdW5kZWZpbmVkXG4gICAgICAgIH1cbiAgICAgICAgdmlzdWFsRWxlbWVudD17XG4gICAgICAgICAgY29uY2VwdC52aXN1YWxFbGVtZW50ICYmIGNvbmNlcHQudmlzdWFsRWxlbWVudC5yZXNvdXJjZSAhPT0gJ2ltYWdlJyAmJiBjb25jZXB0LnZpc3VhbEVsZW1lbnQudXJsID8gKFxuICAgICAgICAgICAgPEltYWdlV3JhcHBlcj5cbiAgICAgICAgICAgICAgPE5vdGlvblxuICAgICAgICAgICAgICAgIGlkPXtub3Rpb25JZH1cbiAgICAgICAgICAgICAgICB0aXRsZT17Y29uY2VwdC50aXRsZX1cbiAgICAgICAgICAgICAgICBoaWRlQmFzZWxpbmVJY29uXG4gICAgICAgICAgICAgICAgc3ViVGl0bGU9e3QoJ3NlYXJjaFBhZ2UucmVzdWx0VHlwZS5ub3Rpb25zSGVhZGluZycpfVxuICAgICAgICAgICAgICAgIGNvbnRlbnQ9e1xuICAgICAgICAgICAgICAgICAgPD5cbiAgICAgICAgICAgICAgICAgICAgPE5vdGlvbkRpYWxvZ0NvbnRlbnQ+XG4gICAgICAgICAgICAgICAgICAgICAge2NvbmNlcHQudmlzdWFsRWxlbWVudCAmJlxuICAgICAgICAgICAgICAgICAgICAgIGNvbmNlcHQudmlzdWFsRWxlbWVudD8ucmVzb3VyY2UgIT09ICdpbWFnZScgJiZcbiAgICAgICAgICAgICAgICAgICAgICBjb25jZXB0LnZpc3VhbEVsZW1lbnQudXJsID8gKFxuICAgICAgICAgICAgICAgICAgICAgICAgPE5vdGlvblZpc3VhbEVsZW1lbnQgdmlzdWFsRWxlbWVudD17Y29uY2VwdC52aXN1YWxFbGVtZW50fSBpZD17bm90aW9uSWR9IGZpZ3VyZUlkPXtmaWd1cmVJZH0gLz5cbiAgICAgICAgICAgICAgICAgICAgICApIDogdW5kZWZpbmVkfVxuXG4gICAgICAgICAgICAgICAgICAgICAgPE5vdGlvbkRpYWxvZ1RleHQ+e3BhcnNlTWFya2Rvd24oY29uY2VwdC50ZXh0LCAnYm9keScpfTwvTm90aW9uRGlhbG9nVGV4dD5cbiAgICAgICAgICAgICAgICAgICAgPC9Ob3Rpb25EaWFsb2dDb250ZW50PlxuICAgICAgICAgICAgICAgICAgICA8Tm90aW9uRGlhbG9nTGljZW5zZXNcbiAgICAgICAgICAgICAgICAgICAgICBhdXRob3JzPXthdXRob3JzfVxuICAgICAgICAgICAgICAgICAgICAgIGxpY2Vuc2U9e2NvbmNlcHQuY29weXJpZ2h0Py5saWNlbnNlPy5saWNlbnNlID8/ICcnfVxuICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZT17Y29uY2VwdC5zb3VyY2V9XG4gICAgICAgICAgICAgICAgICAgIC8+XG4gICAgICAgICAgICAgICAgICA8Lz5cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgID5cbiAgICAgICAgICAgICAgICB7Y29uY2VwdC5pbWFnZSAmJiAoXG4gICAgICAgICAgICAgICAgICA8Tm90aW9uSW1hZ2VcbiAgICAgICAgICAgICAgICAgICAgdHlwZT17dHlwZX1cbiAgICAgICAgICAgICAgICAgICAgaWQ9e3Zpc3VhbEVsZW1lbnRJZH1cbiAgICAgICAgICAgICAgICAgICAgc3JjPXtjb25jZXB0LmltYWdlPy5zcmN9XG4gICAgICAgICAgICAgICAgICAgIGFsdD17Y29uY2VwdC5pbWFnZT8uYWx0ID8/ICcnfVxuICAgICAgICAgICAgICAgICAgLz5cbiAgICAgICAgICAgICAgICApfVxuICAgICAgICAgICAgICA8L05vdGlvbj5cbiAgICAgICAgICAgIDwvSW1hZ2VXcmFwcGVyPlxuICAgICAgICAgICkgOiB1bmRlZmluZWRcbiAgICAgICAgfVxuICAgICAgPjwvVUlOb3Rpb24+XG4gICAgPC9GaWd1cmVOb3Rpb24+XG4gICk7XG59O1xuXG5leHBvcnQgZGVmYXVsdCBDb25jZXB0Tm90aW9uO1xuIl19 */"));
36
- var ConceptNotion = function ConceptNotion(_ref) {
37
- var _concept$copyright$li, _concept$copyright, _concept$copyright$li2, _concept$visualElemen, _concept$visualElemen2, _concept$copyright$li3, _concept$copyright2, _concept$copyright2$l, _concept$visualElemen3, _concept$visualElemen4, _concept$copyright$li4, _concept$copyright3, _concept$copyright3$l, _concept$image, _concept$image$alt, _concept$image2;
38
- var concept = _ref.concept,
39
- disableScripts = _ref.disableScripts,
40
- type = _ref.type,
41
- hideIconsAndAuthors = _ref.hideIconsAndAuthors,
42
- figureType = _ref.figureType;
43
- var notionId = "notion-".concat(concept.id);
44
- var figureId = "notion-figure-".concat(concept.id);
45
- var visualElementId = "visual-element-".concat(concept.id);
46
- var _useTranslation = useTranslation(),
47
- t = _useTranslation.t;
48
- var _getLicenseCredits = getLicenseCredits(concept.copyright),
49
- creators = _getLicenseCredits.creators,
50
- rightsholders = _getLicenseCredits.rightsholders,
51
- processors = _getLicenseCredits.processors;
52
- var authors = (creators.length || rightsholders.length ? [].concat(_toConsumableArray(creators), _toConsumableArray(rightsholders)) : _toConsumableArray(processors)).map(function (author) {
53
- return author.name;
54
- });
55
- useEffect(function () {
56
- if (!disableScripts) {
57
- initArticleScripts();
58
- }
59
- }, [disableScripts]);
60
- return _jsx(FigureNotion, {
61
- resizeIframe: true,
62
- id: figureId,
63
- title: concept.title,
64
- figureId: visualElementId,
65
- copyright: concept.copyright,
66
- licenseString: (_concept$copyright$li = (_concept$copyright = concept.copyright) === null || _concept$copyright === void 0 ? void 0 : (_concept$copyright$li2 = _concept$copyright.license) === null || _concept$copyright$li2 === void 0 ? void 0 : _concept$copyright$li2.license) !== null && _concept$copyright$li !== void 0 ? _concept$copyright$li : '',
67
- type: "concept",
68
- hideIconsAndAuthors: hideIconsAndAuthors,
69
- figureType: figureType,
70
- children: _jsx(UINotion, {
71
- id: notionId,
72
- title: concept.title,
73
- text: concept.text,
74
- imageElement: ((_concept$visualElemen = concept.visualElement) === null || _concept$visualElemen === void 0 ? void 0 : _concept$visualElemen.resource) === 'image' && concept.visualElement.image ? _jsx(ImageWrapper, {
75
- children: _jsx(Notion, {
76
- id: notionId,
77
- title: concept.title,
78
- subTitle: t('searchPage.resultType.notionsHeading'),
79
- hideBaselineIcon: true,
80
- content: _jsxs(_Fragment, {
81
- children: [_jsxs(NotionDialogContent, {
82
- children: [((_concept$visualElemen2 = concept.visualElement) === null || _concept$visualElemen2 === void 0 ? void 0 : _concept$visualElemen2.resource) === 'image' && concept.visualElement.image ? _jsx(NotionVisualElement, {
83
- visualElement: concept.visualElement,
84
- id: notionId,
85
- figureId: figureId
86
- }) : undefined, _jsx(NotionDialogText, {
87
- children: parseMarkdown(concept.text, 'body')
88
- })]
89
- }), _jsx(NotionDialogLicenses, {
90
- authors: authors,
91
- license: (_concept$copyright$li3 = (_concept$copyright2 = concept.copyright) === null || _concept$copyright2 === void 0 ? void 0 : (_concept$copyright2$l = _concept$copyright2.license) === null || _concept$copyright2$l === void 0 ? void 0 : _concept$copyright2$l.license) !== null && _concept$copyright$li3 !== void 0 ? _concept$copyright$li3 : '',
92
- source: concept.source
93
- })]
94
- }),
95
- children: concept.visualElement.image && _jsx(NotionImage, {
96
- type: type,
97
- id: visualElementId,
98
- src: concept.visualElement.image.src,
99
- alt: (_concept$visualElemen3 = concept.visualElement.image.alt) !== null && _concept$visualElemen3 !== void 0 ? _concept$visualElemen3 : ''
100
- })
101
- })
102
- }) : undefined,
103
- visualElement: concept.visualElement && concept.visualElement.resource !== 'image' && concept.visualElement.url ? _jsx(ImageWrapper, {
104
- children: _jsx(Notion, {
105
- id: notionId,
106
- title: concept.title,
107
- hideBaselineIcon: true,
108
- subTitle: t('searchPage.resultType.notionsHeading'),
109
- content: _jsxs(_Fragment, {
110
- children: [_jsxs(NotionDialogContent, {
111
- children: [concept.visualElement && ((_concept$visualElemen4 = concept.visualElement) === null || _concept$visualElemen4 === void 0 ? void 0 : _concept$visualElemen4.resource) !== 'image' && concept.visualElement.url ? _jsx(NotionVisualElement, {
112
- visualElement: concept.visualElement,
113
- id: notionId,
114
- figureId: figureId
115
- }) : undefined, _jsx(NotionDialogText, {
116
- children: parseMarkdown(concept.text, 'body')
117
- })]
118
- }), _jsx(NotionDialogLicenses, {
119
- authors: authors,
120
- license: (_concept$copyright$li4 = (_concept$copyright3 = concept.copyright) === null || _concept$copyright3 === void 0 ? void 0 : (_concept$copyright3$l = _concept$copyright3.license) === null || _concept$copyright3$l === void 0 ? void 0 : _concept$copyright3$l.license) !== null && _concept$copyright$li4 !== void 0 ? _concept$copyright$li4 : '',
121
- source: concept.source
122
- })]
123
- }),
124
- children: concept.image && _jsx(NotionImage, {
125
- type: type,
126
- id: visualElementId,
127
- src: (_concept$image = concept.image) === null || _concept$image === void 0 ? void 0 : _concept$image.src,
128
- alt: (_concept$image$alt = (_concept$image2 = concept.image) === null || _concept$image2 === void 0 ? void 0 : _concept$image2.alt) !== null && _concept$image$alt !== void 0 ? _concept$image$alt : ''
129
- })
130
- })
131
- }) : undefined
132
- })
133
- });
134
- };
135
- export default ConceptNotion;
@@ -1,93 +0,0 @@
1
- import _styled from "@emotion/styled/base";
2
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
3
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
- 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); }
5
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
6
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
7
- 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; }
8
- /**
9
- * Copyright (c) 2022-present, NDLA.
10
- *
11
- * This source code is licensed under the GPLv3 license found in the
12
- * LICENSE file in the root directory of this source tree. *
13
- */
14
-
15
- import { colors, spacing } from '@ndla/core';
16
- import { getGroupedContributorDescriptionList, getLicenseByAbbreviation, getLicenseCredits } from '@ndla/licenses';
17
- import { useTranslation } from 'react-i18next';
18
- import { Figure, FigureCaption, FigureLicenseDialog } from '../Figure';
19
- import { jsx as _jsx } from "@emotion/react/jsx-runtime";
20
- import { Fragment as _Fragment } from "@emotion/react/jsx-runtime";
21
- import { jsxs as _jsxs } from "@emotion/react/jsx-runtime";
22
- var BottomBorder = /*#__PURE__*/_styled("div", {
23
- target: "e16vwpby0",
24
- label: "BottomBorder"
25
- })("margin-top:", spacing.normal, ";border-bottom:1px solid ", colors.brand.greyLight, ";" + (process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLC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H1cbiAgICAgICAgICAgICAgcmV1c2VMYWJlbD17dChgJHt0eXBlfS5yZXVzZWApfVxuICAgICAgICAgICAgICBhdXRob3JzPXthdXRob3JzfVxuICAgICAgICAgICAgICBsaWNlbnNlUmlnaHRzPXtsaWNlbnNlLnJpZ2h0c31cbiAgICAgICAgICAgICAgaGlkZUljb25zQW5kQXV0aG9ycz17aGlkZUljb25zQW5kQXV0aG9yc31cbiAgICAgICAgICAgID5cbiAgICAgICAgICAgICAgPEZpZ3VyZUxpY2Vuc2VEaWFsb2dcbiAgICAgICAgICAgICAgICBpZD17aWR9XG4gICAgICAgICAgICAgICAgYXV0aG9ycz17Z3JvdXBlZEF1dGhvcnN9XG4gICAgICAgICAgICAgICAgbG9jYWxlPXtpMThuLmxhbmd1YWdlfVxuICAgICAgICAgICAgICAgIHRpdGxlPXt0aXRsZX1cbiAgICAgICAgICAgICAgICBvcmlnaW49e2NvcHlyaWdodD8ub3JpZ2lufVxuICAgICAgICAgICAgICAgIGxpY2Vuc2U9e2xpY2Vuc2V9XG4gICAgICAgICAgICAgICAgbWVzc2FnZXM9e3tcbiAgICAgICAgICAgICAgICAgIGNsb3NlOiB0KCdjbG9zZScpLFxuICAgICAgICAgICAgICAgICAgcnVsZXNGb3JVc2U6IHQoYGxpY2Vuc2UuJHt0eXBlfS5ydWxlc2ApLFxuICAgICAgICAgICAgICAgICAgc291cmNlOiB0KCdzb3VyY2UnKSxcbiAgICAgICAgICAgICAgICAgIGxlYXJuQWJvdXRMaWNlbnNlczogdCgnbGljZW5zZS5sZWFybk1vcmUnKSxcbiAgICAgICAgICAgICAgICAgIHRpdGxlOiB0KCd0aXRsZScpLFxuICAgICAgICAgICAgICAgIH19XG4gICAgICAgICAgICAgID5cbiAgICAgICAgICAgICAgICB7bGljZW5zZUJ1dHRvbnN9XG4gICAgICAgICAgICAgIDwvRmlndXJlTGljZW5zZURpYWxvZz5cbiAgICAgICAgICAgIDwvRmlndXJlQ2FwdGlvbj5cbiAgICAgICAgICApIDogKFxuICAgICAgICAgICAgPEJvdHRvbUJvcmRlciAvPlxuICAgICAgICAgICl9XG4gICAgICAgIDwvPlxuICAgICAgKX1cbiAgICA8L0ZpZ3VyZT5cbiAgKTtcbn07XG5cbmV4cG9ydCBkZWZhdWx0IEZpZ3VyZU5vdGlvbjtcbiJdfQ== */"));
26
- var FigureNotion = function FigureNotion(_ref) {
27
- var resizeIframe = _ref.resizeIframe,
28
- figureId = _ref.figureId,
29
- _children = _ref.children,
30
- id = _ref.id,
31
- copyright = _ref.copyright,
32
- licenseString = _ref.licenseString,
33
- title = _ref.title,
34
- type = _ref.type,
35
- hideFigCaption = _ref.hideFigCaption,
36
- hideIconsAndAuthors = _ref.hideIconsAndAuthors,
37
- figureType = _ref.figureType,
38
- licenseButtons = _ref.licenseButtons;
39
- var _useTranslation = useTranslation(),
40
- t = _useTranslation.t,
41
- i18n = _useTranslation.i18n;
42
- var license = getLicenseByAbbreviation(licenseString, i18n.language);
43
- var licenseCredits = getLicenseCredits(copyright);
44
- var creators = licenseCredits.creators,
45
- rightsholders = licenseCredits.rightsholders,
46
- processors = licenseCredits.processors;
47
- var authors = creators.length || rightsholders.length ? [].concat(_toConsumableArray(creators), _toConsumableArray(rightsholders)) : _toConsumableArray(processors);
48
- var groupedAuthors = getGroupedContributorDescriptionList(licenseCredits, i18n.language).map(function (item) {
49
- return {
50
- name: item.description,
51
- type: item.label
52
- };
53
- });
54
- return _jsx(Figure, {
55
- resizeIframe: resizeIframe,
56
- id: figureId,
57
- type: figureType || 'full-column',
58
- children: function children(_ref2) {
59
- var _copyright$license;
60
- var typeClass = _ref2.typeClass;
61
- return _jsxs(_Fragment, {
62
- children: [typeof _children === 'function' ? _children({
63
- typeClass: typeClass
64
- }) : _children, copyright !== null && copyright !== void 0 && (_copyright$license = copyright.license) !== null && _copyright$license !== void 0 && _copyright$license.license ? _jsx(FigureCaption, {
65
- hideFigcaption: hideFigCaption,
66
- figureId: figureId,
67
- id: id,
68
- reuseLabel: t("".concat(type, ".reuse")),
69
- authors: authors,
70
- licenseRights: license.rights,
71
- hideIconsAndAuthors: hideIconsAndAuthors,
72
- children: _jsx(FigureLicenseDialog, {
73
- id: id,
74
- authors: groupedAuthors,
75
- locale: i18n.language,
76
- title: title,
77
- origin: copyright === null || copyright === void 0 ? void 0 : copyright.origin,
78
- license: license,
79
- messages: {
80
- close: t('close'),
81
- rulesForUse: t("license.".concat(type, ".rules")),
82
- source: t('source'),
83
- learnAboutLicenses: t('license.learnMore'),
84
- title: t('title')
85
- },
86
- children: licenseButtons
87
- })
88
- }) : _jsx(BottomBorder, {})]
89
- });
90
- }
91
- });
92
- };
93
- export default FigureNotion;