@decky/ui 4.7.4 → 4.8.0
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/dist/components/Modal.js
CHANGED
|
@@ -5,7 +5,7 @@ export const showModal = (modal, parent, props = {
|
|
|
5
5
|
strTitle: 'Decky Dialog',
|
|
6
6
|
bHideMainWindowForPopouts: false,
|
|
7
7
|
}) => {
|
|
8
|
-
return showModalRaw(modal, parent || findSP(), props.strTitle, props, undefined, {
|
|
8
|
+
return showModalRaw(modal, parent || findSP() || window, props.strTitle, props, undefined, {
|
|
9
9
|
bHideActions: props.bHideActionIcons,
|
|
10
10
|
});
|
|
11
11
|
};
|
package/dist/modules/Router.js
CHANGED
|
@@ -71,8 +71,8 @@ try {
|
|
|
71
71
|
logger.warn("Navigation interface failed to call GetFocusedWindowInstance", e);
|
|
72
72
|
}
|
|
73
73
|
if (!win) {
|
|
74
|
-
logger.warn("Navigation interface could not find any focused window. Falling back to
|
|
75
|
-
win = Router.WindowStore?.GamepadUIMainWindowInstance;
|
|
74
|
+
logger.warn("Navigation interface could not find any focused window. Falling back to Main Window Instance");
|
|
75
|
+
win = Router.WindowStore?.GamepadUIMainWindowInstance || Router?.WindowStore?.SteamUIWindows?.[0];
|
|
76
76
|
}
|
|
77
77
|
if (win) {
|
|
78
78
|
try {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { Ref } from 'react';
|
|
2
3
|
declare global {
|
|
3
4
|
interface Window {
|
|
4
5
|
SP_REACT: typeof React;
|
|
@@ -19,3 +20,5 @@ export interface findInTreeOpts {
|
|
|
19
20
|
export declare type findInTreeFilter = (element: any) => boolean;
|
|
20
21
|
export declare const findInTree: (parent: any, filter: findInTreeFilter, opts: findInTreeOpts) => any;
|
|
21
22
|
export declare const findInReactTree: (node: any, filter: findInTreeFilter) => any;
|
|
23
|
+
export declare function getParentWindow<WindowType = Window>(elem: HTMLElement | null): WindowType | null | undefined;
|
|
24
|
+
export declare function useWindowRef<RefElementType extends HTMLElement, WindowType = Window>(): [Ref<RefElementType>, WindowType | null | undefined];
|
|
@@ -2,6 +2,7 @@ var __setFunctionName = (this && this.__setFunctionName) || function (f, name, p
|
|
|
2
2
|
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
|
3
3
|
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
|
4
4
|
};
|
|
5
|
+
import { useState } from 'react';
|
|
5
6
|
export function createPropListRegex(propList, fromStart = true) {
|
|
6
7
|
let regexString = fromStart ? "const\{" : "";
|
|
7
8
|
propList.forEach((prop, propIdx) => {
|
|
@@ -98,3 +99,10 @@ export const findInTree = (parent, filter, opts) => {
|
|
|
98
99
|
export const findInReactTree = (node, filter) => findInTree(node, filter, {
|
|
99
100
|
walkable: ['props', 'children', 'child', 'sibling'],
|
|
100
101
|
});
|
|
102
|
+
export function getParentWindow(elem) {
|
|
103
|
+
return elem?.ownerDocument?.defaultView;
|
|
104
|
+
}
|
|
105
|
+
export function useWindowRef() {
|
|
106
|
+
const [win, setWin] = useState(null);
|
|
107
|
+
return [(elem) => setWin(getParentWindow(elem)), win];
|
|
108
|
+
}
|
package/package.json
CHANGED
package/src/components/Modal.ts
CHANGED
|
@@ -50,7 +50,7 @@ export const showModal = (
|
|
|
50
50
|
bHideMainWindowForPopouts: false,
|
|
51
51
|
},
|
|
52
52
|
): ShowModalResult => {
|
|
53
|
-
return showModalRaw(modal, parent || findSP(), props.strTitle, props, undefined, {
|
|
53
|
+
return showModalRaw(modal, parent || findSP() || window, props.strTitle, props, undefined, {
|
|
54
54
|
bHideActions: props.bHideActionIcons,
|
|
55
55
|
});
|
|
56
56
|
};
|
package/src/modules/Router.ts
CHANGED
|
@@ -144,8 +144,8 @@ try {
|
|
|
144
144
|
logger.warn("Navigation interface failed to call GetFocusedWindowInstance", e);
|
|
145
145
|
}
|
|
146
146
|
if (!win) {
|
|
147
|
-
logger.warn("Navigation interface could not find any focused window. Falling back to
|
|
148
|
-
win = Router.WindowStore?.GamepadUIMainWindowInstance;
|
|
147
|
+
logger.warn("Navigation interface could not find any focused window. Falling back to Main Window Instance");
|
|
148
|
+
win = Router.WindowStore?.GamepadUIMainWindowInstance || Router?.WindowStore?.SteamUIWindows?.[0];
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
if (win) {
|
package/src/utils/react/react.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { Ref, useState } from 'react';
|
|
2
3
|
|
|
3
4
|
// this shouldn't need to be redeclared but it does for some reason
|
|
4
5
|
|
|
@@ -150,3 +151,21 @@ export const findInReactTree = (node: any, filter: findInTreeFilter) =>
|
|
|
150
151
|
// Specialised findInTree for React nodes
|
|
151
152
|
walkable: ['props', 'children', 'child', 'sibling'],
|
|
152
153
|
});
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Finds the parent window of a DOM element
|
|
157
|
+
*/
|
|
158
|
+
export function getParentWindow<WindowType = Window>(elem: HTMLElement | null): WindowType | null | undefined {
|
|
159
|
+
return elem?.ownerDocument?.defaultView as any;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* React hook to find the host window of a component
|
|
164
|
+
* Pass the returned ref into a React element and window will be its host window.
|
|
165
|
+
* @returns [ref, window]
|
|
166
|
+
*/
|
|
167
|
+
export function useWindowRef<RefElementType extends HTMLElement, WindowType = Window>(): [Ref<RefElementType>, WindowType | null | undefined] {
|
|
168
|
+
const [win, setWin] = useState<WindowType | null | undefined>(null);
|
|
169
|
+
|
|
170
|
+
return [(elem) => setWin(getParentWindow<WindowType>(elem)), win];
|
|
171
|
+
}
|