@scaleflex/widget-webcam 4.8.6 → 4.8.7

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.
@@ -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
+ };