@guestbell/react-page-plugins
Version:
Plugins we use in GuestBell for working with amazing react-page package
99 lines (98 loc) • 4.18 kB
JavaScript
/*
* This file is part of ORY Editor.
*
* ORY Editor is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ORY Editor is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with ORY Editor. If not, see <http://www.gnu.org/licenses/>.
*
* @license LGPL-3.0
* @copyright 2016-2018 Aeneas Rekkas
* @author Aeneas Rekkas <aeneas+oss@aeneas.io>
*
*/
import TextField from '@mui/material/TextField';
import * as React from 'react';
import { defaultVideoState } from '../default/state';
import Tabs from '@mui/material/Tabs';
import Tab from '@mui/material/Tab';
import { VideoTypeEnum } from '../types/enum/VideoTypeEnum';
import EmbeddedIcon from '@mui/icons-material/YouTube';
import UploadedIcon from '@mui/icons-material/PlayArrow';
var Form = function Form(props) {
var readOnly = props.readOnly,
onChange = props.onChange,
_props$data = props.data,
_props$data2 = _props$data === void 0 ? defaultVideoState : _props$data,
_props$data2$type = _props$data2.type,
type = _props$data2$type === void 0 ? props.defaultType : _props$data2$type,
_props$data2$embedded = _props$data2.embeddedSrc,
embeddedSrc = _props$data2$embedded === void 0 ? '' : _props$data2$embedded,
_props$data2$uploaded = _props$data2.uploadedSrc,
uploadedSrc = _props$data2$uploaded === void 0 ? '' : _props$data2$uploaded;
var changeEmbeddedSrc = React.useCallback(function (src) {
onChange({
embeddedSrc: src
});
}, [onChange]);
var changeUploadedSrc = React.useCallback(function (src) {
onChange({
uploadedSrc: src
});
}, [onChange]);
var changeType = React.useCallback(function (type) {
onChange({
type: type
});
}, [onChange]);
var handleTabTypeChange = React.useCallback(function (e, tabType) {
return changeType(tabType);
}, [changeType]);
var handleEmbeddedSrcChange = React.useCallback(function (e) {
return changeEmbeddedSrc(e.target.value);
}, [changeEmbeddedSrc]);
var handleUploadedSrcChange = React.useCallback(function (e) {
return changeUploadedSrc(e.target.value);
}, [changeUploadedSrc]);
return !readOnly ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Tabs, {
value: type,
onChange: handleTabTypeChange,
centered: true
}, (props.enabledTypes & VideoTypeEnum.Embedded) > 0 && /*#__PURE__*/React.createElement(Tab, {
icon: /*#__PURE__*/React.createElement(EmbeddedIcon, {
color: (type & VideoTypeEnum.Embedded) > 0 ? 'primary' : 'action'
}),
label: "Embedded",
value: VideoTypeEnum.Embedded
}), (props.enabledTypes & VideoTypeEnum.Uploaded) > 0 && /*#__PURE__*/React.createElement(Tab, {
icon: /*#__PURE__*/React.createElement(UploadedIcon, {
color: (type & VideoTypeEnum.Uploaded) > 0 ? 'primary' : 'action'
}),
label: "Uploaded",
value: VideoTypeEnum.Uploaded
})), /*#__PURE__*/React.createElement("div", {
className: "p-3"
}, type === VideoTypeEnum.Embedded && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TextField, {
fullWidth: true,
placeholder: props.translations.embeddedPlaceholder,
label: props.translations.embeddedLabel,
value: embeddedSrc,
onChange: handleEmbeddedSrcChange
})), type === VideoTypeEnum.Uploaded && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TextField, {
fullWidth: true,
placeholder: props.translations.uploadedPlaceholder,
label: props.translations.uploadedLabel,
value: uploadedSrc,
onChange: handleUploadedSrcChange
})))) : null;
};
export default Form;
//# sourceMappingURL=VideoDefaultControls.js.map