@decky/ui 4.8.1 → 4.8.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.
@@ -31,11 +31,11 @@ export declare enum GamepadButton {
31
31
  STEAM_QUICK_MENU = 28
32
32
  }
33
33
  export declare enum NavEntryPositionPreferences {
34
- FIRST,
35
- LAST,
36
- MAINTAIN_X,
37
- MAINTAIN_Y,
38
- PREFERRED_CHILD
34
+ FIRST = 0,
35
+ LAST = 1,
36
+ MAINTAIN_X = 2,
37
+ MAINTAIN_Y = 3,
38
+ PREFERRED_CHILD = 4
39
39
  }
40
40
  export interface GamepadEventDetail {
41
41
  button: number;
@@ -47,6 +47,8 @@ export declare type ActionDescriptionMap = {
47
47
  };
48
48
  export declare type GamepadEvent = CustomEvent<GamepadEventDetail>;
49
49
  export interface FooterLegendProps {
50
+ navEntryPreferPosition?: NavEntryPositionPreferences;
51
+ preferredFocus?: boolean;
50
52
  actionDescriptionMap?: ActionDescriptionMap;
51
53
  onOKActionDescription?: ReactNode;
52
54
  onCancelActionDescription?: ReactNode;
@@ -30,3 +30,11 @@ export var GamepadButton;
30
30
  GamepadButton[GamepadButton["STEAM_GUIDE"] = 27] = "STEAM_GUIDE";
31
31
  GamepadButton[GamepadButton["STEAM_QUICK_MENU"] = 28] = "STEAM_QUICK_MENU";
32
32
  })(GamepadButton || (GamepadButton = {}));
33
+ export var NavEntryPositionPreferences;
34
+ (function (NavEntryPositionPreferences) {
35
+ NavEntryPositionPreferences[NavEntryPositionPreferences["FIRST"] = 0] = "FIRST";
36
+ NavEntryPositionPreferences[NavEntryPositionPreferences["LAST"] = 1] = "LAST";
37
+ NavEntryPositionPreferences[NavEntryPositionPreferences["MAINTAIN_X"] = 2] = "MAINTAIN_X";
38
+ NavEntryPositionPreferences[NavEntryPositionPreferences["MAINTAIN_Y"] = 3] = "MAINTAIN_Y";
39
+ NavEntryPositionPreferences[NavEntryPositionPreferences["PREFERRED_CHILD"] = 4] = "PREFERRED_CHILD";
40
+ })(NavEntryPositionPreferences || (NavEntryPositionPreferences = {}));
@@ -13,7 +13,7 @@ export function findSP() {
13
13
  if (document.title == 'SP')
14
14
  return window;
15
15
  const navTrees = getGamepadNavigationTrees();
16
- return navTrees?.find((x) => x.m_ID == 'root_1_')?.Root?.Element?.ownerDocument?.defaultView;
16
+ return navTrees?.find((x) => x.m_ID == 'GamepadUI_Full_Root' || x.m_ID == 'root_1_')?.Root?.Element?.ownerDocument?.defaultView;
17
17
  }
18
18
  export function getFocusNavController() {
19
19
  return window.GamepadNavTree?.m_context?.m_controller || window.FocusNavController;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decky/ui",
3
- "version": "4.8.1",
3
+ "version": "4.8.3",
4
4
  "description": "A library for interacting with the Steam frontend in Decky plugins and elsewhere.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -31,11 +31,42 @@ export enum GamepadButton {
31
31
  STEAM_GUIDE,
32
32
  STEAM_QUICK_MENU,
33
33
  }
34
- export declare enum NavEntryPositionPreferences {
34
+ export enum NavEntryPositionPreferences {
35
+ /**
36
+ * Always give focus to the first child element.
37
+ */
35
38
  FIRST,
39
+
40
+ /**
41
+ * Always give focus to the last child element.
42
+ */
36
43
  LAST,
44
+
45
+ /**
46
+ * Give focus to the child element that would maintain the flow in the X axis.
47
+ *
48
+ * Imagine you have a calculator window with 9 standard buttons.
49
+ * You have 3 rows of buttons, with 3 buttons per row.
50
+ * If you select button with number 8 and navigate down, the buttons
51
+ * will be navigated in the following order 8->5->3.
52
+ * The flow is maintained for the X axis while you're navigating the Y axis.
53
+ */
37
54
  MAINTAIN_X,
55
+
56
+ /**
57
+ * Give focus to the child element that would maintain the flow in the Y axis.
58
+ *
59
+ * Imagine you have a calculator window with 9 standard buttons.
60
+ * You have 3 columns of buttons, with 3 buttons per column.
61
+ * If you select button with number 4 and navigate right, the buttons
62
+ * will be navigated in the following order 4->5->6.
63
+ * The flow is maintained for the Y axis while you're navigating the X axis.
64
+ */
38
65
  MAINTAIN_Y,
66
+
67
+ /**
68
+ * Give focus to the first child element with `preferredFocus == true` prop.
69
+ */
39
70
  PREFERRED_CHILD,
40
71
  }
41
72
  export interface GamepadEventDetail {
@@ -48,6 +79,25 @@ export declare type ActionDescriptionMap = {
48
79
  };
49
80
  export declare type GamepadEvent = CustomEvent<GamepadEventDetail>;
50
81
  export interface FooterLegendProps {
82
+ /**
83
+ * Navigation entry strategy to be used when gaining focus during navigation.
84
+ *
85
+ * This is meant to be used on a parent container that has children. Once the
86
+ * container (e.g. Focusable) is navigated to and has children in it, the children
87
+ * is then navigated to (focused) using the provided strategy.
88
+ *
89
+ * If no strategy is provided, it seems that the `NavEntryPositionPreferences.FIRST`
90
+ * is used initialy, but for the next time the parent remembers previously focused
91
+ * child and focused back on it instead.
92
+ */
93
+ navEntryPreferPosition?: NavEntryPositionPreferences;
94
+
95
+ /**
96
+ * Mark the element as the preferred child (to be focused) whenever the parent uses the
97
+ * `NavEntryPositionPreferences.PREFERRED_CHILD` navigation strategy.
98
+ */
99
+ preferredFocus?: boolean;
100
+
51
101
  actionDescriptionMap?: ActionDescriptionMap;
52
102
  onOKActionDescription?: ReactNode;
53
103
  onCancelActionDescription?: ReactNode;
@@ -25,7 +25,7 @@ export function findSP(): Window {
25
25
  if (document.title == 'SP') return window;
26
26
  // new (SP as popup)
27
27
  const navTrees = getGamepadNavigationTrees();
28
- return navTrees?.find((x: any) => x.m_ID == 'root_1_')?.Root?.Element?.ownerDocument?.defaultView;
28
+ return navTrees?.find((x: any) => x.m_ID == 'GamepadUI_Full_Root' || x.m_ID == 'root_1_')?.Root?.Element?.ownerDocument?.defaultView;
29
29
  }
30
30
 
31
31
  /**