@scaleflex/widget-webcam 0.0.1
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/CHANGELOG.md +7344 -0
- package/LICENSE +21 -0
- package/README.md +189 -0
- package/lib/CameraScreen.js +86 -0
- package/lib/PermissionsScreen.js +26 -0
- package/lib/Webcam.styled.js +78 -0
- package/lib/common.slice.js +30 -0
- package/lib/defaultLocale.js +13 -0
- package/lib/index.js +527 -0
- package/lib/supportsMediaRecorder.js +3 -0
- package/package.json +33 -0
- package/types/index.d.ts +25 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019 scaleflex
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
# `@scaleflex/widget-webcam`
|
|
2
|
+
|
|
3
|
+
[![Plugins][plugins-image]](#plugins)
|
|
4
|
+
[![Website][filerobot-image]][sfx-url]
|
|
5
|
+
[![Version][filerobot-version]][version-url]
|
|
6
|
+
[![Scaleflex team][made-by-image]][sfx-url]
|
|
7
|
+
[![License][license-image]][license-url]
|
|
8
|
+
[![CodeSandbox][codeSandbox-image]][codeSandbox-url]
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
<div align='center'>
|
|
12
|
+
<img title="Scaleflex Widget logo" alt="Scaleflex Widget logo" src="https://cdn.scaleflex.com/plugins/filerobot-widget/assets/filerobot_widget_logo_with_fire.png?vh=b2ff09" width="140"/>
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
The webcam plugin for [Scaleflex Media Asset Widget](https://www.npmjs.com/package/@scaleflex/widget-core) gives the possibility to take a photo and record video from the built-in camera and process them for uploading directly.
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
### NPM
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install --save @scaleflex/widget-webcam
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### YARN
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
yarn add @scaleflex/widget-webcam
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
then
|
|
32
|
+
|
|
33
|
+
```js
|
|
34
|
+
import Webcam from '@scaleflex/widget-webcam'
|
|
35
|
+
...
|
|
36
|
+
...
|
|
37
|
+
...
|
|
38
|
+
scaleflexWidget.use(Webcam, propertiesObject)
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### CDN
|
|
42
|
+
|
|
43
|
+
The plugin from CDN is found inside `Scaleflex` global object `Scaleflex.Webcam`
|
|
44
|
+
|
|
45
|
+
```js
|
|
46
|
+
const Webcam = window.ScaleflexWidget.Webcam
|
|
47
|
+
...
|
|
48
|
+
...
|
|
49
|
+
...
|
|
50
|
+
scaleflexWidget.use(Webcam, propertiesObject)
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Plugin's styles
|
|
54
|
+
|
|
55
|
+
```js
|
|
56
|
+
import '@scaleflex/widget-core/dist/style.css'
|
|
57
|
+
import '@scaleflex/widget-webcam/dist/style.css'
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
or if you prefer the minified version
|
|
61
|
+
|
|
62
|
+
```js
|
|
63
|
+
import '@scaleflex/widget-core/dist/style.min.css'
|
|
64
|
+
import '@scaleflex/widget-webcam/dist/style.min.css'
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
> The plugin's css file should be imported after the [Core's css file](../@scaleflex/widget-core/#modules-styles) for having the styles shown correctly.
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
## Properties
|
|
71
|
+
|
|
72
|
+
### `title`
|
|
73
|
+
|
|
74
|
+
<u>Type:</u> `string`.
|
|
75
|
+
|
|
76
|
+
<u>Default:</u> `'Camera'`
|
|
77
|
+
|
|
78
|
+
The title shown in the top bar of the panel.
|
|
79
|
+
|
|
80
|
+
### `countdown: `
|
|
81
|
+
|
|
82
|
+
<u>Type:</u> `number`.
|
|
83
|
+
|
|
84
|
+
<u>Default:</u> `0/false`
|
|
85
|
+
|
|
86
|
+
When capturing a photo, wait the amount of this countdown in seconds and then capture the photo with showing an informer message with the seconds left & Smile text when countdown is passed.
|
|
87
|
+
|
|
88
|
+
### `modes`
|
|
89
|
+
|
|
90
|
+
<u>Type:</u> `array`.
|
|
91
|
+
|
|
92
|
+
<u>Default:</u> `all modes allowed`
|
|
93
|
+
|
|
94
|
+
The modes allowed for the user:
|
|
95
|
+
- `video-audio`: Records a video file including the audio.
|
|
96
|
+
- `video-only`: Records a video file excluding audio.
|
|
97
|
+
- `audio-only`: Records audio only but no video.
|
|
98
|
+
- `picture`: Takes a photo from the camera.
|
|
99
|
+
|
|
100
|
+
### `mirror`
|
|
101
|
+
|
|
102
|
+
<u>Type:</u> `boolean`.
|
|
103
|
+
|
|
104
|
+
<u>Default:</u> `true`
|
|
105
|
+
|
|
106
|
+
Defines if you need to mirror the (preview image) or not.
|
|
107
|
+
|
|
108
|
+
### `facingMode`
|
|
109
|
+
|
|
110
|
+
<u>Type:</u> `string`.
|
|
111
|
+
|
|
112
|
+
<u>Default:</u> `'user'`
|
|
113
|
+
|
|
114
|
+
`In case device has multiple cameras this option gives the possibility to choose which one should be used:
|
|
115
|
+
- `user`: The video source is facing toward the user; this includes, for example, the front-facing camera on a smartphone.
|
|
116
|
+
- `environment`: The video source is facing away from the user, thereby viewing their environment. This is the back camera on a smartphone.
|
|
117
|
+
- `left`: The video source is facing toward the user but to their left, such as a camera aimed toward the user but over their left shoulder.
|
|
118
|
+
- `right`: The video source is facing toward the user but to their right, such as a camera aimed toward the user but over their right shoulder.
|
|
119
|
+
|
|
120
|
+
### `preferredImageMimeType`
|
|
121
|
+
|
|
122
|
+
<u>Type:</u> `string`.
|
|
123
|
+
|
|
124
|
+
<u>Default:</u> `'image/jpeg'`
|
|
125
|
+
|
|
126
|
+
Defines the captured image mime type ex. `image/png` if not defined or defined some un-supported mime type from the browser then `image/jpeg` would be used.
|
|
127
|
+
|
|
128
|
+
### `preferredVideoMimeType`
|
|
129
|
+
|
|
130
|
+
<u>Type:</u> `string`.
|
|
131
|
+
|
|
132
|
+
<u>Default:</u> `null`
|
|
133
|
+
|
|
134
|
+
The mime type for the recorded video to be saved with if you provided un-supported mime type then the browser's default would be used, if you left it `null` then if found any suitable type inside [`allowedFileTypes`](../core/README.md/#restrictions) it would be used.
|
|
135
|
+
|
|
136
|
+
### `showRecordingLength`
|
|
137
|
+
|
|
138
|
+
<u>Type:</u> `boolean`.
|
|
139
|
+
|
|
140
|
+
<u>Default:</u> `true`
|
|
141
|
+
|
|
142
|
+
Whether to show the video's recording length or not while it is in progress.
|
|
143
|
+
|
|
144
|
+
### `isRecordIconHidden`
|
|
145
|
+
|
|
146
|
+
<u>Type:</u> `boolean`.
|
|
147
|
+
|
|
148
|
+
<u>Default:</u> `false`
|
|
149
|
+
|
|
150
|
+
If set to `true`, the record button in webcam will be disabled preventing users from recording videos.
|
|
151
|
+
|
|
152
|
+
### `locale`
|
|
153
|
+
|
|
154
|
+
<u>Type:</u> `object`.
|
|
155
|
+
|
|
156
|
+
<u>Default:</u>
|
|
157
|
+
|
|
158
|
+
```js
|
|
159
|
+
strings: {
|
|
160
|
+
smile: 'Smile!',
|
|
161
|
+
takePicture: 'Take a picture',
|
|
162
|
+
startRecording: 'Begin video recording',
|
|
163
|
+
stopRecording: 'Stop video recording',
|
|
164
|
+
allowAccessTitle: 'Please allow access to your camera',
|
|
165
|
+
allowAccessDescription: 'In order to take pictures or record video with your camera, please allow camera access for this site.',
|
|
166
|
+
noCameraTitle: 'Camera Not Available',
|
|
167
|
+
noCameraDescription: 'In order to take pictures or record video, please connect a camera device',
|
|
168
|
+
recordingStoppedMaxSize: 'Recording stopped because the file size is about to exceed the limit',
|
|
169
|
+
recordingLength: 'Recording length %{recording_length}'
|
|
170
|
+
}
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
Customizing some of the translations or the language's strings and replace the default locale.
|
|
174
|
+
|
|
175
|
+
<!-- Variables -->
|
|
176
|
+
|
|
177
|
+
[npm-url]: https://www.npmjs.com/package/@scaleflex/widget-webcam
|
|
178
|
+
[license-url]: https://opensource.org/licenses/MIT
|
|
179
|
+
[sfx-url]: https://www.scaleflex.com/
|
|
180
|
+
[version-url]: https://www.npmjs.com/package/@scaleflex/widget-webcam
|
|
181
|
+
[codeSandbox-url]: https://codesandbox.io/s/filerobot-widget-v3-c5l9th
|
|
182
|
+
|
|
183
|
+
[npm-image]: https://img.shields.io/npm/v/@telus/remark-config.svg?style=for-the-badge&logo=npm
|
|
184
|
+
[license-image]: https://img.shields.io/badge/license-MIT-blue.svg?style=for-the-badge
|
|
185
|
+
[made-by-image]: https://img.shields.io/badge/%3C%2F%3E%20with%20%E2%99%A5%20by-the%20Scaleflex%20team-6986fa.svg?style=for-the-badge
|
|
186
|
+
[plugins-image]: https://img.shields.io/static/v1?label=Scaleflex&message=Plugins&color=yellow&style=for-the-badge
|
|
187
|
+
[filerobot-image]: https://img.shields.io/static/v1?label=Scaleflex&message=website&color=orange&style=for-the-badge
|
|
188
|
+
[filerobot-version]: https://img.shields.io/npm/v/@scaleflex/widget-webcam?label=Version&style=for-the-badge&logo=npm
|
|
189
|
+
[codeSandbox-image]: https://img.shields.io/badge/CodeSandbox-black?style=for-the-badge&logo=CodeSandbox
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
import { Photos, Video2 } from '@scaleflex/icons';
|
|
3
|
+
import formatSeconds from '@scaleflex/widget-utils/lib/formatSeconds';
|
|
4
|
+
import Styled from './Webcam.styled';
|
|
5
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
|
+
function isModeAvailable(modes, mode) {
|
|
7
|
+
return modes.indexOf(mode) !== -1;
|
|
8
|
+
}
|
|
9
|
+
var CameraScreen = function CameraScreen(_ref) {
|
|
10
|
+
var showRecordingLength = _ref.showRecordingLength,
|
|
11
|
+
supportsRecording = _ref.supportsRecording,
|
|
12
|
+
modes = _ref.modes,
|
|
13
|
+
src = _ref.src,
|
|
14
|
+
mirror = _ref.mirror,
|
|
15
|
+
isRecording = _ref.isRecording,
|
|
16
|
+
recordingLengthSeconds = _ref.recordingLengthSeconds,
|
|
17
|
+
_ref$onSnapshot = _ref.onSnapshot,
|
|
18
|
+
onSnapshot = _ref$onSnapshot === void 0 ? function () {} : _ref$onSnapshot,
|
|
19
|
+
_ref$onFocus = _ref.onFocus,
|
|
20
|
+
onFocus = _ref$onFocus === void 0 ? function () {} : _ref$onFocus,
|
|
21
|
+
_ref$onStop = _ref.onStop,
|
|
22
|
+
onStop = _ref$onStop === void 0 ? function () {} : _ref$onStop,
|
|
23
|
+
_ref$onStartRecording = _ref.onStartRecording,
|
|
24
|
+
onStartRecording = _ref$onStartRecording === void 0 ? function () {} : _ref$onStartRecording,
|
|
25
|
+
_ref$onStopRecording = _ref.onStopRecording,
|
|
26
|
+
onStopRecording = _ref$onStopRecording === void 0 ? function () {} : _ref$onStopRecording,
|
|
27
|
+
isRecordIconHidden = _ref.isRecordIconHidden;
|
|
28
|
+
var videoElement = useRef();
|
|
29
|
+
var formattedRecordingLengthSeconds = formatSeconds(recordingLengthSeconds);
|
|
30
|
+
var shouldShowRecordButton = supportsRecording && !isRecordIconHidden && (isModeAvailable(modes, 'video-only') || isModeAvailable(modes, 'audio-only') || isModeAvailable(modes, 'video-audio'));
|
|
31
|
+
var shouldShowSnapshotButton = isModeAvailable(modes, 'picture');
|
|
32
|
+
var shouldShowRecordingLength = supportsRecording && showRecordingLength && isRecording;
|
|
33
|
+
useEffect(function () {
|
|
34
|
+
onFocus();
|
|
35
|
+
return function () {
|
|
36
|
+
onStop();
|
|
37
|
+
};
|
|
38
|
+
}, []);
|
|
39
|
+
useEffect(function () {
|
|
40
|
+
if (videoElement !== null && videoElement !== void 0 && videoElement.current) {
|
|
41
|
+
videoElement.current.srcObject = src;
|
|
42
|
+
}
|
|
43
|
+
}, [src]);
|
|
44
|
+
var renderRecordingButton = function renderRecordingButton() {
|
|
45
|
+
if (isRecording) {
|
|
46
|
+
return /*#__PURE__*/_jsx(Styled.StopRecodingButton, {
|
|
47
|
+
onClick: onStopRecording,
|
|
48
|
+
children: /*#__PURE__*/_jsx(Styled.StopRecordingIcon, {})
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return /*#__PURE__*/_jsx(Styled.IconButton, {
|
|
52
|
+
color: "primary",
|
|
53
|
+
onClick: onStartRecording,
|
|
54
|
+
children: /*#__PURE__*/_jsx(Video2, {
|
|
55
|
+
size: 26
|
|
56
|
+
})
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
return /*#__PURE__*/_jsxs(Styled.WebcamContainer, {
|
|
60
|
+
className: "filerobot filerobot-Webcam-container",
|
|
61
|
+
children: [/*#__PURE__*/_jsx(Styled.VideoContainer, {
|
|
62
|
+
className: "filerobot-Webcam-videoContainer",
|
|
63
|
+
children: /*#__PURE__*/_jsx(Styled.Video, {
|
|
64
|
+
ref: videoElement,
|
|
65
|
+
mirror: mirror,
|
|
66
|
+
autoPlay: true,
|
|
67
|
+
className: "filerobot-Webcam-video",
|
|
68
|
+
muted: true,
|
|
69
|
+
playsInline: true
|
|
70
|
+
})
|
|
71
|
+
}), /*#__PURE__*/_jsxs(Styled.ButtonsContainer, {
|
|
72
|
+
className: "filerobot-Webcam-buttonContainer",
|
|
73
|
+
children: [shouldShowRecordingLength && /*#__PURE__*/_jsxs(Styled.RecordingLengthContainer, {
|
|
74
|
+
children: [/*#__PURE__*/_jsx(Styled.RecordingIcon, {}), formattedRecordingLengthSeconds || '00:00']
|
|
75
|
+
}), shouldShowSnapshotButton && /*#__PURE__*/_jsx(Styled.IconButton, {
|
|
76
|
+
color: "primary",
|
|
77
|
+
onClick: onSnapshot,
|
|
78
|
+
hidden: isRecording,
|
|
79
|
+
children: /*#__PURE__*/_jsx(Photos, {
|
|
80
|
+
size: 26
|
|
81
|
+
})
|
|
82
|
+
}), shouldShowRecordButton && renderRecordingButton()]
|
|
83
|
+
})]
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
export default CameraScreen;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { CameraNotAvailable, CameraNoAccess } from '@scaleflex/icons';
|
|
2
|
+
import Styled from './Webcam.styled';
|
|
3
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
|
+
var PermissionsScreen = function PermissionsScreen(_ref) {
|
|
5
|
+
var hasCamera = _ref.hasCamera,
|
|
6
|
+
i18n = _ref.i18n;
|
|
7
|
+
return /*#__PURE__*/_jsxs(Styled.PermissonsWrapper, {
|
|
8
|
+
className: "filerobot-Webcam-permissons",
|
|
9
|
+
children: [/*#__PURE__*/_jsx(Styled.IconWrapper, {
|
|
10
|
+
children: hasCamera ? /*#__PURE__*/_jsx(CameraNotAvailable, {
|
|
11
|
+
className: "filerobot-Webcam-permissonsIcon",
|
|
12
|
+
size: 100
|
|
13
|
+
}) : /*#__PURE__*/_jsx(CameraNoAccess, {
|
|
14
|
+
className: "filerobot-Webcam-permissonsIcon",
|
|
15
|
+
size: 100
|
|
16
|
+
})
|
|
17
|
+
}), /*#__PURE__*/_jsx(Styled.Title, {
|
|
18
|
+
className: "filerobot-Webcam-title",
|
|
19
|
+
children: hasCamera ? i18n('webcamAllowAccessTitle') : i18n('webcamNoCameraAvailableText')
|
|
20
|
+
}), /*#__PURE__*/_jsx(Styled.Description, {
|
|
21
|
+
className: "filerobot-Webcam-description",
|
|
22
|
+
children: hasCamera ? i18n('webcamAllowAccessDescriptionText') : i18n('webcamNoCameraDescriptionText')
|
|
23
|
+
})]
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
export default PermissionsScreen;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15;
|
|
2
|
+
function _taggedTemplateLiteral(e, t) { return t || (t = e.slice(0)), Object.freeze(Object.defineProperties(e, { raw: { value: Object.freeze(t) } })); }
|
|
3
|
+
import styled, { keyframes, css } from 'styled-components';
|
|
4
|
+
import { IconButton as SfxIconButton } from '@scaleflex/ui/core';
|
|
5
|
+
import { FV, PC } from '@scaleflex/widget-common';
|
|
6
|
+
var pluseKeyframes = keyframes(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n 0% {\n transform: scale(0.95);\n box-shadow: 0 0 0 0 rgba(246, 61, 61, 0.7);\n }\n\n 70% {\n transform: scale(1);\n box-shadow: 0 0 0 10px rgba(246, 61, 61, 0);\n }\n\n 100% {\n transform: scale(0.95);\n box-shadow: 0 0 0 0 rgba(246, 61, 61, 0);\n }\n"])));
|
|
7
|
+
var PulseAnimation = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n animation: ", " 2s infinite;\n"])), pluseKeyframes);
|
|
8
|
+
var WebcamContainer = styled.div(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n width: 100%;\n height: 100%;\n display: flex;\n justify-content: center;\n align-items: center;\n flex-direction: column;\n position: relative;\n"])));
|
|
9
|
+
var VideoContainer = styled.div(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n width: 100%;\n flex: 1;\n flex-grow: 1;\n overflow: hidden;\n position: relative;\n padding: 24px;\n background-color: ", ";\n"])), function (_ref) {
|
|
10
|
+
var palette = _ref.theme.palette;
|
|
11
|
+
return palette[PC.BackgroundActive];
|
|
12
|
+
});
|
|
13
|
+
var Video = styled.video(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n max-width: calc(100% - 48px);\n max-height: calc(100% - 48px);\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n margin: auto;\n transform: ", ";\n"])), function (_ref2) {
|
|
14
|
+
var mirror = _ref2.mirror;
|
|
15
|
+
return mirror ? 'scaleX(-1)' : 'scaleX (1)';
|
|
16
|
+
});
|
|
17
|
+
var ButtonsContainer = styled.div(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n display: flex;\n height: 100px;\n padding: 24px 32px;\n column-gap: 12px;\n width: 100%;\n justify-content: center;\n align-items: center;\n border-top: 1px solid ", ";\n"])), function (_ref3) {
|
|
18
|
+
var palette = _ref3.theme.palette;
|
|
19
|
+
return palette[PC.BordersSecondary];
|
|
20
|
+
});
|
|
21
|
+
var IconButton = styled(SfxIconButton)(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n width: 52px;\n height: 52px;\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: 50%;\n padding: 0;\n transition: all 300ms ease-in-out;\n"])));
|
|
22
|
+
var StopRecodingButton = styled(IconButton)(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n border: 0;\n background-color: ", ";\n\n &:hover {\n background-color: ", ";\n }\n"])), function (_ref4) {
|
|
23
|
+
var palette = _ref4.theme.palette;
|
|
24
|
+
return palette[PC.Error];
|
|
25
|
+
}, function (_ref5) {
|
|
26
|
+
var palette = _ref5.theme.palette;
|
|
27
|
+
return palette[PC.ErrorHover];
|
|
28
|
+
});
|
|
29
|
+
var StopRecordingIcon = styled.div(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n width: 17.88px;\n height: 17.88px;\n border-radius: 2px;\n background-color: ", ";\n"])), function (_ref6) {
|
|
30
|
+
var palette = _ref6.theme.palette;
|
|
31
|
+
return palette[PC.BackgroundSecondary];
|
|
32
|
+
});
|
|
33
|
+
var RecordingIcon = styled.div(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["\n width: 14px;\n height: 14px;\n background-color: ", ";\n border-radius: 50%;\n ", "\n"])), function (_ref7) {
|
|
34
|
+
var palette = _ref7.theme.palette;
|
|
35
|
+
return palette[PC.Error];
|
|
36
|
+
}, PulseAnimation);
|
|
37
|
+
var PermissonsWrapper = styled.div(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["\n width: 100%;\n height: 100%;\n padding: 0 32px;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n row-gap: 8px;\n"])));
|
|
38
|
+
var IconWrapper = styled.div(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["\n width: 100px;\n height: 100px;\n color: ", ";\n"])), function (_ref8) {
|
|
39
|
+
var palette = _ref8.theme.palette;
|
|
40
|
+
return palette[PC.BackgroundPrimaryStateless];
|
|
41
|
+
});
|
|
42
|
+
var Title = styled.p(_templateObject13 || (_templateObject13 = _taggedTemplateLiteral(["\n margin: 0;\n font-size: 24px;\n color: ", ";\n ", ";\n"])), function (_ref9) {
|
|
43
|
+
var palette = _ref9.theme.palette;
|
|
44
|
+
return palette[PC.TextPrimary];
|
|
45
|
+
}, function (_ref10) {
|
|
46
|
+
var typography = _ref10.theme.typography;
|
|
47
|
+
return typography.font[FV.LabelExtraLarge];
|
|
48
|
+
});
|
|
49
|
+
var Description = styled.p(_templateObject14 || (_templateObject14 = _taggedTemplateLiteral(["\n margin: 0;\n width: 408px;\n text-align: center;\n ", ";\n color: ", ";\n"])), function (_ref11) {
|
|
50
|
+
var typography = _ref11.theme.typography;
|
|
51
|
+
return typography.font[FV.TextLarge];
|
|
52
|
+
}, function (_ref12) {
|
|
53
|
+
var palette = _ref12.theme.palette;
|
|
54
|
+
return palette[PC.TextSecondary];
|
|
55
|
+
});
|
|
56
|
+
var RecordingLengthContainer = styled.div(_templateObject15 || (_templateObject15 = _taggedTemplateLiteral(["\n position: absolute;\n bottom: 124px;\n left: 50%;\n transform: translateX(-50%);\n z-index: 10;\n color: ", ";\n background-color: ", ";\n border-radius: 4%;\n padding: 12px 16px;\n display: flex;\n align-items: center;\n column-gap: 12px;\n font-size: 24px;\n line-height: 28px;\n font-weight: 500;\n min-width: 119px;\n height: 52px;\n"])), function (_ref13) {
|
|
57
|
+
var palette = _ref13.theme.palette;
|
|
58
|
+
return palette[PC.ButtonPrimaryText];
|
|
59
|
+
}, function (_ref14) {
|
|
60
|
+
var palette = _ref14.theme.palette;
|
|
61
|
+
return palette[PC.Extra_0_9_Overlay];
|
|
62
|
+
});
|
|
63
|
+
var Styled = {
|
|
64
|
+
WebcamContainer: WebcamContainer,
|
|
65
|
+
VideoContainer: VideoContainer,
|
|
66
|
+
Video: Video,
|
|
67
|
+
ButtonsContainer: ButtonsContainer,
|
|
68
|
+
IconButton: IconButton,
|
|
69
|
+
PermissonsWrapper: PermissonsWrapper,
|
|
70
|
+
IconWrapper: IconWrapper,
|
|
71
|
+
Title: Title,
|
|
72
|
+
Description: Description,
|
|
73
|
+
StopRecodingButton: StopRecodingButton,
|
|
74
|
+
StopRecordingIcon: StopRecordingIcon,
|
|
75
|
+
RecordingIcon: RecordingIcon,
|
|
76
|
+
RecordingLengthContainer: RecordingLengthContainer
|
|
77
|
+
};
|
|
78
|
+
export default Styled;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
import { createSlice } from '@reduxjs/toolkit';
|
|
8
|
+
import { PLUGINS_IDS } from '@scaleflex/widget-utils/lib/constants';
|
|
9
|
+
var initialState = {
|
|
10
|
+
cameraReady: false,
|
|
11
|
+
hasCamera: null,
|
|
12
|
+
cameraError: null,
|
|
13
|
+
recordingLengthSeconds: 0,
|
|
14
|
+
isRecording: false
|
|
15
|
+
};
|
|
16
|
+
var commonSlice = createSlice({
|
|
17
|
+
name: PLUGINS_IDS.WEBCAM,
|
|
18
|
+
initialState: initialState,
|
|
19
|
+
reducers: {
|
|
20
|
+
webcamCommonStateUpdated: function webcamCommonStateUpdated(state, action) {
|
|
21
|
+
return _objectSpread(_objectSpread({}, state), action.payload);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
var webcamCommonStateUpdated = commonSlice.actions.webcamCommonStateUpdated;
|
|
26
|
+
export { webcamCommonStateUpdated };
|
|
27
|
+
export var selectWebcamCommonState = function selectWebcamCommonState(state) {
|
|
28
|
+
return state[PLUGINS_IDS.WEBCAM];
|
|
29
|
+
};
|
|
30
|
+
export default commonSlice.reducer;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
webcamSmileInfo: 'Smile!',
|
|
3
|
+
webcamTakePictureTitle: 'Take a picture',
|
|
4
|
+
webcamStartRecordingTitle: 'Begin video recording',
|
|
5
|
+
webcamStopRecordingTitle: 'Stop video recording',
|
|
6
|
+
webcamAllowAccessTitle: 'Please allow access to your camera',
|
|
7
|
+
webcamAllowAccessDescriptionText: 'In order to take pictures or record video with your camera, please allow camera access for this site.',
|
|
8
|
+
webcamNoCameraAvailableText: 'Camera Not Available',
|
|
9
|
+
webcamNoCameraDescriptionText: 'In order to take pictures or record video, please connect a camera device',
|
|
10
|
+
webcamRecordingStoppedMaxSizeInfo: 'Recording stopped because the file size is about to exceed the limit',
|
|
11
|
+
webcamRecordingLengthLabel: 'Recording length %{recording_length}',
|
|
12
|
+
webcamWaitFewSecsAndTryInfo: 'Preparing camera, please wait few seconds and click record again'
|
|
13
|
+
};
|