@maestro_io/maestro-web-sdk 2.1.2 → 2.1.3

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 (68) hide show
  1. package/dist/components/atoms/Rive/index.d.ts +1 -0
  2. package/dist/components/atoms/Rive/index.js +3 -2
  3. package/dist/components/molecules/ActionButton/ActionButton.d.ts +1 -0
  4. package/dist/components/molecules/PanelNavButton/PanelNavButton.d.ts +1 -0
  5. package/dist/components/organisms/PanelNavigation/PanelNavigation.js +5 -6
  6. package/dist/components/organisms/SegmentController/SegmentController.d.ts +2 -2
  7. package/dist/components/organisms/SegmentController/SegmentController.js +5 -6
  8. package/dist/external/spatial-navigation/index.d.ts +2 -3
  9. package/dist/external/spatial-navigation/index.js +1 -2
  10. package/dist/external/spatial-navigation/spatialNavigation.d.ts +2 -4
  11. package/dist/external/spatial-navigation/spatialNavigation.js +25 -36
  12. package/dist/external/spatial-navigation/withFocusable.d.ts +1 -0
  13. package/dist/external/spatial-navigation/withFocusable.js +17 -10
  14. package/dist/maestro-web-sdk.umd.js +3 -3
  15. package/dist/maestro-web-sdk.umd.js.map +1 -1
  16. package/dist/modules/bets/view/HotProps/HotPropsView.d.ts +7 -6
  17. package/dist/modules/bets/view/HotProps/HotPropsView.js +11 -11
  18. package/dist/modules/bets/view/SixPack/SixPackView.d.ts +2 -2
  19. package/dist/modules/bets/view/SixPack/SixPackView.js +4 -4
  20. package/dist/modules/bets/view/TabLoadFailureView.d.ts +1 -0
  21. package/dist/modules/bets/view/UserBets/BetsCard/BetsCard.d.ts +7 -6
  22. package/dist/modules/bets/view/UserBets/BetsCard/BetsCard.js +10 -10
  23. package/dist/modules/bets/view/components/Bet/Bet.d.ts +1 -0
  24. package/dist/modules/bets/view/components/PromoCodeBanner/PromoCodeBanner.d.ts +2 -2
  25. package/dist/modules/bets/view/components/PromoCodeBanner/PromoCodeBanner.js +4 -4
  26. package/dist/modules/bets/view-model/BetsViewModel.js +2 -2
  27. package/dist/modules/key-plays/view/KeyPlayCardView.d.ts +0 -4
  28. package/dist/modules/key-plays/view/KeyPlayCardView.js +4 -26
  29. package/dist/modules/key-plays/view/KeyPlaysView.js +1 -2
  30. package/dist/modules/stats/interfaces/IStats.d.ts +6 -3
  31. package/dist/modules/stats/mocks.d.ts +80 -0
  32. package/dist/modules/stats/mocks.js +140 -0
  33. package/dist/modules/stats/utils/renderTeamStatistic.d.ts +21 -0
  34. package/dist/modules/stats/utils/renderTeamStatistic.js +16 -0
  35. package/dist/modules/stats/view/ActiveAthletes/ActiveAthletes.d.ts +34 -0
  36. package/dist/modules/stats/view/ActiveAthletes/ActiveAthletes.js +78 -0
  37. package/dist/modules/stats/view/ActiveAthletes/CollapsedAthletes/CollapsedAthletes.d.ts +5 -0
  38. package/dist/modules/stats/view/ActiveAthletes/CollapsedAthletes/CollapsedAthletes.js +27 -0
  39. package/dist/modules/stats/view/ActiveAthletes/ExpandedAthletes/ExpandedAthletes.d.ts +10 -0
  40. package/dist/modules/stats/view/ActiveAthletes/ExpandedAthletes/ExpandedAthletes.js +15 -0
  41. package/dist/modules/stats/view/ActiveAthletes/index.d.ts +2 -0
  42. package/dist/modules/stats/view/ActiveAthletes/index.js +2 -0
  43. package/dist/modules/stats/view/GameLeaders/GameLeaders.d.ts +2 -23
  44. package/dist/modules/stats/view/GameLeaders/GameLeaders.js +1 -1
  45. package/dist/modules/stats/view/MatchPredictor/MatchPredictorView.d.ts +1 -0
  46. package/dist/modules/stats/view/RecentGames/RecentGames.d.ts +1 -0
  47. package/dist/modules/stats/view/StatsQRCode/StatsQRCodeView.d.ts +1 -0
  48. package/dist/modules/stats/view/StatsView.d.ts +1 -1
  49. package/dist/modules/stats/view/StatsView.js +31 -11
  50. package/dist/modules/stats/view/TeamStats/TeamStatsView.d.ts +54 -0
  51. package/dist/modules/stats/view/TeamStats/TeamStatsView.js +69 -0
  52. package/dist/modules/stats/view/TeamStats/index.d.ts +2 -0
  53. package/dist/modules/stats/view/TeamStats/index.js +1 -0
  54. package/dist/modules/stats/view/Teams/StatsProgressBar.js +7 -3
  55. package/dist/modules/stats/view/Teams/Teams.d.ts +1 -0
  56. package/dist/modules/stats/view/Teams/Teams.js +15 -8
  57. package/dist/modules/stats/view/WinProbability/WinProbability.d.ts +1 -0
  58. package/dist/modules/stats/view/components/AthletesStatistics/AthletesStatistics.d.ts +19 -3
  59. package/dist/modules/stats/view/components/AthletesStatistics/AthletesStatistics.js +7 -6
  60. package/dist/modules/stats/view/components/AthletesStatistics/StatisticTable.d.ts +2 -8
  61. package/dist/modules/stats/view/components/AthletesStatistics/StatisticTable.js +4 -3
  62. package/dist/modules/stats/view/index.d.ts +1 -0
  63. package/dist/modules/stats/view/index.js +1 -0
  64. package/dist/services/StatsService.d.ts +36 -0
  65. package/dist/services/StatsService.js +68 -0
  66. package/dist/view-models/MaestroEventViewModel.d.ts +7 -0
  67. package/dist/view-models/MaestroEventViewModel.js +18 -6
  68. package/package.json +1 -1
@@ -10,6 +10,7 @@ declare const _default: {
10
10
  onLoadRiveInstance: (riveInstance: any) => void;
11
11
  } & WithFocusableProps) | undefined, context?: any): {
12
12
  state: import("../../../external/spatial-navigation/withFocusable").WithFocusableState;
13
+ navigation: import("../../../external/spatial-navigation/spatialNavigation").default;
13
14
  getChildContext(): {
14
15
  parentFocusKey: string;
15
16
  };
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
- import { setFocus, withFocusable, } from '@/external/spatial-navigation';
2
+ import { withFocusable, } from '@/external/spatial-navigation';
3
+ import SDK from '@/index';
3
4
  class Rive extends React.Component {
4
5
  constructor() {
5
6
  super(...arguments);
@@ -36,7 +37,7 @@ class Rive extends React.Component {
36
37
  }
37
38
  setTimeout(() => {
38
39
  if (this.props.focusKey && this.props.autoFocus) {
39
- setFocus(this.props.focusKey);
40
+ SDK.getMaestroEventViewModel().navigation.setFocus(this.props.focusKey);
40
41
  }
41
42
  }, 0);
42
43
  }
@@ -5,6 +5,7 @@ import React from 'react';
5
5
  declare const _default: {
6
6
  new (props?: (object & WithFocusableProps) | undefined, context?: any): {
7
7
  state: import("../../../external/spatial-navigation/withFocusable").WithFocusableState;
8
+ navigation: import("../../../external/spatial-navigation/spatialNavigation").default;
8
9
  getChildContext(): {
9
10
  parentFocusKey: string;
10
11
  };
@@ -14,6 +14,7 @@ type PanelNavButtonProps = {
14
14
  declare const _default: {
15
15
  new (props?: (PanelNavButtonProps & import("@/external/spatial-navigation").WithFocusableProps) | undefined, context?: any): {
16
16
  state: import("../../../external/spatial-navigation/withFocusable").WithFocusableState;
17
+ navigation: import("../../../external/spatial-navigation/spatialNavigation").default;
17
18
  getChildContext(): {
18
19
  parentFocusKey: string;
19
20
  };
@@ -1,8 +1,7 @@
1
1
  import PanelNavButton from '@/components/molecules/PanelNavButton';
2
2
  import './PanelNavigation.styles.css';
3
3
  import React from 'react';
4
- import deliverFocus from '@/helpers/deliver-focus';
5
- import { setFocus } from '@/external/spatial-navigation';
4
+ import SDK from '@/index';
6
5
  class PanelNavigationButton extends React.Component {
7
6
  constructor() {
8
7
  super(...arguments);
@@ -10,9 +9,9 @@ class PanelNavigationButton extends React.Component {
10
9
  enumerable: true,
11
10
  configurable: true,
12
11
  writable: true,
13
- value: (d, _props, details) => {
14
- if (d === 'left' && this.props.itemFocused === 0 && details.layout) {
15
- deliverFocus(details.layout.node);
12
+ value: (d, _props) => {
13
+ if (d === 'left' && this.props.itemFocused === 0) {
14
+ SDK.getMaestroEventViewModel().deliverFocus();
16
15
  return;
17
16
  }
18
17
  if (this.props.onArrowPress) {
@@ -44,7 +43,7 @@ class PanelNavigation extends React.Component {
44
43
  writable: true,
45
44
  value: (index) => () => {
46
45
  if (this.state.lastFocused !== index && this.state.lastFocused) {
47
- setFocus(`PANEL_NAV_BUTTON_${this.state.lastFocused}`);
46
+ SDK.getMaestroEventViewModel().navigation.setFocus(`PANEL_NAV_BUTTON_${this.state.lastFocused}`);
48
47
  return;
49
48
  }
50
49
  this.setState({ itemFocused: index, lastFocused: null }, () => {
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import './SegmentController.styles.css';
3
- import { Details, Direction, Layout } from '@/external/spatial-navigation/utils';
3
+ import { Direction, Layout } from '@/external/spatial-navigation/utils';
4
4
  import { WithFocusableProps } from '@/external/spatial-navigation';
5
5
  export type SegmentItem = {
6
6
  title: string;
@@ -22,7 +22,7 @@ declare class SegmentController extends React.Component<SegmentControllerProps>
22
22
  lastActiveIndex: number;
23
23
  };
24
24
  onBecameFocused: (item: SegmentItem, i: number) => (layout: Layout) => void;
25
- handleArrowPress: (index: number) => (direction: Direction, _props: WithFocusableProps, details: Details) => void;
25
+ handleArrowPress: (index: number) => (direction: Direction, _props: WithFocusableProps) => void;
26
26
  render(): React.JSX.Element;
27
27
  }
28
28
  export default SegmentController;
@@ -2,8 +2,7 @@ import React from 'react';
2
2
  import SegmentButton from '@/components/molecules/SegmentButton';
3
3
  import './SegmentController.styles.css';
4
4
  import { DEFAULT_SCROLLABLE_CONTAINER_CONTEXT, SCROLLABLE_CONTEXT_TYPE, } from '@/components/core/ScrollableContainer/ScrollableContainer';
5
- import { setFocus } from '@/external/spatial-navigation';
6
- import deliverFocus from '@/helpers/deliver-focus';
5
+ import SDK from '@/index';
7
6
  class SegmentController extends React.Component {
8
7
  constructor() {
9
8
  super(...arguments);
@@ -29,7 +28,7 @@ class SegmentController extends React.Component {
29
28
  value: (item, i) => (layout) => {
30
29
  if (this.state.lastActiveIndex !== i &&
31
30
  this.state.lastActiveIndex !== null) {
32
- setFocus(`segment-controller-${this.state.lastActiveIndex}`);
31
+ SDK.getMaestroEventViewModel().navigation.setFocus(`segment-controller-${this.state.lastActiveIndex}`);
33
32
  return;
34
33
  }
35
34
  this.setState({
@@ -44,12 +43,12 @@ class SegmentController extends React.Component {
44
43
  enumerable: true,
45
44
  configurable: true,
46
45
  writable: true,
47
- value: (index) => (direction, _props, details) => {
46
+ value: (index) => (direction, _props) => {
48
47
  if (direction === 'down' || direction === 'up') {
49
48
  this.setState({ lastActiveIndex: this.state.activeIndex });
50
49
  }
51
- if (direction === 'left' && index === 0 && details.layout) {
52
- deliverFocus(details.layout.node.firstElementChild);
50
+ if (direction === 'left' && index === 0) {
51
+ SDK.getMaestroEventViewModel().deliverFocus();
53
52
  }
54
53
  }
55
54
  });
@@ -1,5 +1,4 @@
1
1
  import withFocusable, { WithFocusableProps } from './withFocusable';
2
- import { InitOptions, KeyMap } from './spatialNavigation';
3
- declare const destroy: () => void, pause: () => void, resume: () => void, setFocus: (targetFocusKey: string, details?: Record<string, any>) => void, init: ({ debug, visualDebug, nativeMode, throttle, throttleKeypresses, }?: InitOptions) => void, setKeyMap: (keyMap: KeyMap) => void;
4
- export { withFocusable, init, setKeyMap, destroy, pause, resume, setFocus };
2
+ import SpatialNavigation, { InitOptions, KeyMap } from './spatialNavigation';
3
+ export { withFocusable, SpatialNavigation };
5
4
  export { InitOptions, KeyMap, WithFocusableProps };
@@ -1,4 +1,3 @@
1
1
  import withFocusable from './withFocusable';
2
2
  import SpatialNavigation from './spatialNavigation';
3
- const { destroy, pause, resume, setFocus, init, setKeyMap } = SpatialNavigation;
4
- export { withFocusable, init, setKeyMap, destroy, pause, resume, setFocus };
3
+ export { withFocusable, SpatialNavigation };
@@ -72,7 +72,6 @@ declare class SpatialNavigation {
72
72
  private focusableComponents;
73
73
  private focusKey;
74
74
  private parentsHavingFocusedChild;
75
- private enabled;
76
75
  private nativeMode;
77
76
  private throttle;
78
77
  private throttleKeypresses;
@@ -105,7 +104,7 @@ declare class SpatialNavigation {
105
104
  * They used as a base to measure adjacent slices
106
105
  */
107
106
  sortSiblingsByPriority(siblings: FocusableComponent[], currentLayout: Layout, direction: Direction, _focusKey: string): FocusableComponent[];
108
- constructor();
107
+ constructor(options?: InitOptions);
109
108
  init({ debug, visualDebug, nativeMode, throttle, throttleKeypresses, }?: InitOptions): void;
110
109
  startDrawLayouts(): void;
111
110
  destroy(): void;
@@ -153,5 +152,4 @@ declare class SpatialNavigation {
153
152
  /**
154
153
  * Export singleton
155
154
  */
156
- declare const _default: SpatialNavigation;
157
- export default _default;
155
+ export default SpatialNavigation;
@@ -235,7 +235,7 @@ class SpatialNavigation {
235
235
  return aPriority - bPriority;
236
236
  });
237
237
  }
238
- constructor() {
238
+ constructor(options = {}) {
239
239
  Object.defineProperty(this, "focusableComponents", {
240
240
  enumerable: true,
241
241
  configurable: true,
@@ -254,12 +254,6 @@ class SpatialNavigation {
254
254
  writable: true,
255
255
  value: void 0
256
256
  });
257
- Object.defineProperty(this, "enabled", {
258
- enumerable: true,
259
- configurable: true,
260
- writable: true,
261
- value: void 0
262
- });
263
257
  Object.defineProperty(this, "nativeMode", {
264
258
  enumerable: true,
265
259
  configurable: true,
@@ -329,12 +323,11 @@ class SpatialNavigation {
329
323
  this.focusableComponents = {};
330
324
  this.focusKey = null;
331
325
  this.parentsHavingFocusedChild = [];
332
- this.enabled = false;
333
326
  this.nativeMode = false;
334
327
  this.throttle = 0;
335
328
  this.throttleKeypresses = false;
336
329
  this.pressedKeys = {};
337
- this.paused = false;
330
+ this.paused = true;
338
331
  this.keyDownEventListener = null;
339
332
  this.keyUpEventListener = null;
340
333
  this.keyMap = DEFAULT_KEY_MAP;
@@ -349,22 +342,20 @@ class SpatialNavigation {
349
342
  this.navigateByDirection = this.navigateByDirection.bind(this);
350
343
  this.init = this.init.bind(this);
351
344
  this.setKeyMap = this.setKeyMap.bind(this);
345
+ this.init(options);
352
346
  }
353
347
  init({ debug = false, visualDebug = false, nativeMode = false, throttle = 0, throttleKeypresses = false, } = {}) {
354
- if (!this.enabled) {
355
- this.enabled = true;
356
- this.nativeMode = nativeMode;
357
- this.throttleKeypresses = throttleKeypresses;
358
- this.debug = debug;
359
- if (!this.nativeMode) {
360
- if (Number.isInteger(throttle) && throttle > 0) {
361
- this.throttle = throttle;
362
- }
363
- this.bindEventHandlers();
364
- if (visualDebug) {
365
- this.visualDebugger = new VisualDebugger();
366
- this.startDrawLayouts();
367
- }
348
+ this.nativeMode = nativeMode;
349
+ this.throttleKeypresses = throttleKeypresses;
350
+ this.debug = debug;
351
+ if (!this.nativeMode) {
352
+ if (Number.isInteger(throttle) && throttle > 0) {
353
+ this.throttle = throttle;
354
+ }
355
+ this.bindEventHandlers();
356
+ if (visualDebug) {
357
+ this.visualDebugger = new VisualDebugger();
358
+ this.startDrawLayouts();
368
359
  }
369
360
  }
370
361
  }
@@ -381,18 +372,7 @@ class SpatialNavigation {
381
372
  draw();
382
373
  }
383
374
  destroy() {
384
- if (this.enabled) {
385
- this.enabled = false;
386
- this.nativeMode = false;
387
- this.throttle = 0;
388
- this.throttleKeypresses = false;
389
- this.focusKey = null;
390
- this.parentsHavingFocusedChild = [];
391
- this.focusableComponents = {};
392
- this.paused = false;
393
- this.keyMap = DEFAULT_KEY_MAP;
394
- this.unbindEventHandlers();
395
- }
375
+ this.unbindEventHandlers();
396
376
  }
397
377
  getEventType(keyCode) {
398
378
  return Object.keys(this.getKeyMap()).find((key) => this.getKeyMap()[key].includes(keyCode));
@@ -806,6 +786,15 @@ class SpatialNavigation {
806
786
  this.focusableComponents[focusKey].onBecameBlurredHandler?.(this.getNodeLayoutByFocusKey(focusKey), details);
807
787
  }
808
788
  pause() {
789
+ this.focusKey = null;
790
+ this.parentsHavingFocusedChild = [];
791
+ this.pressedKeys = {};
792
+ this.log('pause', 'paused');
793
+ this.visualDebugger?.clear();
794
+ this.visualDebugger?.clearLayouts();
795
+ this.getFocusableComponents().forEach((component) => {
796
+ component.onUpdateFocus?.(false);
797
+ });
809
798
  this.paused = true;
810
799
  }
811
800
  resume() {
@@ -872,4 +861,4 @@ class SpatialNavigation {
872
861
  /**
873
862
  * Export singleton
874
863
  */
875
- export default new SpatialNavigation();
864
+ export default SpatialNavigation;
@@ -34,6 +34,7 @@ export interface WithFocusableState {
34
34
  declare const withFocusable: <P extends object>({ forgetLastFocusedChild: configForgetLastFocusedChild, trackChildren: configTrackChildren, autoRestoreFocus: configAutoRestoreFocus, blockNavigationOut: configBlockNavigationOut, }?: WithFocusableConfig) => (WrappedComponent: import("react").ComponentType<P & WithFocusableProps>) => {
35
35
  new (props?: (P & WithFocusableProps) | undefined, context?: any): {
36
36
  state: WithFocusableState;
37
+ navigation: import("./spatialNavigation").default;
37
38
  getChildContext(): {
38
39
  parentFocusKey: string;
39
40
  };
@@ -2,7 +2,8 @@
2
2
  import { findDOMNode } from 'react-dom';
3
3
  import PropTypes from 'prop-types';
4
4
  import { Component, createElement } from 'react';
5
- import SpatialNavigation, { ROOT_FOCUS_KEY } from './spatialNavigation';
5
+ import { ROOT_FOCUS_KEY } from './spatialNavigation';
6
+ import SDK from '@/index';
6
7
  // Helper functions to replace lodash and recompose
7
8
  const uniqueId = (prefix) => `${prefix}${Math.random().toString(36).substr(2, 9)}`;
8
9
  const noop = () => { };
@@ -28,13 +29,19 @@ const withFocusable = ({ forgetLastFocusedChild: configForgetLastFocusedChild =
28
29
  parentFocusKey: this.props.parentFocusKey || ROOT_FOCUS_KEY,
29
30
  }
30
31
  });
32
+ Object.defineProperty(this, "navigation", {
33
+ enumerable: true,
34
+ configurable: true,
35
+ writable: true,
36
+ value: SDK.getMaestroEventViewModel().navigation
37
+ });
31
38
  Object.defineProperty(this, "setFocus", {
32
39
  enumerable: true,
33
40
  configurable: true,
34
41
  writable: true,
35
42
  value: (focusKey) => {
36
- if (!SpatialNavigation.isNativeMode()) {
37
- SpatialNavigation.setFocus(focusKey);
43
+ if (!this.navigation.isNativeMode()) {
44
+ this.navigation.setFocus(focusKey);
38
45
  }
39
46
  }
40
47
  });
@@ -42,14 +49,14 @@ const withFocusable = ({ forgetLastFocusedChild: configForgetLastFocusedChild =
42
49
  enumerable: true,
43
50
  configurable: true,
44
51
  writable: true,
45
- value: SpatialNavigation.navigateByDirection
52
+ value: this.navigation.navigateByDirection
46
53
  });
47
54
  Object.defineProperty(this, "stealFocus", {
48
55
  enumerable: true,
49
56
  configurable: true,
50
57
  writable: true,
51
58
  value: () => {
52
- SpatialNavigation.setFocus(this.state.realFocusKey, {
59
+ this.navigation.setFocus(this.state.realFocusKey, {
53
60
  focusKey: this.state.realFocusKey,
54
61
  });
55
62
  }
@@ -134,7 +141,7 @@ const withFocusable = ({ forgetLastFocusedChild: configForgetLastFocusedChild =
134
141
  const { realFocusKey: focusKey, parentFocusKey } = this.state;
135
142
  const { preferredChildFocusKey, forgetLastFocusedChild = false, trackChildren, focusable = true, autoRestoreFocus = true, blockNavigationOut = false, } = this.props;
136
143
  let node;
137
- if (SpatialNavigation.isNativeMode()) {
144
+ if (this.navigation.isNativeMode()) {
138
145
  node = document.createElement('div');
139
146
  }
140
147
  else {
@@ -144,7 +151,7 @@ const withFocusable = ({ forgetLastFocusedChild: configForgetLastFocusedChild =
144
151
  }
145
152
  node = domNode;
146
153
  }
147
- SpatialNavigation.addFocusable({
154
+ this.navigation.addFocusable({
148
155
  focusKey,
149
156
  node,
150
157
  parentFocusKey,
@@ -170,7 +177,7 @@ const withFocusable = ({ forgetLastFocusedChild: configForgetLastFocusedChild =
170
177
  const { realFocusKey: focusKey } = this.state;
171
178
  const { preferredChildFocusKey, focusable = true, blockNavigationOut = false, } = this.props;
172
179
  let node;
173
- if (SpatialNavigation.isNativeMode()) {
180
+ if (this.navigation.isNativeMode()) {
174
181
  node = document.createElement('div');
175
182
  }
176
183
  else {
@@ -180,7 +187,7 @@ const withFocusable = ({ forgetLastFocusedChild: configForgetLastFocusedChild =
180
187
  }
181
188
  node = domNode;
182
189
  }
183
- SpatialNavigation.updateFocusable(focusKey, {
190
+ this.navigation.updateFocusable(focusKey, {
184
191
  node,
185
192
  preferredChildFocusKey,
186
193
  focusable,
@@ -189,7 +196,7 @@ const withFocusable = ({ forgetLastFocusedChild: configForgetLastFocusedChild =
189
196
  }
190
197
  componentWillUnmount() {
191
198
  const { realFocusKey: focusKey } = this.state;
192
- SpatialNavigation.removeFocusable({ focusKey });
199
+ this.navigation.removeFocusable({ focusKey });
193
200
  }
194
201
  render() {
195
202
  const props = {