@playkit-js/transcript 3.0.1-canary.44-4c445bb → 3.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 +1 -1
- package/dist/playkit-transcript.js +1 -1
- package/dist/playkit-transcript.js.map +1 -1
- package/package.json +3 -3
- package/src/components/caption/caption.tsx +24 -20
- package/src/components/caption-list/captionList.tsx +5 -5
- package/src/components/close-button/index.tsx +3 -9
- package/src/components/download-print-menu/download-print-menu.scss +16 -0
- package/src/components/download-print-menu/download-print-menu.tsx +84 -48
- package/src/components/plugin-button/plugin-button.tsx +2 -10
- package/src/components/popover-menu/index.ts +1 -0
- package/src/components/popover-menu/popover-menu.scss +6 -0
- package/src/components/popover-menu/popover-menu.tsx +52 -0
- package/src/components/search/search.tsx +57 -93
- package/src/components/transcript/transcript.tsx +7 -22
- package/src/transcript-plugin.tsx +31 -18
- package/src/utils/index.ts +1 -0
- package/src/utils/popover/popover.scss +30 -0
- package/src/utils/popover/popover.tsx +178 -0
- package/src/components/popover/index.ts +0 -1
- package/src/components/popover/popover.scss +0 -43
- package/src/components/popover/popover.tsx +0 -142
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import {h, Component, VNode} from 'preact';
|
|
2
|
-
import {A11yWrapper, OnClickEvent} from '@playkit-js/common';
|
|
3
|
-
import * as styles from './popover.scss';
|
|
4
|
-
|
|
5
|
-
const {Tooltip} = KalturaPlayer.ui.components;
|
|
6
|
-
const {ENTER, ESC, SPACE, TAB} = KalturaPlayer.ui.utils.KeyMap;
|
|
7
|
-
|
|
8
|
-
export interface PopoverMenuItem {
|
|
9
|
-
label?: string;
|
|
10
|
-
onMenuChosen: () => void;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
interface PopoverProps {
|
|
14
|
-
label: string;
|
|
15
|
-
options: Array<PopoverMenuItem>;
|
|
16
|
-
children: VNode;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
interface PopoverState {
|
|
20
|
-
open: boolean;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export class Popover extends Component<PopoverProps, PopoverState> {
|
|
24
|
-
private _controlElementRef: HTMLDivElement | null = null;
|
|
25
|
-
private _popoverElementRef: HTMLDivElement | null = null;
|
|
26
|
-
private _firstOptionElementRef: HTMLDivElement | null = null;
|
|
27
|
-
|
|
28
|
-
state = {
|
|
29
|
-
open: false
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
componentWillUnmount() {
|
|
33
|
-
this._removeListeners();
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
private _handleMouseEvent = (event: MouseEvent) => {
|
|
37
|
-
if (!this._controlElementRef?.contains(event.target as Node | null)) {
|
|
38
|
-
this._closePopover();
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
private _handleKeyboardEvent = (event: KeyboardEvent) => {
|
|
43
|
-
if (this._controlElementRef?.contains(event.target as Node | null) && [ENTER, SPACE].includes(event.keyCode)) {
|
|
44
|
-
// use handler of control element
|
|
45
|
-
event.preventDefault();
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
if (this._popoverElementRef?.contains(event.target as Node | null) && event.keyCode !== ESC) {
|
|
49
|
-
// use handler of popover element
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
this._closePopover();
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
private _openPopover = (byKeyboard?: boolean) => {
|
|
56
|
-
this.setState({open: true});
|
|
57
|
-
setTimeout(() => {
|
|
58
|
-
// add listeners after component got re-render
|
|
59
|
-
this._addListeners();
|
|
60
|
-
if (byKeyboard && this._firstOptionElementRef) {
|
|
61
|
-
this._firstOptionElementRef.focus();
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
private _closePopover = () => {
|
|
67
|
-
this._removeListeners();
|
|
68
|
-
this.setState({open: false});
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
private _togglePopover = (e: MouseEvent | KeyboardEvent, byKeyboard?: boolean) => {
|
|
72
|
-
if (this.state.open) {
|
|
73
|
-
this._closePopover();
|
|
74
|
-
} else {
|
|
75
|
-
this._openPopover(byKeyboard);
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
private _addListeners = () => {
|
|
79
|
-
document.addEventListener('click', this._handleMouseEvent);
|
|
80
|
-
document.addEventListener('keydown', this._handleKeyboardEvent);
|
|
81
|
-
};
|
|
82
|
-
private _removeListeners = () => {
|
|
83
|
-
document.removeEventListener('click', this._handleMouseEvent);
|
|
84
|
-
document.removeEventListener('keydown', this._handleKeyboardEvent);
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
private _handleClickOnOptoin = (cb: () => void) => (event: OnClickEvent, byKeyboard?: boolean) => {
|
|
88
|
-
this._closePopover();
|
|
89
|
-
cb();
|
|
90
|
-
if (byKeyboard) {
|
|
91
|
-
setTimeout(() => {});
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
render(props: PopoverProps) {
|
|
95
|
-
const {open} = this.state;
|
|
96
|
-
const content = <A11yWrapper onClick={this._togglePopover}>{props.children}</A11yWrapper>;
|
|
97
|
-
return (
|
|
98
|
-
<div className={styles.popoverContainer}>
|
|
99
|
-
<div
|
|
100
|
-
className="popover-anchor-container"
|
|
101
|
-
ref={node => {
|
|
102
|
-
this._controlElementRef = node;
|
|
103
|
-
}}>
|
|
104
|
-
{open ? (
|
|
105
|
-
content
|
|
106
|
-
) : (
|
|
107
|
-
<Tooltip label={props.label} type="bottom">
|
|
108
|
-
{content}
|
|
109
|
-
</Tooltip>
|
|
110
|
-
)}
|
|
111
|
-
</div>
|
|
112
|
-
<div
|
|
113
|
-
aria-expanded={open}
|
|
114
|
-
ref={node => {
|
|
115
|
-
this._popoverElementRef = node;
|
|
116
|
-
}}
|
|
117
|
-
className={['popover', styles.popoverComponent, styles.bottom, styles.left, open ? '' : styles.hidden].join(' ')}>
|
|
118
|
-
<div className={styles.popoverMenu} role="menu">
|
|
119
|
-
{props.options.map((el, index) => {
|
|
120
|
-
return (
|
|
121
|
-
<A11yWrapper onClick={this._handleClickOnOptoin(el.onMenuChosen)}>
|
|
122
|
-
<div
|
|
123
|
-
tabIndex={0}
|
|
124
|
-
role="menuitem"
|
|
125
|
-
aria-label={el.label}
|
|
126
|
-
className={styles.popoverMenuItem}
|
|
127
|
-
ref={node => {
|
|
128
|
-
if (index === 0) {
|
|
129
|
-
this._firstOptionElementRef = node;
|
|
130
|
-
}
|
|
131
|
-
}}>
|
|
132
|
-
{el.label}
|
|
133
|
-
</div>
|
|
134
|
-
</A11yWrapper>
|
|
135
|
-
);
|
|
136
|
-
})}
|
|
137
|
-
</div>
|
|
138
|
-
</div>
|
|
139
|
-
</div>
|
|
140
|
-
);
|
|
141
|
-
}
|
|
142
|
-
}
|