@24i/bigscreen-sdk 1.0.2-alpha.2074 → 1.0.2-alpha.2078

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 (25) hide show
  1. package/package.json +1 -1
  2. package/packages/developer-tools/src/TechnicalInfo/utils/emeSupport.ts +6 -2
  3. package/packages/driver-tizen/src/DeviceTizen.ts +3 -1
  4. package/packages/focus/src/Layout/Matrix.tsx +1 -2
  5. package/packages/grid/src/Base/Base.tsx +25 -6
  6. package/packages/grid/src/Base/MouseNavigation/MouseNavigation.tsx +82 -0
  7. package/packages/grid/src/Base/MouseNavigation/MouseNavigationFallback.ts +4 -0
  8. package/packages/grid/src/Base/MouseNavigation/index.tizen.tv.ts +1 -0
  9. package/packages/grid/src/Base/MouseNavigation/index.ts +1 -0
  10. package/packages/grid/src/Base/MouseNavigation/index.webos.tv.ts +1 -0
  11. package/packages/grid/src/Base/MouseNavigation/index.webtv.ts +1 -0
  12. package/packages/grid/src/Base/interface.ts +47 -0
  13. package/packages/grid/src/UnifiedGridController/UnifiedGridController.ts +4 -1
  14. package/packages/i18n/src/middlewares/i18next/Plurals/Plurals.ts +2 -2
  15. package/packages/keyboard/src/WhitelabelKeyboard/Keyboard.tsx +6 -2
  16. package/packages/list/src/Base/MouseNavigation/MouseNavigation.tsx +33 -9
  17. package/packages/modal-service/src/ModalService.tsx +3 -1
  18. package/packages/types-bigscreen-jsx/index.d.ts +1 -1
  19. package/packages/utils/src/counter.ts +3 -1
  20. package/packages/utils/src/xhr/xhrSendRetry.ts +2 -2
  21. package/packages/volume-control/src/__mocks__/VolumeControlUIMock.tsx +6 -2
  22. package/packages/grid/src/Base/Base.mouse.tsx +0 -24
  23. package/packages/grid/src/Base/index.tizen.tv.ts +0 -1
  24. package/packages/grid/src/Base/index.webos.tv.ts +0 -1
  25. package/packages/grid/src/Base/index.webtv.ts +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@24i/bigscreen-sdk",
3
- "version": "1.0.2-alpha.2074",
3
+ "version": "1.0.2-alpha.2078",
4
4
  "description": "SmartApps BIGscreen SDK monorepo",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -30,8 +30,12 @@ function isKeySystemSupported(keySystem: string, config: MediaKeySystemConfigura
30
30
  return new Promise((resolve) => {
31
31
  try {
32
32
  window.navigator.requestMediaKeySystemAccess(keySystem, config)
33
- .then(() => { resolve(true); })
34
- .catch(() => { resolve(false); });
33
+ .then(() => {
34
+ resolve(true);
35
+ })
36
+ .catch(() => {
37
+ resolve(false);
38
+ });
35
39
  } catch (e) {
36
40
  resolve(false);
37
41
  }
@@ -252,7 +252,9 @@ export class DeviceTizen extends DeviceBase {
252
252
  this.screenSaverStatus = status;
253
253
  resolve();
254
254
  },
255
- () => { resolve(); },
255
+ () => {
256
+ resolve();
257
+ },
256
258
  );
257
259
  });
258
260
  }
@@ -154,8 +154,7 @@ export class Matrix extends Component<Props> implements IFocusable {
154
154
  isDifferentReferenceFromCurrent(index: Index2D): boolean {
155
155
  const { current } = this.getRefAt(this.index);
156
156
  const { current: searched } = this.getRefAt(index);
157
- if (current !== searched && searched !== null) return true;
158
- return false;
157
+ return current !== searched && searched !== null;
159
158
  }
160
159
 
161
160
  isSameReferenceAsCurrent(index: Index2D): boolean {
@@ -1,13 +1,14 @@
1
1
  import { createRef, Component, Reference, DeclareProps } from '@24i/bigscreen-sdk/jsx';
2
2
  import { device } from '@24i/bigscreen-sdk/device';
3
- import { MouseNavigation } from '@24i/bigscreen-sdk/mouse-navigation';
4
3
  import { Scroller } from '@24i/bigscreen-sdk/scroller';
5
4
  import { stopEvent } from '@24i/bigscreen-sdk/utils/stopEvent';
6
5
  import { noop } from '@24i/bigscreen-sdk/utils/noop';
7
6
  import { forEach } from '@24i/bigscreen-sdk/perf-utils/array';
8
7
  import { createTimeout, createCounter, ICounter } from '@24i/bigscreen-sdk/utils';
8
+ import { MouseNavigation } from './MouseNavigation';
9
9
  import { FastFocusingOptimizer } from '../FastFocusingOptimizer/FastFocusingOptimizer';
10
10
  import { SharedProps, Item } from '../types';
11
+ import { MouseNavigation as IMouseNavigation } from './interface';
11
12
 
12
13
  export type Props<T extends Item<U>, U> = Omit<SharedProps<T, U>, 'scrollStep'> & {
13
14
  forward: () => boolean,
@@ -21,7 +22,6 @@ export type Props<T extends Item<U>, U> = Omit<SharedProps<T, U>, 'scrollStep'>
21
22
  adjustFocusFromTarget?: (itemRefIndex: number, groupRefIndex: number) => void,
22
23
  horizontal?: boolean,
23
24
  limit?: number,
24
- mrcuRef?: Reference<MouseNavigation>;
25
25
  shouldApplySlowdown?: () => boolean,
26
26
  };
27
27
 
@@ -55,6 +55,8 @@ export class GridBase<T extends Item<U>, U>
55
55
 
56
56
  scrollerDom = createRef<HTMLDivElement>();
57
57
 
58
+ mrcuRef = createRef<IMouseNavigation>();
59
+
58
60
  itemRefs: Reference<T>[] = [];
59
61
 
60
62
  groupRefs: Reference<HTMLDivElement>[] = [];
@@ -151,14 +153,13 @@ export class GridBase<T extends Item<U>, U>
151
153
  onWheel = (event: WheelEvent) => {
152
154
  const {
153
155
  forwardGroup, backwardGroup, shouldApplySlowdown,
154
- mrcuRef,
155
156
  } = this.props;
156
157
  let processed;
157
158
  if (event.deltaY > 0) processed = shouldApplySlowdown() || forwardGroup();
158
159
  else if (event.deltaY < 0) processed = shouldApplySlowdown() || backwardGroup();
159
160
  if (processed) {
160
161
  stopEvent(event);
161
- mrcuRef?.current?.handleArrowState();
162
+ this.mrcuRef.current?.handleArrowState();
162
163
  if (this.fastScrollingCounter) {
163
164
  this.fastScrollingCounter.add();
164
165
  this.fakeWheelStop();
@@ -434,7 +435,15 @@ export class GridBase<T extends Item<U>, U>
434
435
  }
435
436
 
436
437
  render() {
437
- const { horizontal, className } = this.props;
438
+ const {
439
+ horizontal,
440
+ className,
441
+ forwardGroup,
442
+ backwardGroup,
443
+ shouldShowMrcuForward,
444
+ shouldShowMrcuBackward,
445
+ } = this.props;
446
+
438
447
  return (
439
448
  <Scroller
440
449
  className={className}
@@ -443,7 +452,17 @@ export class GridBase<T extends Item<U>, U>
443
452
  onKeyDown={this.onKeyDown}
444
453
  horizontal={horizontal}
445
454
  >
446
- {this.renderData()}
455
+ <>{this.renderData()}</>
456
+ <MouseNavigation
457
+ // @ts-ignore - needed to convert fallback (false) to interface
458
+ ref={this.mrcuRef}
459
+ getMountingPoint={() => this.scroller.current!.wrapRef}
460
+ horizontal={horizontal}
461
+ forward={forwardGroup}
462
+ backward={backwardGroup}
463
+ shouldShowMrcuForward={shouldShowMrcuForward}
464
+ shouldShowMrcuBackward={shouldShowMrcuBackward}
465
+ />
447
466
  </Scroller>
448
467
  );
449
468
  }
@@ -0,0 +1,82 @@
1
+ import { Component, createRef, removeNode } from '@24i/bigscreen-sdk/jsx';
2
+ import { MouseNavigation as MouseNavigationBase } from '@24i/bigscreen-sdk/mouse-navigation';
3
+ import { device, DeviceEventMap } from '@24i/bigscreen-sdk/device';
4
+ import {
5
+ MouseNavigationProps as Props,
6
+ MouseNavigation as IMouseNavigation,
7
+ } from '../interface';
8
+
9
+ export class MouseNavigation extends Component<Props> implements IMouseNavigation {
10
+ private readonly wrapper = createRef<HTMLDivElement>();
11
+
12
+ private readonly mouseNavigationBase = createRef<MouseNavigationBase>();
13
+
14
+ private isMouseEnabled = true;
15
+
16
+ componentDidMount() {
17
+ this.handleWheelListener();
18
+ device.addEventListener('mouseactive', this.mouseListener);
19
+ }
20
+
21
+ componentWillUnmount() {
22
+ this.handleWheelListener();
23
+ device.removeEventListener('mouseactive', this.mouseListener);
24
+ }
25
+
26
+ handleWheelListener() {
27
+ if (this.isMouseEnabled && device.isMouseUsed()) {
28
+ this.renderArrows();
29
+ } else {
30
+ this.destroyArrows();
31
+ }
32
+ }
33
+
34
+ handleArrowState() {
35
+ this.mouseNavigationBase?.current?.handleArrowState();
36
+ }
37
+
38
+ mouseListener: DeviceEventMap['mouseactive'] = ({ isMouseActive }) => {
39
+ this.isMouseEnabled = isMouseActive;
40
+ this.handleWheelListener();
41
+ };
42
+
43
+ destroyArrows() {
44
+ if (!this.wrapper.current) return;
45
+ removeNode(this.wrapper);
46
+ }
47
+
48
+ renderArrows() {
49
+ const {
50
+ horizontal,
51
+ forward,
52
+ backward,
53
+ shouldShowMrcuForward,
54
+ shouldShowMrcuBackward,
55
+ getMountingPoint,
56
+ } = this.props;
57
+
58
+ const direction = horizontal ? 'horizontal' : 'vertical';
59
+
60
+ this.appendMount(
61
+ <div ref={this.wrapper} className="mouse-navigation">
62
+ <MouseNavigationBase
63
+ // @ts-ignore - needed to convert fallback (false) to interface
64
+ ref={this.mouseNavigationBase}
65
+ getMountingPoint={() => this.wrapper}
66
+ direction={direction}
67
+ forward={forward}
68
+ backward={backward}
69
+ shouldShowMrcuForward={shouldShowMrcuForward}
70
+ shouldShowMrcuBackward={shouldShowMrcuBackward}
71
+ >
72
+ {null as unknown as JSX.Element}
73
+ </MouseNavigationBase>
74
+ </div>,
75
+ getMountingPoint(),
76
+ );
77
+ }
78
+
79
+ render() {
80
+ return null;
81
+ }
82
+ }
@@ -0,0 +1,4 @@
1
+ import { MouseNavigationProps as Props } from '../interface';
2
+
3
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
4
+ export const MouseNavigation = (props: Props) => false as unknown as JSX.Element;
@@ -0,0 +1 @@
1
+ export { MouseNavigation } from './MouseNavigation';
@@ -0,0 +1 @@
1
+ export { MouseNavigation } from './MouseNavigationFallback';
@@ -0,0 +1 @@
1
+ export { MouseNavigation } from './MouseNavigation';
@@ -0,0 +1 @@
1
+ export { MouseNavigation } from './MouseNavigation';
@@ -0,0 +1,47 @@
1
+ import { Reference, Component } from '@24i/bigscreen-sdk/jsx';
2
+
3
+ export type MouseNavigationProps = {
4
+ /**
5
+ * Function to call on the press of the right arrow.
6
+ */
7
+ forward(): boolean,
8
+ /**
9
+ * Function to call on the press of the left arrow.
10
+ */
11
+ backward(): boolean,
12
+ /**
13
+ * Function to call on the press of the down arrow.
14
+ */
15
+ forwardGroup?(): boolean,
16
+ /**
17
+ * Function to call on the press of the up arrow.
18
+ */
19
+ backwardGroup?(): boolean,
20
+ /**
21
+ * Function which determines whether to show the forward arrow.
22
+ */
23
+ shouldShowMrcuForward?(): boolean,
24
+ /**
25
+ * Function which determines whether to show the backward arrow.
26
+ */
27
+ shouldShowMrcuBackward?(): boolean,
28
+ /**
29
+ * Returns a reference to the element where your `children` should be rendered.
30
+ */
31
+ getMountingPoint(): Reference<HTMLElement>;
32
+ /**
33
+ * Property determines whether navigation is horizontal.
34
+ */
35
+ horizontal?: boolean,
36
+ };
37
+
38
+ export interface MouseNavigation extends Component<MouseNavigationProps> {
39
+ /**
40
+ * Function to disable showing an arrow in the given direction.
41
+ */
42
+ handleArrowState(): void,
43
+ }
44
+
45
+ export interface MouseNavigationComponent {
46
+ new (props: MouseNavigationProps): MouseNavigation,
47
+ }
@@ -295,6 +295,8 @@ export class UnifiedGridController<T> implements IUnifiedGridController<T> {
295
295
  }
296
296
 
297
297
  focusToIndex(dataIndex: number, animate = false) {
298
+ const { grid } = this;
299
+ const base = grid.base.current!;
298
300
  const targetScrollIndex = this.itemIndexToScrollIndex(dataIndex);
299
301
  if (targetScrollIndex > this.scrollIndex) {
300
302
  this.adjustGroupsOffsetsForward(targetScrollIndex);
@@ -304,8 +306,9 @@ export class UnifiedGridController<T> implements IUnifiedGridController<T> {
304
306
  if (targetScrollIndex !== this.scrollIndex) {
305
307
  this.scroll(targetScrollIndex, animate);
306
308
  }
307
- this.grid.base.current!.index = dataIndex;
309
+ base.index = dataIndex;
308
310
  this.focusCurrentItem();
311
+ base.mrcuRef.current?.handleArrowState();
309
312
  }
310
313
 
311
314
  protected focusScrollWrap() {
@@ -45,8 +45,8 @@ const isCountInInterval = (count: number, interval: string) => {
45
45
  if (numbers.length === 1 && parseInt(numbers[0], 10) === count) return true;
46
46
  const from = parseInt(numbers[0], 10);
47
47
  const to = numbers[1] === 'inf' ? Infinity : parseInt(numbers[1], 10);
48
- if (count >= from && count <= to) return true;
49
- return false;
48
+ return count >= from && count <= to;
49
+
50
50
  };
51
51
 
52
52
  const shouldUseInterval = (
@@ -145,7 +145,9 @@ export class Keyboard extends KeyboardBase<Layouts, Props> {
145
145
  <Interactable
146
146
  ref={this.keyRefs.space}
147
147
  className="key key-wide key-space"
148
- onPress={() => { this.onKey(' '); }}
148
+ onPress={() => {
149
+ this.onKey(' ');
150
+ }}
149
151
  >
150
152
  <div className="key-background">
151
153
  {texts.space}
@@ -208,7 +210,9 @@ export class Keyboard extends KeyboardBase<Layouts, Props> {
208
210
  <Interactable
209
211
  ref={this.keyRefs.space}
210
212
  className="key key-wide key-space"
211
- onPress={() => { this.onKey(' '); }}
213
+ onPress={() => {
214
+ this.onKey(' ');
215
+ }}
212
216
  >
213
217
  <div className="key-background">
214
218
  {texts.space}
@@ -1,24 +1,48 @@
1
- import { Component, createRef } from '@24i/bigscreen-sdk/jsx';
1
+ import { Component, createRef, removeNode } from '@24i/bigscreen-sdk/jsx';
2
2
  import { MouseNavigation as MouseNavigationBase } from '@24i/bigscreen-sdk/mouse-navigation';
3
- import { device } from '@24i/bigscreen-sdk/device';
3
+ import { device, DeviceEventMap } from '@24i/bigscreen-sdk/device';
4
4
  import {
5
5
  MouseNavigationProps as Props,
6
6
  MouseNavigation as IMouseNavigation,
7
7
  } from '../interface';
8
8
 
9
9
  export class MouseNavigation extends Component<Props> implements IMouseNavigation {
10
- private readonly div = createRef<HTMLDivElement>();
10
+ private readonly wrapper = createRef<HTMLDivElement>();
11
11
 
12
- private readonly base = createRef<MouseNavigationBase>();
12
+ private readonly mouseNavigationBase = createRef<MouseNavigationBase>();
13
+
14
+ private isMouseEnabled = true;
13
15
 
14
16
  componentDidMount() {
15
- if (device.isMouseUsed()) {
17
+ this.handleWheelListener();
18
+ device.addEventListener('mouseactive', this.mouseListener);
19
+ }
20
+
21
+ componentWillUnmount() {
22
+ this.handleWheelListener();
23
+ device.removeEventListener('mouseactive', this.mouseListener);
24
+ }
25
+
26
+ handleWheelListener() {
27
+ if (this.isMouseEnabled && device.isMouseUsed()) {
16
28
  this.renderArrows();
29
+ } else {
30
+ this.destroyArrows();
17
31
  }
18
32
  }
19
33
 
20
34
  handleArrowState() {
21
- this.base?.current?.handleArrowState();
35
+ this.mouseNavigationBase?.current?.handleArrowState();
36
+ }
37
+
38
+ mouseListener: DeviceEventMap['mouseactive'] = ({ isMouseActive }) => {
39
+ this.isMouseEnabled = isMouseActive;
40
+ this.handleWheelListener();
41
+ };
42
+
43
+ destroyArrows() {
44
+ if (!this.wrapper.current) return;
45
+ removeNode(this.wrapper);
22
46
  }
23
47
 
24
48
  renderArrows() {
@@ -34,11 +58,11 @@ export class MouseNavigation extends Component<Props> implements IMouseNavigatio
34
58
  const direction = horizontal ? 'horizontal' : 'vertical';
35
59
 
36
60
  this.appendMount(
37
- <div ref={this.div} className="mouse-navigation">
61
+ <div ref={this.wrapper} className="mouse-navigation">
38
62
  <MouseNavigationBase
39
63
  // @ts-ignore - needed to convert fallback (false) to interface
40
- ref={this.base}
41
- getMountingPoint={() => this.div}
64
+ ref={this.mouseNavigationBase}
65
+ getMountingPoint={() => this.wrapper}
42
66
  direction={direction}
43
67
  forward={forward}
44
68
  backward={backward}
@@ -36,7 +36,9 @@ export class ModalService extends Component<Props> {
36
36
  }
37
37
  };
38
38
 
39
- getMountedComponent() { return this.modalRef; }
39
+ getMountedComponent() {
40
+ return this.modalRef;
41
+ }
40
42
 
41
43
  open<T extends IModal>(render: (ref: Reference<T>) => JSX.Element) {
42
44
  const { isFocusable } = this.props;
@@ -1273,7 +1273,6 @@ declare namespace React {
1273
1273
  shiftKey: boolean;
1274
1274
  /** @deprecated */
1275
1275
  which: number;
1276
- target: EventTarget & T;
1277
1276
  }
1278
1277
 
1279
1278
  interface MouseEvent<T = Element, E = NativeMouseEvent> extends UIEvent<T, E> {
@@ -2144,6 +2143,7 @@ declare namespace React {
2144
2143
  name?: string | undefined;
2145
2144
  noValidate?: boolean | undefined;
2146
2145
  target?: string | undefined;
2146
+ rel?: string | undefined;
2147
2147
  }
2148
2148
 
2149
2149
  interface HtmlHTMLAttributes<T> extends HTMLAttributes<T> {
@@ -42,6 +42,8 @@ export const createCounter = ({ triggerAt, callback }: CounterProps): ICounter =
42
42
  getCurrentValue: () => counter,
43
43
  isTriggered: () => counter >= triggerAt,
44
44
  isEqual: (value: number = triggerAt) => counter === value,
45
- reset: () => { counter = 0; },
45
+ reset: () => {
46
+ counter = 0;
47
+ },
46
48
  };
47
49
  };
@@ -32,8 +32,8 @@ export type ShouldRetryParam = {
32
32
  function shouldRetryRequest(data: ShouldRetryParam) {
33
33
  const { error, response } = data;
34
34
  if (error) return true;
35
- if (!response || !response.ok) return true;
36
- return false;
35
+ return !response || !response.ok;
36
+
37
37
  }
38
38
 
39
39
  export const defaultRetryConfig = {
@@ -12,7 +12,11 @@ export class VolumeControlUIMock extends Component<{}> implements IVolumeControl
12
12
 
13
13
  hide = () => {};
14
14
 
15
- isVisible() { return true; }
15
+ isVisible() {
16
+ return true;
17
+ }
16
18
 
17
- render() { return <div className="volume-control-ui" />; }
19
+ render() {
20
+ return <div className="volume-control-ui" />;
21
+ }
18
22
  }
@@ -1,24 +0,0 @@
1
- import { createRef, forwardRef, Reference } from '@24i/bigscreen-sdk/jsx';
2
- import { MouseNavigation } from '@24i/bigscreen-sdk/mouse-navigation';
3
- import { GridBase as Base, Props as GridProps } from './Base';
4
- import { Item } from '../types';
5
-
6
- export const GridBase = forwardRef(<T extends Item<U>, U>(props: GridProps<T, U>,
7
- gridRef: Reference<Base<T, U>>,
8
- ) => {
9
- const direction = props.horizontal ? 'horizontal' : 'vertical';
10
- const mrcuRef = createRef<MouseNavigation>();
11
- return (
12
- <MouseNavigation
13
- ref={mrcuRef}
14
- getMountingPoint={() => gridRef.current!.scroller.current!.wrapRef}
15
- direction={direction}
16
- forward={props.mrcuForward || props.forwardGroup}
17
- backward={props.mrcuBackward || props.backwardGroup}
18
- shouldShowMrcuForward={props.shouldShowMrcuForward}
19
- shouldShowMrcuBackward={props.shouldShowMrcuBackward}
20
- >
21
- <Base {...props} ref={gridRef} mrcuRef={mrcuRef} />
22
- </MouseNavigation>
23
- );
24
- });
@@ -1 +0,0 @@
1
- export { GridBase } from './Base.mouse';
@@ -1 +0,0 @@
1
- export { GridBase } from './Base.mouse';
@@ -1 +0,0 @@
1
- export { GridBase } from './Base.mouse';