@ndla/video-search 4.1.44 → 4.1.46

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.
@@ -1,19 +1,3 @@
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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
7
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
8
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
9
- 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); }
10
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
11
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
12
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
13
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
14
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
15
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
16
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
17
1
  /**
18
2
  * Copyright (c) 2016-present, NDLA.
19
3
  *
@@ -22,74 +6,63 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
22
6
  *
23
7
  */
24
8
 
25
- import { Component } from 'react';
26
9
  import PropTypes from 'prop-types';
27
- import { ButtonV2 } from '@ndla/button';
10
+ import { Component } from 'react';
28
11
  import BEMHelper from 'react-bem-helper';
12
+ import { ButtonV2 } from '@ndla/button';
29
13
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
30
14
  import { jsxs as _jsxs } from "@emotion/react/jsx-runtime";
31
- var classes = new BEMHelper({
15
+ const classes = new BEMHelper({
32
16
  name: 'video-search',
33
17
  prefix: 'c-'
34
18
  });
35
- var SearchForm = /*#__PURE__*/function (_Component) {
36
- _inherits(SearchForm, _Component);
37
- var _super = _createSuper(SearchForm);
38
- function SearchForm(props) {
39
- var _this;
40
- _classCallCheck(this, SearchForm);
41
- _this = _super.call(this, props);
42
- _this.state = {
19
+ class SearchForm extends Component {
20
+ constructor(props) {
21
+ super(props);
22
+ this.state = {
43
23
  query: props.query
44
24
  };
45
- _this.handleQueryChange = _this.handleQueryChange.bind(_assertThisInitialized(_this));
46
- _this.handleSubmit = _this.handleSubmit.bind(_assertThisInitialized(_this));
47
- _this.onKeyPress = _this.onKeyPress.bind(_assertThisInitialized(_this));
48
- return _this;
25
+ this.handleQueryChange = this.handleQueryChange.bind(this);
26
+ this.handleSubmit = this.handleSubmit.bind(this);
27
+ this.onKeyPress = this.onKeyPress.bind(this);
49
28
  }
50
- _createClass(SearchForm, [{
51
- key: "onKeyPress",
52
- value: function onKeyPress(evt) {
53
- if (evt.key === 'Enter') {
54
- this.handleSubmit(evt);
55
- }
56
- }
57
- }, {
58
- key: "handleQueryChange",
59
- value: function handleQueryChange(evt) {
60
- this.setState({
61
- query: evt.target.value
62
- });
63
- }
64
- }, {
65
- key: "handleSubmit",
66
- value: function handleSubmit(evt) {
67
- evt.preventDefault();
68
- this.props.onSearchQuerySubmit(this.state.query);
29
+ onKeyPress(evt) {
30
+ if (evt.key === 'Enter') {
31
+ this.handleSubmit(evt);
69
32
  }
70
- }, {
71
- key: "render",
72
- value: function render() {
73
- var _this$props = this.props,
74
- searching = _this$props.searching,
75
- translations = _this$props.translations;
76
- return _jsxs("div", _objectSpread(_objectSpread({}, classes('form')), {}, {
77
- children: [_jsx("input", _objectSpread(_objectSpread({}, classes('form-query')), {}, {
78
- type: "text",
79
- onChange: this.handleQueryChange,
80
- onKeyPress: this.onKeyPress,
81
- value: this.state.query,
82
- placeholder: translations.searchPlaceholder
83
- })), _jsx(ButtonV2, _objectSpread(_objectSpread({}, classes('form-button')), {}, {
84
- onClick: this.handleSubmit,
85
- disabled: searching,
86
- children: translations.searchButtonTitle
87
- }))]
88
- }));
89
- }
90
- }]);
91
- return SearchForm;
92
- }(Component);
33
+ }
34
+ handleQueryChange(evt) {
35
+ this.setState({
36
+ query: evt.target.value
37
+ });
38
+ }
39
+ handleSubmit(evt) {
40
+ evt.preventDefault();
41
+ this.props.onSearchQuerySubmit(this.state.query);
42
+ }
43
+ render() {
44
+ const {
45
+ searching,
46
+ translations
47
+ } = this.props;
48
+ return _jsxs("div", {
49
+ ...classes('form'),
50
+ children: [_jsx("input", {
51
+ ...classes('form-query'),
52
+ type: "text",
53
+ onChange: this.handleQueryChange,
54
+ onKeyPress: this.onKeyPress,
55
+ value: this.state.query,
56
+ placeholder: translations.searchPlaceholder
57
+ }), _jsx(ButtonV2, {
58
+ ...classes('form-button'),
59
+ onClick: this.handleSubmit,
60
+ disabled: searching,
61
+ children: translations.searchButtonTitle
62
+ })]
63
+ });
64
+ }
65
+ }
93
66
  SearchForm.propTypes = {
94
67
  query: PropTypes.string,
95
68
  searching: PropTypes.bool.isRequired,
@@ -1,9 +1,3 @@
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
1
  /**
8
2
  * Copyright (c) 2017-present, NDLA.
9
3
  *
@@ -18,54 +12,55 @@ import { BrightcoveShape, YouTubeShape } from './shapes';
18
12
  import VideoSearchResultBrightcove from './VideoSearchResultBrightcove';
19
13
  import VideoSearchResultYouTube from './VideoSearchResultYouTube';
20
14
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
21
- var classes = new BEMHelper({
15
+ const classes = new BEMHelper({
22
16
  name: 'video-search',
23
17
  prefix: 'c-'
24
18
  });
25
- var VideoSearchList = function VideoSearchList(props) {
26
- var videos = props.videos,
27
- locale = props.locale,
28
- translations = props.translations,
29
- selectedType = props.selectedType,
30
- selectedVideo = props.selectedVideo,
31
- onSelectVideo = props.onSelectVideo,
32
- onVideoPreview = props.onVideoPreview,
33
- searching = props.searching;
19
+ const VideoSearchList = props => {
20
+ const {
21
+ videos,
22
+ locale,
23
+ translations,
24
+ selectedType,
25
+ selectedVideo,
26
+ onSelectVideo,
27
+ onVideoPreview,
28
+ searching
29
+ } = props;
34
30
  if ((!videos || videos.length === 0) && !searching) {
35
31
  return _jsx("p", {
36
32
  children: translations.noResults
37
33
  });
38
34
  }
39
35
  if (searching && !(videos.length > 0)) {
40
- return _jsx("div", _objectSpread({}, classes('result-spinner')));
36
+ return _jsx("div", {
37
+ ...classes('result-spinner')
38
+ });
41
39
  }
42
- var videoresults = function videoresults() {
40
+ const videoresults = () => {
43
41
  if (selectedType === 'youtube') {
44
- return videos.map(function (video) {
45
- return _jsx(VideoSearchResultYouTube, {
46
- video: video,
47
- onVideoPreview: onVideoPreview,
48
- selectedVideo: selectedVideo,
49
- onSelectVideo: onSelectVideo,
50
- translations: translations,
51
- locale: locale
52
- }, video.cacheId);
53
- });
54
- }
55
- return videos.map(function (video) {
56
- return _jsx(VideoSearchResultBrightcove, {
42
+ return videos.map(video => _jsx(VideoSearchResultYouTube, {
57
43
  video: video,
58
44
  onVideoPreview: onVideoPreview,
59
45
  selectedVideo: selectedVideo,
60
46
  onSelectVideo: onSelectVideo,
61
- locale: locale,
62
- translations: translations
63
- }, video.id);
64
- });
47
+ translations: translations,
48
+ locale: locale
49
+ }, video.cacheId));
50
+ }
51
+ return videos.map(video => _jsx(VideoSearchResultBrightcove, {
52
+ video: video,
53
+ onVideoPreview: onVideoPreview,
54
+ selectedVideo: selectedVideo,
55
+ onSelectVideo: onSelectVideo,
56
+ locale: locale,
57
+ translations: translations
58
+ }, video.id));
65
59
  };
66
- return _jsx("div", _objectSpread(_objectSpread({}, classes('list-inner')), {}, {
60
+ return _jsx("div", {
61
+ ...classes('list-inner'),
67
62
  children: videoresults()
68
- }));
63
+ });
69
64
  };
70
65
  VideoSearchList.propTypes = {
71
66
  onSelectVideo: PropTypes.func.isRequired,
@@ -1,9 +1,3 @@
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
1
  /**
8
2
  * Copyright (c) 2017-present, NDLA.
9
3
  *
@@ -13,74 +7,79 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
13
7
  */
14
8
 
15
9
  import PropTypes from 'prop-types';
10
+ import BEMHelper from 'react-bem-helper';
16
11
  import { ButtonV2 } from '@ndla/button';
12
+ import { PanoramaPhotosphere } from '@ndla/icons/common';
17
13
  import { getLicenseByNBTitle } from '@ndla/licenses';
18
14
  import { LicenseByline } from '@ndla/notion';
19
- import { PanoramaPhotosphere } from '@ndla/icons/common';
20
- import BEMHelper from 'react-bem-helper';
21
15
  import PreviewVideo from './PreviewVideo';
22
16
  import { LicenseShape, BrightcoveShape } from './shapes';
23
17
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
24
18
  import { jsxs as _jsxs } from "@emotion/react/jsx-runtime";
25
- var classes = new BEMHelper({
19
+ const classes = new BEMHelper({
26
20
  name: 'video-search',
27
21
  prefix: 'c-'
28
22
  });
29
23
  export default function VideoSearchResultBrightcove(_ref) {
30
- var video = _ref.video,
31
- onVideoPreview = _ref.onVideoPreview,
32
- selectedVideo = _ref.selectedVideo,
33
- onSelectVideo = _ref.onSelectVideo,
34
- locale = _ref.locale,
35
- translations = _ref.translations;
36
- var active = selectedVideo && selectedVideo.id === video.id ? 'active' : '';
37
- var license = video.custom_fields && video.custom_fields.license ? getLicenseByNBTitle(video.custom_fields.license, locale) : '';
38
- var thumbnailSource = video.images && video.images.thumbnail ? video.images.thumbnail.src : '';
39
- var is360video = video.projection === 'equirectangular';
40
- return _jsxs("div", _objectSpread(_objectSpread({}, classes('list-item', active)), {}, {
41
- children: [_jsxs("div", _objectSpread(_objectSpread({}, classes('list-item-inner')), {}, {
24
+ let {
25
+ video,
26
+ onVideoPreview,
27
+ selectedVideo,
28
+ onSelectVideo,
29
+ locale,
30
+ translations
31
+ } = _ref;
32
+ const active = selectedVideo && selectedVideo.id === video.id ? 'active' : '';
33
+ const license = video.custom_fields && video.custom_fields.license ? getLicenseByNBTitle(video.custom_fields.license, locale) : '';
34
+ const thumbnailSource = video.images && video.images.thumbnail ? video.images.thumbnail.src : '';
35
+ const is360video = video.projection === 'equirectangular';
36
+ return _jsxs("div", {
37
+ ...classes('list-item', active),
38
+ children: [_jsxs("div", {
39
+ ...classes('list-item-inner'),
42
40
  children: [_jsx("img", {
43
41
  role: "presentation",
44
42
  alt: "presentation",
45
43
  src: thumbnailSource
46
- }), _jsxs("div", _objectSpread(_objectSpread({}, classes('information')), {}, {
47
- children: [_jsxs("h2", _objectSpread(_objectSpread({}, classes('header')), {}, {
44
+ }), _jsxs("div", {
45
+ ...classes('information'),
46
+ children: [_jsxs("h2", {
47
+ ...classes('header'),
48
48
  children: [video.name || '', is360video && _jsx(PanoramaPhotosphere, {})]
49
- })), _jsx("div", _objectSpread(_objectSpread({}, classes('copyright-author')), {}, {
49
+ }), _jsx("div", {
50
+ ...classes('copyright-author'),
50
51
  children: video.custom_fields && video.custom_fields.licenseinfo ? video.custom_fields.licenseinfo : ''
51
- })), _jsx("div", _objectSpread(_objectSpread({}, classes('license')), {}, {
52
+ }), _jsx("div", {
53
+ ...classes('license'),
52
54
  children: license.rights ? _jsx(LicenseByline, {
53
55
  licenseRights: license.rights,
54
56
  locale: locale
55
57
  }) : license
56
- })), _jsx(ButtonV2, _objectSpread(_objectSpread({}, classes('button')), {}, {
58
+ }), _jsx(ButtonV2, {
59
+ ...classes('button'),
57
60
  variant: "outline",
58
- onClick: function onClick() {
59
- return onVideoPreview(video);
60
- },
61
+ onClick: () => onVideoPreview(video),
61
62
  children: translations.previewVideo
62
- })), _jsx(ButtonV2, _objectSpread(_objectSpread({
63
- "data-testid": "use-video"
64
- }, classes('button')), {}, {
65
- onClick: function onClick() {
66
- return onSelectVideo(video);
67
- },
63
+ }), _jsx(ButtonV2, {
64
+ "data-testid": "use-video",
65
+ ...classes('button'),
66
+ onClick: () => onSelectVideo(video),
68
67
  children: translations.addVideo
69
- }))]
70
- }))]
71
- })), selectedVideo && selectedVideo.id === video.id ? _jsx(PreviewVideo, {
68
+ })]
69
+ })]
70
+ }), selectedVideo && selectedVideo.id === video.id ? _jsx(PreviewVideo, {
72
71
  onVideoPreview: onVideoPreview,
73
72
  selectedType: "brightcove",
74
73
  children: _jsx("iframe", {
75
74
  className: "c-video-preview__video",
76
75
  title: selectedVideo.name,
77
- src: "//players.brightcove.net/".concat(selectedVideo.account_id, "/BkLm8fT_default/index.html?videoId=").concat(selectedVideo.id)
76
+ src: `//players.brightcove.net/${selectedVideo.account_id}/BkLm8fT_default/index.html?videoId=${selectedVideo.id}`
78
77
  // eslint-disable-next-line react/no-unknown-property
79
78
  ,
80
79
  allowFullScreen: true
81
80
  })
82
81
  }) : '']
83
- }), video.id);
82
+ }, video.id);
84
83
  }
85
84
  VideoSearchResultBrightcove.propTypes = {
86
85
  license: LicenseShape,
@@ -1,9 +1,3 @@
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
1
  /**
8
2
  * Copyright (c) 2017-present, NDLA.
9
3
  *
@@ -13,61 +7,62 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
13
7
  */
14
8
 
15
9
  import PropTypes from 'prop-types';
16
- import { ButtonV2 } from '@ndla/button';
17
10
  import BEMHelper from 'react-bem-helper';
11
+ import { ButtonV2 } from '@ndla/button';
18
12
  import PreviewVideo from './PreviewVideo';
19
13
  import { YouTubeShape } from './shapes';
20
14
  import { setLocaleDate, setYouTubeDuration } from './videoHelpers';
21
15
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
22
16
  import { jsxs as _jsxs } from "@emotion/react/jsx-runtime";
23
- var classes = new BEMHelper({
17
+ const classes = new BEMHelper({
24
18
  name: 'video-search',
25
19
  prefix: 'c-'
26
20
  });
27
21
  export default function VideoSearchResultYouTube(_ref) {
28
- var _video$pagemap, _video$pagemap$videoo, _selectedVideo$pagema, _selectedVideo$pagema2, _selectedVideo$pagema3;
29
- var video = _ref.video,
30
- onVideoPreview = _ref.onVideoPreview,
31
- selectedVideo = _ref.selectedVideo,
32
- onSelectVideo = _ref.onSelectVideo,
33
- translations = _ref.translations,
34
- locale = _ref.locale;
35
- var videoData = video === null || video === void 0 ? void 0 : (_video$pagemap = video.pagemap) === null || _video$pagemap === void 0 ? void 0 : (_video$pagemap$videoo = _video$pagemap.videoobject) === null || _video$pagemap$videoo === void 0 ? void 0 : _video$pagemap$videoo[0];
36
- var activeVideo = (selectedVideo === null || selectedVideo === void 0 ? void 0 : (_selectedVideo$pagema = selectedVideo.pagemap) === null || _selectedVideo$pagema === void 0 ? void 0 : (_selectedVideo$pagema2 = _selectedVideo$pagema.videoobject) === null || _selectedVideo$pagema2 === void 0 ? void 0 : (_selectedVideo$pagema3 = _selectedVideo$pagema2[0]) === null || _selectedVideo$pagema3 === void 0 ? void 0 : _selectedVideo$pagema3.videoid) === (videoData === null || videoData === void 0 ? void 0 : videoData.videoid);
22
+ let {
23
+ video,
24
+ onVideoPreview,
25
+ selectedVideo,
26
+ onSelectVideo,
27
+ translations,
28
+ locale
29
+ } = _ref;
30
+ const videoData = video?.pagemap?.videoobject?.[0];
31
+ const activeVideo = selectedVideo?.pagemap?.videoobject?.[0]?.videoid === videoData?.videoid;
37
32
  if (videoData) {
38
- return _jsxs("div", _objectSpread(_objectSpread({}, classes('list-item', activeVideo ? 'active' : '')), {}, {
39
- children: [_jsxs("div", _objectSpread(_objectSpread({}, classes('list-item-inner')), {}, {
33
+ return _jsxs("div", {
34
+ ...classes('list-item', activeVideo ? 'active' : ''),
35
+ children: [_jsxs("div", {
36
+ ...classes('list-item-inner'),
40
37
  children: [_jsx("img", {
41
38
  role: "presentation",
42
39
  alt: "presentation",
43
40
  src: videoData.thumbnailurl
44
- }), _jsxs("div", _objectSpread(_objectSpread({}, classes('information')), {}, {
41
+ }), _jsxs("div", {
42
+ ...classes('information'),
45
43
  children: [_jsx("h2", {
46
44
  children: videoData.name
47
45
  }), _jsx("div", {
48
- children: "".concat(translations.publishedDate, ": ").concat(setLocaleDate(videoData.datepublished, locale))
46
+ children: `${translations.publishedDate}: ${setLocaleDate(videoData.datepublished, locale)}`
49
47
  }), _jsx("div", {
50
- children: "".concat(translations.duration, ": ").concat(setYouTubeDuration(videoData.duration))
48
+ children: `${translations.duration}: ${setYouTubeDuration(videoData.duration)}`
51
49
  }), _jsx("div", {
52
- children: "".concat(translations.interactioncount, ": ").concat(videoData.interactioncount)
50
+ children: `${translations.interactioncount}: ${videoData.interactioncount}`
53
51
  }), _jsx("div", {
54
52
  children: videoData.description
55
- }), _jsx(ButtonV2, _objectSpread(_objectSpread({}, classes('button')), {}, {
53
+ }), _jsx(ButtonV2, {
54
+ ...classes('button'),
56
55
  variant: "outline",
57
- onClick: function onClick() {
58
- return onVideoPreview(video);
59
- },
56
+ onClick: () => onVideoPreview(video),
60
57
  children: translations.previewVideo
61
- })), _jsx(ButtonV2, _objectSpread(_objectSpread({
62
- "data-testid": "use-video"
63
- }, classes('button')), {}, {
64
- onClick: function onClick() {
65
- return onSelectVideo(video);
66
- },
58
+ }), _jsx(ButtonV2, {
59
+ "data-testid": "use-video",
60
+ ...classes('button'),
61
+ onClick: () => onSelectVideo(video),
67
62
  children: translations.addVideo
68
- }))]
69
- }))]
70
- })), activeVideo ? _jsx(PreviewVideo, {
63
+ })]
64
+ })]
65
+ }), activeVideo ? _jsx(PreviewVideo, {
71
66
  onVideoPreview: onVideoPreview,
72
67
  selectedType: "youtube",
73
68
  children: _jsx("iframe", {
@@ -79,7 +74,7 @@ export default function VideoSearchResultYouTube(_ref) {
79
74
  allowFullScreen: true
80
75
  })
81
76
  }) : '']
82
- }));
77
+ });
83
78
  } else {
84
79
  return _jsx("div", {});
85
80
  }
package/es/VideoTabs.js CHANGED
@@ -1,9 +1,3 @@
1
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
- 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."); }
3
- 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); }
4
- 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; }
5
- 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; } }
6
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
1
  /**
8
2
  * Copyright (c) 2016-present, NDLA.
9
3
  *
@@ -12,18 +6,17 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
6
  *
13
7
  */
14
8
 
15
- import { useState } from 'react';
16
9
  import PropTypes from 'prop-types';
10
+ import { useState } from 'react';
17
11
  import Tabs from '@ndla/tabs';
18
12
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
19
- var VideoTabs = function VideoTabs(_ref) {
20
- var onSearchTypeChange = _ref.onSearchTypeChange,
21
- tabs = _ref.tabs;
22
- var _useState = useState(undefined),
23
- _useState2 = _slicedToArray(_useState, 2),
24
- selectedTab = _useState2[0],
25
- setSelectedTab = _useState2[1];
26
- var handleOnSelect = function handleOnSelect(value) {
13
+ const VideoTabs = _ref => {
14
+ let {
15
+ onSearchTypeChange,
16
+ tabs
17
+ } = _ref;
18
+ const [selectedTab, setSelectedTab] = useState(undefined);
19
+ const handleOnSelect = value => {
27
20
  setSelectedTab(value);
28
21
  onSearchTypeChange(value);
29
22
  };
package/es/index.js CHANGED
@@ -1,2 +1,10 @@
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
+
1
9
  import VideoSearch from './VideoSearch';
2
10
  export default VideoSearch;
package/es/shapes.js CHANGED
@@ -7,14 +7,14 @@
7
7
  */
8
8
 
9
9
  import PropTypes from 'prop-types';
10
- export var LicenseShape = PropTypes.shape({
10
+ export const LicenseShape = PropTypes.shape({
11
11
  short: PropTypes.string.isRequired,
12
12
  title: PropTypes.string.isRequired,
13
13
  userFriendlyTitle: PropTypes.string.isRequired,
14
14
  description: PropTypes.string.isRequired,
15
15
  rights: PropTypes.arrayOf(PropTypes.string).isRequired
16
16
  });
17
- export var BrightcoveShape = PropTypes.shape({
17
+ export const BrightcoveShape = PropTypes.shape({
18
18
  id: PropTypes.string.isRequired,
19
19
  name: PropTypes.string.isRequired,
20
20
  custom_fields: PropTypes.shape({
@@ -27,7 +27,7 @@ export var BrightcoveShape = PropTypes.shape({
27
27
  })
28
28
  })
29
29
  });
30
- export var YouTubeShape = PropTypes.shape({
30
+ export const YouTubeShape = PropTypes.shape({
31
31
  pagemap: PropTypes.shape({
32
32
  videoobject: PropTypes.arrayOf(PropTypes.shape({
33
33
  name: PropTypes.string.isRequired,
@@ -6,11 +6,10 @@
6
6
  *
7
7
  */
8
8
 
9
- export var getLastPage = function getLastPage(search, type) {
9
+ export const getLastPage = (search, type) => {
10
10
  if (type === 'youtube') {
11
- var _search$queries, _search$queries$reque;
12
- if ((search === null || search === void 0 ? void 0 : (_search$queries = search.queries) === null || _search$queries === void 0 ? void 0 : (_search$queries$reque = _search$queries.request) === null || _search$queries$reque === void 0 ? void 0 : _search$queries$reque.length) > 0) {
13
- var request = search.queries.request[0];
11
+ if (search?.queries?.request?.length > 0) {
12
+ const request = search.queries.request[0];
14
13
  if (request.totalResults && request.count) {
15
14
  return Math.ceil(request.totalResults / request.count);
16
15
  }
@@ -19,26 +18,26 @@ export var getLastPage = function getLastPage(search, type) {
19
18
  }
20
19
  return 0;
21
20
  };
22
- export var youTubeDurationToSeconds = function youTubeDurationToSeconds(duration) {
23
- var match = duration.match(/PT(\d+H)?(\d+M)?(\d+S)?/);
24
- var hours = parseInt(match[1], 10) || 0;
25
- var minutes = parseInt(match[2], 10) || 0;
26
- var seconds = parseInt(match[3], 10) || 0;
21
+ export const youTubeDurationToSeconds = duration => {
22
+ const match = duration.match(/PT(\d+H)?(\d+M)?(\d+S)?/);
23
+ const hours = parseInt(match[1], 10) || 0;
24
+ const minutes = parseInt(match[2], 10) || 0;
25
+ const seconds = parseInt(match[3], 10) || 0;
27
26
  return hours * 3600 + minutes * 60 + seconds;
28
27
  };
29
- export var setLocaleDate = function setLocaleDate(date, locale) {
30
- var newDate = new Date(Date.parse(date));
31
- var options = {
28
+ export const setLocaleDate = (date, locale) => {
29
+ const newDate = new Date(Date.parse(date));
30
+ const options = {
32
31
  year: 'numeric',
33
32
  month: '2-digit',
34
33
  day: '2-digit'
35
34
  };
36
35
  return newDate.toLocaleDateString(locale, options);
37
36
  };
38
- export var setYouTubeDuration = function setYouTubeDuration(duration) {
39
- var seconds = youTubeDurationToSeconds(duration);
37
+ export const setYouTubeDuration = duration => {
38
+ const seconds = youTubeDurationToSeconds(duration);
40
39
  if (seconds > 86400) {
41
- return "24h+ ".concat(new Date(seconds * 1000).toISOString().substr(11, 8));
40
+ return `24h+ ${new Date(seconds * 1000).toISOString().substr(11, 8)}`;
42
41
  }
43
42
  return new Date(seconds * 1000).toISOString().substr(11, 8);
44
43
  };