@24i/bigscreen-sdk 1.0.4-alpha.2109 → 1.0.4-alpha.2112
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 +1 -1
- package/packages/epg/README.md +1 -0
- package/packages/epg/src/v2/Epg.tsx +20 -2
- package/packages/epg/src/v2/IdleController.ts +25 -0
- package/packages/epg/src/v2/InputEvents.ts +7 -0
- package/packages/epg/src/v2/basic/RowsManager.tsx +2 -1
- package/packages/epg/src/v2/interface.ts +18 -1
- package/packages/keyboard/src/WhitelabelKeyboard/Keyboard.scss +1 -2
package/package.json
CHANGED
package/packages/epg/README.md
CHANGED
|
@@ -20,6 +20,7 @@ This package contains a prepared Electronic Program Guide component.
|
|
|
20
20
|
- `fetchPrograms` - the function to fetch more programs for a channel in a given time range
|
|
21
21
|
- `timelineWidthMs` - optional - the width of the timeline (the part where the programs are) in milliseconds (defaults to `90 minutes`)
|
|
22
22
|
- `scrollStepMs` - optional - the amount of movement step left/right in milliseconds (defaults to `0.5 hours`)
|
|
23
|
+
- `idleTimerMs` - optional - the amount of ms without user input after which epg jumps to the current time (defaults to `scrollStepMs`)
|
|
23
24
|
- `timelineSectionWidthMs` - optional - the width of timeline header section (above rows) in milliseconds (defaults to `0.5 hours`)
|
|
24
25
|
- `limitFromMs` - optional - left limit for movement (cannot go more into history) (defaults to `-Infinity`)
|
|
25
26
|
- `limitToMs` - optional - right limit for movement (cannot go further into future) (defaults to `Infinity`)
|
|
@@ -15,6 +15,7 @@ import { TimelineSection } from './TimelineSection';
|
|
|
15
15
|
import { EpgMouseNavigation } from './MouseNavigation';
|
|
16
16
|
import { DataManager } from './DataManager';
|
|
17
17
|
import { InputEvents } from './InputEvents';
|
|
18
|
+
import { IdleController } from './IdleController';
|
|
18
19
|
import { shouldRenderDatePicker, clamp } from './utils';
|
|
19
20
|
import {
|
|
20
21
|
Props,
|
|
@@ -73,7 +74,9 @@ export class Epg<
|
|
|
73
74
|
|
|
74
75
|
focused: EpgFocus = 'epg';
|
|
75
76
|
|
|
76
|
-
private readonly
|
|
77
|
+
private readonly idleController: IdleController;
|
|
78
|
+
|
|
79
|
+
private readonly inputEvents: InputEvents;
|
|
77
80
|
|
|
78
81
|
static defaultProps = {
|
|
79
82
|
timelineWidthMs: DEFAULT_TIMELINE_WIDTH_IN_MIN * MINUTE_IN_MS,
|
|
@@ -128,7 +131,7 @@ export class Epg<
|
|
|
128
131
|
constructor(props: Props<T, U, V, W>) {
|
|
129
132
|
super(props);
|
|
130
133
|
const {
|
|
131
|
-
initialTimestamp, timeProvider,
|
|
134
|
+
initialTimestamp, timeProvider, scrollStepMs, idleTimerMs,
|
|
132
135
|
channelData, timelineWidthMs, fetchPrograms,
|
|
133
136
|
} = this.props;
|
|
134
137
|
|
|
@@ -143,6 +146,8 @@ export class Epg<
|
|
|
143
146
|
this.dataManagers = map(channelData, (channel) => (
|
|
144
147
|
new DataManager(channel, timelineWidthMs, fetchPrograms, this)
|
|
145
148
|
));
|
|
149
|
+
this.idleController = new IdleController(idleTimerMs ?? scrollStepMs, this.onIdle);
|
|
150
|
+
this.inputEvents = new InputEvents(this, this.idleController.onKeyDown);
|
|
146
151
|
}
|
|
147
152
|
|
|
148
153
|
componentDidMount() {
|
|
@@ -153,6 +158,7 @@ export class Epg<
|
|
|
153
158
|
|
|
154
159
|
componentWillUnmount() {
|
|
155
160
|
this.time.destroy();
|
|
161
|
+
this.idleController.clear();
|
|
156
162
|
}
|
|
157
163
|
|
|
158
164
|
private readonly onDatePickerChange = (timestamp: number) => {
|
|
@@ -211,6 +217,13 @@ export class Epg<
|
|
|
211
217
|
}
|
|
212
218
|
};
|
|
213
219
|
|
|
220
|
+
private readonly onIdle = () => {
|
|
221
|
+
const now = this.time.getCurrentTime();
|
|
222
|
+
this.setCurrentTime(now);
|
|
223
|
+
this.setFocusTimestamp(now);
|
|
224
|
+
this.setFocusToEpg();
|
|
225
|
+
};
|
|
226
|
+
|
|
214
227
|
setFocusTimestamp(timestamp: number, allowScroll = true) {
|
|
215
228
|
const { timelineWidthMs, scrollStepMs, limitFromMs, limitToMs } = this.props;
|
|
216
229
|
this.focusTimestamp = timestamp;
|
|
@@ -363,6 +376,10 @@ export class Epg<
|
|
|
363
376
|
return this.inputEvents.isVerticallyFastScrolling();
|
|
364
377
|
}
|
|
365
378
|
|
|
379
|
+
isFocusInRows = () => {
|
|
380
|
+
return this.focused === 'epg';
|
|
381
|
+
};
|
|
382
|
+
|
|
366
383
|
render() {
|
|
367
384
|
const {
|
|
368
385
|
datePickerProps, timelineWidthPx, channelHeaderWidthPx, scrollStepMs, rowHeightPx,
|
|
@@ -426,6 +443,7 @@ export class Epg<
|
|
|
426
443
|
onMouseEnter={this.onMouseEnter}
|
|
427
444
|
renderChannelHeader={renderChannelHeader}
|
|
428
445
|
renderProgram={renderProgram}
|
|
446
|
+
isFocusInRows={this.isFocusInRows}
|
|
429
447
|
/>
|
|
430
448
|
<EpgMouseNavigation
|
|
431
449
|
// @ts-ignore - needed to convert fallback (false) to interface
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createTimeout } from '@24i/bigscreen-sdk/utils/timers';
|
|
2
|
+
|
|
3
|
+
export class IdleController {
|
|
4
|
+
private timeout = createTimeout();
|
|
5
|
+
|
|
6
|
+
constructor(
|
|
7
|
+
private intervalMs: number,
|
|
8
|
+
private onIdleCallback: () => void,
|
|
9
|
+
) {
|
|
10
|
+
this.timeout.set(this.onTimeout, this.intervalMs);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
onKeyDown = () => {
|
|
14
|
+
this.timeout.set(this.onTimeout, this.intervalMs);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
onTimeout = () => {
|
|
18
|
+
this.timeout.set(this.onTimeout, this.intervalMs);
|
|
19
|
+
this.onIdleCallback();
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
clear() {
|
|
23
|
+
this.timeout.clear();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -23,6 +23,7 @@ export class InputEvents {
|
|
|
23
23
|
|
|
24
24
|
constructor(
|
|
25
25
|
private readonly epg: InternalEpg<any, any, any, any>,
|
|
26
|
+
private readonly onUserInput: () => void,
|
|
26
27
|
) {}
|
|
27
28
|
|
|
28
29
|
onKeyDown = (event: KeyboardEvent) => {
|
|
@@ -44,6 +45,7 @@ export class InputEvents {
|
|
|
44
45
|
this.stopFastHorizontalScrolling();
|
|
45
46
|
this.stopFastVerticalScrolling();
|
|
46
47
|
}
|
|
48
|
+
this.onUserInput();
|
|
47
49
|
};
|
|
48
50
|
|
|
49
51
|
onKeyUp = (event: KeyboardEvent) => {
|
|
@@ -188,6 +190,7 @@ export class InputEvents {
|
|
|
188
190
|
|
|
189
191
|
onWheel = (e: WheelEvent) => {
|
|
190
192
|
const processed = e.deltaY > 0 ? this.onWheelDown() : this.onWheelUp();
|
|
193
|
+
this.onUserInput();
|
|
191
194
|
if (processed) {
|
|
192
195
|
stopEvent(e);
|
|
193
196
|
this.setVerticalScroll(ARROWS_FACTOR);
|
|
@@ -266,21 +269,25 @@ export class InputEvents {
|
|
|
266
269
|
}
|
|
267
270
|
|
|
268
271
|
onMouseClickUp = () => {
|
|
272
|
+
this.onUserInput();
|
|
269
273
|
this.onUp();
|
|
270
274
|
this.fakeMouseClickStop();
|
|
271
275
|
};
|
|
272
276
|
|
|
273
277
|
onMouseClickDown = () => {
|
|
278
|
+
this.onUserInput();
|
|
274
279
|
this.onDown();
|
|
275
280
|
this.fakeMouseClickStop();
|
|
276
281
|
};
|
|
277
282
|
|
|
278
283
|
onMouseClickLeft = () => {
|
|
284
|
+
this.onUserInput();
|
|
279
285
|
this.onLeft();
|
|
280
286
|
this.fakeMouseClickStop();
|
|
281
287
|
};
|
|
282
288
|
|
|
283
289
|
onMouseClickRight = () => {
|
|
290
|
+
this.onUserInput();
|
|
284
291
|
this.onRight();
|
|
285
292
|
this.fakeMouseClickStop();
|
|
286
293
|
};
|
|
@@ -72,6 +72,7 @@ export class RowsManager<
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
onFastScrollingEnd() {
|
|
75
|
+
const { isFocusInRows } = this.props;
|
|
75
76
|
this.isFastScrolling = false;
|
|
76
77
|
if (this.coiBeforeFastScrolling < this.channelOffsetIndex) {
|
|
77
78
|
const { navigatableRows } = this.props;
|
|
@@ -82,7 +83,7 @@ export class RowsManager<
|
|
|
82
83
|
this.updateRowsBackward();
|
|
83
84
|
}
|
|
84
85
|
// it is same if we scroll horizontally and at that case we do not need to do anything
|
|
85
|
-
this.focusCurrentRowAtTimestamp();
|
|
86
|
+
if (isFocusInRows()) this.focusCurrentRowAtTimestamp();
|
|
86
87
|
this.setCurrentRowActive();
|
|
87
88
|
forEach(this.rows, ({ current: row }) => {
|
|
88
89
|
row!.onFastScrollingEnd();
|
|
@@ -212,6 +212,14 @@ type RenderTimeProp<T extends TimelineSection> = {
|
|
|
212
212
|
renderTime: TimeRenderer<T>,
|
|
213
213
|
};
|
|
214
214
|
|
|
215
|
+
type IsFocusInRowsProp = {
|
|
216
|
+
/**
|
|
217
|
+
* Returns whether the focus is in Rows part of the epg.
|
|
218
|
+
* @returns true fif cosu is in rows part, false otherwise
|
|
219
|
+
*/
|
|
220
|
+
isFocusInRows: () => boolean,
|
|
221
|
+
};
|
|
222
|
+
|
|
215
223
|
type RowHeightPxProp = {
|
|
216
224
|
/**
|
|
217
225
|
* The height of the EPG row in pixels
|
|
@@ -233,6 +241,14 @@ type ScrollStepMsProp = {
|
|
|
233
241
|
scrollStepMs: number,
|
|
234
242
|
};
|
|
235
243
|
|
|
244
|
+
type IdleTimerMsProp = {
|
|
245
|
+
/**
|
|
246
|
+
* The number of milliseconds of inactivity (no input) after which EPG starts jumps
|
|
247
|
+
* to the current time.
|
|
248
|
+
*/
|
|
249
|
+
idleTimerMs: number,
|
|
250
|
+
};
|
|
251
|
+
|
|
236
252
|
type TimeProp = {
|
|
237
253
|
/**
|
|
238
254
|
* The time interface that provides current time and time change events
|
|
@@ -806,6 +822,7 @@ export type RowsManagerProps<
|
|
|
806
822
|
& OnFocusChangeProp<U>
|
|
807
823
|
& RenderChannelHeaderProp<T>
|
|
808
824
|
& RenderProgramProp<U>
|
|
825
|
+
& IsFocusInRowsProp
|
|
809
826
|
);
|
|
810
827
|
|
|
811
828
|
/**
|
|
@@ -1250,6 +1267,7 @@ export type Props<
|
|
|
1250
1267
|
& FetchProgramsProp
|
|
1251
1268
|
& Partial<TimelineWidthMsProp>
|
|
1252
1269
|
& Partial<ScrollStepMsProp>
|
|
1270
|
+
& Partial<IdleTimerMsProp>
|
|
1253
1271
|
& Partial<TimelineSectionWidthMsProp>
|
|
1254
1272
|
& Partial<LimitFromMsProp>
|
|
1255
1273
|
& Partial<LimitToMsProp>
|
|
@@ -1267,7 +1285,6 @@ export type Props<
|
|
|
1267
1285
|
& Partial<RenderTimeProp<W>>
|
|
1268
1286
|
& Partial<DatePickerProp>
|
|
1269
1287
|
& Partial<PluginsProp<U>>
|
|
1270
|
-
|
|
1271
1288
|
);
|
|
1272
1289
|
|
|
1273
1290
|
/**
|