@24i/bigscreen-sdk 1.1.0 → 2.1.1-alpha.2133
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/README.md +1 -1
- package/package.json +34 -53
- package/packages/adobe-heartbeat/src/AdobeHeartbeat.ts +9 -9
- package/packages/async-image/src/AsyncImage.tsx +10 -15
- package/packages/developer-tools/PlayerDebugWindow/README.md +1 -1
- package/packages/developer-tools/src/DeveloperToolsService/DeveloperToolsList.tsx +0 -11
- package/packages/developer-tools/src/PlayerDebugWindow/PlayerDebugWindow.tsx +5 -5
- package/packages/developer-tools/src/PlayerDebugWindow/constants.ts +0 -15
- package/packages/developer-tools/src/TechnicalInfo/TechnicalInfoDetail.tsx +1 -2
- package/packages/developer-tools/src/TechnicalInfo/TechnicalInfoProvider.ts +3 -34
- package/packages/developer-tools/src/TechnicalInfo/__mocks__/Device.ts +0 -4
- package/packages/developer-tools/src/TechnicalInfo/translations.ts +0 -4
- package/packages/device/src/getKeyDigit.ts +2 -2
- package/packages/device/src/resolver/resolver.ts +5 -18
- package/packages/digital-clock/src/DigitalClock.tsx +4 -15
- package/packages/driver-androidtv/src/DeviceAndroidTV.ts +9 -54
- package/packages/driver-androidtv/src/__mocks__/javaScriptBridge.ts +5 -29
- package/packages/driver-androidtv/src/keymap.ts +0 -18
- package/packages/driver-androidtv/src/types.ts +16 -102
- package/packages/driver-base/src/DeviceBase.ts +2 -61
- package/packages/driver-base/src/KeyMap/Key.ts +1 -8
- package/packages/driver-base/src/KeyMap/KeyMap.ts +0 -4
- package/packages/driver-base/src/KeyMap/interface.ts +0 -1
- package/packages/driver-base/src/KeyMap/overrideValues.ts +1 -2
- package/packages/driver-base/src/__mocks__/keyMap.ts +0 -1
- package/packages/driver-base/src/types/DeviceEvent.ts +0 -2
- package/packages/driver-base/src/types/KeycodeKeyMap.ts +0 -1
- package/packages/driver-browser/src/keymap.ts +0 -8
- package/packages/driver-entone/src/keymap.ts +0 -1
- package/packages/driver-tizen/src/TizenKeys.ts +0 -2
- package/packages/driver-vidaa/src/DeviceVidaa.ts +2 -3
- package/packages/driver-vidaa/src/__mocks__/vidaa.ts +1 -1
- package/packages/driver-vidaa/src/keymap.ts +0 -2
- package/packages/driver-webos/src/DeviceWebos.ts +0 -8
- package/packages/driver-webos/src/keymap.ts +1 -2
- package/packages/driver-xbox/src/keymap.ts +1 -1
- package/packages/epg/README.md +1 -3
- package/packages/epg/src/v2/Cell.tsx +2 -16
- package/packages/epg/src/v2/DataManager.ts +41 -112
- package/packages/epg/src/v2/DatePicker.tsx +3 -9
- package/packages/epg/src/v2/DateToast/DateToast.tsx +9 -12
- package/packages/epg/src/v2/Day.tsx +3 -6
- package/packages/epg/src/v2/Epg.tsx +5 -5
- package/packages/epg/src/v2/MockGenerator/generator.ts +2 -3
- package/packages/epg/src/v2/ProgramInfo/utils.ts +3 -4
- package/packages/epg/src/v2/Row.tsx +1 -3
- package/packages/epg/src/v2/TimelineSection.tsx +1 -4
- package/packages/epg/src/v2/basic/CellsManager.tsx +2 -7
- package/packages/epg/src/v2/basic/RowsManager.tsx +1 -3
- package/packages/epg/src/v2/interface.ts +0 -13
- package/packages/events-manager/src/EventsManager.ts +56 -1
- package/packages/focus/README.md +0 -33
- package/packages/focus/src/IFocusable.ts +0 -1
- package/packages/focus/src/Layout/Base.tsx +6 -41
- package/packages/focus/src/Layout/Matrix.tsx +19 -51
- package/packages/focus/src/Layout/__test__/Base.spec.ts +180 -0
- package/packages/focus/src/Layout/__test__/Horizontal.spec.ts +94 -0
- package/packages/focus/src/Layout/__test__/Matrix.spec.ts +261 -0
- package/packages/focus/src/Layout/__test__/Vertical.spec.ts +46 -0
- package/packages/focus/src/Layout/__test__/isRtl.spec.ts +23 -0
- package/packages/focus/src/Layout/__test__/shared.ts +19 -0
- package/packages/focus/src/focusFirstExisting.ts +1 -7
- package/packages/focus/src/index.ts +1 -2
- package/packages/gallup/src/Gallup.ts +3 -3
- package/packages/grid/src/Base/Base.tsx +10 -15
- package/packages/grid/src/FirstOnlyGrid/FirstOnlyGrid.tsx +2 -4
- package/packages/icon/src/Icon.tsx +5 -27
- package/packages/input/README.md +1 -4
- package/packages/input/src/Input.tsx +29 -65
- package/packages/input/src/handleOverflow.ts +29 -0
- package/packages/interactable/README.md +1 -2
- package/packages/interactable/src/Interactable.tsx +3 -9
- package/packages/interactable/src/interface.ts +0 -1
- package/packages/jsx/src/index.ts +1 -1
- package/packages/jsx/src/test-utils/index.ts +0 -1
- package/packages/keyboard/src/Backdrop/Backdrop.scss +0 -2
- package/packages/keyboard/src/KeyboardBase.tsx +4 -16
- package/packages/keyboard/src/WhitelabelKeyboard/Keyboard.scss +0 -4
- package/packages/keyboard/src/WhitelabelKeyboard/Keyboard.tsx +20 -28
- package/packages/keyboard/src/WhitelabelKeyboard/_sizes.1080.scss +0 -1
- package/packages/keyboard/src/WhitelabelKeyboard/_sizes.scss +0 -1
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/index.ts +0 -11
- package/packages/keyboard/src/WhitelabelKeyboard/types.ts +0 -1
- package/packages/l10n/README.md +0 -18
- package/packages/l10n/src/date/common.ts +6 -18
- package/packages/l10n/src/date/cs.ts +8 -2
- package/packages/l10n/src/date/en-001.ts +3 -3
- package/packages/l10n/src/date/en-common.ts +4 -5
- package/packages/l10n/src/date/en-us.ts +3 -3
- package/packages/l10n/src/date/iso.ts +13 -12
- package/packages/l10n/src/date/types.ts +0 -9
- package/packages/l10n/src/l10n.ts +3 -61
- package/packages/list/src/Base/Base.tsx +9 -19
- package/packages/list/src/Base/interface.ts +2 -2
- package/packages/list/src/CenteredList/controller.ts +1 -0
- package/packages/list/src/EdgeOffsetList/EdgeOffsetList.tsx +3 -3
- package/packages/list/src/UnifiedListController/UnifiedListController.ts +2 -6
- package/packages/logger/src/loggers/SentryLogger/Sentry.ts +0 -1
- package/packages/logger/src/loggers/SentryLogger/SentryLogger.ts +2 -2
- package/packages/menu/src/MenuAndContentContainer/MenuAndContentContainer.tsx +3 -31
- package/packages/menu/src/MenuAndContentContainer/interface.ts +0 -8
- package/packages/modal-service/README.md +1 -4
- package/packages/modal-service/src/ModalService.tsx +5 -29
- package/packages/perf-utils/README.md +120 -1
- package/packages/perf-utils/src/array/filter.ts +54 -1
- package/packages/perf-utils/src/array/find.ts +43 -1
- package/packages/perf-utils/src/array/findIndex.ts +43 -1
- package/packages/perf-utils/src/array/forEach.ts +48 -1
- package/packages/perf-utils/src/array/includes.ts +41 -1
- package/packages/perf-utils/src/array/includesNaN.ts +32 -1
- package/packages/perf-utils/src/array/index.ts +7 -1
- package/packages/perf-utils/src/array/map.ts +52 -1
- package/packages/player-ui/README.md +1 -1
- package/packages/player-ui/src/CurrentTime.tsx +2 -2
- package/packages/player-ui/src/Duration.tsx +2 -2
- package/packages/player-ui/src/PauseButton.tsx +0 -8
- package/packages/player-ui/src/PlayerInteractable.tsx +0 -1
- package/packages/player-ui/src/PlayerTime.tsx +1 -3
- package/packages/player-ui/src/PlayerUI.tsx +35 -68
- package/packages/player-ui/src/RemainingTime.tsx +2 -2
- package/packages/player-ui/src/Seekbar.tsx +18 -110
- package/packages/player-ui/src/Seeking.ts +16 -57
- package/packages/player-ui/src/Subtitles.tsx +2 -2
- package/packages/player-ui/src/index.ts +0 -1
- package/packages/player-ui/src/mocks.ts +8 -32
- package/packages/player-ui/src/timeUtils.ts +3 -3
- package/packages/player-ui/src/types.ts +3 -9
- package/packages/router/src/Route.tsx +27 -61
- package/packages/router/src/Router.tsx +13 -59
- package/packages/router/src/history.ts +1 -8
- package/packages/router/src/index.ts +1 -1
- package/packages/router/src/utils.ts +4 -9
- package/packages/sass-utils/src/linear-gradient.scss +4 -9
- package/packages/sass-utils/src/scale.1080.scss +1 -3
- package/packages/sass-utils/src/scale.720.scss +1 -1
- package/packages/time/README.md +1 -4
- package/packages/time/src/Time.ts +13 -35
- package/packages/time/src/constants.ts +0 -1
- package/packages/toast/src/ToastService.tsx +5 -16
- package/packages/types-bigscreen-jsx/README.md +4 -5
- package/packages/types-bigscreen-jsx/index.d.ts +67 -72
- package/packages/utils/README.md +0 -27
- package/packages/utils/src/elementUtils.ts +0 -25
- package/packages/utils/src/index.ts +0 -8
- package/packages/utils/src/scaledImage.ts +3 -6
- package/packages/utils/src/textUtils.ts +14 -46
- package/packages/utils/src/wait.ts +1 -3
- package/packages/utils/src/xhr/xhrSend.ts +1 -3
- package/packages/utils/src/xhr/xhrSendRetry.ts +1 -3
- package/packages/zapping/src/ChannelZapping.ts +0 -9
- package/packages/zapping/src/Zapping.tsx +0 -10
- package/.vscode/settings.json +0 -6
- package/packages/analytics/README.md +0 -8
- package/packages/analytics/src/A.ts +0 -1
- package/packages/analytics/src/Analytics.ts +0 -1
- package/packages/analytics/src/analyticsOnScroll.ts +0 -1
- package/packages/analytics/src/clients/ConsoleAnalytics/ConsoleAnalytics.ts +0 -1
- package/packages/analytics/src/clients/ConsoleAnalytics/index.ts +0 -1
- package/packages/analytics/src/clients/GoogleAnalytics/GoogleAnalytics.ts +0 -200
- package/packages/analytics/src/clients/GoogleAnalytics/constants.ts +0 -118
- package/packages/analytics/src/clients/GoogleAnalytics/getUrl.ts +0 -17
- package/packages/analytics/src/clients/GoogleAnalytics/index.ts +0 -2
- package/packages/analytics/src/clients/GoogleAnalytics/interface.ts +0 -77
- package/packages/analytics/src/clients/GoogleAnalytics/mapPayload.ts +0 -50
- package/packages/analytics/src/clients/GoogleAnalytics/prepareBody.ts +0 -14
- package/packages/analytics/src/clients/TealiumAnalytics/TealiumAnalytics.ts +0 -169
- package/packages/analytics/src/clients/TealiumAnalytics/constants.ts +0 -102
- package/packages/analytics/src/clients/TealiumAnalytics/findIdForLanguage.ts +0 -9
- package/packages/analytics/src/clients/TealiumAnalytics/index.ts +0 -4
- package/packages/analytics/src/clients/TealiumAnalytics/interface.ts +0 -33
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/__mocks__/mediaPayload.ts +0 -70
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/helper.ts +0 -36
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapAppError.ts +0 -13
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapFavoriteAdd.ts +0 -11
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapFavoriteRemove.ts +0 -11
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapPlayerClose.ts +0 -15
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapPlayerOpen.ts +0 -15
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapSceneView.ts +0 -18
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapSearch.ts +0 -18
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapSearchFailed.ts +0 -8
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapSearchSuccess.ts +0 -8
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapVideoPause.ts +0 -15
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapVideoProgress.ts +0 -18
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapVideoResume.ts +0 -15
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapVideoStart.ts +0 -15
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapVideoStop.ts +0 -15
- package/packages/analytics/src/clients/TealiumAnalytics/types.ts +0 -156
- package/packages/analytics/src/clients/TwentyFourIQ/TwentyFourIQClient.ts +0 -116
- package/packages/analytics/src/clients/TwentyFourIQ/constants.ts +0 -99
- package/packages/analytics/src/clients/TwentyFourIQ/helper.ts +0 -34
- package/packages/analytics/src/clients/TwentyFourIQ/index.ts +0 -2
- package/packages/analytics/src/clients/TwentyFourIQ/interface.ts +0 -31
- package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapAdLoaded.ts +0 -13
- package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapAdSkipped.ts +0 -16
- package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapBase.ts +0 -21
- package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapBuffering.ts +0 -15
- package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapPlayerClose.ts +0 -24
- package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapPlayerOpen.ts +0 -18
- package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapSceneView.ts +0 -15
- package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapScroll.ts +0 -17
- package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapVideoComplete.ts +0 -21
- package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapVideoPause.ts +0 -24
- package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapVideoProgress.ts +0 -24
- package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapVideoStart.ts +0 -34
- package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapVideoStop.ts +0 -32
- package/packages/analytics/src/clients/TwentyFourIQ/types.ts +0 -115
- package/packages/analytics/src/constants.ts +0 -1
- package/packages/analytics/src/index.ts +0 -3
- package/packages/analytics/src/interface.ts +0 -1
- package/packages/analytics/src/utils/generateSessionId.ts +0 -8
- package/packages/create-package/dist/createPackage.js +0 -66
- package/packages/create-package/dist/createPackage.js.map +0 -1
- package/packages/create-package/dist/index.js +0 -5
- package/packages/create-package/dist/index.js.map +0 -1
- package/packages/create-package/dist/questionnaire/questions.js +0 -35
- package/packages/create-package/dist/questionnaire/questions.js.map +0 -1
- package/packages/create-package/dist/settings/Settings.js +0 -10
- package/packages/create-package/dist/settings/Settings.js.map +0 -1
- package/packages/create-package/dist/types.js +0 -3
- package/packages/create-package/dist/types.js.map +0 -1
- package/packages/device/src/driver/index.firetv.ts +0 -1
- package/packages/device/src/driver/index.smartcast.tv.ts +0 -1
- package/packages/driver-firetv/src/DeviceFireTV.ts +0 -18
- package/packages/driver-firetv/src/__mocks__/javaScriptBridge.ts +0 -36
- package/packages/driver-firetv/src/index.ts +0 -1
- package/packages/driver-smartcast/src/DeviceSmartCast.ts +0 -317
- package/packages/driver-smartcast/src/__mocks__/api.ts +0 -49
- package/packages/driver-smartcast/src/index.ts +0 -1
- package/packages/driver-smartcast/src/keymap.ts +0 -9
- package/packages/driver-smartcast/src/types.ts +0 -65
- package/packages/focus/src/hasFocus.ts +0 -36
- package/packages/input/src/utils.ts +0 -71
- package/packages/jsx/src/test-utils/keyup.ts +0 -27
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/arabic.ts +0 -27
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/burmese.ts +0 -27
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/dari.ts +0 -28
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/korean.ts +0 -26
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/pashto.ts +0 -27
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/persian.ts +0 -27
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/russian.ts +0 -27
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/tibetan.ts +0 -26
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/turkish.ts +0 -26
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/ukrainian.ts +0 -27
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/urdu.ts +0 -26
- package/packages/l10n/src/date/de.ts +0 -97
- package/packages/l10n/src/date/es.ts +0 -71
- package/packages/l10n/src/date/fr.ts +0 -94
- package/packages/l10n/src/date/he.ts +0 -101
- package/packages/time/src/adapters/24iMediaTimeApi.ts +0 -47
- package/packages/time/src/services/24iMediaTimeApi/24iMediaTimeApi.ts +0 -43
- package/packages/time/src/services/24iMediaTimeApi/index.ts +0 -6
- package/packages/utils/src/forceReflow.ts +0 -14
- package/packages/utils/src/keyPress/index.ts +0 -6
- package/packages/utils/src/keyPress/keyPressSimulator.ts +0 -74
- package/packages/utils/src/keyPress/simulateKeyPress.ts +0 -25
- package/utils/release/release.ts +0 -154
|
@@ -1,42 +1,33 @@
|
|
|
1
1
|
import { Component, createRef } from '@24i/bigscreen-sdk/jsx';
|
|
2
2
|
import { IFocusable } from '@24i/bigscreen-sdk/focus';
|
|
3
3
|
import { stopEvent } from '@24i/bigscreen-sdk/utils/stopEvent';
|
|
4
|
-
import { ITimeUpdateEvent, IDurationChangeEvent } from '@24i/
|
|
4
|
+
import { ITimeUpdateEvent, IDurationChangeEvent } from '@24i/player-base';
|
|
5
5
|
import { createTimeout } from '@24i/bigscreen-sdk/utils/timers';
|
|
6
6
|
import { switchByKey } from '@24i/bigscreen-sdk/device/keymap';
|
|
7
|
-
import { getDisplayToggler } from '@24i/bigscreen-sdk/utils/displayToggler';
|
|
8
7
|
import { PlayerTime } from './PlayerTime';
|
|
9
8
|
import { getLiveProgressBasedOnCurrentTime } from './timeUtils';
|
|
10
|
-
import {
|
|
9
|
+
import { PlayerUICommonProps } from './types';
|
|
11
10
|
|
|
12
11
|
const CONSECUTIVE_TIMEOUT = 500;
|
|
13
12
|
const FAST_TRESHOLD = 5;
|
|
14
13
|
const SLOW_TIME = 10000;
|
|
15
|
-
const FAST_TIME =
|
|
16
|
-
const SAFE_END_MARGIN = 10000;
|
|
14
|
+
const FAST_TIME = 20000;
|
|
17
15
|
const TO_PERCENT = 100;
|
|
18
16
|
|
|
19
|
-
type Props =
|
|
20
|
-
ui: IPlayerUIWithSeeking;
|
|
21
|
-
children?: JSX.Element;
|
|
22
|
-
} & PlayerUICommonProps;
|
|
17
|
+
type Props = PlayerUICommonProps;
|
|
23
18
|
|
|
24
19
|
export class Seekbar extends Component<Props> implements IFocusable {
|
|
25
20
|
wrap = createRef<HTMLDivElement>();
|
|
26
21
|
|
|
27
|
-
seekBarWrap = createRef<HTMLDivElement>();
|
|
28
|
-
|
|
29
22
|
seekBar = createRef<HTMLDivElement>();
|
|
30
23
|
|
|
31
24
|
seekPoint = createRef<HTMLDivElement>();
|
|
32
25
|
|
|
33
26
|
seekTime = createRef<PlayerTime>();
|
|
34
27
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
leftConsecutiveness = 0;
|
|
28
|
+
leftConsecutives = 0;
|
|
38
29
|
|
|
39
|
-
|
|
30
|
+
rightConsecutives = 0;
|
|
40
31
|
|
|
41
32
|
leftConsecutiveTimeout = createTimeout();
|
|
42
33
|
|
|
@@ -46,10 +37,6 @@ export class Seekbar extends Component<Props> implements IFocusable {
|
|
|
46
37
|
|
|
47
38
|
duration = 0;
|
|
48
39
|
|
|
49
|
-
isMouseDownPressed = false;
|
|
50
|
-
|
|
51
|
-
seekingDisabled = false;
|
|
52
|
-
|
|
53
40
|
static defaultProps = {
|
|
54
41
|
className: '',
|
|
55
42
|
};
|
|
@@ -58,59 +45,18 @@ export class Seekbar extends Component<Props> implements IFocusable {
|
|
|
58
45
|
const { ui } = this.props;
|
|
59
46
|
const playerInstance = ui.getPlayer();
|
|
60
47
|
this.duration = playerInstance.duration;
|
|
61
|
-
document.addEventListener('mouseup', this.onMouseUp);
|
|
62
|
-
document.addEventListener('mousemove', this.onMouseMove);
|
|
63
48
|
ui.seeking.addEventListener('seektimeupdate', this.onSeekTimeUpdate);
|
|
64
|
-
ui.seeking.addEventListener('stopautomaticseek', this.onStopAutomaticSeek);
|
|
65
49
|
ui.getPlayer().addEventListener('timeupdate', this.onTimeUpdate);
|
|
66
50
|
ui.getPlayer().addEventListener('durationchange', this.onDurationUpdate);
|
|
67
51
|
}
|
|
68
52
|
|
|
69
53
|
componentWillUnmount() {
|
|
70
54
|
const { ui } = this.props;
|
|
71
|
-
document.removeEventListener('mouseup', this.onMouseUp);
|
|
72
|
-
document.removeEventListener('mousemove', this.onMouseMove);
|
|
73
55
|
ui.seeking.removeEventListener('seektimeupdate', this.onSeekTimeUpdate);
|
|
74
|
-
ui.seeking.removeEventListener('stopautomaticseek', this.onStopAutomaticSeek);
|
|
75
56
|
ui.getPlayer().removeEventListener('timeupdate', this.onTimeUpdate);
|
|
76
57
|
ui.getPlayer().removeEventListener('durationchange', this.onDurationUpdate);
|
|
77
58
|
}
|
|
78
59
|
|
|
79
|
-
onMouseMove = (event: MouseEvent) => {
|
|
80
|
-
if (!this.isMouseDownPressed || this.seekingDisabled) return;
|
|
81
|
-
const { ui: { seeking } } = this.props;
|
|
82
|
-
const wrapRect = this.wrap.current!.getBoundingClientRect();
|
|
83
|
-
const clientX = event.clientX - wrapRect.left;
|
|
84
|
-
const wrapRight = wrapRect.right - wrapRect.left;
|
|
85
|
-
let percentage = (TO_PERCENT * clientX) / wrapRight;
|
|
86
|
-
percentage = Math.max(0, Math.min(TO_PERCENT, percentage));
|
|
87
|
-
const seekTo = Math.round((this.duration / TO_PERCENT) * percentage);
|
|
88
|
-
seeking.setSeekTime(seekTo);
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
onMouseClick = (event: MouseEvent) => {
|
|
92
|
-
if (this.seekingDisabled) return;
|
|
93
|
-
const { ui: { seeking } } = this.props;
|
|
94
|
-
const wrapWidth = this.wrap.current!.offsetWidth;
|
|
95
|
-
const percentage = (TO_PERCENT * event.offsetX) / wrapWidth;
|
|
96
|
-
const seekTo = Math.round((this.duration / TO_PERCENT) * percentage);
|
|
97
|
-
seeking.setSeekTime(seekTo);
|
|
98
|
-
seeking.confirmSeek();
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
onMouseDown = () => {
|
|
102
|
-
const { ui } = this.props;
|
|
103
|
-
this.isMouseDownPressed = true;
|
|
104
|
-
ui.disableHiding();
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
onMouseUp = () => {
|
|
108
|
-
const { ui } = this.props;
|
|
109
|
-
this.isMouseDownPressed = false;
|
|
110
|
-
ui.seeking.confirmSeek();
|
|
111
|
-
ui.enableHiding();
|
|
112
|
-
};
|
|
113
|
-
|
|
114
60
|
onKeyDown = (event: KeyboardEvent) => {
|
|
115
61
|
const processed = switchByKey(event, {
|
|
116
62
|
LEFT: this.onLeft,
|
|
@@ -126,50 +72,34 @@ export class Seekbar extends Component<Props> implements IFocusable {
|
|
|
126
72
|
};
|
|
127
73
|
|
|
128
74
|
onLeft = () => {
|
|
129
|
-
if (this.seekingDisabled) return true;
|
|
130
75
|
const { ui } = this.props;
|
|
131
|
-
this.
|
|
76
|
+
this.leftConsecutives += 1;
|
|
132
77
|
if (ui.seeking.isAutomaticallySeeking()) {
|
|
133
78
|
ui.seeking.stopAutomaticSeek();
|
|
134
79
|
}
|
|
135
|
-
ui.seeking.seekBackward(this.
|
|
80
|
+
ui.seeking.seekBackward(this.leftConsecutives >= FAST_TRESHOLD ? FAST_TIME : SLOW_TIME);
|
|
136
81
|
this.leftConsecutiveTimeout.set(() => {
|
|
137
|
-
this.
|
|
82
|
+
this.leftConsecutives = 0;
|
|
138
83
|
}, CONSECUTIVE_TIMEOUT);
|
|
139
84
|
return true;
|
|
140
85
|
};
|
|
141
86
|
|
|
142
87
|
onRight = () => {
|
|
143
|
-
if (this.seekingDisabled) return true;
|
|
144
88
|
const { ui } = this.props;
|
|
145
|
-
|
|
146
|
-
if (seekTime == null && this.currentTime + SLOW_TIME >= this.duration) return true;
|
|
147
|
-
this.rightConsecutiveness += 1;
|
|
89
|
+
this.rightConsecutives += 1;
|
|
148
90
|
if (ui.seeking.isAutomaticallySeeking()) {
|
|
149
91
|
ui.seeking.stopAutomaticSeek();
|
|
150
92
|
}
|
|
151
|
-
|
|
152
|
-
if (
|
|
153
|
-
(seekTime != null
|
|
154
|
-
&& (seekTime + SLOW_TIME >= this.duration - SAFE_END_MARGIN
|
|
155
|
-
|| (isFastSeeking && seekTime + FAST_TIME >= this.duration - SAFE_END_MARGIN)))
|
|
156
|
-
|| (seekTime == null && this.currentTime >= this.duration - SAFE_END_MARGIN)
|
|
157
|
-
) {
|
|
158
|
-
ui.seeking.setSeekTime(this.duration - SAFE_END_MARGIN);
|
|
159
|
-
} else {
|
|
160
|
-
ui.seeking.seekForward(isFastSeeking ? FAST_TIME : SLOW_TIME);
|
|
161
|
-
}
|
|
93
|
+
ui.seeking.seekForward(this.rightConsecutives >= FAST_TRESHOLD ? FAST_TIME : SLOW_TIME);
|
|
162
94
|
this.rightConsecutiveTimeout.set(() => {
|
|
163
|
-
this.
|
|
95
|
+
this.rightConsecutives = 0;
|
|
164
96
|
}, CONSECUTIVE_TIMEOUT);
|
|
165
97
|
return true;
|
|
166
98
|
};
|
|
167
99
|
|
|
168
100
|
onEnter = () => {
|
|
169
|
-
const { ui
|
|
170
|
-
|
|
171
|
-
if (!player.playing) player.play();
|
|
172
|
-
return seeking.confirmSeek();
|
|
101
|
+
const { ui } = this.props;
|
|
102
|
+
return ui.seeking.confirmSeek();
|
|
173
103
|
};
|
|
174
104
|
|
|
175
105
|
onSeekTimeUpdate = (seekTime: number) => {
|
|
@@ -178,11 +108,6 @@ export class Seekbar extends Component<Props> implements IFocusable {
|
|
|
178
108
|
this.updateSeekBar();
|
|
179
109
|
};
|
|
180
110
|
|
|
181
|
-
onStopAutomaticSeek = () => {
|
|
182
|
-
const { ui } = this.props;
|
|
183
|
-
ui.enableHiding();
|
|
184
|
-
};
|
|
185
|
-
|
|
186
111
|
onTimeUpdate = ({ currentTime }: ITimeUpdateEvent) => {
|
|
187
112
|
const { ui } = this.props;
|
|
188
113
|
this.currentTime = currentTime;
|
|
@@ -196,7 +121,7 @@ export class Seekbar extends Component<Props> implements IFocusable {
|
|
|
196
121
|
const { ui } = this.props;
|
|
197
122
|
const player = ui.getPlayer();
|
|
198
123
|
if (player.live) {
|
|
199
|
-
const { programStart = 0, programEnd = 0 } = player.
|
|
124
|
+
const { programStart = 0, programEnd = 0 } = player.getMetadata();
|
|
200
125
|
this.duration = programEnd - programStart || Date.now();
|
|
201
126
|
} else {
|
|
202
127
|
this.duration = duration;
|
|
@@ -208,7 +133,7 @@ export class Seekbar extends Component<Props> implements IFocusable {
|
|
|
208
133
|
const { ui } = this.props;
|
|
209
134
|
const player = ui.getPlayer();
|
|
210
135
|
if (player.live) {
|
|
211
|
-
const { programStart = 0, programEnd = 0 } = player.
|
|
136
|
+
const { programStart = 0, programEnd = 0 } = player.getMetadata();
|
|
212
137
|
const { start, end } = player.seekableRange;
|
|
213
138
|
return getLiveProgressBasedOnCurrentTime(
|
|
214
139
|
programStart,
|
|
@@ -235,34 +160,17 @@ export class Seekbar extends Component<Props> implements IFocusable {
|
|
|
235
160
|
this.seekPoint.current!.style.left = `${percentTime}%`;
|
|
236
161
|
}
|
|
237
162
|
|
|
238
|
-
disableSeeking() {
|
|
239
|
-
this.seekingDisabled = true;
|
|
240
|
-
this.displaySeekPoint.hide();
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
enableSeeking() {
|
|
244
|
-
this.seekingDisabled = false;
|
|
245
|
-
this.displaySeekPoint.show();
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
isSeekingDisabled() {
|
|
249
|
-
return this.seekingDisabled;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
163
|
render() {
|
|
253
|
-
const {
|
|
164
|
+
const { className } = this.props;
|
|
254
165
|
return (
|
|
255
166
|
<div
|
|
256
167
|
className={`seek-bar ${className}`}
|
|
257
168
|
ref={this.wrap}
|
|
258
169
|
tabIndex={0}
|
|
259
170
|
onKeyDown={this.onKeyDown}
|
|
260
|
-
onMouseDown={this.onMouseDown}
|
|
261
|
-
onClick={this.onMouseClick}
|
|
262
171
|
onBlur={this.onBlur}
|
|
263
172
|
>
|
|
264
|
-
|
|
265
|
-
<div className="bar" ref={this.seekBarWrap}>
|
|
173
|
+
<div className="bar">
|
|
266
174
|
<div className="bg" ref={this.seekBar} />
|
|
267
175
|
</div>
|
|
268
176
|
<div className="point" ref={this.seekPoint}>
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import { IEvents, EventMapType, EventsManager } from '@24i/bigscreen-sdk/events-manager';
|
|
2
|
-
import { createInterval
|
|
3
|
-
import { PlayerBase } from '@24i/
|
|
2
|
+
import { createInterval } from '@24i/bigscreen-sdk/utils/timers';
|
|
3
|
+
import { PlayerBase } from '@24i/player-base';
|
|
4
4
|
|
|
5
|
-
const DEFAULT_SEEK_TIME =
|
|
6
|
-
const FAST_SEEK_TIME = 30000;
|
|
5
|
+
const DEFAULT_SEEK_TIME = 20000;
|
|
7
6
|
const AUTOMATIC_SEEK_INTERVAL = 300;
|
|
8
|
-
const FAST_THRESHOLD = 5;
|
|
9
|
-
const CONSECUTIVE_TIMEOUT = 500;
|
|
10
7
|
|
|
11
8
|
interface SeekingEventsMap extends EventMapType {
|
|
12
9
|
'seektimeupdate': (payload: number) => void,
|
|
@@ -26,21 +23,13 @@ export class Seeking implements IEvents<SeekingEventsMap> {
|
|
|
26
23
|
|
|
27
24
|
automaticSeekInterval = createInterval();
|
|
28
25
|
|
|
29
|
-
player: PlayerBase | null;
|
|
26
|
+
player: PlayerBase<any> | null;
|
|
30
27
|
|
|
31
28
|
isAutomaticallySeekingForward = false;
|
|
32
29
|
|
|
33
30
|
isAutomaticallySeekingBackward = false;
|
|
34
31
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
rewConsecutiveness = 0;
|
|
38
|
-
|
|
39
|
-
ffConsecutiveTimeout = createTimeout();
|
|
40
|
-
|
|
41
|
-
rewConsecutiveTimeout = createTimeout();
|
|
42
|
-
|
|
43
|
-
constructor(player: PlayerBase | null = null) {
|
|
32
|
+
constructor(player: PlayerBase<any> | null = null) {
|
|
44
33
|
this.player = player;
|
|
45
34
|
}
|
|
46
35
|
|
|
@@ -52,7 +41,7 @@ export class Seeking implements IEvents<SeekingEventsMap> {
|
|
|
52
41
|
this.player!.removeEventListener('seeked', this.nullSeekTime);
|
|
53
42
|
}
|
|
54
43
|
|
|
55
|
-
setPlayer(player: PlayerBase) {
|
|
44
|
+
setPlayer(player: PlayerBase<any>) {
|
|
56
45
|
this.player = player;
|
|
57
46
|
}
|
|
58
47
|
|
|
@@ -87,53 +76,28 @@ export class Seeking implements IEvents<SeekingEventsMap> {
|
|
|
87
76
|
this.triggerEvent('seektimeupdate', this.seekTime!);
|
|
88
77
|
}
|
|
89
78
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
this.ffConsecutiveTimeout.set(() => {
|
|
93
|
-
this.ffConsecutiveness = 0;
|
|
94
|
-
}, CONSECUTIVE_TIMEOUT);
|
|
95
|
-
this.ffConsecutiveness += 1;
|
|
96
|
-
if (this.ffConsecutiveness === FAST_THRESHOLD) {
|
|
97
|
-
this.automaticSeekInterval.set(
|
|
98
|
-
() => this.seekForward(FAST_SEEK_TIME),
|
|
99
|
-
AUTOMATIC_SEEK_INTERVAL,
|
|
100
|
-
);
|
|
101
|
-
}
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
79
|
+
startAutomaticSeekForward() {
|
|
80
|
+
this.stopAutomaticSeek();
|
|
104
81
|
this.isAutomaticallySeekingForward = true;
|
|
105
|
-
this.ffConsecutiveness += 1;
|
|
106
82
|
this.seekForward();
|
|
107
|
-
this.automaticSeekInterval.set(() =>
|
|
83
|
+
this.automaticSeekInterval.set(() => {
|
|
84
|
+
this.seekForward();
|
|
85
|
+
}, AUTOMATIC_SEEK_INTERVAL);
|
|
108
86
|
}
|
|
109
87
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
this.rewConsecutiveTimeout.set(() => {
|
|
113
|
-
this.rewConsecutiveness = 0;
|
|
114
|
-
}, CONSECUTIVE_TIMEOUT);
|
|
115
|
-
this.rewConsecutiveness += 1;
|
|
116
|
-
if (this.rewConsecutiveness === FAST_THRESHOLD) {
|
|
117
|
-
this.automaticSeekInterval.set(
|
|
118
|
-
() => this.seekBackward(FAST_SEEK_TIME),
|
|
119
|
-
AUTOMATIC_SEEK_INTERVAL,
|
|
120
|
-
);
|
|
121
|
-
}
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
88
|
+
startAutomaticSeekBackward() {
|
|
89
|
+
this.stopAutomaticSeek();
|
|
124
90
|
this.isAutomaticallySeekingBackward = true;
|
|
125
|
-
this.rewConsecutiveness += 1;
|
|
126
91
|
this.seekBackward();
|
|
127
|
-
this.automaticSeekInterval.set(() =>
|
|
92
|
+
this.automaticSeekInterval.set(() => {
|
|
93
|
+
this.seekBackward();
|
|
94
|
+
}, AUTOMATIC_SEEK_INTERVAL);
|
|
128
95
|
}
|
|
129
96
|
|
|
130
97
|
stopAutomaticSeek() {
|
|
131
|
-
if (this.isAutomaticallySeeking()) this.triggerEvent('stopautomaticseek');
|
|
132
98
|
this.automaticSeekInterval.clear();
|
|
133
99
|
this.isAutomaticallySeekingForward = false;
|
|
134
100
|
this.isAutomaticallySeekingBackward = false;
|
|
135
|
-
this.ffConsecutiveness = 0;
|
|
136
|
-
this.rewConsecutiveness = 0;
|
|
137
101
|
}
|
|
138
102
|
|
|
139
103
|
cancelSeek() {
|
|
@@ -146,11 +110,6 @@ export class Seeking implements IEvents<SeekingEventsMap> {
|
|
|
146
110
|
this.triggerEvent('seektimeupdate', this.seekTime!);
|
|
147
111
|
};
|
|
148
112
|
|
|
149
|
-
setSeekTime = (seekTime: number) => {
|
|
150
|
-
this.seekTime = seekTime;
|
|
151
|
-
this.triggerEvent('seektimeupdate', this.seekTime!);
|
|
152
|
-
};
|
|
153
|
-
|
|
154
113
|
confirmSeek() {
|
|
155
114
|
if (!this.player) return false;
|
|
156
115
|
this.stopAutomaticSeek();
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { PlayerBase, ITimeUpdateEvent } from '@24i/
|
|
1
|
+
import { PlayerBase, ITimeUpdateEvent } from '@24i/player-base';
|
|
2
2
|
import { Component, createRef, DeclareProps, setText } from '@24i/bigscreen-sdk/jsx';
|
|
3
3
|
import { getDisplayToggler } from '@24i/bigscreen-sdk/utils';
|
|
4
4
|
import { SubtitlesType } from '@24i/smartapps-datalayer/src/models';
|
|
5
5
|
import { timeToMs } from './timeUtils';
|
|
6
6
|
|
|
7
7
|
type Props = {
|
|
8
|
-
player: PlayerBase
|
|
8
|
+
player: PlayerBase<any>,
|
|
9
9
|
className?: string,
|
|
10
10
|
};
|
|
11
11
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export { PlayerUI } from './PlayerUI';
|
|
2
2
|
export type { PlayerUIState } from './PlayerUI';
|
|
3
|
-
export type { IPlayerUIWithSeeking } from './types';
|
|
4
3
|
export { BackwardButton } from './BackwardButton';
|
|
5
4
|
export { CurrentTime } from './CurrentTime';
|
|
6
5
|
export { Duration } from './Duration';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PlayerBase, PlayerBaseMock } from '@24i/player-base';
|
|
2
2
|
import { EventsManager } from '@24i/bigscreen-sdk/events-manager';
|
|
3
|
-
import {
|
|
3
|
+
import { IPlayerUI } from './types';
|
|
4
4
|
|
|
5
|
-
const getSeekingMock = (): jest.Mocked<
|
|
5
|
+
const getSeekingMock = (): jest.Mocked<IPlayerUI['seeking']> => ({
|
|
6
6
|
events: {} as EventsManager<{}>,
|
|
7
7
|
addEventListener: jest.fn(),
|
|
8
8
|
removeEventListener: jest.fn(),
|
|
@@ -13,16 +13,12 @@ const getSeekingMock = (): jest.Mocked<IPlayerUIWithSeeking['seeking']> => ({
|
|
|
13
13
|
isAutomaticallySeeking: jest.fn(),
|
|
14
14
|
isAutomaticallySeekingForward: false,
|
|
15
15
|
isAutomaticallySeekingBackward: false,
|
|
16
|
-
ffConsecutiveness: 0,
|
|
17
|
-
rewConsecutiveness: 0,
|
|
18
|
-
ffConsecutiveTimeout: null!,
|
|
19
|
-
rewConsecutiveTimeout: null!,
|
|
20
16
|
isSeeking: jest.fn(),
|
|
21
17
|
startSeeking: jest.fn(),
|
|
22
18
|
seekForward: jest.fn(),
|
|
23
19
|
seekBackward: jest.fn(),
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
startAutomaticSeekForward: jest.fn(),
|
|
21
|
+
startAutomaticSeekBackward: jest.fn(),
|
|
26
22
|
stopAutomaticSeek: jest.fn(),
|
|
27
23
|
cancelSeek: jest.fn(),
|
|
28
24
|
confirmSeek: jest.fn(),
|
|
@@ -30,36 +26,16 @@ const getSeekingMock = (): jest.Mocked<IPlayerUIWithSeeking['seeking']> => ({
|
|
|
30
26
|
unsubscribeEvents: jest.fn(),
|
|
31
27
|
setPlayer: jest.fn(),
|
|
32
28
|
nullSeekTime: jest.fn(),
|
|
33
|
-
setSeekTime: jest.fn(),
|
|
34
29
|
});
|
|
35
30
|
|
|
36
|
-
const
|
|
31
|
+
export const getPlayerMock = (): PlayerBase<any> => new PlayerBaseMock();
|
|
37
32
|
|
|
38
|
-
export const
|
|
39
|
-
const initialConfig: IPlayerProperties = {
|
|
40
|
-
source: {
|
|
41
|
-
url: '',
|
|
42
|
-
},
|
|
43
|
-
};
|
|
44
|
-
const parentElement = document.createElement('div');
|
|
45
|
-
|
|
46
|
-
const playerMock = new PlayerBaseMock(initialConfig, parentElement);
|
|
47
|
-
playerMock.source = initialConfig.source;
|
|
48
|
-
jest.spyOn(playerMock, 'duration', 'get').mockReturnValue(PLAYER_MOCK_DURATION);
|
|
49
|
-
|
|
50
|
-
return playerMock;
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
export const getUiMock = (): { ui: jest.Mocked<IPlayerUIWithSeeking> } => ({
|
|
33
|
+
export const getUiMock = (): { ui: jest.Mocked<IPlayerUI> } => ({
|
|
54
34
|
ui: {
|
|
55
|
-
getPlayer: jest.fn((): PlayerBase => getPlayerMock()),
|
|
35
|
+
getPlayer: jest.fn((): PlayerBase<any> => getPlayerMock()),
|
|
56
36
|
heartbeat: jest.fn(),
|
|
57
37
|
trigger: jest.fn(),
|
|
58
38
|
isPlaying: jest.fn(),
|
|
59
|
-
enableHiding: jest.fn(),
|
|
60
|
-
disableHiding: jest.fn(),
|
|
61
|
-
enableSeeking: jest.fn(),
|
|
62
|
-
disableSeeking: jest.fn(),
|
|
63
39
|
seeking: getSeekingMock(),
|
|
64
40
|
},
|
|
65
41
|
});
|
|
@@ -63,9 +63,9 @@ export const formatTime = (duration: number, pattern: string) => {
|
|
|
63
63
|
const unitValues = calculateUnitValues(duration, units);
|
|
64
64
|
let result: string = pattern;
|
|
65
65
|
forEach(matches, (match) => {
|
|
66
|
-
const formatedValue = Number.isNaN(unitValues[match.unit])
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
const formatedValue = Number.isNaN(unitValues[match.unit]) ?
|
|
67
|
+
'--' :
|
|
68
|
+
unitValues[match.unit]!.toString().padStart(match.count, '0');
|
|
69
69
|
result = result.replace(
|
|
70
70
|
match.completeMatch,
|
|
71
71
|
formatedValue,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PlayerBase } from '@24i/
|
|
1
|
+
import { PlayerBase } from '@24i/player-base';
|
|
2
2
|
import { Seeking } from './Seeking';
|
|
3
3
|
|
|
4
4
|
export enum PlayerAction {
|
|
@@ -20,12 +20,8 @@ export interface ActionsWithPayloadMap {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
export interface IPlayerUI {
|
|
23
|
-
seeking
|
|
24
|
-
getPlayer: () => PlayerBase
|
|
25
|
-
disableHiding: () => void,
|
|
26
|
-
enableHiding: () => void,
|
|
27
|
-
disableSeeking: () => void,
|
|
28
|
-
enableSeeking: () => void,
|
|
23
|
+
seeking: Seeking;
|
|
24
|
+
getPlayer: () => PlayerBase<any>,
|
|
29
25
|
heartbeat: () => void,
|
|
30
26
|
trigger<K extends keyof ActionsWithoutPayloadMap>(action: K): void,
|
|
31
27
|
trigger<K extends keyof ActionsWithPayloadMap>(
|
|
@@ -34,8 +30,6 @@ export interface IPlayerUI {
|
|
|
34
30
|
isPlaying: () => boolean,
|
|
35
31
|
}
|
|
36
32
|
|
|
37
|
-
export type IPlayerUIWithSeeking = Required<IPlayerUI>;
|
|
38
|
-
|
|
39
33
|
export type PlayerUICommonProps = {
|
|
40
34
|
ui: IPlayerUI,
|
|
41
35
|
className?: string,
|
|
@@ -3,38 +3,36 @@ import {
|
|
|
3
3
|
Component,
|
|
4
4
|
createRef,
|
|
5
5
|
detachNode,
|
|
6
|
-
Reference,
|
|
7
6
|
replaceNode,
|
|
8
7
|
} from '@24i/bigscreen-sdk/jsx';
|
|
9
8
|
import { filter, forEach } from '@24i/bigscreen-sdk/perf-utils/array';
|
|
10
|
-
import { addClass, removeClass } from '@24i/bigscreen-sdk/utils';
|
|
11
|
-
import { ModalService } from '@24i/bigscreen-sdk/modal-service';
|
|
12
|
-
import { menuService } from '@24i/bigscreen-sdk/menu';
|
|
13
9
|
import { getCurrentHash } from './utils';
|
|
14
10
|
import { IRoute, RouteParams } from './types';
|
|
15
11
|
|
|
16
12
|
type Props = {
|
|
17
13
|
path: string,
|
|
18
|
-
domParent?: Reference<HTMLElement>;
|
|
19
14
|
regexpPath?: RegExp,
|
|
20
15
|
paramNames?: string[],
|
|
16
|
+
isDetachable?: boolean;
|
|
21
17
|
Component: Function,
|
|
22
18
|
};
|
|
23
19
|
|
|
24
|
-
const MRCU_DISABLED = 'mrcu-disabled';
|
|
25
|
-
|
|
26
20
|
export class Route extends Component<Props> {
|
|
27
21
|
wasCreated = false;
|
|
28
22
|
|
|
29
23
|
isDetached = false;
|
|
30
24
|
|
|
25
|
+
domParent: HTMLElement | null = null;
|
|
26
|
+
|
|
31
27
|
domRef = createRef<HTMLDivElement>();
|
|
32
28
|
|
|
33
29
|
component = createRef<IRoute | null>();
|
|
34
30
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
31
|
+
componentDidMount() {
|
|
32
|
+
const { isDetachable } = this.props;
|
|
33
|
+
this.domParent = this.domRef.current?.parentElement!;
|
|
34
|
+
if (isDetachable) this.detach();
|
|
35
|
+
}
|
|
38
36
|
|
|
39
37
|
getParams(): RouteParams {
|
|
40
38
|
const { regexpPath, paramNames } = this.props;
|
|
@@ -51,50 +49,21 @@ export class Route extends Component<Props> {
|
|
|
51
49
|
return {};
|
|
52
50
|
}
|
|
53
51
|
|
|
54
|
-
onMenuVisibilityChange = (isVisible: boolean) => {
|
|
55
|
-
if (isVisible) {
|
|
56
|
-
addClass(this.domRef, MRCU_DISABLED);
|
|
57
|
-
} else {
|
|
58
|
-
removeClass(this.domRef, MRCU_DISABLED);
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
onCloseModalService = () => {
|
|
63
|
-
if (this.shouldCallReactivateOnCloseModal) {
|
|
64
|
-
this.component.current?.reactivate(this.getParams());
|
|
65
|
-
}
|
|
66
|
-
this.shouldCallReactivateOnCloseModal = false;
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
getModalService() {
|
|
70
|
-
if (!this.modalService.current) {
|
|
71
|
-
this.appendMount(
|
|
72
|
-
<ModalService
|
|
73
|
-
ref={this.modalService}
|
|
74
|
-
onCloseLastModal={this.onCloseModalService}
|
|
75
|
-
/>,
|
|
76
|
-
this.domRef,
|
|
77
|
-
);
|
|
78
|
-
}
|
|
79
|
-
return this.modalService;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
52
|
show() {
|
|
83
|
-
|
|
53
|
+
this.showRoute();
|
|
84
54
|
if (!this.wasCreated) {
|
|
85
55
|
this.mountRoute();
|
|
86
56
|
this.component.current?.activate(this.getParams());
|
|
87
|
-
} else if (this.modalService.current?.isOpen()) {
|
|
88
|
-
this.focusModal();
|
|
89
|
-
this.shouldCallReactivateOnCloseModal = true;
|
|
90
57
|
} else {
|
|
91
58
|
this.component.current?.reactivate(this.getParams());
|
|
92
59
|
}
|
|
93
60
|
}
|
|
94
61
|
|
|
95
62
|
hide() {
|
|
96
|
-
|
|
97
|
-
|
|
63
|
+
if (this.wasCreated) {
|
|
64
|
+
this.component.current?.deactivate();
|
|
65
|
+
this.hideRoute();
|
|
66
|
+
}
|
|
98
67
|
}
|
|
99
68
|
|
|
100
69
|
replace(newRoute: Route) {
|
|
@@ -106,9 +75,8 @@ export class Route extends Component<Props> {
|
|
|
106
75
|
}
|
|
107
76
|
|
|
108
77
|
attach() {
|
|
109
|
-
const { domParent } = this.props;
|
|
110
78
|
if (this.isDetached) {
|
|
111
|
-
attachNode(this.domRef, domParent!);
|
|
79
|
+
attachNode(this.domRef, this.domParent!);
|
|
112
80
|
this.isDetached = false;
|
|
113
81
|
}
|
|
114
82
|
}
|
|
@@ -126,27 +94,20 @@ export class Route extends Component<Props> {
|
|
|
126
94
|
}
|
|
127
95
|
}
|
|
128
96
|
|
|
129
|
-
private focusModal() {
|
|
130
|
-
const mountedComponent = this.modalService.current!.getMountedComponent();
|
|
131
|
-
mountedComponent.current?.focus();
|
|
132
|
-
}
|
|
133
|
-
|
|
134
97
|
focus() {
|
|
135
98
|
if (this.wasCreated) {
|
|
136
|
-
|
|
137
|
-
this.focusModal();
|
|
138
|
-
} else {
|
|
139
|
-
this.component.current?.focus();
|
|
140
|
-
}
|
|
99
|
+
this.component.current?.focus();
|
|
141
100
|
}
|
|
142
101
|
}
|
|
143
102
|
|
|
144
|
-
showRoute() {
|
|
145
|
-
|
|
103
|
+
private showRoute() {
|
|
104
|
+
const { isDetachable } = this.props;
|
|
105
|
+
if (!isDetachable) this.domRef.current!.style.display = 'block';
|
|
146
106
|
}
|
|
147
107
|
|
|
148
|
-
hideRoute() {
|
|
149
|
-
|
|
108
|
+
private hideRoute() {
|
|
109
|
+
const { isDetachable } = this.props;
|
|
110
|
+
if (!isDetachable) this.domRef.current!.style.display = 'none';
|
|
150
111
|
}
|
|
151
112
|
|
|
152
113
|
private mountRoute() {
|
|
@@ -159,8 +120,13 @@ export class Route extends Component<Props> {
|
|
|
159
120
|
}
|
|
160
121
|
|
|
161
122
|
render() {
|
|
123
|
+
const { isDetachable } = this.props;
|
|
162
124
|
return (
|
|
163
|
-
<div
|
|
125
|
+
<div
|
|
126
|
+
className="route"
|
|
127
|
+
style={!isDetachable ? { display: 'none' } : {}}
|
|
128
|
+
ref={this.domRef}
|
|
129
|
+
/>
|
|
164
130
|
);
|
|
165
131
|
}
|
|
166
132
|
}
|