@appquality/unguess-design-system 2.12.63 → 2.12.65
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
CHANGED
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
# v2.12.65 (Mon Jan 30 2023)
|
|
2
|
+
|
|
3
|
+
#### 🐛 Bug Fix
|
|
4
|
+
|
|
5
|
+
- Player fixes [#194](https://github.com/AppQuality/unguess-design-system/pull/194) ([@cannarocks](https://github.com/cannarocks))
|
|
6
|
+
|
|
7
|
+
#### Authors: 1
|
|
8
|
+
|
|
9
|
+
- Luca Cannarozzo ([@cannarocks](https://github.com/cannarocks))
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# v2.12.64 (Mon Jan 30 2023)
|
|
14
|
+
|
|
15
|
+
#### 🐛 Bug Fix
|
|
16
|
+
|
|
17
|
+
- refactor(controls): progress update must be attached to any ref change [#193](https://github.com/AppQuality/unguess-design-system/pull/193) ([@cannarocks](https://github.com/cannarocks))
|
|
18
|
+
|
|
19
|
+
#### Authors: 1
|
|
20
|
+
|
|
21
|
+
- Luca Cannarozzo ([@cannarocks](https://github.com/cannarocks))
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
1
25
|
# v2.12.62 (Mon Jan 30 2023)
|
|
2
26
|
|
|
3
27
|
#### 🐛 Bug Fix
|
package/build/index.js
CHANGED
|
@@ -4079,9 +4079,7 @@ const StyledDiv$2 = styled__default["default"].div `
|
|
|
4079
4079
|
color: ${({ theme }) => theme.palette.grey[300]};
|
|
4080
4080
|
}
|
|
4081
4081
|
`;
|
|
4082
|
-
const TimeLabel = ({ current, duration, }) => {
|
|
4083
|
-
return (jsxRuntime.jsx(StyledDiv$2, { children: jsxRuntime.jsxs(SM, Object.assign({ tag: "span" }, { children: [current, "/", duration] })) }));
|
|
4084
|
-
};
|
|
4082
|
+
const TimeLabel = ({ current, duration, }) => (jsxRuntime.jsx(StyledDiv$2, { children: jsxRuntime.jsxs(SM, Object.assign({ tag: "span" }, { children: [current, "/", duration] })) }));
|
|
4085
4083
|
|
|
4086
4084
|
var _path$8, _path2$1;
|
|
4087
4085
|
function _extends$9() { _extends$9 = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$9.apply(this, arguments); }
|
|
@@ -4124,24 +4122,25 @@ var SvgVolumeUnmutedFill = function SvgVolumeUnmutedFill(props) {
|
|
|
4124
4122
|
|
|
4125
4123
|
const AudioButton = (props) => {
|
|
4126
4124
|
const [isMuted, setIsMuted] = React.useState(false);
|
|
4125
|
+
const { videoRef } = props;
|
|
4127
4126
|
const hasAudio = (video) => {
|
|
4128
4127
|
if (!video) {
|
|
4129
4128
|
return false;
|
|
4130
4129
|
}
|
|
4131
|
-
const
|
|
4130
|
+
const videohasAudio = video.mozHasAudio ||
|
|
4132
4131
|
Boolean(video.webkitAudioDecodedByteCount) ||
|
|
4133
4132
|
Boolean(video.audioTracks && video.audioTracks.length);
|
|
4134
|
-
return
|
|
4133
|
+
return videohasAudio;
|
|
4135
4134
|
};
|
|
4136
4135
|
React.useEffect(() => {
|
|
4137
|
-
if (
|
|
4138
|
-
setIsMuted(!hasAudio(
|
|
4136
|
+
if (videoRef) {
|
|
4137
|
+
setIsMuted(!hasAudio(videoRef) || videoRef.muted);
|
|
4139
4138
|
}
|
|
4140
|
-
}, [
|
|
4141
|
-
return (jsxRuntime.jsx(IconButton, Object.assign({ isBright: true, disabled: !
|
|
4142
|
-
if (
|
|
4143
|
-
|
|
4144
|
-
setIsMuted(
|
|
4139
|
+
}, [videoRef]);
|
|
4140
|
+
return (jsxRuntime.jsx(IconButton, Object.assign({ isBright: true, disabled: !videoRef || !hasAudio(videoRef), onClick: (e) => {
|
|
4141
|
+
if (videoRef) {
|
|
4142
|
+
videoRef.muted = !videoRef.muted;
|
|
4143
|
+
setIsMuted(videoRef.muted);
|
|
4145
4144
|
}
|
|
4146
4145
|
e.stopPropagation();
|
|
4147
4146
|
} }, { children: isMuted ? jsxRuntime.jsx(SvgVolumeMutedFill, {}) : jsxRuntime.jsx(SvgVolumeUnmutedFill, {}) })));
|
|
@@ -4166,34 +4165,35 @@ const FullScreenButton = (props) => {
|
|
|
4166
4165
|
const { videoRef } = props;
|
|
4167
4166
|
const { requestFullscreen, webkitRequestFullscreen, mozRequestFullScreen, webkitEnterFullscreen, msRequestFullscreen, } = videoRef || {};
|
|
4168
4167
|
const handleFullScreen = React.useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
4169
|
-
if (
|
|
4170
|
-
if (
|
|
4171
|
-
yield
|
|
4168
|
+
if (videoRef) {
|
|
4169
|
+
if (videoRef.requestFullscreen) {
|
|
4170
|
+
yield videoRef.requestFullscreen();
|
|
4172
4171
|
}
|
|
4173
|
-
else if (
|
|
4174
|
-
yield
|
|
4172
|
+
else if (videoRef.webkitRequestFullscreen) {
|
|
4173
|
+
yield videoRef.webkitRequestFullscreen();
|
|
4175
4174
|
}
|
|
4176
|
-
else if (
|
|
4177
|
-
yield
|
|
4175
|
+
else if (videoRef.mozRequestFullScreen) {
|
|
4176
|
+
yield videoRef.mozRequestFullScreen();
|
|
4178
4177
|
}
|
|
4179
|
-
else if (
|
|
4178
|
+
else if (videoRef.webkitEnterFullscreen) {
|
|
4180
4179
|
// iOS
|
|
4181
|
-
yield
|
|
4180
|
+
yield videoRef.webkitEnterFullscreen();
|
|
4182
4181
|
}
|
|
4183
|
-
else if (
|
|
4184
|
-
yield
|
|
4182
|
+
else if (videoRef.msRequestFullscreen) {
|
|
4183
|
+
yield videoRef.msRequestFullscreen();
|
|
4185
4184
|
}
|
|
4186
4185
|
}
|
|
4187
|
-
}), [
|
|
4186
|
+
}), [videoRef]);
|
|
4188
4187
|
const canGoFullScreen = React.useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
4189
|
-
if (
|
|
4188
|
+
if (videoRef) {
|
|
4190
4189
|
return (requestFullscreen ||
|
|
4191
4190
|
webkitRequestFullscreen ||
|
|
4192
4191
|
mozRequestFullScreen ||
|
|
4193
4192
|
webkitEnterFullscreen ||
|
|
4194
4193
|
msRequestFullscreen);
|
|
4195
4194
|
}
|
|
4196
|
-
|
|
4195
|
+
return false;
|
|
4196
|
+
}), [videoRef]);
|
|
4197
4197
|
return (jsxRuntime.jsx(IconButton, Object.assign({ isBright: true, onClick: (e) => {
|
|
4198
4198
|
handleFullScreen();
|
|
4199
4199
|
e.stopPropagation();
|
|
@@ -4240,23 +4240,25 @@ const Controls = (props) => {
|
|
|
4240
4240
|
const [tooltipLabel, setTooltipLabel] = React.useState("00:00");
|
|
4241
4241
|
const progressRef = React.useRef(null);
|
|
4242
4242
|
const getVideoPositionFromEvent = (clientX) => {
|
|
4243
|
-
|
|
4243
|
+
const totalTime = (videoRef === null || videoRef === void 0 ? void 0 : videoRef.duration) || duration || 0;
|
|
4244
|
+
if (progressRef && progressRef.current && totalTime) {
|
|
4244
4245
|
const bounds = progressRef.current.getBoundingClientRect();
|
|
4245
4246
|
const x = clientX - bounds.left;
|
|
4246
|
-
const videoPositionSecs = (x / progressRef.current.clientWidth) *
|
|
4247
|
+
const videoPositionSecs = (x / progressRef.current.clientWidth) * totalTime;
|
|
4247
4248
|
return videoPositionSecs;
|
|
4248
4249
|
}
|
|
4249
4250
|
return 0;
|
|
4250
4251
|
};
|
|
4251
|
-
const handleProgressUpdate = () => {
|
|
4252
|
+
const handleProgressUpdate = React.useCallback(() => {
|
|
4253
|
+
const totalTime = (videoRef === null || videoRef === void 0 ? void 0 : videoRef.duration) || duration || 0;
|
|
4252
4254
|
const currentTime = (videoRef === null || videoRef === void 0 ? void 0 : videoRef.currentTime) || 0;
|
|
4253
|
-
setProgress((currentTime /
|
|
4254
|
-
};
|
|
4255
|
-
const handleSkipAhead = (pageX) => {
|
|
4255
|
+
setProgress((currentTime / totalTime) * 100);
|
|
4256
|
+
}, [duration, videoRef]);
|
|
4257
|
+
const handleSkipAhead = React.useCallback((pageX) => {
|
|
4256
4258
|
if (videoRef) {
|
|
4257
4259
|
videoRef.currentTime = getVideoPositionFromEvent(pageX);
|
|
4258
4260
|
}
|
|
4259
|
-
};
|
|
4261
|
+
}, [videoRef]);
|
|
4260
4262
|
const StyledDiv = styled__default["default"].div `
|
|
4261
4263
|
display: flex;
|
|
4262
4264
|
align-items: center;
|
|
@@ -4267,9 +4269,9 @@ const Controls = (props) => {
|
|
|
4267
4269
|
const maxMargin = progressRef.current.clientWidth - tooltipWidth;
|
|
4268
4270
|
const bounds = progressRef.current.getBoundingClientRect();
|
|
4269
4271
|
const marginX = e.clientX - bounds.left;
|
|
4270
|
-
const
|
|
4272
|
+
const newTooltipMargin = marginX >= maxMargin ? maxMargin : marginX;
|
|
4271
4273
|
const videoTargetDuration = getVideoPositionFromEvent(e.clientX);
|
|
4272
|
-
setTooltipMargin(
|
|
4274
|
+
setTooltipMargin(newTooltipMargin);
|
|
4273
4275
|
setTooltipLabel(formatDuration(videoTargetDuration));
|
|
4274
4276
|
}
|
|
4275
4277
|
};
|
|
@@ -4283,7 +4285,7 @@ const Controls = (props) => {
|
|
|
4283
4285
|
}
|
|
4284
4286
|
};
|
|
4285
4287
|
}, [videoRef]);
|
|
4286
|
-
return (jsxRuntime.jsxs(ControlsWrapper, Object.assign({ isPlaying: isPlaying }, { children: [jsxRuntime.jsxs(ProgressContainer, Object.assign({ onMouseEnter: onMouseEvent, onMouseMove: onMouseEvent, onMouseLeave: onMouseEvent }, { children: [jsxRuntime.jsx(StyledTooltip, Object.assign({ style: { marginLeft: tooltipMargin
|
|
4288
|
+
return (jsxRuntime.jsxs(ControlsWrapper, Object.assign({ isPlaying: isPlaying }, { children: [jsxRuntime.jsxs(ProgressContainer, Object.assign({ onMouseEnter: onMouseEvent, onMouseMove: onMouseEvent, onMouseLeave: onMouseEvent }, { children: [jsxRuntime.jsx(StyledTooltip, Object.assign({ style: { marginLeft: `${tooltipMargin}px` } }, { children: tooltipLabel })), jsxRuntime.jsx(TimeLabel, { current: formatDuration((videoRef === null || videoRef === void 0 ? void 0 : videoRef.currentTime) || 0), duration: formatDuration(duration) }), jsxRuntime.jsx(StyledProgress, { ref: progressRef, value: progress, onClick: (e) => handleSkipAhead(e.clientX) })] })), jsxRuntime.jsxs(ControlsBar, { children: [jsxRuntime.jsx(StyledDiv, { children: jsxRuntime.jsx(AudioButton, { videoRef: videoRef }) }), jsxRuntime.jsx(ControlsGroupCenter, { videoRef: videoRef, onPlayChange: onPlayChange, isPlaying: isPlaying }), jsxRuntime.jsx(StyledDiv, { children: jsxRuntime.jsx(FullScreenButton, { videoRef: videoRef }) })] })] })));
|
|
4287
4289
|
};
|
|
4288
4290
|
|
|
4289
4291
|
const FloatingContainer = styled__default["default"].div `
|
|
@@ -4313,8 +4315,8 @@ const ButtonsContainer = styled__default["default"].div `
|
|
|
4313
4315
|
height: 100%;
|
|
4314
4316
|
`;
|
|
4315
4317
|
const FloatingControls = (props) => {
|
|
4316
|
-
const { isPlaying } = props;
|
|
4317
|
-
return (jsxRuntime.jsx(FloatingContainer, Object.assign({ isPlaying: isPlaying }, { children: jsxRuntime.jsx(ButtonsContainer, { children: !isPlaying && (jsxRuntime.jsx(BigButton, Object.assign({ isBright: true }, { children: jsxRuntime.jsx(PlayIcon, {}) }))) }) })));
|
|
4318
|
+
const { isPlaying, onClick } = props;
|
|
4319
|
+
return (jsxRuntime.jsx(FloatingContainer, Object.assign({ isPlaying: isPlaying, onClick: onClick }, { children: jsxRuntime.jsx(ButtonsContainer, { children: !isPlaying && (jsxRuntime.jsx(BigButton, Object.assign({ isBright: true }, { children: jsxRuntime.jsx(PlayIcon, {}) }))) }) })));
|
|
4318
4320
|
};
|
|
4319
4321
|
|
|
4320
4322
|
const Container = styled__default["default"].div `
|
|
@@ -4386,6 +4388,10 @@ const Player = React.forwardRef((props, forwardRef) => {
|
|
|
4386
4388
|
setIsLoaded(true);
|
|
4387
4389
|
setDuration(((_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.duration) || 0);
|
|
4388
4390
|
};
|
|
4391
|
+
const handleDuration = React.useCallback(() => {
|
|
4392
|
+
var _a;
|
|
4393
|
+
setDuration(((_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.duration) || 0);
|
|
4394
|
+
}, [videoRef]);
|
|
4389
4395
|
const handlePlayPause = React.useCallback(() => {
|
|
4390
4396
|
if (!videoRef || !videoRef.current)
|
|
4391
4397
|
return;
|
|
@@ -4421,10 +4427,7 @@ const Player = React.forwardRef((props, forwardRef) => {
|
|
|
4421
4427
|
}
|
|
4422
4428
|
};
|
|
4423
4429
|
}, [videoRef.current]);
|
|
4424
|
-
return (jsxRuntime.jsxs(Container, Object.assign({ isLoaded: isLoaded, isPlaying: isPlaying, onClick: (
|
|
4425
|
-
e.stopPropagation();
|
|
4426
|
-
handlePlayPause();
|
|
4427
|
-
} }, { children: [!isLoaded ? (jsxRuntime.jsx(VideoSpinner, {})) : (jsxRuntime.jsx(FloatingControls, { isPlaying: isPlaying })), jsxRuntime.jsx(Video, Object.assign({ ref: videoRef, onLoadedMetadata: handleLoad, preload: "auto", playsInline: true }, { children: props.children })), jsxRuntime.jsx(Controls, { videoRef: videoRef.current, duration: duration, isPlaying: isPlaying, onPlayChange: (isPlaying) => setIsPlaying(isPlaying) })] })));
|
|
4430
|
+
return (jsxRuntime.jsxs(Container, Object.assign({ isLoaded: isLoaded, isPlaying: isPlaying }, { children: [!isLoaded ? (jsxRuntime.jsx(VideoSpinner, {})) : (jsxRuntime.jsx(FloatingControls, { isPlaying: isPlaying, onClick: handlePlayPause })), jsxRuntime.jsx(Video, Object.assign({ ref: videoRef, onLoadedMetadata: handleLoad, onLoad: handleDuration, preload: "auto", playsInline: true, onClick: handlePlayPause }, { children: props.children })), jsxRuntime.jsx(Controls, { videoRef: videoRef.current, duration: duration, isPlaying: isPlaying, onPlayChange: (playing) => setIsPlaying(playing) })] })));
|
|
4428
4431
|
});
|
|
4429
4432
|
|
|
4430
4433
|
var _path$5;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const ControlsGroupCenter: ({ videoRef, isPlaying, onPlayChange, }: {
|
|
2
2
|
videoRef: HTMLVideoElement | null;
|
|
3
3
|
isPlaying?: boolean | undefined;
|
|
4
|
-
onPlayChange?: ((
|
|
4
|
+
onPlayChange?: ((playing: boolean) => void) | undefined;
|
|
5
5
|
}) => JSX.Element;
|
|
@@ -2,4 +2,5 @@ import { WrapperProps } from "../_types";
|
|
|
2
2
|
export declare const FloatingContainer: import("styled-components").StyledComponent<"div", any, WrapperProps, never>;
|
|
3
3
|
export declare const FloatingControls: (props: {
|
|
4
4
|
isPlaying?: boolean;
|
|
5
|
+
onClick?: () => void;
|
|
5
6
|
}) => JSX.Element;
|