@ndla/video-search 4.1.46 → 5.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.
- package/README.md +8 -30
- package/es/VideoResultList.js +130 -0
- package/es/VideoSearch.js +90 -245
- package/es/index.js +1 -1
- package/lib/VideoResultList.d.ts +24 -0
- package/lib/VideoResultList.js +136 -0
- package/lib/VideoSearch.d.ts +31 -0
- package/lib/VideoSearch.js +90 -244
- package/lib/index.d.ts +10 -0
- package/lib/index.js +2 -3
- package/package.json +15 -12
- package/es/PreviewVideo.js +0 -37
- package/es/VideoLoadMoreButton.js +0 -51
- package/es/VideoSearchForm.js +0 -78
- package/es/VideoSearchList.js +0 -79
- package/es/VideoSearchResultBrightcove.js +0 -95
- package/es/VideoSearchResultYouTube.js +0 -93
- package/es/VideoTabs.js +0 -37
- package/es/shapes.js +0 -43
- package/es/videoHelpers.js +0 -43
- package/lib/PreviewVideo.js +0 -43
- package/lib/VideoLoadMoreButton.js +0 -58
- package/lib/VideoSearchForm.js +0 -84
- package/lib/VideoSearchList.js +0 -86
- package/lib/VideoSearchResultBrightcove.js +0 -101
- package/lib/VideoSearchResultYouTube.js +0 -99
- package/lib/VideoTabs.js +0 -44
- package/lib/shapes.js +0 -50
- package/lib/videoHelpers.js +0 -53
- package/scss/video-search.scss +0 -245
package/es/VideoSearchList.js
DELETED
|
@@ -1,79 +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 PropTypes from 'prop-types';
|
|
10
|
-
import BEMHelper from 'react-bem-helper';
|
|
11
|
-
import { BrightcoveShape, YouTubeShape } from './shapes';
|
|
12
|
-
import VideoSearchResultBrightcove from './VideoSearchResultBrightcove';
|
|
13
|
-
import VideoSearchResultYouTube from './VideoSearchResultYouTube';
|
|
14
|
-
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
15
|
-
const classes = new BEMHelper({
|
|
16
|
-
name: 'video-search',
|
|
17
|
-
prefix: 'c-'
|
|
18
|
-
});
|
|
19
|
-
const VideoSearchList = props => {
|
|
20
|
-
const {
|
|
21
|
-
videos,
|
|
22
|
-
locale,
|
|
23
|
-
translations,
|
|
24
|
-
selectedType,
|
|
25
|
-
selectedVideo,
|
|
26
|
-
onSelectVideo,
|
|
27
|
-
onVideoPreview,
|
|
28
|
-
searching
|
|
29
|
-
} = props;
|
|
30
|
-
if ((!videos || videos.length === 0) && !searching) {
|
|
31
|
-
return _jsx("p", {
|
|
32
|
-
children: translations.noResults
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
if (searching && !(videos.length > 0)) {
|
|
36
|
-
return _jsx("div", {
|
|
37
|
-
...classes('result-spinner')
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
const videoresults = () => {
|
|
41
|
-
if (selectedType === 'youtube') {
|
|
42
|
-
return videos.map(video => _jsx(VideoSearchResultYouTube, {
|
|
43
|
-
video: video,
|
|
44
|
-
onVideoPreview: onVideoPreview,
|
|
45
|
-
selectedVideo: selectedVideo,
|
|
46
|
-
onSelectVideo: onSelectVideo,
|
|
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));
|
|
59
|
-
};
|
|
60
|
-
return _jsx("div", {
|
|
61
|
-
...classes('list-inner'),
|
|
62
|
-
children: videoresults()
|
|
63
|
-
});
|
|
64
|
-
};
|
|
65
|
-
VideoSearchList.propTypes = {
|
|
66
|
-
onSelectVideo: PropTypes.func.isRequired,
|
|
67
|
-
onVideoPreview: PropTypes.func.isRequired,
|
|
68
|
-
searching: PropTypes.bool.isRequired,
|
|
69
|
-
selectedType: PropTypes.string.isRequired,
|
|
70
|
-
selectedVideo: PropTypes.oneOfType([BrightcoveShape, YouTubeShape]),
|
|
71
|
-
videos: PropTypes.oneOfType([PropTypes.arrayOf(BrightcoveShape), PropTypes.arrayOf(YouTubeShape)]),
|
|
72
|
-
translations: PropTypes.shape({
|
|
73
|
-
searchPlaceholder: PropTypes.string.isRequired,
|
|
74
|
-
searchButtonTitle: PropTypes.string.isRequired,
|
|
75
|
-
loadMoreVideos: PropTypes.string.isRequired
|
|
76
|
-
}),
|
|
77
|
-
locale: PropTypes.string.isRequired
|
|
78
|
-
};
|
|
79
|
-
export default VideoSearchList;
|
|
@@ -1,95 +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 PropTypes from 'prop-types';
|
|
10
|
-
import BEMHelper from 'react-bem-helper';
|
|
11
|
-
import { ButtonV2 } from '@ndla/button';
|
|
12
|
-
import { PanoramaPhotosphere } from '@ndla/icons/common';
|
|
13
|
-
import { getLicenseByNBTitle } from '@ndla/licenses';
|
|
14
|
-
import { LicenseByline } from '@ndla/notion';
|
|
15
|
-
import PreviewVideo from './PreviewVideo';
|
|
16
|
-
import { LicenseShape, BrightcoveShape } from './shapes';
|
|
17
|
-
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
18
|
-
import { jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
19
|
-
const classes = new BEMHelper({
|
|
20
|
-
name: 'video-search',
|
|
21
|
-
prefix: 'c-'
|
|
22
|
-
});
|
|
23
|
-
export default function VideoSearchResultBrightcove(_ref) {
|
|
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'),
|
|
40
|
-
children: [_jsx("img", {
|
|
41
|
-
role: "presentation",
|
|
42
|
-
alt: "presentation",
|
|
43
|
-
src: thumbnailSource
|
|
44
|
-
}), _jsxs("div", {
|
|
45
|
-
...classes('information'),
|
|
46
|
-
children: [_jsxs("h2", {
|
|
47
|
-
...classes('header'),
|
|
48
|
-
children: [video.name || '', is360video && _jsx(PanoramaPhotosphere, {})]
|
|
49
|
-
}), _jsx("div", {
|
|
50
|
-
...classes('copyright-author'),
|
|
51
|
-
children: video.custom_fields && video.custom_fields.licenseinfo ? video.custom_fields.licenseinfo : ''
|
|
52
|
-
}), _jsx("div", {
|
|
53
|
-
...classes('license'),
|
|
54
|
-
children: license.rights ? _jsx(LicenseByline, {
|
|
55
|
-
licenseRights: license.rights,
|
|
56
|
-
locale: locale
|
|
57
|
-
}) : license
|
|
58
|
-
}), _jsx(ButtonV2, {
|
|
59
|
-
...classes('button'),
|
|
60
|
-
variant: "outline",
|
|
61
|
-
onClick: () => onVideoPreview(video),
|
|
62
|
-
children: translations.previewVideo
|
|
63
|
-
}), _jsx(ButtonV2, {
|
|
64
|
-
"data-testid": "use-video",
|
|
65
|
-
...classes('button'),
|
|
66
|
-
onClick: () => onSelectVideo(video),
|
|
67
|
-
children: translations.addVideo
|
|
68
|
-
})]
|
|
69
|
-
})]
|
|
70
|
-
}), selectedVideo && selectedVideo.id === video.id ? _jsx(PreviewVideo, {
|
|
71
|
-
onVideoPreview: onVideoPreview,
|
|
72
|
-
selectedType: "brightcove",
|
|
73
|
-
children: _jsx("iframe", {
|
|
74
|
-
className: "c-video-preview__video",
|
|
75
|
-
title: selectedVideo.name,
|
|
76
|
-
src: `//players.brightcove.net/${selectedVideo.account_id}/BkLm8fT_default/index.html?videoId=${selectedVideo.id}`
|
|
77
|
-
// eslint-disable-next-line react/no-unknown-property
|
|
78
|
-
,
|
|
79
|
-
allowFullScreen: true
|
|
80
|
-
})
|
|
81
|
-
}) : '']
|
|
82
|
-
}, video.id);
|
|
83
|
-
}
|
|
84
|
-
VideoSearchResultBrightcove.propTypes = {
|
|
85
|
-
license: LicenseShape,
|
|
86
|
-
video: BrightcoveShape.isRequired,
|
|
87
|
-
onVideoPreview: PropTypes.func.isRequired,
|
|
88
|
-
selectedVideo: BrightcoveShape,
|
|
89
|
-
onSelectVideo: PropTypes.func.isRequired,
|
|
90
|
-
locale: PropTypes.string.isRequired,
|
|
91
|
-
translations: PropTypes.shape({
|
|
92
|
-
addVideo: PropTypes.string.isRequired,
|
|
93
|
-
previewVideo: PropTypes.string.isRequired
|
|
94
|
-
})
|
|
95
|
-
};
|
|
@@ -1,93 +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 PropTypes from 'prop-types';
|
|
10
|
-
import BEMHelper from 'react-bem-helper';
|
|
11
|
-
import { ButtonV2 } from '@ndla/button';
|
|
12
|
-
import PreviewVideo from './PreviewVideo';
|
|
13
|
-
import { YouTubeShape } from './shapes';
|
|
14
|
-
import { setLocaleDate, setYouTubeDuration } from './videoHelpers';
|
|
15
|
-
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
16
|
-
import { jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
17
|
-
const classes = new BEMHelper({
|
|
18
|
-
name: 'video-search',
|
|
19
|
-
prefix: 'c-'
|
|
20
|
-
});
|
|
21
|
-
export default function VideoSearchResultYouTube(_ref) {
|
|
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;
|
|
32
|
-
if (videoData) {
|
|
33
|
-
return _jsxs("div", {
|
|
34
|
-
...classes('list-item', activeVideo ? 'active' : ''),
|
|
35
|
-
children: [_jsxs("div", {
|
|
36
|
-
...classes('list-item-inner'),
|
|
37
|
-
children: [_jsx("img", {
|
|
38
|
-
role: "presentation",
|
|
39
|
-
alt: "presentation",
|
|
40
|
-
src: videoData.thumbnailurl
|
|
41
|
-
}), _jsxs("div", {
|
|
42
|
-
...classes('information'),
|
|
43
|
-
children: [_jsx("h2", {
|
|
44
|
-
children: videoData.name
|
|
45
|
-
}), _jsx("div", {
|
|
46
|
-
children: `${translations.publishedDate}: ${setLocaleDate(videoData.datepublished, locale)}`
|
|
47
|
-
}), _jsx("div", {
|
|
48
|
-
children: `${translations.duration}: ${setYouTubeDuration(videoData.duration)}`
|
|
49
|
-
}), _jsx("div", {
|
|
50
|
-
children: `${translations.interactioncount}: ${videoData.interactioncount}`
|
|
51
|
-
}), _jsx("div", {
|
|
52
|
-
children: videoData.description
|
|
53
|
-
}), _jsx(ButtonV2, {
|
|
54
|
-
...classes('button'),
|
|
55
|
-
variant: "outline",
|
|
56
|
-
onClick: () => onVideoPreview(video),
|
|
57
|
-
children: translations.previewVideo
|
|
58
|
-
}), _jsx(ButtonV2, {
|
|
59
|
-
"data-testid": "use-video",
|
|
60
|
-
...classes('button'),
|
|
61
|
-
onClick: () => onSelectVideo(video),
|
|
62
|
-
children: translations.addVideo
|
|
63
|
-
})]
|
|
64
|
-
})]
|
|
65
|
-
}), activeVideo ? _jsx(PreviewVideo, {
|
|
66
|
-
onVideoPreview: onVideoPreview,
|
|
67
|
-
selectedType: "youtube",
|
|
68
|
-
children: _jsx("iframe", {
|
|
69
|
-
className: "c-video-preview__video",
|
|
70
|
-
title: selectedVideo.title,
|
|
71
|
-
src: selectedVideo.pagemap.videoobject[0].embedurl
|
|
72
|
-
// eslint-disable-next-line react/no-unknown-property
|
|
73
|
-
,
|
|
74
|
-
allowFullScreen: true
|
|
75
|
-
})
|
|
76
|
-
}) : '']
|
|
77
|
-
});
|
|
78
|
-
} else {
|
|
79
|
-
return _jsx("div", {});
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
VideoSearchResultYouTube.propTypes = {
|
|
83
|
-
video: YouTubeShape.isRequired,
|
|
84
|
-
onVideoPreview: PropTypes.func.isRequired,
|
|
85
|
-
selectedVideo: YouTubeShape,
|
|
86
|
-
onSelectVideo: PropTypes.func.isRequired,
|
|
87
|
-
locale: PropTypes.string.isRequired,
|
|
88
|
-
translations: PropTypes.shape({
|
|
89
|
-
addVideo: PropTypes.string.isRequired,
|
|
90
|
-
previewVideo: PropTypes.string.isRequired,
|
|
91
|
-
publishedDate: PropTypes.string.isRequired
|
|
92
|
-
})
|
|
93
|
-
};
|
package/es/VideoTabs.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2016-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 PropTypes from 'prop-types';
|
|
10
|
-
import { useState } from 'react';
|
|
11
|
-
import Tabs from '@ndla/tabs';
|
|
12
|
-
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
13
|
-
const VideoTabs = _ref => {
|
|
14
|
-
let {
|
|
15
|
-
onSearchTypeChange,
|
|
16
|
-
tabs
|
|
17
|
-
} = _ref;
|
|
18
|
-
const [selectedTab, setSelectedTab] = useState(undefined);
|
|
19
|
-
const handleOnSelect = value => {
|
|
20
|
-
setSelectedTab(value);
|
|
21
|
-
onSearchTypeChange(value);
|
|
22
|
-
};
|
|
23
|
-
return _jsx(Tabs, {
|
|
24
|
-
value: selectedTab,
|
|
25
|
-
onValueChange: handleOnSelect,
|
|
26
|
-
tabs: tabs
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
VideoTabs.propTypes = {
|
|
30
|
-
onSearchTypeChange: PropTypes.func.isRequired,
|
|
31
|
-
tabs: PropTypes.arrayOf(PropTypes.shape({
|
|
32
|
-
type: PropTypes.string,
|
|
33
|
-
id: PropTypes.string,
|
|
34
|
-
content: PropTypes.node
|
|
35
|
-
})).isRequired
|
|
36
|
-
};
|
|
37
|
-
export default VideoTabs;
|
package/es/shapes.js
DELETED
|
@@ -1,43 +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 PropTypes from 'prop-types';
|
|
10
|
-
export const LicenseShape = PropTypes.shape({
|
|
11
|
-
short: PropTypes.string.isRequired,
|
|
12
|
-
title: PropTypes.string.isRequired,
|
|
13
|
-
userFriendlyTitle: PropTypes.string.isRequired,
|
|
14
|
-
description: PropTypes.string.isRequired,
|
|
15
|
-
rights: PropTypes.arrayOf(PropTypes.string).isRequired
|
|
16
|
-
});
|
|
17
|
-
export const BrightcoveShape = PropTypes.shape({
|
|
18
|
-
id: PropTypes.string.isRequired,
|
|
19
|
-
name: PropTypes.string.isRequired,
|
|
20
|
-
custom_fields: PropTypes.shape({
|
|
21
|
-
licenseinfo: PropTypes.string.isRequired,
|
|
22
|
-
license: PropTypes.string.isRequired
|
|
23
|
-
}),
|
|
24
|
-
images: PropTypes.shape({
|
|
25
|
-
thumbnail: PropTypes.shape({
|
|
26
|
-
src: PropTypes.string.isRequired
|
|
27
|
-
})
|
|
28
|
-
})
|
|
29
|
-
});
|
|
30
|
-
export const YouTubeShape = PropTypes.shape({
|
|
31
|
-
pagemap: PropTypes.shape({
|
|
32
|
-
videoobject: PropTypes.arrayOf(PropTypes.shape({
|
|
33
|
-
name: PropTypes.string.isRequired,
|
|
34
|
-
description: PropTypes.string.isRequired,
|
|
35
|
-
videoid: PropTypes.string.isRequired,
|
|
36
|
-
duration: PropTypes.string.isRequired,
|
|
37
|
-
thumbnailurl: PropTypes.string.isRequired,
|
|
38
|
-
embedurl: PropTypes.string.isRequired,
|
|
39
|
-
interactioncount: PropTypes.string.isRequired,
|
|
40
|
-
datepublished: PropTypes.string.isRequired
|
|
41
|
-
}))
|
|
42
|
-
})
|
|
43
|
-
});
|
package/es/videoHelpers.js
DELETED
|
@@ -1,43 +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
|
-
export const getLastPage = (search, type) => {
|
|
10
|
-
if (type === 'youtube') {
|
|
11
|
-
if (search?.queries?.request?.length > 0) {
|
|
12
|
-
const request = search.queries.request[0];
|
|
13
|
-
if (request.totalResults && request.count) {
|
|
14
|
-
return Math.ceil(request.totalResults / request.count);
|
|
15
|
-
}
|
|
16
|
-
return 0;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return 0;
|
|
20
|
-
};
|
|
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;
|
|
26
|
-
return hours * 3600 + minutes * 60 + seconds;
|
|
27
|
-
};
|
|
28
|
-
export const setLocaleDate = (date, locale) => {
|
|
29
|
-
const newDate = new Date(Date.parse(date));
|
|
30
|
-
const options = {
|
|
31
|
-
year: 'numeric',
|
|
32
|
-
month: '2-digit',
|
|
33
|
-
day: '2-digit'
|
|
34
|
-
};
|
|
35
|
-
return newDate.toLocaleDateString(locale, options);
|
|
36
|
-
};
|
|
37
|
-
export const setYouTubeDuration = duration => {
|
|
38
|
-
const seconds = youTubeDurationToSeconds(duration);
|
|
39
|
-
if (seconds > 86400) {
|
|
40
|
-
return `24h+ ${new Date(seconds * 1000).toISOString().substr(11, 8)}`;
|
|
41
|
-
}
|
|
42
|
-
return new Date(seconds * 1000).toISOString().substr(11, 8);
|
|
43
|
-
};
|
package/lib/PreviewVideo.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = PreviewVideo;
|
|
7
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
8
|
-
var _reactBemHelper = _interopRequireDefault(require("react-bem-helper"));
|
|
9
|
-
var _button = require("@ndla/button");
|
|
10
|
-
var _action = require("@ndla/icons/action");
|
|
11
|
-
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
/**
|
|
14
|
-
* Copyright (c) 2017-present, NDLA.
|
|
15
|
-
*
|
|
16
|
-
* This source code is licensed under the GPLv3 license found in the
|
|
17
|
-
* LICENSE file in the root directory of this source tree.
|
|
18
|
-
*
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
const classes = new _reactBemHelper.default({
|
|
22
|
-
name: 'video-preview',
|
|
23
|
-
prefix: 'c-'
|
|
24
|
-
});
|
|
25
|
-
function PreviewVideo(_ref) {
|
|
26
|
-
let {
|
|
27
|
-
onVideoPreview,
|
|
28
|
-
children
|
|
29
|
-
} = _ref;
|
|
30
|
-
return (0, _jsxRuntime.jsxs)("div", {
|
|
31
|
-
...classes(),
|
|
32
|
-
children: [(0, _jsxRuntime.jsx)(_button.ButtonV2, {
|
|
33
|
-
...classes('close'),
|
|
34
|
-
variant: "stripped",
|
|
35
|
-
onClick: () => onVideoPreview(undefined),
|
|
36
|
-
children: (0, _jsxRuntime.jsx)(_action.Cross, {})
|
|
37
|
-
}), children]
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
PreviewVideo.propTypes = {
|
|
41
|
-
children: _propTypes.default.node,
|
|
42
|
-
onVideoPreview: _propTypes.default.func.isRequired
|
|
43
|
-
};
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
8
|
-
var _reactBemHelper = _interopRequireDefault(require("react-bem-helper"));
|
|
9
|
-
var _button = require("@ndla/button");
|
|
10
|
-
var _shapes = require("./shapes");
|
|
11
|
-
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
/**
|
|
14
|
-
* Copyright (c) 2017-present, NDLA.
|
|
15
|
-
*
|
|
16
|
-
* This source code is licensed under the GPLv3 license found in the
|
|
17
|
-
* LICENSE file in the root directory of this source tree.
|
|
18
|
-
*
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
const classes = new _reactBemHelper.default({
|
|
22
|
-
name: 'video-search',
|
|
23
|
-
prefix: 'c-'
|
|
24
|
-
});
|
|
25
|
-
const VideoLoadMoreButton = props => {
|
|
26
|
-
const {
|
|
27
|
-
videos,
|
|
28
|
-
searching,
|
|
29
|
-
limit,
|
|
30
|
-
translations,
|
|
31
|
-
loadMoreVideos
|
|
32
|
-
} = props;
|
|
33
|
-
if (!videos || videos.length === 0 || videos.length % limit !== 0) {
|
|
34
|
-
return null;
|
|
35
|
-
}
|
|
36
|
-
return (0, _jsxRuntime.jsx)("div", {
|
|
37
|
-
...classes('load-videos'),
|
|
38
|
-
children: (0, _jsxRuntime.jsx)(_button.ButtonV2, {
|
|
39
|
-
disabled: searching,
|
|
40
|
-
onClick: loadMoreVideos,
|
|
41
|
-
children: searching ? (0, _jsxRuntime.jsx)("div", {
|
|
42
|
-
...classes('spinner')
|
|
43
|
-
}) : translations.loadMoreVideos
|
|
44
|
-
})
|
|
45
|
-
});
|
|
46
|
-
};
|
|
47
|
-
VideoLoadMoreButton.propTypes = {
|
|
48
|
-
searching: _propTypes.default.bool.isRequired,
|
|
49
|
-
videos: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_shapes.BrightcoveShape), _propTypes.default.arrayOf(_shapes.YouTubeShape)]),
|
|
50
|
-
translations: _propTypes.default.shape({
|
|
51
|
-
searchPlaceholder: _propTypes.default.string.isRequired,
|
|
52
|
-
searchButtonTitle: _propTypes.default.string.isRequired,
|
|
53
|
-
loadMoreVideos: _propTypes.default.string.isRequired
|
|
54
|
-
}),
|
|
55
|
-
limit: _propTypes.default.number.isRequired,
|
|
56
|
-
loadMoreVideos: _propTypes.default.func.isRequired
|
|
57
|
-
};
|
|
58
|
-
var _default = exports.default = VideoLoadMoreButton;
|
package/lib/VideoSearchForm.js
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
8
|
-
var _react = require("react");
|
|
9
|
-
var _reactBemHelper = _interopRequireDefault(require("react-bem-helper"));
|
|
10
|
-
var _button = require("@ndla/button");
|
|
11
|
-
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
/**
|
|
14
|
-
* Copyright (c) 2016-present, NDLA.
|
|
15
|
-
*
|
|
16
|
-
* This source code is licensed under the GPLv3 license found in the
|
|
17
|
-
* LICENSE file in the root directory of this source tree.
|
|
18
|
-
*
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
const classes = new _reactBemHelper.default({
|
|
22
|
-
name: 'video-search',
|
|
23
|
-
prefix: 'c-'
|
|
24
|
-
});
|
|
25
|
-
class SearchForm extends _react.Component {
|
|
26
|
-
constructor(props) {
|
|
27
|
-
super(props);
|
|
28
|
-
this.state = {
|
|
29
|
-
query: props.query
|
|
30
|
-
};
|
|
31
|
-
this.handleQueryChange = this.handleQueryChange.bind(this);
|
|
32
|
-
this.handleSubmit = this.handleSubmit.bind(this);
|
|
33
|
-
this.onKeyPress = this.onKeyPress.bind(this);
|
|
34
|
-
}
|
|
35
|
-
onKeyPress(evt) {
|
|
36
|
-
if (evt.key === 'Enter') {
|
|
37
|
-
this.handleSubmit(evt);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
handleQueryChange(evt) {
|
|
41
|
-
this.setState({
|
|
42
|
-
query: evt.target.value
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
handleSubmit(evt) {
|
|
46
|
-
evt.preventDefault();
|
|
47
|
-
this.props.onSearchQuerySubmit(this.state.query);
|
|
48
|
-
}
|
|
49
|
-
render() {
|
|
50
|
-
const {
|
|
51
|
-
searching,
|
|
52
|
-
translations
|
|
53
|
-
} = this.props;
|
|
54
|
-
return (0, _jsxRuntime.jsxs)("div", {
|
|
55
|
-
...classes('form'),
|
|
56
|
-
children: [(0, _jsxRuntime.jsx)("input", {
|
|
57
|
-
...classes('form-query'),
|
|
58
|
-
type: "text",
|
|
59
|
-
onChange: this.handleQueryChange,
|
|
60
|
-
onKeyPress: this.onKeyPress,
|
|
61
|
-
value: this.state.query,
|
|
62
|
-
placeholder: translations.searchPlaceholder
|
|
63
|
-
}), (0, _jsxRuntime.jsx)(_button.ButtonV2, {
|
|
64
|
-
...classes('form-button'),
|
|
65
|
-
onClick: this.handleSubmit,
|
|
66
|
-
disabled: searching,
|
|
67
|
-
children: translations.searchButtonTitle
|
|
68
|
-
})]
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
SearchForm.propTypes = {
|
|
73
|
-
query: _propTypes.default.string,
|
|
74
|
-
searching: _propTypes.default.bool.isRequired,
|
|
75
|
-
onSearchQuerySubmit: _propTypes.default.func.isRequired,
|
|
76
|
-
translations: _propTypes.default.shape({
|
|
77
|
-
searchPlaceholder: _propTypes.default.string.isRequired,
|
|
78
|
-
searchButtonTitle: _propTypes.default.string.isRequired
|
|
79
|
-
})
|
|
80
|
-
};
|
|
81
|
-
SearchForm.defaultProps = {
|
|
82
|
-
query: ''
|
|
83
|
-
};
|
|
84
|
-
var _default = exports.default = SearchForm;
|
package/lib/VideoSearchList.js
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
8
|
-
var _reactBemHelper = _interopRequireDefault(require("react-bem-helper"));
|
|
9
|
-
var _shapes = require("./shapes");
|
|
10
|
-
var _VideoSearchResultBrightcove = _interopRequireDefault(require("./VideoSearchResultBrightcove"));
|
|
11
|
-
var _VideoSearchResultYouTube = _interopRequireDefault(require("./VideoSearchResultYouTube"));
|
|
12
|
-
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
13
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
-
/**
|
|
15
|
-
* Copyright (c) 2017-present, NDLA.
|
|
16
|
-
*
|
|
17
|
-
* This source code is licensed under the GPLv3 license found in the
|
|
18
|
-
* LICENSE file in the root directory of this source tree.
|
|
19
|
-
*
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
const classes = new _reactBemHelper.default({
|
|
23
|
-
name: 'video-search',
|
|
24
|
-
prefix: 'c-'
|
|
25
|
-
});
|
|
26
|
-
const VideoSearchList = props => {
|
|
27
|
-
const {
|
|
28
|
-
videos,
|
|
29
|
-
locale,
|
|
30
|
-
translations,
|
|
31
|
-
selectedType,
|
|
32
|
-
selectedVideo,
|
|
33
|
-
onSelectVideo,
|
|
34
|
-
onVideoPreview,
|
|
35
|
-
searching
|
|
36
|
-
} = props;
|
|
37
|
-
if ((!videos || videos.length === 0) && !searching) {
|
|
38
|
-
return (0, _jsxRuntime.jsx)("p", {
|
|
39
|
-
children: translations.noResults
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
if (searching && !(videos.length > 0)) {
|
|
43
|
-
return (0, _jsxRuntime.jsx)("div", {
|
|
44
|
-
...classes('result-spinner')
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
const videoresults = () => {
|
|
48
|
-
if (selectedType === 'youtube') {
|
|
49
|
-
return videos.map(video => (0, _jsxRuntime.jsx)(_VideoSearchResultYouTube.default, {
|
|
50
|
-
video: video,
|
|
51
|
-
onVideoPreview: onVideoPreview,
|
|
52
|
-
selectedVideo: selectedVideo,
|
|
53
|
-
onSelectVideo: onSelectVideo,
|
|
54
|
-
translations: translations,
|
|
55
|
-
locale: locale
|
|
56
|
-
}, video.cacheId));
|
|
57
|
-
}
|
|
58
|
-
return videos.map(video => (0, _jsxRuntime.jsx)(_VideoSearchResultBrightcove.default, {
|
|
59
|
-
video: video,
|
|
60
|
-
onVideoPreview: onVideoPreview,
|
|
61
|
-
selectedVideo: selectedVideo,
|
|
62
|
-
onSelectVideo: onSelectVideo,
|
|
63
|
-
locale: locale,
|
|
64
|
-
translations: translations
|
|
65
|
-
}, video.id));
|
|
66
|
-
};
|
|
67
|
-
return (0, _jsxRuntime.jsx)("div", {
|
|
68
|
-
...classes('list-inner'),
|
|
69
|
-
children: videoresults()
|
|
70
|
-
});
|
|
71
|
-
};
|
|
72
|
-
VideoSearchList.propTypes = {
|
|
73
|
-
onSelectVideo: _propTypes.default.func.isRequired,
|
|
74
|
-
onVideoPreview: _propTypes.default.func.isRequired,
|
|
75
|
-
searching: _propTypes.default.bool.isRequired,
|
|
76
|
-
selectedType: _propTypes.default.string.isRequired,
|
|
77
|
-
selectedVideo: _propTypes.default.oneOfType([_shapes.BrightcoveShape, _shapes.YouTubeShape]),
|
|
78
|
-
videos: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_shapes.BrightcoveShape), _propTypes.default.arrayOf(_shapes.YouTubeShape)]),
|
|
79
|
-
translations: _propTypes.default.shape({
|
|
80
|
-
searchPlaceholder: _propTypes.default.string.isRequired,
|
|
81
|
-
searchButtonTitle: _propTypes.default.string.isRequired,
|
|
82
|
-
loadMoreVideos: _propTypes.default.string.isRequired
|
|
83
|
-
}),
|
|
84
|
-
locale: _propTypes.default.string.isRequired
|
|
85
|
-
};
|
|
86
|
-
var _default = exports.default = VideoSearchList;
|