@ndla/video-search 4.1.43 → 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.
- package/es/PreviewVideo.js +12 -16
- package/es/VideoLoadMoreButton.js +15 -16
- package/es/VideoSearch.js +201 -230
- package/es/VideoSearchForm.js +46 -73
- package/es/VideoSearchList.js +32 -37
- package/es/VideoSearchResultBrightcove.js +39 -40
- package/es/VideoSearchResultYouTube.js +32 -37
- package/es/VideoTabs.js +8 -15
- package/es/index.js +8 -0
- package/es/shapes.js +3 -3
- package/es/videoHelpers.js +14 -15
- package/lib/PreviewVideo.js +20 -22
- package/lib/VideoLoadMoreButton.js +24 -24
- package/lib/VideoSearch.js +210 -238
- package/lib/VideoSearchForm.js +55 -81
- package/lib/VideoSearchList.js +41 -45
- package/lib/VideoSearchResultBrightcove.js +47 -46
- package/lib/VideoSearchResultYouTube.js +40 -43
- package/lib/VideoTabs.js +17 -23
- package/lib/index.js +8 -2
- package/lib/shapes.js +4 -7
- package/lib/videoHelpers.js +14 -15
- package/package.json +8 -8
package/lib/PreviewVideo.js
CHANGED
|
@@ -10,34 +10,32 @@ var _button = require("@ndla/button");
|
|
|
10
10
|
var _action = require("@ndla/icons/action");
|
|
11
11
|
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
12
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
* LICENSE file in the root directory of this source tree.
|
|
23
|
-
*
|
|
24
|
-
*/
|
|
25
|
-
var classes = new _reactBemHelper.default({
|
|
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({
|
|
26
22
|
name: 'video-preview',
|
|
27
23
|
prefix: 'c-'
|
|
28
24
|
});
|
|
29
25
|
function PreviewVideo(_ref) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
34
|
variant: "stripped",
|
|
35
|
-
onClick:
|
|
36
|
-
return onVideoPreview(undefined);
|
|
37
|
-
},
|
|
35
|
+
onClick: () => onVideoPreview(undefined),
|
|
38
36
|
children: (0, _jsxRuntime.jsx)(_action.Cross, {})
|
|
39
|
-
})
|
|
40
|
-
})
|
|
37
|
+
}), children]
|
|
38
|
+
});
|
|
41
39
|
}
|
|
42
40
|
PreviewVideo.propTypes = {
|
|
43
41
|
children: _propTypes.default.node,
|
|
@@ -10,38 +10,39 @@ var _button = require("@ndla/button");
|
|
|
10
10
|
var _shapes = require("./shapes");
|
|
11
11
|
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
12
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
* LICENSE file in the root directory of this source tree.
|
|
23
|
-
*
|
|
24
|
-
*/
|
|
25
|
-
var classes = new _reactBemHelper.default({
|
|
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({
|
|
26
22
|
name: 'video-search',
|
|
27
23
|
prefix: 'c-'
|
|
28
24
|
});
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
25
|
+
const VideoLoadMoreButton = props => {
|
|
26
|
+
const {
|
|
27
|
+
videos,
|
|
28
|
+
searching,
|
|
29
|
+
limit,
|
|
30
|
+
translations,
|
|
31
|
+
loadMoreVideos
|
|
32
|
+
} = props;
|
|
35
33
|
if (!videos || videos.length === 0 || videos.length % limit !== 0) {
|
|
36
34
|
return null;
|
|
37
35
|
}
|
|
38
|
-
return (0, _jsxRuntime.jsx)("div",
|
|
36
|
+
return (0, _jsxRuntime.jsx)("div", {
|
|
37
|
+
...classes('load-videos'),
|
|
39
38
|
children: (0, _jsxRuntime.jsx)(_button.ButtonV2, {
|
|
40
39
|
disabled: searching,
|
|
41
40
|
onClick: loadMoreVideos,
|
|
42
|
-
children: searching ? (0, _jsxRuntime.jsx)("div",
|
|
41
|
+
children: searching ? (0, _jsxRuntime.jsx)("div", {
|
|
42
|
+
...classes('spinner')
|
|
43
|
+
}) : translations.loadMoreVideos
|
|
43
44
|
})
|
|
44
|
-
})
|
|
45
|
+
});
|
|
45
46
|
};
|
|
46
47
|
VideoLoadMoreButton.propTypes = {
|
|
47
48
|
searching: _propTypes.default.bool.isRequired,
|
|
@@ -54,5 +55,4 @@ VideoLoadMoreButton.propTypes = {
|
|
|
54
55
|
limit: _propTypes.default.number.isRequired,
|
|
55
56
|
loadMoreVideos: _propTypes.default.func.isRequired
|
|
56
57
|
};
|
|
57
|
-
var _default = VideoLoadMoreButton;
|
|
58
|
-
exports.default = _default;
|
|
58
|
+
var _default = exports.default = VideoLoadMoreButton;
|
package/lib/VideoSearch.js
CHANGED
|
@@ -1,54 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
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); }
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.default = void 0;
|
|
8
|
-
var _react = require("react");
|
|
9
7
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
8
|
+
var _react = require("react");
|
|
10
9
|
var _reactBemHelper = _interopRequireDefault(require("react-bem-helper"));
|
|
11
10
|
var _pager = _interopRequireDefault(require("@ndla/pager"));
|
|
11
|
+
var _videoHelpers = require("./videoHelpers");
|
|
12
|
+
var _VideoLoadMoreButton = _interopRequireDefault(require("./VideoLoadMoreButton"));
|
|
12
13
|
var _VideoSearchForm = _interopRequireDefault(require("./VideoSearchForm"));
|
|
13
14
|
var _VideoSearchList = _interopRequireDefault(require("./VideoSearchList"));
|
|
14
|
-
var _VideoLoadMoreButton = _interopRequireDefault(require("./VideoLoadMoreButton"));
|
|
15
15
|
var _VideoTabs = _interopRequireDefault(require("./VideoTabs"));
|
|
16
|
-
var _videoHelpers = require("./videoHelpers");
|
|
17
16
|
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
18
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
29
|
-
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); }; }
|
|
30
|
-
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); }
|
|
31
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
32
|
-
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; } }
|
|
33
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } /**
|
|
34
|
-
* Copyright (c) 2017-present, NDLA.
|
|
35
|
-
*
|
|
36
|
-
* This source code is licensed under the GPLv3 license found in the
|
|
37
|
-
* LICENSE file in the root directory of this source tree.
|
|
38
|
-
*
|
|
39
|
-
*/
|
|
40
|
-
var classes = new _reactBemHelper.default({
|
|
18
|
+
/**
|
|
19
|
+
* Copyright (c) 2017-present, NDLA.
|
|
20
|
+
*
|
|
21
|
+
* This source code is licensed under the GPLv3 license found in the
|
|
22
|
+
* LICENSE file in the root directory of this source tree.
|
|
23
|
+
*
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
const classes = new _reactBemHelper.default({
|
|
41
27
|
name: 'video-search',
|
|
42
28
|
prefix: 'c-'
|
|
43
29
|
});
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
var _this;
|
|
49
|
-
_classCallCheck(this, VideoSearch);
|
|
50
|
-
_this = _super.call(this);
|
|
51
|
-
_this.state = {
|
|
30
|
+
class VideoSearch extends _react.Component {
|
|
31
|
+
constructor() {
|
|
32
|
+
super();
|
|
33
|
+
this.state = {
|
|
52
34
|
queryObject: {
|
|
53
35
|
query: '',
|
|
54
36
|
offset: 0,
|
|
@@ -61,218 +43,209 @@ var VideoSearch = /*#__PURE__*/function (_Component) {
|
|
|
61
43
|
lastPage: 0,
|
|
62
44
|
searching: false
|
|
63
45
|
};
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
return _this;
|
|
46
|
+
this.submitVideoSearchQuery = this.submitVideoSearchQuery.bind(this);
|
|
47
|
+
this.changeQueryPage = this.changeQueryPage.bind(this);
|
|
48
|
+
this.onSearchTypeChange = this.onSearchTypeChange.bind(this);
|
|
49
|
+
this.searchVideos = this.searchVideos.bind(this);
|
|
50
|
+
this.onVideoPreview = this.onVideoPreview.bind(this);
|
|
51
|
+
this.onSelectVideo = this.onSelectVideo.bind(this);
|
|
52
|
+
this.loadMoreVideos = this.loadMoreVideos.bind(this);
|
|
72
53
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
54
|
+
componentDidMount() {
|
|
55
|
+
this.searchVideos(this.state.queryObject);
|
|
56
|
+
}
|
|
57
|
+
onVideoPreview(video) {
|
|
58
|
+
this.setState({
|
|
59
|
+
selectedVideo: video
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
onSelectVideo(video) {
|
|
63
|
+
const {
|
|
64
|
+
selectedType
|
|
65
|
+
} = this.state;
|
|
66
|
+
const {
|
|
67
|
+
onVideoSelect
|
|
68
|
+
} = this.props;
|
|
69
|
+
this.setState({
|
|
70
|
+
selectedVideo: undefined
|
|
71
|
+
});
|
|
72
|
+
onVideoSelect(video, selectedType);
|
|
73
|
+
}
|
|
74
|
+
onSearchTypeChange(type) {
|
|
75
|
+
let queryObject;
|
|
76
|
+
if (type === 'youtube') {
|
|
77
|
+
queryObject = {
|
|
78
|
+
query: '',
|
|
79
|
+
offset: undefined,
|
|
80
|
+
limit: undefined,
|
|
81
|
+
page: 1,
|
|
82
|
+
start: 1
|
|
83
|
+
};
|
|
84
|
+
} else {
|
|
85
|
+
queryObject = {
|
|
86
|
+
query: '',
|
|
87
|
+
offset: 0,
|
|
88
|
+
limit: 10,
|
|
89
|
+
page: undefined,
|
|
90
|
+
start: undefined
|
|
91
|
+
};
|
|
84
92
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
93
|
+
this.setState({
|
|
94
|
+
queryObject,
|
|
95
|
+
selectedType: type,
|
|
96
|
+
selectedVideo: undefined,
|
|
97
|
+
videos: [],
|
|
98
|
+
searching: true
|
|
99
|
+
}, this.searchVideos(queryObject, type));
|
|
100
|
+
}
|
|
101
|
+
loadMoreVideos() {
|
|
102
|
+
const {
|
|
103
|
+
queryObject,
|
|
104
|
+
videos,
|
|
105
|
+
selectedType
|
|
106
|
+
} = this.state;
|
|
107
|
+
const {
|
|
108
|
+
searchVideos,
|
|
109
|
+
onError
|
|
110
|
+
} = this.props;
|
|
111
|
+
this.setState({
|
|
112
|
+
searching: true
|
|
113
|
+
});
|
|
114
|
+
searchVideos({
|
|
115
|
+
...queryObject,
|
|
116
|
+
offset: queryObject.offset + 10
|
|
117
|
+
}, selectedType).then(result => {
|
|
118
|
+
this.setState(prevState => ({
|
|
119
|
+
queryObject: {
|
|
120
|
+
...prevState.queryObject,
|
|
121
|
+
offset: prevState.queryObject.offset + 10
|
|
122
|
+
},
|
|
123
|
+
videos: videos.concat(result),
|
|
124
|
+
searching: false
|
|
125
|
+
}));
|
|
126
|
+
}).catch(err => {
|
|
127
|
+
onError(err);
|
|
90
128
|
this.setState({
|
|
91
|
-
|
|
129
|
+
searching: false
|
|
92
130
|
});
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
changeQueryPage(page) {
|
|
134
|
+
this.setState({
|
|
135
|
+
lastPage: 0
|
|
136
|
+
});
|
|
137
|
+
const {
|
|
138
|
+
queryObject
|
|
139
|
+
} = this.state;
|
|
140
|
+
const nextIndex = queryObject.start + (page.page - queryObject.page) * 10;
|
|
141
|
+
const newQueryObject = {
|
|
142
|
+
...queryObject,
|
|
143
|
+
...page,
|
|
144
|
+
start: nextIndex
|
|
145
|
+
};
|
|
146
|
+
this.searchVideos(newQueryObject);
|
|
147
|
+
}
|
|
148
|
+
submitVideoSearchQuery(query) {
|
|
149
|
+
const queryObject = {
|
|
150
|
+
...this.state.queryObject,
|
|
151
|
+
query
|
|
152
|
+
};
|
|
153
|
+
this.searchVideos(queryObject);
|
|
154
|
+
}
|
|
155
|
+
searchVideos(queryObject) {
|
|
156
|
+
let selectedType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.state.selectedType;
|
|
157
|
+
const {
|
|
158
|
+
searchVideos,
|
|
159
|
+
onError
|
|
160
|
+
} = this.props;
|
|
161
|
+
searchVideos(queryObject, selectedType).then(result => {
|
|
162
|
+
if (selectedType === this.state.selectedType) {
|
|
163
|
+
this.setState(prevState => ({
|
|
164
|
+
queryObject: {
|
|
165
|
+
...prevState.queryObject,
|
|
166
|
+
query: queryObject.query,
|
|
167
|
+
page: queryObject.page,
|
|
168
|
+
start: queryObject.start,
|
|
169
|
+
offset: 0
|
|
170
|
+
},
|
|
171
|
+
videos: selectedType === 'youtube' ? result.items : result,
|
|
172
|
+
searching: false,
|
|
173
|
+
lastPage: (0, _videoHelpers.getLastPage)(result, selectedType)
|
|
174
|
+
}));
|
|
115
175
|
}
|
|
176
|
+
}).catch(err => {
|
|
177
|
+
onError(err);
|
|
116
178
|
this.setState({
|
|
117
|
-
|
|
118
|
-
selectedType: type,
|
|
119
|
-
selectedVideo: undefined,
|
|
120
|
-
videos: [],
|
|
121
|
-
searching: true
|
|
122
|
-
}, this.searchVideos(queryObject, type));
|
|
123
|
-
}
|
|
124
|
-
}, {
|
|
125
|
-
key: "loadMoreVideos",
|
|
126
|
-
value: function loadMoreVideos() {
|
|
127
|
-
var _this2 = this;
|
|
128
|
-
var _this$state = this.state,
|
|
129
|
-
queryObject = _this$state.queryObject,
|
|
130
|
-
videos = _this$state.videos,
|
|
131
|
-
selectedType = _this$state.selectedType;
|
|
132
|
-
var _this$props = this.props,
|
|
133
|
-
searchVideos = _this$props.searchVideos,
|
|
134
|
-
onError = _this$props.onError;
|
|
135
|
-
this.setState({
|
|
136
|
-
searching: true
|
|
137
|
-
});
|
|
138
|
-
searchVideos(_objectSpread(_objectSpread({}, queryObject), {}, {
|
|
139
|
-
offset: queryObject.offset + 10
|
|
140
|
-
}), selectedType).then(function (result) {
|
|
141
|
-
_this2.setState(function (prevState) {
|
|
142
|
-
return {
|
|
143
|
-
queryObject: _objectSpread(_objectSpread({}, prevState.queryObject), {}, {
|
|
144
|
-
offset: prevState.queryObject.offset + 10
|
|
145
|
-
}),
|
|
146
|
-
videos: videos.concat(result),
|
|
147
|
-
searching: false
|
|
148
|
-
};
|
|
149
|
-
});
|
|
150
|
-
}).catch(function (err) {
|
|
151
|
-
onError(err);
|
|
152
|
-
_this2.setState({
|
|
153
|
-
searching: false
|
|
154
|
-
});
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
}, {
|
|
158
|
-
key: "changeQueryPage",
|
|
159
|
-
value: function changeQueryPage(page) {
|
|
160
|
-
this.setState({
|
|
161
|
-
lastPage: 0
|
|
162
|
-
});
|
|
163
|
-
var queryObject = this.state.queryObject;
|
|
164
|
-
var nextIndex = queryObject.start + (page.page - queryObject.page) * 10;
|
|
165
|
-
var newQueryObject = _objectSpread(_objectSpread(_objectSpread({}, queryObject), page), {}, {
|
|
166
|
-
start: nextIndex
|
|
167
|
-
});
|
|
168
|
-
this.searchVideos(newQueryObject);
|
|
169
|
-
}
|
|
170
|
-
}, {
|
|
171
|
-
key: "submitVideoSearchQuery",
|
|
172
|
-
value: function submitVideoSearchQuery(query) {
|
|
173
|
-
var queryObject = _objectSpread(_objectSpread({}, this.state.queryObject), {}, {
|
|
174
|
-
query: query
|
|
175
|
-
});
|
|
176
|
-
this.searchVideos(queryObject);
|
|
177
|
-
}
|
|
178
|
-
}, {
|
|
179
|
-
key: "searchVideos",
|
|
180
|
-
value: function searchVideos(queryObject) {
|
|
181
|
-
var _this3 = this;
|
|
182
|
-
var selectedType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.state.selectedType;
|
|
183
|
-
var _this$props2 = this.props,
|
|
184
|
-
searchVideos = _this$props2.searchVideos,
|
|
185
|
-
onError = _this$props2.onError;
|
|
186
|
-
searchVideos(queryObject, selectedType).then(function (result) {
|
|
187
|
-
if (selectedType === _this3.state.selectedType) {
|
|
188
|
-
_this3.setState(function (prevState) {
|
|
189
|
-
return {
|
|
190
|
-
queryObject: _objectSpread(_objectSpread({}, prevState.queryObject), {}, {
|
|
191
|
-
query: queryObject.query,
|
|
192
|
-
page: queryObject.page,
|
|
193
|
-
start: queryObject.start,
|
|
194
|
-
offset: 0
|
|
195
|
-
}),
|
|
196
|
-
videos: selectedType === 'youtube' ? result.items : result,
|
|
197
|
-
searching: false,
|
|
198
|
-
lastPage: (0, _videoHelpers.getLastPage)(result, selectedType)
|
|
199
|
-
};
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
}).catch(function (err) {
|
|
203
|
-
onError(err);
|
|
204
|
-
_this3.setState({
|
|
205
|
-
searching: false
|
|
206
|
-
});
|
|
179
|
+
searching: false
|
|
207
180
|
});
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
return (0, _jsxRuntime.jsx)(_pager.default, {
|
|
237
|
-
page: page || 1,
|
|
238
|
-
lastPage: lastPage,
|
|
239
|
-
onClick: _this4.changeQueryPage
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
render() {
|
|
184
|
+
const {
|
|
185
|
+
translations,
|
|
186
|
+
locale,
|
|
187
|
+
enabledSources
|
|
188
|
+
} = this.props;
|
|
189
|
+
const {
|
|
190
|
+
queryObject,
|
|
191
|
+
lastPage,
|
|
192
|
+
videos,
|
|
193
|
+
selectedVideo,
|
|
194
|
+
selectedType,
|
|
195
|
+
searching
|
|
196
|
+
} = this.state;
|
|
197
|
+
const {
|
|
198
|
+
query,
|
|
199
|
+
page
|
|
200
|
+
} = queryObject;
|
|
201
|
+
const paginationItem = () => {
|
|
202
|
+
if (selectedType === 'brightcove') {
|
|
203
|
+
return (0, _jsxRuntime.jsx)(_VideoLoadMoreButton.default, {
|
|
204
|
+
searching: searching,
|
|
205
|
+
videos: videos,
|
|
206
|
+
loadMoreVideos: this.loadMoreVideos,
|
|
207
|
+
limit: queryObject.limit,
|
|
208
|
+
translations: translations
|
|
240
209
|
});
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
content: (0, _jsxRuntime.jsx)("div", _objectSpread(_objectSpread({}, classes('list')), {}, {
|
|
247
|
-
children: selectedType === source.toLowerCase() && (0, _jsxRuntime.jsx)(_VideoSearchList.default, {
|
|
248
|
-
translations: translations,
|
|
249
|
-
selectedType: source.toLowerCase(),
|
|
250
|
-
selectedVideo: selectedVideo,
|
|
251
|
-
videos: videos,
|
|
252
|
-
locale: locale,
|
|
253
|
-
onVideoPreview: _this4.onVideoPreview,
|
|
254
|
-
searching: searching,
|
|
255
|
-
onSelectVideo: _this4.onSelectVideo
|
|
256
|
-
})
|
|
257
|
-
}))
|
|
258
|
-
};
|
|
210
|
+
}
|
|
211
|
+
return (0, _jsxRuntime.jsx)(_pager.default, {
|
|
212
|
+
page: page || 1,
|
|
213
|
+
lastPage: lastPage,
|
|
214
|
+
onClick: this.changeQueryPage
|
|
259
215
|
});
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
216
|
+
};
|
|
217
|
+
const searchListTabs = enabledSources.map(source => ({
|
|
218
|
+
title: source,
|
|
219
|
+
id: source,
|
|
220
|
+
content: (0, _jsxRuntime.jsx)("div", {
|
|
221
|
+
...classes('list'),
|
|
222
|
+
children: selectedType === source.toLowerCase() && (0, _jsxRuntime.jsx)(_VideoSearchList.default, {
|
|
223
|
+
translations: translations,
|
|
224
|
+
selectedType: source.toLowerCase(),
|
|
225
|
+
selectedVideo: selectedVideo,
|
|
226
|
+
videos: videos,
|
|
227
|
+
locale: locale,
|
|
228
|
+
onVideoPreview: this.onVideoPreview,
|
|
264
229
|
searching: searching,
|
|
265
|
-
|
|
266
|
-
})
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
230
|
+
onSelectVideo: this.onSelectVideo
|
|
231
|
+
})
|
|
232
|
+
})
|
|
233
|
+
}));
|
|
234
|
+
return (0, _jsxRuntime.jsxs)("div", {
|
|
235
|
+
...classes(),
|
|
236
|
+
children: [(0, _jsxRuntime.jsx)(_VideoSearchForm.default, {
|
|
237
|
+
onSearchQuerySubmit: this.submitVideoSearchQuery,
|
|
238
|
+
query: query,
|
|
239
|
+
searching: searching,
|
|
240
|
+
translations: translations
|
|
241
|
+
}), (0, _jsxRuntime.jsx)(_VideoTabs.default, {
|
|
242
|
+
searchTypes: selectedType,
|
|
243
|
+
tabs: searchListTabs,
|
|
244
|
+
onSearchTypeChange: this.onSearchTypeChange
|
|
245
|
+
}), paginationItem()]
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
}
|
|
276
249
|
VideoSearch.propTypes = {
|
|
277
250
|
onVideoSelect: _propTypes.default.func.isRequired,
|
|
278
251
|
searchVideos: _propTypes.default.func.isRequired,
|
|
@@ -288,5 +261,4 @@ VideoSearch.propTypes = {
|
|
|
288
261
|
VideoSearch.defaultProps = {
|
|
289
262
|
enabledSources: ['Brightcove']
|
|
290
263
|
};
|
|
291
|
-
var _default = VideoSearch;
|
|
292
|
-
exports.default = _default;
|
|
264
|
+
var _default = exports.default = VideoSearch;
|