@24i/bigscreen-sdk 0.9.9-alpha.2154 → 1.0.0-alpha.2054

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.
Files changed (142) hide show
  1. package/package.json +3 -1
  2. package/packages/create-package/dist/createPackage.js +66 -0
  3. package/packages/create-package/dist/createPackage.js.map +1 -0
  4. package/packages/create-package/dist/index.js +5 -0
  5. package/packages/create-package/dist/index.js.map +1 -0
  6. package/packages/create-package/dist/questionnaire/questions.js +35 -0
  7. package/packages/create-package/dist/questionnaire/questions.js.map +1 -0
  8. package/packages/create-package/dist/settings/Settings.js +10 -0
  9. package/packages/create-package/dist/settings/Settings.js.map +1 -0
  10. package/packages/create-package/dist/types.js +3 -0
  11. package/packages/create-package/dist/types.js.map +1 -0
  12. package/packages/developer-tools/src/EnvironmentSelection/EnvironmentList.tsx +3 -1
  13. package/packages/developer-tools/src/EnvironmentSelection/EnvironmentListItem.tsx +23 -3
  14. package/packages/developer-tools/src/EnvironmentSelection/EnvironmentSelection.tsx +2 -0
  15. package/packages/developer-tools/src/EnvironmentSelection/styles/EnvironmentSelection.scss +10 -0
  16. package/packages/device/src/driver/index.vidaa.tv.ts +1 -0
  17. package/packages/device/src/resolver/resolver.ts +5 -0
  18. package/packages/driver-vidaa/src/DeviceVidaa.ts +134 -0
  19. package/packages/driver-vidaa/src/__mocks__/vidaa.ts +20 -0
  20. package/packages/driver-vidaa/src/formatUserAgent.ts +16 -0
  21. package/packages/driver-vidaa/src/index.ts +1 -0
  22. package/packages/driver-vidaa/src/keymap.ts +54 -0
  23. package/packages/driver-vidaa/src/types.ts +82 -0
  24. package/packages/input/src/Input.tsx +2 -2
  25. package/packages/list/src/BasicList/BasicList.tsx +4 -1
  26. package/packages/list/src/EdgeOffsetList/EdgeOffsetList.tsx +4 -3
  27. package/packages/list/src/FirstOnlyList/FirstOnlyList.tsx +2 -2
  28. package/packages/list/src/FirstOnlyVariedList/FirstOnlyVariedList.tsx +2 -2
  29. package/packages/list/src/FixedToEndList/FixedToEndList.tsx +2 -2
  30. package/packages/logger/README.md +1 -1
  31. package/packages/rnv-build-engine/dist/src/constants/buildSchemes.js +14 -0
  32. package/packages/rnv-build-engine/dist/src/constants/index.js +7 -0
  33. package/packages/rnv-build-engine/dist/src/constants/platforms.js +14 -0
  34. package/packages/rnv-build-engine/dist/src/engine.js +94 -0
  35. package/packages/rnv-build-engine/dist/src/index.js +26 -0
  36. package/packages/rnv-build-engine/dist/src/resolvers/index.js +29 -0
  37. package/packages/rnv-build-engine/dist/src/resolvers/resolveBaseUrl.js +31 -0
  38. package/packages/rnv-build-engine/dist/src/resolvers/resolveBuildFileExtension.js +12 -0
  39. package/packages/rnv-build-engine/dist/src/resolvers/resolveBuildFileName.js +36 -0
  40. package/packages/rnv-build-engine/dist/src/resolvers/resolveBuildVersion.js +42 -0
  41. package/packages/rnv-build-engine/dist/src/resolvers/resolveBuildVersionOffset.js +34 -0
  42. package/packages/rnv-build-engine/dist/src/resolvers/resolveDeployLocations.js +79 -0
  43. package/packages/rnv-build-engine/dist/src/resolvers/resolveGenericRnvConfig.js +47 -0
  44. package/packages/rnv-build-engine/dist/src/resolvers/resolveHbbtvDeployConfig.js +13 -0
  45. package/packages/rnv-build-engine/dist/src/resolvers/resolveHbbtvDeployUrl.js +11 -0
  46. package/packages/rnv-build-engine/dist/src/resolvers/resolveHbbtvRemoteBuildDirRelativePath.js +24 -0
  47. package/packages/rnv-build-engine/dist/src/resolvers/resolveSupportedPlatforms.js +5 -0
  48. package/packages/rnv-build-engine/dist/src/resolvers/resolveUsedFlavours.js +23 -0
  49. package/packages/rnv-build-engine/dist/src/resolvers/resolveZippedPlatformBuildsRelativeFilePath.js +14 -0
  50. package/packages/rnv-build-engine/dist/src/scripts/buildAllWithScheme.js +25 -0
  51. package/packages/rnv-build-engine/dist/src/scripts/generateDeployUrls/formatTableDataSpaces.js +30 -0
  52. package/packages/rnv-build-engine/dist/src/scripts/generateDeployUrls/generateDeployUrls.js +90 -0
  53. package/packages/rnv-build-engine/dist/src/scripts/generateDeployUrls/index.js +4 -0
  54. package/packages/rnv-build-engine/dist/src/scripts/generateDeployUrls/makeTableDataByScheme.js +63 -0
  55. package/packages/rnv-build-engine/dist/src/scripts/gitReleaser/afterVersionBump.js +18 -0
  56. package/packages/rnv-build-engine/dist/src/scripts/gitReleaser/beforeVersionBump.js +12 -0
  57. package/packages/rnv-build-engine/dist/src/scripts/gitReleaser/checkReleaseNotes.js +16 -0
  58. package/packages/rnv-build-engine/dist/src/scripts/gitReleaser/pushRelease.js +31 -0
  59. package/packages/rnv-build-engine/dist/src/scripts/gitReleaser/pushReleaseCandidate.js +6 -0
  60. package/packages/rnv-build-engine/dist/src/scripts/gitReleaser/pushReleaseNotes.js +37 -0
  61. package/packages/rnv-build-engine/dist/src/scripts/release/deleteSourceMaps.js +11 -0
  62. package/packages/rnv-build-engine/dist/src/scripts/release/deployToAppCenter.js +83 -0
  63. package/packages/rnv-build-engine/dist/src/scripts/release/githubRelease.js +128 -0
  64. package/packages/rnv-build-engine/dist/src/scripts/release/notifySlack/generateWebhoook.js +65 -0
  65. package/packages/rnv-build-engine/dist/src/scripts/release/notifySlack/makePayload.js +85 -0
  66. package/packages/rnv-build-engine/dist/src/scripts/release/notifySlack/notifySlack.js +44 -0
  67. package/packages/rnv-build-engine/dist/src/scripts/release/notifySlack/slackBlockKitBuilder.js +39 -0
  68. package/packages/rnv-build-engine/dist/src/scripts/release/sentryRelease.js +85 -0
  69. package/packages/rnv-build-engine/dist/src/scripts/release/urlsMarkdown.js +62 -0
  70. package/packages/rnv-build-engine/dist/src/scripts/releaseAllWithScheme.js +79 -0
  71. package/packages/rnv-build-engine/dist/src/scripts/utils/cmdUtils.js +12 -0
  72. package/packages/rnv-build-engine/dist/src/scripts/utils/fsUtils.js +33 -0
  73. package/packages/rnv-build-engine/dist/src/scripts/utils/generateIcons.js +29 -0
  74. package/packages/rnv-build-engine/dist/src/scripts/utils/gitUtils.js +78 -0
  75. package/packages/rnv-build-engine/dist/src/scripts/utils/index.js +27 -0
  76. package/packages/rnv-build-engine/dist/src/scripts/utils/stringUtils.js +5 -0
  77. package/packages/rnv-build-engine/dist/src/sdks/index.js +42 -0
  78. package/packages/rnv-build-engine/dist/src/sdks/sdk-tizen/index.js +13 -0
  79. package/packages/rnv-build-engine/dist/src/sdks/sdk-tizen/sdkTizen.js +168 -0
  80. package/packages/rnv-build-engine/dist/src/sdks/sdk-utils/index.js +14 -0
  81. package/packages/rnv-build-engine/dist/src/sdks/sdk-utils/registerSdkPath.js +14 -0
  82. package/packages/rnv-build-engine/dist/src/sdks/sdk-utils/sdk-installer/index.js +5 -0
  83. package/packages/rnv-build-engine/dist/src/sdks/sdk-utils/sdk-installer/sdkInstaller.js +37 -0
  84. package/packages/rnv-build-engine/dist/src/sdks/sdk-utils/sdk-installer/services/clean.js +11 -0
  85. package/packages/rnv-build-engine/dist/src/sdks/sdk-utils/sdk-installer/services/download.js +76 -0
  86. package/packages/rnv-build-engine/dist/src/sdks/sdk-utils/sdk-installer/services/index.js +11 -0
  87. package/packages/rnv-build-engine/dist/src/sdks/sdk-utils/sdk-installer/services/install.js +23 -0
  88. package/packages/rnv-build-engine/dist/src/sdks/sdk-utils/sdk-installer/services/unzip.js +12 -0
  89. package/packages/rnv-build-engine/dist/src/sdks/sdk-webos/index.js +13 -0
  90. package/packages/rnv-build-engine/dist/src/sdks/sdk-webos/sdkWebos.js +80 -0
  91. package/packages/rnv-build-engine/dist/src/sdks/sdk-webpack/index.js +13 -0
  92. package/packages/rnv-build-engine/dist/src/sdks/sdk-webpack/sdkWebpack.js +6 -0
  93. package/packages/rnv-build-engine/dist/src/sdks/sdk-xbox/index.js +13 -0
  94. package/packages/rnv-build-engine/dist/src/sdks/sdk-xbox/sdkXbox.js +221 -0
  95. package/packages/rnv-build-engine/dist/src/tasks/deploy/aswS3/aws.js +22 -0
  96. package/packages/rnv-build-engine/dist/src/tasks/deploy/aswS3/deployS3.js +71 -0
  97. package/packages/rnv-build-engine/dist/src/tasks/deploy/hbbtv/deployHbbtv.js +94 -0
  98. package/packages/rnv-build-engine/dist/src/tasks/engineTasks.js +24 -0
  99. package/packages/rnv-build-engine/dist/src/tasks/task.rnv.build.js +91 -0
  100. package/packages/rnv-build-engine/dist/src/tasks/task.rnv.configure.js +42 -0
  101. package/packages/rnv-build-engine/dist/src/tasks/task.rnv.configureSoft.js +30 -0
  102. package/packages/rnv-build-engine/dist/src/tasks/task.rnv.deploy.js +40 -0
  103. package/packages/rnv-build-engine/dist/src/tasks/task.rnv.hooks.run.js +70 -0
  104. package/packages/rnv-build-engine/dist/src/tasks/task.rnv.package.js +18 -0
  105. package/packages/rnv-build-engine/dist/src/tasks/task.rnv.platform.configure.js +37 -0
  106. package/packages/rnv-build-engine/dist/src/tasks/task.rnv.project.configure.js +116 -0
  107. package/packages/rnv-build-engine/dist/src/tasks/task.rnv.start.js +73 -0
  108. package/packages/rnv-build-engine/dist/src/types/c.js +2 -0
  109. package/packages/rnv-build-engine/dist/src/types/constants.js +2 -0
  110. package/packages/rnv-build-engine/dist/src/types/index.js +2 -0
  111. package/packages/rnv-build-engine/dist/src/utils/forEachSupportedPlatformFlavour.js +24 -0
  112. package/packages/rnv-build-engine/dist/src/utils/generatePngSpriteMap.js +78 -0
  113. package/packages/rnv-build-engine/dist/src/utils/generateSvgSpriteMap.js +113 -0
  114. package/packages/rnv-build-engine/dist/src/utils/mergeSvgAndPngIcons.js +65 -0
  115. package/packages/rnv-build-engine/dist/src/utils/replaceRelevantStringsInConfig/index.js +5 -0
  116. package/packages/rnv-build-engine/dist/src/utils/replaceRelevantStringsInConfig/replaceRelevantStringsInConfig.js +31 -0
  117. package/packages/rnv-build-engine/dist/src/utils/replaceRelevantStringsInConfig/replaceTemplateString.js +40 -0
  118. package/packages/rnv-build-engine/dist/src/utils/zipBuildsByPlatforms.js +61 -0
  119. package/packages/rnv-build-engine/dist/templates/platforms/_shared/template.js +87 -0
  120. package/packages/rnv-build-engine/dist/templates/platforms/_shared/utils/extendSass.js +29 -0
  121. package/packages/rnv-build-engine/dist/templates/platforms/_shared/utils/joinStrings.js +5 -0
  122. package/packages/rnv-build-engine/dist/templates/platforms/_shared/webpack.base.js +234 -0
  123. package/packages/rnv-build-engine/dist/templates/platforms/_shared/webpack.config.dev.js +6 -0
  124. package/packages/rnv-build-engine/dist/templates/platforms/_shared/webpack.config.prod.js +6 -0
  125. package/packages/rnv-build-engine/dist/templates/platforms/_shared/webpack.extend.js +8 -0
  126. package/packages/rnv-build-engine/dist/templates/platforms/_shared/webpackConfigAdapter.js +100 -0
  127. package/packages/rnv-build-engine/dist/templates/platforms/_shared/webpackPlatformProps.js +8 -0
  128. package/packages/rnv-build-engine/dist/templates/platforms/hbbtv/webpackPlatformProps.js +24 -0
  129. package/packages/rnv-build-engine/dist/templates/platforms/tizen/project/.project +24 -0
  130. package/packages/rnv-build-engine/dist/templates/platforms/tizen/project/.tproject +12 -0
  131. package/packages/rnv-build-engine/dist/templates/platforms/tizen/project/config.xml +17 -0
  132. package/packages/rnv-build-engine/dist/templates/platforms/webos/project/.project +35 -0
  133. package/packages/rnv-build-engine/dist/templates/platforms/webos/project/appinfo.json +19 -0
  134. package/packages/rnv-build-engine/dist/templates/platforms/webos/webpackPlatformProps.js +8 -0
  135. package/packages/scroll-text/src/Base.tsx +5 -0
  136. package/packages/utils/src/textUtils.ts +25 -0
  137. package/packages/focus/src/__test__/candidate.spec.tsx +0 -245
  138. package/packages/focus/src/__test__/focusFirstExisting.spec.tsx +0 -21
  139. package/packages/focus/src/__test__/refocusAfterHashChange.spec.tsx +0 -41
  140. package/packages/focus/src/__test__/safeFocus.spec.tsx +0 -41
  141. package/packages/mouse-navigation/src/__test__/MouseElementWrapper.spec.tsx +0 -61
  142. package/packages/mouse-navigation/src/__test__/MouseNavigation.spec.tsx +0 -107
@@ -0,0 +1,17 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <widget xmlns="http://www.w3.org/ns/widgets" xmlns:tizen="http://tizen.org/ns/widgets" id="https://24i.com/apps/smartapps/bigscreen/{{configProps.id}}" version="{{APP_VERSION}}" viewmodes="maximized">
3
+ <tizen:application id="{{configProps.id}}" package="{{configProps.package}}" required_version="2.3"/>
4
+ <name>{{configProps.appName}}</name>
5
+ <content src="public/index.html"/>
6
+ <icon src="app_icon_512x512.png"/>
7
+ <access origin="*" subdomains="true"></access>
8
+ <feature name="http://tizen.org/feature/screen.size.normal.{{configProps.webpackConfig.resolution.width}}.{{configProps.webpackConfig.resolution.height}}"/>
9
+ <feature name="http://tizen.org/feature/network.internet"/>
10
+ <feature name="http://tizen.org/api/tizen" required="true"/>
11
+ <tizen:profile name="tv-samsung"/>
12
+ <tizen:privilege name="http://developer.samsung.com/privilege/network.public"/>
13
+ <tizen:privilege name="http://developer.samsung.com/privilege/productinfo"/>
14
+ <tizen:privilege name="http://tizen.org/privilege/internet"/>
15
+ <tizen:privilege name="http://tizen.org/privilege/tv.inputdevice"/>
16
+ <tizen:setting screen-orientation="landscape" context-menu="enable" background-support="disable" encryption="disable" install-location="auto" hwkey-event="enable"/>
17
+ </widget>
@@ -0,0 +1,35 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <projectDescription>
3
+ <name>{{configProps.title}}</name>
4
+ <comment></comment>
5
+ <projects>
6
+ </projects>
7
+ <buildSpec>
8
+ <buildCommand>
9
+ <name>org.eclipse.wst.common.project.facet.core.builder</name>
10
+ <arguments>
11
+ </arguments>
12
+ </buildCommand>
13
+ <buildCommand>
14
+ <name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
15
+ <arguments>
16
+ </arguments>
17
+ </buildCommand>
18
+ <buildCommand>
19
+ <name>com.webos.ide.nature.WebOSBuilder</name>
20
+ <arguments>
21
+ </arguments>
22
+ </buildCommand>
23
+ <buildCommand>
24
+ <name>org.eclipse.wst.validation.validationbuilder</name>
25
+ <arguments>
26
+ </arguments>
27
+ </buildCommand>
28
+ </buildSpec>
29
+ <natures>
30
+ <nature>com.webos.ide.project.nature</nature>
31
+ <nature>org.eclipse.wst.jsdt.core.jsNature</nature>
32
+ <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
33
+ <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
34
+ </natures>
35
+ </projectDescription>
@@ -0,0 +1,19 @@
1
+ {
2
+ "icon": "app_icon_80x80.png",
3
+ "id": "{{configProps.id}}",
4
+ "largeIcon": "app_icon_130x130.png",
5
+ "main": "public/index.html",
6
+ "splashBackground": "splash_background_1920x1080.png",
7
+ "title": "{{configProps.title}}",
8
+ "type": "web",
9
+ "vendor": "{{configProps.author.name}}",
10
+ "version": "{{configProps.packageVersion}}",
11
+ "appDescription": "{{configProps.description}}",
12
+ "bgColor": "{{configProps.backgroundColor}}",
13
+ "bgImage": "{{configProps.appinfo.bgImage}}",
14
+ "disableBackHistoryAPI": true,
15
+ "handlesRelaunch": "{{configProps.appinfo.handlesRelaunch}}",
16
+ "iconColor": "{{configProps.appinfo.iconColor}}",
17
+ "resolution": "{{configProps.webpackConfig.resolution.width}}x{{configProps.webpackConfig.resolution.height}}",
18
+ "transparent": "{{configProps.appinfo.transparent}}"
19
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.webpackPlatformProps = void 0;
4
+ exports.webpackPlatformProps = {
5
+ metaTags: `
6
+ <meta name="viewport" content="width={{APP_WIDTH}}, initial-scale=1, shrink-to-fit=no" />
7
+ `,
8
+ };
@@ -78,6 +78,10 @@ export class ScrollTextBase extends Component<Props> implements IFocusable {
78
78
  if (processed) stopEvent(event);
79
79
  };
80
80
 
81
+ onMouseEnter = () => {
82
+ this.focus({ preventScroll: true });
83
+ };
84
+
81
85
  updateArrowNavigation(enable: boolean) {
82
86
  if (enable) {
83
87
  removeClass(this.arrowNavRef.current!.domRef, DISABLED_CLASS);
@@ -118,6 +122,7 @@ export class ScrollTextBase extends Component<Props> implements IFocusable {
118
122
  className={className}
119
123
  ref={this.domRef}
120
124
  onKeyDown={this.onKeyDown}
125
+ onMouseEnter={this.onMouseEnter}
121
126
  tabIndex={0}
122
127
  >
123
128
  <Scroller
@@ -0,0 +1,25 @@
1
+ const ELLIPSIS = '...';
2
+
3
+ export const trimWithLeadingEllipsis = (row: HTMLSpanElement) => {
4
+ if (row && row.textContent != null) {
5
+ row.style.visibility = 'hidden';
6
+ const lineHeightString = window.getComputedStyle(row, null).getPropertyValue('line-height');
7
+ const lineHeight = parseInt(lineHeightString, 10);
8
+ let numberOfLines = row.offsetHeight / lineHeight;
9
+ if (numberOfLines > 2) {
10
+ const originalTextContent = row.textContent;
11
+ row.textContent = ELLIPSIS;
12
+ let stringBuffer = '';
13
+ let currentPosition = originalTextContent.length - 1;
14
+ do {
15
+ const charToAdd = originalTextContent.at(currentPosition);
16
+ stringBuffer = `${charToAdd}${stringBuffer}`;
17
+ row.textContent = `${ELLIPSIS}${stringBuffer}`;
18
+ currentPosition -= 1;
19
+ numberOfLines = Math.floor(row.offsetHeight / lineHeight);
20
+ } while (numberOfLines <= 2 && currentPosition >= 0);
21
+ row.textContent = `${ELLIPSIS}${stringBuffer.substring(1)}`;
22
+ }
23
+ row.style.visibility = 'visible';
24
+ }
25
+ };
@@ -1,245 +0,0 @@
1
- import { Component, createRef, removeNode } from '@24i/bigscreen-sdk/jsx';
2
- import { shallow, MountedComponent } from '@24i/bigscreen-sdk/jsx/test-utils';
3
- import {
4
- focusCandidate,
5
- setFocusCandidate,
6
- setActiveElementAsFocusCandidate,
7
- setNextFocusCandidate,
8
- setCandidateFallback,
9
- getLastCandidate,
10
- getCandidateStack,
11
- clearCandidateStack,
12
- } from '../candidate';
13
-
14
- class MockComponent extends Component<{}> {
15
- wrapperRef = createRef<HTMLDivElement>();
16
-
17
- focus(options?: FocusOptions) {
18
- this.wrapperRef.current!.focus(options);
19
- }
20
-
21
- render() {
22
- return <div tabIndex={0} ref={this.wrapperRef} />;
23
- }
24
- }
25
-
26
- describe('Focus candidate', () => {
27
- let elementStructure: MountedComponent<HTMLDivElement>;
28
- const refs = {
29
- testElement: createRef<HTMLDivElement>(),
30
- testComponent1: createRef<MockComponent>(),
31
- testComponent2: createRef<MockComponent>(),
32
- };
33
-
34
- beforeEach(() => {
35
- elementStructure = shallow<HTMLDivElement>(
36
- <div tabIndex={0}>
37
- <div
38
- ref={refs.testElement}
39
- tabIndex={0}
40
- className="test-element"
41
- />
42
- <MockComponent ref={refs.testComponent1} />
43
- <MockComponent ref={refs.testComponent2} />
44
- </div>,
45
- );
46
- });
47
-
48
- afterEach(() => {
49
- jest.clearAllMocks();
50
- clearCandidateStack();
51
- elementStructure.unmount();
52
- });
53
-
54
- it('should register a candidate', () => {
55
- refs.testElement.current!.focus();
56
- setActiveElementAsFocusCandidate();
57
- expect(getLastCandidate()).toBe(refs.testElement.current!);
58
- });
59
-
60
- it('should register a manual candidate', () => {
61
- setFocusCandidate(refs.testComponent1.current!);
62
- expect(getLastCandidate()).toBe(refs.testComponent1.current!);
63
- });
64
-
65
- it('should register the next candidate', () => {
66
- setNextFocusCandidate(refs.testComponent1.current!);
67
- expect(getLastCandidate()).toBe(refs.testComponent1.current!);
68
- });
69
-
70
- it('should not register the same candidates twice', () => {
71
- refs.testElement.current!.focus();
72
- setActiveElementAsFocusCandidate();
73
- setActiveElementAsFocusCandidate();
74
- expect(getCandidateStack()).toEqual([
75
- refs.testElement.current!,
76
- ]);
77
- });
78
-
79
- it('should the focus candidate', () => {
80
- elementStructure.ref().focus();
81
- setActiveElementAsFocusCandidate();
82
- refs.testElement.current!.focus();
83
- focusCandidate();
84
- expect(document.activeElement).toBe(elementStructure.ref());
85
- });
86
-
87
- it('should fill and pop the candidate stack properly', () => {
88
- elementStructure.ref().focus();
89
- setActiveElementAsFocusCandidate();
90
- refs.testElement.current!.focus();
91
- setActiveElementAsFocusCandidate();
92
- refs.testComponent1.current!.focus();
93
- setActiveElementAsFocusCandidate();
94
- refs.testComponent2.current!.focus();
95
- setActiveElementAsFocusCandidate();
96
- expect(getCandidateStack()).toEqual([
97
- elementStructure.ref(),
98
- refs.testElement.current!,
99
- refs.testComponent1.current!.wrapperRef.current!,
100
- refs.testComponent2.current!.wrapperRef.current!,
101
- ]);
102
- // the last registered is skipped, because it's the current activeElement
103
- // so the method should be called only 3x
104
- focusCandidate();
105
- focusCandidate();
106
- focusCandidate();
107
- expect(getCandidateStack()).toEqual([]);
108
- });
109
-
110
- it('should focus candidates during stack popping', () => {
111
- elementStructure.ref().focus();
112
- setActiveElementAsFocusCandidate();
113
- refs.testElement.current!.focus();
114
- setActiveElementAsFocusCandidate();
115
- refs.testComponent1.current!.focus();
116
- setActiveElementAsFocusCandidate();
117
- refs.testComponent2.current!.focus();
118
- focusCandidate();
119
- expect(document.activeElement).toBe(refs.testComponent1.current!.wrapperRef.current!);
120
- focusCandidate();
121
- expect(document.activeElement).toBe(refs.testElement.current!);
122
- focusCandidate();
123
- expect(document.activeElement).toBe(elementStructure.ref());
124
- });
125
-
126
- it('should work with the next candidate', () => {
127
- elementStructure.ref().focus();
128
- setActiveElementAsFocusCandidate();
129
- setNextFocusCandidate(refs.testElement.current!);
130
- refs.testElement.current!.focus();
131
- focusCandidate();
132
- expect(document.activeElement).toBe(elementStructure.ref());
133
- });
134
-
135
- it('should work with the candidate as a component', () => {
136
- refs.testComponent1.current!.focus();
137
- setNextFocusCandidate(refs.testComponent1.current!);
138
- refs.testComponent2.current!.focus();
139
- setNextFocusCandidate(refs.testComponent2.current!);
140
- expect(getCandidateStack()).toEqual([
141
- refs.testComponent1.current!,
142
- refs.testComponent2.current!,
143
- ]);
144
- // last candidate shoul'd not be focused
145
- // because last focused candidate can't be currently focused element
146
- focusCandidate();
147
- expect(document.activeElement).toBe(refs.testComponent1.current!.wrapperRef.current!);
148
- });
149
-
150
- it('should work with the candidate as a reference', () => {
151
- refs.testComponent1.current!.focus();
152
- setNextFocusCandidate(refs.testComponent1);
153
- refs.testComponent2.current!.focus();
154
- setNextFocusCandidate(refs.testComponent2);
155
- expect(getCandidateStack()).toEqual([
156
- refs.testComponent1,
157
- refs.testComponent2,
158
- ]);
159
- focusCandidate();
160
- expect(document.activeElement).toBe(refs.testComponent1.current!.wrapperRef.current!);
161
- });
162
-
163
- it('should work with the candidate as multiple types and focus only unique elements', () => {
164
- refs.testElement.current!.focus();
165
- setActiveElementAsFocusCandidate();
166
- refs.testComponent1.current!.focus();
167
- setNextFocusCandidate(refs.testComponent1);
168
- refs.testComponent2.current!.focus();
169
- setNextFocusCandidate(refs.testComponent2.current!);
170
- expect(getCandidateStack()).toEqual([
171
- refs.testElement.current!,
172
- refs.testComponent1,
173
- refs.testComponent2.current!,
174
- ]);
175
- focusCandidate();
176
- expect(document.activeElement).toBe(refs.testComponent1.current!.wrapperRef.current!);
177
- focusCandidate();
178
- expect(document.activeElement).toBe(refs.testElement.current!);
179
- });
180
-
181
- it('should work with the next candidate as a component', () => {
182
- refs.testComponent1.current!.focus();
183
- setFocusCandidate(refs.testComponent1.current!);
184
- refs.testComponent2.current!.focus();
185
- setNextFocusCandidate(refs.testComponent2.current!);
186
- expect(getCandidateStack()).toEqual([
187
- refs.testComponent1.current!,
188
- refs.testComponent2.current!,
189
- ]);
190
- focusCandidate();
191
- expect(document.activeElement).toBe(refs.testComponent1.current!.wrapperRef.current!);
192
- });
193
-
194
- it('should not focus an unavailable candidate', () => {
195
- elementStructure.ref().focus();
196
- setActiveElementAsFocusCandidate();
197
- refs.testElement.current!.focus();
198
- setActiveElementAsFocusCandidate();
199
- refs.testComponent1.current!.focus();
200
- setFocusCandidate(refs.testComponent1.current!);
201
-
202
- refs.testElement.current!.style.display = 'none';
203
- removeNode(refs.testComponent1.current!.wrapperRef);
204
-
205
- focusCandidate();
206
- expect(document.activeElement).toBe(elementStructure.ref());
207
- });
208
-
209
- it('should set and work with a candidate fallback', () => {
210
- setCandidateFallback(elementStructure.ref());
211
-
212
- refs.testElement.current!.focus();
213
- setActiveElementAsFocusCandidate();
214
- refs.testComponent1.current!.focus();
215
- setActiveElementAsFocusCandidate();
216
- refs.testComponent2.current!.focus();
217
- setActiveElementAsFocusCandidate();
218
-
219
- refs.testElement.current!.style.display = 'none';
220
- removeNode(refs.testComponent1.current!.wrapperRef);
221
- removeNode(refs.testComponent2.current!.wrapperRef);
222
-
223
- focusCandidate();
224
- expect(document.activeElement).toBe(elementStructure.ref());
225
- });
226
-
227
- it('should clear the candidate stack', () => {
228
- elementStructure.ref().focus();
229
- setActiveElementAsFocusCandidate();
230
- refs.testElement.current!.focus();
231
- setActiveElementAsFocusCandidate();
232
- refs.testComponent1.current!.focus();
233
- setActiveElementAsFocusCandidate();
234
-
235
- expect(getCandidateStack()).toEqual([
236
- elementStructure.ref(),
237
- refs.testElement.current!,
238
- refs.testComponent2.current!.wrapperRef.current!,
239
- ]);
240
-
241
- clearCandidateStack();
242
-
243
- expect(getCandidateStack()).toEqual([]);
244
- });
245
- });
@@ -1,21 +0,0 @@
1
- import { focusFirstExisting } from '../focusFirstExisting';
2
-
3
- describe('focusFirstExisting', () => {
4
- const mockFocus1 = jest.fn();
5
- const mockFocus2 = jest.fn();
6
-
7
- it('should properly focus references', () => {
8
- focusFirstExisting(
9
- { current: { focus: mockFocus1 } },
10
- { current: { focus: mockFocus2 } },
11
- )();
12
- expect(mockFocus1).toHaveBeenCalledTimes(1);
13
- expect(mockFocus2).toHaveBeenCalledTimes(0);
14
- focusFirstExisting(
15
- { current: null },
16
- { current: { focus: mockFocus2 } },
17
- )();
18
- expect(mockFocus1).toHaveBeenCalledTimes(1);
19
- expect(mockFocus2).toHaveBeenCalledTimes(1);
20
- });
21
- });
@@ -1,41 +0,0 @@
1
- import { createRef } from '@24i/bigscreen-sdk/jsx';
2
- import { shallow } from '@24i/bigscreen-sdk/jsx/test-utils';
3
- import { refocusAfterHashChange } from '../refocusAfterHashChange';
4
-
5
- jest.useFakeTimers();
6
-
7
- describe('refocusAfterHashChange', () => {
8
- const wrapper = createRef<HTMLDivElement>();
9
- const elementInsideWrapper = createRef<HTMLDivElement>();
10
- const elementOutsideWrapper = createRef<HTMLDivElement>();
11
- shallow(
12
- <div>
13
- <div ref={wrapper}>
14
- <div ref={elementInsideWrapper} tabIndex={0} />
15
- </div>
16
- <div ref={elementOutsideWrapper} tabIndex={0} />
17
- </div>,
18
- );
19
-
20
- afterEach(() => {
21
- jest.clearAllMocks();
22
- });
23
-
24
- it('should refocus active element inside wrapper', () => {
25
- elementInsideWrapper.current!.focus();
26
- const activeElement = document.activeElement as HTMLElement;
27
- const spyOnFocus = jest.spyOn(activeElement, 'focus');
28
- refocusAfterHashChange(wrapper);
29
- jest.runAllTimers();
30
- expect(spyOnFocus).toHaveBeenCalledTimes(1);
31
- });
32
-
33
- it('should not refocus active element outside wrapper', () => {
34
- elementOutsideWrapper.current!.focus();
35
- const activeElement = document.activeElement as HTMLElement;
36
- const spyOnFocus = jest.spyOn(activeElement, 'focus');
37
- refocusAfterHashChange(wrapper);
38
- jest.runAllTimers();
39
- expect(spyOnFocus).toHaveBeenCalledTimes(0);
40
- });
41
- });
@@ -1,41 +0,0 @@
1
- import { createRef } from '@24i/bigscreen-sdk/jsx';
2
- import { shallow } from '@24i/bigscreen-sdk/jsx/test-utils';
3
- import { safeFocus } from '../safeFocus';
4
-
5
- describe('safeFocus', () => {
6
- const wrapperElement = createRef<HTMLDivElement>();
7
- const element1 = createRef<HTMLDivElement>();
8
- const element2 = createRef<HTMLDivElement>();
9
- const testSafeFocus = safeFocus(wrapperElement);
10
-
11
- shallow(
12
- <div>
13
- <div ref={wrapperElement} tabIndex={0}>
14
- <div ref={element1} tabIndex={0} />
15
- </div>
16
- <div ref={element2} tabIndex={0} />
17
- </div>,
18
- );
19
-
20
- it('should focus element when activeElement is inside of the wrapperElement', () => {
21
- wrapperElement.current!.focus();
22
- testSafeFocus(element1.current!);
23
- expect(document.activeElement === element1.current!).toBeTruthy();
24
- testSafeFocus(wrapperElement.current!);
25
- expect(document.activeElement === wrapperElement.current!).toBeTruthy();
26
- });
27
-
28
- it('should focus element when activeElement is body', () => {
29
- document.body.focus();
30
- testSafeFocus(element1.current!);
31
- expect(document.activeElement === element1.current!).toBeTruthy();
32
- });
33
-
34
- it('should not focus element when activeElement is outside of the wrapperElement', () => {
35
- element2.current!.focus();
36
- testSafeFocus(element1.current!);
37
- expect(document.activeElement === element1.current!).toBeFalsy();
38
- testSafeFocus(wrapperElement.current!);
39
- expect(document.activeElement === wrapperElement.current!).toBeFalsy();
40
- });
41
- });
@@ -1,61 +0,0 @@
1
- import { createRef } from '@24i/bigscreen-sdk/jsx';
2
- import { getKeyMap } from '@24i/bigscreen-sdk/device';
3
- import { MountedComponent, shallow, keydown } from '@24i/bigscreen-sdk/jsx/test-utils';
4
- import { MouseElementWrapper } from '../MouseElementWrapper';
5
- import { MouseNavigationInterface } from '../MouseNavigationInterface';
6
-
7
- describe('MouseElementWrapper', () => {
8
- const mPointRef = createRef<HTMLDivElement>();
9
- let root: MountedComponent<HTMLDivElement>;
10
- let nav: MountedComponent<MouseElementWrapper>;
11
-
12
- beforeEach(() => {
13
- jest.clearAllMocks();
14
- root = shallow(<div className="mounting-point" ref={mPointRef} />);
15
- nav = shallow(
16
- <>
17
- <MouseElementWrapper
18
- getMountingPoint={() => mPointRef}
19
- >
20
- <div className="test-child" />
21
- </MouseElementWrapper>
22
- </>,
23
- );
24
- });
25
-
26
- afterEach(() => {
27
- nav.unmount();
28
- root.unmount();
29
- });
30
-
31
- it('should not render child immediately', () => {
32
- expect(root.find('.test-child')).toBe(null);
33
- });
34
-
35
- it('should handle key event correctly', () => {
36
-
37
- const event = new MouseEvent('mousemove', {});
38
- document.dispatchEvent(event);
39
-
40
- expect(root.find('.mounting-point').firstElementChild)
41
- .toBe(nav.ref().domRef.current);
42
-
43
- keydown(document, getKeyMap().UP!);
44
- expect(root.find('.mounting-point').firstElementChild).toBe(null);
45
- });
46
-
47
- it('should handle interface request to hide', () => {
48
- const event = new MouseEvent('mousemove', {});
49
- document.dispatchEvent(event);
50
-
51
- expect(root.find('.mounting-point').firstElementChild)
52
- .toBe(nav.ref().domRef.current);
53
-
54
- MouseNavigationInterface.hide();
55
- expect(root.find('.mounting-point').firstElementChild).toBe(null);
56
-
57
- MouseNavigationInterface.show();
58
- expect(root.find('.mounting-point').firstElementChild)
59
- .toBe(nav.ref().domRef.current);
60
- });
61
- });
@@ -1,107 +0,0 @@
1
- import { createRef } from '@24i/bigscreen-sdk/jsx';
2
- import { getKeyMap } from '@24i/bigscreen-sdk/device';
3
- import { MountedComponent, shallow, keydown } from '@24i/bigscreen-sdk/jsx/test-utils';
4
- import { MouseNavigation } from '../MouseNavigation';
5
- import { MouseNavigationInterface } from '../MouseNavigationInterface';
6
-
7
- const forwardMock = jest.fn();
8
- const backwardMock = jest.fn();
9
- const showForwardMock = jest.fn(() => true);
10
- const showBackwardMock = jest.fn(() => true);
11
-
12
- describe('MouseNavigation', () => {
13
- const mPointRef = createRef<HTMLDivElement>();
14
- let nav: MountedComponent<MouseNavigation>;
15
-
16
- beforeEach(() => {
17
- nav = shallow(
18
- <MouseNavigation
19
- getMountingPoint={() => mPointRef}
20
- direction="vertical"
21
- forward={forwardMock}
22
- backward={backwardMock}
23
- shouldShowMrcuForward={showForwardMock}
24
- shouldShowMrcuBackward={showBackwardMock}
25
- >
26
- <>
27
- <div className="test-child" />
28
- <div className="mounting-point" ref={mPointRef} />
29
- </>
30
- </MouseNavigation>,
31
- );
32
- });
33
-
34
- afterEach(() => {
35
- nav.unmount();
36
- });
37
-
38
- it('should handle key event correctly', () => {
39
-
40
- const event = new MouseEvent('mousemove', {});
41
- document.dispatchEvent(event);
42
-
43
- expect(nav.find('.mounting-point').firstElementChild)
44
- .toBe(nav.ref().arrows.current?.domRef.current);
45
-
46
- keydown(document, getKeyMap().UP!);
47
-
48
- expect(nav.find('.mounting-point').firstElementChild).toBe(null);
49
- });
50
-
51
- it('should render child', () => {
52
- expect(nav.find('.test-child').className).not.toBe(null);
53
- });
54
-
55
- it('should return correct mapped direction', () => {
56
- expect(nav.ref().mapDirectionToProps('horizontal').horizontal).toBe(true);
57
- expect(nav.ref().mapDirectionToProps('vertical').vertical).toBe(true);
58
- });
59
-
60
- it('should handle interface request to hide', () => {
61
- const event = new MouseEvent('mousemove', {});
62
- document.dispatchEvent(event);
63
-
64
- expect(nav.find('.mounting-point').firstElementChild)
65
- .toBe(nav.ref().arrows.current?.domRef.current);
66
-
67
- MouseNavigationInterface.hide();
68
-
69
- expect(nav.find('.mounting-point').firstElementChild).toBe(null);
70
-
71
- MouseNavigationInterface.show();
72
-
73
- expect(nav.find('.mounting-point').firstElementChild)
74
- .toBe(nav.ref().arrows.current?.domRef.current);
75
- });
76
-
77
- it('should propagate forward and backward', () => {
78
- nav.ref().handleArrowState = jest.fn();
79
- nav.ref().forward();
80
- nav.ref().backward();
81
-
82
- expect(forwardMock).toHaveBeenCalledTimes(1);
83
- expect(backwardMock).toHaveBeenCalledTimes(1);
84
- expect(nav.ref().handleArrowState).toHaveBeenCalledTimes(2);
85
- });
86
-
87
- it('should show/hide arrows as reported', () => {
88
- nav.ref().arrows = {
89
- current: {
90
- enableArrow: jest.fn(),
91
- disableArrow: jest.fn(),
92
- },
93
- } as any;
94
-
95
- nav.ref().handleArrowState();
96
- expect(nav.ref().arrows.current?.enableArrow).toHaveBeenNthCalledWith(1, 'down');
97
- expect(nav.ref().arrows.current?.enableArrow).toHaveBeenNthCalledWith(2, 'up');
98
- expect(nav.ref().arrows.current?.enableArrow).toHaveBeenCalledTimes(2);
99
-
100
- showForwardMock.mockImplementationOnce(() => false);
101
- showBackwardMock.mockImplementationOnce(() => false);
102
- nav.ref().handleArrowState();
103
- expect(nav.ref().arrows.current?.disableArrow).toHaveBeenNthCalledWith(1, 'down');
104
- expect(nav.ref().arrows.current?.disableArrow).toHaveBeenNthCalledWith(2, 'up');
105
- expect(nav.ref().arrows.current?.disableArrow).toHaveBeenCalledTimes(2);
106
- });
107
- });