@24i/bigscreen-sdk 1.0.4-alpha.2118 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@24i/bigscreen-sdk",
3
- "version": "1.0.4-alpha.2118",
3
+ "version": "1.0.4",
4
4
  "description": "SmartApps BIGscreen SDK monorepo",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -38,11 +38,11 @@
38
38
  "homepage": "https://github.com/24i/smartapps-bigscreen-sdk#readme",
39
39
  "dependencies": {
40
40
  "@24i/player-base": "6.10.0",
41
- "@24i/smartapps-datalayer": "2.3.4-beta.2",
42
- "@sentry/browser": "^7.8.0",
41
+ "@24i/smartapps-datalayer": "3.0.2",
42
+ "@sentry/browser": "^7.12.1",
43
43
  "@types/prop-types": "^15.7.5",
44
- "@types/scheduler": "^0.16.1",
45
- "csstype": "^3.1.0",
44
+ "@types/scheduler": "^0.16.2",
45
+ "csstype": "^3.1.1",
46
46
  "lottie-web": "5.9.6",
47
47
  "prop-types": "^15.8.1"
48
48
  },
@@ -50,33 +50,33 @@
50
50
  "@24i/bigscreen-sdk": "file:.",
51
51
  "@24i/eslint-config-smartapps-bigscreen-linters": "file:./libs/linters",
52
52
  "@24i/smartapps-bigscreen-changelog-generator": "0.17.0",
53
- "@babel/core": "^7.18.9",
54
- "@babel/preset-env": "^7.18.9",
53
+ "@babel/core": "^7.19.0",
54
+ "@babel/preset-env": "^7.19.0",
55
55
  "@types/fs-extra": "^9.0.13",
56
- "@types/inquirer": "^8.2.1",
57
- "@types/jest": "^28.1.6",
56
+ "@types/inquirer": "^9.0.1",
57
+ "@types/jest": "^29.0.2",
58
58
  "@types/minimist": "^1.2.2",
59
- "@types/node": "^18.6.3",
60
- "@types/react": "^18.0.18",
61
- "babel-jest": "^28.1.2",
62
- "chalk": "^4.1.2",
63
- "coveralls": "^3.1.0",
59
+ "@types/node": "^18.7.18",
60
+ "@types/react": "^18.0.20",
61
+ "babel-jest": "^29.0.3",
62
+ "chalk": "^5.0.1",
63
+ "coveralls": "^3.1.1",
64
64
  "cross-env": "^7.0.3",
65
65
  "fs-extra": "^10.1.0",
66
- "full-icu": "^1.4.0",
66
+ "full-icu": "^1.5.0",
67
67
  "identity-obj-proxy": "^3.0.0",
68
- "inquirer": "^9.0.2",
69
- "jest": "^28.1.2",
68
+ "inquirer": "^9.1.1",
69
+ "jest": "^29.0.3",
70
70
  "jest-canvas-mock": "^2.4.0",
71
- "jest-environment-jsdom": "^28.1.2",
71
+ "jest-environment-jsdom": "^29.0.3",
72
72
  "minimist": "^1.2.6",
73
- "patch-package": "^6.2.1",
74
- "sass": "^1.54.8",
73
+ "patch-package": "^6.4.7",
74
+ "sass": "^1.54.9",
75
75
  "sass-true": "^6.1.0",
76
- "ts-jest": "^28.0.8",
77
- "ts-node": "^10.8.2",
76
+ "ts-jest": "^29.0.1",
77
+ "ts-node": "^10.9.1",
78
78
  "tsconfig-paths-jest": "0.0.1",
79
- "typescript": "^4.8.2"
79
+ "typescript": "^4.8.3"
80
80
  },
81
81
  "exports": {
82
82
  "./adobe-heartbeat": "./packages/adobe-heartbeat/src/index.ts",
@@ -53,7 +53,7 @@ export class EnvironmentListItem extends Component<Props> implements Item<ItemDa
53
53
  trimRows() {
54
54
  const { leadingEllipses } = this.props;
55
55
  if (leadingEllipses) {
56
- trimWithLeadingEllipsis(this.labelRef.current!, 2);
56
+ trimWithLeadingEllipsis(this.labelRef.current!, 1);
57
57
  }
58
58
  }
59
59
 
@@ -83,6 +83,25 @@ Because of this behavior, actions frequently used in onFocusChanged representing
83
83
  scroll change can't be used. For this purpose there is `onScrollChanged` callback,
84
84
  which is called every time grid is performing scroll operation.
85
85
 
86
+ ## Prevent blur on long press
87
+ When the user holds a navigation key, he usually scrolls to the end (or start) of the grid,
88
+ and then releases the key. This operation is very quick and most of the time he releases
89
+ the key too late, so the keydown event from the grid will propagate to another component
90
+ in the layout. This causes for example opening of the menu even though the user is still holding
91
+ the key and scrolling the grid. For those situations and to have better control above the layout
92
+ navigation, there is a prop `preventBlurOnLongPress`. When the user scrolls to the end (or start)
93
+ of the grid, he needs to release the key and press it again to propagate the event higher
94
+ and focus another component.
95
+
96
+ ```ts
97
+ preventBlurOnLongPress: {
98
+ forward?: boolean, // apply when user scroll forward in the current grid group
99
+ backward?: boolean, // apply when user scroll backward in the current grid group
100
+ forwardGroup?: boolean, // apply when user scroll forward the whole grid group
101
+ backwardGroup?: boolean, // apply when user scroll backward the whole grid group
102
+ }
103
+ ```
104
+
86
105
  ## Prepared grids
87
106
  - [BasicGrid - (slow/animated)](./BasicGrid/README.md)
88
107
  - [FixedToEndGrid - (slow/animated)](./FixedToEndGrid/README.md)
@@ -134,10 +153,10 @@ Less the number, slower the scrolling. Undefined or 0 is unlimited scroll speed.
134
153
  speed could improve overall animation performance in some cases.
135
154
 
136
155
  ### fastLinear property
137
- List animation provides possibility of optimizing the animation during slow speeds and smoothing
156
+ Grid animation provides possibility of optimizing the animation during slow speeds and smoothing
138
157
  the scrolling effect without easing in `normal` property interfering the movement.
139
158
  This is achieved by changing the ease of the animation to linear when the scroll is longer
140
- and user is moving the list further.
159
+ and user is moving the grid further.
141
160
  `fastLinear` property have these settings:
142
161
  - time - duration of the animation, same as in `normal` property
143
162
  - startRatio - this number represents the threshold, when should linear animation start.
@@ -20,9 +20,9 @@ export type Props<T extends Item<U>, U> = Omit<SharedProps<T, U>, 'scrollStep'>
20
20
  shouldShowMrcuForward?: () => boolean,
21
21
  shouldShowMrcuBackward?: () => boolean,
22
22
  adjustFocusFromTarget?: (itemRefIndex: number, groupRefIndex: number) => void,
23
+ shouldApplySlowdown?: () => boolean,
23
24
  horizontal?: boolean,
24
25
  limit?: number,
25
- shouldApplySlowdown?: () => boolean,
26
26
  };
27
27
 
28
28
  const isForward = (event: KeyboardEvent, horizontal: boolean | undefined) => {
@@ -49,6 +49,8 @@ const WHEEL_STOP_TIMEOUT = 500;
49
49
 
50
50
  const FAST_SCROLLING_TRIGGERED_AT = 2;
51
51
 
52
+ const PREVENT_BLUR_ON_LONG_PRESS_KEYDOWNS = 2;
53
+
52
54
  export class GridBase<T extends Item<U>, U>
53
55
  extends Component<Props<T, U>> {
54
56
  scroller = createRef<Scroller>();
@@ -75,6 +77,8 @@ export class GridBase<T extends Item<U>, U>
75
77
 
76
78
  isFastScrolling = false;
77
79
 
80
+ preventBlurCounter = 0;
81
+
78
82
  static defaultProps = {
79
83
  className: '',
80
84
  horizontal: false,
@@ -82,6 +86,7 @@ export class GridBase<T extends Item<U>, U>
82
86
  onFocusChanged: noop,
83
87
  fastFocusingOptimization: false,
84
88
  shouldApplySlowdown: () => false,
89
+ preventBlurOnLongPress: {},
85
90
  };
86
91
 
87
92
  declare props: DeclareProps<Props<T, U>, typeof GridBase.defaultProps>;
@@ -118,6 +123,7 @@ export class GridBase<T extends Item<U>, U>
118
123
  const {
119
124
  horizontal, forward, backward, forwardGroup, backwardGroup, shouldApplySlowdown,
120
125
  } = this.props;
126
+ this.preventBlurCounter += 1;
121
127
  if (device.isMouseUsed()) this.adjustIndexFromTarget(event.target!);
122
128
  let processed;
123
129
  let processedGroup;
@@ -142,12 +148,14 @@ export class GridBase<T extends Item<U>, U>
142
148
  } else if (processed === false) {
143
149
  this.fastFocusingOptimizer.stop();
144
150
  this.stopFastScrolling();
151
+ if (this.shouldPreventBlur(event)) stopEvent(event);
145
152
  }
146
153
  };
147
154
 
148
155
  onKeyUp = () => {
149
156
  this.stopFastScrolling();
150
157
  this.fastFocusingOptimizer.stop();
158
+ this.preventBlurCounter = 0;
151
159
  };
152
160
 
153
161
  onWheel = (event: WheelEvent) => {
@@ -170,6 +178,16 @@ export class GridBase<T extends Item<U>, U>
170
178
  }
171
179
  };
172
180
 
181
+ shouldPreventBlur(event: KeyboardEvent) {
182
+ const { horizontal, preventBlurOnLongPress } = this.props;
183
+ return (this.preventBlurCounter >= PREVENT_BLUR_ON_LONG_PRESS_KEYDOWNS && (
184
+ (preventBlurOnLongPress.forward && isForward(event, horizontal))
185
+ || (preventBlurOnLongPress.backward && isBackward(event, horizontal))
186
+ || (preventBlurOnLongPress.forwardGroup && isFwGroup(event, horizontal))
187
+ || (preventBlurOnLongPress.backwardGroup && isBwGroup(event, horizontal))
188
+ ));
189
+ }
190
+
173
191
  getRefAtIndex(i: number): Reference<T> {
174
192
  const ref = this.itemRefs[i];
175
193
  if (!ref) {
@@ -29,6 +29,12 @@ type CommonProps<T extends Item<U>, U> = {
29
29
  fastFocusingOptimization?: boolean,
30
30
  onScrollChanged?: (item: Reference<T>, scrollIndex: number) => void,
31
31
  firstScrollStep?: number,
32
+ preventBlurOnLongPress?: {
33
+ forward?: boolean,
34
+ backward?: boolean,
35
+ forwardGroup?: boolean,
36
+ backwardGroup?: boolean,
37
+ }
32
38
  };
33
39
 
34
40
  type VerticalSharedProps = {
@@ -106,6 +106,23 @@ Because of this behavior, actions frequently used in onFocusChanged representing
106
106
  scroll change can't be used. For this purpose there is `onScrollChanged` callback,
107
107
  which is called every time list is performing scroll operation.
108
108
 
109
+ ## Prevent blur on long press
110
+ When the user holds a navigation key, he usually scrolls to the end (or start) of the list
111
+ and then releases the key. This operation is very quick and most of the time he releases
112
+ the key too late, so the keydown event from the list will propagate to another component
113
+ in the layout. This causes for example opening of the menu even though the user is still holding
114
+ the key and scrolling the list. For those situations and to have better control above the layout
115
+ navigation, there is a prop `preventBlurOnLongPress`. When the user scrolls to the end (or start)
116
+ of the list, he needs to release the key and press it again to propagate the event higher
117
+ and focus another component.
118
+
119
+ ```ts
120
+ preventBlurOnLongPress: {
121
+ forward?: boolean, // apply when user scroll forward
122
+ backward?: boolean, // apply when user scroll backward
123
+ }
124
+ ```
125
+
109
126
  ## Prepared lists
110
127
  - Fixed item size lists
111
128
  - [BasicList - (slow/animated)](./BasicList/README.md)
@@ -24,8 +24,8 @@ export type Props<T extends Item<U>, U> = BasicProps<T, U> & {
24
24
  shouldShowMrcuForward?: () => boolean,
25
25
  shouldShowMrcuBackward?: () => boolean,
26
26
  adjustFocusFromTarget?: (itemRefIndex: number) => void,
27
- limit?: number,
28
27
  shouldApplySlowdown?: () => boolean,
28
+ limit?: number,
29
29
  };
30
30
 
31
31
  const isForward = (event: KeyboardEvent, horizontal: boolean | undefined) => {
@@ -39,8 +39,11 @@ const isBackward = (event: KeyboardEvent, horizontal: boolean | undefined) => {
39
39
  };
40
40
 
41
41
  const WHEEL_STOP_TIMEOUT = 500;
42
+
42
43
  const FAST_SCROLLING_TRIGGERED_AT = 2;
43
44
 
45
+ const PREVENT_BLUR_ON_LONG_PRESS_KEYDOWNS = 2;
46
+
44
47
  export class ListBase<T extends Item<U>, U>
45
48
  extends Component<Props<T, U>> {
46
49
  scroller = createRef<Scroller>();
@@ -65,11 +68,14 @@ export class ListBase<T extends Item<U>, U>
65
68
 
66
69
  isFastScrolling = false;
67
70
 
71
+ preventBlurCounter = 0;
72
+
68
73
  static defaultProps = {
69
74
  className: '',
70
75
  adjustFocusFromTarget: noop,
71
76
  fastFocusingOptimization: false,
72
77
  shouldApplySlowdown: () => false,
78
+ preventBlurOnLongPress: {},
73
79
  };
74
80
 
75
81
  declare props: DeclareProps<Props<T, U>, typeof ListBase.defaultProps>;
@@ -105,9 +111,9 @@ export class ListBase<T extends Item<U>, U>
105
111
  const {
106
112
  horizontal, forward, backward, shouldApplySlowdown,
107
113
  } = this.props;
114
+ this.preventBlurCounter += 1;
108
115
  this.fastFocusingOptimizer.onKeyDown();
109
116
  if (device.isMouseUsed()) this.adjustIndexFromTarget(event.target!);
110
-
111
117
  let processed;
112
118
  if (isForward(event, horizontal)) processed = shouldApplySlowdown() || forward();
113
119
  else if (isBackward(event, horizontal)) processed = shouldApplySlowdown() || backward();
@@ -117,12 +123,14 @@ export class ListBase<T extends Item<U>, U>
117
123
  } else if (processed === false) {
118
124
  this.fastFocusingOptimizer.stop();
119
125
  this.stopFastScrolling();
126
+ if (this.shouldPreventBlur(event)) stopEvent(event);
120
127
  }
121
128
  };
122
129
 
123
130
  onKeyUp = () => {
124
131
  this.stopFastScrolling();
125
132
  this.fastFocusingOptimizer.stop();
133
+ this.preventBlurCounter = 0;
126
134
  };
127
135
 
128
136
  onWheel = (event: WheelEvent) => {
@@ -144,6 +152,14 @@ export class ListBase<T extends Item<U>, U>
144
152
  }
145
153
  };
146
154
 
155
+ shouldPreventBlur(event: KeyboardEvent) {
156
+ const { horizontal, preventBlurOnLongPress } = this.props;
157
+ return (this.preventBlurCounter >= PREVENT_BLUR_ON_LONG_PRESS_KEYDOWNS && (
158
+ (preventBlurOnLongPress.forward && isForward(event, horizontal))
159
+ || (preventBlurOnLongPress.backward && isBackward(event, horizontal))
160
+ ));
161
+ }
162
+
147
163
  getRefAtIndex(i: number): Reference<T> {
148
164
  const ref = this.itemRefs[i];
149
165
  if (!ref) {
@@ -31,7 +31,7 @@ export class CenteredListController<T> extends UnifiedListController<T, Props<an
31
31
  if (initialFocusIndex !== 0) {
32
32
  base.index = initialFocusIndex!;
33
33
  this.focusCurrentItem();
34
- this.scroll(base.index);
34
+ this.scroll(base.index, false);
35
35
  }
36
36
  }
37
37
 
@@ -51,32 +51,39 @@ export type BasicProps<T extends Item<U>, U> = {
51
51
  * config files
52
52
  */
53
53
  animate?: boolean,
54
+ /**
55
+ * Configuration of the animation.
56
+ */
54
57
  animation?: AnimationConfiguration,
55
-
56
58
  /**
57
59
  * Flag that allows speed up scrolling with built in feature in Item
58
60
  * (onFastScrolling) by reducing amount of elements during scrolling.
59
61
  */
60
62
  fastScrolling?: boolean,
61
-
62
63
  /**
63
64
  * Flag that enables fast focusing optimization for scrolling. It prevents
64
65
  * focusing items during scrolling that reduces possible reflow performance
65
66
  * issues.
66
67
  */
67
68
  fastFocusingOptimization?: boolean,
68
-
69
69
  /**
70
70
  * Returns a reference to the custom HTML element for the MRCU arrows.
71
71
  */
72
72
  mrcuMountingPoint?: Reference<HTMLDivElement>,
73
-
74
73
  /**
75
74
  * Function called every time before list performs one full scroll.
76
75
  * @param item Reference to item on current scroll
77
76
  * @param scrollIndex index of current scroll in list
78
77
  */
79
78
  onScrollChanged?: (item: Reference<T>, scrollIndex: number) => void,
79
+ /**
80
+ * Object with flags to prevent the blur of the component and jumping focus
81
+ * out when the user is holding a key to the very end (or start) of the list.
82
+ */
83
+ preventBlurOnLongPress?: {
84
+ forward?: boolean,
85
+ backward?: boolean,
86
+ }
80
87
  };
81
88
 
82
89
  export type SharedProps<T extends Item<U>, U> = BasicProps<T, U> & {
@@ -240,6 +240,7 @@ export class NumericZapper extends Component<Props> {
240
240
  className={`numeric-zapper ${className || ''} ${DISPLAY_NONE}`}
241
241
  ref={this.div}
242
242
  tabIndex={0}
243
+ dir="ltr"
243
244
  data-zapper-allowed
244
245
  >
245
246
  {nTimes(MAX_DIGITS, (_, index) => (
@@ -59,7 +59,7 @@ declare const UNDEFINED_VOID_ONLY: unique symbol;
59
59
  type Destructor = () => void | { [UNDEFINED_VOID_ONLY]: never };
60
60
  type VoidOrUndefinedOnly = void | { [UNDEFINED_VOID_ONLY]: never };
61
61
 
62
- // tslint:disable-next-line:export-just-namespace
62
+ // eslint-disable-next-line export-just-namespace
63
63
  export = React;
64
64
  export as namespace React;
65
65