@playkit-js/hotspots 3.2.22 → 3.2.23-canary.0-6b571ba
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@playkit-js/hotspots",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.23-canary.0-6b571ba",
|
|
4
4
|
"private": false,
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/kaltura/playkit-js-hotspots/issues"
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"conventional-github-releaser": "3.1.3",
|
|
20
20
|
"cross-env": "^7.0.3",
|
|
21
21
|
"css-loader": "^6.7.1",
|
|
22
|
-
"cypress": "
|
|
22
|
+
"cypress": "14.1.0",
|
|
23
23
|
"playwright-webkit": "^1.33.0",
|
|
24
24
|
"prettier": "^2.6.2",
|
|
25
25
|
"sass": "^1.52.3",
|
|
@@ -1,8 +1,18 @@
|
|
|
1
|
-
import {h, Component} from 'preact';
|
|
1
|
+
import {h, Component, createRef} from 'preact';
|
|
2
2
|
import {LayoutHotspot, shallowCompareHotspots} from '../utils/hotspot';
|
|
3
3
|
import Hotspot from './Hotspot';
|
|
4
4
|
import {AnalyticsEvents} from '../utils/analyticsEvents';
|
|
5
5
|
|
|
6
|
+
const { withPlayer } = KalturaPlayer.ui.components;
|
|
7
|
+
const { withText, Text } = KalturaPlayer.ui.preacti18n;
|
|
8
|
+
const translates = {
|
|
9
|
+
hotspotRemoved: (
|
|
10
|
+
<Text id="hotspots.hotspot_removed" fields={{ hotspotLabel: '' }}>
|
|
11
|
+
{`{hotspotLabel} hotspot removed`}
|
|
12
|
+
</Text>
|
|
13
|
+
)
|
|
14
|
+
};
|
|
15
|
+
|
|
6
16
|
const hotspotsContainerStyles = {
|
|
7
17
|
position: 'absolute',
|
|
8
18
|
display: 'block',
|
|
@@ -18,13 +28,48 @@ export interface Props {
|
|
|
18
28
|
pauseVideo(): void;
|
|
19
29
|
seekTo(time: number): void;
|
|
20
30
|
sendAnalytics(event: AnalyticsEvents): void;
|
|
21
|
-
dispatcher(name: string, payload?: any): void
|
|
31
|
+
dispatcher(name: string, payload?: any): void;
|
|
32
|
+
hotspotRemoved?: string;
|
|
33
|
+
player?: any;
|
|
22
34
|
}
|
|
23
35
|
|
|
36
|
+
@withPlayer
|
|
37
|
+
@withText(translates)
|
|
24
38
|
export default class HotspotWrapper extends Component<Props> {
|
|
39
|
+
|
|
40
|
+
private liveRegionRef = createRef<HTMLDivElement>();
|
|
41
|
+
private previousHotspotMap: Map<string, string> = new Map();
|
|
42
|
+
|
|
25
43
|
shouldComponentUpdate(nextProps: Props) {
|
|
26
44
|
return !shallowCompareHotspots(this.props.hotspots, nextProps.hotspots);
|
|
27
45
|
}
|
|
46
|
+
componentDidUpdate() {
|
|
47
|
+
const currentMap = new Map<string, string>(
|
|
48
|
+
this.props.hotspots
|
|
49
|
+
.filter(h => typeof h.label === 'string')
|
|
50
|
+
.map(h => [h.id, h.label!])
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
let announced = false;
|
|
54
|
+
this.previousHotspotMap.forEach((label, id) => {
|
|
55
|
+
if (!currentMap.has(id) && !announced) {
|
|
56
|
+
if (this.props.hotspotRemoved) {
|
|
57
|
+
const message = this.props.hotspotRemoved.replace('{hotspotLabel}', label);
|
|
58
|
+
this.announceHotspotChange(message);
|
|
59
|
+
}
|
|
60
|
+
announced = true;
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
this.previousHotspotMap = currentMap;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
private announceHotspotChange(message: string) {
|
|
68
|
+
const liveRegion = this.liveRegionRef.current;
|
|
69
|
+
if (!liveRegion) return;
|
|
70
|
+
liveRegion.textContent = '';
|
|
71
|
+
liveRegion.textContent = message;
|
|
72
|
+
}
|
|
28
73
|
|
|
29
74
|
private renderHotspots = (visualHotspot: LayoutHotspot[]) => {
|
|
30
75
|
if (!visualHotspot) {
|
|
@@ -40,10 +85,25 @@ export default class HotspotWrapper extends Component<Props> {
|
|
|
40
85
|
render() {
|
|
41
86
|
const {hotspots} = this.props;
|
|
42
87
|
const hotspotsElements = this.renderHotspots(hotspots);
|
|
88
|
+
const targetId = this.props.player?.config?.targetId;
|
|
89
|
+
const liveRegionId = `hotspot-liveRegion-${targetId}`;
|
|
43
90
|
|
|
44
91
|
return (
|
|
45
92
|
<div style={hotspotsContainerStyles} data-testid="hotspots_hotspotsContainer">
|
|
46
93
|
{hotspotsElements}
|
|
94
|
+
<div
|
|
95
|
+
ref={this.liveRegionRef}
|
|
96
|
+
id={liveRegionId}
|
|
97
|
+
aria-live="polite"
|
|
98
|
+
role="status"
|
|
99
|
+
style={{
|
|
100
|
+
position: 'absolute',
|
|
101
|
+
left: '-9999px',
|
|
102
|
+
width: '1px',
|
|
103
|
+
height: '1px',
|
|
104
|
+
overflow: 'hidden'
|
|
105
|
+
}}
|
|
106
|
+
/>
|
|
47
107
|
</div>
|
|
48
108
|
);
|
|
49
109
|
}
|